home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 203
/
203.d81
/
z.kb+
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
17KB
|
694 lines
1 rem "z.kb+" 2001.03.20 ======================================
10 r=24927:v=25600:w=25614
12 f=peek(v)
14 x=v+1
16 p=peek(x)
18 iff=0then48
20 iff=1then42
22 x=v+2
24 a=peek(x)
26 iff=2then38
28 x=v+3
30 b=peek(x)
32 q=3-p
34 gosub700
36 goto50
38 gosub600
40 goto50
42 t=1
44 gosub500
46 goto50
48 gosub100
50 end
100 rem ******************************** find "b" (s=2,4,6,8)
102 x=v+5
104 s=peek(x)
106 g=0:o=p:q=p:h=100:t=0:u=w
108 rem - down
110 p=q:q=3-p:h=100-h:t=t+1:w=w+126
112 x=w-126:y=x+115:z=w
114 gosub900
116 gosub500:rem "a"
118 gosub600:rem "b" list
120 ifn>0then128:rem not win/loss
122 l=0
124 ifo=pthen186:rem loss
126 goto190:rem win
128 ift>1then138
130 ifn>1then138
132 pokez,0
134 f=50
136 goto278:rem only move
138 gosub630:rem "b" sort
140 x=w+125
142 pokex,h
144 rem - next "b"
146 m=8
148 x=w-126:y=x+115:z=w
150 gosub900
152 x=w+116
154 l=peek(x)
156 ifl=0then250:rem up
158 l=l-1
160 pokex,l
162 x=w+117:x=x+l
164 b=peek(x)
166 rem - results
168 x=w+115
170 a=peek(x)
172 ift>1then178
174 x=w+125
176 pokex,h
178 gosub700:rem sets m
180 ifm>2then194:rem not win/loss
182 ifo=pthen190:rem win
184 rem - pts for win/loss win(99,97,95,93) loss(2,4,6,8)
186 f=t
188 goto246:rem loss
190 f=100-t
192 goto246:rem win
194 rem - pts @ "o" move(t=2,4,6,8) good(>50) neutral(50) bad(<50)
196 ifo=pthen108:rem down
198 f=50
200 e=o-1:e=e*8
202 x=u+99:x=x+e
204 i=peek(x)
206 x=w+99:x=x+e
208 j=peek(x)
210 f=f-i:f=f+j
212 e=8-e
214 x=u+99:x=x+e
216 i=peek(x)
218 x=w+99:x=x+e
220 k=peek(x)
222 f=f+i:f=f-k
224 iff>50then246:rem good enough
226 iff=50then234:rem neutral
228 ift>2then234:rem not "xo"
230 l=0
232 goto246:rem bad enough
234 ift<sthen108:rem down
236 rem . don't xch when behind
238 ifi=kthen246:rem no xch
240 ifj>kthen246:rem xch ok - ahead
242 ifj=kthen246:rem xch ok - equal
244 f=49
246 rem - update board pts
248 gosub300
250 rem - up
252 x=w+125
254 f=peek(x)
256 ift=1then278:rem top
258 ifm=2then262:rem win/loss
260 ifl>0then276:rem not last "b"
262 p=q:q=3-p:h=100-h:t=t-1:w=w-126
264 gosub300
266 ift>1then276:rem not top
268 x=w+125
270 f=peek(x)
272 iff>50then278:rem good enough
274 gosub320
276 goto144:rem next "b"
278 rem -
280 iff=gthen284
282 gosub320
284 return
300 rem ******************************** update board pts
302 x=w+125
304 d=peek(x)
306 iff=dthen318:rem not min/max
308 ifo=pthen314:rem "x" move
310 iff>dthen318:rem not "o" min
312 goto316
314 iff<dthen318:rem not "x" max
316 pokex,f
318 return
320 rem ******************************** update best move(t=1)
322 iff>gthen326
324 goto352
326 x=u+126:x=x+115
328 a=peek(x)
330 x=x+1
332 i=peek(x)
334 x=x+1:x=x+i
336 b=peek(x)
338 x=v+2
340 pokex,a
342 x=v+3
344 pokex,b
346 x=v+4
348 pokex,f
350 g=f
352 return
500 rem ******************************** "a"
502 i=0
504 e=p-1:e=e*8:x=w+99:x=x+e
506 n=peek(x)
508 d=t*7:y=r+d
510 x=y+i
512 f=peek(x)
514 iff>nthen518
516 goto522
518 i=i+1
520 goto510
522 i=f-1:x=w+100:x=x+e:x=x+i
524 a=peek(x)
526 x=w+115
528 pokex,a
530 return
600 rem ******************************** "b" list
602 n=0:y=v+6:z=w+116
604 fori=0to7
606 x=y+i
608 c=peek(x)
610 b=a+c:b=b-20:x=w+b
612 d=peek(x)
614 ifd=0then622
616 ifd=pthen622
618 n=n+1:x=z+n
620 pokex,b
622 next
624 pokez,n
626 return
630 rem ******************************** sort "b" list
632 i=n:x=w+117:x=x+n:z=x
634 i=i-1:x=x-1
636 b=peek(x)
638 y=w+b
640 d=peek(y)
642 ifd=4then652
644 z=z-1
646 ifx=zthen652
648 y=x+1
650 gosub920
652 ifi>0then634
654 return
700 rem ******************************** results
702 m=8
704 x=w+a
706 pokex,4
708 x=w+b
710 d=peek(x)
712 pokex,p
714 y=w+99:e=p-1:e=e*8:y=y+e
716 n=peek(y)
718 x=y+n:x=x+1
720 x=x-1
722 e=peek(x)
724 ife=athen728
726 goto720
728 pokex,b
730 ifd=4then754
732 y=w+99:e=q-1:e=e*8:y=y+e
734 n=peek(y)
736 x=y+n:x=x+1:m=n-1
738 pokey,m
740 x=x-1
742 e=peek(x)
744 ife=bthen748
746 goto740
748 z=x:y=y+n:y=y+1:x=x+1
750 ifx=ythen754
752 gosub900
754 return
900 rem ******************************** copy: x=start y=end+1 z=dest
902 rem - copy mem @ 16528(64*256+144) - x,y,z @ 105*256+(sc-1)*2
904 poke781,46
906 poke782,105
908 sys16528
910 return
920 rem ******************************** swap: x=start y=end+1 z=dest
922 rem - swap mem @ 16531(64*256+147) - x,y,z @ 105*256+(sc-1)*2
924 poke781,46
926 poke782,105
928 sys16531
930 return
999 rem ================================
1000 poke55,96:poke56,105:clr:bs=96+105*256:fl$="kb 6960":goto1630
1010 b=peek(ad):ad=ad+1:ifb=32then1010
1020 return
1030 aa=ad
1040 b=peek(aa):aa=aa+1:ifb=32then1040
1050 return
1060 gosub1010:ifb<>0thenprintb:goto1730
1070 return
1080 n=0
1090 gosub1010:ifb<48 or b>57 then return
1100 n=n*10+(b-48):goto1090
1110 nh=int(nn/256):nl=nn-(nh*256):return
1120 gosub1110:print mid$(hx$,(nhand240)/16+1,1);mid$(hx$,(nhand15)+1,1);
1130 printmid$(hx$,(nland240)/16+1,1);mid$(hx$,(nland15)+1,1);:return
1140 bx=bx+1:ifp<>3 then ml=ml+1:return
1150 poke ml,z:ml=ml+1:return
1160 ifp<>1thensp=sp+1:sl=sl+1:return
1170 pokesp,z:sp=sp+1:sl=sl+1:return
1180 ifp<>3thenreturn
1190 dx=dx+1:poke dw,nl:poke dw+1,nh:dw=dw+2:return
1200 gosub1010:ifb>64then1220
1210 g=1:ad=ad-1:gosub1080:ad=ad-1:nn=n:goto1240
1220 gosub1250
1230 g=0:b=b-65:nn=(b*2)+zv
1240 b=peek(ad):gosub1110:return
1250 if(b<65 or b>90)then5360
1260 return
1270 z=173:gosub1140:z=nl:gosub1140:z=nh:goto1140
1280 z=173:gosub1140:z=nl+1:gosub1140:z=nh:goto1140
1290 z=141:gosub1140:z=nl:gosub1140:z=nh:goto1140
1300 z=141:gosub1140:z=nl+1:gosub1140:z=nh:goto1140
1310 z=169:gosub1140:z=nl:goto1140
1320 z=169:gosub1140:z=nh:goto1140
1330 z=173:gosub1140:z=vl:gosub1140:z=vh:goto1140
1340 z=173:gosub1140:z=vl+1:gosub1140:z=vh:goto1140
1350 z=141:gosub1140:z=vl:gosub1140:z=vh:goto1140
1360 z=141:gosub1140:z=vl+1:gosub1140:z=vh:goto1140
1370 nl=ms(h,0):nh=ms(h,1):return
1380 gosub1140:z=nl:gosub1140:z=nh:goto1140
1390 gosub1140:z=nl+1:gosub1140:z=nh:goto1140
1400 gosub1140:z=nl:goto1140
1410 gosub1140:z=nh:goto1140
1420 z=165:gosub1140:z=y:goto1140
1430 z=162:gosub1140:z=y:goto1140
1440 z=161:gosub1140:z=y:goto1140
1450 z=145:gosub1140:z=y:goto1140
1460 z=160:gosub1140:z=y:goto1140
1470 z=133:gosub1140:z=y:goto1140
1480 z=56:goto1140
1490 z=24:goto1140
1500 z=32:gosub1140:z=yl:gosub1140:z=yh:goto1140
1510 z=76:gosub1140:z=yl:gosub1140:z=yh:goto1140
1520 z=233:gosub1140:z=nl:goto1140
1530 z=233:gosub1140:z=nh:goto1140
1540 z=105:gosub1140:z=nl:goto1140
1550 z=105:gosub1140:z=nh:goto1140
1560 z=237:gosub1140:z=nl:gosub1140:z=nh:goto1140
1570 z=237:gosub1140:z=nl+1:gosub1140:z=nh:goto1140
1580 z=109:gosub1140:z=nl:gosub1140:z=nh:goto1140
1590 z=109:gosub1140:z=nl+1:gosub1140:z=nh:goto1140
1600 z=y1:gosub1140:z=y2:goto1140
1610 z=y1:gosub1140:z=y2:gosub1140:z=y3:goto1140
1620 z=169:gosub1140:z=y:goto1140
1630 lx=3:xx=0:zp=bs+80:p=1:zm=zp:sk=-1
1635 zv=105*256:rem variable's start address, for original set zv=679
1640 dim ll(255,1),fs(6,4),li%(lx,5),ms(5,3),oc%(3,1)
1650 gosub5440:sys828,232,3
1660 fori=0tolx:forj=0to5:readli%(i,j):next:next:bx=0:dx=0:f2=0
1670 ad=peek(43)+peek(44)*256:print"[147] ***** pass";p;" *****"
1680 sp=zp:ml=zm
1690 nm=peek(ad)+peek(ad+1)*256
1700 ln=peek(ad+2)+peek(ad+3)*256:ifln>999then1740
1710 print" compiling line #"mid$(str$(ln),2)
1720 ifp=2thenll(xx,0)=ln:ll(xx,1)=ml:xx=xx+1
1730 ad=ad+4:gosub1010:goto1790
1740 ifp=1thenp=2:zm=sp:r1=zm:la=sp:u1=bx:bx=0:goto1670
1750 ifp=2thenp=3:zm=la:r2=zm:gosub5420:db=la+bx+4:dw=db:u2=bx:bx=0:goto1670
1760 u3=bx:gosub4760:print"done!":print:gosub4580
1770 ifpeek(ml-1)<>96thenz=96:gosub1140
1780 goto4450
1790 ifb=136then3610:rem let
1800 ifb=153then2020:rem print
1810 ifb=128then2300:rem end
1820 ifb=137then2170:rem goto
1830 ifb=141then2230:rem gosub
1840 ifb=142then2300:rem return
1850 ifb=139then2320:rem if
1860 ifb=151then2600:rem poke
1870 ifb=129then2710:rem for
1880 ifb=130then2960:rem next
1890 ifb=135then3320:rem read
1900 ifb=140then3420:rem restore
1910 ifb=131then3470:rem data
1920 ifb=156then3510:rem clr
1930 ifb=143then2000:rem rem
1940 ifb=161then3530:rem get
1950 ifb=158then4300:rem sys
1960 rem this line assumes let
19