home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 154
/
154.d81
/
king.main
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
5KB
|
152 lines
10 poke56,48:poke55,0:clr
20 dv=peek(186):ifdv<8thendv=8
30 :
40 print"[147]":poke53280,0:poke53281,10:poke646,0:poke53272,31
50 :
60 rem gameboard screen
70 :
80 print"[147] [176][192][192][192][192][192][192][192][192][178][192][192][192][192][192][192][192][192][178][192][192][192][192][192][192][192][192][174]
90 [153]" (NULL)1listint absstopwait(NULL)2print#int absstopwait(NULL)3listint absstopwait(NULL)
100 fori=1to5:print" [221][155][181] [182][144][146][221][152][181] [182][144][146][221][155][181] [182][144][146][221]":next
110 print" [171][192][192][192][192][192][192][192][192][219][192][192][192][192][192][192][192][192][219][192][192][192][192][192][192][192][192][179]
120 [153]" (NULL)4print#int absstopwait(NULL)5listint absstopwait(NULL)6print#int absstopwait(NULL)
130 fori=1to5:print" [221][152][181] [182][144][146][221][155][181] [182][144][146][221][152][181] [182][144][146][221]":next
140 print" [171][192][192][192][192][192][192][192][192][219][192][192][192][192][192][192][192][192][219][192][192][192][192][192][192][192][192][179]
150 [153]" (NULL)7listint absstopwait(NULL)8print#int absstopwait(NULL)9listint absstopwait(NULL)
160 fori=1to5:print" [221][155][181] [182][144][146][221][152][181] [182][144][146][221][155][181] [182][144][146][221]":next
170 print" [173][192][192][192][192][192][192][192][192][177][192][192][192][192][192][192][192][192][177][192][192][192][192][192][192][192][192][189]
172 [151]214,17:[153]
174 [153]"stop (NULL)resscmdcmdcmdcmdcmd(NULL) tocmdcmdcmdcmdquit
180 :
190 rem set sprites
200 :
210 v=53248:poke2040,192:poke2041,193:poke2042,194:poke2043,195:poke2044,195
220 poke2045,196:poke2046,196:poke2047,196:pokev+29,255:pokev+23,255
230 pokev,232:pokev+1,62:pokev+2,232:pokev+3,118:pokev+4,232:pokev+5,174
240 pokev+6,160:pokev+7,174:pokev+8,160:pokev+9,118:pokev+10,160:pokev+11,62
250 pokev+12,88:pokev+13,62:pokev+14,88:pokev+15,118:pokev+16,0
260 fori=39to45step2:pokev+i,1:pokev+i+1,0:next:pokev+21,255
270 :
280 rem set variables
290 :
300 z=0:f=0:t=0:nn=peek(1020):ifnn<1ornn>2thennn=1
310 y=62:forj=0to2:x=88:fori=1to3:x(3*j+i)=x:y(3*j+i)=y:x=x+72:next:y=y+56:next
320 s(0)=3:s(1)=6:s(2)=9:s(3)=8:s(4)=5:s(5)=4:s(6)=1:s(7)=2
330 g(1)=6:g(2)=7:g(3)=0:g(4)=5:g(5)=4:g(6)=1:g(7)=9:g(8)=3:g(9)=2
340 :
350 rem set permitted moves
360 :
370 dimf(25),t(25),qf(20),qt(20),rf(12),rt(12),kf(12),kt(12)
380 a$="576586985975876836539569":fori=1to12:b$=mid$(a$,2*i-1,2)
390 l$=left$(b$,1):r$=right$(b$,1):f(i)=val(l$):t(i)=val(r$):next
400 a$="86785785685635638698597587":fori=1to13:b$=mid$(a$,2*i-1,2)
410 l$=left$(b$,1):r$=right$(b$,1):f(i+12)=val(l$):t(i+12)=val(r$):next
420 a$="365658697889":fori=1to11step2:b$=mid$(a$,i,2):r=val(b$)
430 rf(i)=int(r/10):rt(i)=r-10*rf(i):rf(i+1)=rt(i):rt(i+1)=rf(i)
440 qf(i)=rf(i):qt(i)=rt(i):qf(i+1)=rf(i+1):qt(i+1)=rt(i+1)
450 kf(i)=rf(i):kt(i)=rt(i):kf(i+1)=rf(i+1):kt(i+1)=rt(i+1):next
460 a$="35575968":fori=1to7step2:b$=mid$(a$,i,2):r=val(b$)
470 bf(i)=int(r/10):bt(i)=r-10*bf(i):bf(i+1)=bt(i):bt(i+1)=bf(i)
480 qf(i+12)=bf(i):qt(i+12)=bt(i):qf(i+13)=bf(i+1):qt(i+13)=bt(i+1):next
490 :
500 rem set letters in sprites
510 :
520 fori=12288to12544step64:forj=31to46step3:readk:pokei+j,k:nextj,i
530 :
540 rem input move
550 :
560 z=z+1:z1=int(z/10):z2=z-10*z1:p=1916:gosub1180:print"[144][205]ove [206]umber: "
570 poke1931,z2+48:ifz1<>0thenpoke1930,z1+48
580 dd=300:gosub1250:ifnn=2then1080
590 p=1944:gosub1180:print" ";
600 p=1951:gosub1180:print"[144][205]ove [198]rom: [157][157]";:poke198,0:poke204,0:poke207,0
610 getf$:iff$=""then610
612 iff$="q"thenpoke204,1:goto1000
620 print""f$:poke204,1:f=asc(f$)-48:iff<3orf>9then680
630 p=1967:gosub1180:print"[144][205]ove [212]o: [157][157]";:poke198,0:poke204,0:poke207,0
640 gett$:ift$=""ort$=chr$(13)then640
650 print""t$:poke204,1:t=asc(t$)-48:ift<3ort=4ort>9then680
660 ifg(t)<>9org(f)=9then680
670 on(g(f)+1)goto920,800,740,860,860:goto580
680 p=1990:gosub1180:print"[144][211]orry, [206]o [211]uch [205]ove [208]ossible!";
690 dd=1000:gosub1250
700 p=1990:gosub1180:print" ";:goto580
710 :
720 rem rook check and move
730 :
740 fl=0:fori=1to12:ifrf(i)=fandrt(i)=tthenfl=1
750 next:iffl=1then1290
760 p=1991:gosub1180:print"[206]o [211]uch [210]ook [205]ove [208]ossible!";:goto690
770 :
780 rem queen check and move
790 :
800 fl=0:fori=1to20:ifqf(i)=fandqt(i)=tthenfl=1
810 next:iffl=1then1290
820 p=1991:gosub1180:print"[206]o [211]uch [209]ueen [205]ove [208]ossible!";:goto690
830 :
840 rem bishop check and move
850 :
860 fl=0:fori=1to8:ifbf(i)=fandbt(i)=tthenfl=1
870 next:iffl=1then1290
880 p=1990:gosub1180:print"[206]o [211]uch [194]ishop [205]ove [208]ossible!";:goto690
890 :
900 rem king check and move
910 :
920 ift=5then950
930 fl=0:fori=1to12:ifkf(i)=fandkt(i)=tthenfl=1
940 next:iffl=1then960
950 p=1991:gosub1180:print"[206]o [211]uch [203]ing [205]ove [208]ossible!";:goto690
960 ift<>7then1290
970 kc=1:gosub1290:kc=0
980 p=1904:gosub1180:print"[195]ongratulations! [217]ou have successfully";
990 print"moved the king to the lower left corner.";
1000 poke214,23:print:print"[144] (1[144]) [193]lone (2[144]) [196]emo (3[144]) [194]ack to [209][213][193][210][212][207] "
1010 poke198,0
1020 getf$:iff$<"1"orf$>"3"then1020
1022 pokev+21,0:iff$="3"then4000
1030 nn=asc(f$)-48
1040 poke1020,nn:run
1050 :
1060 rem computer demonstration
1070 :
1080 z=1:p=1951:gosub1180:print"[144][205]ove [198]rom: [205]ove [212]o:":dd=300:gosub1250
1090 fori=1to25:dd=1000:gosub1250
1100 z1=int(z/10):z2=z-10*z1:poke1931,z2+48:ifz1<>0thenpoke1930,z1+48
1110 f=f(i):t=t(i):poke1962,f+48:poke1976,t+48:dd=300:gosub1250:gosub1290
1120 dd=3000:gosub1250:z=z+1:next:dd=2000:gosub1250:p=1904:gosub1180
1130 print"[212]his demonstration illustrates [196]udeney's";
1140 print"solution to the [195]orner the [203]ing puzzle. ";:goto1000
1150 :
1160 rem cursor positioning subroutine
1170 :
1180 print"";:p=p-1024:py=int(p/40):px=p-40*py
1190 ifpy<>0thenforpp=1topy:print"";:next
1200 ifpx<>0thenforpp=1topx:print"";:next
1210 p=p+1024:return
1220 :
1230 rem delay loop subroutine
1240 :
1250 forq=1todd:next:return
1260 :
1270 rem sprite movement subroutine
1280 :
1290 s=sgn(x(t)-x(f)):ss=(y(t)-y(f))/72:ll=ss:ifs=0then1340
1300 forl=x(f)tox(t)steps:pokev+2*g(f),l:pokev+2*g(f)+1,y(f)+ll:ll=ll+ss:next
1310 g(t)=g(f):g(f)=9:ifnn=1andkc=1thenreturn
1320 ifnn=1then560
1330 return
1340 s=sgn(y(t)-y(f)):forl=y(f)toy(t)steps:pokev+2*g(f)+1,l:next:goto1310
1350 :
1360 rem sprite letters
1370 data 90,86,78,86,90,255,102,90,90,86,106,253,70,90,70,86,90,255,70,90,70,90
1380 data 70,255,70,90,70,94,94,255
3997 :
3998 :rem back to quarto
3999 :
4000 print"[147]":poke53281,0
4010 poke214,12:print:printtab(8)"[159][204]oading [195][200][197][211][211] [209][213][193][210][212][207]"
4020 print"[144] load"chr$(34)"b.chess quarto"chr$(34)","dv
4030 print" run"
4040 poke631,13:poke632,13:poke198,2:end
10000 d=peek(186):n$="king.main":open15,d,15,"s0:"+n$:close15:saven$,d:end