home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ENTERPRS / C64 / GAMES / BTTLSHP.C64 (.txt) < prev    next >
Commodore BASIC  |  2000-06-30  |  10KB  |  180 lines

  1. 5 POKE45,93:POKE46,32:POKE55,.:POKE56,40:CLR:POKE53272,27
  2. 10 REM*********************************       *         BATTLESHIPS 64        *
  3. 15 REM*               BY              *       *         ROGER D. BURGE        *
  4. 20 REM*               &               *       *         JIM BUTTERFIELD       *
  5. 25 REM*                               *       *   BASED ON THE ORIGINAL PET   *
  6. 30 REM*   PROGRAM BY J. BUTTERFIELD   *       *                               *
  7. 35 REM* PROGRAM REVISED & UPGRADED BY *       *         ROGER D. BURGE        *
  8. 40 REM*                               *       *    PROGRAM CONVERTED TO THE   *
  9. 45 REM*          COMMODORE 64         *       *               BY              *
  10. 50 REM*         ROGER D. BURGE        *       *             #2667             *
  11. 55 REM*  TORONTO PET USERS GROUP INC. *       * INCORPORATED, TORONTO, CANADA *
  12. 60 REM*********************************
  13. 65 LL=40:SM=1024:CY=214:CX=211:
  14. 70 POKE53281,1:POKE53280,1:PRINT"[147][144][192]            BATTLESHIPS 64            [193]"
  15. 75 PRINTSPC(19)"BY":PRINTSPC(13)"[\]#[[146] $&[146] ';[]#
  16. 80 [153][166]10)"AND  JIM BUTTERFIELDSTOP":[141]865
  17. 85 [153]"WANT INSTRUCTIONS? (Y/N)":[161]Z$:[139]Z$[178]"N"[167]145
  18. 90 [139]Z$[178]"Y"[167]100
  19. 95 [137]85
  20. 100 [153]"ONSTOP WE BOTH HAVE 5 SHIPS ON A GRID. "
  21. 105 [153]" WE CAN'T SEE EACH OTHERS SHIPS,";
  22. 110 [153]"BUT WE  CAN TAKE TURNS FIRING AT ONE ANOTHER'S
  23. 115 PRINT"GRID. A MISS SHOWS AS '[215][146]', A HIT AS '[214][146]'.
  24. 120 [153]"TRY TO SINK MY SHIPS BEFORE I GET YOURS.
  25. 125 PRINT"TO START YOU MUST INPUT CO-ORDINATES":PRINT"FOR YOUR SHIPS.
  26. 130 [153]"FOR EXAMPLE: A SUBMARINE (LENGTH 3)     MIGHT LIE 'E4-E6'
  27. 135 PRINT"GOOD LUCK! [157][157][192]HIT ANY KEY TO START[193]
  28. 140 [161]Z$:[139]Z$[178]""[137]140
  29. 145 [134]B(9,9,1),N$(4),L(4),H(4,1),I$(5):R[178]TI
  30. 150 [153]"LOAD(null)TANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANRIGHT$";
  31. 155 [153]"(null)   PRESS _ TO QUIT  OR ^ TO RESTART   (null)";
  32. 160 [153]"MID$TANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTANTAN(null)";
  33. 165 [153]"STOP BY JIM BUTTERFIELD  AND ROGER D. BURGE "
  34. 170 [129]T[178].[164]18:[153]"CMDSAVESAVE":[151]218,144:[130]
  35. 175 [153]"STOP  INPUT:CMDCMDCMDCMDCMDCMDCMDCMD";
  36. 180 [153]"(null)ASCASCASCASCASCASCASCASCRIGHT$CMDCMDCMDCMDCMDCMDCMDCMDCMDCMD(null)        (null)";:I$(5)[178]"":I$(2)[178]""
  37. 185 [153]"CMDCMDCMDCMDCMDCMDCMDCMDCMDCMDMID$ASCASCASCASCASCASCASCASC(null)":IB$[178]""
  38. 190 [151]53280,.:[153]"STOP             BATTLESHIPS 64             ";
  39. 195 [153]"ASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCASCON"
  40. 200 [131]CARRIER,BATTLESHIP,CRUISER,SUBMARINE,"PT BOAT"
  41. 205 [131]5,5,4,3,2
  42. 210 [129]J[178].[164]4:[135]N$(J):[130]:[129]J[178].[164]4:[135]L(J):[130]
  43. 215 R[178]R[173]1000:R1[178][187]([171]R):[139]R[177]1[167]215
  44. 220 [153]"    MY BOARD"[166]15)"YOUR BOARD
  45. 225 PRINT"[211] ABCDEFGHIJ [216]"SPC(10)"[211] ABCDEFGHIJ [216]"
  46. 230 PRINT"  __________  "SPC(10)"  __________  "
  47. 235 Z=.:Z$="[176][178][178][178][178][178][178][178][178][174]":GOSUB675
  48. 240 Z$="[171][219][219][219][219][219][219][219][219][179]":FORZ=1TO8:GOSUB675:NEXT
  49. 245 Z$="[173][177][177][177][177][177][177][177][177][189]":GOSUB675
  50. 250 Z$=""
  51. 255 E$="[144]"+Z$+"                                        [145]"
  52. 260 PRINT"  ^^^^^^^^^^  "SPC(10)"  ^^^^^^^^^^  "
  53. 265 PRINT"[166] ABCDEFGHIJ [218]"SPC(10)"[166] ABCDEFGHIJ [218]"
  54. 270 PRINTZ$;"[144]INPUT YOUR SHIPS (I WON'T PEEK)..."
  55. 275 FORJ=1TO2000:NEXT:PRINTE$;"GIVE END CO-ORDINATES FOR EACH SHIP..."
  56. 280 FORL=.TO1:FORJ=.TO9:FORK=.TO9:B(J,K,L)=.:NEXTK,J,L
  57. 285 FORL=.TO1:FORJ=.TO4:H(J,L)=.:NEXTJ,L
  58. 290 FORC=.TO4
  59. 295 PRINTE$;N$(C);" (LENGTH";L(C);")": ML=5:GOSUB805:Y$=B$:GOSUB690:IFE=1GOTO295
  60. 300 X1=X:Y1=Y:GOSUB695:IFE=1GOTO295
  61. 305 L=L(C):IFX<>X1ANDABS(X-X1)<>L-1GOTO295
  62. 310 IFY<>Y1ANDABS(Y-Y1)<>L-1GOTO295
  63. 315 IFY=Y1ANDX=X1GOTO295
  64. 320 Y2=SGN(Y1-Y):X2=SGN(X1-X):Y3=Y:X3=X
  65. 325 FORJ=1TOL-1:IFB(X3,Y3,.)<>.THEN295
  66. 330 IFX2*Y2<>.THENIFB(X3+X2,Y3,.)=B(X3,Y3+Y2,.)THENIFB(X3,Y3+Y2,.)<>.THEN295
  67. 335 X3=X3+X2:Y3=Y3+Y2:NEXT
  68. 340 IFB(X3,Y3,.)<>.THEN295
  69. 345 Y$="[209]":FORJ=1TOL:B(X,Y,.)=C+1:GOSUB715:X=X+X2:Y=Y+Y2:NEXTJ,C
  70. 350 PRINTE$;"NOW I AM READY..":S=.:H9=.
  71. 355 FORC=.TO4:L=L(C)
  72. 360 D=INT(RND(1)*4):X1=L-1:Y1=L-1
  73. 365 IFD=2THENX1=.
  74. 370 IFD=.THENY1=.
  75. 375 X=INT(RND(1)*(10-X1)):IFD=3THENX=X+X1
  76. 380 Y=INT(RND(1)*(10-Y1)):Y3=Y:X3=X:X2=SGN(2-D):Y2=SGN(Y1)
  77. 385 FORJ=1TOL-1:IFB(X3,Y3,1)<>.THEN360
  78. 390 IFX2*Y2<>.THENIFB(X3+X2,Y3,1)=B(X3,Y3+Y2,1)THENIFB(X3,Y3+Y2,1)<>.THEN360
  79. 395 X3=X3+X2:Y3=Y3+Y2:NEXT
  80. 400 IFB(X3,Y3,1)<>.THEN360
  81. 405 FORJ=1TOL:B(X,Y,1)=C+1:X=X+X2:Y=Y+Y2:NEXTJ,C
  82. 410 PRINTE$;
  83. 415 PRINTE$;:PRINT"INPUT YOUR SHOT":ML=2:GOSUB805:Y$=B$:PRINT"[146]"E$;"OKAY";
  84. 420 GOSUB690:IFE=1THEN410
  85. 425 B=B(X,Y,1):IFB>9GOTO410
  86. 430 GOSUB870
  87. 435 B(X,Y,1)=B+10:Y$="[215]":IFB=.THEN455
  88. 440 Y$="[214]":H(B-1,1)=H(B-1,1)+1:IFH(B-1,1)<L(B-1)THEN455
  89. 445 PRINTE$;N$(B-1);" SUNK":FORC=1TO500:NEXT:FORC=.TO4:IFH(C,1)<L(C)THEN455
  90. 450 NEXT:GOTO740
  91. 455 IFY$="[215]"THENGOSUB890:GOTO465
  92. 460 GOSUB880
  93. 465 GOSUB720
  94. 470 ONSGOTO500,540
  95. 475 X=INT(RND(1)*10):Y=INT(RND(1)*10)
  96. 480 B=B(X,Y,.):IFB<9THEN570
  97. 485 X=X+3:IFX<10THEN480
  98. 490 X=X-10:Y=Y+1:IFY<10THEN480
  99. 495 Y=Y-10:GOTO480
  100. 500 X1=X9-D:X2=X9+D:Y1=Y9-D:Y2=Y9+D
  101. 505 IFX1<.THENX1=.
  102. 510 IFY1<.THENY1=.
  103. 515 IFX2>9THENX2=9
  104. 520 IFY2>9THENY2=9
  105. 525 FORX=X1TOX2:FORY=Y1TOY2
  106. 530 B=B(X,Y,.):IFB<9THEN570
  107. 535 NEXTY,X:D=D+1:GOTO500
  108. 540 X=X9:Y=Y9
  109. 545 X=X+X8:Y=Y+Y8:IFX<.ORX>9ORY<.ORY>9THEN560
  110. 550 B=B(X,Y,.):IFB<9THEN570
  111. 555 B=B-10:IFB>.THEN545
  112. 560 IFS1=1THENS=1:GOTO500
  113. 565 S1=1:X8=-X8:Y8=-Y8:GOTO540
  114. 570 PRINTE$;"MY TURN       ":GOSUB870
  115. 575 B(X,Y,.)=B+10:Y$="[215]":H7=.:H8=SGN(B):H9=H9+H8:X$="MISS":IFB=.THEN590
  116. 580 B=B-1:Y$="[214]":X$="HIT":H(B,.)=H(B,.)+1:IFH(B,.)<L(B)THEN590
  117. 585 H7=1:H9=H9-L(B):X$="[157][157]I SINK "+N$(B)
  118. 590 IFX$="MISS"THENGOSUB890:GOTO600
  119. 595 GOSUB880
  120. 600 GOSUB715:PRINTE$;"I ";X$;" AT ";CHR$(X+65);CHR$(Y+48):FORJ=1TO1000:NEXT
  121. 605 FORJ=.TO4:IFH(J,.)<L(J)THEN615
  122. 610 NEXT:GOTO745
  123. 615 ONSGOTO630,655
  124. 620 IFH8=1THENS=1:D=1:X9=X:Y9=Y
  125. 625 GOTO415
  126. 630 IFH9=.THENS=.:GOTO415
  127. 635 IFH8=.GOTO415
  128. 640 X8=X-X9:Y8=Y-Y9:S1=.
  129. 645 IFX8=SGN(X8)ANDY8=SGN(Y8)THENS=2
  130. 650 GOTO415
  131. 655 IFH7=.GOTO415
  132. 660 S=1
  133. 665 IFH9=.THENS=.
  134. 670 GOTO415
  135. 675 PRINT""CHR$(Z+48)">"Z$"<"CHR$(Z+48)"[146]"SPC(10)""CHR$(Z+48)">"Z$"<";
  136. 680 PRINTCHR$(Z+48)
  137. 685 RETURN
  138. 690 P=1:E=.
  139. 695 FORZ=PTOLEN(Y$)-1:X=ASC(MID$(Y$,Z))-65:IFX>=.ANDX<=9THEN705
  140. 700 NEXT:E=1:RETURN
  141. 705 FORP=ZTOLEN(Y$):Y=ASC(MID$(Y$,P))-48:IFY>=.ANDY<=9THENRETURN
  142. 710 NEXT:GOTO700
  143. 715 PRINT"";TAB(27);:GOTO725
  144. 720 PRINT"";
  145. 725 FORQ=1TOY+6:PRINT"";:NEXT
  146. 730 FORQ=1TOX+1:PRINT"";:NEXT
  147. 735 PRINT"[157]";Y$:RETURN
  148. 740 GOSUB720:PRINTE$;"YOU WIN":GOTO770
  149. 745 FORT=.TO999:NEXT:PRINTE$;"I WIN -I'LL SHOW MY HIDDEN SHIPS"
  150. 750 FORX=.TO9:FORY=.TO9
  151. 755 B=B(X,Y,1):IFB=.ORB>9THEN765
  152. 760 Y$="[209]":GOSUB720
  153. 765 NEXT:NEXT
  154. 770 FORT=.TO999:NEXT:PRINTZ$;"ANOTHER GAME? (Y/N)                    "
  155. 775 GETA$:IFA$="Y"THENRUN
  156. 780 IFA$="N"THEN795
  157. 785 GOTO775
  158. 790 INPUTY$:IFLEFT$(Y$,1)<>"N"GOTO220
  159. 795 PRINTE$;"GOOD DAY THEN":FORT=.TO1000:NEXT:SYS64738
  160. 805 PRINTIB$"        ":B$="":PRINTIB$I$(ML);:POKE198,.
  161. 810 SP=SM+PEEK(CX)+PEEK(CY)*LL:POKESP,PEEK(SP)OR191
  162. 815 GETA$:IFA$=""THEN810
  163. 820 POKESP,PEEK(SP)-128:I=ASC(A$):IFPEEK(SP)=63THENPOKESP,160
  164. 825 IFI=20THEN855
  165. 830 IFI<32ORI>128ANDI<160THEN810
  166. 835 IFI=95THEN795
  167. 840 IFI=94THENRUN
  168. 845 B$=B$+A$:PRINTA$;:IFLEN(B$)<MLTHEN810
  169. 850 RETURN
  170. 855 I=LEN(B$):IFITHENB$=MID$(B$,1,I-1)
  171. 860 PRINT:PRINT"[145]"RIGHT$(IB$,16)I$(ML)B$;:GOTO810
  172. 865 SC=54272:FORT=SCTOSC+23:POKET,.:NEXT:POKET,15:POKE53269,.:RETURN
  173. 870 POKESC+5,130:POKESC+6,136:POKESC,255:POKESC+4,17
  174. 875 FORT=200TO.STEP-1:POKESC+1,T:FORTT=.TO12:NEXT:NEXT:POKESC+4,.:RETURN
  175. 880 POKESC+5,33:POKESC+6,129:POKESC+1,7:POKESC+4,129:FORT=15TO.STEP-1
  176. 885 POKESC+24,T:FORTT=.TO99:NEXT:NEXT:POKESC+4,.:POKESC+24,15:RETURN
  177. 890 POKESC+5,130:POKESC+6,136:POKESC+4,129:FORT=100TO 233:POKESC+1,T:NEXT
  178. 895 FORT=15TO.STEP-1:POKESC+24,T:FORTT=.TO22:NEXT:NEXT:POKESC+4,.:POKESC+24,15
  179. 900 RETURN
  180.