home *** CD-ROM | disk | FTP | other *** search
/ UpTime Volume 1 #9 / utv1n9s1.d64 / battleship.exe (.txt) < prev    next >
Commodore BASIC  |  2022-08-28  |  9KB  |  253 lines

  1. 10 rem      battleship 64
  2. 13 rem      by mike cooke
  3. 16 rem      copyright 1987
  4. 19 rem      published by uptime
  5. 22 rem
  6. 26 clr
  7. 28 print"[147]                                       "
  8. 31 print" "tab(7)" "tab(31)" "tab(38)" "
  9. 34 print" "tab(8)" [146][155]    [\]]^_!#$% &'(";
  10. 37 printtab(30)" "tab(38)" "
  11. 40 print" "tab(9)" "tab(29)" "tab(38)" "
  12. 43 print" "tab(10)"                   "tab(38)" "
  13. 46 print" "tab(11)" [155][146] battle screen  "tab(38)" "
  14. 49 print" "tab(12)"               "tab(38)" "
  15. 52 fort=1to11:print" "tab(19)" "tab(38)" ":nextt
  16. 55 print"                                       "
  17. 57 print"      [151]press[155] f8[151] to return to uptime"
  18. 58 print"[154]allies"tab(31)"enemies"
  19. 61 print"[152]abcdefghijklmno"tab(23)"abcdefghijklmno"
  20. 64 print"0[157]1[157]2[157]3[157]4[157]5[157]6[157]7[157]8[157]9"
  21. 67 printtab(22)"[145][145][145][145][145][145][145][145][145][145]0[157]1[157]2[157]3[157]4[157]5[157]6[157]7[157]8[157]9[154]"
  22. 70 y=1346:fort=0to9:forz=0to14:pokey+(t*40)+z,103:pokey+(t*40)+z+21,103
  23. 73 poke55618+(t*40)+z,14:poke55618+(t*40)+z+21,14:nextz,t
  24. 76 fort=1to8:poke1362+t*40,102:poke1364+t*40,102:nextt:ifflag=1thenreturn
  25. 79 v=53248:pokev+16,1:pokev,35:pokev+1,75:pokev+2,50:pokev+3,75:pokev+21,3
  26. 82 rem   * variables *
  27. 85 cv$="[193][157][194][157][195][157][196][157][197]":ch$="[210][211][212][213][214]"
  28. 88 bv$="[198][157][199][157][200][157][201]":bh$="[215][216][217][218]"
  29. 91 dv$="[202][157][203][157][204]":dh$="[219][220][221]"
  30. 94 sv$="[205][157][206][157][207]":sh$="[255][223][161]"
  31. 97 pv$="[208][157][209]":ph$="[162][163]"
  32. 100 dimsh$(9,3):dimhi(9,3):dimp1$(9,6):dimp2$(9,6)
  33. 103 fort=1to8:fory=1to2:readsh$(t,y):nexty,t
  34. 106 rem     * ship data *
  35. 109 data carrier,5,battleship,4,destroyer 1,3,destroyer 2,3,sub 1,3,sub 2,3
  36. 112 data pt boat 1,2,pt boat 2,2
  37. 115 gosub124
  38. 118 goto142
  39. 121 rem    * some sub routines *
  40. 124 rem    ... clear space ...
  41. 127 fort=1823to2022:poket,32:nextt
  42. 130 print"":return
  43. 133 rem    ... press key ...
  44. 134 poke 198,0
  45. 136 printtab(14)"press return[152]";
  46. 139 geta$:ifa$="[140]"then1000
  47. 140 ifa$<>chr$(13)then139
  48. 141 return
  49. 142 rem   beginning inputs
  50. 145 printtab(11)"[152]how many players?":printtab(16)"1 or 2?"
  51. 146 getnp$:ifnp$="[140]"then1000
  52. 147 np=val(np$):ifnp<1ornp>2then 146
  53. 148 rem
  54. 151 rem     player one input
  55. 154 rem
  56. 210 gosub124:print"            player one input":pn=0
  57. 212 ifnp=1thenprint"     the enemy promises not to look":goto217
  58. 214 print"      player two please turn away"
  59. 217 gosub133:gosub124
  60. 218 fors=1to8
  61. 220 printtab(6)"[155]"sh$(s,1)":":printtab(8)"[152]start on ";
  62. 230 getl$:ifl$="[140]"then1000
  63. 231 ifl$<"a"orl$>"o"then230
  64. 235 print"";l$;:st$=l$:l$=""
  65. 240 getl$:ifl$="[140]"then1000
  66. 241 ifl$<"0"orl$>"9"then240
  67. 245 printl$:st$=st$+l$:l$="":printtab(8)"[152]point ";
  68. 255 getl$:ifl$="[140]"then1000
  69. 256 ifl$<>"r"andl$<>"l"andl$<>"u"andl$<>"d"then255
  70. 260 ifl$="r"thenprint"right":goto280
  71. 265 ifl$="l"thenprint"left":goto281
  72. 270 ifl$="u"thenprint"up":goto291
  73. 275 ifl$="d"thenprint"down":goto290
  74. 280 cs=55616:forc=1toval(sh$(s,2)):goto282
  75. 281 cs=55616:forc=-(val(sh$(s,2)))+2to1
  76. 282 vv=(cs+(asc(st$)-64)+(val(right$(st$,1))*40)+pn*21+c)
  77. 283 vp=peek(vv):ifvp-(int(vp/16)*16)<>14then315
  78. 284 nextc:goto320
  79. 290 cs=55577:forc=1toval(sh$(s,2)):goto292
  80. 291 cs=55577:forc=-(val(sh$(s,2)))+2to1
  81. 292 vv=(cs+(asc(st$)-64)+(val(right$(st$,1))*40)+pn*21+c*40)
  82. 293 vp=peek(vv):ifvp-(int(vp/16)*16)<>14then315
  83. 294 nextc:goto340
  84. 315 gosub124:printtab(9)"[155]illegal sector, capt":printtab(11)"please try again"
  85. 316 gosub133:gosub124:goto220
  86. 320 ifl$="l"thens$=chr$(asc(st$)-val(sh$(s,2))+1)+right$(st$,1):st$=s$:l$="r"
  87. 322 print"":ford=1to7+val(right$(st$,1)):print:nextd
  88. 324 printtab((asc(st$)-63)+pn*21);"[152]";
  89. 325 onsgosub326,327,328,328,329,329,330,330:goto370
  90. 326 printch$:return
  91. 327 printbh$:return
  92. 328 printdh$:return
  93. 329 printsh$:return
  94. 330 printph$:return
  95. 340 ifl$="u"thens$=left$(st$,1)+str$((val(right$(st$,1)))-(val(sh$(s,2))-1))
  96. 341 ifl$="u"thenst$=s$
  97. 342 print"":ford=1to7+val(right$(st$,1)):print:nextd
  98. 344 printtab((asc(st$)-63)+pn*21);"[152]";
  99. 345 onsgosub346,347,348,348,349,349,350,350:goto400
  100. 346 printcv$:return
  101. 347 printbv$:return
  102. 348 printdv$:return
  103. 349 printsv$:return
  104. 350 printpv$:return
  105. 370 rem put ship in array
  106. 375 rem    right
  107. 380 ford=1toval(sh$(s,2))
  108. 385 ifpn=0thenp1$(s,d)=chr$(asc(st$)+d-1)+right$(st$,1)
  109. 386 ifpn=1thenp2$(s,d)=chr$(asc(st$)+d-1)+right$(st$,1)
  110. 390 nextd:gosub124:nexts:goto450
  111. 400 rem    down
  112. 405 ford=1toval(sh$(s,2))
  113. 410 ifpn=0thenp1$(s,d)=left$(st$,1)+chr$(asc(right$(st$,1))+d-1)
  114. 411 ifpn=1thenp2$(s,d)=left$(st$,1)+chr$(asc(right$(st$,1))+d-1)
  115. 420 nextd:gosub124:nexts
  116. 450 rem player two
  117. 451 ifnp=1then500
  118. 452 ifpn=1then600
  119. 455 print"[152] ready to clear the grid for player two":gosub133:flag=1:gosub70
  120. 460 gosub124:print"            player two input"
  121. 465 print"[145]      player one please turn away":pn=1
  122. 470 goto217
  123. 500 rem computer player setup
  124. 505 print" [152]the enemies are placing their ships..."
  125. 510 open15,8,15,"i0":open1,8,2,"battledata2,l,"+chr$(100)
  126. 515 input#15,a,b$:ifa<20ora=50then520
  127. 516 print"disk error...please correct.":gosub133:gosub124:close1:close15:goto500
  128. 520 r=int(rnd(1)*20)+1
  129. 525 print#15,"p"+chr$(98)+chr$(r)+chr$(0)
  130. 530 input#1,a$
  131. 535 print#15,"p"+chr$(98)+chr$(r)+chr$(0)
  132. 540 close1:close15
  133. 545 t=1:fors=1to8:forc=1toval(sh$(s,2))
  134. 550 p2$(s,c)=mid$(a$,t,2):t=t+2
  135. 555 nextc:nexts
  136. 600 rem battle
  137. 602 ifnp=2then605
  138. 603 gosub124:print"[152]         prepare for the battle":gosub133:goto620
  139. 605 print"[152]  prepare to clear the grid for battle":gosub133:flag=1:gosub70
  140. 620 pn=0
  141. 622 gosub124
  142. 623 ifnp=1andpn=1then950
  143. 625 ifpn=0thenprint"[155]             allies attack([152]"
  144. 630 ifpn=1thenprint"[155]            enemies attack([152]"
  145. 635 printtab(10)"sector to attack: ";
  146. 640 getl$:ifl$="[140]"then1000
  147. 645 ifl$<"a"orl$>"o"then640
  148. 650 print""l$;:at$=l$:l$=""
  149. 655 getl$:ifl$="[140]"then1000
  150. 660 ifl$<"0"orl$>"9"then655
  151. 665 at$=at$+l$:printl$
  152. 667 cs=55617
  153. 670 ifpn=0thense=(cs+(asc(at$)-64)+(val(right$(at$,1))*40)+21):vp=peek(se)
  154. 671 ifpn=1thense=(cs+(asc(at$)-64)+(val(right$(at$,1))*40)):vp=peek(se)
  155. 675 ifvp-int(vp/16)*16=14then680
  156. 676 gosub124:print"[152]      we have attacked there, capt":gosub133:goto622
  157. 680 printtab(12)"fireing...";:gosub2000
  158. 685 fors=1to8:forc=1to5
  159. 690 onpn+1goto700,710
  160. 700 ifp2$(s,c)=at$then720
  161. 701 goto715
  162. 710 ifp1$(s,c)=at$then720
  163. 715 nextc,s:goto900
  164. 720 rem hit
  165. 721 pokese,2:pokese-54272,100
  166. 722 printtab(17)"hit(([152]"
  167. 725 gosub2500:gosub124
  168. 726 ifpn=0thenprint"[155]             allies attack([152]"
  169. 727 ifpn=1thenprint"[155]            enemies attack([152]"
  170. 729 printtab(20-(len(sh$(s,1))+14)/2)"ship damaged: ";sh$(s,1)"[152]"
  171. 730 ifpn=0thenhi(s,2)=hi(s,2)+1:ifhi(s,2)=val(sh$(s,2))then740
  172. 731 ifpn=1thenhi(s,1)=hi(s,1)+1:ifhi(s,1)=val(sh$(s,2))then740
  173. 735 gosub133:ifpn=0thenpn=1:goto737
  174. 736 pn=0
  175. 737 goto622
  176. 740 printtab(9)"she is sunk, captian("
  177. 741 ifpn=0thens2=s2+1:poke1364+s2*40,24:poke1364+s2*40+54272,2
  178. 742 ifpn=1thens1=s1+1:poke1362+s1*40,24:poke1362+s1*40+54272,2
  179. 745 ifs1<8ands2<8then735
  180. 750 rem finished
  181. 751 fort=1to1000:nextt
  182. 755 print"[147][152]":ifpn=0thenw$="allies":l$="enemies"
  183. 757 ifpn=1thenw$="enemies":l$="allies"
  184. 759 print:print:print"      the ";w$;"[152] are the victors("
  185. 761 print:print"            sorry ";l$;"[152]((("
  186. 762 print
  187. 763 fort=1to4
  188. 764 print"                                     [152]":nextt
  189. 765 v=53248:fort=75to115:fory=1to50:nexty
  190. 766 ifpn=0thenpokev+1,t
  191. 767 ifpn=1thenpokev+3,t
  192. 768 nextt
  193. 769 print:print"    would you like to play again or"
  194. 770 printtab(11)"return to uptime?":printtab(15)"p or r?
  195. 771 [161]a$
  196. 772 [139]a$[178]"r"[167]1000
  197. 773 [139]a$[178]"p"[167][138]
  198. 774 [137]771
  199. 899 [128]
  200. 900 [143] miss
  201. 901 [151]se,6:[151]se[171]54272,100
  202. 902 [153][163]16)"miss("
  203. 905 [141]3000:[139]pn[178]0[167]pn[178]1:[137]622
  204. 906 pn[178]0:[137]622
  205. 950 [143] computer player
  206. 955 [153]"print#      the enemies fire...";
  207. 957 [139]m[178]3[167]990
  208. 959 at$[178][199]([181]([187](0)[172]15)[170]65)
  209. 961 at$[178]at$[170][199]([181]([187](0)[172]10)[170]48)
  210. 963 cs[178]55617:se[178](cs[170]([198](at$)[171]64)[170]([197]([201](at$,1))[172]40))
  211. 964 vp[178][194](se):