-
Notifications
You must be signed in to change notification settings - Fork 0
/
macros.asm
executable file
·269 lines (225 loc) · 3.33 KB
/
macros.asm
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
258
259
260
261
262
263
264
265
266
267
268
269
INCLUDE "macros/enum.asm"
INCLUDE "macros/wram.asm"
INCLUDE "macros/sound.asm"
INCLUDE "macros/scripting.asm"
Bankswitch EQU $10
MemBankswitch EQU $18
FarCall EQU $20
text EQUS "db $00,"
txfn EQUS "db $e1,"
line EQUS "db $e2,"
done EQUS "db $e0"
TX_SPEED: MACRO
db "<DELAY>"
db \1
ENDM
TX_CALL: MACRO
db "<CALL>"
dw \1
ENDM
TX_DENJUU: MACRO
db "<DENJUU>"
db \1
ENDM
RGB: MACRO
dw ((\3) << 10) + ((\2) << 5) + (\1)
ENDM
percent EQUS "* $ff / 100"
ddb: MACRO
rept _NARG
db \1, \1
shift
endr
ENDM
callba_rst: MACRO
ld a, BANK(\1)
ld hl, \1
rst FarCall
ENDM
callba: MACRO
ld a, BANK(\1)
ld hl, \1
call FarCall_HL
ENDM
jpba: MACRO
ld a, BANK(\1)
ld hl, \1
jp FarCall_HL
ENDM
palettes EQUS "* 8"
tiles EQUS "* $10"
tile EQUS "+ $10 *"
lb: MACRO
ld \1, ((\2 & $ff) << 8) | (\3 & $ff)
ENDM
bigdw: MACRO
REPT _NARG
db (\1 >> 8), (\1 & $ff)
shift
ENDR
ENDM
dn: MACRO
REPT _NARG / 2
db ((\1 & $f) << 4) | (\2 & $f)
shift
shift
ENDR
ENDM
ln: MACRO
ld \1, ((\2 & $f) << 4) | (\3 & $f)
ENDM
dbw: MACRO
db \1
dw \2
ENDM
dba: MACRO
dbw BANK(\1), \1
ENDM
dwb: MACRO
dw \1
db \2
ENDM
dab: MACRO
dwb \1, BANK(\1)
ENDM
homecall: MACRO
ld a, [wROMBank]
push af
ld a, BANK(\1)
rst Bankswitch
REPT _NARG
call \1
shift
ENDR
pop af
rst Bankswitch
ENDM
homecall_memret: MACRO
ld a, BANK(\1)
rst Bankswitch
REPT _NARG
call \1
shift
ENDR
rst MemBankswitch
ENDM
homecall_memret_passa: MACRO
push af
ld a, BANK(\1)
rst Bankswitch
pop af
REPT _NARG
call \1
shift
ENDR
rst MemBankswitch
ENDM
bgcoord: MACRO
IF _NARG >= 4
ld \1, (\3 * BG_MAP_WIDTH) + \2 + \4
ELSE
ld \1, (\3 * BG_MAP_WIDTH) + \2 + VBGMap
ENDC
ENDM
hlbgcoord EQUS "bgcoord hl,"
debgcoord EQUS "bgcoord de,"
bcbgcoord EQUS "bgcoord bc,"
dwbgcoord: MACRO
IF _NARG >= 3
dw (\2 * BG_MAP_WIDTH) + \1 + \3
ELSE
dw (\2 * BG_MAP_WIDTH) + \1 + VBGMap
ENDC
ENDM
bgcoord_a: MACRO
IF _NARG >= 3
ld [(\2 * BG_MAP_WIDTH) + \1 + \3], a
ELSE
ld [(\2 * BG_MAP_WIDTH) + \1 + VBGMap], a
ENDC
ENDM
a_bgcoord: MACRO
IF _NARG >= 3
ld a, [(\2 * BG_MAP_WIDTH) + \1 + \3]
ELSE
ld a, [(\2 * BG_MAP_WIDTH) + \1 + VBGMap]
ENDC
ENDM
coord: MACRO
ld \1, (\3 * (SCREEN_WIDTH / 2) + \2) + wOverworldMap
ENDM
hlcoord EQUS "coord hl,"
decoord EQUS "coord de,"
bccoord EQUS "coord bc,"
dwcoord: MACRO
dw (\2 * (SCREEN_WIDTH / 2) + \1) + wOverworldMap
ENDM
check_cgb: MACRO
ld a, [wCGB]
cp $11
ENDM
inchlntimes: MACRO
cp $0
jr z, .skip\@
.loop\@
inc hl
dec a
jr nz, .loop\@
.skip\@
ENDM
addntimes_hl_de: MACRO
cp $0
jr z, .skip\@
.loop\@
add hl, de
dec a
jr nz, .loop\@
.skip\@
ENDM
char_def: MACRO
cur_char = 0
ENDM
defchar: MACRO
charmap \1, cur_char
cur_char = cur_char + 1
ENDM
flag_array: MACRO
IF (\1 & $7) > 0
ds (\1 >> 3) + 1
ELSE
ds (\1 >> 3)
ENDC
ENDM
jump_table: MACRO
IF _NARG >= 1
ld hl, \1
ELSE
ld hl, @ + 7
ENDC
call GetWordFromTable
jp hl
ENDM
overcoord: MACRO
ld \1, (\3 * SCREEN_WIDTH / 2) + \2 + wOverworldMap
ENDM
hlovercoord EQUS "overcoord hl,"
deovercoord EQUS "overcoord de,"
bcovercoord EQUS "overcoord bc,"
Aovercoord: MACRO
ld a, [(\2 * SCREEN_WIDTH / 2) + \1 + wOverworldMap]
ENDM
overcoordA: MACRO
ld [(\2 * SCREEN_WIDTH / 2) + \1 + wOverworldMap], a
ENDM
enable_sram: MACRO
ld a, SRAM_ENABLE
ld [MBC3SRamEnable], a
IF _NARG > 0
ld a, BANK(\1)
ld [MBC3SRamBank], a
ENDC
ENDM
disable_sram: MACRO
ld a, SRAM_DISABLE
ld [MBC3SRamEnable], a
ENDM