-
Notifications
You must be signed in to change notification settings - Fork 2
/
nmovgen.src
193 lines (193 loc) · 3.95 KB
/
nmovgen.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
10 DIRDATA
20 .BYTE -1,-10,1,10,-11,-9,11,9
30 .BYTE 12,8,21,19,-12,-8,-21,-19
40 DIRIND
50 .BYTE 0,8,4,0,0,0
60 DIST
70 .BYTE 0,8,4,4,8,8
80 GODATA
90 .BYTE 0,0,1,1,1,0
0100 SETUP LDY #$80
0110 SETLOOP LDA BDATA-1,Y
0120 STA BOARD-1,Y
0130 DEY
0140 BNE SETLOOP
0150 RTS
0160 BDATA
0170 .BYTE $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
0180 .BYTE $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
0190 .BYTE $FF,$84,$82,$83,$85,$86,$83,$82,$84,$FF
0200 .BYTE $FF,$81,$81,$81,$81,$81,$81,$81,$81,$FF
0210 .BYTE $FF,0,0,0,0,0,0,0,0,$FF
0220 .BYTE $FF,0,0,0,0,0,0,0,0,$FF
0230 .BYTE $FF,0,0,0,0,0,0,0,0,$FF
0240 .BYTE $FF,0,0,0,0,0,0,0,0,$FF
0250 .BYTE $FF,$01,$01,$01,$01,$01,$01,$01,$01,$FF
0260 .BYTE $FF,$04,$02,$03,$05,$06,$03,$02,$04,$FF
0270 .BYTE $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
0280 .BYTE $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
0290 MOVGEN
0300 LDA #$15
0310 STA BLOK
0311 LDA #$00
0312 STA CSTKPTR
0320 LDA #$FF
0330 JSR PUSHA
0340 JSR PUSHA
0350 GENLOOP LDX BLOK
0360 LDA BOARD,X
0370 BEQ ENDGEN
0380 CMP #$FF
0390 BEQ ENDGEN
0400 AND #$80
0410 CMP TYPE
0420 BNE ENDGEN
0430 LDA BOARD,X
0440 AND #$07
0450 CMP #$01
0460 BNE NOTPAWN
0470 JMP PAWNSUB
0480 NOTPAWN TAX
0490 DEX
0500 LDA DIST,X
0510 STA COUNT
0520 LDA GODATA,X
0530 STA GOFLAG
0540 LDA DIRIND,X
0550 TAX
0560 GEN2LOOP LDA BLOK
0570 SLIDE CLC
0580 ADC DIRDATA,X
0590 TAY
0600 LDA BOARD,Y
0610 BEQ MVFOUND
0620 CMP #$FF
0630 BEQ END2GEN
0640 AND #$80
0650 CMP TYPE
0660 BEQ END2GEN
0670 LDA BLOK
0680 JSR CPA
0690 TYA
0700 JSR CPA
0710 JMP END2GEN
0720 MVFOUND LDA BLOK
0730 JSR PUSHA
0740 TYA
0750 JSR PUSHA
0760 LDA GOFLAG
0770 BEQ END2GEN ; STOP-PIECE MOVES 1
0780 LDA TEMP
0790 JMP SLIDE
0800 END2GEN INX ; TRY NEXT DIRECTION
0810 DEC COUNT
0820 BNE GEN2LOOP
0830 ENDGEN INC BLOK
0840 LDA BLOK
0850 CMP #$63
0860 BNE GENLOOP
0870 LDY #$00
0880 MGCAPT CPY CSTKPTR
0890 BEQ MGQUIT
0900 LDA CSTACK,Y
0910 JSR PUSHA
0920 INY
0930 JMP MGCAPT
0940 MGQUIT RTS
0950 PDATA
0960 .BYTE -10,-9,-11,-20,10,9,11,20
0970 PLEFT
0980 .BYTE 81,31
0990 PRIGHT
1000 .BYTE 89,39
1010 PAWNSUB
1020 LDY #$00
1030 STY GOFLAG
1040 LDA BOARD,X
1050 AND #$80
1060 BEQ PAWN2
1070 LDY #$04
1080 PAWN2 LDA BLOK
1090 CLC
1100 ADC PDATA,Y
1110 TAX
1120 LDA BOARD,X
1130 BNE PAWN3
1140 JSR PSAVE
1150 INC GOFLAG
1160 PAWN3 INY
1170 LDA PDATA,Y
1180 CLC
1190 ADC BLOK
1200 TAX
1210 LDA BOARD,X
1220 BEQ PAWN4
1230 CMP #$FF
1240 BEQ PAWN4
1250 AND #$80
1260 CMP TYPE
1270 BEQ PAWN4
1280 LDA BLOK ; CAN ATTACK
1290 JSR CPA
1300 TXA
1310 JSR CPA
1320 PAWN4 INY
1330 LDA PDATA,Y
1340 CLC
1350 ADC BLOK
1360 TAX
1370 LDA BOARD,X
1380 BEQ PAWN5
1390 CMP #$FF
1400 BEQ PAWN5
1410 AND #$80
1420 CMP TYPE
1430 BEQ PAWN5
1440 LDA BLOK
1450 JSR CPA
1460 TXA
1470 JSR CPA
1480 PAWN5 LDA GOFLAG
1490 BEQ PEXIT
1500 INY ; TEST MOVE 2
1510 LDX #$00
1520 LDA TYPE
1530 BPL PSKIP
1540 INX
1550 PSKIP LDA BLOK
1560 CMP PLEFT,X
1570 BCC PEXIT
1580 CMP PRIGHT,X
1590 BCS PEXIT
1600 CLC
1610 ADC PDATA,Y
1620 TAX
1630 LDA BOARD,X
1640 BNE PEXIT
1650 JSR PSAVE
1660 PEXIT JMP ENDGEN
1670 PSAVE
1680 LDA BLOK
1690 JSR PUSHA
1700 TXA
1710 JSR PUSHA
1720 RTS
1730 PUSHA
1740 STY TEMP
1750 PHA
1760 LDY #$00
1770 LDA STKPTR
1780 BNE PASKIP
1790 DEC STKPTR+1
1800 PASKIP DEC STKPTR
1810 PLA
1820 STA (STKPTR),Y
1830 LDY TEMP
1840 RTS
1850 CPA
1860 STY TEMP
1870 LDY CSTKPTR
1880 STA CSTACK,Y
1890 INC CSTKPTR
1900 LDY TEMP
1910 RTS