aboutsummaryrefslogtreecommitdiffstats
path: root/macros
diff options
context:
space:
mode:
authorvulcandth <vulcandth@gmail.com>2022-06-06 16:25:34 -0500
committerGitHub <noreply@github.com>2022-06-06 17:25:34 -0400
commitc1ef7b75972fa4fbdf125bc85cc1a66f358151cd (patch)
treebcf71939ec5573ed5001c4a4b4342d26e5d8f9b1 /macros
parentImproved Virtual Console patch identifiers (#85) (diff)
downloadpokeyellow-c1ef7b75972fa4fbdf125bc85cc1a66f358151cd.tar.gz
pokeyellow-c1ef7b75972fa4fbdf125bc85cc1a66f358151cd.tar.xz
pokeyellow-c1ef7b75972fa4fbdf125bc85cc1a66f358151cd.zip
RGBDS syntax updates (#86)
New MACRO and DEF syntax
Diffstat (limited to 'macros')
-rw-r--r--macros/asserts.asm172
-rw-r--r--macros/code.asm16
-rw-r--r--macros/const.asm70
-rw-r--r--macros/coords.asm36
-rw-r--r--macros/data.asm90
-rw-r--r--macros/farcall.asm20
-rw-r--r--macros/gfx.asm28
-rw-r--r--macros/predef.asm14
-rw-r--r--macros/scripts/audio.asm54
-rw-r--r--macros/scripts/events.asm158
-rw-r--r--macros/scripts/gfx_anims.asm24
-rw-r--r--macros/scripts/maps.asm172
-rw-r--r--macros/scripts/text.asm88
-rw-r--r--macros/vc.asm40
-rw-r--r--macros/wram.asm20
15 files changed, 501 insertions, 501 deletions
diff --git a/macros/asserts.asm b/macros/asserts.asm
index df2cdcd4..b8498537 100644
--- a/macros/asserts.asm
+++ b/macros/asserts.asm
@@ -1,122 +1,122 @@
; Macros to verify assumptions about the data or code
-table_width: MACRO
-CURRENT_TABLE_WIDTH = \1
-IF _NARG == 2
-REDEF CURRENT_TABLE_START EQUS "\2"
-ELSE
-REDEF CURRENT_TABLE_START EQUS "._table_width\@"
-{CURRENT_TABLE_START}:
-ENDC
+MACRO table_width
+ DEF CURRENT_TABLE_WIDTH = \1
+ IF _NARG == 2
+ REDEF CURRENT_TABLE_START EQUS "\2"
+ ELSE
+ REDEF CURRENT_TABLE_START EQUS "._table_width\@"
+ {CURRENT_TABLE_START}:
+ ENDC
ENDM
-assert_table_length: MACRO
-x = \1
+MACRO assert_table_length
+ DEF x = \1
ASSERT x * CURRENT_TABLE_WIDTH == @ - {CURRENT_TABLE_START}, \
"{CURRENT_TABLE_START}: expected {d:x} entries, each {d:CURRENT_TABLE_WIDTH} bytes"
ENDM
-list_start: MACRO
-list_index = 0
-IF _NARG == 1
-REDEF CURRENT_LIST_START EQUS "\1"
-ELSE
-REDEF CURRENT_LIST_START EQUS "._list_start\@"
-{CURRENT_LIST_START}:
-ENDC
+MACRO list_start
+ DEF list_index = 0
+ IF _NARG == 1
+ REDEF CURRENT_LIST_START EQUS "\1"
+ ELSE
+ REDEF CURRENT_LIST_START EQUS "._list_start\@"
+ {CURRENT_LIST_START}:
+ ENDC
ENDM
-li: MACRO
+MACRO li
ASSERT !STRIN(\1, "@"), STRCAT("String terminator \"@\" in list entry: ", \1)
db \1, "@"
-list_index += 1
+ DEF list_index += 1
ENDM
-assert_list_length: MACRO
-x = \1
+MACRO assert_list_length
+ DEF x = \1
ASSERT x == list_index, \
"{CURRENT_LIST_START}: expected {d:x} entries, got {d:list_index}"
ENDM
-nybble_array: MACRO
-CURRENT_NYBBLE_ARRAY_VALUE = 0
-CURRENT_NYBBLE_ARRAY_LENGTH = 0
-IF _NARG == 1
-REDEF CURRENT_NYBBLE_ARRAY_START EQUS "\1"
-ELSE
-REDEF CURRENT_NYBBLE_ARRAY_START EQUS "._nybble_array\@"
-{CURRENT_NYBBLE_ARRAY_START}:
-ENDC
+MACRO nybble_array
+ DEF CURRENT_NYBBLE_ARRAY_VALUE = 0
+ DEF CURRENT_NYBBLE_ARRAY_LENGTH = 0
+ IF _NARG == 1
+ REDEF CURRENT_NYBBLE_ARRAY_START EQUS "\1"
+ ELSE
+ REDEF CURRENT_NYBBLE_ARRAY_START EQUS "._nybble_array\@"
+ {CURRENT_NYBBLE_ARRAY_START}:
+ ENDC
ENDM
-nybble: MACRO
+MACRO nybble
ASSERT 0 <= (\1) && (\1) < $10, "nybbles must be 0-15"
-CURRENT_NYBBLE_ARRAY_VALUE = (\1) | (CURRENT_NYBBLE_ARRAY_VALUE << 4)
-CURRENT_NYBBLE_ARRAY_LENGTH += 1
-IF CURRENT_NYBBLE_ARRAY_LENGTH % 2 == 0
- db CURRENT_NYBBLE_ARRAY_VALUE
-CURRENT_NYBBLE_ARRAY_VALUE = 0
-ENDC
+ DEF CURRENT_NYBBLE_ARRAY_VALUE = (\1) | (CURRENT_NYBBLE_ARRAY_VALUE << 4)
+ DEF CURRENT_NYBBLE_ARRAY_LENGTH += 1
+ IF CURRENT_NYBBLE_ARRAY_LENGTH % 2 == 0
+ db CURRENT_NYBBLE_ARRAY_VALUE
+ DEF CURRENT_NYBBLE_ARRAY_VALUE = 0
+ ENDC
ENDM
-end_nybble_array: MACRO
-IF CURRENT_NYBBLE_ARRAY_LENGTH % 2
- db CURRENT_NYBBLE_ARRAY_VALUE << 4
-ENDC
-IF _NARG == 1
-x = \1
- ASSERT x == CURRENT_NYBBLE_ARRAY_LENGTH, \
- "{CURRENT_NYBBLE_ARRAY_START}: expected {d:x} nybbles, got {d:CURRENT_NYBBLE_ARRAY_LENGTH}"
-x = (x + 1) / 2
- ASSERT x == @ - {CURRENT_NYBBLE_ARRAY_START}, \
- "{CURRENT_NYBBLE_ARRAY_START}: expected {d:x} bytes"
-ENDC
+MACRO end_nybble_array
+ IF CURRENT_NYBBLE_ARRAY_LENGTH % 2
+ db CURRENT_NYBBLE_ARRAY_VALUE << 4
+ ENDC
+ IF _NARG == 1
+ DEF x = \1
+ ASSERT x == CURRENT_NYBBLE_ARRAY_LENGTH, \
+ "{CURRENT_NYBBLE_ARRAY_START}: expected {d:x} nybbles, got {d:CURRENT_NYBBLE_ARRAY_LENGTH}"
+ DEF x = (x + 1) / 2
+ ASSERT x == @ - {CURRENT_NYBBLE_ARRAY_START}, \
+ "{CURRENT_NYBBLE_ARRAY_START}: expected {d:x} bytes"
+ ENDC
ENDM
-bit_array: MACRO
-CURRENT_BIT_ARRAY_VALUE = 0
-CURRENT_BIT_ARRAY_LENGTH = 0
-IF _NARG == 1
-REDEF CURRENT_BIT_ARRAY_START EQUS "\1"
-ELSE
-REDEF CURRENT_BIT_ARRAY_START EQUS "._bit_array\@"
-{CURRENT_BIT_ARRAY_START}:
-ENDC
+MACRO bit_array
+ DEF CURRENT_BIT_ARRAY_VALUE = 0
+ DEF CURRENT_BIT_ARRAY_LENGTH = 0
+ IF _NARG == 1
+ REDEF CURRENT_BIT_ARRAY_START EQUS "\1"
+ ELSE
+ REDEF CURRENT_BIT_ARRAY_START EQUS "._bit_array\@"
+ {CURRENT_BIT_ARRAY_START}:
+ ENDC
ENDM
-dbit: MACRO
+MACRO dbit
ASSERT (\1) == 0 || (\1) == 1, "bits must be 0 or 1"
-CURRENT_BIT_ARRAY_VALUE |= (\1) << (CURRENT_BIT_ARRAY_LENGTH % 8)
-CURRENT_BIT_ARRAY_LENGTH += 1
-IF CURRENT_BIT_ARRAY_LENGTH % 8 == 0
- db CURRENT_BIT_ARRAY_VALUE
-CURRENT_BIT_ARRAY_VALUE = 0
-ENDC
+ DEF CURRENT_BIT_ARRAY_VALUE |= (\1) << (CURRENT_BIT_ARRAY_LENGTH % 8)
+ DEF CURRENT_BIT_ARRAY_LENGTH += 1
+ IF CURRENT_BIT_ARRAY_LENGTH % 8 == 0
+ db CURRENT_BIT_ARRAY_VALUE
+ DEF CURRENT_BIT_ARRAY_VALUE = 0
+ ENDC
ENDM
-end_bit_array: MACRO
-IF CURRENT_BIT_ARRAY_LENGTH % 8
- db CURRENT_BIT_ARRAY_VALUE
-ENDC
-IF _NARG == 1
-x = \1
- ASSERT x == CURRENT_BIT_ARRAY_LENGTH, \
- "{CURRENT_BIT_ARRAY_START}: expected {d:x} bits, got {d:CURRENT_BIT_ARRAY_LENGTH}"
-x = (x + 7) / 8
- ASSERT x == @ - {CURRENT_BIT_ARRAY_START}, \
- "{CURRENT_BIT_ARRAY_START}: expected {d:x} bytes"
-ENDC
+MACRO end_bit_array
+ IF CURRENT_BIT_ARRAY_LENGTH % 8
+ db CURRENT_BIT_ARRAY_VALUE
+ ENDC
+ IF _NARG == 1
+ DEF x = \1
+ ASSERT x == CURRENT_BIT_ARRAY_LENGTH, \
+ "{CURRENT_BIT_ARRAY_START}: expected {d:x} bits, got {d:CURRENT_BIT_ARRAY_LENGTH}"
+ DEF x = (x + 7) / 8
+ ASSERT x == @ - {CURRENT_BIT_ARRAY_START}, \
+ "{CURRENT_BIT_ARRAY_START}: expected {d:x} bytes"
+ ENDC
ENDM
-def_grass_wildmons: MACRO
+MACRO def_grass_wildmons
;\1: encounter rate
-CURRENT_GRASS_WILDMONS_RATE = \1
-REDEF CURRENT_GRASS_WILDMONS_LABEL EQUS "._def_grass_wildmons_\1"
+ DEF CURRENT_GRASS_WILDMONS_RATE = \1
+ REDEF CURRENT_GRASS_WILDMONS_LABEL EQUS "._def_grass_wildmons_\1"
{CURRENT_GRASS_WILDMONS_LABEL}:
db \1
ENDM
-end_grass_wildmons: MACRO
+MACRO end_grass_wildmons
IF CURRENT_GRASS_WILDMONS_RATE == 0
ASSERT 1 == @ - {CURRENT_GRASS_WILDMONS_LABEL}, \
"def_grass_wildmons {d:CURRENT_GRASS_WILDMONS_RATE}: expected 1 byte"
@@ -126,15 +126,15 @@ end_grass_wildmons: MACRO
ENDC
ENDM
-def_water_wildmons: MACRO
+MACRO def_water_wildmons
;\1: encounter rate
-CURRENT_WATER_WILDMONS_RATE = \1
-REDEF CURRENT_WATER_WILDMONS_LABEL EQUS "._def_water_wildmons_\1"
+ DEF CURRENT_WATER_WILDMONS_RATE = \1
+ REDEF CURRENT_WATER_WILDMONS_LABEL EQUS "._def_water_wildmons_\1"
{CURRENT_WATER_WILDMONS_LABEL}:
db \1
ENDM
-end_water_wildmons: MACRO
+MACRO end_water_wildmons
IF CURRENT_WATER_WILDMONS_RATE == 0
ASSERT 1 == @ - {CURRENT_WATER_WILDMONS_LABEL}, \
"def_water_wildmons {d:CURRENT_WATER_WILDMONS_RATE}: expected 1 byte"
diff --git a/macros/code.asm b/macros/code.asm
index e0b3e9c9..3c65e100 100644
--- a/macros/code.asm
+++ b/macros/code.asm
@@ -1,20 +1,20 @@
; Syntactic sugar macros
-lb: MACRO ; r, hi, lo
+MACRO lb ; r, hi, lo
ld \1, ((\2) & $ff) << 8 + ((\3) & $ff)
ENDM
-ldpal: MACRO
+MACRO ldpal
ld \1, \2 << 6 | \3 << 4 | \4 << 2 | \5
ENDM
; Design patterns
-dict: MACRO
-IF \1 == 0
- and a
-ELSE
- cp \1
-ENDC
+MACRO dict
+ IF \1 == 0
+ and a
+ ELSE
+ cp \1
+ ENDC
jp z, \2
ENDM
diff --git a/macros/const.asm b/macros/const.asm
index afbde7bc..7c7f8591 100644
--- a/macros/const.asm
+++ b/macros/const.asm
@@ -1,48 +1,48 @@
; Enumerate constants
-const_def: MACRO
-IF _NARG >= 1
-const_value = \1
-ELSE
-const_value = 0
-ENDC
-IF _NARG >= 2
-const_inc = \2
-ELSE
-const_inc = 1
-ENDC
+MACRO const_def
+ IF _NARG >= 1
+ DEF const_value = \1
+ ELSE
+ DEF const_value = 0
+ ENDC
+ IF _NARG >= 2
+ DEF const_inc = \2
+ ELSE
+ DEF const_inc = 1
+ ENDC
ENDM
-const: MACRO
-\1 EQU const_value
-const_value += const_inc
+MACRO const
+ DEF \1 EQU const_value
+ DEF const_value += const_inc
ENDM
-shift_const: MACRO
-\1 EQU 1 << const_value
-const_value += const_inc
+MACRO shift_const
+ DEF \1 EQU 1 << const_value
+ DEF const_value += const_inc
ENDM
-const_skip: MACRO
-if _NARG >= 1
-const_value += const_inc * (\1)
-else
-const_value += const_inc
-endc
+MACRO const_skip
+ if _NARG >= 1
+ DEF const_value += const_inc * (\1)
+ else
+ DEF const_value += const_inc
+ endc
ENDM
-const_next: MACRO
-if (const_value > 0 && \1 < const_value) || (const_value < 0 && \1 > const_value)
-fail "const_next cannot go backwards from {const_value} to \1"
-else
-const_value = \1
-endc
+MACRO const_next
+ if (const_value > 0 && \1 < const_value) || (const_value < 0 && \1 > const_value)
+ fail "const_next cannot go backwards from {const_value} to \1"
+ else
+ DEF const_value = \1
+ endc
ENDM
-rb_skip: MACRO
-IF _NARG == 1
-rsset _RS + \1
-ELSE
-rsset _RS + 1
-ENDC
+MACRO rb_skip
+ IF _NARG == 1
+ rsset _RS + \1
+ ELSE
+ rsset _RS + 1
+ ENDC
ENDM
diff --git a/macros/coords.asm b/macros/coords.asm
index 6b16e7f7..81388895 100644
--- a/macros/coords.asm
+++ b/macros/coords.asm
@@ -1,4 +1,4 @@
-validate_coords: MACRO
+MACRO validate_coords
IF _NARG >= 4
IF \1 >= \3
fail "x coord out of range"
@@ -11,11 +11,11 @@ validate_coords: MACRO
ENDC
ENDM
-hlcoord EQUS "coord hl,"
-bccoord EQUS "coord bc,"
-decoord EQUS "coord de,"
+DEF hlcoord EQUS "coord hl,"
+DEF bccoord EQUS "coord bc,"
+DEF decoord EQUS "coord de,"
-coord: MACRO
+MACRO coord
; register, x, y[, origin]
validate_coords \2, \3
IF _NARG >= 4
@@ -25,11 +25,11 @@ coord: MACRO
ENDC
ENDM
-hlbgcoord EQUS "bgcoord hl,"
-bcbgcoord EQUS "bgcoord bc,"
-debgcoord EQUS "bgcoord de,"
+DEF hlbgcoord EQUS "bgcoord hl,"
+DEF bcbgcoord EQUS "bgcoord bc,"
+DEF debgcoord EQUS "bgcoord de,"
-bgcoord: MACRO
+MACRO bgcoord
; register, x, y[, origin]
validate_coords \2, \3, BG_MAP_WIDTH, BG_MAP_HEIGHT
IF _NARG >= 4
@@ -39,22 +39,22 @@ bgcoord: MACRO
ENDC
ENDM
-hlowcoord EQUS "owcoord hl,"
-bcowcoord EQUS "owcoord bc,"
-deowcoord EQUS "owcoord de,"
+DEF hlowcoord EQUS "owcoord hl,"
+DEF bcowcoord EQUS "owcoord bc,"
+DEF deowcoord EQUS "owcoord de,"
-owcoord: MACRO
+MACRO owcoord
; register, x, y, map width
ld \1, wOverworldMap + ((\2) + 3) + (((\3) + 3) * ((\4) + (3 * 2)))
ENDM
-event_displacement: MACRO
+MACRO event_displacement
; map width, x blocks, y blocks
dw (wOverworldMap + 7 + (\1) + ((\1) + 6) * ((\3) >> 1) + ((\2) >> 1))
db \3, \2
ENDM
-dwcoord: MACRO
+MACRO dwcoord
; x, y
validate_coords \1, \2
IF _NARG >= 3
@@ -64,7 +64,7 @@ dwcoord: MACRO
ENDC
ENDM
-ldcoord_a: MACRO
+MACRO ldcoord_a
; x, y[, origin]
validate_coords \1, \2
IF _NARG >= 3
@@ -74,7 +74,7 @@ ldcoord_a: MACRO
ENDC
ENDM
-lda_coord: MACRO
+MACRO lda_coord
; x, y[, origin]
validate_coords \1, \2
IF _NARG >= 3
@@ -84,7 +84,7 @@ lda_coord: MACRO
ENDC
ENDM
-dbmapcoord: MACRO
+MACRO dbmapcoord
; x, y
db \2, \1
ENDM
diff --git a/macros/data.asm b/macros/data.asm
index 58e8f740..38ec8c9f 100644
--- a/macros/data.asm
+++ b/macros/data.asm
@@ -1,80 +1,80 @@
; Value macros
-percent EQUS "* $ff / 100"
+DEF percent EQUS "* $ff / 100"
-bcd2: MACRO
+MACRO bcd2
dn ((\1) / 1000) % 10, ((\1) / 100) % 10
dn ((\1) / 10) % 10, (\1) % 10
ENDM
-bcd3: MACRO
+MACRO bcd3
dn ((\1) / 100000) % 10, ((\1) / 10000) % 10
dn ((\1) / 1000) % 10, ((\1) / 100) % 10
dn ((\1) / 10) % 10, (\1) % 10
ENDM
; used in data/pokemon/base_stats/*.asm
-tmhm: MACRO
+MACRO tmhm
; initialize bytes to 0
-FOR n, (NUM_TM_HM + 7) / 8
-_tm{d:n} = 0
-ENDR
-; set bits of bytes
-REPT _NARG
- IF DEF(\1_TMNUM)
-n = (\1_TMNUM - 1) / 8
-i = (\1_TMNUM - 1) % 8
-_tm{d:n} |= 1 << i
- ELSE
- FAIL "\1 is not a TM or HM move"
- ENDC
- SHIFT
-ENDR
-; output bytes
-FOR n, (NUM_TM_HM + 7) / 8
- db _tm{d:n}
-ENDR
+ FOR n, (NUM_TM_HM + 7) / 8
+ DEF _tm{d:n} = 0
+ ENDR
+ ; set bits of bytes
+ REPT _NARG
+ IF DEF(\1_TMNUM)
+ DEF n = (\1_TMNUM - 1) / 8
+ DEF i = (\1_TMNUM - 1) % 8
+ DEF _tm{d:n} |= 1 << i
+ ELSE
+ FAIL "\1 is not a TM or HM move"
+ ENDC
+ SHIFT
+ ENDR
+ ; output bytes
+ FOR n, (NUM_TM_HM + 7) / 8
+ db _tm{d:n}
+ ENDR
ENDM
; Constant data (db, dw, dl) macros
-dbw: MACRO
+MACRO dbw
db \1
dw \2
ENDM
-dwb: MACRO
+MACRO dwb
dw \1
db \2
ENDM
-dn: MACRO ; nybbles
-REPT _NARG / 2
- db ((\1) << 4) | (\2)
- SHIFT 2
-ENDR
+MACRO dn ; nybbles
+ REPT _NARG / 2
+ db ((\1) << 4) | (\2)
+ SHIFT 2
+ ENDR
ENDM
-dba: MACRO ; dbw bank, address
-REPT _NARG
- dbw BANK(\1), \1
- SHIFT
-ENDR
+MACRO dba ; dbw bank, address
+ REPT _NARG
+ dbw BANK(\1), \1
+ SHIFT
+ ENDR
ENDM
-dab: MACRO ; dwb address, bank
-REPT _NARG
- dwb \1, BANK(\1)
- SHIFT
-ENDR
+MACRO dab ; dwb address, bank
+ REPT _NARG
+ dwb \1, BANK(\1)
+ SHIFT
+ ENDR
ENDM
-sine_table: MACRO
+MACRO sine_table
; \1 samples of sin(x) from x=0 to x<32768 (pi radians)
-x = 0
-REPT \1
- dw (sin(x) + (sin(x) & $ff)) >> 8 ; round up
-x += DIV(32768, \1) ; a circle has 65536 "degrees"
-ENDR
+ DEF x = 0
+ REPT \1
+ dw (sin(x) + (sin(x) & $ff)) >> 8 ; round up
+ DEF x += DIV(32768, \1) ; a circle has 65536 "degrees"
+ ENDR
ENDM
diff --git a/macros/farcall.asm b/macros/farcall.asm
index f3fa07d4..2cea1656 100644
--- a/macros/farcall.asm
+++ b/macros/farcall.asm
@@ -1,28 +1,28 @@
-farcall: MACRO
+MACRO farcall
ld b, BANK(\1)
ld hl, \1
call Bankswitch
ENDM
-callfar: MACRO
+MACRO callfar
ld hl, \1
ld b, BANK(\1)
call Bankswitch
ENDM
-farjp: MACRO
+MACRO farjp
ld b, BANK(\1)
ld hl, \1
jp Bankswitch
ENDM
-jpfar: MACRO
+MACRO jpfar
ld hl, \1
ld b, BANK(\1)
jp Bankswitch
ENDM
-homecall: MACRO
+MACRO homecall
ldh a, [hLoadedROMBank]
push af
ld a, BANK(\1)
@@ -32,7 +32,7 @@ homecall: MACRO
call BankswitchCommon
ENDM
-homejp: MACRO
+MACRO homejp
ldh a, [hLoadedROMBank]
push af
ld a, BANK(\1)
@@ -42,7 +42,7 @@ homejp: MACRO
jp BankswitchCommon
ENDM
-homecall_sf: MACRO ; homecall but save flags by popping into bc instead of af
+MACRO homecall_sf ; homecall but save flags by popping into bc instead of af
ldh a, [hLoadedROMBank]
push af
ld a, BANK(\1)
@@ -53,7 +53,7 @@ homecall_sf: MACRO ; homecall but save flags by popping into bc instead of af
call BankswitchCommon
ENDM
-homejp_sf: MACRO ; homejp but save flags by popping into bc instead of af
+MACRO homejp_sf ; homejp but save flags by popping into bc instead of af
ldh a, [hLoadedROMBank]
push af
ld a, BANK(\1)
@@ -64,14 +64,14 @@ homejp_sf: MACRO ; homejp but save flags by popping into bc instead of af
jp BankswitchCommon
ENDM
-calladb_ModifyPikachuHappiness: MACRO
+MACRO calladb_ModifyPikachuHappiness
ld hl, ModifyPikachuHappiness
ld d, \1
ld b, BANK(ModifyPikachuHappiness)
call Bankswitch
ENDM
-callabd_ModifyPikachuHappiness: MACRO
+MACRO callabd_ModifyPikachuHappiness
ld hl, ModifyPikachuHappiness
ld b, BANK(ModifyPikachuHappiness)
ld d, \1
diff --git a/macros/gfx.asm b/macros/gfx.asm
index 98eabec4..944e6dd5 100644
--- a/macros/gfx.asm
+++ b/macros/gfx.asm
@@ -1,22 +1,22 @@
-RGB: MACRO
-REPT _NARG / 3
- dw palred (\1) + palgreen (\2) + palblue (\3)
- SHIFT 3
-ENDR
+MACRO RGB
+ REPT _NARG / 3
+ dw palred (\1) + palgreen (\2) + palblue (\3)
+ SHIFT 3
+ ENDR
ENDM
-palred EQUS "(1 << 0) *"
-palgreen EQUS "(1 << 5) *"
-palblue EQUS "(1 << 10) *"
+DEF palred EQUS "(1 << 0) *"
+DEF palgreen EQUS "(1 << 5) *"
+DEF palblue EQUS "(1 << 10) *"
-palettes EQUS "* PALETTE_SIZE"
-palette EQUS "+ PALETTE_SIZE *"
-color EQUS "+ PAL_COLOR_SIZE *"
+DEF palettes EQUS "* PALETTE_SIZE"
+DEF palette EQUS "+ PALETTE_SIZE *"
+DEF color EQUS "+ PAL_COLOR_SIZE *"
-tiles EQUS "* LEN_2BPP_TILE"
-tile EQUS "+ LEN_2BPP_TILE *"
+DEF tiles EQUS "* LEN_2BPP_TILE"
+DEF tile EQUS "+ LEN_2BPP_TILE *"
-dbsprite: MACRO
+MACRO dbsprite
; x tile, y tile, x pixel, y pixel, vtile offset, attributes
db (\2 * TILE_WIDTH) % $100 + \4, (\1 * TILE_WIDTH) % $100 + \3, \5, \6
ENDM
diff --git a/macros/predef.asm b/macros/predef.asm
index d86582d1..45b0197b 100644
--- a/macros/predef.asm
+++ b/macros/predef.asm
@@ -1,32 +1,32 @@
-predef_id: MACRO
+MACRO predef_id
ld a, (\1Predef - PredefPointers) / 3
ENDM
-predef: MACRO
+MACRO predef
predef_id \1
call Predef
ENDM
-predef_jump: MACRO
+MACRO predef_jump
predef_id \1
jp Predef
ENDM
-tx_pre_id: MACRO
+MACRO tx_pre_id
ld a, (\1_id - TextPredefs) / 2 + 1
ENDM
-tx_pre: MACRO
+MACRO tx_pre
tx_pre_id \1
call PrintPredefTextID
ENDM
-tx_pre_jump: MACRO
+MACRO tx_pre_jump
tx_pre_id \1
jp PrintPredefTextID
ENDM
-db_tx_pre: MACRO
+MACRO db_tx_pre
db (\1_id - TextPredefs) / 2 + 1
ENDM
diff --git a/macros/scripts/audio.asm b/macros/scripts/audio.asm
index b12a2adc..114bf576 100644
--- a/macros/scripts/audio.asm
+++ b/macros/scripts/audio.asm
@@ -1,4 +1,4 @@
-audio_header: MACRO
+MACRO audio_header
db (_NARG - 2) << 6 | \2
dw \1_\2
IF _NARG > 2
@@ -24,7 +24,7 @@ ENDM
; small magnitude means quick change, large magnitude means slow change
; in signed magnitude representation, so a value of 8 is the same as (negative) 0
const pitch_sweep_cmd ; $10
-pitch_sweep: MACRO
+MACRO pitch_sweep
db pitch_sweep_cmd
IF \2 < 0
db (\1 << 4) | (%1000 | (\2 * -1))
@@ -41,8 +41,8 @@ ENDM
; fade: positive value means decrease in volume, negative value means increase in volume
; small magnitude means quick change, large magnitude means slow change
; in signed magnitude representation, so a value of 8 is the same as (negative) 0
-square_note_cmd EQU sfx_note_cmd ; $20
-square_note: MACRO
+DEF square_note_cmd EQU sfx_note_cmd ; $20
+MACRO square_note
db square_note_cmd | \1
IF \3 < 0
db (\2 << 4) | (%1000 | (\3 * -1))
@@ -56,8 +56,8 @@ ENDM
; fade: positive value means decrease in volume, negative value means increase in volume
; small magnitude means quick change, large magnitude means slow change
; in signed magnitude representation, so a value of 8 is the same as (negative) 0
-noise_note_cmd EQU sfx_note_cmd ; $20
-noise_note: MACRO
+DEF noise_note_cmd EQU sfx_note_cmd ; $20
+MACRO noise_note
db noise_note_cmd | \1
IF \3 < 0
db (\2 << 4) | (%1000 | (\3 * -1))
@@ -68,7 +68,7 @@ noise_note: MACRO
ENDM
; arguments: pitch, length [1, 16]
-note: MACRO
+MACRO note
db (\1 << 4) | (\2 - 1)
ENDM
@@ -76,7 +76,7 @@ ENDM
; arguments: instrument [1, 19], length [1, 16]
const drum_note_cmd ; $b0
-drum_note: MACRO
+MACRO drum_note
db drum_note_cmd | (\2 - 1)
db \1
ENDM
@@ -85,7 +85,7 @@ ENDM
; like drum_note but one 1 byte instead of 2
; can only be used with instruments 1-10, excluding 2
; unused
-drum_note_short: MACRO
+MACRO drum_note_short
db (\1 << 4) | (\2 - 1)
ENDM
@@ -93,7 +93,7 @@ ENDM
; arguments: length [1, 16]
const rest_cmd ; $c0
-rest: MACRO
+MACRO rest
db rest_cmd | (\1 - 1)
ENDM
@@ -104,7 +104,7 @@ ENDM
; small magnitude means quick change, large magnitude means slow change
; in signed magnitude representation, so a value of 8 is the same as (negative) 0
const note_type_cmd ; $d0
-note_type: MACRO
+MACRO note_type
db note_type_cmd | \1
IF \3 < 0
db (\2 << 4) | (%1000 | (\3 * -1))
@@ -114,8 +114,8 @@ note_type: MACRO
ENDM
; arguments: speed [0, 15]
-drum_speed_cmd EQU note_type_cmd ; $d0
-drum_speed: MACRO
+DEF drum_speed_cmd EQU note_type_cmd ; $d0
+MACRO drum_speed
db drum_speed_cmd | \1
ENDM
@@ -123,7 +123,7 @@ ENDM
; arguments: octave [1, 8]
const octave_cmd ; $e0
-octave: MACRO
+MACRO octave
db octave_cmd | (8 - \1)
ENDM
@@ -131,7 +131,7 @@ ENDM
; when enabled, effective frequency used is incremented by 1
const toggle_perfect_pitch_cmd ; $e8
-toggle_perfect_pitch: MACRO
+MACRO toggle_perfect_pitch
db toggle_perfect_pitch_cmd
ENDM
@@ -142,7 +142,7 @@ ENDM
; depth: amplitude of vibrato wave
; rate: frequency of vibrato wave
const vibrato_cmd ; $ea
-vibrato: MACRO
+MACRO vibrato
db vibrato_cmd
db \1
db (\2 << 4) | \3
@@ -150,7 +150,7 @@ ENDM
; arguments: length [1, 256], octave [1, 8], pitch
const pitch_slide_cmd ; $eb
-pitch_slide: MACRO
+MACRO pitch_slide
db pitch_slide_cmd
db \1 - 1
db ((8 - \2) << 4) | \3
@@ -158,7 +158,7 @@ ENDM
; arguments: duty cycle [0, 3] (12.5%, 25%, 50%, 75%)
const duty_cycle_cmd ; $ec
-duty_cycle: MACRO
+MACRO duty_cycle
db duty_cycle_cmd
db \1
ENDM
@@ -170,27 +170,27 @@ ENDM
; if larger than $100, large note speed or note length values might cause overflow
; stored in big endian
const tempo_cmd ; $ed
-tempo: MACRO
+MACRO tempo
db tempo_cmd
db HIGH(\1), LOW(\1)
ENDM
; arguments: left output enable mask, right output enable mask
const stereo_panning_cmd ; $ee
-stereo_panning: MACRO
+MACRO stereo_panning
db stereo_panning_cmd
db (\1 << 4) | \2
ENDM
const unknownmusic0xef_cmd ; $ef
-unknownmusic0xef: MACRO
+MACRO unknownmusic0xef
db unknownmusic0xef_cmd
db \1
ENDM
; arguments: left master volume [0, 7], right master volume [0, 7]
const volume_cmd ; $f0
-volume: MACRO
+MACRO volume
db volume_cmd
db (\1 << 4) | \2
ENDM
@@ -199,7 +199,7 @@ ENDM
; when enabled, the sfx data is interpreted as music data
const execute_music_cmd ; $f8
-execute_music: MACRO
+MACRO execute_music
db execute_music_cmd
ENDM
@@ -207,27 +207,27 @@ ENDM
; arguments: duty cycle 1, duty cycle 2, duty cycle 3, duty cycle 4
const duty_cycle_pattern_cmd ; $fc
-duty_cycle_pattern: MACRO
+MACRO duty_cycle_pattern
db duty_cycle_pattern_cmd
db \1 << 6 | \2 << 4 | \3 << 2 | \4
ENDM
; arguments: address
const sound_call_cmd ; $fd
-sound_call: MACRO
+MACRO sound_call
db sound_call_cmd
dw \1
ENDM
; arguments: count, address
const sound_loop_cmd ; $fe
-sound_loop: MACRO
+MACRO sound_loop
db sound_loop_cmd
db \1
dw \2
ENDM
const sound_ret_cmd ; $ff
-sound_ret: MACRO
+MACRO sound_ret
db sound_ret_cmd
ENDM
diff --git a/macros/scripts/events.asm b/macros/scripts/events.asm
index 81404ade..ea67cd0a 100644
--- a/macros/scripts/events.asm
+++ b/macros/scripts/events.asm
@@ -1,7 +1,7 @@
;\1 = event index
;\2 = return result in carry instead of zero flag
-CheckEvent: MACRO
-event_byte = ((\1) / 8)
+MACRO CheckEvent
+ DEF event_byte = ((\1) / 8)
ld a, [wEventFlags + event_byte]
IF _NARG > 1
@@ -19,9 +19,9 @@ ENDM
;\1 = event index
-CheckEventReuseA: MACRO
+MACRO CheckEventReuseA
IF event_byte != ((\1) / 8)
-event_byte = ((\1) / 8)
+ DEF event_byte = ((\1) / 8)
ld a, [wEventFlags + event_byte]
ENDC
@@ -31,10 +31,10 @@ ENDM
;\1 = event index
;\2 = event index of the last event used before the branch
-CheckEventAfterBranchReuseA: MACRO
-event_byte = ((\2) / 8)
+MACRO CheckEventAfterBranchReuseA
+ DEF event_byte = ((\2) / 8)
IF event_byte != ((\1) / 8)
-event_byte = ((\1) / 8)
+ DEF event_byte = ((\1) / 8)
ld a, [wEventFlags + event_byte]
ENDC
@@ -45,7 +45,7 @@ ENDM
;\1 = reg
;\2 = event index
;\3 = event index this event is relative to (optional, this is needed when there is a fixed flag address)
-EventFlagBit: MACRO
+MACRO EventFlagBit
IF _NARG > 2
ld \1, ((\3) % 8) + ((\2) - (\3))
ELSE
@@ -56,34 +56,34 @@ ENDM
;\1 = reg
;\2 = event index
-EventFlagAddress: MACRO
-event_byte = ((\2) / 8)
+MACRO EventFlagAddress
+ DEF event_byte = ((\2) / 8)
ld \1, wEventFlags + event_byte
ENDM
-EventFlagAddressA: MACRO
-event_byte = ((\1) / 8)
+MACRO EventFlagAddressA
+ DEF event_byte = ((\1) / 8)
ld [wEventFlags + event_byte], a
ENDM
-AEventFlagAddress: MACRO
-event_byte = ((\1) / 8)
+MACRO AEventFlagAddress
+ DEF event_byte = ((\1) / 8)
ld a, [wEventFlags + event_byte]
ENDM
;\1 = event index
-CheckEventHL: MACRO
-event_byte = ((\1) / 8)
+MACRO CheckEventHL
+ DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
bit (\1) % 8, [hl]
ENDM
;\1 = event index
-CheckEventReuseHL: MACRO
-IF event_byte != ((\1) / 8)
-event_byte = ((\1) / 8)
+MACRO CheckEventReuseHL
+ IF event_byte != ((\1) / 8)
+ DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@@ -93,18 +93,18 @@ ENDM
; dangerous, only use when HL is guaranteed to be the desired value
;\1 = event index
-CheckEventForceReuseHL: MACRO
-event_byte = ((\1) / 8)
+MACRO CheckEventForceReuseHL
+ DEF event_byte = ((\1) / 8)
bit (\1) % 8, [hl]
ENDM
;\1 = event index
;\2 = event index of the last event used before the branch
-CheckEventAfterBranchReuseHL: MACRO
-event_byte = ((\2) / 8)
-IF event_byte != ((\1) / 8)
-event_byte = ((\1) / 8)
+MACRO CheckEventAfterBranchReuseHL
+ DEF event_byte = ((\2) / 8)
+ IF event_byte != ((\1) / 8)
+ DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@@ -113,8 +113,8 @@ ENDM
;\1 = event index
-CheckAndSetEvent: MACRO
-event_byte = ((\1) / 8)
+MACRO CheckAndSetEvent
+ DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
bit (\1) % 8, [hl]
set (\1) % 8, [hl]
@@ -122,8 +122,8 @@ ENDM
;\1 = event index
-CheckAndResetEvent: MACRO
-event_byte = ((\1) / 8)
+MACRO CheckAndResetEvent
+ DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
bit (\1) % 8, [hl]
res (\1) % 8, [hl]
@@ -131,7 +131,7 @@ ENDM
;\1 = event index
-CheckAndSetEventA: MACRO
+MACRO CheckAndSetEventA
ld a, [wEventFlags + ((\1) / 8)]
bit (\1) % 8, a
set (\1) % 8, a
@@ -140,7 +140,7 @@ ENDM
;\1 = event index
-CheckAndResetEventA: MACRO
+MACRO CheckAndResetEventA
ld a, [wEventFlags + ((\1) / 8)]
bit (\1) % 8, a
res (\1) % 8, a
@@ -148,9 +148,9 @@ CheckAndResetEventA: MACRO
ENDM
-CheckAndSetEventReuseHL: MACRO
+MACRO CheckAndSetEventReuseHL
IF event_byte != ((\1) / 8)
-event_byte = ((\1) / 8)
+ DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@@ -158,9 +158,9 @@ event_byte = ((\1) / 8)
set (\1) % 8, [hl]
ENDM
-CheckAndResetEventReuseHL: MACRO
+MACRO CheckAndResetEventReuseHL
IF event_byte != ((\1) / 8)
-event_byte = ((\1) / 8)
+ DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@@ -170,17 +170,17 @@ ENDM
;\1 = event index
-SetEvent: MACRO
-event_byte = ((\1) / 8)
+MACRO SetEvent
+ DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
set (\1) % 8, [hl]
ENDM
;\1 = event index
-SetEventReuseHL: MACRO
+MACRO SetEventReuseHL
IF event_byte != ((\1) / 8)
-event_byte = ((\1) / 8)
+ DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@@ -190,10 +190,10 @@ ENDM
;\1 = event index
;\2 = event index of the last event used before the branch
-SetEventAfterBranchReuseHL: MACRO
-event_byte = ((\2) / 8)
-IF event_byte != ((\1) / 8)
-event_byte = ((\1) / 8)
+MACRO SetEventAfterBranchReuseHL
+ DEF event_byte = ((\2) / 8)
+ IF event_byte != ((\1) / 8)
+ DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@@ -203,8 +203,8 @@ ENDM
; dangerous, only use when HL is guaranteed to be the desired value
;\1 = event index
-SetEventForceReuseHL: MACRO
-event_byte = ((\1) / 8)
+MACRO SetEventForceReuseHL
+ DEF event_byte = ((\1) / 8)
set (\1) % 8, [hl]
ENDM
@@ -212,7 +212,7 @@ ENDM
;\1 = event index
;\2 = event index
;\3, \4, ... = additional (optional) event indices
-SetEvents: MACRO
+MACRO SetEvents
SetEvent \1
REPT _NARG - 1
SetEventReuseHL \2
@@ -222,17 +222,17 @@ ENDM
;\1 = event index
-ResetEvent: MACRO
-event_byte = ((\1) / 8)
+MACRO ResetEvent
+ DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
res (\1) % 8, [hl]
ENDM
;\1 = event index
-ResetEventReuseHL: MACRO
+MACRO ResetEventReuseHL
IF event_byte != ((\1) / 8)
-event_byte = ((\1) / 8)
+ DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@@ -242,10 +242,10 @@ ENDM
;\1 = event index
;\2 = event index of the last event used before the branch
-ResetEventAfterBranchReuseHL: MACRO
-event_byte = ((\2) / 8)
-IF event_byte != ((\1) / 8)
-event_byte = ((\1) / 8)
+MACRO ResetEventAfterBranchReuseHL
+ DEF event_byte = ((\2) / 8)
+ IF event_byte != ((\1) / 8)
+ DEF event_byte = ((\1) / 8)
ld hl, wEventFlags + event_byte
ENDC
@@ -255,8 +255,8 @@ ENDM
; dangerous, only use when HL is guaranteed to be the desired value
;\1 = event index
-ResetEventForceReuseHL: MACRO
-event_byte = ((\1) / 8)
+MACRO ResetEventForceReuseHL
+ DEF event_byte = ((\1) / 8)
res (\1) % 8, [hl]
ENDM
@@ -264,7 +264,7 @@ ENDM
;\1 = event index
;\2 = event index
;\3 = event index (optional)
-ResetEvents: MACRO
+MACRO ResetEvents
ResetEvent \1
REPT _NARG - 1
ResetEventReuseHL \2
@@ -275,9 +275,9 @@ ENDM
;\1 = start
;\2 = end
-SetEventRange: MACRO
-event_start_byte = ((\1) / 8)
-event_end_byte = ((\2) / 8)
+MACRO SetEventRange
+ DEF event_start_byte = ((\1) / 8)
+ DEF event_end_byte = ((\2) / 8)
IF event_end_byte < event_start_byte
FAIL "Incorrect argument order in SetEventRange."
@@ -288,12 +288,12 @@ event_end_byte = ((\2) / 8)
or (1 << (((\2) % 8) + 1)) - (1 << ((\1) % 8))
ld [wEventFlags + event_start_byte], a
ELSE
-event_fill_start = event_start_byte + 1
-event_fill_count = event_end_byte - event_start_byte - 1
+ DEF event_fill_start = event_start_byte + 1
+ DEF event_fill_count = event_end_byte - event_start_byte - 1
IF ((\1) % 8) == 0
-event_fill_start -= 1
-event_fill_count += 1
+ DEF event_fill_start -= 1
+ DEF event_fill_count += 1
ELSE
ld a, [wEventFlags + event_start_byte]
or $ff - ((1 << ((\1) % 8)) - 1)
@@ -301,7 +301,7 @@ event_fill_count += 1
ENDC
IF ((\2) % 8) == 7
-event_fill_count += 1
+ DEF event_fill_count += 1
ENDC
IF event_fill_count == 1
@@ -337,9 +337,9 @@ ENDM
;\1 = start
;\2 = end
;\3 = assume a is 0 if present
-ResetEventRange: MACRO
-event_start_byte = ((\1) / 8)
-event_end_byte = ((\2) / 8)
+MACRO ResetEventRange
+ DEF event_start_byte = ((\1) / 8)
+ DEF event_end_byte = ((\2) / 8)
IF event_end_byte < event_start_byte
FAIL "Incorrect argument order in ResetEventRange."
@@ -350,12 +350,12 @@ event_end_byte = ((\2) / 8)
and ~((1 << (((\2) % 8) + 1)) - (1 << ((\1) % 8))) & $ff
ld [wEventFlags + event_start_byte], a
ELSE
-event_fill_start = event_start_byte + 1
-event_fill_count = event_end_byte - event_start_byte - 1
+ DEF event_fill_start = event_start_byte + 1
+ DEF event_fill_count = event_end_byte - event_start_byte - 1
IF ((\1) % 8) == 0
-event_fill_start -= 1
-event_fill_count += 1
+ DEF event_fill_start -= 1
+ DEF event_fill_count += 1
ELSE
ld a, [wEventFlags + event_start_byte]
and ~($ff - ((1 << ((\1) % 8)) - 1)) & $ff
@@ -363,7 +363,7 @@ event_fill_count += 1
ENDC
IF ((\2) % 8) == 7
-event_fill_count += 1
+ DEF event_fill_count += 1
ENDC
IF event_fill_count == 1
@@ -406,10 +406,10 @@ ENDM
;\1 = event index 1
;\2 = event index 2
;\3 = try to reuse a (optional)
-CheckBothEventsSet: MACRO
+MACRO CheckBothEventsSet
IF ((\1) / 8) == ((\2) / 8)
IF (_NARG < 3) || (((\1) / 8) != event_byte)
-event_byte = ((\1) / 8)
+ DEF event_byte = ((\1) / 8)
ld a, [wEventFlags + ((\1) / 8)]
ENDC
and (1 << ((\1) % 8)) | (1 << ((\2) % 8))
@@ -442,7 +442,7 @@ ENDM
; returns the complement of whether either event is set in Z flag
;\1 = event index 1
;\2 = event index 2
-CheckEitherEventSet: MACRO
+MACRO CheckEitherEventSet
IF ((\1) / 8) == ((\2) / 8)
ld a, [wEventFlags + ((\1) / 8)]
and (1 << ((\1) % 8)) | (1 << ((\2) % 8))
@@ -469,9 +469,9 @@ CheckEitherEventSet: MACRO
ENDM
-CheckEitherEventSetReuseA: MACRO
+MACRO CheckEitherEventSetReuseA
IF event_byte != ((\1) / 8)
-event_byte = ((\1) / 8)
+ DEF event_byte = ((\1) / 8)
ld a, [wEventFlags + event_byte]
ENDC
IF ((\1) / 8) == ((\2) / 8)
@@ -502,7 +502,7 @@ ENDM
; for handling fixed event bits when events are inserted/removed
;\1 = event index
;\2 = fixed flag bit
-AdjustEventBit: MACRO
+MACRO AdjustEventBit
IF ((\1) % 8) != (\2)
add ((\1) % 8) - (\2)
ENDC
diff --git a/macros/scripts/gfx_anims.asm b/macros/scripts/gfx_anims.asm
index 9ba1e61c..2eb0aa81 100644
--- a/macros/scripts/gfx_anims.asm
+++ b/macros/scripts/gfx_anims.asm
@@ -1,37 +1,37 @@
; pic + oam animations
-frame: MACRO
+MACRO frame
db \1
-x = \2
-IF _NARG > 2
-REPT _NARG - 2
-x |= \3 << 1
- shift
-ENDR
-ENDC
+ DEF x = \2
+ IF _NARG > 2
+ REPT _NARG - 2
+ DEF x |= \3 << 1
+ shift
+ ENDR
+ ENDC
db x
ENDM
const_def -1, -1
const endanim_command ; $ff
-endanim: MACRO
+MACRO endanim
db endanim_command
ENDM
const dorestart_command ; $fe
-dorestart: MACRO
+MACRO dorestart
db dorestart_command
ENDM
const dorepeat_command ; $fd
-dorepeat: MACRO
+MACRO dorepeat
db dorepeat_command
db \1 ; command offset to jump to
ENDM
const delanim_command ; $fc
-delanim: MACRO
+MACRO delanim
; Removes the object from the screen, as opposed to `endanim` which just stops all motion
db delanim_command
ENDM
diff --git a/macros/scripts/maps.asm b/macros/scripts/maps.asm
index bae8fd07..5c1a8ad5 100644
--- a/macros/scripts/maps.asm
+++ b/macros/scripts/maps.asm
@@ -1,7 +1,7 @@
-def_object_events: MACRO
-REDEF _NUM_OBJECT_EVENTS EQUS "_NUM_OBJECT_EVENTS_\@"
+MACRO def_object_events
+ REDEF _NUM_OBJECT_EVENTS EQUS "_NUM_OBJECT_EVENTS_\@"
db {_NUM_OBJECT_EVENTS}
-{_NUM_OBJECT_EVENTS} = 0
+ DEF {_NUM_OBJECT_EVENTS} = 0
ENDM
;\1 x position
@@ -13,7 +13,7 @@ ENDM
;\7 items only: item id
;\7 trainers only: trainer class/pokemon id
;\8 trainers only: trainer number/pokemon level
-object_event: MACRO
+MACRO object_event
db \3
db \2 + 4
db \1 + 4
@@ -29,42 +29,42 @@ object_event: MACRO
ELSE
db \6
ENDC
-{_NUM_OBJECT_EVENTS} += 1
+ DEF {_NUM_OBJECT_EVENTS} += 1
ENDM
-def_warp_events: MACRO
-REDEF _NUM_WARP_EVENTS EQUS "_NUM_WARP_EVENTS_\@"
+MACRO def_warp_events
+ REDEF _NUM_WARP_EVENTS EQUS "_NUM_WARP_EVENTS_\@"
db {_NUM_WARP_EVENTS}
-{_NUM_WARP_EVENTS} = 0
+ DEF {_NUM_WARP_EVENTS} = 0
ENDM
;\1 x position
;\2 y position
;\3 destination map (-1 = wLastMap)
;\4 destination warp id; starts at 1 (internally at 0)
-warp_event: MACRO
+MACRO warp_event
db \2, \1, \4 - 1, \3
-_WARP_{d:{_NUM_WARP_EVENTS}}_X = \1
-_WARP_{d:{_NUM_WARP_EVENTS}}_Y = \2
-{_NUM_WARP_EVENTS} += 1
+ DEF _WARP_{d:{_NUM_WARP_EVENTS}}_X = \1
+ DEF _WARP_{d:{_NUM_WARP_EVENTS}}_Y = \2
+ DEF {_NUM_WARP_EVENTS} += 1
ENDM
-def_bg_events: MACRO
-REDEF _NUM_BG_EVENTS EQUS "_NUM_BG_EVENTS_\@"
+MACRO def_bg_events
+ REDEF _NUM_BG_EVENTS EQUS "_NUM_BG_EVENTS_\@"
db {_NUM_BG_EVENTS}
-{_NUM_BG_EVENTS} = 0
+ DEF {_NUM_BG_EVENTS} = 0
ENDM
;\1 x position
;\2 y position
;\3 sign id
-bg_event: MACRO
+MACRO bg_event
db \2, \1, \3
-{_NUM_BG_EVENTS} += 1
+ DEF {_NUM_BG_EVENTS} += 1
ENDM
;\1 source map
-def_warps_to: MACRO
+MACRO def_warps_to
FOR n, _NUM_WARP_EVENTS
warp_to _WARP_{d:n}_X, _WARP_{d:n}_Y, \1_WIDTH
ENDR
@@ -73,18 +73,18 @@ ENDM
;\1 x position
;\2 y position
;\3 map width
-warp_to: MACRO
+MACRO warp_to
event_displacement \3, \1, \2
ENDM
;\1 first bit offset / first object id
-def_trainers: MACRO
-IF _NARG == 1
-CURRENT_TRAINER_BIT = \1
-ELSE
-CURRENT_TRAINER_BIT = 1
-ENDC
+MACRO def_trainers
+ IF _NARG == 1
+ DEF CURRENT_TRAINER_BIT = \1
+ ELSE
+ DEF CURRENT_TRAINER_BIT = 1
+ ENDC
ENDM
;\1 event flag
@@ -92,22 +92,22 @@ ENDM
;\3 TextBeforeBattle
;\4 TextAfterBattle
;\5 TextEndBattle
-trainer: MACRO
-_ev_bit = \1 % 8
-_cur_bit = CURRENT_TRAINER_BIT % 8
+MACRO trainer
+ DEF _ev_bit = \1 % 8
+ DEF _cur_bit = CURRENT_TRAINER_BIT % 8
ASSERT _ev_bit == _cur_bit, \
"Expected \1 to be bit {d:_cur_bit}, got {d:_ev_bit}"
db CURRENT_TRAINER_BIT
db \2 << 4
dw wEventFlags + (\1 - CURRENT_TRAINER_BIT) / 8
dw \3, \5, \4, \4
-CURRENT_TRAINER_BIT += 1
+ DEF CURRENT_TRAINER_BIT += 1
ENDM
;\1 x position
;\2 y position
;\3 movement data
-map_coord_movement: MACRO
+MACRO map_coord_movement
dbmapcoord \1, \2
dw \3
ENDM
@@ -117,10 +117,10 @@ ENDM
;\2 map id
;\3 tileset
;\4 connections: combo of NORTH, SOUTH, WEST, and/or EAST, or 0 for none
-map_header: MACRO
-CURRENT_MAP_WIDTH = \2_WIDTH
-CURRENT_MAP_HEIGHT = \2_HEIGHT
-CURRENT_MAP_OBJECT EQUS "\1_Object"
+MACRO map_header
+ DEF CURRENT_MAP_WIDTH = \2_WIDTH
+ DEF CURRENT_MAP_HEIGHT = \2_HEIGHT
+ DEF CURRENT_MAP_OBJECT EQUS "\1_Object"
\1_h::
db \3
db CURRENT_MAP_HEIGHT, CURRENT_MAP_WIDTH
@@ -131,7 +131,7 @@ CURRENT_MAP_OBJECT EQUS "\1_Object"
ENDM
; Comes after map_header and connection macros
-end_map_header: MACRO
+MACRO end_map_header
dw {CURRENT_MAP_OBJECT}
PURGE CURRENT_MAP_WIDTH, CURRENT_MAP_HEIGHT, CURRENT_MAP_OBJECT
ENDM
@@ -142,63 +142,63 @@ ENDM
;\3 map id
;\4 offset of the target map relative to the current map
; (x offset for east/west, y offset for north/south)
-connection: MACRO
+MACRO connection
-; Calculate tile offsets for source (current) and target maps
-_src = 0
-_tgt = (\4) + 3
-IF _tgt < 2
-_src = -_tgt
-_tgt = 0
-ENDC
+ ; Calculate tile offsets for source (current) and target maps
+ DEF _src = 0
+ DEF _tgt = (\4) + 3
+ IF _tgt < 2
+ DEF _src = -_tgt
+ DEF _tgt = 0
+ ENDC
-IF !STRCMP("\1", "north")
-_blk = \3_WIDTH * (\3_HEIGHT - 3) + _src
-_map = _tgt
-_win = (\3_WIDTH + 6) * \3_HEIGHT + 1
-_y = \3_HEIGHT * 2 - 1
-_x = (\4) * -2
-_len = CURRENT_MAP_WIDTH + 3 - (\4)
-IF _len > \3_WIDTH
-_len = \3_WIDTH
-ENDC
+ IF !STRCMP("\1", "north")
+ DEF _blk = \3_WIDTH * (\3_HEIGHT - 3) + _src
+ DEF _map = _tgt
+ DEF _win = (\3_WIDTH + 6) * \3_HEIGHT + 1
+ DEF _y = \3_HEIGHT * 2 - 1
+ DEF _x = (\4) * -2
+ DEF _len = CURRENT_MAP_WIDTH + 3 - (\4)
+ IF _len > \3_WIDTH
+ DEF _len = \3_WIDTH
+ ENDC
-ELIF !STRCMP("\1", "south")
-_blk = _src
-_map = (CURRENT_MAP_WIDTH + 6) * (CURRENT_MAP_HEIGHT + 3) + _tgt
-_win = \3_WIDTH + 7
-_y = 0
-_x = (\4) * -2
-_len = CURRENT_MAP_WIDTH + 3 - (\4)
-IF _len > \3_WIDTH
-_len = \3_WIDTH
-ENDC
+ ELIF !STRCMP("\1", "south")
+ DEF _blk = _src
+ DEF _map = (CURRENT_MAP_WIDTH + 6) * (CURRENT_MAP_HEIGHT + 3) + _tgt
+ DEF _win = \3_WIDTH + 7
+ DEF _y = 0
+ DEF _x = (\4) * -2
+ DEF _len = CURRENT_MAP_WIDTH + 3 - (\4)
+ IF _len > \3_WIDTH
+ DEF _len = \3_WIDTH
+ ENDC
-ELIF !STRCMP("\1", "west")
-_blk = (\3_WIDTH * _src) + \3_WIDTH - 3
-_map = (CURRENT_MAP_WIDTH + 6) * _tgt
-_win = (\3_WIDTH + 6) * 2 - 6
-_y = (\4) * -2
-_x = \3_WIDTH * 2 - 1
-_len = CURRENT_MAP_HEIGHT + 3 - (\4)
-IF _len > \3_HEIGHT
-_len = \3_HEIGHT
-ENDC
+ ELIF !STRCMP("\1", "west")
+ DEF _blk = (\3_WIDTH * _src) + \3_WIDTH - 3
+ DEF _map = (CURRENT_MAP_WIDTH + 6) * _tgt
+ DEF _win = (\3_WIDTH + 6) * 2 - 6
+ DEF _y = (\4) * -2
+ DEF _x = \3_WIDTH * 2 - 1
+ DEF _len = CURRENT_MAP_HEIGHT + 3 - (\4)
+ IF _len > \3_HEIGHT
+ DEF _len = \3_HEIGHT
+ ENDC
-ELIF !STRCMP("\1", "east")
-_blk = (\3_WIDTH * _src)
-_map = (CURRENT_MAP_WIDTH + 6) * _tgt + CURRENT_MAP_WIDTH + 3
-_win = \3_WIDTH + 7
-_y = (\4) * -2
-_x = 0
-_len = CURRENT_MAP_HEIGHT + 3 - (\4)
-IF _len > \3_HEIGHT
-_len = \3_HEIGHT
-ENDC
+ ELIF !STRCMP("\1", "east")
+ DEF _blk = (\3_WIDTH * _src)
+ DEF _map = (CURRENT_MAP_WIDTH + 6) * _tgt + CURRENT_MAP_WIDTH + 3
+ DEF _win = \3_WIDTH + 7
+ DEF _y = (\4) * -2
+ DEF _x = 0
+ DEF _len = CURRENT_MAP_HEIGHT + 3 - (\4)
+ IF _len > \3_HEIGHT
+ DEF _len = \3_HEIGHT
+ ENDC
-ELSE
-fail "Invalid direction for 'connection'."
-ENDC
+ ELSE
+ fail "Invalid direction for 'connection'."
+ ENDC
db \3
dw \2_Blocks + _blk
diff --git a/macros/scripts/text.asm b/macros/scripts/text.asm
index 38e56b77..aad42452 100644
--- a/macros/scripts/text.asm
+++ b/macros/scripts/text.asm
@@ -1,44 +1,44 @@
-text EQUS "db TX_START," ; Start writing text.
-next EQUS "db \"<NEXT>\"," ; Move a line down.
-line EQUS "db \"<LINE>\"," ; Start writing at the bottom line.
-para EQUS "db \"<PARA>\"," ; Start a new paragraph.
-cont EQUS "db \"<CONT>\"," ; Scroll to the next line.
-done EQUS "db \"<DONE>\"" ; End a text box.
-prompt EQUS "db \"<PROMPT>\"" ; Prompt the player to end a text box (initiating some other event).
+DEF text EQUS "db TX_START," ; Start writing text.
+DEF next EQUS "db \"<NEXT>\"," ; Move a line down.
+DEF line EQUS "db \"<LINE>\"," ; Start writing at the bottom line.
+DEF para EQUS "db \"<PARA>\"," ; Start a new paragraph.
+DEF cont EQUS "db \"<CONT>\"," ; Scroll to the next line.
+DEF done EQUS "db \"<DONE>\"" ; End a text box.
+DEF prompt EQUS "db \"<PROMPT>\"" ; Prompt the player to end a text box (initiating some other event).
-page EQUS "db \"<PAGE>\"," ; Start a new Pokédex page.
-dex EQUS "db \"<DEXEND>\", \"@\"" ; End a Pokédex entry.
+DEF page EQUS "db \"<PAGE>\"," ; Start a new Pokédex page.
+DEF dex EQUS "db \"<DEXEND>\", \"@\"" ; End a Pokédex entry.
; TextCommandJumpTable indexes (see home/text.asm)
const_def
const TX_START ; $00
-text_start: MACRO
+MACRO text_start
db TX_START
ENDM
const TX_RAM ; $01
-text_ram: MACRO
+MACRO text_ram
db TX_RAM
dw \1 ; address to read from
ENDM
const TX_BCD ; $02
-text_bcd: MACRO
+MACRO text_bcd
db TX_BCD
dw \1 ; address to read from
db \2 ; number of bytes + print flags
ENDM
const TX_MOVE ; $03
-text_move: MACRO
+MACRO text_move
db TX_MOVE
dw \1 ; address of the new location
ENDM
const TX_BOX ; $04
-text_box: MACRO
+MACRO text_box
; draw box
db TX_BOX
dw \1 ; address of upper left corner
@@ -46,27 +46,27 @@ text_box: MACRO
ENDM
const TX_LOW ; $05
-text_low: MACRO
+MACRO text_low
db TX_LOW
ENDM
const TX_PROMPT_BUTTON ; $06
-text_promptbutton: MACRO
+MACRO text_promptbutton
db TX_PROMPT_BUTTON
ENDM
const TX_SCROLL ; $07
-text_scroll: MACRO
+MACRO text_scroll
db TX_SCROLL
ENDM
const TX_START_ASM ; $08
-text_asm: MACRO
+MACRO text_asm
db TX_START_ASM
ENDM
const TX_NUM ; $09
-text_decimal: MACRO
+MACRO text_decimal
; print a big-endian decimal number.
db TX_NUM
dw \1 ; address to read from
@@ -74,76 +74,76 @@ text_decimal: MACRO
ENDM
const TX_PAUSE ; $0a
-text_pause: MACRO
+MACRO text_pause
db TX_PAUSE
ENDM
const TX_SOUND_GET_ITEM_1 ; $0b
-sound_get_item_1: MACRO
+MACRO sound_get_item_1
db TX_SOUND_GET_ITEM_1
ENDM
-TX_SOUND_LEVEL_UP EQU TX_SOUND_GET_ITEM_1
-sound_level_up EQUS "sound_get_item_1"
+DEF TX_SOUND_LEVEL_UP EQU TX_SOUND_GET_ITEM_1
+DEF sound_level_up EQUS "sound_get_item_1"
const TX_DOTS ; $0c
-text_dots: MACRO
+MACRO text_dots
db TX_DOTS
db \1 ; number of ellipses to draw
ENDM
const TX_WAIT_BUTTON ; $0d
-text_waitbutton: MACRO
+MACRO text_waitbutton
db TX_WAIT_BUTTON
ENDM
const TX_SOUND_POKEDEX_RATING ; $0e
-sound_pokedex_rating: MACRO
+MACRO sound_pokedex_rating
db TX_SOUND_POKEDEX_RATING
ENDM
const TX_SOUND_GET_ITEM_1_DUPLICATE ; $0f
-sound_get_item_1_duplicate: MACRO
+MACRO sound_get_item_1_duplicate
db TX_SOUND_GET_ITEM_1_DUPLICATE
ENDM
const TX_SOUND_GET_ITEM_2 ; $10
-sound_get_item_2: MACRO
+MACRO sound_get_item_2
db TX_SOUND_GET_ITEM_2
ENDM
const TX_SOUND_GET_KEY_ITEM ; $11
-sound_get_key_item: MACRO
+MACRO sound_get_key_item
db TX_SOUND_GET_KEY_ITEM
ENDM
const TX_SOUND_CAUGHT_MON ; $12
-sound_caught_mon: MACRO
+MACRO sound_caught_mon
db TX_SOUND_CAUGHT_MON
ENDM
const TX_SOUND_DEX_PAGE_ADDED ; $13
-sound_dex_page_added: MACRO
+MACRO sound_dex_page_added
db TX_SOUND_DEX_PAGE_ADDED
ENDM
const TX_SOUND_CRY_PIKACHU ; $14
-sound_cry_pikachu: MACRO
+MACRO sound_cry_pikachu
db TX_SOUND_CRY_PIKACHU
ENDM
const TX_SOUND_CRY_PIDGEOT ; $15
-sound_cry_pidgeot: MACRO
+MACRO sound_cry_pidgeot
db TX_SOUND_CRY_PIDGEOT
ENDM
const TX_SOUND_CRY_DEWGONG ; $16
-sound_cry_dewgong: MACRO
+MACRO sound_cry_dewgong
db TX_SOUND_CRY_DEWGONG
ENDM
const TX_FAR ; $17
-text_far: MACRO
+MACRO text_far
db TX_FAR
dab \1 ; address of text commands
ENDM
@@ -152,7 +152,7 @@ ENDM
const_next $50
const TX_END ; $50
-text_end: MACRO
+MACRO text_end
db TX_END
ENDM
@@ -161,12 +161,12 @@ ENDM
const_def -1, -1
const TX_SCRIPT_POKECENTER_NURSE ; $ff
-script_pokecenter_nurse: MACRO
+MACRO script_pokecenter_nurse
db TX_SCRIPT_POKECENTER_NURSE
ENDM
const TX_SCRIPT_MART ; $fe
-script_mart: MACRO
+MACRO script_mart
db TX_SCRIPT_MART
db _NARG ; number of items
IF _NARG
@@ -176,12 +176,12 @@ script_mart: MACRO
ENDM
const TX_SCRIPT_BILLS_PC ; $fd
-script_bills_pc: MACRO
+MACRO script_bills_pc
db TX_SCRIPT_BILLS_PC
ENDM
const TX_SCRIPT_PLAYERS_PC ; $fc
-script_players_pc: MACRO
+MACRO script_players_pc
db TX_SCRIPT_PLAYERS_PC
ENDM
@@ -190,23 +190,23 @@ ENDM
const_skip ; $fa
const TX_SCRIPT_POKECENTER_PC ; $f9
-script_pokecenter_pc: MACRO
+MACRO script_pokecenter_pc
db TX_SCRIPT_POKECENTER_PC
ENDM
const_skip ; $f8
const TX_SCRIPT_PRIZE_VENDOR ; $f7
-script_prize_vendor: MACRO
+MACRO script_prize_vendor
db TX_SCRIPT_PRIZE_VENDOR
ENDM
const TX_SCRIPT_CABLE_CLUB_RECEPTIONIST ; $f6
-script_cable_club_receptionist: MACRO
+MACRO script_cable_club_receptionist
db TX_SCRIPT_CABLE_CLUB_RECEPTIONIST
ENDM
const TX_SCRIPT_VENDING_MACHINE ; $f5
-script_vending_machine: MACRO
+MACRO script_vending_machine
db TX_SCRIPT_VENDING_MACHINE
ENDM
diff --git a/macros/vc.asm b/macros/vc.asm
index 2fbdf9d6..3b33e844 100644
--- a/macros/vc.asm
+++ b/macros/vc.asm
@@ -1,27 +1,27 @@
-vc_hook: MACRO
-IF DEF(_YELLOW_VC)
-.VC_\1::
-ENDC
+MACRO vc_hook
+ IF DEF(_YELLOW_VC)
+ .VC_\1::
+ ENDC
ENDM
-vc_patch: MACRO
-IF DEF(_YELLOW_VC)
- ASSERT !DEF(CURRENT_VC_PATCH), "Already started a vc_patch"
-CURRENT_VC_PATCH EQUS "\1"
-.VC_{CURRENT_VC_PATCH}::
-ENDC
+MACRO vc_patch
+ IF DEF(_YELLOW_VC)
+ ASSERT !DEF(CURRENT_VC_PATCH), "Already started a vc_patch"
+ DEF CURRENT_VC_PATCH EQUS "\1"
+ .VC_{CURRENT_VC_PATCH}::
+ ENDC
ENDM
-vc_patch_end: MACRO
-IF DEF(_YELLOW_VC)
- ASSERT DEF(CURRENT_VC_PATCH), "No vc_patch started"
-.VC_{CURRENT_VC_PATCH}_End::
- PURGE CURRENT_VC_PATCH
-ENDC
+MACRO vc_patch_end
+ IF DEF(_YELLOW_VC)
+ ASSERT DEF(CURRENT_VC_PATCH), "No vc_patch started"
+ .VC_{CURRENT_VC_PATCH}_End::
+ PURGE CURRENT_VC_PATCH
+ ENDC
ENDM
-vc_assert: MACRO
-IF DEF(_YELLOW_VC)
- ASSERT \#
-ENDC
+MACRO vc_assert
+ IF DEF(_YELLOW_VC)
+ ASSERT \#
+ ENDC
ENDM
diff --git a/macros/wram.asm b/macros/wram.asm
index be89dad6..f45708a3 100644
--- a/macros/wram.asm
+++ b/macros/wram.asm
@@ -1,12 +1,12 @@
; Used in wram.asm
-flag_array: MACRO
+MACRO flag_array
ds ((\1) + 7) / 8
ENDM
-BOX_STRUCT_LENGTH EQU 25 + NUM_MOVES * 2
+DEF BOX_STRUCT_LENGTH EQU 25 + NUM_MOVES * 2
-box_struct: MACRO
+MACRO box_struct
\1Species:: db
\1HP:: dw
\1BoxLevel:: db
@@ -27,7 +27,7 @@ box_struct: MACRO
\1PP:: ds NUM_MOVES
ENDM
-party_struct: MACRO
+MACRO party_struct
box_struct \1
\1Level:: db
\1Stats::
@@ -38,7 +38,7 @@ party_struct: MACRO
\1Special:: dw
ENDM
-battle_struct: MACRO
+MACRO battle_struct
\1Species:: db
\1HP:: dw
\1PartyPos::
@@ -60,7 +60,7 @@ battle_struct: MACRO
\1PP:: ds NUM_MOVES
ENDM
-spritestatedata1: MACRO
+MACRO spritestatedata1
\1PictureID:: db
\1MovementStatus:: db
\1ImageIndex:: db
@@ -78,7 +78,7 @@ spritestatedata1: MACRO
\1End::
ENDM
-spritestatedata2: MACRO
+MACRO spritestatedata2
\1WalkAnimationCounter:: db
ds 1
\1YDisplacement:: db
@@ -96,14 +96,14 @@ spritestatedata2: MACRO
\1End::
ENDM
-sprite_oam_struct: MACRO
+MACRO sprite_oam_struct
\1YCoord:: db
\1XCoord:: db
\1TileID:: db
\1Attributes:: db
ENDM
-map_connection_struct: MACRO
+MACRO map_connection_struct
\1ConnectedMap:: db
\1ConnectionStripSrc:: dw
\1ConnectionStripDest:: dw
@@ -114,7 +114,7 @@ map_connection_struct: MACRO
\1ConnectedMapViewPointer:: dw
ENDM
-animated_object: MACRO
+MACRO animated_object
\1Index:: db
\1FramesetID:: db
\1AnimSeqID:: db