CPC Basic

Basic cross-compiler for Amstad CPC


    Double Buffering in CPC BASIC 3

    Out Bush
    Out Bush

    Posts : 8
    Join date : 2019-12-02

    Double Buffering in CPC BASIC 3 Empty Double Buffering in CPC BASIC 3

    Post  Out Bush on Sat Jan 18, 2020 8:44 pm

    I was able to create a Double Buffer example using Locomotive BASIC and a little Sprite Driver I created, but am having problems with it.

    I've setup CPC BASIC 3, so it generates an Assembly file, I can then modify the Assembly file, so the Code is relocated to &8000, leaving the Screen at &4000 available, I can then Assemble using the incliuded Pasmo Assembler, but I use Winape which lets me Pause and Load the Object file on the Debugger screen.

    Like my earlier version I was trying to have working with Locomotive BASIC, the problem occurs when I try to move the Ball up the screen, I thought that perhaps some adjustments I'd made in this version from the original Locomotive would get it working, but it's not quite as clear cut.

    Code:
    100 DEFWORD a-z:GOSUB 2000
    110 MODE 0:BORDER 0:INK 0,3:INK 1,26:INK 2,21
    120 CALL &A02E:CLS:CALL &A028:CLS:CALL &A02E
    130 sc=2:x1=40:oy=720:ox=40
    140 i=720:i1=720:y1=720
    150 GOSUB 1310
    160 WHILE 1
    170  IF INKEY(2)=0 THEN IF y1<>1920 THEN GOSUB 1110
    180  IF INKEY(0)=0 THEN IF y1>0 THEN GOSUB 1140
    190  IF INKEY(1)=0 THEN IF x1<>76 THEN GOSUB 1170
    200  IF INKEY(8)=0 THEN IF x1>0 THEN GOSUB 1200
    210 WEND
    220 END
    800 ' Move Down
    810 IF y1>&3FFF THEN i1=i+&50:i=i+&50:y1=i1
    820 GOSUB 1410:GOSUB 1510
    830 RETURN
    840 IF y1>&3FFF THEN i1=i+&50:i=i+&50:y1=i1
    850 GOSUB 1610:GOSUB 1310
    860 RETURN
    900 ' Move Up
    910 IF y1<2 THEN i2=i+&37B0:i=i-&50:y1=i2
    920 GOSUB 1410:GOSUB 1510
    930 RETURN
    940 IF y1<2 THEN i2=i+&37B0:i=i-&50:y1=i2
    950 GOSUB 1610:GOSUB 1310
    960 RETURN
    1000 ' Move Right
    1010 GOSUB 1410:GOSUB 1510
    1020 RETURN
    1050 ' Move Left
    1060 GOSUB 1610:GOSUB 1310
    1070 RETURN
    1100 ' Check Screen Status and Move accordingly
    1110 IF sc=1 THEN oy=z:y1=y1+&800:GOSUB 810:sc=2:RETURN
    1120 IF sc=2 THEN oy=z:y1=y1+&800:GOSUB 840:sc=1:RETURN
    1130 RETURN
    1140 IF sc=1 THEN oy=z:y1=y1-&800:GOSUB 910:sc=2:RETURN
    1150 IF sc=2 THEN oy=z:y1=y1-&800:GOSUB 940:sc=1:RETURN
    1160 RETURN
    1170 IF sc=1 THEN ox=w:x1=x1+1:GOSUB 1010:sc=2:CALL &BD19:RETURN
    1180 IF sc=2 THEN ox=w:x1=x1+1:GOSUB 1060:sc=1:CALL &BD19:RETURN
    1190 RETURN
    1200 IF sc=1 THEN ox=w:x1=x1-1:GOSUB 1010:sc=2:CALL &BD19:RETURN
    1210 IF sc=2 THEN ox=w:x1=x1-1:GOSUB 1060:sc=1:CALL &BD19:RETURN
    1220 RETURN
    1300 ' Draw screen to &4000
    1310 s=&4000
    1320 z=y1
    1330 w=x1
    1340 CALL &A000,&A036,(s+z)+w
    1350 CALL &A028
    1360 RETURN
    1400 ' Clear Screen at &C000
    1410 s=&C000
    1420 oz=oy
    1430 ow=ox
    1440 CALL &A000,&A056,(s+oz)+ow
    1450 RETURN
    1500 ' Draw screen at &C000
    1510 s=&C000
    1520 z=y1
    1530 w=x1
    1540 CALL &A000,&A036,(s+z)+w
    1550 CALL &A02E
    1560 RETURN
    1600 ' Clear Screeb at &4000
    1610 s=&4000
    1620 oz=oy
    1630 ow=ox
    1640 CALL &A000,&A056,(s+oz)+ow
    1650 RETURN
    2000 addr=&A000
    2010 FOR ln=1 TO 7
    2020 READ a$
    2030 FOR p=1 TO 31 STEP 2
    2040 POKE addr,VAL("&"+MID$(a$,p,2))
    2050 addr=addr+1
    2060 NEXT p:NEXT ln
    2070 RETURN
    2100 DATA DD6E02DD6603EBDD6E00DD66012234A0
    2110 DATA 0608C506041A77132310FA2A34A0CD26
    2120 DATA BC2234A0C110EBC93E40CD08BCC93EC0
    2130 DATA CD08BCC900C000000000004080000084
    2140 DATA 48000084480000844800008448000040
    2150 DATA 80000000000000000000000000000000
    2170 DATA 00000000000000000000000000000000

      Current date/time is Tue Feb 18, 2020 3:24 am