Use constant in wram for hidden item flags (#445)

Prevents defining more hidden items than the flag array has room for
This commit is contained in:
Vortyne 2024-05-05 10:56:08 -04:00 committed by GitHub
parent d870ad6ea8
commit 5f7b444ae8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 15 additions and 2 deletions

View file

@ -215,3 +215,6 @@ DEF NUM_TM_HM EQU NUM_TMS + NUM_HMS
; These fit in 7 bytes, with one unused bit left over.
DEF __tmhm_value__ = NUM_TM_HM + 1
DEF UNUSED_TMNUM EQU __tmhm_value__
DEF MAX_HIDDEN_ITEMS EQU 112
DEF MAX_HIDDEN_COINS EQU 16

View file

@ -3,6 +3,7 @@ MACRO hidden_coin
ENDM
HiddenCoinCoords:
table_width 3, HiddenCoinCoords
; map id, x, y
hidden_coin GAME_CORNER, 0, 8
hidden_coin GAME_CORNER, 1, 16
@ -16,4 +17,5 @@ HiddenCoinCoords:
hidden_coin GAME_CORNER, 11, 7
hidden_coin GAME_CORNER, 15, 8
hidden_coin GAME_CORNER, 12, 15
assert_max_table_length MAX_HIDDEN_COINS
db -1 ; end

View file

@ -3,6 +3,7 @@ MACRO hidden_item
ENDM
HiddenItemCoords:
table_width 3, HiddenItemCoords
; map id, x, y
hidden_item VIRIDIAN_FOREST, 1, 18
hidden_item VIRIDIAN_FOREST, 16, 42
@ -58,4 +59,5 @@ HiddenItemCoords:
hidden_item VERMILION_CITY, 14, 11
hidden_item CERULEAN_CITY, 15, 8
hidden_item ROUTE_4, 40, 3
assert_max_table_length MAX_HIDDEN_ITEMS
db -1 ; end

View file

@ -16,6 +16,12 @@ MACRO assert_table_length
"{CURRENT_TABLE_START}: expected {d:x} entries, each {d:CURRENT_TABLE_WIDTH} bytes"
ENDM
MACRO assert_max_table_length
DEF x = \1
ASSERT x * CURRENT_TABLE_WIDTH >= @ - {CURRENT_TABLE_START}, \
"{CURRENT_TABLE_START}: expected a maximum of {d:x} entries, each {d:CURRENT_TABLE_WIDTH} bytes"
ENDM
MACRO list_start
DEF list_index = 0
IF _NARG == 1

View file

@ -2042,9 +2042,9 @@ wGameProgressFlagsEnd::
ds 56
wObtainedHiddenItemsFlags:: flag_array 112
wObtainedHiddenItemsFlags:: flag_array MAX_HIDDEN_ITEMS
wObtainedHiddenCoinsFlags:: flag_array 16
wObtainedHiddenCoinsFlags:: flag_array MAX_HIDDEN_COINS
; $00 = walking
; $01 = biking