forked from pret/pokepinball
-
Notifications
You must be signed in to change notification settings - Fork 2
/
macros.asm
executable file
·170 lines (144 loc) · 2.94 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
INCLUDE "macros/sound.asm"
AdvanceFrame EQUS "$10"
JumpTable EQUS "$18"
dex_text EQUS "db " ; Start beginning of pokedex description
dex_line EQUS "db $0d," ; Start new line in pokedex description
dex_end EQUS "db $00" ; Terminate the pokedex description
dbw: MACRO
db \1
dw \2
ENDM
dwb: MACRO
dw \1
db \2
ENDM
dba: MACRO
dbw BANK(\1), \1
ENDM
dab: MACRO
dwb \1, BANK(\1)
ENDM
lb: MACRO
ld \1, (\2 << 8) | \3
ENDM
padded_dab: MACRO
dab \1
db $00
ENDM
dn: MACRO
rept _NARG / 2
db (\1) << 4 + (\2)
shift
shift
endr
ENDM
dx: MACRO
x = 8 * ((\1) - 1)
rept \1
db ((\2) >> x) & $ff
x = x + -8
endr
ENDM
bigdw: MACRO ; big-endian word
dx 2, \1
ENDM
callba: MACRO
ld [hFarCallTempA], a
IF _NARG > 1
ld a, BANK(\2)
ld hl, \2
call \1, BankSwitch
ELSE
ld a, BANK(\1)
ld hl, \1
call BankSwitch
ENDC
ENDM
bigBCD6: MACRO
; There is probably a better name for this macro.
; It write a BCD in big-endian form.
dn ((\1) / 10) % 10, (\1) % 10
dn ((\1) / 1000) % 10, ((\1) / 100) % 10
dn ((\1) / 100000) % 10, ((\1) / 10000) % 10
dn ((\1) / 10000000) % 10, ((\1) / 1000000) % 10
dn ((\1) / 1000000000) % 10, ((\1) / 100000000) % 10
dn ((\1) / 100000000000) % 10, ((\1) / 10000000000) % 10
ENDM
; Constant enumeration is useful for mons, maps, etc.
const_def: MACRO
const_value = 0
ENDM
const: MACRO
\1 EQU const_value
const_value = const_value + 1
ENDM
;\1 = X
;\2 = Y
;\3 = Reference Background Map (e.g. vBGMap or vBGWin)
coord: MACRO
ld \1, \4 + $20 * \3 + \2
ENDM
hlCoord EQUS "coord hl,"
deCoord EQUS "coord de,"
bcCoord EQUS "coord bc,"
tile EQUS "+ $10 *"
;\1 = 5-bit Blue value
;\2 = 5-bit Green value
;\3 = 5-bit Red value
RGB: MACRO
dw (\3 << 10 | \2 << 5 | \1)
ENDM
;\1 = pointer to 2bpp tile data
;\2 = destination for tile data in VRAM
;\3 = size of 2bpp tile data to copy
VIDEO_DATA_TILES: MACRO
dw \1
db Bank(\1)
dw \2
dw (\3 << 2)
ENDM
;\1 = pointer to 2bpp tile data
;\2 = bank of data
;\3 = destination for tile data in VRAM
;\4 = size of 2bpp tile data to copy
VIDEO_DATA_TILES_BANK: MACRO
dw \1
db \2
dw \3
dw (\4 << 2)
ENDM
;\1 = pointer to 2bpp tile data
;\2 = destination for tile data in VRAM
;\3 = size of 2bpp tile data to copy
VIDEO_DATA_TILES_BANK2: MACRO
dw \1
db Bank(\1)
dw \2
dw (\3 << 2) | $2
ENDM
;\1 = pointer to tilemap data
;\2 = destination for tilemap data in VRAM
;\3 = size of tilemap to copy
VIDEO_DATA_TILEMAP: MACRO
VIDEO_DATA_TILES \1, \2, \3
ENDM
;\1 = pointer to tilemap data
;\2 = destination for tilemap data in VRAM
;\3 = size of tilemap to copy
VIDEO_DATA_TILEMAP_BANK2: MACRO
VIDEO_DATA_TILES_BANK2 \1, \2, \3
ENDM
;\1 = pointer to background attribute data
;\2 = destination for background attribute data in VRAM
;\3 = size of background attribute data to copy
VIDEO_DATA_BGATTR: MACRO
VIDEO_DATA_TILES_BANK2 \1, \2, \3
ENDM
;\1 = pointer to palette data
;\2 = size of palette data
VIDEO_DATA_PALETTES: MACRO
dw \1
db Bank(\1)
dw $0000
dw (\2 << 1) | $1
ENDM