summaryrefslogtreecommitdiff
path: root/macros/scripts
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2020-10-26 22:24:47 -0400
committerRangi <remy.oukaour+rangi42@gmail.com>2020-10-26 22:24:47 -0400
commit676f2f12e3e7990dcc49e3ea391f10aae8131639 (patch)
tree0411091966fe7a6b5a64f27aa828df015bb84362 /macros/scripts
parent46f6cc4d41494c044f1091491c712afc2a5bfd3a (diff)
Use more assertions to ensure correct code and data
Diffstat (limited to 'macros/scripts')
-rw-r--r--macros/scripts/audio.asm5
-rw-r--r--macros/scripts/battle_anims.asm4
-rw-r--r--macros/scripts/maps.asm2
3 files changed, 8 insertions, 3 deletions
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