diff options
author | Remy Oukaour <remy.oukaour@gmail.com> | 2017-12-23 00:31:04 -0500 |
---|---|---|
committer | Remy Oukaour <remy.oukaour@gmail.com> | 2017-12-23 00:31:04 -0500 |
commit | aa97752efeef1425a0e0a00059f4a44569c917fc (patch) | |
tree | 5c3318a90425a347546c1aa6e63db3ea810928d1 | |
parent | daa071451d998e7cf460468870ca82498a5eb4af (diff) |
Move NUM_BUENA_PRIZES to event/buena.asm (still hard-coded)
Buena_PrizeMenu has "rept NUM_BUENA_PRIZES", which needs NUM_BUENA_PRIZES to be already defined. BuenaPrizeItems and BuenaPrizeItemsEnd are needed to define NUM_BUENA_PRIZES; but BuenaPrizeItems is defined after Buena_PrizeMenu. I don't see a way to avoid hard-coding its value of 9.
Contrast that with the NUM_MOM_ITEMS constants, which are not used as "rept" arguments and so can be defined within their code file.
-rw-r--r-- | constants/radio_constants.asm | 3 | ||||
-rw-r--r-- | data/items/buena_prizes.asm | 3 | ||||
-rw-r--r-- | event/buena.asm | 2 | ||||
-rwxr-xr-x | event/mom_phone.asm | 9 |
4 files changed, 10 insertions, 7 deletions
diff --git a/constants/radio_constants.asm b/constants/radio_constants.asm index 4e9d94434..86817081e 100644 --- a/constants/radio_constants.asm +++ b/constants/radio_constants.asm @@ -123,6 +123,3 @@ NUM_PASSWORDS_PER_CATEGORY EQU 3 const BUENA_ITEM const BUENA_MOVE const BUENA_STRING - -; BuenaPrizeItems table length (see data/items/buena_prizes.asm) -NUM_BUENA_PRIZES EQU 9 diff --git a/data/items/buena_prizes.asm b/data/items/buena_prizes.asm index 34a3bd524..8aecf2bd0 100644 --- a/data/items/buena_prizes.asm +++ b/data/items/buena_prizes.asm @@ -1,5 +1,5 @@ BuenaPrizeItems: ; 8b15e -; there are NUM_BUENA_PRIZES entries +; there are NUM_BUENA_PRIZES items (see event/buena.asm) db ULTRA_BALL, 2 db FULL_RESTORE, 2 db NUGGET, 3 @@ -9,4 +9,5 @@ BuenaPrizeItems: ; 8b15e db CARBOS, 5 db CALCIUM, 5 db HP_UP, 5 +BuenaPrizeItemsEnd: ; 8b170 diff --git a/event/buena.asm b/event/buena.asm index fa54cc3de..2cb3b5a63 100644 --- a/event/buena.asm +++ b/event/buena.asm @@ -288,6 +288,8 @@ Buena_PrizeMenu: ; 8b0e2 dba .prizepoints ; 8b129 +NUM_BUENA_PRIZES EQU 9 ; ((BuenaPrizeItemsEnd - BuenaPrizeItems) / 2) + .indices ; 8b129 db NUM_BUENA_PRIZES x = 1 diff --git a/event/mom_phone.asm b/event/mom_phone.asm index 58ecad02a..aab4abe4b 100755 --- a/event/mom_phone.asm +++ b/event/mom_phone.asm @@ -1,3 +1,6 @@ +NUM_MOM_ITEMS_1 EQUS "((MomItems_1End - MomItems_1) / 8)" +NUM_MOM_ITEMS_2 EQUS "((MomItems_2End - MomItems_2) / 8)" + const_value = 1 const MOM_ITEM const MOM_DOLL @@ -57,7 +60,7 @@ MomTriesToBuySomething:: ; fcfec CheckBalance_MomItem2: ; fd044 ld a, [wWhichMomItem] - cp 10 + cp NUM_MOM_ITEMS_2 jr nc, .nope call GetItemFromMom ld a, [hli] @@ -100,7 +103,7 @@ CheckBalance_MomItem2: ; fd044 .exact call .AddMoney - ld a, 5 + ld a, NUM_MOM_ITEMS_1 call RandomRange inc a ld [wWhichMomItemSet], a @@ -195,7 +198,7 @@ GetItemFromMom: ; fd117 .zero ld a, [wWhichMomItem] - cp 10 ; length of MomItems_2 + cp NUM_MOM_ITEMS_2 jr c, .ok xor a |