From aa85c0046d06b306d99e3b48460782ac04814975 Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Wed, 2 Jul 2025 17:25:03 -0400 Subject: Define `MAX_WARP_EVENTS` --- macros/scripts/maps.asm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'macros/scripts/maps.asm') diff --git a/macros/scripts/maps.asm b/macros/scripts/maps.asm index 2837d0c0..63b41424 100644 --- a/macros/scripts/maps.asm +++ b/macros/scripts/maps.asm @@ -84,6 +84,8 @@ MACRO def_warps_to FOR n, {_NUM_WARP_EVENTS} warp_to _WARP_{d:n}_X, _WARP_{d:n}_Y, \1_WIDTH ENDR + ASSERT {_NUM_WARP_EVENTS} <= MAX_WARP_EVENTS, \ + "Too many warp_events (above {d:MAX_WARP_EVENTS})!" ENDM ;\1 x position -- cgit v1.3.1-sl0p From 3f4b3ee96fe9c2f0d13c89be5be98fa31213c35c Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Wed, 2 Jul 2025 18:32:31 -0400 Subject: Check limits for warp, bg, and object events --- constants/map_data_constants.asm | 6 ++++++ macros/scripts/maps.asm | 8 ++++++-- ram/wram.asm | 12 ++++++------ 3 files changed, 18 insertions(+), 8 deletions(-) (limited to 'macros/scripts/maps.asm') diff --git a/constants/map_data_constants.asm b/constants/map_data_constants.asm index 9d816a6a..32a56518 100644 --- a/constants/map_data_constants.asm +++ b/constants/map_data_constants.asm @@ -19,6 +19,12 @@ DEF MAP_BORDER EQU 3 ; wWarpEntries DEF MAX_WARP_EVENTS EQU 32 +; wNumSigns +DEF MAX_BG_EVENTS EQU 16 + +; wMapSpriteData +DEF MAX_OBJECT_EVENTS EQU 16 + ; flower and water tile animations const_def const TILEANIM_NONE ; 0 diff --git a/macros/scripts/maps.asm b/macros/scripts/maps.asm index 63b41424..49150c6e 100644 --- a/macros/scripts/maps.asm +++ b/macros/scripts/maps.asm @@ -72,6 +72,12 @@ ENDM ;\1 source map MACRO def_warps_to + ASSERT {_NUM_WARP_EVENTS} <= MAX_WARP_EVENTS, \ + "Too many warp_events (above {d:MAX_WARP_EVENTS})!" + ASSERT {_NUM_BG_EVENTS} <= MAX_BG_EVENTS, \ + "Too many bg_events (above {d:MAX_BG_EVENTS})!" + ASSERT {_NUM_OBJECT_EVENTS} <= MAX_OBJECT_EVENTS, \ + "Too many object_events (above {d:MAX_OBJECT_EVENTS})!" ; text ID values are significant (see DisplayTextID in home/text_scripts.asm) FOR n, {_NUM_BG_EVENTS} ASSERT {_BG_EVENT_{d:n}_TEXT_ID} > {_NUM_OBJECT_EVENTS}, \ @@ -84,8 +90,6 @@ MACRO def_warps_to FOR n, {_NUM_WARP_EVENTS} warp_to _WARP_{d:n}_X, _WARP_{d:n}_Y, \1_WIDTH ENDR - ASSERT {_NUM_WARP_EVENTS} <= MAX_WARP_EVENTS, \ - "Too many warp_events (above {d:MAX_WARP_EVENTS})!" ENDM ;\1 x position diff --git a/ram/wram.asm b/ram/wram.asm index 4e3e6411..504eb646 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -1826,13 +1826,13 @@ wDestinationWarpID:: db ds 128 -; number of signs in the current map (up to 16) +; number of signs in the current map (up to MAX_BG_EVENTS) wNumSigns:: db -wSignCoords:: ds 16 * 2 ; Y, X -wSignTextIDs:: ds 16 +wSignCoords:: ds MAX_BG_EVENTS * 2 ; Y, X +wSignTextIDs:: ds MAX_BG_EVENTS -; number of sprites on the current map (up to 16) +; number of sprites on the current map (up to MAX_OBJECT_EVENTS) wNumSprites:: db ; these two variables track the X and Y offset in blocks from the last special warp used @@ -1840,8 +1840,8 @@ wNumSprites:: db wYOffsetSinceLastSpecialWarp:: db wXOffsetSinceLastSpecialWarp:: db -wMapSpriteData:: ds 16 * 2 ; movement byte 2, text ID -wMapSpriteExtraData:: ds 16 * 2 ; trainer class/item ID, trainer set ID +wMapSpriteData:: ds MAX_OBJECT_EVENTS * 2 ; movement byte 2, text ID +wMapSpriteExtraData:: ds MAX_OBJECT_EVENTS * 2 ; trainer class/item ID, trainer set ID ; map height in 2x2 meta-tiles wCurrentMapHeight2:: db -- cgit v1.3.1-sl0p