Code: Select all
1 '*******************
2 '* CHESSMASTER *
3 '* BY: *
4 '* HAROLD SNYDER *
5 '* P.O. BOX 3330 *
6 '* CHEYENNE, WY *
7 '* 82003 *
8 '*******************
9 CLS(3)
10 PRINT@128," * CHESSMASTER *"
11 PRINT@192," BY"
12 PRINT@256," HAROLD SNYDER"
13 FORQZ=1TO2999:NEXT
14 A=0:B=0:X=0:Y=0:S=0:A0=0:T=0:A8=0:A2=0:A3=0:A4=0:B1=0:B6=0:H=0:M=0:N=0:P=0:A5=0:I=1:DIMA(9,9),C(64):POKE248,&H32:POKE249,&H62:POKE250,&H1C:POKE251,&HAF:POKE252,&H7E:POKE253,&HAD:POKE254,&HA5:POKE410,&H7E:POKE411,0:POKE412,&HF8
15 CLS:PRINT:PRINT" * CAN THIS COMPUTER USE THE HIGH SPEED POKE Y/N"
16 IN$=INKEY$:IFIN$=""THEN16
17 IFIN$<>"Y"ANDIN$<>"N"THEN16
18 IFIN$="Y"THENPOKE65495,0
19 CLS:PRINT:PRINT"DO YOU WANT INSTRUCTIONS Y/N"
20 IN$=INKEY$:IFIN$<>"Y"ANDIN$<>"N"THEN20
21 IFIN$="Y"THENGOSUB194
22 PRINT:PRINT"WHAT LEVEL OF PLAY 1-7"
23 IN$=INKEY$:IFIN$=""THEN23
24 B8=VAL(IN$)-1:IFB8<0ORB8>6THEN23
25 B7=B8*2
26 IFB7=0THENB7=1
27 PRINT:PRINT"DO YOU WANT WHITE Y/N"
28 IN$=INKEY$:IFIN$=""THEN28
29 IFIN$<>"Y"ANDIN$<>"N"THEN28
30 GOSUB111
31 IFIN$<>"N"THENGOSUB122:GOTO41
32 GOSUB120
33 'COMPUTER MOVE
34 F=-99:A0=0:FORJ=1TO8:FORK=1TO8:IFA(J,K)=99THENA6=J:A7=K:GOTO35ELSENEXT:NEXT
35 FORX=1TO8:FORY=1TO8:IFA(X,Y)<0THENGOSUB52:IFF>=B7 THEN37
36 NEXT:NEXT:IFF>=-9THEN37ELSE190
37 A(R,U)=A(E,Q):A(E,Q)=1:IFA(R,U)=-2ANDU=1THENA(R,U)=-9
38 X=R:Y=U:A0=4:GOSUB52:SOUND190,1:SOUND110,1:SOUND160,1:SOUND140,1:PRINT@89,"MY MOVE";:PRINT@121," WAS ";:PRINT@155,CHR$(E+64);CHR$(Q+48);CHR$(R+64);CHR$(U+48);
39 GOSUB124:X=E:Y=Q:GOSUB124:IFC=1THENPRINT@185," check ";:C=0ELSEPRINT@185," ";:
40 'PLAYER MOVE
41 GOSUB152:D=0:B4=A:B9=B:B5=0
42 IFX$="K"ORX$="Q"THEN34
43 A0=3:GOSUB48:IFD=0THENPRINT@25,"illegal";:PRINT@57," move ";:FORJ=1TO1500:NEXT:GOTO41
44 PRINT@89," ";:PRINT@121," ";:PRINT@155," ";:PRINT@217," ";:PRINT@249," ";:PRINT@315," ";:A=B4:B=B9:A(A,B)=A(X,Y):A(X,Y)=1:GOSUB124:X=A:Y=B:GOSUB124
45 IFA(A,B)=2ANDB=8THENGOSUB180:GOSUB124
46 IFB5=1THENA(A,B-1)=1:X=A:Y=B-1:GOSUB124:GOTO34ELSE34
47 'COMPUTER PIECE MOVE
48 PRINT@31,CHR$(191);:ONA(X,Y)GOTO9,74,9,65,59,9,54,9,59
49 'KING MOVE
50 FORA=X-1TOX+1:FORB=Y-1TOY+1:IFA(A,B)<>0THENGOSUB94:NEXT:NEXT:RETURNELSENEXT:NEXT:RETURN
51 'PLAYER PIECE MOVE
52 ON-A(X,Y)GOTO9,80,9,65,59,9,54,9,59:GOTO50
53 'ROOK/QUEEN MOVE
54 B=Y:FORA=X+1TO8:GOSUB93:IFS=0THENNEXT
55 FORA=X-1TO1STEP-1:GOSUB93:IFS=0THENNEXT
56 A=X:FORB=Y+1TO8:GOSUB93:IFS=0THENNEXT
57 FORB=Y-1TO1STEP-1:GOSUB93:IFS=0THENNEXT:RETURNELSERETURN
58 'BISHOP/QUEEN MOVE
59 B=Y:FORA=X+1TO8:B=B+1:GOSUB93:IFS=0THENNEXT
60 B=Y:FORA=X-1TO1STEP-1:B=B-1:GOSUB93:IFS=0THENNEXT
61 B=Y:FORA=X-1TO1STEP-1:B=B+1:GOSUB93:IFS=0THENNEXT
62 B=Y:FORA=X+1TO8:B=B-1:GOSUB93:IFS=0THENNEXT
63 IFABS(A(X,Y))=9THEN54ELSERETURN
64 'KNIGHT MOVE
65 A=X+2:B=Y+1:IFA<9ANDB<9THENGOSUB94
66 B=B-2:IFB>0ANDA<9THENGOSUB94
67 A=A-4:IFA>0ANDB>0THENGOSUB94
68 B=B+2:IFB<9ANDA>0THENGOSUB94
69 A=A+1:B=B+1:IFA>0ANDA<9ANDB<9THENGOSUB94
70 B=B-4:IFB>0ANDA>0ANDA<9THENGOSUB94
71 A=A+2:IFA>0ANDA<9ANDB>0THENGOSUB94
72 B=B+4:IFB<9ANDA>0ANDA<9THENGOSUB94:RETURNELSERETURN
73 'PLAYER PAWN MOVE
74 A=X:IFY>2THEN76
75 B=Y+1:IFA(A,B)=1THENGOSUB95:B=B+1:IFA(A,B)=1THENGOSUB95:GOTO77ELSE77ELSE77
76 B=Y+1:IFA(A,B)=1THENGOSUB95
77 A=X+1:B=Y+1:IFA(A,B)<0THENGOSUB95
78 A=A-2:IFA(A,B)<0THENGOSUB95:RETURNELSERETURN
79 'COMPUTER PAWN MOVE
80 A=X:IFY<7THEN82
81 B=Y-1:IFA(A,B)=1THENGOSUB95:B=B-1:IFA(A,B)=1THENGOSUB95:GOTO83ELSE83ELSE83
82 B=Y-1:IFA(A,B)=1THENGOSUB95
83 A=X-1:B=Y-1:IFA(A,B)>1THENGOSUB95
84 A=A+2:IFA(A,B)>1THENGOSUB95:RETURNELSERETURN
85 'PROTECT ROUTINE
86 T=A(A,B):IFT=-99THENB1=T:RETURN
87 A5=S:IFABS(T)<=A(X,Y)THENA(A,B)=A(X,Y):A(X,Y)=1:GOTO89
88 IFT<B1 THENB1=T:S=A5:RETURNELSES=A5:RETURN
89 A1=X:A2=Y:A3=A:A4=B:A8=T:A0=2:FORX=1TO8:FORY=1TO8:IFA(X,Y)<0THENGOSUB52:IFT=0THEN91
90 NEXT:NEXT
91 X=A1:Y=A2:A=A3:B=A4:A0=5:A(X,Y)=A(A,B):A(A,B)=A8:GOTO88
92 'LEGAL MOVE CHECK
93 S=0:IFA(A,B)=1THEN95ELSEIFA(A,B)=0THENS=1:RETURNELSEIFSGN(A(A,B))=SGN(A(X,Y))THENS=1:RETURNELSES=1:GOTO95
94 IFA(A,B)<>1THENIFSGN(A(A,B))=SGN(A(X,Y))THENRETURN
95 PRINT@31," ";:ONA0 GOTO96,97,98,99,100:GOTO102
96 IFA6=A ANDA7=B THENB1=B1+1:RETURNELSERETURN
97 IFA3=A ANDA4=B THENT=0:RETURNELSERETURN
98 IFB4=A ANDB9=B THEND=1:RETURNELSERETURN
99 IFA6=A ANDA7=B THENC=1:RETURNELSERETURN
100 IFA(A,B)<0THEN86ELSERETURN
101 'LOOK-AHEAD ROUTINE
102 B3=S:W=X:M=Y:N=A:H=B:P=A(A,B):A(A,B)=A(X,Y):A(X,Y)=1:B1=0
103 A0=5:FORX=1TO8:FORY=1TO8:IFA(X,Y)>1THENGOSUB48
104 NEXT:NEXT:X=N:Y=H:A0=1:GOSUB52:A0=0:S=B3:X=W:Y=M:A=N:B=H:A(X,Y)=A(A,B):A(A,B)=P
105 'EVALUATE MOVE
106 B6=1/(ABS(4.5-A)+ABS(4.5-B)+1):IFA(X,Y)<-2ANDA(X,Y)>-9THENB6=B6+1/(ABS(A6-A)+ABS(A7-B)+5)+RND(0)/15
107 G=P+B1+B6:IFP=99THENGOSUB178:PRINT@89," ";:PRINT@121," mate! ";:PRINT@153,B$;:PRINT@185," ";:GOTO192
108 IFG<=F THENRETURN
109 F=G:E=X:Q=Y:R=A:U=B:RETURN
110 'INITIALIZATION ROUTINE
111 CLS:FORY=8TO1STEP-1:FORX=1TO8:READA(X,Y):NEXT:NEXT
112 FORJ=1TO4:SB$=SB$+STRING$(3,CHR$(140))+STRING$(3,CHR$(131)):SW$=SW$+STRING$(3,CHR$(131))+STRING$(3,CHR$(140)):NEXT
113 FORJ=32TO416STEP128:PRINT@J,SB$;:PRINT@J+64,SW$;:NEXT:FORJ=1TO7STEP2:PRINT@477+J*3,CHR$(128);CHR$(J+96);CHR$(128);CHR$(140);CHR$(J+65);CHR$(140);:NEXT:FORJ=1TO8:PRINT@J*64-8,CHR$(128);:PRINT@J*64-40,CHR$(57-J);:NEXT:PRINT@504,CHR$(128);:RETURN
114 DATA-7,-4,-5,-9,-99,-5,-4,-7
115 DATA-2,-2,-2,-2,-2,-2,-2,-2
116 DATA1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
117 DATA2,2,2,2,2,2,2,2
118 DATA7,4,5,9,99,5,4,7
119 'PLAYER REQUESTS BLACK
120 I=-I:A(4,1)=99:A(5,1)=9:A(4,8)=-99:A(5,8)=-9
121 'GRAPHIC DRIVER-FULL SCREEN
122 FORY=1TO8:FORX=1TO8:GOSUB124:NEXT:NEXT:RETURN
123 'GRAPHIC DRIVER-ONE PIECE
124 L=509+X*3-Y*64:IFX+Y-INT((X+Y)/2)*2=0THEN126
125 IFI*A(X,Y)>0THENONABS(A(X,Y))GOTO127,128,9,129,130,9,131,9,132:PRINT@L," K ";:RETURNELSEONABS(A(X,Y))GOTO127,133,9,134,135,9,136,9,137:PRINT@L," k ";:RETURN
126 IFI*A(X,Y)>0THENONABS(A(X,Y))GOTO138,139,9,140,141,9,142,9,143:PRINT@L,CHR$(128);"K";CHR$(128);:RETURNELSEONABS(A(X,Y))GOTO138,144,9,145,146,9,147,9,148:PRINT@L,CHR$(128);"k";CHR$(128);:RETURN
127 PRINT@L," ";:RETURN
128 PRINT@L," P ";:RETURN
129 PRINT@L," N ";:RETURN
130 PRINT@L," B ";:RETURN
131 PRINT@L," R ";:RETURN
132 PRINT@L," Q ";:RETURN
133 PRINT@L," p ";:RETURN
134 PRINT@L," n ";:RETURN
135 PRINT@L," b ";:RETURN
136 PRINT@L," r ";:RETURN
137 PRINT@L," q ";:RETURN
138 PRINT@L,STRING$(3,CHR$(128));:RETURN
139 PRINT@L,CHR$(128);"P";CHR$(128);:RETURN
140 PRINT@L,CHR$(128);"N";CHR$(128);:RETURN
141 PRINT@L,CHR$(128);"B";CHR$(128);:RETURN
142 PRINT@L,CHR$(128);"R";CHR$(128);:RETURN
143 PRINT@L,CHR$(128);"Q";CHR$(128);:RETURN
144 PRINT@L,CHR$(128);"p";CHR$(128);:RETURN
145 PRINT@L,CHR$(128);"n";CHR$(128);:RETURN
146 PRINT@L,CHR$(128);"b";CHR$(128);:RETURN
147 PRINT@L,CHR$(128);"r";CHR$(128);:RETURN
148 PRINT@L,CHR$(128);"q";CHR$(128);:RETURN
149 'INPUT ROUTINE
150 PRINT@25,"cannot ";:PRINT@57,"castle ";:FORJ=1TO1500:NEXT:GOTO152
151 PRINT@25," entry ";:PRINT@57," error ";:FORJ=1TO1500:NEXT
152 GOSUB175:GOSUB178:PRINT@217," your ";:PRINT@249," move ";
153 X$=INKEY$:IFX$=""THEN153
154 PRINT@315,X$;
155 SOUND120,1
156 X1$=INKEY$:IFX1$=""THEN156
157 PRINT@316,X1$;
158 SOUND120,1
159 X2$=INKEY$:IFX2$=""THEN159
160 PRINT@317,X2$;
161 SOUND120,1
162 X3$=INKEY$:IFX3$=""THEN162
163 PRINT@318,X3$;:IN$=X$+X1$+X2$+X3$
164 SOUND150,1
165 IFX$>="A"ANDX$<="H"THEN173
166 IFX$="K"THENIFA(5,1)=99ANDA(8,1)=7ANDA(6,1)<2ANDA(7,1)<2THENA(5,1)=1:A(6,1)=7:A(7,1)=99:A(8,1)=1:GOTO176
167 IFX$="Q"THENIFA(5,1)=99ANDA(1,1)=7ANDA(4,1)<2ANDA(3,1)<2THENA(5,1)=1:A(4,1)=7:A(3,1)=99:A(1,1)=1:GOTO176
168 IFX$="K"THENIFA(4,1)=99ANDA(1,1)=7ANDA(3,1)<2ANDA(2,1)<2THENA(4,1)=1:A(3,1)=7:A(2,1)=99:A(1,1)=1:GOTO176
169 IFX$="Q"THENIFA(4,1)=99ANDA(8,1)=7ANDA(5,1)<2ANDA(6,1)<2THENA(4,1)=1:A(5,1)=7:A(6,1)=99:A(8,1)=1:GOTO176
170 'DECODE INPUT
171 IFX$="I"THENGOSUB194:GOSUB113:GOSUB122:GOTO152
172 IFX$="P"THENRUNELSE151
173 IFLEN(IN$)=4THENX=ASC(X$)-64:Y=ASC(MID$(IN$,2,1))-48:A=ASC(MID$(IN$,3,1))-64:B=ASC(MID$(IN$,4,1))-48ELSE151
174 IFY<1ORY>8ORA<1ORA>8ORB<1ORB>8THEN151ELSEIFA(X,Y)<2ORA(A,B)>1THEN151ELSEGOSUB175:RETURN
175 PRINT@25," ";:PRINT@57," ";:RETURN
176 PRINT@313,"CASTLE ";:PRINT@345,X$;"-SIDE ";:GOSUB175:GOSUB122:RETURN
177 'BLANK MESSAGE AREA
178 FORJ=217TO345STEP32:PRINT@J," ";:NEXT:RETURN
179 'PROMOTE PLAYER PAWN
180 GOSUB178:PRINT@217," what ";:PRINT@249," piece ";:PRINT@281," PNBRQ ";:
181 IN$=INKEY$:IFIN$=""THEN181
182 IFIN$<>"P"ANDIN$<>"N"ANDIN$<>"B"ANDIN$<>"R"ANDIN$<>"Q"THENPRINT@315," ";:GOTO181
183 PRINT@316,IN$;
184 IFIN$="P"THENA(A,B)=2:RETURN
185 IFIN$="N"THENA(A,B)=4:RETURN
186 IFIN$="B"THENA(A,B)=5:RETURN
187 IFIN$="R"THENA(A,B)=7:RETURN
188 IFIN$="Q"THENA(A,B)=9:RETURNELSE181
189 'END OF GAME
190 GOSUB178:PRINT@89," ";:PRINT@121," YOU ";:PRINT@153," WIN! ";
191 POKE65494,0
192 GOTO192
193 'INSTRUCTIONS
194 CLS
195 PRINT" * INSTUCTIONS *"
196 PRINT"ENTER KKKK TO CASTLE KING SIDE"
197 PRINT" QQQQ TO CASTLE QUEEN SIDE"
198 PRINT" IIII TO GET INSTUCTIONS"
199 PRINT" PPPP TO START NEW GAME"
200 PRINT
201 PRINT" TO PROMOTE TO P, N, B, R OR Q"
202 PRINT" ENTER LETTER WHEN PROMPTED"
203 PRINT:PRINT" TO MOVE, CAPTURE OR CAPTURE"
204 PRINT" EN PASSANT, SPECIFY FROM/TO"
205 PRINT" (E.G. 'B1C3')"
206 PRINT:PRINT" LEVELS OF PLAY ARE 1 THRU 7"
207 PRINT
208 PRINT" (HIT ANY KEY)";
209 IN$=INKEY$:IFIN$=""THEN209
210 CLS:RETURN