8-Bit Software Online Conversion

:0.$.BSHIPS3 - Listing

10REM BATTLESHIPS - version 3A 20REM (c) M.Bobrowski 9'90 30MODE4:LOMEM=PAGE+&1F00:W%=LOMEM-&16 0:*FX202,32 40DIMS%(3,9,9),N$(10),V%(10),D%(1,3): PROCs:REPEAT:PROCi:PROCp:PROCc:UNTILNOTF Ny("Another Game"):END 50DEFPROCi:FORI%=0TO9:FORJ%=0TO9:FORK %=0TO3:S%(K%,I%,J%)=0:NEXT,,:PROCd:H%=0: PRINT"Calculating. Please wait a moment. .":FORI%=10TO1STEP-1:PROCh(I%,V%(I%)):NE XT:CLS:PRINT" All my ships are in place. "''" Position your ships now !":CALL&927 :Z=INKEY(300):SOUND1,-10,200,2:FORI%=10T O1STEP-1:PROCA(I%,V%(I%)):NEXT:PROCo:END PROC 60DEFPROCh(N%,L%):LOCALo:REPEAT:IFRND (2)=1o=FNc(L%)ELSEo=FNh(L%) 70UNTILo:ENDPROC 80DEFFNc(L%):LOCALX%,Y%,C%,I%,J%:X%=R ND(10)-1:Y%=RND(10-L%)-1:FORI%=X%-1TOX%+ 1:FORJ%=Y%-1TOY%+L%:IFI%>-1ANDI%<10ANDJ% >-1ANDJ%<10C%=C%+S%(0,I%,J%) 90NEXT,:IFC%>0THEN=FALSE 100FORI%=0TOL%-1:S%(0,X%,Y%+I%)=N%:NEX T:=TRUE 110DEFFNh(L%):LOCALX%,Y%,C%,I%,J%:X%=R ND(10-L%)-1:Y%=RND(10)-1:FORI%=X%-1TOX%+ L%:FORJ%=Y%-1TOY%+1:IFI%>-1ANDI%<10ANDJ% >-1ANDJ%<10C%=C%+S%(0,I%,J%) 120NEXT,:IFC%>0THEN=FALSE 130FORI%=0TOL%-1:S%(0,X%+I%,Y%)=N%:NEX T:=TRUE 140DEFPROCA(N%,L%):LOCALX%,Y%,o:REPEAT :PROCo:SOUND1,-10,200,2:CLS:PRINT"Positi on of "N$(N%);" : ";:PROCe:IFL%>1PRINT"P osition it horizonally or"'"vertically ( H,V) ? ";:REPEATA$=GET$:UNTILINSTR("HV", A$):PRINTA$ELSEA$="H" 150IFA$="H"o=FNp(L%)ELSEo=FNv(L%) 160IFNOToSOUND1,2,200,20:PRINT'"ILLEGA L PLACING";:FORZ=0TO4000:NEXT 170UNTILo:PRINT'"OK";:ENDPROC 180DEFPROCo:LOCALI%,J%:VDU5:FORI%=0TO9 :FORJ%=0TO9:V%=S%(1,J%,I%):IFV%=0ELSEMOV E136+J%*44,746-I%*44:IFV%<11VDU229ELSEIF V%>11GCOL1,0:VDU228:GCOL0,1 190NEXT,:VDU4:ENDPROC 200DEFFNp(L%):LOCALI%,J%,C%:IFX%+L%>10 THEN=FALSE 210FORI%=X%-1TOX%+L%:FORJ%=Y%-1TOY%+1: IFI%>-1ANDI%<10ANDJ%>-1ANDJ%<10C%=C%+S%( 1,I%,J%) 220NEXT,:IFC%>0THEN=FALSE 230FORI%=0TOL%-1:S%(1,X%+I%,Y%)=N%:NEX T:=TRUE 240DEFFNv(L%):LOCALI%,J%,C%:IFY%+L%>10 THEN=FALSE 250FORI%=X%-1TOX%+1:FORJ%=Y%-1TOY%+L%: IFI%>-1ANDI%<10ANDJ%>-1ANDJ%<10C%=C%+S%( 1,I%,J%) 260NEXT,:IFC%>0THEN=FALSE 270FORI%=0TOL%-1:S%(1,X%,Y%+I%)=N%:NEX T:=TRUE 280DEFPROCp:CLS:PRINT" Now let's start the battle.":B%=RND(2)-2:Q%=20:P%=20:PR INT'" This time ";:IFB%PRINT"you begin." ;ELSEPRINT"I begin."; 290PROCu:PROCn:REPEAT:CLS:IFB%PROClELS EPROCm 300B%=NOTB%:UNTILQ%=0ORP%=0:ENDPROC 310DEFPROCl:LOCALX%,Y%,Z%:CLS:PRINT"Yo ur go. ";:REPEAT:SOUND1,-10,200,2:PRINT" Position : ";:PROCe:IFS%(3,X%,Y%)<>0PRIN T"Already shot !"':SOUND1,2,200,20 320UNTILS%(3,X%,Y%)=0:SOUND1,-10,200,2 :Z%=(S%(0,X%,Y%)<>0ANDNOT(S%(0,X%,Y%)AND 16)):S%(3,X%,Y%)=1-Z%:S%(0,X%,Y%)=S%(0,X %,Y%)-Z%*16:IFZ%PRINT''"A HIT !" 330Q%=Q%+Z%:PROCt:IFZ%PROC3:PROCk 340ENDPROC 350DEFPROCt:VDU5:V%=S%(3,X%,Y%):IFV%=0 ELSEMOVE764+X%*44,746-Y%*44:IFV%=1VDU227 ELSEVDU228 360VDU4:ENDPROC 370DEFPROCk:LOCALV%,C%,I%,J%:V%=S%(0,X %,Y%):FORI%=0TO9:FORJ%=0TO9:IFS%(0,I%,J% )=V%:C%=C%+1 380NEXT,:IFC%<V%(V%AND15)ENDPROC 390PRINT'"You sunk my "N$(V%AND15)".": PROCn:ENDPROC 400DEFFNs(X%,Y%):IFX%<0ORY%<0ORX%>9ORY %>9THEN=1ELSE=S%(2,X%,Y%) 410DEFPROCm:LOCALX%,Y%:IFH%=0PROCrELSE PROCB 420PROCy:ENDPROC 430DEFPROCr:R%=RND(4)-1:REPEAT:X%=RND( 10)-1:Y%=RND(10)-1:UNTILS%(2,X%,Y%)=0:EN DPROC 440DEFPROCy:PROCC:SOUND1,-10,0,10:PRIN T"My shot is at "CHR$(X%+65);Y%;". Is th is a hit,"'"a sinking, or a miss (H,S,M) ? ";:TIME=1:REPEAT:G%=INKEY(0):IFTIMEMO D1000=0SOUND1,2,150,5 450A$=CHR$G%:UNTILINSTR("HMS",A$):VDU4 :PRINTA$:PROCC:S%(1,X%,Y%)=S%(1,X%,Y%)+1 6:IFA$="M"S%(2,X%,Y%)=1:ENDPROC 460P%=P%-1:S%(2,X%,Y%)=2:PROCa:PROC3:E %=X%:O%=Y%:IFH%=0:F%=X%:A%=Y% 470H%=H%+1:IFA$="H"ENDPROC 480IFF%=E%PROCv(H%)ELSEPROCg(H%) 490H%=0:PROCu:ENDPROC 500DEFPROCC:VDU5:GCOL4,0:MOVE136+X%*44 ,746-Y%*44:VDU226:GCOL0,1:VDU4:ENDPROC 510DEFPROCa:VDU24,136+X%*44;714-Y%*44; 168+X%*44;746-Y%*44;16:MOVE136+X%*44,746 -Y%*44:GCOL0,1:VDU5,224,4,24,0;0;1279;10 23;:ENDPROC 520DEFPROCD(D%):D%=(D%+8)MOD4:X%=X%+D% (0,D%):Y%=Y%+D%(1,D%):ENDPROC 530DEFPROCB:LOCALR%,T%:R%=RND(4)-1:PRO CE(F%,A%):IFT%ENDPROC 540PROCE(E%,O%):IFT%ENDPROC 550IFT%THENENDPROC 560PROCb(F%,A%):IFT%ENDPROC 570PROCb(E%,O%):IFT%ENDPROC 580PROCF:ENDPROC 590DEFPROCE(U%,V%):LOCALI%:FORI%=0TO3: X%=U%:Y%=V%:PROCD(I%+R%):IFFNs(X%,Y%)=2P ROC1(I%+R%) 600NEXT:ENDPROC 610DEFPROC1(D%):REPEAT:PROCD(D%):UNTIL FNs(X%,Y%)<>2:IFFNs(X%,Y%)=0T%=TRUE:R%=D %:I%=3 620ENDPROC 630DEFPROCb(U%,V%):LOCALI%:FORI%=0TO3: X%=U%:Y%=V%:PROCD(I%+R%):IFFNs(X%,Y%)=0T %=TRUE:I%=3 640NEXT:ENDPROC 650DEFPROCv(L%):LOCALI%,J%,S%,a%:FORI% =0TO9:IFS%(2,X%,I%)=2:a%=I%:I%=9 660NEXT:S%=X%:FORI%=S%-1TOS%+1:FORJ%=a %-1TOa%+L%:IFI%>-1ANDI%<10ANDJ%>-1ANDJ%< 10S%(2,I%,J%)=1 670NEXT,:ENDPROC 680DEFPROCg(L%):LOCALI%,J%,S%,a%:FORI% =0TO9:IFS%(2,I%,Y%)=2:S%=I%:I%=9 690NEXT:a%=Y%:FORI%=S%-1TOS%+L%:FORJ%= a%-1TOa%+1:IFI%>-1ANDI%<10ANDJ%>-1ANDJ%< 10S%(1,I%,J%)=1 700NEXT,:ENDPROC 710DEFPROCc:IFP%=0PRINT''"I win..!!"EL SEPRINT''"You win ..!!"'"Congratulations ." 720IFQ%=0CALL&900:ENDPROCELSEIFNOTFNy( "Do you wish to see the positions of my ships")ENDPROC 730VDU5:FORI%=0TO9:FORJ%=0TO9:V%=S%(0, I%,J%):IFV%>0ANDV%<11MOVE764+I%*44,746-J %*44:VDU229:SOUND1,2,I%*J%*3,3:SOUND1,0, 0,3 740NEXT,:VDU4:ENDPROC 750DEFFNy(A$):PRINTA$;" (Y/N) ? ";:REP EAT:A$=GET$:UNTILINSTR("YN",A$):PRINTA$: CALL&927:=(A$="Y") 760DEFPROCG:PRINT"The computer will fi rst position its"'"own ships. Then it wi ll ask you for"'"the positions of your s hips."'"The ships are as follows:"''" A ircraft carrier - 4 squares"'" Battlesh ip"TAB(19)"- 3 squares" 770PRINT" Destroyer"TAB(19)"- 3 squar es"'" Cruiser"TAB(19)"- 2 squares"'" F rigate"TAB(19)"- 2 squares"'" Minesweep er"TAB(19)"- 2 squares"'" Submarine"TAB (19)"- 1 square"'" Tug boat"TAB(19)"- 1 square":PRINT" Patrol Boat"TAB(19)"- 1 square"'" Dinghy"TAB(19)"- 1 square" 780PRINT'"When all the ships are in po sition"'"the game begins. The object of the"'"game is to sink all the computer's "'"ships before it sinks yours. The only "'"problem is that you do not know where "'"each other's ships are.":PROCH 790PRINT"Positions for shots are, for example,"'"D3, which is: column D and ro w 3."''"When calculating its move the co mputerdoes not look at the positions of yourships at all, so you will have to te ll" 800PRINT"it if it has hit , missed or sunk yourship. Be very careful not to li e, as"'"the computer will find you out." :PROCH:ENDPROC 810DEFPROCF:CLS:SOUND1,2,200,20:PRINT" I can't find the rest of this ship"'" I think you LIE!";:FORZ=1TO7000:NEXT:SOUN D1,3,150,30:PROC3:PROC3:PRINT;SPC21;"BYE !":END 820DEFPROCs:FORI%=0TO&11CSTEP4:I%!&900 =I%!(PAGE+&1C80):NEXT:FORI%=0TO3:READD%( 0,I%),D%(1,I%):NEXT:FORI%=1TO10:READN$(I %),V%(I%):NEXT:CLS:VDU23;8202;0;0;0;19,0 ,4;0;19,1,3;0; 830VDU23,224,170,85,170,85,170,85,170, 85,23,225,0,24,38,193,0,24,38,193,23,226 ,24,24,24,255,255,24,24,24,23,227,0,60,6 6,66,66,66,60,0,23,228,0,60,126,126,126, 126,60,0,23,229,255,255,255,255,255,255, 255,255 840ENVELOPE1,5,0,0,0,0,0,0,120,-5,-2,- 10,63,63:ENVELOPE2,4,4,8,128,4,8,128,126 ,0,0,-126,126,126:ENVELOPE3,132,-1,0,0,5 0,0,0,20,-1,-1,-12,100,0:ENVELOPE4,1,0,0 ,0,0,0,0,126,-1,0,-20,126,30:PROCI:PROCw (32,912,1248,1000):PROCx("B A T T L E S H I P S",272,964):VDU28,1,31,38,7:CALL &900:PROCG 850VDU26,12:FORI%=0TO4:PRINTSTRING$(25 5,CHR$224);:NEXT:VDU5:MOVE1122,30:PRINTS TRING$(6,CHR$224):PROCI:FORI%=0TO3:READa ,b,c,d:PROCw(a,b,c,d):NEXT:FORI%=0TO172S TEP4:I%!&5AC8=I%!W%:NEXT:FORI%=0TO172STE P4:I%!&5C08=I%!(W%+&B0):NEXT:PROCJ(172,8 90):PROCJ(1100,888):VDU18,4,0:MOVE52,870 :PRINTSTRING$(37,CHR$225):VDU18,0,1,4:EN DPROC 860DEFPROCd:VDU5,24,56;256;600;776;16, 24,684;256;1228;776;16,26:x=128:FORy=312 TO752STEP44:MOVE128,y:DRAW568,y:MOVEx,31 2:DRAWx,752:MOVE756,y:DRAW1196,y:MOVE628 +x,312:DRAW628+x,752:x=x+44:NEXT:a=65:b= 48:y=744:FORx=136TO532STEP44:MOVEx,296:V DUa:MOVE80,y:VDUb:MOVEx+628,296:VDUa:MOV E708,y:VDUb:a=a+1:b=b+1:y=y-44:NEXT:VDU4 870VDU28,2,29,37,26,12:ENDPROC 880DEFPROCI:GCOL0,1:MOVE0,0:DRAW0,1023 :DRAW1279,1023:DRAW1279,0:DRAW0,0:ENDPRO C 890DEFPROCJ(X,Y):VDU29,X;Y;:MOVE-4,20: MOVE-100,0:PLOT85,-88,-32:MOVE-4,-32:PLO T85,-4,20:MOVE4,20:MOVE100,0:PLOT85,88,- 32:MOVE4,-32:PLOT85,4,20:MOVE-60,40:DRAW 60,40:MOVE60,16:PLOT85,0,28:MOVE-60,16:P LOT85,-60,40:MOVE-40,48:MOVE40,48:PLOT85 ,40,56:MOVE-40,56:PLOT85,-40,48 900MOVE0,56:DRAW0,72:MOVE-10,64:DRAW12 ,64:MOVE-50,28:PLOT22,-20,28:MOVE52,28:P LOT22,20,28:PLOT69,8,32:PLOT69,-8,32:VDU 26:ENDPROC 910DEFPROCw(L%,B%,R%,T%):VDU18,0,129,1 8,0,0,24,L%-16;B%-16;R%-16;T%-16;16,26:M OVEL%-16,B%-16:DRAWR%-16,B%-16:DRAWR%-16 ,T%-16:DRAWL%-16,T%-16:DRAWL%-16,B%-16:V DU18,0,128,18,0,1,24,L%;B%;R%;T%;16,26:M OVEL%,B%:DRAWR%,B%:DRAWR%,T%:DRAWL%,T%:D RAWL%,B%:ENDPROC 920DEFPROCx(A$,x,y):VDU18,0,1,5:FORB=y -4TOy+4STEP4:FORA=x-4TOx+4STEP4:MOVEA,B: PRINT;A$;:NEXT,:GCOL0,0:MOVEx,y:PRINT;A$ ;:VDU18,0,1,4:ENDPROC 930DEFPROCH:LOCALA$,B$,C$,I%:OSCLI"FX2 1":A$=STRING$(19," ")+"Press <SPACE BAR> ":REPEAT:B$=INKEY$0:C$=RIGHT$(A$,1):A$=C $+LEFT$(A$,35):PRINTTAB(1,23);A$:FORI%=0 TO1000:NEXT:UNTILB$=" ":CLS:PROCI:ENDPRO C 940DEFPROCe:LOCALM%,N%:M%=POS:N%=VPOS: REPEAT:IFFNk=0PRINTTAB(M%,N%)SPC2;:PRINT TAB(M%,N%); 950UNTILINKEY-74:PRINT':ENDPROC 960DEFFNk:REPEAT:G%=GET:UNTILG%>64ANDG %<75:PRINTCHR$G%;:X%=G%-65:REPEAT:G%=GET :UNTILG%>47ANDG%<58:VDUG%:Y%=G%-48:REPEA TUNTILINKEY-90ORINKEY-74:IFINKEY-90THEN= 0:ELSE=-1 970DEFPROCu:FORK%=0TO225STEP4:SOUND1,- K%DIV15,K%,1:NEXT:ENDPROC 980DEFPROCn:FORK%=225TO1STEP-4:SOUND1, -K%DIV15,K%,1:NEXT:ENDPROC 990DEFPROC3:SOUND0,4,6,20:FORZ=0TO1200 :NEXT:ENDPROC 1000DATA0,1,1,0,0,-1,-1,0,Dinghy,1,Patr ol Boat,1,Tug Boat,1,Submarine,1,Mineswe eper,2,Frigate,2,Cruiser,2,Destroyer,3,B attleship,3,Aircraft Carrier,4,48,248,60 8,784,676,248,1236,784,48,832,1236,1000, 48,32,1236,212