8-Bit Software Online Conversion
Battleships - Listing
10ON ERROR CLOSE#0:RUN
20MODE7:VDU23,1,0;0;0;0;
30PRINTTAB(12,10);CHR$141;CHR$134"BAT
TLESHIPS";TAB(12,11);CHR$141;CHR$134"BAT
TLESHIPS"
40PRINTTAB(11,13);CHR$132"By John Hen
son"
50PRINTTAB(14,23);"Press Space"
60PROCdefine
70REPEAT:UNTIL INKEY$(0)=" "
80DIM P1 100,P2 100
90PROCWIPE
100MODE1:GCOL3,3:VDU23,1,0;0;0;0;
110PROCGRID`DRAW
120PROCLABEL
130VDU29,640;0;
140GCOL3,3:PROCGRID`DRAW:PROCLABEL
150VDU29,0;0;
160PROCPLACE(1)
170VDU29,640;0;
180PROCPLACE(2)
190ON ERROR GOTO 1220
200*DELETE BFILE
210ON ERROR CLOSE#0:RUN
220CH=OPENOUT("BFILE")
230FORI=0TO99:BPUT#CH,P1?I:NEXT
240FORI=0TO99:BPUT#CH,P2?I:NEXT
250CLOSE#CH
260CLS:PRINT'"Will you be using joysti
cks for your"''"battle ?";
270REPEAT:J$=GET$:UNTIL J$="Y" OR J$="
N":PRINTJ$
280IF J$="Y" J%=1 ELSE J%=0
290CHAIN"SHIP"
300END
310DEFFNSQUARE(J,X,Y)
320IF J=1 =?(P1+(Y*10)+X)
330IF J=2 =?(P2+(Y*10)+X)
340DEFPROCWIPE
350LOCAL I
360FORI=0 TO 100
370P1?I=0:P2?I=0:NEXT:ENDPROC
380DEFPROCSET(J,X,Y,I)
390IF J=1 ?(P1+(Y*10)+X)=I
400IF J=2 ?(P2+(Y*10)+X)=I
410ENDPROC
420DEFPROCGRID`DRAW
430LOCAL I
440FOR I=0 TO 10*48 STEP 48
450MOVE 0,I:DRAW 480,I:NEXT
460FOR I=0 TO 10*48 STEP 48
470MOVE I,0:DRAW I,480:NEXT
480ENDPROC
490DEFPROCFILL`SQUARE(X,Y)
500LOCAL X1,Y1,I
510X1=X*48:Y1=Y*48
520FORI=X1+8 TO X1+48-8 STEP 4
530MOVE I,Y1+4:DRAW I,Y1+48-4:NEXT
540ENDPROC
550DATA 5,"n Aircraft Carrier",4," Bat
tle ship",3," Destroyer",2,"n Escort",2,
" Submarine"
560DEFPROCLABEL
570LOCAL I
580GCOL0,1:VDU5
590FORI=0 TO 432 STEP 48
600MOVEI,528:PRINTCHR$((I/48)+65)
610MOVE504,I+32:PRINTCHR$((I/48)+65)
620NEXT
630ENDPROC
640DEFPROCPLACE(J)
650RESTORE
660GCOL0,1:VDU4,17,3,28,0,12,39,0
670Q=0
680REPEAT
690READ A,A$
700CLS
710CLS:PRINT"Player ";J;", please ente
r X and Y grid"''"co-ordinates for a";A$
''"which is ";A;" squares long."
720PRINT'"X is ?";:INPUT""X$
730PRINT'"Y is ?";:INPUT""Y$
740X=ASC(X$)-65:Y=ASC(Y$)-65
750IF LEN(X$)<>1 OR LEN(Y$)<>1 CLS:GOT
O 710
760IFX<0 ORX>9 ORY<0 ORY>9 CLS:GOTO 71
0
770CLS
780PRINT"Player ";J;", enter the direc
tion"''"the ";RIGHT$(A$,LEN(A$)-1);" wil
l go"''"from location ";X$;",";Y$;"."
790PRINTTAB(34,0);"1 2 3";TAB(34,1);"
";TAB(34,2);"4 6";TAB(34,3);"
";TAB(34,4);"7 8 9"
800INPUT'"Direction 1 to 9 (not 5) ",D
810IFD=5 OR D<1 OR D>9 GOTO 770
820IFD=1 AND (X-A<1 OR Y+A>10)GOTO710
830IFD=2 AND Y+A>10 GOTO 710
840IFD=3 AND (X+A>10 OR Y+A>10)GOTO710
850IFD=4 AND X-A<1 GOTO 710
860IFD=9 AND (X+A>10 OR Y-A<1)GOTO710
870IFD=6 AND X+A>10 GOTO 710
880IFD=7 AND (X-A<1 OR Y-A<1)GOTO710
890IFD=8 AND Y-A<1 GOTO 710
900X$="":Y$=""
910ON D GOTO 920,930,940,950,960,970,9
80,990,1000
920X$="-":Y$="+":GOTO1010
930X$="":Y$="+":GOTO1010
940X$="+":Y$="+":GOTO1010
950X$="-":Y$="":GOTO1010
960X$="":Y$="":GOTO1010
970X$="+":Y$="":GOTO1010
980X$="-":Y$="-":GOTO1010
990X$="":Y$="-":GOTO1010
1000X$="+":Y$="-":GOTO1010
1010IF X$<>"" XT=EVAL("X"+X$+"A") ELSE
XT=99
1020IF Y$<>"" YT=EVAL("Y"+Y$+"A") ELSE
YT=99
1030FLAG=FALSE:TEMPX=X:TEMPY=Y
1040REPEAT
1050IF FNSQUARE(J,X,Y)<>0 FLAG=TRUE:GOT
O 1080
1060 IF X$<>"" X=EVAL("X"+X$+"1")
1070 IF Y$<>"" Y=EVAL("Y"+Y$+"1")
1080UNTIL FLAG OR X=XT OR Y=YT
1090IF FLAG GOTO 710
1100X=TEMPX:Y=TEMPY
1110REPEAT
1120PROCFILL`SQUARE(X,Y)
1130PROCSET(J,X,Y,1)
1140IF X$<>"" X=EVAL("X"+X$+"1")
1150IF Y$<>"" Y=EVAL("Y"+Y$+"1")
1160UNTIL FLAG OR X=XT OR Y=YT
1170Q=Q+1
1180CLS:UNTIL Q=5
1190GCOL0,2:VDU19,2,2,0,0,0
1200FORI%=4 TO 476 STEP 8:MOVE4,I%:DRAW
476,I%:NEXT:FOR I%=8 TO 476 STEP 8:MOVE4
,I%:DRAW476,I%:NEXT
1210ENDPROC
1220IF ERR=214 GOTO 210
1230CLS
1240REPORT:PRINT;" at line ";ERL:END
1250DEFPROCdefine:FORL%=128 TO 224 STEP
96
1260VDU23,L%,16,56,124,254,56,56,56,56
1270VDU23,L%+1,63,31,15,31,59,113,224,6
4
1280VDU23,L%+2,8,12,126,127,126,12,8,0
1290VDU23,L%+3,64,224,113,59,31,15,31,6
3
1300VDU23,L%+4,56,56,56,56,254,124,56,1
6
1310VDU23,L%+5,2,7,142,220,248,240,248,
252
1320VDU23,L%+6,16,48,126,254,126,48,16,
0
1330VDU23,L%+7,252,248,240,248,220,142,
7,2:NEXT
1340ENDPROC