summaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
Diffstat (limited to 'macros')
-rw-r--r--macros/code.asm1
-rw-r--r--macros/data.asm4
-rw-r--r--macros/gfx.asm8
-rw-r--r--macros/scripts/audio.asm5
-rw-r--r--macros/scripts/battle_anims.asm4
-rw-r--r--macros/scripts/maps.asm2
-rw-r--r--macros/wram.asm1
7 files changed, 21 insertions, 4 deletions
diff --git a/macros/code.asm b/macros/code.asm
index e393d495..a5d8c756 100644
--- a/macros/code.asm
+++ b/macros/code.asm
@@ -38,6 +38,7 @@ maskbits: MACRO
; maskbits 26
; cp 26
; jr nc, .loop
+ assert 0 < (\1) && (\1) <= $100, "bitmask must be 8-bit"
x = 1
rept 8
if x + 1 < (\1)
diff --git a/macros/data.asm b/macros/data.asm
index b6cedbf7..a2b1f23c 100644
--- a/macros/data.asm
+++ b/macros/data.asm
@@ -25,6 +25,10 @@ percent EQUS "* $ff / 100"
; e.g. 1 out_of 2 == 50 percent + 1 == $80
out_of EQUS "* $100 /"
+assert_power_of_2: MACRO
+ assert (\1) & ((\1) - 1) == 0, "\1 must be a power of 2"
+ENDM
+
; Constant data (db, dw, dl) macros
dwb: MACRO
diff --git a/macros/gfx.asm b/macros/gfx.asm
index 2c67cfc8..b42b1440 100644
--- a/macros/gfx.asm
+++ b/macros/gfx.asm
@@ -1,5 +1,13 @@
+assert_valid_rgb: MACRO
+rept _NARG
+ assert 0 <= (\1) && (\1) <= 31, "RGB channel must be 0-31"
+ shift
+endr
+ENDM
+
RGB: MACRO
rept _NARG / 3
+ assert_valid_rgb \1, \2, \3
dw palred (\1) + palgreen (\2) + palblue (\3)
shift 3
endr
diff --git a/macros/scripts/audio.asm b/macros/scripts/audio.asm
index 2776c293..127f2d1e 100644
--- a/macros/scripts/audio.asm
+++ b/macros/scripts/audio.asm
@@ -1,8 +1,12 @@
channel_count: MACRO
+ assert 0 < (\1) && (\1) <= NUM_MUSIC_CHANS, \
+ "channel_count must be 1-{d:NUM_MUSIC_CHANS}"
_num_channels = \1 - 1
ENDM
channel: MACRO
+ assert 0 < (\1) && (\1) <= NUM_CHANNELS, \
+ "channel id must be 1-{d:NUM_CHANNELS}"
dn (_num_channels << 2), \1 - 1 ; channel id
dw \2 ; address
_num_channels = 0
@@ -46,6 +50,7 @@ FIRST_MUSIC_CMD EQU const_value
const octave_cmd ; $d0
octave: MACRO
+ assert 0 < (\1) && (\1) < 8, "octave must be 1-8"
db octave_cmd | 8 - (\1) ; octave
ENDM
diff --git a/macros/scripts/battle_anims.asm b/macros/scripts/battle_anims.asm
index 123a262a..a6ebe431 100644
--- a/macros/scripts/battle_anims.asm
+++ b/macros/scripts/battle_anims.asm
@@ -1,7 +1,5 @@
anim_wait: MACRO
-if \1 >= $d0
- fail "anim_wait argument must be less than $d0."
-endc
+ assert (\1) < $d0, "anim_wait argument must be less than $d0"
db \1
ENDM
diff --git a/macros/scripts/maps.asm b/macros/scripts/maps.asm
index d9ffd83e..a30e0c06 100644
--- a/macros/scripts/maps.asm
+++ b/macros/scripts/maps.asm
@@ -1,5 +1,7 @@
map_id: MACRO
;\1: map id
+ assert DEF(GROUP_\1) && DEF(MAP_\1), \
+ "Missing 'map_const \1' in constants/map_constants.asm"
db GROUP_\1, MAP_\1
ENDM
diff --git a/macros/wram.asm b/macros/wram.asm
index a2aa71df..b514bbde 100644
--- a/macros/wram.asm
+++ b/macros/wram.asm
@@ -77,7 +77,6 @@ battle_struct: MACRO
\1Species:: db
\1Item:: db
\1Moves:: ds NUM_MOVES
-\1MovesEnd::
\1DVs:: dw
\1PP:: ds NUM_MOVES
\1Happiness:: db