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