rem ****************************** rem CityScape Atari2600 20110904 rem ****************************** rem By Tom Babich rem ****************************** rem First level is Blitz, then it's rem like Space Invaders in reverse rem ****************************** rem (don't forget to use Turbo) rem ****************************** include div_mul.asm set kernel_options no_blank_lines rem set kernel_options pfcolors set romsize 8kSC set smartbranching on set optimization speed const pfres=32 rem *****Title Screen****** pfclear title missile1height=4:missile1y=255 COLUPF=rand rem AUDV1=10:AUDC1=15:AUDF1=g rem rand sound v = rand:n=rand:v=v/17:n=n/10 AUDV1=v:AUDC1=15:AUDF1=n o=0 rem default o to 0 for no opponent on 1st screen playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.. X............................X.. X............................X.. X.XXX.X.XXXX.X..X...XX.XX....X.. X.X...X..XX...XX....XX.XX....X.. X.X...X..XX...XX....XX.XX....X.. X.XXX.X..XX...XX....XX.XX....X.. X............................X.. X............................X.. X............................X.. X............................X.. X..XXXXX..X....XXXXX.XXXXX...X.. X......X..X....X...X.X...X...X.. X..XXXXX..XXXX.X...X.X...X...X.. X..X......X..X.X...X.X...X...X.. X..XXXXX..XXXX.XXXXX.XXXXX...X.. X............................X.. X...XXXX.XXX.XXXX.XXXX..XX...X.. X...XX.X.X.X.XX.X.X.....XX...X.. X...XXXX.XXX.XXX..XXXX..XX...X.. X...XXX..X.X.XXX..X..........X.. X...XX.X.X.X.XX.X.XXXX..XX...X.. X............................X.. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.. end drawscreen if !joy0fire goto title init pfclear:AUDV0=0:AUDV1=0 rem COLUBK= 143 player0x=11:player0y=9:player1x=70:player1y=32 rem player1 is opponent not visible on early levels, o=1 rem o=1 rem on for debug d=0 rem d is opponentfrozen delay, seededby collsion rem this is the city draw start with random building gen city COLUPF=rand rem city has opponent? if o=1 then player1y=90 v= rand: v=v/15 if v < 8 then v = 8 for w=1 to v q = rand: q= q / 8 rem q = 32 - q if q < 5 then q = 5 if q >26 then q = 6 t= rand: t= t/8 u = rand: u= u/40 + t rem can't get that last column... so don't set it if u>29 then u=29 if t>29 then t=29 for m = t to u for n = q to 31 rem goes to 31 pfpixel m n on next next next rem fix occasional paint bug n=0 for m=0 to 31:pfpixel m n off:next rem count how many columns are seeded since they can overlap (use this to checkifwon) k=0 for n=1 to 31 if !pfread(n,26) then 17 k=k+1 17 next s=0 rem s is the column counter that gets incremented to match k (win) rem dim movementdelay = m rem dim forward = f m = 0:l = 3: f = 1 rem using l as "level" now 10 is default fast z=0:q=0 rem q is missle fired gameloop if switchreset then o=0:goto init rem loses color change rnd breaks if switchreset then reboot if f=1 then gosub fwdplane else gosub bwdplane COLUP0=15 rem loop backwards and forwards rem l and m are 255x255 millisecond delay ;) rem this took forever, only need m ;) rem if l < 255 then l=l+1 rem if m < 255 && l=255 then m = m + 1 rem if l=255 then l = 0 if m 8 then gosub plot2 rem if it's time to move and dir is fwd if m=l && f=1 then player0x=player0x+1 if player0x>137 then f=0 if player0x>137 then player0y=player0y+1 if player0x>137 then player0x=137 if m=l && f=0 then player0x=player0x-1 if player0x<10 then f=1 if player0x<10 then player0y=player0y+1 if player0x<10 then player0x=10 if joy0left && f=0 then player0x=player0x-1:if player0x<10 then player0x=10 if joy0right && f=1 then player0x=player0x+1:if player0x>137 then player0x=137 rem if joy0up then player0y=player0y-1:if player0y<7 then player0y=7 if joy0down && m=l then player0y=player0y+1:if player0y>99 then player0y=99 rem if movementdelay =255 reset it (Now using l, level) if m = l then m = 0 rem backward loop rem if m = skipjoy rem if joy0fire then gosub plot2 rem init missle fired, misslex and missley? if joy0fire && q=0 then g=((player0y-7)/3)+3 if joy0fire && q=0 then h=(player0x-10)/4 rem fix reverse fire if joy0fire && q=0 && f=0 then g=g+2:h=h-1 if joy0fire && q=0 then q=1 rem : g=(player0y-7)/3:h=(player0x-10)/4 if q=1 then gosub plot2 rem crashed? if player0y > 9 && collision(player0,playfield) then z=1:gosub explosion rem is there an opponent at this level? if o=1 then gosub opponent rem first gosub explosioneffect if collision(missile1,player0) then z=1:missile1y=8:missile1x=player1x:z=1:gosub explosion drawscreen goto gameloop plot rem convert player position to playfield pixel rem divide by 3 vertically rem g=(player0y-7)/3 rem h=(player0x-10)/4 rem if g=i && j=h then return rem i=g:j=h rem pfpixel h g flip return plot2 rem pfpixel 30 2 on rem return rem if h<4 then h=4 if g<4 then g=4 if h>30 then h=30 rem AUDV0=10:AUDC0=12:AUDF0=h AUDV1=10:AUDC1=10:AUDF1=g pfpixel h g on v = g-1 pfpixel h v off rem COLUPF = rand rem if missle is almost done check if it hit anything if g=25 && pfread(h,27) then s=s+1 rem if missle is done, allow another to be fired if g = 31 then q=0:AUDV0=0:AUDV1=0:pfpixel h g off:gosub checkifwon else g=g+1 return checkifwon rem piggyback seed d if opponent gets frozen (hit) b=(player1x-10)/4:if b=h && d=0 then d=25 rem should we freeze the missle? b=b+1:if b=h && d=0 then d=45 rem b=b+1:if b=h && d=0 then d=25 rem b=b-3:if b=h && d=0 then d=45 b=b-2:if b=h && d=0 then d=35 rem checkifwon here rem this is a bad routine; only one call to pfread should rem be made not 30 in a loop, that should be done when the city is drawn rem and there is no overhead, and a var here incremented until it matches the count rem b=0 rem drawscreen rem for n=3 to 29 rem if !pfread(n,26) then 17 rem drawscreen rem if n = 10 then drawscreen rem if n = 17 then drawscreen rem if n=23 then drawscreen rem pfpixel n 26 flip rem if b<>1 then b=1 rem 17 rem rem next rem drawscreen rem b=1 rem debug rem if b=1 then 19 if s<>k then 19 rem win: for n = 0 to 31 AUDV0=10:AUDC0=6:AUDF0=n COLUPF=rand drawscreen next AUDV0=0 o=1 rem (set level to show opponent) pop:pop goto init rem 18 goto 18 19 rem return fwdplane player0: %11000000 %01111000 %11111111 %11000000 end return bwdplane player0: %00000011 %00011110 %11111111 %00000011 end return opponent player1: %11111111 %10111101 %00111100 %00011000 %00011000 end rem if opponent is called (higher levels) logic is here ;) COLUP1=120 if d>0 then d=d-1:COLUP1=rand AUDV0=10:AUDC0=4:AUDF0=d*3 if d>0 && missile1y>2 then missile1y=missile1y-2 if d>0 then return if d=0 then AUDV0=0 if player1xplayer0x then player1x = player1x-1 if player1x>player0x && rand>127 then player1x = player1x-1 if missile1y<10 then missile1y=player1y:missile1x=player1x missile1y = missile1y-2 return explosion player0: %00011000 %01111100 %01111110 %00111000 %00010000 end for x = 1 to 10 COLUP0=rand drawscreen AUDV0=10:AUDC0=6:AUDF0=x*2 AUDV1=10:AUDC1=8:AUDF1=x*3 next pop goto init return