Check limits for warp, bg, and object events

This commit is contained in:
Rangi42 2025-07-02 18:32:31 -04:00
parent aa85c0046d
commit 3f4b3ee96f
3 changed files with 18 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -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