home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1987 January / 1987-01.d64 / connect'em (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  5KB  |  159 lines

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