set smartbranching on set romsize 32k set debug cyclescore dim frame=a dim readjoy=b rem bits 4-7 of b dim herox=c dim heroy=d dim baddie1x=e dim baddie1y=f dim baddie2x=g dim baddie2y=h dim baddie3x=i dim baddie3y=j dim flagx=k dim flagy=l dim objectdir=m dim mapx=n dim mapy=o dim p44=playfield+44 dim p45=playfield+45 dim p46=playfield+46 dim p47=playfield+47 COLUBK=2 mapx=10:mapy=44:rem position of the map on screen rem objectdir: 6,7=baddie3; 4,5=baddie2; 2,3=baddie1; 0,1=hero rem objectdir bits: 00=up, 01=down, 10=left, 11=right COLUPF=140 dim baddiemove=b rem bits 1-3 of b gosub pixels herox=87:heroy=48 baddie1x=57:baddie1y=88 baddie2x=87:baddie2y=88 baddie3x=103:baddie3y=88 flagx=44:flagy=68 missile0height=7:missile1height=7 ballheight=3 rem gosub up_player0 rem gosub up_player1 gameloop temp1=readjoy & %00001111: rem preserve lower bits temp2=SWCHA & %11110000 : rem just upper bits if temp2 <> 250 then temp6=rand:rem mess up randomizer readjoy=temp2 | temp1 : rem combine them if !readjoy{4} then goto down if !readjoy{5} then goto up if !readjoy{6} then goto left if !readjoy{7} then goto right goto donemoving down if pfread(15,4) then readjoy=readjoy | %11110000:goto donemoving rem set bits 5-7, clear bit 4 mapy=mapy-1 temp2=mapx temp1=mapy:gosub newscrolldataup temp1=readjoy & %00001111 readjoy=temp1 | %11100000 objectdir=objectdir & %11111100 goto donemoving up if pfread(15,6) then readjoy=readjoy | %11110000:goto donemoving mapy=mapy+1 temp2=mapx temp1=mapy+10:gosub newscrolldataup temp1=readjoy & %00001111 readjoy=temp1 | %11010000 objectdir=objectdir & %11111100 objectdir=objectdir | 1 goto donemoving left if pfread(13,5) then readjoy=readjoy | %11110000:goto donemoving mapx=mapx-1 rem temp2=mapx rem temp3=3 rem temp1=mapy:gosub newscrolldataleft temp1=readjoy & %00001111 readjoy=temp1 | %10110000 objectdir=objectdir & %11111100 objectdir=objectdir | 2 goto donemoving right if pfread(17,5) then readjoy=readjoy | %11110000:goto donemoving mapx=mapx+1 rem temp2=mapx+15 rem temp3=0 rem temp1=mapy:gosub newscrolldataleft temp1=readjoy & %00001111 readjoy=temp1 | %01110000 objectdir=objectdir | 3 donemoving temp1=rand:temp1=temp1 & %11111100 temp2=objectdir & %00000011 rem if baddies moved last time, keep moving same dir, otherwise change dir if baddiemove{1} then temp1=temp1 & %11110011:temp3=objectdir & %00001100:temp2=temp2 | temp3 if baddiemove{2} then temp1=temp1 & %11001111:temp3=objectdir & %00110000:temp2=temp2 | temp3 if baddiemove{3} then temp1=temp1 & %00111111:temp3=objectdir & %11000000:temp2=temp2 | temp3 objectdir=temp1 | temp2 baddiemove=baddiemove | %00001110 temp6=objectdir rem check to see if we can move that way temp2=objectdir/4:temp2=temp2&3:temp3=baddie1x:temp4=baddie1y:gosub check if temp2<>0 then goto move1 baddiemove=baddiemove & %11111101 objectdir=objectdir & %11110011 temp5=temp6 & %00001100 objectdir=objectdir | temp5 move1 temp2=objectdir/16:temp2=temp2&3:temp3=baddie2x:temp4=baddie2y:gosub check if temp2<>0 then goto move2 baddiemove=baddiemove & %11111011 objectdir=objectdir & %11001111 temp5=temp6 & %00110000 objectdir=objectdir | temp5 move2 temp2=objectdir/64:temp2=temp2&3:temp3=baddie3x:temp4=baddie3y:gosub check if temp2<>0 then goto move3 baddiemove=baddiemove & %11110111 objectdir=objectdir & %00111111 temp5=temp6 & %11000000 objectdir=objectdir | temp5 move3 rem scroll extended screen gosub frame4 gosub frame1:rem scrolling (lots of cycles) gosub frame2:rem scrolling gosub frame1 gosub frame4 gosub frame1 gosub frame2:rem scrolling gosub frame1:rem scrolling goto gameloop frame1 rem move up/down gosub drawsprites1: rem draw hero with player0, baddie1 with player1, baddie2 with missile0, baddie3 with missile1 temp1=bymove(objectdir,1):baddie1y=baddie1y+temp1 temp1=bymove(objectdir,2):baddie2y=baddie2y+temp1 temp1=bymove(objectdir,3):baddie3y=baddie3y+temp1 if readjoy{4} then goto checkup pfscroll down:pfscroll down baddie1y=baddie1y+2 baddie2y=baddie2y+2 baddie3y=baddie3y+2 flagy=flagy+2:if flagy>95 then flagy=0 goto skipup checkup if readjoy{5} then goto skipup pfscroll up:pfscroll up if flagy=0 then flagy=96 baddie1y=baddie1y-2 baddie2y=baddie2y-2 baddie3y=baddie3y-2 flagy=flagy-2 skipup if baddie1y=96 || baddie1y=98 then baddie1y=baddie1y-96 if baddie1y=254 || baddie1y=252 then baddie1y=baddie1y+96 if baddie2y=96 || baddie2y=98 then baddie2y=baddie2y-96 if baddie2y=254 || baddie2y=252 then baddie2y=baddie2y+96 if baddie3y=96 || baddie3y=98 then baddie3y=baddie3y-96 if baddie3y=254 || baddie3y=252 then baddie3y=baddie3y+96 drawscreen:return thisbank frame2 rem move left/right gosub drawsprites2: rem draw hero with missile0, baddie1 with missine1, baddie2 with player0, baddie3 with player1 temp1=bxmove(objectdir,3):baddie3x=baddie3x+temp1 temp1=bxmove(objectdir,2):baddie2x=baddie2x+temp1 temp1=bxmove(objectdir,1):baddie1x=baddie1x+temp1 if baddie1x<31 then baddie1x=155 if baddie2x<31 then baddie2x=155 if baddie3x<31 then baddie3x=155 if baddie1x>155 then baddie1x=31 if baddie2x>155 then baddie2x=31 if baddie3x>155 then baddie3x=31 if readjoy{7} then goto checkright temp2=mapx+15 temp3=0 temp1=mapy:gosub newscrolldataleft pfscroll left baddie1x=baddie1x-4:if baddie1x<31 then baddie1x=155 baddie2x=baddie2x-4:if baddie2x<31 then baddie2x=155 baddie3x=baddie3x-4:if baddie3x<31 then baddie3x=155 flagx=flagx-4:if flagx<31 then flagx=155 goto skipright checkright if readjoy{6} then goto skipright temp2=mapx temp3=3 temp1=mapy:gosub newscrolldataleft pfscroll right baddie1x=baddie1x+4:if baddie1x>155 then baddie1x=31 baddie2x=baddie2x+4:if baddie2x>155 then baddie2x=31 baddie3x=baddie3x+4:if baddie3x>155 then baddie3x=31 flagx=flagx+4:if flagx>155 then flagx=31 skipright drawscreen:return thisbank frame4 rem general calculations gosub drawsprites2: rem draw hero with missile0, baddie1 with missine1, baddie2 with player0, baddie3 with player1 drawscreen:return thisbank drawsprites1 COLUP0=24:COLUP1=14 NUSIZ0=$10:NUSIZ1=$10 ballx=flagx:bally=flagy player0x=herox-14:player0y=heroy if objectdir{1} then goto drawheroleftright if !objectdir{0} then gosub up_player0 else gosub down_player0 goto skipheroleftright drawheroleftright gosub lr_player0 REFP0=objectdir*8 skipheroleftright player1x=baddie1x-14:player1y=baddie1y if objectdir{3} then goto drawbaddie1leftright if !objectdir{2} then gosub down_player1 else gosub up_player1 goto skipbaddie1leftright drawbaddie1leftright gosub lr_player1 REFP1=objectdir*2 skipbaddie1leftright if objectdir{5} then goto drawbaddie2leftright1 missile0x=baddie2x-10:missile0y=baddie2y-1 missile0height=7 goto skipbaddie2leftright1 drawbaddie2leftright1 missile0x=baddie2x-13:missile0y=baddie2y-3 missile0height=2:NUSIZ0=$30 skipbaddie2leftright1 if objectdir{7} then goto drawbaddie3leftright1 missile1x=baddie3x-10:missile1y=baddie3y-2 missile1height=7 goto skipbaddie3leftright1 drawbaddie3leftright1 missile1x=baddie3x-13:missile1y=baddie3y-4 missile1height=1:NUSIZ1=$30 skipbaddie3leftright1 return thisbank drawsprites2 COLUP0=24:COLUP1=14 NUSIZ0=$10:NUSIZ1=$10 rem ballx=flagx:bally=flagy rem unrem the above (done cuz 4k was full!) if objectdir{1} then goto drawheroleftright1 missile0x=herox-10:missile0y=heroy missile0height=7 goto skipheroleftright1 drawheroleftright1 missile0x=herox-13:missile0y=heroy-3 missile0height=2:NUSIZ0=$30 skipheroleftright1 if objectdir{3} then goto drawbaddie1leftright1 missile1x=baddie1x-10:missile1y=baddie1y-1 missile1height=7 goto skipbaddie1leftright1 drawbaddie1leftright1 missile1x=baddie1x-13:missile1y=baddie1y-4 missile1height=1:NUSIZ1=$30 skipbaddie1leftright1 player0x=baddie2x-14:player0y=baddie2y if objectdir{5} then goto drawbaddie2leftright if objectdir{4} then gosub up_player0 else player0y=player0y-1:gosub down_player0 goto skipbaddie2leftright drawbaddie2leftright gosub lr_player0 temp1=objectdir/2 REFP0=temp1 ^ $FF skipbaddie2leftright player1x=baddie3x-14:player1y=baddie3y if objectdir{7} then goto drawbaddie3leftright if objectdir{6} then gosub up_player1 else player1y=player1y-1:gosub down_player1 goto skipbaddie3leftright drawbaddie3leftright gosub lr_player1 REFP1=objectdir/8 skipbaddie3leftright return thisbank up_player0 player0: %11011011 %11111111 %11011011 %00011000 %11011011 %11111111 %11011011 %00011000 end return thisbank up_player1 player1: %11011011 %11111111 %11011011 %00011000 %11011011 %11111111 %11011011 %00011000 end return thisbank down_player0 player0: %00011000 %11011011 %11111111 %11011011 %00011000 %11011011 %11111111 %11011011 end return thisbank down_player1 player1: %00011000 %11011011 %11111111 %11011011 %00011000 %11011011 %11111111 %11011011 end return thisbank lr_player0 player0: %01110111 %01110111 %00100010 %11111111 %11111111 %00100010 %01110111 %01110111 end return thisbank lr_player1 player1: %11101110 %11101110 %01000100 %11111111 %11111111 %01000100 %11101110 %11101110 end return thisbank check rem check to see if baddie is to hit a wall temp3=temp3-31:temp3=temp3/4 if temp4<8 then temp4=temp4+96 temp4=temp4/8 on temp2 goto doup dodown doright doleft doleft temp4=temp4-1 if temp3=0 then temp3=31 temp3=temp3-1 if pfread(temp3,temp4) then temp2=0 return thisbank doright temp4=temp4-1 temp3=temp3+2 if temp3=32 then temp3=1 if pfread(temp3,temp4) then temp2=0 return thisbank doup if temp4>11 then temp4=0 if pfread(temp3,temp4) then temp2=0 return thisbank dodown if temp4=1 then temp4=13 temp4=temp4-2 if pfread(temp3,temp4) then temp2=0 return thisbank function bxmove if temp2=3 then temp1=temp1/64: if !baddiemove{3} then return 0 if temp2=2 then temp1=temp1/16: if !baddiemove{2} then return 0 if temp2=1 then temp1=temp1/4: if !baddiemove{1} then return 0 if !temp1{1} then return 0 if temp1{0} then return 252 else return 4 function bymove if temp2=3 then temp1=temp1/64: if !baddiemove{3} then return 0 if temp2=2 then temp1=temp1/16: if !baddiemove{2} then return 0 if temp2=1 then temp1=temp1/4: if !baddiemove{1} then return 0 rem above is hack because div8 has a bug if temp1{1} then return 0 if temp1{0} then return 254 else return 2 pixels rem temp1=start ypos, temp2=start xpos for a=43 to 54 temp1=a:temp2=10 gosub newscrolldataup c=8 reptscroll pfscroll up c=c-1 if c<>0 then goto reptscroll next return thisbank newscrolldataleft rem copies data to left edge rem temp1=start ypos rem temp2=start xpos rem temp3=which end of screen (0 left, 3 right) temp5=temp1*4 temp4=temp2/8 temp5=temp5+temp4 for temp4=temp3 to 47 step 4 if temp2>31 || temp5>224 then goto pixelson temp6=level1[temp5] & singlebits[temp2] if temp6=0 then playfield[temp4]=playfield[temp4] & %01111111:goto pixelsoff pixelson playfield[temp4]=playfield[temp4] | %10000000 pixelsoff temp5=temp5+4 next return thisbank newscrolldataup rem this copies data to line 11 rem temp1=start ypos, temp2=start xpos if temp1>55 then temp3=255:temp4=255:goto norot temp1=temp1*4 temp6=temp2/8 if temp2<200 then temp1=temp1+temp6 rem temp1 has the proper byte now temp3=level1[temp1]:temp1=temp1+1 temp4=level1[temp1]:temp1=temp1+1 if temp2<17 then temp5=level1[temp1] else temp5=255 if temp2<200 then rotleft rotright asm sec ror temp3 ror temp4 end rem if temp2<8 then temp3=temp3 | edgemask[temp2] temp2=temp2+1:if temp2=0 then goto norot goto rotright rotleft asm echo * end temp1=temp6*8 temp1=temp2-temp1 if temp2=24 then temp4=255 rem temp1 now has number of times to shift if temp1=0 then norot for temp6=1 to temp1 asm rol temp5 rol temp4 rol temp3 end next norot rem check for edges! rem now temp3 and temp4 have the bits we need for the screen rem but need to be doubled up temp1=temp3/16:p44=doublebits[temp1] temp1=temp3&15:p45=doublebitsrev[temp1] temp1=temp4/16:p46=doublebits[temp1] temp1=temp4&15:p47=doublebitsrev[temp1] return thisbank rem level data - 224 bytes data level1 %00000000, %00000001, %11111110, %00000000 %01110111, %11011000, %00011110, %11111110 %01110111, %11011000, %10011110, %00000000 %00000000, %00000000, %10000000, %11101110 %01111110, %11111000, %00011110, %11101110 %00000000, %00000001, %11011110, %00000000 %00001111, %11010111, %11011110, %11111110 %10100000, %01010111, %00000000, %00000000 %10101111, %01010111, %01110111, %11111101 %10101000, %01010111, %01110100, %00000101 %10101011, %01010000, %01110100, %00000101 %00101011, %01010111, %01110101, %11110101 %01101000, %01010111, %01110101, %11110101 %01101011, %11010000, %00000100, %00000101 %00001000, %00010111, %01100111, %00111101 %01101011, %11110111, %01100111, %00111101 %01100000, %00000111, %01100111, %00111100 %01111111, %11110111, %00000000, %00000000 %00000011, %00000000, %00000000, %00111011 %01111011, %01111111, %00111111, %00111011 %01111000, %00000111, %00111111, %00000011 %01111011, %01110111, %00000011, %00111001 %00000011, %01110000, %00110011, %00111001 %10111111, %01111111, %00110011, %00111101 %10000000, %00000000, %00110000, %00000001 %10111111, %01111111, %00111111, %00111101 %10111111, %01111111, %00111111, %00111101 %10000000, %00000000, %00000000, %00000000 %10111011, %01111011, %00111011, %00111101 %10111011, %01111011, %00111011, %00111101 %10111011, %01100000, %00000011, %00110001 %10111011, %01101011, %00111011, %00110101 %10000000, %00000011, %00111000, %00110101 %10110111, %01111011, %00000011, %00000100 %10110111, %01111011, %00111011, %00111110 %10000000, %00011011, %00111011, %00111110 %10111101, %11000000, %00000000, %00000000 %00111101, %11000000, %00000000, %00000000 %00000000, %01110110, %11101111, %00110110 %00110111, %01110110, %11101111, %00110110 %00110111, %01110000, %00001111, %00110110 %00010111, %01110110, %11100000, %00110000 %00110000, %00000110, %00001011, %00110110 %00110111, %11011110, %11101011, %00110110 %00110111, %11011110, %11101011, %00110110 %00000000, %00000000, %00001000, %00000110 %11011101, %10111110, %11101011, %00110110 %11011101, %10111110, %11101011, %00110110 %11000000, %00000000, %00000011, %00110110 %11011101, %10101010, %10101011, %00110110 %11011101, %10101010, %10101011, %00000000 %00001100, %00101010, %10101000, %00111110 %01100001, %10101010, %10101011, %00111110 %01101111, %10101010, %10101011, %00000110 %01101111, %10101010, %10101011, %00110110 %00000000, %00000000, %00000000, %00110000 ; 224 bytes here end data singlebits 128,64,32,16,8,4,2,1 128,64,32,16,8,4,2,1 128,64,32,16,8,4,2,1 128,64,32,16,8,4,2,1 end data doublebits %00000000 %00000011 %00001100 %00001111 %00110000 %00110011 %00111100 %00111111 %11000000 %11000011 %11001100 %11001111 %11110000 %11110011 %11111100 %11111111 end data doublebitsrev %00000000 %11000000 %00110000 %11110000 %00001100 %11001100 %00111100 %11111100 %00000011 %11000011 %00110011 %11110011 %00001111 %11001111 %00111111 %11111111 end