diff options
| author | Rangi42 <sylvie.oukaour+rangi42@gmail.com> | 2025-07-02 18:32:31 -0400 |
|---|---|---|
| committer | Rangi42 <sylvie.oukaour+rangi42@gmail.com> | 2025-07-02 18:32:31 -0400 |
| commit | 3f4b3ee96fe9c2f0d13c89be5be98fa31213c35c (patch) | |
| tree | bc97e2a390d9b233dab565f2b0cb66f2bef7223c | |
| parent | Define `MAX_WARP_EVENTS` (diff) | |
| download | pokeyellow-3f4b3ee96fe9c2f0d13c89be5be98fa31213c35c.tar.gz pokeyellow-3f4b3ee96fe9c2f0d13c89be5be98fa31213c35c.tar.xz pokeyellow-3f4b3ee96fe9c2f0d13c89be5be98fa31213c35c.zip | |
Check limits for warp, bg, and object events
| -rw-r--r-- | constants/map_data_constants.asm | 6 | ||||
| -rw-r--r-- | macros/scripts/maps.asm | 8 | ||||
| -rw-r--r-- | ram/wram.asm | 12 |
3 files changed, 18 insertions, 8 deletions
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 |
