home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1987 January
/
1987-01.d64
/
connect'em
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
5KB
|
159 lines
10 dim bx(8,13),zo(84),zx(4,4)
20 fora=679to743:readb:ch=ch+b:pokea,b:next
30 forx=0to4:fory=1to4:readzx(x,y):ch=ch+zx(x,y):next:next
40 ifch<>6391thenprint"data error":end
50 poke785,167:poke786,2
60 data 32,247,183,165,20,201,3,176,26,73,3,170,189,255,219,41,15,133,2,169
70 data 15,56,229,2,170,189,221,2,168,169,0,32,145,179,96,160,0,41,1,170,189
80 data 0,220,41,16,208,1,200,169,0,32,145,179,96,0,1,3,0,4,8,7,0,2,5,6
90 data 1,40,42,81,-1,0,0,2,0,-1,0,80,0,1,2,82,1,0,80,82
100 print"[147]":s=1024:c=54272:ch=81:cl=2:ox=46:p1=0:p2=0:in$="":lx=28:ux=12
110 poke53280,15:poke53281,1:fort=0to3:pc$(t)="":bz$(t)="":next
120 x=7:y=6:v=s+40*x+y:ov=v:pl=1:ol=46:dt$=""
130 gosub710:ifpc$(1)<>"x"thenpokev,ch:pokev+c,14:x=7:y=6:goto150
140 goto1210
150 a=usr(pl):ifa=0goto210
160 ifa=1thenx=x-1
170 ifa=2theny=y+1
180 ifa=3thenx=x+1
190 ifa=4theny=y-1
200 goto260
210 b=usr(pl+2):ifb=0goto150
220 ifol=66goto690
230 ifol<>46thengosub1440:goto150
240 gosub1460:ifd1=0thend1=v:goto150
250 d2=v:goto360
260 ifx<7thenx=7
270 ifx>21thenx=21
280 ify<6theny=6
290 ify>lxtheny=lx
300 v=s+40*x+y
310 ifpc$(pl)="x"thenol=ox:oc=oy
320 pokeov,ol:pokeov+c,oc
330 ol=peek(v):oc=peek(v+c):pokev,ch:pokev+c,14:ov=v:ox=ol
340 ifpc$(pl)<"x"thenoy=oc
350 goto150
360 aa=d1:bb=d2:bx$="":ifd1<d2goto380
370 a=d1:d1=d2:aa=d2:d2=a
380 e=d2-d1:ife=2thendi$="a":goto410
390 ife=80thendi$="d":goto470
400 gosub1440:d2=0:d1=0:goto150
410 e=peek(aa+1):ife=111goto400
420 poked1+1,111
430 ifpc$(pl)=""goto560
440 gosub1540
450 fore=1to8:poked1+1,32:fork=1to50:next:poked1+1,111:fork=1to75:next
460 next:goto560
470 e=peek(aa+40):ife=66goto400
480 poked1+40,66:poked1+40+c,2:poked2,66:poked2+c,2:ifpc$(pc)="x"goto540
490 ifpc$(pl)=""goto540
500 gosub1540:ifv=d2thenox=66:oy=2
510 fore=1to8:poked1+40,32:poked2,32:fork=1to50:next:poked1+40,66:poked2,66
520 poked1+40+c,2:poked2+c,2
530 fork=1to75:next:next
540 ifov=d2andpl=1thenox=66:oy=2
550 ifov=d2thenol=66:oc=2
560 xx=aa-s:fork=1to21:xx=xx-40:yy=xx:ifyy<40thenxx=k:k=21
570 next
580 row=(xx-7)/2+1:col=(yy-6)/2+1
590 bx(ro,co)=bx(ro,co)+1:ty$="n"
600 ifbx(ro,co)=4thenbx$="x":gosub1480:gosub880:gosub950
610 ifdi$="a"thenbx(row-1,col)=bx(row-1,col)+1:ty$="a":ifbx(ro-1,co)=4goto650
620 ifdi$="a"goto660
630 bx(row,col-1)=bx(row,col-1)+1:ty$="d"
640 ifbx(row,col-1)<>4goto660
650 bx$="x":gosub1480:gosub880:gosub950
660 d1=0:d2=0:ifbx$=""thenpl=pl+1:gosub950
670 ifpc$(pl)="x"goto1210
680 pokev,ch:pokev+c,14:ov=v:goto150
690 e=x:fork=1to9:e=e-2:ife=0thengosub1440:goto150
700 next:goto240
710 print"[147]":printtab(8)"[150] welcome to connect'em ":print:print:gosub1480
720 ts=84:gosub1460
730 print"to play the computer, enter [150]c-64"
740 print"for either or both player's names..":print:print:fort=1to2500:next
750 fori=1to2:gosub1460:print"what is player #"i"[157]'s name[150]";:inputpl$(i)
755 if pl$(i)="" then goto 750
760 pl$(i)=left$(pl$(i),8):next
770 print:gosub1460:f1=-1:f2=0:print:fort=1to2:z$=left$(pl$(t),1):a=asc(z$)
780 fl(t)=a-64:f1=f1+4:nc(t)=f1:ifpl$(t)="c-64"thenf2=f2+1:pc$(t)="x"
790 ift=2andf2=2thenpl$(t)="commodore"
800 print"[150] ";pl$(t);" will use joystick";t:next
810 l%=len(pl$(1)):m%=len(pl$(2)):l%=(l%/2)+7:m%=(m%/2)+23
820 print:print:print"regular or mini game (r/m)?"
830 getz$:ifz$="r"goto860
840 ifz$<>"m"goto830
850 lx=18:ux=7:ts=42
860 forx=1toux:dt$=dt$+". ":next
870 gosub1480:gosub950:return
880 ifty$="n"thenaa=ro:bb=co
890 ifty$="a"thenaa=ro-1:bb=co
900 ifty$="d"thenaa=ro:bb=co-1
910 a=(aa*2+7)-2:b=bb*2+4:e=s+a*40+b+41
920 aa=fl(pl):cl=nc(pl)
930 pokee,aa+128:pokee+c,cl:cl=2:return
940 print"":forj=1tocc:print:next:return
950 ifin$=""thenbx$="":print"[147]"
960 print"":printtab(9)" connect'em scoreboard ":print
970 ifbx$<>"x"goto1000
980 ifpl=1thenp1=p1+1:goto1000
990 p2=p2+1:pl=2
1000 printtab(8)"[159]"+pl$(1);tab(24)"[158]"+pl$(2):ifpl>2thenpl=1
1010 printtab(l%)"[150]";p1;tab(m%)p2
1020 poke781,6:sys59903:na$=pl$(pl):poke646,nc(pl)
1030 print:printtab(4)na$;"'s turn":ifpc$(pl)=""thengosub1460
1040 ifin$<>""goto1070
1050 in$="x":cc=6:gosub940
1060 forx=1to8:printtab(6)"";dt$:print:next:ti$="000000"
1070 gosub1200
1080 a=p1+p2:ifa=tsgoto1100
1090 return
1100 wn$=" wins!!":na$=pl$(1)+wn$:ifp2=p1thenna$="it's a tie!!":goto1120
1110 poke646,nc(1):ifp2>p1thenna$=pl$(2)+wn$:poke646,nc(2)
1120 cc=22:gosub940
1130 forx=1to7:poke781,22:sys59903:gosub1480:printtab(12)"[145]";na$
1140 fory=1to300:next:next
1150 printtab(7)"[150]care to play again (y/n)?"
1160 getz$:ifz$=""goto1160
1170 ifz$="n"thenend
1180 ifz$<>"y"thengoto1160
1190 fora=1to7:forb=1to12:bx(a,b)=0:next:next:d1=0:d2=0:goto100
1200 print"":print"[156]";left$(ti$,2);":";mid$(ti$,3,2);":";right$(ti$,2):return
1210 nz=0:va=-1:nx=0:gosub1510
1220 va=va+1:nl=va+1
1230 ifbz$(va)="x"goto1220
1240 fora=1to7:forb=1toux-1
1250 ifbx(a,b)=3thennz=0:nl=4:nx=0:gosub1380:a=7:b=ux-1:goto1270
1260 ifbx(a,b)=vathengosub1380
1270 next:next:nx=0:ifnz>0goto1290
1280 bz$(va)="x":goto1220
1290 r=int(rnd(1)*nz)+1:ifnx=nzthennz=0:goto1220
1300 ifzo(r)=99goto1290
1310 nx=nx+1:loc=zo(r)
1320 forz=1to4:rx$(z)="":next:rx=0
1330 ifrx=4thenzo(r)=99:goto1290
1340 z=int(rnd(1)*4)+1:ifrx$(z)="x"goto1340
1350 rx=rx+1:rx$(z)="x"
1360 e=peek(loc+zx(0,z)):ife=32thengosub1390:goto1420
1370 goto1330
1380 e=(a*2+7)-2:k=b*2+4:loc=s+e*40+k:nz=nz+1:zo(nz)=loc:return
1390 xx=loc-s:fork=1to21:xx=xx-40:yy=xx:ifyy<40thenxx=k:k=21
1400 next
1410 row=(xx-7)/2+1:col=(yy-6)/2+1:return
1420 ifbx(row+zx(z,1),col+zx(z,2))<nlthend1=loc+zx(z,3):d2=loc+zx(z,4):goto360
1430 goto1330
1440 gosub1570:pokec+5,45:pokec+6,165:pokec+4,33:pokec+1,6:pokec,5
1450 fort=1to200:next:pokec+4,32:pokec+1,0:pokec,0:return
1460 gosub1570:pokec+5,0:pokec+6,247:pokec+4,17
1470 pokec+1,40:pokec,0:fort=1to100:next:pokec+4,16:return
1480 gosub1570:pokec+5,0:pokec+6,255:pokec+4,21
1490 pokec+15,40:fora=1to4:f1=20:forb=1to2:f2=100:pokec+1,f1:fork=1to2
1500 pokec+15,f2:f1=f1*1.05:f2=f2*.9:nextk:nextb:nexta:pokec+6,15:return
1510 gosub1570:pokec+5,6:forz=1to15
1520 a=int(10*rnd(1))+1:q=int(25*rnd(1))+1:pokec+1,40:f2=int(15*rnd(1))+1
1530 pokec+15,f2:pokec+4,23:fort=1toq:next:pokec+4,128:nextz:return
1540 gosub1570:pokec+5,8:pokec+6,255:pokec+4,23
1550 pokec+15,40:forz=1to4:forf1=255to0step-6:pokec+1,f1:nextf1
1560 forf1=0to255step10:pokec+1,f1:nextf1:pokec+6,10:return
1570 forl=ctoc+23:pokel,0:next:pokec+24,15:return