2021-03-04 03:22:41 +00:00
|
|
|
; Macros to verify assumptions about the data or code
|
|
|
|
|
2022-06-06 21:25:42 +00:00
|
|
|
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
|
2021-03-04 03:22:41 +00:00
|
|
|
ENDM
|
|
|
|
|
2022-06-06 21:25:42 +00:00
|
|
|
MACRO assert_table_length
|
|
|
|
DEF x = \1
|
2021-04-19 20:31:37 +00:00
|
|
|
assert x * CURRENT_TABLE_WIDTH == @ - {CURRENT_TABLE_START}, \
|
2021-03-04 03:22:41 +00:00
|
|
|
"{CURRENT_TABLE_START}: expected {d:x} entries, each {d:CURRENT_TABLE_WIDTH} bytes"
|
|
|
|
ENDM
|
2021-03-04 22:58:30 +00:00
|
|
|
|
2022-06-06 21:25:42 +00:00
|
|
|
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
|
2021-03-22 21:15:21 +00:00
|
|
|
ENDM
|
|
|
|
|
2022-06-06 21:25:42 +00:00
|
|
|
MACRO li
|
2021-03-22 21:15:21 +00:00
|
|
|
assert !STRIN(\1, "@"), STRCAT("String terminator \"@\" in list entry: ", \1)
|
|
|
|
db \1, "@"
|
2022-06-06 21:25:42 +00:00
|
|
|
DEF list_index += 1
|
2021-03-22 21:15:21 +00:00
|
|
|
ENDM
|
|
|
|
|
2022-06-06 21:25:42 +00:00
|
|
|
MACRO assert_list_length
|
|
|
|
DEF x = \1
|
2021-03-22 21:15:21 +00:00
|
|
|
assert x == list_index, \
|
|
|
|
"{CURRENT_LIST_START}: expected {d:x} entries, got {d:list_index}"
|
|
|
|
ENDM
|
|
|
|
|
2022-06-06 21:25:42 +00:00
|
|
|
MACRO def_grass_wildmons
|
2021-03-04 22:58:30 +00:00
|
|
|
;\1: map id
|
2022-06-06 21:25:42 +00:00
|
|
|
REDEF CURRENT_GRASS_WILDMONS_MAP EQUS "\1"
|
|
|
|
REDEF CURRENT_GRASS_WILDMONS_LABEL EQUS "._def_grass_wildmons_\1"
|
2021-04-19 20:31:37 +00:00
|
|
|
{CURRENT_GRASS_WILDMONS_LABEL}:
|
2021-03-04 22:58:30 +00:00
|
|
|
map_id \1
|
|
|
|
ENDM
|
|
|
|
|
2022-06-06 21:25:42 +00:00
|
|
|
MACRO end_grass_wildmons
|
2021-04-19 20:31:37 +00:00
|
|
|
assert GRASS_WILDDATA_LENGTH == @ - {CURRENT_GRASS_WILDMONS_LABEL}, \
|
2021-03-04 22:58:30 +00:00
|
|
|
"def_grass_wildmons {CURRENT_GRASS_WILDMONS_MAP}: expected {d:GRASS_WILDDATA_LENGTH} bytes"
|
|
|
|
ENDM
|
|
|
|
|
2022-06-06 21:25:42 +00:00
|
|
|
MACRO def_water_wildmons
|
2021-03-04 22:58:30 +00:00
|
|
|
;\1: map id
|
2022-06-06 21:25:42 +00:00
|
|
|
REDEF CURRENT_WATER_WILDMONS_MAP EQUS "\1"
|
|
|
|
REDEF CURRENT_WATER_WILDMONS_LABEL EQUS "._def_water_wildmons_\1"
|
2021-04-19 20:31:37 +00:00
|
|
|
{CURRENT_WATER_WILDMONS_LABEL}:
|
2021-03-04 22:58:30 +00:00
|
|
|
map_id \1
|
|
|
|
ENDM
|
|
|
|
|
2022-06-06 21:25:42 +00:00
|
|
|
MACRO end_water_wildmons
|
2021-04-19 20:31:37 +00:00
|
|
|
assert WATER_WILDDATA_LENGTH == @ - {CURRENT_WATER_WILDMONS_LABEL}, \
|
2021-03-04 22:58:30 +00:00
|
|
|
"def_water_wildmons {CURRENT_WATER_WILDMONS_MAP}: expected {d:WATER_WILDDATA_LENGTH} bytes"
|
|
|
|
ENDM
|