rem ----------------------------------------- rem *** BREAKOUT ADVENTURE Version2 rem *** FEATURING THE BALL AS PLAYER 1 rem *** AND THE ATARI LOGO AS PLAYER 2 rem ----------------------------------------- rem *** Hit enough blocks to clear the board rem *** The Camera only follows Player 1, rem *** and the AI can control player 2 rem ----------------------------------------- rem ----------------------------------------- rem ---init section, runs once: ------------- rem ----------------------------------------- rem ----------------------------------------- f=0:t=0:g=3:u=5:x=5:y=5:v=6:w=0:z=0:m=0:r=16:p=2:q=2:h=112:l=0:k=0:n=0:score=0 rem loadplayer0(104) COLUPF=$3A: rem COLUPF=$be COLUP0=$54 rem vwpixel(x,y,bindplayer0):vwpixel(u,v,bindplayer1) NUSIZ1=%00011111 setuproutine rem ---- can call this scrollvirtualworldtoggle=1:rem refresh cam after drawing on virtual world for i = 13 to 19 step 2 for j = 3 to 5 vwpixel(i,j,on) next j,i for i= 91 to 13 step -2 for j = 7 to 12 vwpixel (i,j,on) next j,i rem ------------------------------------------------ rem end init section (implicit return)-------------- rem ------------------------------------------------ rem ------------------------------------------------ rem ------------------------------------------------ rem ---:the next comment line is used by the compiler rem ---gameloop subroutine, runs every frame: --- rem ------------------------------------------------ rem ------------------------------------------------ rem vars t-toggle x,y f-frame g - direction (12345678, 1 is up) rem varx u,v (p1 xy), r - marquee in center of virtual world index rem w, z dir x/y, : p,q dir p1 x/y, m - musical pixels p0 rem i,j,e - temp vars for loops, expressions rem l used by scroll, k, n too. rem TinyBASIC program rem --------------------------------------------------- t=1-t:rem this expression toggles var t between 0 and 1 rem if t=1 then return:rem half speed option rem --------------------------------------------------- rem ------- four loads, split every 16 frames rem can split them again using t for sprite multiplexing f=f+1 if f=1 then goto framehandler1 if f=2 then goto framehandler2 if f=3 then goto framehandler3 if f=4 then f=0: goto framehandler4 return:rem never gets here rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem ------------------------------------------------------------- framehandler1 rem ---------------------------- start framehandler1 rem ------------------------------------------------------------- rem ------------------------------------------------------------- vwpixel(x,y,bindplayer0) vwpixel(u,v,bindplayer1) rem --- player 1 action/input: rem z=0:w=0 rem COLUP0=$84 if joy0left=1 then w=1 if w=1 and x>0 then x=x-1 if joy0right=1 then w=2 if w=2 and x<91 then x=x+1 if joy0up=1 then z=1 if z=1 and y>0 then y=y-1 if joy0down=1 then z=2 if z=2 and y<19 then y=y+1 loadplayer0(104) REFP0=0: rem face forward, default incommming if x=0 and w=1 then w=2: rem flip direction if at border of virtual world if x=91 and w=2 then w=1 if z=1 and y=0 then z=2 if z=2 and y=19 then z=1 if vwpixel(x,y,poll)=0 then return if w=1 and z=1 then z=2:goto jmpxif :rem if left and up go down and left if w=2 and z=1 then z=2:goto jmpxif:rem if right and up go down and right if w=1 and z=2 then z=1:goto jmpxif:rem if left and down go left and up if w=2 and z=2 then z=1 : rem if right and down then right and up jmpxif vwpixel(x,y,flip):rem pixel destroyed, take over one voice; fx with the music: AUDC0=ballwaveform(m):rem ball wave AUDF0=ballmusic(m):rem ball music if m>9 then m=0 else m=m+1 SUSTAINFORFRAMES=10 score=score+1 rem ------------------------------------------------------------- rem ------------------------------------------------------------- return: rem ---------end framehandler1 rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem ------------------------------------------------------------- framehandler2 rem ----------------------------- start framehander2 rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem COLUP0=$64 REFP0=255:rem player face backwards rem COLUP1=68:REFP1=0: rem player face forward rem ------------------------------------------------------------- rem ------------------------------------------------------------- return : rem -------------end framehandler2 rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem ------------------------------------------------------------- framehandler3 rem ----------------------------- start framehander3 rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem COLUP0=$44 loadplayer0upsidedown(104): rem player upsidedown rem player2 action/input: rem q=0:p=0 if joy1left=1 then p=1 if p=1 and u>0 then u=u-1 if joy1right=1 then p=2 if p=2 and u<91 then u=u+1 if joy1up=1 then q=1 if q=1 and v>0 then v=v-1 if joy1down=1 then q=2 if q=2 and v<19 then v=v+1 rem REFP1=0: rem face forward, default incommming if u=0 and p=1 then p=2: rem flip direction if at border of virtual world if u=91 and p=2 then p=1 if q=1 and v=0 then q=2 if q=2 and v=19 then q=1 if vwpixel(u,v,poll)=0 then return if p=1 and q=1 then q=2:goto jmpxif2 :rem if left and up go down and left if p=2 and q=1 then q=2:goto jmpxif2:rem if right and up go down and right if p=1 and q=2 then q=1:goto jmpxif2:rem if left and down go left and up if p=2 and q=2 then q=1 : rem if right and down then right and up jmpxif2 vwpixel(u,v,flip):rem pixel destroyed, take over one voice; fx with the music: rem unless both players have simultaneous hits - then both fx AUDC1=ballwaveform2(m):rem ball wave AUDF1=ballmusic2(m):rem ball music if m>9 then m=0 else m=m+1 SUSTAINFORFRAMES=10 rem ------------------------------------------------------------- rem ------------------------------------------------------------- return : rem -------------end framehandler3 rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem ------------------------------------------------------------- framehandler4 rem --------------------------- start frame handler4 rem ------------------------------------------------------------- rem ------------------------------------------------------------- REFP0=0: rem player face forward rem COLUP1=50:REFP1=255:rem player face backwards rem ------------------------------------------------ rem ------pan the camera to follow player 1: rem ------------------------------------------------ if x-BITIndex > 12 and BITIndex < 72 then BITIndex=BITIndex+1:scrollvirtualworldtoggle=1 if x < BITIndex+10 and BITIndex>0 then BITIndex=BITIndex-1:scrollvirtualworldtoggle=1 rem -----pan camera vertically (BYTErowoffset) if player is near the edge of the playfield CAM rem i = y*12: rem "read i(fastyindex,y)" is faster (12 step lookup table for virtual world y values) i=fastyindex(y): rem index the y*12 lookup table if BYTErowoffset<120 and BYTErowoffset+3636 then i=i-36 if BYTErowoffset>i then BYTErowoffset=BYTErowoffset-12:scrollvirtualworldtoggle=1 rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem ----------end framehandler4 rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem ------------------------------------------------ rem end game loop (implicit return)----------------- rem ------------------------------------------------ rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem ---:the next comment line is used by the compiler rem ---gameloop2 subroutine, runs every frame: -- rem ------------------------------------------------ rem ------------------------------------------------------------- rem vars: h - sliding index for player 2 sprite message if l<>4 and l<>8 and l<>12 and l<>16 then goto scrollplayerdelay loadplayer1(h) h=h+1 if h>184 then h=112 scrollplayerdelay rem i=i+1:mazecolours(l)=i l=l+1 if l>16 then l=0:COLUP1=mazecolors(n):n=n+1 if n>16 then n=0 rem play 2nd or 3rd (60/90 MUSICINDEX) and clear board if enough blocks are destroyed: if score=255 then score=0:COLUPF=0:MUSICINDEX=90:for i=0 to 91:for j=0 to 19 step 3:vwpixel(i,j,on):next j,i:COLUPF=mazecolors(k):k=k+1 if k>16 then k=0 rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem end gameloop2 (implicit return)----------------- rem ------------------------------------------------ rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem ---:the next comment line is used by the compiler rem ---KITCHENSINK subroutine, runs when scrollvirtualworldtoggle=1 rem ------------------------------------------------ rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem run playfield central banner routine when scrolling: if r>84 then r=16 for j=0 to 19: rem --- slide sprite library array through virtual world array i=r+j e=fastyindex(j)+5: rem same as j*12+5, lookup table rem e=e+5 virtualworld(e)=sprites(i):push a slice of sprites array into world array next j r=r+20 rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem end KITCHENSINK (implicit return)---------------------------- rem ------------------------------------------------------------- rem ------------------------------------------------------------- rem Dynamic RAM array variables are initialised in data statements: data mazecolors $b0,$50,$60,$a0,$02,$40,$22,$c0,$92,$f4,$52,$a2,$d0,$f2,$70,$e2 rem -- player one block destroyed music: data ballwaveform 6,6,4,7,8,1,2,6,6,4,4,7 data ballmusic 2,4,6,8,10,12,14,16,18,20,9 rem ---- player2 block destroyed music: data ballwaveform2 4,4,4,4,4,4,4,6,6,4,4,7 data ballmusic2 11,9,12,4,7,0,11,14,18,20,9 virtualworld X.....................................X...X..X.........X..XXXX.....XXXXXX......XXXXXXXXXXXXX .X.......XXXXX........................X...X..X.........X..X..X....X......X.....X..........XX ..XX.........X........................X...X...X...X...X...XXXXX..X..X..X..X....X...XXXXXXXXX ....X........X.........................X.X.....X.X.X.X....X....X.X........X....X............ .....X.......X..........................X.......X...X.....XXXXXX.X.X....X.X....XXXXXXXXXX... ......X......X..........XXXXXXXXXX...............................X..XXXX..X.............X... .......X......X..................X................................X......X..............X... ........X.....X..................X.................................XXXXXX...............X... .........X.....X.............X...X..............................................XXXXXXXXX... ..........X...X..............X...X.......................................................... ...........X.X...............X...X..................................................XXXXXXXX ............X................X...XXXXXXXXX........................................XXX......X X............................X....................................................X........X .X.......XXXXX...............XXXXXXXXXXXXX........................................X...XXXXXX ..XX.........X........................................................................X..... ....X........X........................................................................X..... .....X.......X........................................................................X..... ......X......X........................................................................X..... .......X......X.......................................................................X..... X.......X.....XXXX....................................................................XXXXXX sprites 0 ..XXX... ..XXX... XXXXX.X. ..XX.XX. XXXX.X.. X.XXX... XX.XXX.. .XX.XXXX 8 .X.X.X.. ..XXXX.. X..XX... XXXXXX.. ...XX.XX ...XX... X.X..X.X .X....X. 16 ........ XX...XX. XX...XX. XXXXXXX. XXXXXXX. XX...XX. XX...XX. ........ 24 ........ ..XXX... .X...X.. .XXXXX.. .X...... .X...... ..XXXX.. ........ 32 ........ .XX..... .XX..... .XX..... .XX..... .XXXXX.. .XXXXX.. ........ 40 ........ .XX..... .XX..... .XX..... .XX..... .XXXXX.. .XXXXX.. ........ 48 ........ ..XXXX.. .XXX.XX. .XX..XX. .XX..XX. .XX.XXX. ..XXXX.. ........ 56 ........ ........ ........ ........ ........ ........ ........ ........ 64 ........ X......X X......X X..XX..X X..XX..X X.X..X.X XX....XX ........ 72 ........ ..XXXX.. .XXX.XX. .XX..XX. .XX..XX. .XX.XXX. ..XXXX.. ........ 80 ........ .XXXX... .XX..X.. .XXXX... .XX.X... .XX..X.. .XX..XXX ........ 88 ........ .XX..... .XX..... .XX..... .XX..... .XXXXX.. .XXXXX.. ........ 96 ........ .XXXX... .XX.XX.. .XX..XX. .XX..XX. .XX..XX. .XXXXX.. ........ 104 ........ ........ ...xx... ..x.xx.. .x..xxx. .x....x. ..x..x.. ...xx... 112 XXXXXX.. X...XX.. XXXXXX.. XX...X.. XX...X.. XX...X.. XX...X.. ........ 120 ........ ........ XXXXX... ..X..... ..X..... ..XX.... ..XX.... ..XX.... ........ 128 ........ XXXXXX.. X...XX.. XXXXXX.. XX...X.. XX...X.. XX...X.. ........ 136 ........ XXXXXX.. X...XX.. XXXXXXX. XX....X. XX....X. XX....X. ........ 144 ........ ........ ..X..... ..X..... ..XX.... ..XX.... ..XX.... ..XX.... ........ 152 ........ ........ .xxxxx.. .x...x.. .....x.. ..xxxx.. .xx..... .xx..... .xxxxx.. 160 ........ ........ .xxxxx.. .x...... .x...... .xxxxx.. .x...x.. .xx..x.. .xxxxx.. 168 ........ .xxxxxx. .xx...x. .xx...x. .xx...x .xx...x. .xxx..x. .xxxxxx. ........ 176 ........ .xxxxxx. .xx...x. .xx...x. .xx...x .xx...x. .xxx..x. .xxxxxx. ........ 184 ........ ........ ........ ........ ........ ........ ........ ........ chiptunes 7, 30, 0, 0, 8 7, 24, 0, 0, 8 7, 20, 0, 0, 8 12, 9, 12, 7, 22 12, 14, 12, 11, 22 6, 30, 0, 0, 20 6, 24, 6, 30, 10 6, 22, 6, 30, 10 6, 21, 6, 30, 20 12, 26, 12, 19, 20 0, 0, 0, 0, 254 0,0,0,0,0 15, 5, 15, 12, 10 15, 17, 15, 19, 10 15, 5, 15, 12, 10 15, 5, 15, 12, 15 0, 0, 0, 0, 255 29,23,5,10,0 7, 30, 0, 0, 68 7, 24, 0, 0, 8 7, 20, 0, 0, 8 7, 24, 0, 0, 7 30, 0, 0, 8, 17 24, 0, 0, 8, 7 20, 0, 0, 8, 17 24, 0, 0, 8, 7 22, 0, 0, 8, 20 6, 0, 4, 0, 255 27, 0, 0, 8, 15 24, 0, 0, 8, 17 24,24,24,24,0