Skip to content

Commit 3f4b3ee

Browse files
committed
Check limits for warp, bg, and object events
1 parent aa85c00 commit 3f4b3ee

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

constants/map_data_constants.asm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ DEF MAP_BORDER EQU 3
1919
; wWarpEntries
2020
DEF MAX_WARP_EVENTS EQU 32
2121

22+
; wNumSigns
23+
DEF MAX_BG_EVENTS EQU 16
24+
25+
; wMapSpriteData
26+
DEF MAX_OBJECT_EVENTS EQU 16
27+
2228
; flower and water tile animations
2329
const_def
2430
const TILEANIM_NONE ; 0

macros/scripts/maps.asm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ ENDM
7272

7373
;\1 source map
7474
MACRO def_warps_to
75+
ASSERT {_NUM_WARP_EVENTS} <= MAX_WARP_EVENTS, \
76+
"Too many warp_events (above {d:MAX_WARP_EVENTS})!"
77+
ASSERT {_NUM_BG_EVENTS} <= MAX_BG_EVENTS, \
78+
"Too many bg_events (above {d:MAX_BG_EVENTS})!"
79+
ASSERT {_NUM_OBJECT_EVENTS} <= MAX_OBJECT_EVENTS, \
80+
"Too many object_events (above {d:MAX_OBJECT_EVENTS})!"
7581
; text ID values are significant (see DisplayTextID in home/text_scripts.asm)
7682
FOR n, {_NUM_BG_EVENTS}
7783
ASSERT {_BG_EVENT_{d:n}_TEXT_ID} > {_NUM_OBJECT_EVENTS}, \
@@ -84,8 +90,6 @@ MACRO def_warps_to
8490
FOR n, {_NUM_WARP_EVENTS}
8591
warp_to _WARP_{d:n}_X, _WARP_{d:n}_Y, \1_WIDTH
8692
ENDR
87-
ASSERT {_NUM_WARP_EVENTS} <= MAX_WARP_EVENTS, \
88-
"Too many warp_events (above {d:MAX_WARP_EVENTS})!"
8993
ENDM
9094

9195
;\1 x position

ram/wram.asm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,22 +1826,22 @@ wDestinationWarpID:: db
18261826

18271827
ds 128
18281828

1829-
; number of signs in the current map (up to 16)
1829+
; number of signs in the current map (up to MAX_BG_EVENTS)
18301830
wNumSigns:: db
18311831

1832-
wSignCoords:: ds 16 * 2 ; Y, X
1833-
wSignTextIDs:: ds 16
1832+
wSignCoords:: ds MAX_BG_EVENTS * 2 ; Y, X
1833+
wSignTextIDs:: ds MAX_BG_EVENTS
18341834

1835-
; number of sprites on the current map (up to 16)
1835+
; number of sprites on the current map (up to MAX_OBJECT_EVENTS)
18361836
wNumSprites:: db
18371837

18381838
; these two variables track the X and Y offset in blocks from the last special warp used
18391839
; they don't seem to be used for anything
18401840
wYOffsetSinceLastSpecialWarp:: db
18411841
wXOffsetSinceLastSpecialWarp:: db
18421842

1843-
wMapSpriteData:: ds 16 * 2 ; movement byte 2, text ID
1844-
wMapSpriteExtraData:: ds 16 * 2 ; trainer class/item ID, trainer set ID
1843+
wMapSpriteData:: ds MAX_OBJECT_EVENTS * 2 ; movement byte 2, text ID
1844+
wMapSpriteExtraData:: ds MAX_OBJECT_EVENTS * 2 ; trainer class/item ID, trainer set ID
18451845

18461846
; map height in 2x2 meta-tiles
18471847
wCurrentMapHeight2:: db

0 commit comments

Comments
 (0)