From 4b6f988fba9528cf4d8f178a80a3ad3d6c1df9ba Mon Sep 17 00:00:00 2001 From: mzxrules Date: Wed, 18 Dec 2024 03:08:16 -0500 Subject: [PATCH 1/5] Simplify most event flags --- include/z64save.h | 168 ++++++++---------- src/code/z_inventory.c | 2 +- src/code/z_map_exp.c | 4 +- src/code/z_parameter.c | 6 +- src/code/z_sram.c | 17 +- .../ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c | 5 +- .../ovl_Bg_Spot09_Obj/z_bg_spot09_obj.c | 2 +- src/overlays/actors/ovl_En_Daiku/z_en_daiku.c | 4 +- src/overlays/actors/ovl_En_Fr/z_en_fr.c | 20 +-- src/overlays/actors/ovl_En_Ge2/z_en_ge2.c | 2 +- src/overlays/actors/ovl_En_Hy/z_en_hy.c | 6 +- src/overlays/actors/ovl_En_Mu/z_en_mu.c | 6 +- src/overlays/actors/ovl_En_Niw/z_en_niw.c | 7 +- .../actors/ovl_En_Niw_Lady/z_en_niw_lady.c | 21 ++- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 11 +- .../actors/ovl_player_actor/z_player.c | 2 +- .../ovl_kaleido_scope/z_kaleido_equipment.c | 2 +- 17 files changed, 143 insertions(+), 142 deletions(-) diff --git a/include/z64save.h b/include/z64save.h index 30c51eeb023..a1c6cd3ef2a 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -464,6 +464,15 @@ typedef enum LinkAge { * SaveContext.eventChkInf */ +#define GET_EVENTCHKINF(flag) (gSaveContext.save.info.eventChkInf[(flag) >> 4] & (1 << ((flag) & 0xF))) +#define SET_EVENTCHKINF(flag) (gSaveContext.save.info.eventChkInf[(flag) >> 4] |= (1 << ((flag) & 0xF))) +#define CLEAR_EVENTCHKINF(flag) (gSaveContext.save.info.eventChkInf[(flag) >> 4] &= ~(1 << ((flag) & 0xF))) + +#define GET_EVENTCHKINF_MASK(flag) (1 << ((flag) & 0xF)) + +// EVENTCHKINF 0x00-0x0F +#define EVENTCHKINF_00_UNUSED 0x00 // flag is set in the debug save, but has no functionality +#define EVENTCHKINF_01_UNUSED 0x01 // flag is set in the debug save, but has no functionality #define EVENTCHKINF_MIDO_DENIED_DEKU_TREE_ACCESS 0x02 #define EVENTCHKINF_03 0x03 #define EVENTCHKINF_04 0x04 @@ -507,11 +516,9 @@ typedef enum LinkAge { #define EVENTCHKINF_3B 0x3B #define EVENTCHKINF_DEFEATED_NABOORU_KNUCKLE 0x3C -// 0x40 -#define EVENTCHKINF_40_INDEX 4 -#define EVENTCHKINF_40_SHIFT 0 -#define EVENTCHKINF_40_MASK (1 << EVENTCHKINF_40_SHIFT) -#define EVENTCHKINF_40 ((EVENTCHKINF_40_INDEX << 4) | EVENTCHKINF_40_SHIFT) +// EVENTCHKINF 0x40 +#define EVENTCHKINF_INDEX_40 (EVENTCHKINF_40 >> 4) +#define EVENTCHKINF_40 0x40 #define EVENTCHKINF_41 0x41 #define EVENTCHKINF_42 0x42 @@ -540,11 +547,9 @@ typedef enum LinkAge { #define EVENTCHKINF_RESTORED_LAKE_HYLIA 0x69 #define EVENTCHKINF_TALON_WOKEN_IN_KAKARIKO 0x6A -// 0x6B -#define EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO_INDEX 6 -#define EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO_SHIFT 11 -#define EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO_MASK (1 << EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO_SHIFT) -#define EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO ((EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO_INDEX << 4) | EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO_SHIFT) +// EVENTCHKINF 0x6B +#define EVENTCHKINF_INDEX_TALON_RETURNED_FROM_KAKARIKO (EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO >> 4) +#define EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO 0x6B #define EVENTCHKINF_6E 0x6E #define EVENTCHKINF_6F 0x6F @@ -564,19 +569,19 @@ typedef enum LinkAge { #define EVENTCHKINF_PAID_BACK_SPOOKY_MASK 0x8E #define EVENTCHKINF_PAID_BACK_BUNNY_HOOD 0x8F -// 0x90-0x93 +// EVENTCHKINF 0x90-0x93 // carpenters freed from the gerudo -#define EVENTCHKINF_CARPENTERS_FREE_INDEX 9 +#define EVENTCHKINF_INDEX_CARPENTERS_FREE 9 #define EVENTCHKINF_CARPENTERS_FREE_SHIFT(n) (0 + (n)) #define EVENTCHKINF_CARPENTERS_FREE_MASK(n) (1 << EVENTCHKINF_CARPENTERS_FREE_SHIFT(n)) -#define EVENTCHKINF_CARPENTERS_FREE(n) ((EVENTCHKINF_CARPENTERS_FREE_INDEX << 4) | EVENTCHKINF_CARPENTERS_FREE_SHIFT(n)) +#define EVENTCHKINF_CARPENTERS_FREE(n) ((EVENTCHKINF_INDEX_CARPENTERS_FREE << 4) | EVENTCHKINF_CARPENTERS_FREE_SHIFT(n)) #define EVENTCHKINF_CARPENTERS_FREE_MASK_ALL (\ EVENTCHKINF_CARPENTERS_FREE_MASK(0) \ | EVENTCHKINF_CARPENTERS_FREE_MASK(1) \ | EVENTCHKINF_CARPENTERS_FREE_MASK(2) \ | EVENTCHKINF_CARPENTERS_FREE_MASK(3) ) #define GET_EVENTCHKINF_CARPENTERS_FREE_ALL() \ - CHECK_FLAG_ALL(gSaveContext.save.info.eventChkInf[EVENTCHKINF_CARPENTERS_FREE_INDEX], EVENTCHKINF_CARPENTERS_FREE_MASK_ALL) + CHECK_FLAG_ALL(gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_CARPENTERS_FREE], EVENTCHKINF_CARPENTERS_FREE_MASK_ALL) #define EVENTCHKINF_94 0x94 #define EVENTCHKINF_95 0x95 @@ -620,48 +625,34 @@ typedef enum LinkAge { #define EVENTCHKINF_C8 0xC8 #define EVENTCHKINF_C9 0xC9 -// 0xD0-0xD6 -#define EVENTCHKINF_SONGS_FOR_FROGS_INDEX 13 -#define EVENTCHKINF_SONGS_FOR_FROGS_CHOIR_SHIFT 0 -#define EVENTCHKINF_SONGS_FOR_FROGS_ZL_SHIFT 1 -#define EVENTCHKINF_SONGS_FOR_FROGS_EPONA_SHIFT 2 -#define EVENTCHKINF_SONGS_FOR_FROGS_SUNS_SHIFT 3 -#define EVENTCHKINF_SONGS_FOR_FROGS_SARIA_SHIFT 4 -#define EVENTCHKINF_SONGS_FOR_FROGS_SOT_SHIFT 5 -#define EVENTCHKINF_SONGS_FOR_FROGS_STORMS_SHIFT 6 -#define EVENTCHKINF_SONGS_FOR_FROGS_CHOIR_MASK (1 << EVENTCHKINF_SONGS_FOR_FROGS_CHOIR_SHIFT) -#define EVENTCHKINF_SONGS_FOR_FROGS_ZL_MASK (1 << EVENTCHKINF_SONGS_FOR_FROGS_ZL_SHIFT) -#define EVENTCHKINF_SONGS_FOR_FROGS_EPONA_MASK (1 << EVENTCHKINF_SONGS_FOR_FROGS_EPONA_SHIFT) -#define EVENTCHKINF_SONGS_FOR_FROGS_SUNS_MASK (1 << EVENTCHKINF_SONGS_FOR_FROGS_SUNS_SHIFT) -#define EVENTCHKINF_SONGS_FOR_FROGS_SARIA_MASK (1 << EVENTCHKINF_SONGS_FOR_FROGS_SARIA_SHIFT) -#define EVENTCHKINF_SONGS_FOR_FROGS_SOT_MASK (1 << EVENTCHKINF_SONGS_FOR_FROGS_SOT_SHIFT) -#define EVENTCHKINF_SONGS_FOR_FROGS_STORMS_MASK (1 << EVENTCHKINF_SONGS_FOR_FROGS_STORMS_SHIFT) -#define EVENTCHKINF_SONGS_FOR_FROGS_CHOIR ((EVENTCHKINF_SONGS_FOR_FROGS_INDEX << 4) | EVENTCHKINF_SONGS_FOR_FROGS_CHOIR_SHIFT) -#define EVENTCHKINF_SONGS_FOR_FROGS_ZL ((EVENTCHKINF_SONGS_FOR_FROGS_INDEX << 4) | EVENTCHKINF_SONGS_FOR_FROGS_ZL_SHIFT) -#define EVENTCHKINF_SONGS_FOR_FROGS_EPONA ((EVENTCHKINF_SONGS_FOR_FROGS_INDEX << 4) | EVENTCHKINF_SONGS_FOR_FROGS_EPONA_SHIFT) -#define EVENTCHKINF_SONGS_FOR_FROGS_SUNS ((EVENTCHKINF_SONGS_FOR_FROGS_INDEX << 4) | EVENTCHKINF_SONGS_FOR_FROGS_SUNS_SHIFT) -#define EVENTCHKINF_SONGS_FOR_FROGS_SARIA ((EVENTCHKINF_SONGS_FOR_FROGS_INDEX << 4) | EVENTCHKINF_SONGS_FOR_FROGS_SARIA_SHIFT) -#define EVENTCHKINF_SONGS_FOR_FROGS_SOT ((EVENTCHKINF_SONGS_FOR_FROGS_INDEX << 4) | EVENTCHKINF_SONGS_FOR_FROGS_SOT_SHIFT) -#define EVENTCHKINF_SONGS_FOR_FROGS_STORMS ((EVENTCHKINF_SONGS_FOR_FROGS_INDEX << 4) | EVENTCHKINF_SONGS_FOR_FROGS_STORMS_SHIFT) - -// 0xDA-0xDE -#define EVENTCHKINF_DA_DB_DC_DD_DE_INDEX 13 -#define EVENTCHKINF_DA_MASK (1 << 10) -#define EVENTCHKINF_DB_MASK (1 << 11) -#define EVENTCHKINF_DC_MASK (1 << 12) -#define EVENTCHKINF_DD_MASK (1 << 13) -#define EVENTCHKINF_DE_MASK (1 << 14) - - -#define GET_EVENTCHKINF(flag) (gSaveContext.save.info.eventChkInf[(flag) >> 4] & (1 << ((flag) & 0xF))) -#define SET_EVENTCHKINF(flag) (gSaveContext.save.info.eventChkInf[(flag) >> 4] |= (1 << ((flag) & 0xF))) -#define CLEAR_EVENTCHKINF(flag) (gSaveContext.save.info.eventChkInf[(flag) >> 4] &= ~(1 << ((flag) & 0xF))) +// EVENTCHKINF 0xD0-0xD6 +#define EVENTCHKINF_INDEX_SONGS_FOR_FROGS (EVENTCHKINF_SONGS_FOR_FROGS_CHOIR >> 4) +#define EVENTCHKINF_SONGS_FOR_FROGS_CHOIR 0xD0 +#define EVENTCHKINF_SONGS_FOR_FROGS_ZL 0xD1 +#define EVENTCHKINF_SONGS_FOR_FROGS_EPONA 0xD2 +#define EVENTCHKINF_SONGS_FOR_FROGS_SUNS 0xD3 +#define EVENTCHKINF_SONGS_FOR_FROGS_SARIA 0xD4 +#define EVENTCHKINF_SONGS_FOR_FROGS_SOT 0xD5 +#define EVENTCHKINF_SONGS_FOR_FROGS_STORMS 0xD6 + +// EVENTCHKINF 0xDA-0xDE +#define EVENTCHKINF_INDEX_DA_DB_DC_DD_DE (EVENTCHKINF_DA >> 4) +#define EVENTCHKINF_DA 0xDA +#define EVENTCHKINF_DB 0xDB +#define EVENTCHKINF_DC 0xDC +#define EVENTCHKINF_DD 0xDD +#define EVENTCHKINF_DE 0xDE /* * SaveContext.itemGetInf */ +#define GET_ITEMGETINF(flag) (gSaveContext.save.info.itemGetInf[(flag) >> 4] & (1 << ((flag) & 0xF))) +#define SET_ITEMGETINF(flag) (gSaveContext.save.info.itemGetInf[(flag) >> 4] |= (1 << ((flag) & 0xF))) + +#define GET_ITEMGETINF_MASK(flag) (1 << ((flag) & 0xF)) + #define ITEMGETINF_TALON_BOTTLE 0x02 #define ITEMGETINF_03 0x03 #define ITEMGETINF_04 0x04 @@ -684,17 +675,11 @@ typedef enum LinkAge { #define ITEMGETINF_16 0x16 #define ITEMGETINF_17 0x17 -// 0x18-0x1A -#define ITEMGETINF_18_19_1A_INDEX 1 -#define ITEMGETINF_18_SHIFT 8 -#define ITEMGETINF_19_SHIFT 9 -#define ITEMGETINF_1A_SHIFT 10 -#define ITEMGETINF_18_MASK (1 << ITEMGETINF_18_SHIFT) -#define ITEMGETINF_19_MASK (1 << ITEMGETINF_19_SHIFT) -#define ITEMGETINF_1A_MASK (1 << ITEMGETINF_1A_SHIFT) -#define ITEMGETINF_18 ((ITEMGETINF_18_19_1A_INDEX << 4) | ITEMGETINF_18_SHIFT) -#define ITEMGETINF_19 ((ITEMGETINF_18_19_1A_INDEX << 4) | ITEMGETINF_19_SHIFT) -#define ITEMGETINF_1A ((ITEMGETINF_18_19_1A_INDEX << 4) | ITEMGETINF_1A_SHIFT) +// ITEMGETINF 0x18-0x1A +#define ITEMGETINF_INDEX_18_19_1A 1 +#define ITEMGETINF_18 0x18 +#define ITEMGETINF_19 0x19 +#define ITEMGETINF_1A 0x1A #define ITEMGETINF_1B 0x1B #define ITEMGETINF_1C 0x1C @@ -720,14 +705,16 @@ typedef enum LinkAge { #define ITEMGETINF_3F 0x3F -#define GET_ITEMGETINF(flag) (gSaveContext.save.info.itemGetInf[(flag) >> 4] & (1 << ((flag) & 0xF))) -#define SET_ITEMGETINF(flag) (gSaveContext.save.info.itemGetInf[(flag) >> 4] |= (1 << ((flag) & 0xF))) - - /* * SaveContext.infTable */ +#define GET_INFTABLE(flag) (gSaveContext.save.info.infTable[(flag) >> 4] & (1 << ((flag) & 0xF))) +#define SET_INFTABLE(flag) (gSaveContext.save.info.infTable[(flag) >> 4] |= (1 << ((flag) & 0xF))) +#define CLEAR_INFTABLE(flag) (gSaveContext.save.info.infTable[(flag) >> 4] &= ~(1 << ((flag) & 0xF))) + +#define GET_INFTABLE_MASK(flag) (1 << ((flag) & 0xF)) + #define INFTABLE_00 0x00 #define INFTABLE_01 0x01 #define INFTABLE_03 0x03 @@ -855,18 +842,18 @@ typedef enum LinkAge { #define INFTABLE_197 0x197 #define INFTABLE_198 0x198 -// 0x199-0x19F -#define INFTABLE_199_19A_19B_19C_19D_19E_19F_INDEX 25 -#define INFTABLE_199_MASK (1 << 9) -#define INFTABLE_19A_MASK (1 << 10) -#define INFTABLE_19B_MASK (1 << 11) -#define INFTABLE_19C_MASK (1 << 12) -#define INFTABLE_19D_MASK (1 << 13) -#define INFTABLE_19E_MASK (1 << 14) -#define INFTABLE_19F_MASK (1 << 15) - -// 0x1A0-0x1AF -#define INFTABLE_1AX_INDEX 26 +// INFTABLE 0x199-0x19F +#define INFTABLE_INDEX_199_19A_19B_19C_19D_19E_19F 25 +#define INFTABLE_199 0x199 +#define INFTABLE_19A 0x19A +#define INFTABLE_19B 0x19B +#define INFTABLE_19C 0x19C +#define INFTABLE_19D 0x19D +#define INFTABLE_19E 0x19E +#define INFTABLE_19F 0x19F + +// INFTABLE 0x1A0-0x1AF +#define INFTABLE_INDEX_1AX 26 #define INFTABLE_1A0_SHIFT 0 #define INFTABLE_1A1_SHIFT 1 #define INFTABLE_1A2_SHIFT 2 @@ -880,20 +867,22 @@ typedef enum LinkAge { #define INFTABLE_1AB_SHIFT 11 #define INFTABLE_1AD_SHIFT 13 -// 0x1D0-0x1DF -#define INFTABLE_1DX_INDEX 29 - - -#define GET_INFTABLE(flag) (gSaveContext.save.info.infTable[(flag) >> 4] & (1 << ((flag) & 0xF))) -#define SET_INFTABLE(flag) (gSaveContext.save.info.infTable[(flag) >> 4] |= (1 << ((flag) & 0xF))) -#define CLEAR_INFTABLE(flag) (gSaveContext.save.info.infTable[(flag) >> 4] &= ~(1 << ((flag) & 0xF))) +// INFTABLE 0x1D0-0x1DF +#define INFTABLE_INDEX_1DX (0x1D0 >> 4) +#define INFTABLE_1D0 0x1D0 /* * SaveContext.eventInf */ -// 0x00-0x0F +#define GET_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] & (1 << ((flag) & 0xF))) +#define SET_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] |= (1 << ((flag) & 0xF))) +#define CLEAR_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] &= ~(1 << ((flag) & 0xF))) + +#define GET_EVENTINF_MASK(flag) (1 << ((flag) & 0xF)) + +// EVENTINF 0x00-0x0F // horses related #define EVENTINF_HORSES_INDEX 0 #define EVENTINF_HORSES_STATE_SHIFT 0 @@ -952,8 +941,8 @@ typedef enum EventInfHorsesState { // Is the running man race active #define EVENTINF_MARATHON_ACTIVE 0x10 -// 0x20-0x24 -#define EVENTINF_20_21_22_23_24_INDEX 2 +// EVENTINF 0x20-0x24 +#define EVENTINF_INDEX_20_21_22_23_24 2 #define EVENTINF_20_MASK (1 << 0) #define EVENTINF_21_MASK (1 << 1) #define EVENTINF_22_MASK (1 << 2) @@ -963,11 +952,6 @@ typedef enum EventInfHorsesState { #define EVENTINF_30 0x30 -#define GET_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] & (1 << ((flag) & 0xF))) -#define SET_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] |= (1 << ((flag) & 0xF))) -#define CLEAR_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] &= ~(1 << ((flag) & 0xF))) - - extern SaveContext gSaveContext; #endif diff --git a/src/code/z_inventory.c b/src/code/z_inventory.c index b452a92e16d..2f89c0565be 100644 --- a/src/code/z_inventory.c +++ b/src/code/z_inventory.c @@ -299,7 +299,7 @@ u8 Inventory_DeleteEquipment(PlayState* play, s16 equipment) { if (equipment == EQUIP_TYPE_SWORD) { gSaveContext.save.info.equips.buttonItems[0] = ITEM_NONE; - gSaveContext.save.info.infTable[INFTABLE_1DX_INDEX] = 1; + gSaveContext.save.info.infTable[INFTABLE_INDEX_1DX] = 1; } Player_SetEquipmentData(play, player); diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c index 1c82288b7ad..916add81f20 100644 --- a/src/code/z_map_exp.c +++ b/src/code/z_map_exp.c @@ -496,7 +496,7 @@ void Minimap_Draw(PlayState* play) { (LINK_AGE_IN_YEARS != YEARS_ADULT)) { if ((gMapData->owEntranceFlag[sEntranceIconMapIndex] == 0xFFFF) || ((gMapData->owEntranceFlag[sEntranceIconMapIndex] != 0xFFFF) && - (gSaveContext.save.info.infTable[INFTABLE_1AX_INDEX] & + (gSaveContext.save.info.infTable[INFTABLE_INDEX_1AX] & gBitFlags[gMapData->owEntranceFlag[mapIndex]]))) { gDPLoadTextureBlock(OVERLAY_DISP++, gMapDungeonEntranceIconTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, @@ -513,7 +513,7 @@ void Minimap_Draw(PlayState* play) { } if ((play->sceneId == SCENE_ZORAS_FOUNTAIN) && - (gSaveContext.save.info.infTable[INFTABLE_1AX_INDEX] & gBitFlags[INFTABLE_1A9_SHIFT])) { + (gSaveContext.save.info.infTable[INFTABLE_INDEX_1AX] & gBitFlags[INFTABLE_1A9_SHIFT])) { gDPLoadTextureBlock(OVERLAY_DISP++, gMapDungeonEntranceIconTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 8, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 7666b1ff07f..a0f54a1e787 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -851,7 +851,7 @@ void func_80083108(PlayState* play) { (gSaveContext.save.info.equips.buttonItems[0] == ITEM_BOMBCHU) || (gSaveContext.save.info.equips.buttonItems[0] == ITEM_NONE)) { if ((gSaveContext.save.info.equips.buttonItems[0] != ITEM_NONE) || - (gSaveContext.save.info.infTable[INFTABLE_1DX_INDEX] == 0)) { + (gSaveContext.save.info.infTable[INFTABLE_INDEX_1DX] == 0)) { gSaveContext.save.info.equips.buttonItems[0] = gSaveContext.buttonStatus[0]; sp28 = true; @@ -875,7 +875,7 @@ void func_80083108(PlayState* play) { (gSaveContext.save.info.equips.buttonItems[0] == ITEM_BOMBCHU) || (gSaveContext.save.info.equips.buttonItems[0] == ITEM_NONE)) { if ((gSaveContext.save.info.equips.buttonItems[0] != ITEM_NONE) || - (gSaveContext.save.info.infTable[INFTABLE_1DX_INDEX] == 0)) { + (gSaveContext.save.info.infTable[INFTABLE_INDEX_1DX] == 0)) { gSaveContext.save.info.equips.buttonItems[0] = gSaveContext.buttonStatus[0]; sp28 = true; @@ -1345,7 +1345,7 @@ void func_80084BF4(PlayState* play, u16 flag) { } } else if (gSaveContext.save.info.equips.buttonItems[0] == ITEM_NONE) { if ((gSaveContext.save.info.equips.buttonItems[0] != ITEM_NONE) || - (gSaveContext.save.info.infTable[INFTABLE_1DX_INDEX] == 0)) { + (gSaveContext.save.info.infTable[INFTABLE_INDEX_1DX] == 0)) { gSaveContext.save.info.equips.buttonItems[0] = gSaveContext.buttonStatus[0]; Interface_LoadItemIcon1(play, 0); } diff --git a/src/code/z_sram.c b/src/code/z_sram.c index 0fcee6f0323..595793ad051 100644 --- a/src/code/z_sram.c +++ b/src/code/z_sram.c @@ -162,7 +162,7 @@ void Sram_InitNewSave(void) { gSaveContext.save.info.horseData.pos.z = 5497; gSaveContext.save.info.horseData.angle = -0x6AD9; gSaveContext.save.info.playerData.magicLevel = 0; - gSaveContext.save.info.infTable[INFTABLE_1DX_INDEX] = 1; + gSaveContext.save.info.infTable[INFTABLE_INDEX_1DX] = 1; gSaveContext.save.info.sceneFlags[SCENE_WATER_TEMPLE].swch = 0x40000000; } @@ -325,8 +325,15 @@ void Sram_InitDebugSave(void) { gSaveContext.save.info.horseData.pos.y = 72; gSaveContext.save.info.horseData.pos.z = 5497; gSaveContext.save.info.horseData.angle = -0x6AD9; - gSaveContext.save.info.infTable[0] |= 0x5009; - gSaveContext.save.info.eventChkInf[0] |= 0x123F; + gSaveContext.save.info.infTable[0] |= GET_INFTABLE_MASK(INFTABLE_00) | GET_INFTABLE_MASK(INFTABLE_03) | + GET_INFTABLE_MASK(INFTABLE_0C) | GET_INFTABLE_MASK(INFTABLE_0E); + + gSaveContext.save.info.eventChkInf[0] |= + GET_EVENTCHKINF_MASK(EVENTCHKINF_00_UNUSED) | GET_EVENTCHKINF_MASK(EVENTCHKINF_01_UNUSED) | + GET_EVENTCHKINF_MASK(EVENTCHKINF_MIDO_DENIED_DEKU_TREE_ACCESS) | GET_EVENTCHKINF_MASK(EVENTCHKINF_03) | + GET_EVENTCHKINF_MASK(EVENTCHKINF_04) | GET_EVENTCHKINF_MASK(EVENTCHKINF_05) | + GET_EVENTCHKINF_MASK(EVENTCHKINF_09) | GET_EVENTCHKINF_MASK(EVENTCHKINF_0C); + SET_EVENTCHKINF(EVENTCHKINF_80); SET_EVENTCHKINF(EVENTCHKINF_C4); @@ -498,8 +505,8 @@ void Sram_OpenSave(SramContext* sramCtx) { // if zelda cutscene has been watched but lullaby was not obtained, restore cutscene and take away letter if (GET_EVENTCHKINF(EVENTCHKINF_40) && !CHECK_QUEST_ITEM(QUEST_SONG_LULLABY)) { - i = gSaveContext.save.info.eventChkInf[EVENTCHKINF_40_INDEX] & ~EVENTCHKINF_40_MASK; - gSaveContext.save.info.eventChkInf[EVENTCHKINF_40_INDEX] = i; + i = gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_40] & ~GET_EVENTCHKINF_MASK(EVENTCHKINF_40); + gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_40] = i; INV_CONTENT(ITEM_ZELDAS_LETTER) = ITEM_CHICKEN; diff --git a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c index 9ec48c5084e..249a079c471 100644 --- a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c +++ b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c @@ -696,7 +696,8 @@ static s16 sDemoEffectLightColors[] = { DEMO_EFFECT_LIGHT_GREEN, DEMO_EFFECT_LIG static s16 sExItemTypes[] = { EXITEM_MAGIC_WIND, EXITEM_MAGIC_FIRE, EXITEM_MAGIC_DARK }; -static s16 sItemGetFlags[] = { ITEMGETINF_18_MASK, ITEMGETINF_19_MASK, ITEMGETINF_1A_MASK }; +static s16 sItemGetFlagMasks[] = { GET_ITEMGETINF_MASK(ITEMGETINF_18), GET_ITEMGETINF_MASK(ITEMGETINF_19), + GET_ITEMGETINF_MASK(ITEMGETINF_1A) }; static u8 sItemIds[] = { ITEM_FARORES_WIND, ITEM_DINS_FIRE, ITEM_NAYRUS_LOVE }; @@ -808,7 +809,7 @@ void BgDyYoseizo_Give_Reward(BgDyYoseizo* this, PlayState* play) { this->itemSpawned = true; gSaveContext.healthAccumulator = 0x140; Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_HEARTS_MAGIC); - gSaveContext.save.info.itemGetInf[ITEMGETINF_18_19_1A_INDEX] |= sItemGetFlags[cueIdTemp]; + gSaveContext.save.info.itemGetInf[ITEMGETINF_INDEX_18_19_1A] |= sItemGetFlagMasks[cueIdTemp]; Item_Give(play, sItemIds[cueIdTemp]); } } else { diff --git a/src/overlays/actors/ovl_Bg_Spot09_Obj/z_bg_spot09_obj.c b/src/overlays/actors/ovl_Bg_Spot09_Obj/z_bg_spot09_obj.c index 2839607d855..23bfb153fd5 100644 --- a/src/overlays/actors/ovl_Bg_Spot09_Obj/z_bg_spot09_obj.c +++ b/src/overlays/actors/ovl_Bg_Spot09_Obj/z_bg_spot09_obj.c @@ -138,7 +138,7 @@ void BgSpot09Obj_Init(Actor* thisx, PlayState* play) { BgSpot09Obj* this = (BgSpot09Obj*)thisx; PRINTF("Spot09 Object [arg_data : 0x%04x](大工救出フラグ 0x%x)\n", this->dyna.actor.params, - gSaveContext.save.info.eventChkInf[EVENTCHKINF_CARPENTERS_FREE_INDEX] & + gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_CARPENTERS_FREE] & EVENTCHKINF_CARPENTERS_FREE_MASK_ALL); this->dyna.actor.params &= 0xFF; if ((this->dyna.actor.params < 0) || (this->dyna.actor.params >= 5)) { diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c index 2fac588608b..f106e270c29 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -270,7 +270,7 @@ void EnDaiku_UpdateText(EnDaiku* this, PlayState* play) { if (this->stateFlags & ENDAIKU_STATEFLAG_GERUDODEFEATED) { freedCount = 0; for (carpenterType = 0; carpenterType < 4; carpenterType++) { - if (gSaveContext.save.info.eventChkInf[EVENTCHKINF_CARPENTERS_FREE_INDEX] & + if (gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_CARPENTERS_FREE] & EVENTCHKINF_CARPENTERS_FREE_MASK(carpenterType)) { freedCount++; } @@ -399,7 +399,7 @@ void EnDaiku_InitEscape(EnDaiku* this, PlayState* play) { EnDaiku_ChangeAnim(this, ENDAIKU_ANIM_RUN, &this->currentAnimIndex); this->stateFlags &= ~(ENDAIKU_STATEFLAG_1 | ENDAIKU_STATEFLAG_2); - gSaveContext.save.info.eventChkInf[EVENTCHKINF_CARPENTERS_FREE_INDEX] |= + gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_CARPENTERS_FREE] |= EVENTCHKINF_CARPENTERS_FREE_MASK(PARAMS_GET_U(this->actor.params, 0, 2)); this->actor.gravity = -1.0f; diff --git a/src/overlays/actors/ovl_En_Fr/z_en_fr.c b/src/overlays/actors/ovl_En_Fr/z_en_fr.c index b683415f800..38053a8f238 100644 --- a/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ b/src/overlays/actors/ovl_En_Fr/z_en_fr.c @@ -108,22 +108,22 @@ static EnFrPointers sEnFrPointers = { }; #define FROG_HAS_SONG_BEEN_PLAYED(frogSongIndex) \ - (gSaveContext.save.info.eventChkInf[EVENTCHKINF_SONGS_FOR_FROGS_INDEX] & \ + (gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_SONGS_FOR_FROGS] & \ sFrogSongIndexToEventChkInfSongsForFrogsMask[frogSongIndex]) #define FROG_SET_SONG_PLAYED(frogSongIndex) \ - gSaveContext.save.info.eventChkInf[EVENTCHKINF_SONGS_FOR_FROGS_INDEX] |= \ + gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_SONGS_FOR_FROGS] |= \ sFrogSongIndexToEventChkInfSongsForFrogsMask[frogSongIndex]; static u16 sFrogSongIndexToEventChkInfSongsForFrogsMask[] = { - EVENTCHKINF_SONGS_FOR_FROGS_ZL_MASK, // FROG_ZL - EVENTCHKINF_SONGS_FOR_FROGS_EPONA_MASK, // FROG_EPONA - EVENTCHKINF_SONGS_FOR_FROGS_SARIA_MASK, // FROG_SARIA - EVENTCHKINF_SONGS_FOR_FROGS_SUNS_MASK, // FROG_SUNS - EVENTCHKINF_SONGS_FOR_FROGS_SOT_MASK, // FROG_SOT - EVENTCHKINF_SONGS_FOR_FROGS_STORMS_MASK, // FROG_STORMS - EVENTCHKINF_SONGS_FOR_FROGS_CHOIR_MASK, // FROG_CHOIR_SONG - 0, // FROG_NO_SONG + GET_EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_ZL), // FROG_ZL + GET_EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_EPONA), // FROG_EPONA + GET_EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_SARIA), // FROG_SARIA + GET_EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_SUNS), // FROG_SUNS + GET_EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_SOT), // FROG_SOT + GET_EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_STORMS), // FROG_STORMS + GET_EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_CHOIR), // FROG_CHOIR_SONG + 0, // FROG_NO_SONG }; static u8 sFrogToFrogSongIndex[] = { diff --git a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c index 5bdefc80f7a..4fce54f436f 100644 --- a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c +++ b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c @@ -224,7 +224,7 @@ s32 Ge2_DetectPlayerInUpdate(PlayState* play, EnGe2* this, Vec3f* pos, s16 yRot, } s32 EnGe2_CheckCarpentersFreed(void) { - if (CHECK_FLAG_ALL(gSaveContext.save.info.eventChkInf[EVENTCHKINF_CARPENTERS_FREE_INDEX] & + if (CHECK_FLAG_ALL(gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_CARPENTERS_FREE] & (EVENTCHKINF_CARPENTERS_FREE_MASK_ALL | 0xF0), EVENTCHKINF_CARPENTERS_FREE_MASK_ALL)) { return 1; diff --git a/src/overlays/actors/ovl_En_Hy/z_en_hy.c b/src/overlays/actors/ovl_En_Hy/z_en_hy.c index 10af2a5899e..30a68ba012d 100644 --- a/src/overlays/actors/ovl_En_Hy/z_en_hy.c +++ b/src/overlays/actors/ovl_En_Hy/z_en_hy.c @@ -605,7 +605,7 @@ u16 EnHy_GetTextId(PlayState* play, Actor* thisx) { switch (ENHY_GET_TYPE(&this->actor)) { case ENHY_TYPE_DOG_LADY: if (play->sceneId == SCENE_KAKARIKO_CENTER_GUEST_HOUSE) { - return (this->talonEventChkInf & EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO_MASK) + return (this->talonEventChkInf & GET_EVENTCHKINF_MASK(EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO)) ? 0x508D : (GET_INFTABLE(INFTABLE_CB) ? 0x508C : 0x508B); } else if (play->sceneId == SCENE_MARKET_DAY) { @@ -738,7 +738,7 @@ u16 EnHy_GetTextId(PlayState* play, Actor* thisx) { if (!LINK_IS_ADULT) { return GET_EVENTCHKINF(EVENTCHKINF_80) ? 0x505F : (GET_INFTABLE(INFTABLE_163) ? 0x505E : 0x505D); } else { - return (this->talonEventChkInf & EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO_MASK) + return (this->talonEventChkInf & GET_EVENTCHKINF_MASK(EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO)) ? 0x5062 : (GET_INFTABLE(INFTABLE_164) ? 0x5061 : 0x5060); } @@ -1165,7 +1165,7 @@ void EnHy_WaitForObjects(EnHy* this, PlayState* play) { } if (play->sceneId == SCENE_KAKARIKO_CENTER_GUEST_HOUSE) { - this->talonEventChkInf = gSaveContext.save.info.eventChkInf[EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO_INDEX]; + this->talonEventChkInf = gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_TALON_RETURNED_FROM_KAKARIKO]; } EnHy_InitSetProperties(this); diff --git a/src/overlays/actors/ovl_En_Mu/z_en_mu.c b/src/overlays/actors/ovl_En_Mu/z_en_mu.c index 01c3788df9a..dbe5e1b15c8 100644 --- a/src/overlays/actors/ovl_En_Mu/z_en_mu.c +++ b/src/overlays/actors/ovl_En_Mu/z_en_mu.c @@ -64,9 +64,9 @@ void EnMu_Interact(EnMu* this, PlayState* play) { s32 randomIndex; s32 i; - textFlags = gSaveContext.eventInf[EVENTINF_20_21_22_23_24_INDEX] & + textFlags = gSaveContext.eventInf[EVENTINF_INDEX_20_21_22_23_24] & (EVENTINF_20_MASK | EVENTINF_21_MASK | EVENTINF_22_MASK | EVENTINF_23_MASK | EVENTINF_24_MASK); - gSaveContext.eventInf[EVENTINF_20_21_22_23_24_INDEX] &= + gSaveContext.eventInf[EVENTINF_INDEX_20_21_22_23_24] &= ~(EVENTINF_20_MASK | EVENTINF_21_MASK | EVENTINF_22_MASK | EVENTINF_23_MASK | EVENTINF_24_MASK); randomIndex = (play->state.frames + (s32)(Rand_ZeroOne() * 5.0f)) % 5; @@ -95,7 +95,7 @@ void EnMu_Interact(EnMu* this, PlayState* play) { textFlags |= bitmask[randomIndex]; this->defaultTextId = textIdOffset[randomIndex] | 0x7000; textFlags &= EVENTINF_20_MASK | EVENTINF_21_MASK | EVENTINF_22_MASK | EVENTINF_23_MASK | EVENTINF_24_MASK | 0xE0; - gSaveContext.eventInf[EVENTINF_20_21_22_23_24_INDEX] |= textFlags; + gSaveContext.eventInf[EVENTINF_INDEX_20_21_22_23_24] |= textFlags; } u16 EnMu_GetTextId(PlayState* play, Actor* thisx) { diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index 88ec34a0961..3f846eba8ac 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -66,8 +66,9 @@ static Vec3f sKakarikoPosList[] = { }; static s16 sKakarikoFlagList[] = { - INFTABLE_199_MASK, INFTABLE_19A_MASK, INFTABLE_19B_MASK, INFTABLE_19C_MASK, - INFTABLE_19D_MASK, INFTABLE_19E_MASK, INFTABLE_19F_MASK, + GET_INFTABLE_MASK(INFTABLE_199), GET_INFTABLE_MASK(INFTABLE_19A), GET_INFTABLE_MASK(INFTABLE_19B), + GET_INFTABLE_MASK(INFTABLE_19C), GET_INFTABLE_MASK(INFTABLE_19D), GET_INFTABLE_MASK(INFTABLE_19E), + GET_INFTABLE_MASK(INFTABLE_19F), }; static u8 sLowerRiverSpawned = false; @@ -162,7 +163,7 @@ void EnNiw_Init(Actor* thisx, PlayState* play) { fabsf(this->actor.world.pos.z - sKakarikoPosList[i].z) < 40.0f) { this->unk_2AA = i; PRINTF(VT_FGCOL(YELLOW) " 通常鶏index %d\n" VT_RST, this->unk_2AA); - if (gSaveContext.save.info.infTable[INFTABLE_199_19A_19B_19C_19D_19E_19F_INDEX] & + if (gSaveContext.save.info.infTable[INFTABLE_INDEX_199_19A_19B_19C_19D_19E_19F] & sKakarikoFlagList[i]) { this->actor.world.pos.x = 300.0f; this->actor.world.pos.y = 100.0f; diff --git a/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c b/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c index 2f650637c7d..129bddd0a7b 100644 --- a/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c +++ b/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c @@ -43,8 +43,9 @@ static s16 sMissingCuccoTextIds[] = { }; static s16 D_80ABB3B4[] = { - INFTABLE_199_MASK, INFTABLE_19A_MASK, INFTABLE_19B_MASK, INFTABLE_19C_MASK, - INFTABLE_19D_MASK, INFTABLE_19E_MASK, INFTABLE_19F_MASK, + GET_INFTABLE_MASK(INFTABLE_199), GET_INFTABLE_MASK(INFTABLE_19A), GET_INFTABLE_MASK(INFTABLE_19B), + GET_INFTABLE_MASK(INFTABLE_19C), GET_INFTABLE_MASK(INFTABLE_19D), GET_INFTABLE_MASK(INFTABLE_19E), + GET_INFTABLE_MASK(INFTABLE_19F), }; static ColliderCylinderInit sCylinderInit = { @@ -210,7 +211,7 @@ void func_80ABA244(EnNiwLady* this, PlayState* play) { if ((fabsf(currentCucco->actor.world.pos.x - 330.0f) < 90.0f) && (fabsf(currentCucco->actor.world.pos.z - 1610.0f) < 190.0f)) { if (this->unk_26C == 0) { - gSaveContext.save.info.infTable[INFTABLE_199_19A_19B_19C_19D_19E_19F_INDEX] |= + gSaveContext.save.info.infTable[INFTABLE_INDEX_199_19A_19B_19C_19D_19E_19F] |= D_80ABB3B4[currentCucco->unk_2AA]; if (BREG(1) != 0) { // "GET inside the chicken fence!" @@ -219,7 +220,7 @@ void func_80ABA244(EnNiwLady* this, PlayState* play) { } this->cuccosInPen++; } else if (this->unk_26C == 0) { - gSaveContext.save.info.infTable[INFTABLE_199_19A_19B_19C_19D_19E_19F_INDEX] &= + gSaveContext.save.info.infTable[INFTABLE_INDEX_199_19A_19B_19C_19D_19E_19F] &= ~D_80ABB3B4[currentCucco->unk_2AA]; } } @@ -276,12 +277,14 @@ void func_80ABA244(EnNiwLady* this, PlayState* play) { this->unk_262 = TEXT_STATE_EVENT; this->unk_26A = this->cuccosInPen; PRINTF(VT_FGCOL(CYAN) "☆☆☆☆☆ 柵内BIT変更前 ☆☆ %x\n" VT_RST, - gSaveContext.save.info.infTable[INFTABLE_199_19A_19B_19C_19D_19E_19F_INDEX]); - gSaveContext.save.info.infTable[INFTABLE_199_19A_19B_19C_19D_19E_19F_INDEX] &= - (u16) ~(INFTABLE_199_MASK | INFTABLE_19A_MASK | INFTABLE_19B_MASK | INFTABLE_19C_MASK | - INFTABLE_19D_MASK | INFTABLE_19E_MASK | INFTABLE_19F_MASK); + gSaveContext.save.info.infTable[INFTABLE_INDEX_199_19A_19B_19C_19D_19E_19F]); + gSaveContext.save.info.infTable[INFTABLE_INDEX_199_19A_19B_19C_19D_19E_19F] &= + (u16) ~(GET_INFTABLE_MASK(INFTABLE_199) | GET_INFTABLE_MASK(INFTABLE_19A) | + GET_INFTABLE_MASK(INFTABLE_19B) | GET_INFTABLE_MASK(INFTABLE_19C) | + GET_INFTABLE_MASK(INFTABLE_19D) | GET_INFTABLE_MASK(INFTABLE_19E) | + GET_INFTABLE_MASK(INFTABLE_19F)); PRINTF(VT_FGCOL(CYAN) "☆☆☆☆☆ 柵内BIT変更後 ☆☆ %x\n" VT_RST, - gSaveContext.save.info.infTable[INFTABLE_199_19A_19B_19C_19D_19E_19F_INDEX]); + gSaveContext.save.info.infTable[INFTABLE_INDEX_199_19A_19B_19C_19D_19E_19F]); PRINTF("\n\n"); this->actionFunc = func_80ABA654; return; diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index e4ad4398064..ec3b7ccf6b0 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -74,7 +74,12 @@ static EnSthActionFunc sRewardObtainedWaitActions[6] = { }; static u16 sEventFlags[6] = { - 0, EVENTCHKINF_DA_MASK, EVENTCHKINF_DB_MASK, EVENTCHKINF_DC_MASK, EVENTCHKINF_DD_MASK, EVENTCHKINF_DE_MASK, + 0, + GET_EVENTCHKINF_MASK(EVENTCHKINF_DA), + GET_EVENTCHKINF_MASK(EVENTCHKINF_DB), + GET_EVENTCHKINF_MASK(EVENTCHKINF_DC), + GET_EVENTCHKINF_MASK(EVENTCHKINF_DD), + GET_EVENTCHKINF_MASK(EVENTCHKINF_DE), }; static s16 sGetItemIds[6] = { @@ -156,7 +161,7 @@ void EnSth_SetupAfterObjectLoaded(EnSth* this, PlayState* play) { this->eventFlag = sEventFlags[this->actor.params]; params = &this->actor.params; - if (gSaveContext.save.info.eventChkInf[EVENTCHKINF_DA_DB_DC_DD_DE_INDEX] & this->eventFlag) { + if (gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_DA_DB_DC_DD_DE] & this->eventFlag) { EnSth_SetupAction(this, sRewardObtainedWaitActions[*params]); } else { EnSth_SetupAction(this, EnSth_RewardUnobtainedWait); @@ -256,7 +261,7 @@ void EnSth_GiveReward(EnSth* this, PlayState* play) { if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; EnSth_SetupAction(this, EnSth_RewardObtainedTalk); - gSaveContext.save.info.eventChkInf[EVENTCHKINF_DA_DB_DC_DD_DE_INDEX] |= this->eventFlag; + gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_DA_DB_DC_DD_DE] |= this->eventFlag; } else { EnSth_GivePlayerItem(this, play); } diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 8b6b3263872..5484e259b3b 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -10760,7 +10760,7 @@ void Player_Init(Actor* thisx, PlayState* play2) { gSaveContext.respawn[RESPAWN_MODE_DOWN].data = 1; if (play->sceneId <= SCENE_INSIDE_GANONS_CASTLE_COLLAPSE) { - gSaveContext.save.info.infTable[INFTABLE_1AX_INDEX] |= gBitFlags[play->sceneId]; + gSaveContext.save.info.infTable[INFTABLE_INDEX_1AX] |= gBitFlags[play->sceneId]; } startMode = PLAYER_GET_START_MODE(thisx); diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c index 33c98159c95..e633b06e2e2 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c @@ -466,7 +466,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) { Inventory_ChangeEquipment(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP]); if (pauseCtx->cursorY[PAUSE_EQUIP] == 0) { - gSaveContext.save.info.infTable[INFTABLE_1DX_INDEX] = 0; + gSaveContext.save.info.infTable[INFTABLE_INDEX_1DX] = 0; gSaveContext.save.info.equips.buttonItems[0] = cursorItem; if ((pauseCtx->cursorX[PAUSE_EQUIP] == 3) && (gSaveContext.save.info.playerData.bgsFlag != 0)) { From ed6c8ceb3202e0ee93093358034c6f0fbfa86466 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Wed, 18 Dec 2024 03:14:39 -0500 Subject: [PATCH 2/5] EVENTINF_HORSES_INDEX -> EVENTINF_INDEX_HORSES --- include/z64save.h | 18 +++++++++--------- src/code/z_parameter.c | 4 ++-- src/overlays/actors/ovl_En_In/z_en_in.c | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/z64save.h b/include/z64save.h index 5a95850d929..74ccbaaa33c 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -884,7 +884,7 @@ typedef enum LinkAge { // EVENTINF 0x00-0x0F // Ingo Race, Lon Lon Ranch minigames, and Horseback Archery minigame flags -#define EVENTINF_HORSES_INDEX 0 +#define EVENTINF_INDEX_HORSES 0 // EVENTINF 0x00-0x03 reserved for IngoRaceState #define EVENTINF_INGO_RACE_STATE_MASK (0xF << 0) typedef enum IngoRaceState { @@ -915,22 +915,22 @@ typedef enum IngoRaceState { #define EVENTINF_INGO_RACE_0F_MASK (1 << EVENTINF_INGO_RACE_0F) // "InRaceSeq" -#define GET_EVENTINF_INGO_RACE_STATE() (gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & EVENTINF_INGO_RACE_STATE_MASK) +#define GET_EVENTINF_INGO_RACE_STATE() (gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & EVENTINF_INGO_RACE_STATE_MASK) #define SET_EVENTINF_INGO_RACE_STATE(v) \ - gSaveContext.eventInf[EVENTINF_HORSES_INDEX] = \ - (gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & ~EVENTINF_INGO_RACE_STATE_MASK) | (v) + gSaveContext.eventInf[EVENTINF_INDEX_HORSES] = \ + (gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & ~EVENTINF_INGO_RACE_STATE_MASK) | (v) #define GET_EVENTINF_INGO_RACE_FLAG(flag) \ - ((gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & (1 << ((flag) & 0xF))) >> ((flag) & 0xF)) + ((gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & (1 << ((flag) & 0xF))) >> ((flag) & 0xF)) #define SET_EVENTINF_INGO_RACE_FLAG(flag) \ - gSaveContext.eventInf[EVENTINF_HORSES_INDEX] = \ - (gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & 0xFFFF) | (1 << ((flag) & 0xF)) + gSaveContext.eventInf[EVENTINF_INDEX_HORSES] = \ + (gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & 0xFFFF) | (1 << ((flag) & 0xF)) #define WRITE_EVENTINF_INGO_RACE_FLAG(flag, v) \ - gSaveContext.eventInf[EVENTINF_HORSES_INDEX] = \ - (gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & ~(1 << ((flag) & 0xF))) | ((v) << ((flag) & 0xF)) + gSaveContext.eventInf[EVENTINF_INDEX_HORSES] = \ + (gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & ~(1 << ((flag) & 0xF))) | ((v) << ((flag) & 0xF)) #define GET_EVENTINF_INGO_RACE_HORSETYPE() GET_EVENTINF_INGO_RACE_FLAG(EVENTINF_INGO_RACE_HORSETYPE) #define WRITE_EVENTINF_INGO_RACE_HORSETYPE(v) WRITE_EVENTINF_INGO_RACE_FLAG(EVENTINF_INGO_RACE_HORSETYPE, v) diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 724d6f79e4c..ec45b03530f 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -3545,11 +3545,11 @@ void Interface_Draw(PlayState* play) { for (svar1 = 0; svar1 < ARRAY_COUNT(gSpoilingItems); svar1++) { if (INV_CONTENT(ITEM_TRADE_ADULT) == gSpoilingItems[svar1]) { #if OOT_VERSION >= NTSC_1_1 - gSaveContext.eventInf[EVENTINF_HORSES_INDEX] &= + gSaveContext.eventInf[EVENTINF_INDEX_HORSES] &= (u16) ~(EVENTINF_INGO_RACE_STATE_MASK | EVENTINF_INGO_RACE_HORSETYPE_MASK | EVENTINF_INGO_RACE_LOST_ONCE_MASK | EVENTINF_INGO_RACE_SECOND_RACE_MASK | EVENTINF_INGO_RACE_0F_MASK); - PRINTF("EVENT_INF=%x\n", gSaveContext.eventInf[EVENTINF_HORSES_INDEX]); + PRINTF("EVENT_INF=%x\n", gSaveContext.eventInf[EVENTINF_INDEX_HORSES]); #endif play->nextEntranceIndex = spoilingItemEntrances[svar1]; INV_CONTENT(gSpoilingItemReverts[svar1]) = gSpoilingItemReverts[svar1]; diff --git a/src/overlays/actors/ovl_En_In/z_en_in.c b/src/overlays/actors/ovl_En_In/z_en_in.c index b5e543f450b..7ce346f6333 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -500,7 +500,7 @@ void EnIn_Init(Actor* thisx, PlayState* play) { respawnPos = respawn->pos; // hardcoded coords for lon lon entrance if (D_80A7B998 == 0 && respawnPos.x == 1107.0f && respawnPos.y == 0.0f && respawnPos.z == -3740.0f) { - gSaveContext.eventInf[EVENTINF_HORSES_INDEX] = 0; + gSaveContext.eventInf[EVENTINF_INDEX_HORSES] = 0; D_80A7B998 = 1; } this->actionFunc = EnIn_WaitForObject; @@ -586,7 +586,7 @@ void EnIn_WaitForObject(EnIn* this, PlayState* play) { case INGO_RACE_STATE_RACING: EnIn_ChangeAnim(this, ENIN_ANIM_2); this->actionFunc = func_80A7A4C8; - gSaveContext.eventInf[EVENTINF_HORSES_INDEX] = 0; + gSaveContext.eventInf[EVENTINF_INDEX_HORSES] = 0; break; case INGO_RACE_STATE_HORSE_RENTAL_PERIOD: this->actor.attentionRangeType = ATTENTION_RANGE_3; From c1f2672c266a4d6871840677acd613fa9f9abc40 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Wed, 18 Dec 2024 03:35:44 -0500 Subject: [PATCH 3/5] Add missing index numbers --- include/z64save.h | 3 +++ src/code/z_sram.c | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/z64save.h b/include/z64save.h index 74ccbaaa33c..bac3e29bc6b 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -471,6 +471,7 @@ typedef enum LinkAge { #define GET_EVENTCHKINF_MASK(flag) (1 << ((flag) & 0xF)) // EVENTCHKINF 0x00-0x0F +#define EVENTCHKINF_INDEX_0 0 #define EVENTCHKINF_00_UNUSED 0x00 // flag is set in the debug save, but has no functionality #define EVENTCHKINF_01_UNUSED 0x01 // flag is set in the debug save, but has no functionality #define EVENTCHKINF_MIDO_DENIED_DEKU_TREE_ACCESS 0x02 @@ -715,6 +716,8 @@ typedef enum LinkAge { #define GET_INFTABLE_MASK(flag) (1 << ((flag) & 0xF)) +// INFTABLE 0x0-0xF +#define INFTABLE_INDEX_0 0 #define INFTABLE_00 0x00 #define INFTABLE_01 0x01 #define INFTABLE_03 0x03 diff --git a/src/code/z_sram.c b/src/code/z_sram.c index 595793ad051..045a0dca7a1 100644 --- a/src/code/z_sram.c +++ b/src/code/z_sram.c @@ -325,10 +325,11 @@ void Sram_InitDebugSave(void) { gSaveContext.save.info.horseData.pos.y = 72; gSaveContext.save.info.horseData.pos.z = 5497; gSaveContext.save.info.horseData.angle = -0x6AD9; - gSaveContext.save.info.infTable[0] |= GET_INFTABLE_MASK(INFTABLE_00) | GET_INFTABLE_MASK(INFTABLE_03) | - GET_INFTABLE_MASK(INFTABLE_0C) | GET_INFTABLE_MASK(INFTABLE_0E); + gSaveContext.save.info.infTable[INFTABLE_INDEX_0] |= + GET_INFTABLE_MASK(INFTABLE_00) | GET_INFTABLE_MASK(INFTABLE_03) | GET_INFTABLE_MASK(INFTABLE_0C) | + GET_INFTABLE_MASK(INFTABLE_0E); - gSaveContext.save.info.eventChkInf[0] |= + gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_0] |= GET_EVENTCHKINF_MASK(EVENTCHKINF_00_UNUSED) | GET_EVENTCHKINF_MASK(EVENTCHKINF_01_UNUSED) | GET_EVENTCHKINF_MASK(EVENTCHKINF_MIDO_DENIED_DEKU_TREE_ACCESS) | GET_EVENTCHKINF_MASK(EVENTCHKINF_03) | GET_EVENTCHKINF_MASK(EVENTCHKINF_04) | GET_EVENTCHKINF_MASK(EVENTCHKINF_05) | From 1e25e83ec2f1a259b8343fa6d74a808a1845dc78 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Thu, 19 Dec 2024 03:30:16 -0500 Subject: [PATCH 4/5] pr suggestions --- include/z64save.h | 50 ++++++++++--------- src/code/z_sram.c | 15 +++--- .../ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c | 4 +- src/overlays/actors/ovl_En_Fr/z_en_fr.c | 16 +++--- src/overlays/actors/ovl_En_Hy/z_en_hy.c | 4 +- src/overlays/actors/ovl_En_Niw/z_en_niw.c | 5 +- .../actors/ovl_En_Niw_Lady/z_en_niw_lady.c | 12 ++--- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 10 ++-- 8 files changed, 58 insertions(+), 58 deletions(-) diff --git a/include/z64save.h b/include/z64save.h index bac3e29bc6b..27c0126ad52 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -464,11 +464,12 @@ typedef enum LinkAge { * SaveContext.eventChkInf */ -#define GET_EVENTCHKINF(flag) (gSaveContext.save.info.eventChkInf[(flag) >> 4] & (1 << ((flag) & 0xF))) -#define SET_EVENTCHKINF(flag) (gSaveContext.save.info.eventChkInf[(flag) >> 4] |= (1 << ((flag) & 0xF))) -#define CLEAR_EVENTCHKINF(flag) (gSaveContext.save.info.eventChkInf[(flag) >> 4] &= ~(1 << ((flag) & 0xF))) +#define EVENTCHKINF_INDEX(flag) ((flag) >> 4) +#define EVENTCHKINF_MASK(flag) (1 << ((flag) & 0xF)) -#define GET_EVENTCHKINF_MASK(flag) (1 << ((flag) & 0xF)) +#define GET_EVENTCHKINF(flag) (gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX(flag)] & EVENTCHKINF_MASK(flag)) +#define SET_EVENTCHKINF(flag) (gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX(flag)] |= EVENTCHKINF_MASK(flag)) +#define CLEAR_EVENTCHKINF(flag) (gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX(flag)] &= ~EVENTCHKINF_MASK(flag)) // EVENTCHKINF 0x00-0x0F #define EVENTCHKINF_INDEX_0 0 @@ -518,7 +519,7 @@ typedef enum LinkAge { #define EVENTCHKINF_DEFEATED_NABOORU_KNUCKLE 0x3C // EVENTCHKINF 0x40 -#define EVENTCHKINF_INDEX_40 (EVENTCHKINF_40 >> 4) +#define EVENTCHKINF_INDEX_40 EVENTCHKINF_INDEX(EVENTCHKINF_40) #define EVENTCHKINF_40 0x40 #define EVENTCHKINF_41 0x41 @@ -549,7 +550,7 @@ typedef enum LinkAge { #define EVENTCHKINF_TALON_WOKEN_IN_KAKARIKO 0x6A // EVENTCHKINF 0x6B -#define EVENTCHKINF_INDEX_TALON_RETURNED_FROM_KAKARIKO (EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO >> 4) +#define EVENTCHKINF_INDEX_TALON_RETURNED_FROM_KAKARIKO EVENTCHKINF_INDEX(EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO) #define EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO 0x6B #define EVENTCHKINF_6E 0x6E @@ -627,7 +628,7 @@ typedef enum LinkAge { #define EVENTCHKINF_C9 0xC9 // EVENTCHKINF 0xD0-0xD6 -#define EVENTCHKINF_INDEX_SONGS_FOR_FROGS (EVENTCHKINF_SONGS_FOR_FROGS_CHOIR >> 4) +#define EVENTCHKINF_INDEX_SONGS_FOR_FROGS EVENTCHKINF_INDEX(EVENTCHKINF_SONGS_FOR_FROGS_CHOIR) #define EVENTCHKINF_SONGS_FOR_FROGS_CHOIR 0xD0 #define EVENTCHKINF_SONGS_FOR_FROGS_ZL 0xD1 #define EVENTCHKINF_SONGS_FOR_FROGS_EPONA 0xD2 @@ -637,7 +638,7 @@ typedef enum LinkAge { #define EVENTCHKINF_SONGS_FOR_FROGS_STORMS 0xD6 // EVENTCHKINF 0xDA-0xDE -#define EVENTCHKINF_INDEX_DA_DB_DC_DD_DE (EVENTCHKINF_DA >> 4) +#define EVENTCHKINF_INDEX_DA_DB_DC_DD_DE EVENTCHKINF_INDEX(EVENTCHKINF_DA) #define EVENTCHKINF_DA 0xDA #define EVENTCHKINF_DB 0xDB #define EVENTCHKINF_DC 0xDC @@ -649,10 +650,11 @@ typedef enum LinkAge { * SaveContext.itemGetInf */ -#define GET_ITEMGETINF(flag) (gSaveContext.save.info.itemGetInf[(flag) >> 4] & (1 << ((flag) & 0xF))) -#define SET_ITEMGETINF(flag) (gSaveContext.save.info.itemGetInf[(flag) >> 4] |= (1 << ((flag) & 0xF))) +#define ITEMGETINF_INDEX(flag) ((flag) >> 4) +#define ITEMGETINF_MASK(flag) (1 << ((flag) & 0xF)) -#define GET_ITEMGETINF_MASK(flag) (1 << ((flag) & 0xF)) +#define GET_ITEMGETINF(flag) (gSaveContext.save.info.itemGetInf[ITEMGETINF_INDEX(flag)] & ITEMGETINF_MASK(flag)) +#define SET_ITEMGETINF(flag) (gSaveContext.save.info.itemGetInf[ITEMGETINF_INDEX(flag)] |= ITEMGETINF_MASK(flag)) #define ITEMGETINF_TALON_BOTTLE 0x02 #define ITEMGETINF_03 0x03 @@ -710,11 +712,12 @@ typedef enum LinkAge { * SaveContext.infTable */ -#define GET_INFTABLE(flag) (gSaveContext.save.info.infTable[(flag) >> 4] & (1 << ((flag) & 0xF))) -#define SET_INFTABLE(flag) (gSaveContext.save.info.infTable[(flag) >> 4] |= (1 << ((flag) & 0xF))) -#define CLEAR_INFTABLE(flag) (gSaveContext.save.info.infTable[(flag) >> 4] &= ~(1 << ((flag) & 0xF))) +#define INFTABLE_INDEX(flag) ((flag) >> 4) +#define INFTABLE_MASK(flag) (1 << ((flag) & 0xF)) -#define GET_INFTABLE_MASK(flag) (1 << ((flag) & 0xF)) +#define GET_INFTABLE(flag) (gSaveContext.save.info.infTable[INFTABLE_INDEX(flag)] & INFTABLE_MASK(flag)) +#define SET_INFTABLE(flag) (gSaveContext.save.info.infTable[INFTABLE_INDEX(flag)] |= INFTABLE_MASK(flag)) +#define CLEAR_INFTABLE(flag) (gSaveContext.save.info.infTable[INFTABLE_INDEX(flag)] &= ~INFTABLE_MASK(flag)) // INFTABLE 0x0-0xF #define INFTABLE_INDEX_0 0 @@ -871,7 +874,7 @@ typedef enum LinkAge { #define INFTABLE_1AD_SHIFT 13 // INFTABLE 0x1D0-0x1DF -#define INFTABLE_INDEX_1DX (0x1D0 >> 4) +#define INFTABLE_INDEX_1DX INFTABLE_INDEX(INFTABLE_1D0) #define INFTABLE_1D0 0x1D0 @@ -879,11 +882,12 @@ typedef enum LinkAge { * SaveContext.eventInf */ -#define GET_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] & (1 << ((flag) & 0xF))) -#define SET_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] |= (1 << ((flag) & 0xF))) -#define CLEAR_EVENTINF(flag) (gSaveContext.eventInf[(flag) >> 4] &= ~(1 << ((flag) & 0xF))) +#define EVENTINF_INDEX(flag) ((flag) >> 4) +#define EVENTINF_MASK(flag) (1 << ((flag) & 0xF)) -#define GET_EVENTINF_MASK(flag) (1 << ((flag) & 0xF)) +#define GET_EVENTINF(flag) (gSaveContext.eventInf[EVENTINF_INDEX(flag)] & EVENTINF_MASK(flag)) +#define SET_EVENTINF(flag) (gSaveContext.eventInf[EVENTINF_INDEX(flag)] |= EVENTINF_MASK(flag)) +#define CLEAR_EVENTINF(flag) (gSaveContext.eventInf[EVENTINF_INDEX(flag)] &= ~EVENTINF_MASK(flag)) // EVENTINF 0x00-0x0F // Ingo Race, Lon Lon Ranch minigames, and Horseback Archery minigame flags @@ -925,15 +929,15 @@ typedef enum IngoRaceState { (gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & ~EVENTINF_INGO_RACE_STATE_MASK) | (v) #define GET_EVENTINF_INGO_RACE_FLAG(flag) \ - ((gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & (1 << ((flag) & 0xF))) >> ((flag) & 0xF)) + ((gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & EVENTINF_MASK(flag)) >> ((flag) & 0xF)) #define SET_EVENTINF_INGO_RACE_FLAG(flag) \ gSaveContext.eventInf[EVENTINF_INDEX_HORSES] = \ - (gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & 0xFFFF) | (1 << ((flag) & 0xF)) + (gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & 0xFFFF) | EVENTINF_MASK(flag) #define WRITE_EVENTINF_INGO_RACE_FLAG(flag, v) \ gSaveContext.eventInf[EVENTINF_INDEX_HORSES] = \ - (gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & ~(1 << ((flag) & 0xF))) | ((v) << ((flag) & 0xF)) + (gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & ~EVENTINF_MASK(flag)) | ((v) << ((flag) & 0xF)) #define GET_EVENTINF_INGO_RACE_HORSETYPE() GET_EVENTINF_INGO_RACE_FLAG(EVENTINF_INGO_RACE_HORSETYPE) #define WRITE_EVENTINF_INGO_RACE_HORSETYPE(v) WRITE_EVENTINF_INGO_RACE_FLAG(EVENTINF_INGO_RACE_HORSETYPE, v) diff --git a/src/code/z_sram.c b/src/code/z_sram.c index 045a0dca7a1..cd3a2f13e69 100644 --- a/src/code/z_sram.c +++ b/src/code/z_sram.c @@ -325,15 +325,14 @@ void Sram_InitDebugSave(void) { gSaveContext.save.info.horseData.pos.y = 72; gSaveContext.save.info.horseData.pos.z = 5497; gSaveContext.save.info.horseData.angle = -0x6AD9; - gSaveContext.save.info.infTable[INFTABLE_INDEX_0] |= - GET_INFTABLE_MASK(INFTABLE_00) | GET_INFTABLE_MASK(INFTABLE_03) | GET_INFTABLE_MASK(INFTABLE_0C) | - GET_INFTABLE_MASK(INFTABLE_0E); + gSaveContext.save.info.infTable[INFTABLE_INDEX_0] |= INFTABLE_MASK(INFTABLE_00) | INFTABLE_MASK(INFTABLE_03) | + INFTABLE_MASK(INFTABLE_0C) | INFTABLE_MASK(INFTABLE_0E); gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_0] |= - GET_EVENTCHKINF_MASK(EVENTCHKINF_00_UNUSED) | GET_EVENTCHKINF_MASK(EVENTCHKINF_01_UNUSED) | - GET_EVENTCHKINF_MASK(EVENTCHKINF_MIDO_DENIED_DEKU_TREE_ACCESS) | GET_EVENTCHKINF_MASK(EVENTCHKINF_03) | - GET_EVENTCHKINF_MASK(EVENTCHKINF_04) | GET_EVENTCHKINF_MASK(EVENTCHKINF_05) | - GET_EVENTCHKINF_MASK(EVENTCHKINF_09) | GET_EVENTCHKINF_MASK(EVENTCHKINF_0C); + EVENTCHKINF_MASK(EVENTCHKINF_00_UNUSED) | EVENTCHKINF_MASK(EVENTCHKINF_01_UNUSED) | + EVENTCHKINF_MASK(EVENTCHKINF_MIDO_DENIED_DEKU_TREE_ACCESS) | EVENTCHKINF_MASK(EVENTCHKINF_03) | + EVENTCHKINF_MASK(EVENTCHKINF_04) | EVENTCHKINF_MASK(EVENTCHKINF_05) | EVENTCHKINF_MASK(EVENTCHKINF_09) | + EVENTCHKINF_MASK(EVENTCHKINF_0C); SET_EVENTCHKINF(EVENTCHKINF_80); SET_EVENTCHKINF(EVENTCHKINF_C4); @@ -506,7 +505,7 @@ void Sram_OpenSave(SramContext* sramCtx) { // if zelda cutscene has been watched but lullaby was not obtained, restore cutscene and take away letter if (GET_EVENTCHKINF(EVENTCHKINF_40) && !CHECK_QUEST_ITEM(QUEST_SONG_LULLABY)) { - i = gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_40] & ~GET_EVENTCHKINF_MASK(EVENTCHKINF_40); + i = gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_40] & ~EVENTCHKINF_MASK(EVENTCHKINF_40); gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_40] = i; INV_CONTENT(ITEM_ZELDAS_LETTER) = ITEM_CHICKEN; diff --git a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c index 249a079c471..c8877e0e644 100644 --- a/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c +++ b/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c @@ -696,8 +696,8 @@ static s16 sDemoEffectLightColors[] = { DEMO_EFFECT_LIGHT_GREEN, DEMO_EFFECT_LIG static s16 sExItemTypes[] = { EXITEM_MAGIC_WIND, EXITEM_MAGIC_FIRE, EXITEM_MAGIC_DARK }; -static s16 sItemGetFlagMasks[] = { GET_ITEMGETINF_MASK(ITEMGETINF_18), GET_ITEMGETINF_MASK(ITEMGETINF_19), - GET_ITEMGETINF_MASK(ITEMGETINF_1A) }; +static s16 sItemGetFlagMasks[] = { ITEMGETINF_MASK(ITEMGETINF_18), ITEMGETINF_MASK(ITEMGETINF_19), + ITEMGETINF_MASK(ITEMGETINF_1A) }; static u8 sItemIds[] = { ITEM_FARORES_WIND, ITEM_DINS_FIRE, ITEM_NAYRUS_LOVE }; diff --git a/src/overlays/actors/ovl_En_Fr/z_en_fr.c b/src/overlays/actors/ovl_En_Fr/z_en_fr.c index 38053a8f238..6cf0808a4ff 100644 --- a/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ b/src/overlays/actors/ovl_En_Fr/z_en_fr.c @@ -116,14 +116,14 @@ static EnFrPointers sEnFrPointers = { sFrogSongIndexToEventChkInfSongsForFrogsMask[frogSongIndex]; static u16 sFrogSongIndexToEventChkInfSongsForFrogsMask[] = { - GET_EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_ZL), // FROG_ZL - GET_EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_EPONA), // FROG_EPONA - GET_EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_SARIA), // FROG_SARIA - GET_EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_SUNS), // FROG_SUNS - GET_EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_SOT), // FROG_SOT - GET_EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_STORMS), // FROG_STORMS - GET_EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_CHOIR), // FROG_CHOIR_SONG - 0, // FROG_NO_SONG + EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_ZL), // FROG_ZL + EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_EPONA), // FROG_EPONA + EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_SARIA), // FROG_SARIA + EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_SUNS), // FROG_SUNS + EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_SOT), // FROG_SOT + EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_STORMS), // FROG_STORMS + EVENTCHKINF_MASK(EVENTCHKINF_SONGS_FOR_FROGS_CHOIR), // FROG_CHOIR_SONG + 0, // FROG_NO_SONG }; static u8 sFrogToFrogSongIndex[] = { diff --git a/src/overlays/actors/ovl_En_Hy/z_en_hy.c b/src/overlays/actors/ovl_En_Hy/z_en_hy.c index 92065101bb1..2aa163d0fbc 100644 --- a/src/overlays/actors/ovl_En_Hy/z_en_hy.c +++ b/src/overlays/actors/ovl_En_Hy/z_en_hy.c @@ -605,7 +605,7 @@ u16 EnHy_GetTextId(PlayState* play, Actor* thisx) { switch (ENHY_GET_TYPE(&this->actor)) { case ENHY_TYPE_DOG_LADY: if (play->sceneId == SCENE_KAKARIKO_CENTER_GUEST_HOUSE) { - return (this->talonEventChkInf & GET_EVENTCHKINF_MASK(EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO)) + return (this->talonEventChkInf & EVENTCHKINF_MASK(EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO)) ? 0x508D : (GET_INFTABLE(INFTABLE_CB) ? 0x508C : 0x508B); } else if (play->sceneId == SCENE_MARKET_DAY) { @@ -738,7 +738,7 @@ u16 EnHy_GetTextId(PlayState* play, Actor* thisx) { if (!LINK_IS_ADULT) { return GET_EVENTCHKINF(EVENTCHKINF_80) ? 0x505F : (GET_INFTABLE(INFTABLE_163) ? 0x505E : 0x505D); } else { - return (this->talonEventChkInf & GET_EVENTCHKINF_MASK(EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO)) + return (this->talonEventChkInf & EVENTCHKINF_MASK(EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO)) ? 0x5062 : (GET_INFTABLE(INFTABLE_164) ? 0x5061 : 0x5060); } diff --git a/src/overlays/actors/ovl_En_Niw/z_en_niw.c b/src/overlays/actors/ovl_En_Niw/z_en_niw.c index 3f846eba8ac..144c76b2cbb 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -66,9 +66,8 @@ static Vec3f sKakarikoPosList[] = { }; static s16 sKakarikoFlagList[] = { - GET_INFTABLE_MASK(INFTABLE_199), GET_INFTABLE_MASK(INFTABLE_19A), GET_INFTABLE_MASK(INFTABLE_19B), - GET_INFTABLE_MASK(INFTABLE_19C), GET_INFTABLE_MASK(INFTABLE_19D), GET_INFTABLE_MASK(INFTABLE_19E), - GET_INFTABLE_MASK(INFTABLE_19F), + INFTABLE_MASK(INFTABLE_199), INFTABLE_MASK(INFTABLE_19A), INFTABLE_MASK(INFTABLE_19B), INFTABLE_MASK(INFTABLE_19C), + INFTABLE_MASK(INFTABLE_19D), INFTABLE_MASK(INFTABLE_19E), INFTABLE_MASK(INFTABLE_19F), }; static u8 sLowerRiverSpawned = false; diff --git a/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c b/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c index e6640725ef6..0415f95bb93 100644 --- a/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c +++ b/src/overlays/actors/ovl_En_Niw_Lady/z_en_niw_lady.c @@ -43,9 +43,8 @@ static s16 sMissingCuccoTextIds[] = { }; static s16 D_80ABB3B4[] = { - GET_INFTABLE_MASK(INFTABLE_199), GET_INFTABLE_MASK(INFTABLE_19A), GET_INFTABLE_MASK(INFTABLE_19B), - GET_INFTABLE_MASK(INFTABLE_19C), GET_INFTABLE_MASK(INFTABLE_19D), GET_INFTABLE_MASK(INFTABLE_19E), - GET_INFTABLE_MASK(INFTABLE_19F), + INFTABLE_MASK(INFTABLE_199), INFTABLE_MASK(INFTABLE_19A), INFTABLE_MASK(INFTABLE_19B), INFTABLE_MASK(INFTABLE_19C), + INFTABLE_MASK(INFTABLE_19D), INFTABLE_MASK(INFTABLE_19E), INFTABLE_MASK(INFTABLE_19F), }; static ColliderCylinderInit sCylinderInit = { @@ -279,10 +278,9 @@ void func_80ABA244(EnNiwLady* this, PlayState* play) { PRINTF(VT_FGCOL(CYAN) "☆☆☆☆☆ 柵内BIT変更前 ☆☆ %x\n" VT_RST, gSaveContext.save.info.infTable[INFTABLE_INDEX_199_19A_19B_19C_19D_19E_19F]); gSaveContext.save.info.infTable[INFTABLE_INDEX_199_19A_19B_19C_19D_19E_19F] &= - (u16) ~(GET_INFTABLE_MASK(INFTABLE_199) | GET_INFTABLE_MASK(INFTABLE_19A) | - GET_INFTABLE_MASK(INFTABLE_19B) | GET_INFTABLE_MASK(INFTABLE_19C) | - GET_INFTABLE_MASK(INFTABLE_19D) | GET_INFTABLE_MASK(INFTABLE_19E) | - GET_INFTABLE_MASK(INFTABLE_19F)); + (u16) ~(INFTABLE_MASK(INFTABLE_199) | INFTABLE_MASK(INFTABLE_19A) | INFTABLE_MASK(INFTABLE_19B) | + INFTABLE_MASK(INFTABLE_19C) | INFTABLE_MASK(INFTABLE_19D) | INFTABLE_MASK(INFTABLE_19E) | + INFTABLE_MASK(INFTABLE_19F)); PRINTF(VT_FGCOL(CYAN) "☆☆☆☆☆ 柵内BIT変更後 ☆☆ %x\n" VT_RST, gSaveContext.save.info.infTable[INFTABLE_INDEX_199_19A_19B_19C_19D_19E_19F]); PRINTF("\n\n"); diff --git a/src/overlays/actors/ovl_En_Sth/z_en_sth.c b/src/overlays/actors/ovl_En_Sth/z_en_sth.c index ec3b7ccf6b0..1c8a222c068 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -75,11 +75,11 @@ static EnSthActionFunc sRewardObtainedWaitActions[6] = { static u16 sEventFlags[6] = { 0, - GET_EVENTCHKINF_MASK(EVENTCHKINF_DA), - GET_EVENTCHKINF_MASK(EVENTCHKINF_DB), - GET_EVENTCHKINF_MASK(EVENTCHKINF_DC), - GET_EVENTCHKINF_MASK(EVENTCHKINF_DD), - GET_EVENTCHKINF_MASK(EVENTCHKINF_DE), + EVENTCHKINF_MASK(EVENTCHKINF_DA), + EVENTCHKINF_MASK(EVENTCHKINF_DB), + EVENTCHKINF_MASK(EVENTCHKINF_DC), + EVENTCHKINF_MASK(EVENTCHKINF_DD), + EVENTCHKINF_MASK(EVENTCHKINF_DE), }; static s16 sGetItemIds[6] = { From 196fb60972b8a5f2178954ea74a543caba6630ae Mon Sep 17 00:00:00 2001 From: mzxrules Date: Thu, 19 Dec 2024 03:49:30 -0500 Subject: [PATCH 5/5] Clean up INGO_RACE flags --- include/z64save.h | 18 +++++++----------- src/code/z_parameter.c | 6 +++--- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/include/z64save.h b/include/z64save.h index 27c0126ad52..cdd2d62fc50 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -893,7 +893,7 @@ typedef enum LinkAge { // Ingo Race, Lon Lon Ranch minigames, and Horseback Archery minigame flags #define EVENTINF_INDEX_HORSES 0 // EVENTINF 0x00-0x03 reserved for IngoRaceState -#define EVENTINF_INGO_RACE_STATE_MASK (0xF << 0) +#define EVENTINF_INGO_RACE_STATE_MASK (0xF << 0x00) typedef enum IngoRaceState { /* 0 */ INGO_RACE_STATE_OFFER_RENTAL, /* 1 */ INGO_RACE_STATE_HORSE_RENTAL_PERIOD, @@ -905,21 +905,17 @@ typedef enum IngoRaceState { /* 7 */ INGO_RACE_STATE_REMATCH } IngoRaceState; -#define EVENTINF_INGO_RACE_HORSETYPE 4 -#define EVENTINF_INGO_RACE_HORSETYPE_MASK (1 << EVENTINF_INGO_RACE_HORSETYPE) -#define EVENTINF_INGO_RACE_LOST_ONCE 5 -#define EVENTINF_INGO_RACE_LOST_ONCE_MASK (1 << EVENTINF_INGO_RACE_LOST_ONCE) -#define EVENTINF_INGO_RACE_SECOND_RACE 6 -#define EVENTINF_INGO_RACE_SECOND_RACE_MASK (1 << EVENTINF_INGO_RACE_SECOND_RACE) +#define EVENTINF_INGO_RACE_HORSETYPE 0x04 +#define EVENTINF_INGO_RACE_LOST_ONCE 0x05 +#define EVENTINF_INGO_RACE_SECOND_RACE 0x06 // Used in z_en_ta (Talon) to store Cucco game winning status // and in z_en_ge1 (Gerudo) to store archery in-progress status -#define EVENTINF_HORSES_08 8 +#define EVENTINF_HORSES_08 0x08 #define EVENTINF_CUCCO_GAME_WON EVENTINF_HORSES_08 // Used in z_en_ta (Talon) and z_en_ma3 (Malon) to store minigame finishing status -#define EVENTINF_HORSES_0A 10 +#define EVENTINF_HORSES_0A 0x0A #define EVENTINF_CUCCO_GAME_FINISHED EVENTINF_HORSES_0A -#define EVENTINF_INGO_RACE_0F 15 // unused? -#define EVENTINF_INGO_RACE_0F_MASK (1 << EVENTINF_INGO_RACE_0F) +#define EVENTINF_INGO_RACE_0F 0x0F // unused? // "InRaceSeq" #define GET_EVENTINF_INGO_RACE_STATE() (gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & EVENTINF_INGO_RACE_STATE_MASK) diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index ec45b03530f..7987cccd1ce 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -3546,9 +3546,9 @@ void Interface_Draw(PlayState* play) { if (INV_CONTENT(ITEM_TRADE_ADULT) == gSpoilingItems[svar1]) { #if OOT_VERSION >= NTSC_1_1 gSaveContext.eventInf[EVENTINF_INDEX_HORSES] &= - (u16) ~(EVENTINF_INGO_RACE_STATE_MASK | EVENTINF_INGO_RACE_HORSETYPE_MASK | - EVENTINF_INGO_RACE_LOST_ONCE_MASK | EVENTINF_INGO_RACE_SECOND_RACE_MASK | - EVENTINF_INGO_RACE_0F_MASK); + (u16) ~(EVENTINF_INGO_RACE_STATE_MASK | EVENTINF_MASK(EVENTINF_INGO_RACE_HORSETYPE) | + EVENTINF_MASK(EVENTINF_INGO_RACE_LOST_ONCE) | + EVENTINF_MASK(EVENTINF_INGO_RACE_SECOND_RACE) | EVENTINF_MASK(EVENTINF_INGO_RACE_0F)); PRINTF("EVENT_INF=%x\n", gSaveContext.eventInf[EVENTINF_INDEX_HORSES]); #endif play->nextEntranceIndex = spoilingItemEntrances[svar1];