home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun: Game Pak
/
rerun-gamepak
/
battleship
(
.txt
)
next >
Wrap
Commodore BASIC
|
2022-09-20
|
11KB
|
231 lines
10 poke55,0:poke56,128:clr:rem move top of memory down to 32768
20 goto5000
97 *
98 * main game loop
99 *
100 ti$="000000"
110 getin$:ifin$=""goto150
120 ifin$=""thengosub2200
130 ifin$=""thengosub2400
140 ifin$=" "thendc=1
150 r=fne(.):onrgosub1000,1100,1200,1300,1400,1500,1000,1300:ifdcthengosub2000
160 ifti<tlimgoto110
170 goto7000
997 *
998 * small sub
999 *
1000 pokehom+x(1)+sw*y(1),bl:x(1)=x(1)+fnd(.):ifx(1)<swgoto1020
1010 x(1)=1:y(1)=fnb(.):ify(1)=y(2)ory(1)=y(3)goto1010
1020 pokehom+x(1)+sw*y(1),34:return
1097 *
1098 * med sub
1099 *
1100 a=hom+x(2)+sw*y(2):pokea,bl:pokea-1,bl:x(2)=x(2)+fna(.):ifx(2)<swgoto1120
1110 x(2)=2:y(2)=fnb(.):ify(2)=y(1)ory(2)=y(3)goto1110
1120 a=hom+x(2)+sw*y(2):pokea,36:pokea-1,35:return
1197 *
1198 * large sub
1199 *
1200 a=hom+x(3)+sw*y(3):fori=a-2toa:pokei,bl:next
1210 x(3)=x(3)+fna(.):ifx(3)<swgoto1230
1220 x(3)=3:y(3)=fnb(.):ify(3)=y(1)ory(3)=y(2)goto1220
1230 a=hom+x(3)+sw*y(3):pokea,39:pokea-1,38:pokea-2,37:return
1297 *
1298 * small plane
1299 *
1300 pokehom+x(4)+sw*y(4),bl:x(4)=x(4)-fna(.):ifx(4)>.goto1320
1310 x(4)=sw:y(4)=fnc(.):ify(4)=y(5)ory(4)=y(6)goto1310
1320 pokehom+x(4)+sw*y(4),22:return
1397 *
1398 * med plane
1399 *
1400 a=hom+x(5)+sw*y(5):pokea,bl:pokea+1,bl:x(5)=x(5)-fnd(.):ifx(5)>.goto1420
1410 x(5)=39:y(5)=fnc(.):ify(5)=y(4)ory(5)=y(6)goto1410
1420 a=hom+x(5)+sw*y(5):pokea,23:pokea+1,24:return
1497 *
1498 * large plane
1499 *
1500 a=hom+x(6)+sw*y(6):fori=atoa+2:pokei,bl:next
1510 x(6)=x(6)-fna(.):ifx(6)>.goto1530
1520 x(6)=38:y(6)=fnc(.):ify(6)=y(4)ory(6)=y(5)goto1520
1530 a=hom+x(6)+sw*y(6):pokea,25:pokea+1,26:pokea+2,27:return
1997 *
1998 * depth charge
1999 *
2000 pokefq,38:pokewv,tri:pk%=peek(d):ifpk%<>blandpk%<>63goto2030
2010 poked,bl:d=d+sw:ifd>33767goto2040
2020 pk%=peek(d):ifpk%=blthenpoked,63:pokewv,.:return
2030 c=d:gosub3000
2040 d=33266:dc=.:pokewv,.:return
2197 *
2198 * left gun
2199 *
2200 pokefq,10:pokewv,noi:poke33141,42:fori=1to10:next:c=.:pokewv,.
2210 fori=33100to32813step-41:pokei+41,bl:pk%=peek(i):ifpk%=blthenpokei,40:next
2220 ifpk%<>blthenc=i:i=32772:next
2230 ifcthengosub3000:return
2240 poke32813,bl:return
2397 *
2398 * right gun
2399 *
2400 pokefq,9:pokewv,noi:poke33151,42:fori=1to10:next:c=.:pokewv,.
2410 fori=33112to32839step-39:pokei+39,bl:pk%=peek(i):ifpk%=blthenpokei,41:next
2420 ifpk%<>blthenc=i:i=32800:next
2430 ifcthengosub3000:return
2440 poke32839,bl:return
2997 *
2998 * plane or sub hit
2999 *
3000 t=pk%:ex=62+(t<28):gosub3500:tg=6:ift=23ort=24thentg=5:goto3050
3010 ift>36andt<40thentg=3:goto3050
3020 ift=35ort=36thentg=2:goto3050
3030 ift=22thentg=4
3040 ift=34thentg=1
3050 tpt=tpt+pt(tg):print"[145]";sl$;tpt;" ":x(tg)=-sw*(tg<4):return
3497 *
3498 * explosion
3499 *
3500 pokewv,saw:ifex=62thenpokewv,tri
3510 fori=c-2toc+2:pokei,bl:next:pokec,42
3520 fori=c-swtoc+swstepsw:fori2=-1to1:a=i+i2:ifpeek(a)=blthenpokea,ex
3530 pokefq,20-10*i2:nexti2,i:pokewv,.
3540 fori=c-swtoc+swstepsw:fori2=-1to1:a=i+i2:ifpeek(a)=exthenpokea,bl
3550 nexti2,i:pokec,bl:return
4997 *
4998 * initialize
4999 *
5000 print "[147]initializing......"
5010 poke 53280,11:poke 53281,1:rem set screen colors
5011 fort=55296to56319:poket,0:next
5015 rem set sound voice #1
5020 poke 54296,15:rem volume
5030 poke 54277,0:rem attack-decay
5040 poke 54278,240:rem sustain release
5050 poke 54272,100:rem lo freq.
5060 fq=54273:rem hi freq. register
5070 wv=54276:rem wave form register
5080 noi=129:saw=33:tri=17:rem wave form values
5090 hom=32727:d=33266:rem screen locations
5100 tlim=10800:rem time limit (jiffies)
5110 bl=32:sw=40:rem value to poke blank, screen width
5115 rem set random value functions
5120 def fn a(r)=int(rnd(r)*3+1)
5130 def fn b(r)=int(rnd(r)*9+15)
5140 def fn c(r)=int(rnd(r)*6+3)
5150 def fn d(r)=int(rnd(r)*2+1)
5160 def fn e(r)=int(rnd(r)*8+1)
5170 st$="":fori=1to11:reada:st$=st$+chr$(a):next:rem top of ship
5180 data 32,66,69,70,73,74,77,78,81,82,32
5190 sb$="":fori=1to11:reada:sb$=sb$+chr$(a):next:rem bottem of ship
5200 data 67,68,71,72,75,76,79,80,83,84,85
5210 sl$="":fori=43to47:sl$=sl$+chr$(i):next:rem score display line
5220 fori=1to6:readpt(i):next:rem point values
5230 data 150,40,25,75,20,15
5240 gosub 8000:rem read, poke custom character set
5250 goto 6000
5997 *
5998 * begin game
5999 *
6000 x=rnd(-ti):print "[147][151] - battleship war - by keith meade "
6010 print " you are in command of a battleship."
6020 print " you have 3 minutes to destroy as many"
6030 print " enemy subs and planes as possible."
6040 print " point values:"
6050 print " small sub = 150[146] small plane = 75"
6060 print " med sub = 40 med plane = 20"
6070 print " large sub = 25 large plane = 15"
6080 print " cursor keys fire the cannons."
6090 print " space bar releases a depth charge."
6100 for x=1 to 40:next
6110 print "[145] press any key to begin play"
6120 for x=1 to 40:next
6130 print "[145] press any key to begin play"
6140 get in$:if in$="" goto 6100
6150 print "[147]"
6160 scram=0:chset=2:rem screen ram, char set location values
6170 gosub 10000:rem move video block, etc.
6175 rem draw game display
6180 poke 53281,5:print "[147]":poke 53281,1:rem clear, set color ram
6190 fori=55296to55695:pokei,11:next:rem change some color ram
6200 print "[154]";:fori=1to40:printchr$(65);:next:rem water line
6210 print "[145][145][152]";spc(13);st$:rem ship top
6220 print spc(13);sb$:rem ship bottem
6230 print "[151]";sl$;tpt:rem score line
6240 for i=1 to 3:x(i)=39:x(i+3)=0:next:rem reset target positions
6245 poke53281,15
6250 goto 100
6997 *
6998 * game over
6999 *
7000 poke 53281,7:rem change screen color
7010 for i=1 to 2000:next:rem wait
7020 poke 53281,1:rem restore screen color
7030 print"[147]"
7040 gosub 10100:rem restore video location
7050 poke 53272,(peek(53272) and 240)+5:rem restore standard character set
7060 print "[147]time's up!!"
7070 if tpt>higame then higame=tpt
7080 print "your score =";tpt
7090 print "high score =";higame
7100 print "another game? (y or n)"
7110 get in$:if in$="y" then tpt=0:goto 6000
7120 if in$<>"n" goto 7110
7130 end
7997 *
7998 * poke custom char data
7999 *
8000 m=34816
8010 forlin=8040to8350step10:tt=0:fori=1to16:reada:pokem,a:m=m+1:tt=tt+a:next
8020 reada:iftt<>athenprint"error in line";lin:stop
8030 next:return
8040 data 0,0,0,0,0,0,0,0,0,0,0,0,0,204,170,51,425
8050 data 192,96,48,24,12,2,10,10,0,0,170,255,127,59,21,14,1040
8060 data 10,10,170,255,255,187,85,238,0,0,0,0,0,128,160,160,1658
8070 data 10,10,10,10,10,255,255,204,160,160,170,255,255,187,85,238,2274
8080 data 204,255,170,255,255,187,85,238,138,138,138,138,138,255,255,204,3053
8090 data 138,138,138,138,138,255,255,204,204,255,170,255,255,187,85,238,3053
8100 data 204,255,170,255,255,187,85,238,138,138,138,138,138,255,255,204,3053
8110 data 138,138,138,138,138,255,255,204,204,255,170,255,255,187,85,238,3053
8120 data 204,255,170,255,255,187,85,238,128,128,128,128,128,193,197,197,2876
8130 data 3,6,12,24,48,80,84,84,197,197,170,255,255,187,85,238,1925
8140 data 84,84,170,255,255,187,85,238,0,0,170,254,252,184,80,224,2522
8150 data 0,48,49,255,255,49,48,0,3,6,12,255,255,6,3,1,1245
8160 data 1,3,7,255,255,0,0,128,0,0,0,42,170,170,0,0,1031
8170 data 40,80,160,170,170,170,80,40,1,2,5,170,169,170,10,2,1439
8180 data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
8190 data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
8200 data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
8210 data 0,12,12,255,255,0,0,0,0,0,0,0,255,127,63,0,979
8220 data 0,224,224,224,255,255,254,0,0,0,0,0,170,170,42,10,1828
8230 data 2,2,2,2,170,170,170,170,128,128,128,128,168,170,170,168,1876
8240 data 128,64,32,16,8,4,2,1,1,2,4,8,16,32,64,128,510
8250 data 0,146,84,56,214,56,84,146,112,249,193,241,121,25,249,240,2216
8260 data 225,243,131,131,131,131,243,225,227,243,51,51,51,51,243,227,2604
8270 data 227,51,51,227,227,51,51,51,224,224,15,207,192,15,239,224,2276
8280 data 60,102,102,102,102,102,60,0,24,24,24,24,24,24,24,0,798
8290 data 124,6,6,12,48,96,126,0,124,6,6,28,6,6,124,0,718
8300 data 102,102,102,127,6,6,6,0,126,96,96,124,6,6,124,0,1029
8310 data 60,96,96,124,102,102,60,0,126,6,12,24,