-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmacros.s
257 lines (233 loc) · 6.9 KB
/
macros.s
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
processor 6502
mac varbase
NEXT_VAR set {1}
endm
mac var
{1} = NEXT_VAR
NEXT_VAR set NEXT_VAR + 1
endm
mac varrange
{1} = NEXT_VAR
NEXT_VAR set NEXT_VAR + {2}
endm
mac checkvarbase
if NEXT_VAR > {1}
err
endif
endm
mac definescript
NEXT_EP set {1}*$100
endm
mac defineep
EP_{1} = NEXT_EP
NEXT_EP set NEXT_EP + 1
endm
; Text jump. Game texts need to be located between $0000-$7fff to use
mac textjump
dc.b >{1} | $80
dc.b <{1}
endm
; BIT instruction for skipping the next 1- or 2-byte instruction
mac skip1
dc.b $24
endm
mac skip2
dc.b $2c
endm
; Encode 4 instruction lengths into one byte
mac instrlen
dc.b {1} | ({2} * 4) | ({3} * 16) | ({4} * 64)
endm
; Screen redraw macros
mac drawbottomedge
subroutine dbe
ldy $1000,x
lda blkColors,y
bne .1
lda (dsBottomPtrLo),y
sta colors+{1},x
bcc .3
.1: sta colors+{1},x
.2: lda (dsBottomPtrLo),y
.3: sta screen+{1},x
subroutine dbeend
endm
mac drawbottom
subroutine db
ldy $1000,x
lda blkColors,y
bmi .1
bne .2
lda blkBL,y
sta colors+{1},x
sta screen+{1},x
lda blkBR,y
sta colors+{1}+1,x
bcc .3
.1: sta colors+{1},x
sta colors+{1}+1,x
.2: lda blkBL,y
sta screen+{1},x
lda blkBR,y
.3: sta screen+{1}+1,x
subroutine dbend
endm
mac drawtopedge
subroutine dte
ldy $1000,x
lda blkColors,y
bne .1
lda (dsTopPtrLo),y
sta colors+{1},x
bcc .3
.1: sta colors+{1},x
.2: lda (dsTopPtrLo),y
.3: sta screen+{1},x
subroutine dteend
endm
mac drawtop
subroutine dt
ldy $1000,x
lda blkColors,y
bmi .1
bne .2
lda blkTL,y
sta colors+{1},x
sta screen+{1},x
lda blkTR,y
sta colors+{1}+1,x
bcc .3
.1: sta colors+{1},x
sta colors+{1}+1,x
.2: lda blkTL,y
sta screen+{1},x
lda blkTR,y
.3: sta screen+{1}+1,x
subroutine dtend
endm
mac drawedge
subroutine de
ldy $1000,x
lda blkColors,y
bmi .1
bne .2
lda (dsTopPtrLo),y
sta colors+{1},x
sta screen+{1},x
lda (dsBottomPtrLo),y
sta colors+{1}+40,x
bcc .3
.1: sta colors+{1},x
sta colors+{1}+40,x
.2: lda (dsTopPtrLo),y
sta screen+{1},x
lda (dsBottomPtrLo),y
.3: sta screen+{1}+40,x
subroutine deend
endm
mac drawfullblock
subroutine dfb
ldy $1000,x
lda blkColors,y
bmi .1
bne .2
lda blkTL,y
sta colors+{1},x
sta screen+{1},x
lda blkTR,y
sta colors+{1}+1,x
sta screen+{1}+1,x
lda blkBL,y
sta colors+{1}+40,x
sta screen+{1}+40,x
lda blkBR,y
sta colors+{1}+41,x
bcc .3
.1: sta colors+{1},x
sta colors+{1}+1,x
sta colors+{1}+40,x
sta colors+{1}+41,x
.2: lda blkTL,y
sta screen+{1},x
lda blkTR,y
sta screen+{1}+1,x
lda blkBL,y
sta screen+{1}+40,x
lda blkBR,y
.3: sta screen+{1}+41,x
subroutine dfbend
endm
mac drawfullblockexit
subroutine dfbe
ldy $1000,x
lda blkColors,y
bmi .1
bne .2
lda blkTL,y
sta colors+{1},x
sta screen+{1},x
lda blkTR,y
sta colors+{1}+1,x
sta screen+{1}+1,x
lda blkBL,y
sta colors+{1}+40,x
sta screen+{1}+40,x
lda blkBR,y
sta colors+{1}+41,x
sta screen+{1}+41,x
bcc {2}
.1: sta colors+{1},x
sta colors+{1}+1,x
sta colors+{1}+40,x
sta colors+{1}+41,x
.2: lda blkTL,y
sta screen+{1},x
lda blkTR,y
sta screen+{1}+1,x
lda blkBL,y
sta screen+{1}+40,x
lda blkBR,y
sta screen+{1}+41,x
bcc {2}
subroutine dfbeend
endm
mac loadrow
txa
adc mapTblLo+{3},y
sta {1}+1
sta {2}+1
lda zpSrcHi
adc mapTblHi+{3},y
sta {1}+2
sta {2}+2
endm
mac adjustedge
subroutine ae
inc {1}+1
bne .1
inc {1}+2
.1:
subroutine aeend
endm
mac copycrtcode
subroutine ccc
ldx #>({2}-{1}+$ff)
ldy #$00
lda #<{1}
sta zpSrcLo
lda #>{1}
sta zpSrcHi
lda #<{3}
sta zpDestLo
lda #>{3}
sta zpDestHi
.1: lda (zpSrcLo),y
sta (zpDestLo),y
iny
bne .1
inc zpSrcHi
inc zpDestHi
dex
bne .1
subroutine cccend
endm