-
Notifications
You must be signed in to change notification settings - Fork 2
/
mkmove.src
208 lines (208 loc) · 4.16 KB
/
mkmove.src
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
10 MOVE
20 LDA LEVEL
30 AND #$01
40 CLC
50 ROR A
60 ROR A
70 EOR COMPTYPE
80 STA TYPE
90 LDA #$00
0100 STA PEXTRA
0110 LDA LEVEL
0120 CMP SEEK
0130 BCC NEXTPLY
0140 CMP SEEK2
0150 BCS TERMINAL
0160 ; WAS PIECE CAPTURED LAST TURN?
0170 LDA CAPTCONT
0180 BNE PLYEXTRA
0190 ; ASSIGN TERMINAL EVALUATION
0200 TERMINAL LDA COMPTYPE
0210 BNE OTHER
0220 JMP EVAL2
0230 OTHER JMP EVAL2
0240 PLYEXTRA LDA #$FF
0250 STA PEXTRA
0260 JSR TERMINAL
0270 LDA NSCORE
0280 STA ALPHA
0290 LDA NSCORE+1
0300 STA ALPHA+1
0310 NEXTPLY JSR MOVGEN
0320 JSR STKCPY
0330 CPX #$FF ; NO LEGAL MOVES
0340 BNE MLOOP
0350 JSR PULLXY
0360 JSR TERMINAL
0370 RTS
0380 MLOOP JSR STKCPY
0390 CPX #$FF ; NO MOVES LEFT
0400 BNE MVPIECE
0410 JSR PULLXY
0420 LDA ALPHA+1
0430 STA NSCORE+1
0440 LDA ALPHA
0450 STA NSCORE
0460 RTS
0470 MVPIECE JSR MAKEMOVE
0480 ; SAVE ALPHA AND BETA
0490 LDA ALPHA
0500 JSR PUSHRT
0510 LDA ALPHA+1
0520 JSR PUSHRT
0530 LDA BETA
0540 JSR PUSHRT
0550 LDA BETA+1
0560 JSR PUSHRT
0570 ; ALPHA = - BETA;BETA = - ALPHA
0580 LDA #$00
0590 SEC
0600 SBC ALPHA
0610 PHA
0620 LDA #$80
0630 SBC ALPHA+1
0640 PHA
0650 LDA #$00
0660 SEC
0670 SBC BETA
0680 STA ALPHA
0690 LDA #$80
0700 SBC BETA+1
0710 STA ALPHA+1
0720 PLA
0730 STA BETA+1
0740 PLA
0750 STA BETA
0760 ; CALL PROCEDURE RECURSIVELY
0770 INC LEVEL
0780 LDA VIEWFLAG
0790 BEQ VIEWSKIP
0800 JSR BOARDRAW
0810 JSR $F6E2
0820 VIEWSKIP JSR MOVE
0830 DEC LEVEL
0840 JSR PULLXY
0850 JSR TAKEMOVE ; RESTORE BOARD
0860 ; RESTORE ALPHA AND BETA
0870 JSR PULLRT
0880 STA BETA+1
0890 JSR PULLRT
0900 STA BETA
0910 JSR PULLRT
0920 STA ALPHA+1
0930 JSR PULLRT
0940 STA ALPHA
0950 ; NEGATE EVALUATION SCORE
0960 LDA #$00
0970 SEC
0980 SBC NSCORE
0990 STA NSCORE
1000 LDA #$80
1010 SBC NSCORE+1
1020 STA NSCORE+1
1030 ; ALPHA=MAX ( ALPHA,-NSCORE)
1040 LDA NSCORE+1 ; CHECK FOR NEW
1050 CMP ALPHA+1
1060 BCC NOSWITCH
1070 BEQ TRY2
1080 JMP SWITCH
1090 TRY2 LDA NSCORE
1100 CMP ALPHA
1110 BCC NOSWITCH
1120 SWITCH LDA NSCORE
1130 STA ALPHA
1140 LDA NSCORE+1
1150 STA ALPHA+1
1160 LDX LEVEL
1170 LDA LASTMOVE
1180 STA BESTSTART,X
1190 LDA LASTMOVE+1
1200 STA BESTEND,X
1210 JSR SHOWMOVE
1220 NOSWITCH LDA ALPHA+1
1230 CMP BETA+1
1240 BCC NOPRUNE
1250 BNE PRUNE
1260 LDA ALPHA
1270 CMP BETA
1280 BCC NOPRUNE
1290 PRUNE JSR PULLXY
1300 CPX #$FF
1310 BNE PRUNE
1320 LDA #$7F
1330 STA NSCORE+1
1340 LDA #$FF
1350 STA NSCORE
1360 LDX LASTMOVE+1
1370 LDA BOARD,X
1380 BNE KHUSKIP
1390 LDY LEVEL
1400 LDA LASTMOVE
1410 STA KILLSTART,Y
1420 TXA
1430 STA KILLEND,Y
1440 KHUSKIP RTS
1450 NOPRUNE JMP MLOOP
1460 STKCPY
1470 LDY #$01
1480 LDA (STKPTR),Y
1490 TAX
1500 DEY
1510 LDA (STKPTR),Y
1520 TAY
1530 RTS
1540 PULLXY
1550 JSR STKCPY
1560 INC STKPTR
1570 INC STKPTR
1580 BNE PLEXIT
1590 INC STKPTR+1
1600 PLEXIT RTS
1610 MAKEMOVE
1620 STX LASTMOVE
1630 STY LASTMOVE+1
1640 LDA BOARD,Y
1650 PHA
1660 AND #$0F
1670 CMP #$06
1680 BEQ KINGCAPT
1690 LDA BOARD,X
1700 STA BOARD,Y
1710 LDA #$00
1720 STA BOARD,X
1730 PLA
1740 LDY LEVEL
1750 STA STORE,Y
1760 STA CAPTCONT
1770 RTS
1780 KINGCAPT
1790 PLA ; REMOVE GARBAGE
1800 PLA
1810 PLA
1820 KCPRUNE JSR PULLXY
1830 CPX #$FF
1840 BNE KCPRUNE
1850 LDA #$6F
1860 STA NSCORE+1
1870 LDA #$FF
1880 STA NSCORE
1890 RTS ; TERMINATE NODE
1900 TAKEMOVE
1910 STX LASTMOVE
1920 STY LASTMOVE+1
1930 LDA BOARD,Y
1940 STA BOARD,X
1950 LDX LEVEL
1960 LDA STORE,X
1970 STA BOARD,Y
1980 RTS
1990 PUSHRT
2000 LDY RTSTKPTR
2010 STA RTSTACK,Y
2020 INC RTSTKPTR
2030 RTS
2040 PULLRT
2050 DEC RTSTKPTR
2060 LDY RTSTKPTR
2070 LDA RTSTACK,Y
2080 RTS