diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2021-03-22 17:15:21 -0400 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2021-03-22 17:17:08 -0400 |
commit | 94057c7726995b0da484a39c22497876b7c22997 (patch) | |
tree | 4eb89c1047a1aea1806b52763f05ba2846be0676 /macros | |
parent | dbe2360ecd3eb11fd144168427e1323f5e1b2ec2 (diff) |
Verify uneven list sizes with list_start, li, and assert_list_length macros
This was discussed in #815
Diffstat (limited to 'macros')
-rw-r--r-- | macros/asserts.asm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/macros/asserts.asm b/macros/asserts.asm index 306fc4c34..04c039ecc 100644 --- a/macros/asserts.asm +++ b/macros/asserts.asm @@ -19,6 +19,31 @@ x = \1 "{CURRENT_TABLE_START}: expected {d:x} entries, each {d:CURRENT_TABLE_WIDTH} bytes" ENDM +list_start: MACRO +list_index = 0 +if DEF(CURRENT_LIST_START) +PURGE CURRENT_LIST_START +endc +if _NARG == 1 +CURRENT_LIST_START EQUS "\1" +else +CURRENT_LIST_START EQUS "._list_start\@" +CURRENT_LIST_START: +endc +ENDM + +li: MACRO + assert !STRIN(\1, "@"), STRCAT("String terminator \"@\" in list entry: ", \1) + db \1, "@" +list_index = list_index + 1 +ENDM + +assert_list_length: MACRO +x = \1 + assert x == list_index, \ + "{CURRENT_LIST_START}: expected {d:x} entries, got {d:list_index}" +ENDM + def_grass_wildmons: MACRO ;\1: map id if DEF(CURRENT_GRASS_WILDMONS_MAP) |