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