home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
UpTime Volume 1 #9
/
utv1n9s1.d64
/
battleship.exe
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-28
|
9KB
|
253 lines
10 rem battleship 64
13 rem by mike cooke
16 rem copyright 1987
19 rem published by uptime
22 rem
26 clr
28 print"[147] "
31 print" "tab(7)" "tab(31)" "tab(38)" "
34 print" "tab(8)" [146][155] [\]]^_!#$% &'(";
37 printtab(30)" "tab(38)" "
40 print" "tab(9)" "tab(29)" "tab(38)" "
43 print" "tab(10)" "tab(38)" "
46 print" "tab(11)" [155][146] battle screen "tab(38)" "
49 print" "tab(12)" "tab(38)" "
52 fort=1to11:print" "tab(19)" "tab(38)" ":nextt
55 print" "
57 print" [151]press[155] f8[151] to return to uptime"
58 print"[154]allies"tab(31)"enemies"
61 print"[152]abcdefghijklmno"tab(23)"abcdefghijklmno"
64 print"0[157]1[157]2[157]3[157]4[157]5[157]6[157]7[157]8[157]9"
67 printtab(22)"[145][145][145][145][145][145][145][145][145][145]0[157]1[157]2[157]3[157]4[157]5[157]6[157]7[157]8[157]9[154]"
70 y=1346:fort=0to9:forz=0to14:pokey+(t*40)+z,103:pokey+(t*40)+z+21,103
73 poke55618+(t*40)+z,14:poke55618+(t*40)+z+21,14:nextz,t
76 fort=1to8:poke1362+t*40,102:poke1364+t*40,102:nextt:ifflag=1thenreturn
79 v=53248:pokev+16,1:pokev,35:pokev+1,75:pokev+2,50:pokev+3,75:pokev+21,3
82 rem * variables *
85 cv$="[193][157][194][157][195][157][196][157][197]":ch$="[210][211][212][213][214]"
88 bv$="[198][157][199][157][200][157][201]":bh$="[215][216][217][218]"
91 dv$="[202][157][203][157][204]":dh$="[219][220][221]"
94 sv$="[205][157][206][157][207]":sh$="[255][223][161]"
97 pv$="[208][157][209]":ph$="[162][163]"
100 dimsh$(9,3):dimhi(9,3):dimp1$(9,6):dimp2$(9,6)
103 fort=1to8:fory=1to2:readsh$(t,y):nexty,t
106 rem * ship data *
109 data carrier,5,battleship,4,destroyer 1,3,destroyer 2,3,sub 1,3,sub 2,3
112 data pt boat 1,2,pt boat 2,2
115 gosub124
118 goto142
121 rem * some sub routines *
124 rem ... clear space ...
127 fort=1823to2022:poket,32:nextt
130 print"":return
133 rem ... press key ...
134 poke 198,0
136 printtab(14)"press return[152]";
139 geta$:ifa$="[140]"then1000
140 ifa$<>chr$(13)then139
141 return
142 rem beginning inputs
145 printtab(11)"[152]how many players?":printtab(16)"1 or 2?"
146 getnp$:ifnp$="[140]"then1000
147 np=val(np$):ifnp<1ornp>2then 146
148 rem
151 rem player one input
154 rem
210 gosub124:print" player one input":pn=0
212 ifnp=1thenprint" the enemy promises not to look":goto217
214 print" player two please turn away"
217 gosub133:gosub124
218 fors=1to8
220 printtab(6)"[155]"sh$(s,1)":":printtab(8)"[152]start on ";
230 getl$:ifl$="[140]"then1000
231 ifl$<"a"orl$>"o"then230
235 print"";l$;:st$=l$:l$=""
240 getl$:ifl$="[140]"then1000
241 ifl$<"0"orl$>"9"then240
245 printl$:st$=st$+l$:l$="":printtab(8)"[152]point ";
255 getl$:ifl$="[140]"then1000
256 ifl$<>"r"andl$<>"l"andl$<>"u"andl$<>"d"then255
260 ifl$="r"thenprint"right":goto280
265 ifl$="l"thenprint"left":goto281
270 ifl$="u"thenprint"up":goto291
275 ifl$="d"thenprint"down":goto290
280 cs=55616:forc=1toval(sh$(s,2)):goto282
281 cs=55616:forc=-(val(sh$(s,2)))+2to1
282 vv=(cs+(asc(st$)-64)+(val(right$(st$,1))*40)+pn*21+c)
283 vp=peek(vv):ifvp-(int(vp/16)*16)<>14then315
284 nextc:goto320
290 cs=55577:forc=1toval(sh$(s,2)):goto292
291 cs=55577:forc=-(val(sh$(s,2)))+2to1
292 vv=(cs+(asc(st$)-64)+(val(right$(st$,1))*40)+pn*21+c*40)
293 vp=peek(vv):ifvp-(int(vp/16)*16)<>14then315
294 nextc:goto340
315 gosub124:printtab(9)"[155]illegal sector, capt":printtab(11)"please try again"
316 gosub133:gosub124:goto220
320 ifl$="l"thens$=chr$(asc(st$)-val(sh$(s,2))+1)+right$(st$,1):st$=s$:l$="r"
322 print"":ford=1to7+val(right$(st$,1)):print:nextd
324 printtab((asc(st$)-63)+pn*21);"[152]";
325 onsgosub326,327,328,328,329,329,330,330:goto370
326 printch$:return
327 printbh$:return
328 printdh$:return
329 printsh$:return
330 printph$:return
340 ifl$="u"thens$=left$(st$,1)+str$((val(right$(st$,1)))-(val(sh$(s,2))-1))
341 ifl$="u"thenst$=s$
342 print"":ford=1to7+val(right$(st$,1)):print:nextd
344 printtab((asc(st$)-63)+pn*21);"[152]";
345 onsgosub346,347,348,348,349,349,350,350:goto400
346 printcv$:return
347 printbv$:return
348 printdv$:return
349 printsv$:return
350 printpv$:return
370 rem put ship in array
375 rem right
380 ford=1toval(sh$(s,2))
385 ifpn=0thenp1$(s,d)=chr$(asc(st$)+d-1)+right$(st$,1)
386 ifpn=1thenp2$(s,d)=chr$(asc(st$)+d-1)+right$(st$,1)
390 nextd:gosub124:nexts:goto450
400 rem down
405 ford=1toval(sh$(s,2))
410 ifpn=0thenp1$(s,d)=left$(st$,1)+chr$(asc(right$(st$,1))+d-1)
411 ifpn=1thenp2$(s,d)=left$(st$,1)+chr$(asc(right$(st$,1))+d-1)
420 nextd:gosub124:nexts
450 rem player two
451 ifnp=1then500
452 ifpn=1then600
455 print"[152] ready to clear the grid for player two":gosub133:flag=1:gosub70
460 gosub124:print" player two input"
465 print"[145] player one please turn away":pn=1
470 goto217
500 rem computer player setup
505 print" [152]the enemies are placing their ships..."
510 open15,8,15,"i0":open1,8,2,"battledata2,l,"+chr$(100)
515 input#15,a,b$:ifa<20ora=50then520
516 print"disk error...please correct.":gosub133:gosub124:close1:close15:goto500
520 r=int(rnd(1)*20)+1
525 print#15,"p"+chr$(98)+chr$(r)+chr$(0)
530 input#1,a$
535 print#15,"p"+chr$(98)+chr$(r)+chr$(0)
540 close1:close15
545 t=1:fors=1to8:forc=1toval(sh$(s,2))
550 p2$(s,c)=mid$(a$,t,2):t=t+2
555 nextc:nexts
600 rem battle
602 ifnp=2then605
603 gosub124:print"[152] prepare for the battle":gosub133:goto620
605 print"[152] prepare to clear the grid for battle":gosub133:flag=1:gosub70
620 pn=0
622 gosub124
623 ifnp=1andpn=1then950
625 ifpn=0thenprint"[155] allies attack([152]"
630 ifpn=1thenprint"[155] enemies attack([152]"
635 printtab(10)"sector to attack: ";
640 getl$:ifl$="[140]"then1000
645 ifl$<"a"orl$>"o"then640
650 print""l$;:at$=l$:l$=""
655 getl$:ifl$="[140]"then1000
660 ifl$<"0"orl$>"9"then655
665 at$=at$+l$:printl$
667 cs=55617
670 ifpn=0thense=(cs+(asc(at$)-64)+(val(right$(at$,1))*40)+21):vp=peek(se)
671 ifpn=1thense=(cs+(asc(at$)-64)+(val(right$(at$,1))*40)):vp=peek(se)
675 ifvp-int(vp/16)*16=14then680
676 gosub124:print"[152] we have attacked there, capt":gosub133:goto622
680 printtab(12)"fireing...";:gosub2000
685 fors=1to8:forc=1to5
690 onpn+1goto700,710
700 ifp2$(s,c)=at$then720
701 goto715
710 ifp1$(s,c)=at$then720
715 nextc,s:goto900
720 rem hit
721 pokese,2:pokese-54272,100
722 printtab(17)"hit(([152]"
725 gosub2500:gosub124
726 ifpn=0thenprint"[155] allies attack([152]"
727 ifpn=1thenprint"[155] enemies attack([152]"
729 printtab(20-(len(sh$(s,1))+14)/2)"ship damaged: ";sh$(s,1)"[152]"
730 ifpn=0thenhi(s,2)=hi(s,2)+1:ifhi(s,2)=val(sh$(s,2))then740
731 ifpn=1thenhi(s,1)=hi(s,1)+1:ifhi(s,1)=val(sh$(s,2))then740
735 gosub133:ifpn=0thenpn=1:goto737
736 pn=0
737 goto622
740 printtab(9)"she is sunk, captian("
741 ifpn=0thens2=s2+1:poke1364+s2*40,24:poke1364+s2*40+54272,2
742 ifpn=1thens1=s1+1:poke1362+s1*40,24:poke1362+s1*40+54272,2
745 ifs1<8ands2<8then735
750 rem finished
751 fort=1to1000:nextt
755 print"[147][152]":ifpn=0thenw$="allies":l$="enemies"
757 ifpn=1thenw$="enemies":l$="allies"
759 print:print:print" the ";w$;"[152] are the victors("
761 print:print" sorry ";l$;"[152]((("
762 print
763 fort=1to4
764 print" [152]":nextt
765 v=53248:fort=75to115:fory=1to50:nexty
766 ifpn=0thenpokev+1,t
767 ifpn=1thenpokev+3,t
768 nextt
769 print:print" would you like to play again or"
770 printtab(11)"return to uptime?":printtab(15)"p or r?
771 [161]a$
772 [139]a$[178]"r"[167]1000
773 [139]a$[178]"p"[167][138]
774 [137]771
899 [128]
900 [143] miss
901 [151]se,6:[151]se[171]54272,100
902 [153][163]16)"miss("
905 [141]3000:[139]pn[178]0[167]pn[178]1:[137]622
906 pn[178]0:[137]622
950 [143] computer player
955 [153]"print# the enemies fire...";
957 [139]m[178]3[167]990
959 at$[178][199]([181]([187](0)[172]15)[170]65)
961 at$[178]at$[170][199]([181]([187](0)[172]10)[170]48)
963 cs[178]55617:se[178](cs[170]([198](at$)[171]64)[170]([197]([201](at$,1))[172]40))
964 vp[178][194](se):