home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun 1984 Half 2 / rerun-1984-07-12.d64 / battleship (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  11KB  |  231 lines

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