diff options
author | Rangi <remy.oukaour+rangi42@gmail.com> | 2021-03-23 09:57:48 -0400 |
---|---|---|
committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2021-03-23 09:57:48 -0400 |
commit | bc59bad170a8d1ff908199587f26a3da59603c08 (patch) | |
tree | 6fe699f9f084424b5d08106aa1edcbad91956be9 /macros | |
parent | b2332f27f01ce98d521e4a0c0df6199bb7a6ada3 (diff) |
Verify uneven list sizes with list_start, li, and assert_list_length macros
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 306fc4c3..04c039ec 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) |