From dae30ac2790a1697061552d67b8bb6dc25f2759b Mon Sep 17 00:00:00 2001 From: mzxrules Date: Wed, 20 Nov 2024 05:49:34 -0500 Subject: [PATCH 1/4] Restructure save flags --- include/z64save.h | 374 ++++++++++-------- src/code/z_horse.c | 8 +- src/code/z_map_data.c | 22 +- src/code/z_map_exp.c | 5 +- src/code/z_message.c | 4 +- src/code/z_parameter.c | 8 +- .../ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c | 11 +- .../actors/ovl_Bg_Ingate/z_bg_ingate.c | 2 +- .../ovl_Bg_Spot09_Obj/z_bg_spot09_obj.c | 3 +- src/overlays/actors/ovl_En_Daiku/z_en_daiku.c | 48 +-- src/overlays/actors/ovl_En_Daiku/z_en_daiku.h | 7 + src/overlays/actors/ovl_En_Fr/z_en_fr.c | 16 +- src/overlays/actors/ovl_En_Ge1/z_en_ge1.c | 4 +- src/overlays/actors/ovl_En_Ge2/z_en_ge2.c | 8 +- src/overlays/actors/ovl_En_Horse/z_en_horse.c | 8 +- .../z_en_horse_game_check.c | 14 +- src/overlays/actors/ovl_En_Hy/z_en_hy.c | 6 +- src/overlays/actors/ovl_En_In/z_en_in.c | 108 +++-- src/overlays/actors/ovl_En_Mu/z_en_mu.c | 13 +- src/overlays/actors/ovl_En_Niw/z_en_niw.c | 8 +- .../actors/ovl_En_Niw_Lady/z_en_niw_lady.c | 19 +- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 13 +- .../actors/ovl_Oceff_Spot/z_oceff_spot.c | 2 +- .../actors/ovl_player_actor/z_player.c | 2 +- 24 files changed, 387 insertions(+), 326 deletions(-) diff --git a/include/z64save.h b/include/z64save.h index 2c10d76bc61..88a332ca77b 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -462,8 +462,21 @@ typedef enum LinkAge { /* * SaveContext.eventChkInf + * eventChkInf is an array of 16 bit flags. These typically track main quest events. + * Generally, a flag will be assigned a unique id, ranging from 0x00-0xDE. Flag state can be individually accessed + * or modified by passing the flag id into GET_EVENTCHKINF, SET_EVENTCHKINF, and CLEAR_EVENTCHKINF + * + * In some instances where a set of flags share a common accociation, the eventChkInf variable will be accessed directly. + * When this is the case, an EVENTCHKINF_*_INDEX constant is defined for accessing a specific eventChkInf variable. */ +#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_VAR(flag) (gSaveContext.save.info.eventChkInf[(flag) >> 4]) +#define GET_EVENTCHKINF_MASK(flag) (1 << ((flag) & 0xF)) + #define EVENTCHKINF_02 0x02 #define EVENTCHKINF_03 0x03 #define EVENTCHKINF_04 0x04 @@ -507,11 +520,10 @@ typedef enum LinkAge { #define EVENTCHKINF_3B 0x3B #define EVENTCHKINF_3C 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_40_INDEX (EVENTCHKINF_40 >> 4) +#define EVENTCHKINF_40_MASK GET_EVENTCHKINF_MASK(EVENTCHKINF_40) +#define EVENTCHKINF_40 0x40 #define EVENTCHKINF_41 0x41 #define EVENTCHKINF_42 0x42 @@ -540,11 +552,11 @@ typedef enum LinkAge { #define EVENTCHKINF_69 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_TALON_RETURNED_FROM_KAKARIKO 0x6B + +#define ENHY_GET_COPY_EVENTCHKINF(flag) GET_EVENTCHKINF_VAR(flag) +#define ENHY_CHECK_COPY_EVENTCHKINF(v, flag) ((v) & GET_EVENTCHKINF_MASK((flag))) #define EVENTCHKINF_6E 0x6E #define EVENTCHKINF_6F 0x6F @@ -564,19 +576,41 @@ typedef enum LinkAge { #define EVENTCHKINF_8E 0x8E #define EVENTCHKINF_8F 0x8F -// 0x90-0x93 +// EVENTCHKINF 0x90-0x93 // carpenters freed from the gerudo -#define EVENTCHKINF_CARPENTERS_FREE_INDEX 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_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) +#define EVENTCHKINF_CARPENTERS_FREED_INDEX (EVENTCHKINF_CARPENTER_0_FREED >> 4) +#define EVENTCHKINF_CARPENTER_0_FREED 0x90 +#define EVENTCHKINF_CARPENTER_1_FREED 0x91 +#define EVENTCHKINF_CARPENTER_2_FREED 0x92 +#define EVENTCHKINF_CARPENTER_3_FREED 0x93 + +#define EVENTCHKINF_CARPENTERS_FREE_MASK_ALL \ + ( GET_EVENTCHKINF_MASK(EVENTCHKINF_CARPENTER_0_FREED) \ + | GET_EVENTCHKINF_MASK(EVENTCHKINF_CARPENTER_1_FREED) \ + | GET_EVENTCHKINF_MASK(EVENTCHKINF_CARPENTER_2_FREED) \ + | GET_EVENTCHKINF_MASK(EVENTCHKINF_CARPENTER_3_FREED)) + +#define GET_EVENTCHKINF_CARPENTERS_FREE_ALL() \ + CHECK_FLAG_ALL(gSaveContext.save.info.eventChkInf[EVENTCHKINF_CARPENTERS_FREED_INDEX], \ + EVENTCHKINF_CARPENTERS_FREE_MASK_ALL) + +#define GET_EVENTCHKINF_CARPENTERS_FREE_ALL2() \ + CHECK_FLAG_ALL(gSaveContext.save.info.eventChkInf[EVENTCHKINF_CARPENTERS_FREED_INDEX] & \ + (EVENTCHKINF_CARPENTERS_FREE_MASK_ALL | 0xF0), \ + EVENTCHKINF_CARPENTERS_FREE_MASK_ALL) + +#define ENDAIKU_CARPENTER_FREE_MASK(carpenterType) (1 << ((EVENTCHKINF_CARPENTER_0_FREED & 0xF) + (carpenterType))) +#define ENDAIKU_IS_CARPENTER_FREE(carpenterType) \ + gSaveContext.save.info.eventChkInf[EVENTCHKINF_CARPENTERS_FREED_INDEX] & \ + ENDAIKU_CARPENTER_FREE_MASK(carpenterType) + +#define ENDAIKU_SET_CARPENTER_FREE(carpenterType) \ + gSaveContext.save.info.eventChkInf[EVENTCHKINF_CARPENTERS_FREED_INDEX] |= \ + ENDAIKU_CARPENTER_FREE_MASK((carpenterType)) + +#define GET_EVENTCHKINF_CARPENTERS_FREE_FLAGS() \ + gSaveContext.save.info.eventChkInf[EVENTCHKINF_CARPENTERS_FREED_INDEX] & \ + EVENTCHKINF_CARPENTERS_FREE_MASK_ALL #define EVENTCHKINF_94 0x94 #define EVENTCHKINF_95 0x95 @@ -620,48 +654,42 @@ 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_SONGS_FOR_FROGS_INDEX (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_SKULLTULA_REWARD_INDEX (EVENTCHKINF_SKULLTULA_REWARD_10 >> 4) +#define EVENTCHKINF_SKULLTULA_REWARD_10 0xDA +#define EVENTCHKINF_SKULLTULA_REWARD_20 0xDB +#define EVENTCHKINF_SKULLTULA_REWARD_30 0xDC +#define EVENTCHKINF_SKULLTULA_REWARD_40 0xDD +#define EVENTCHKINF_SKULLTULA_REWARD_50 0xDE /* * SaveContext.itemGetInf + * itemGetInf is an array of 16 bit flags. These track whether the player has obtained certain items. + * Most C-Items do not have tracking flags, preferring to instead just check if the item is in the player's inventory. + * + * Generally, a flag will be assigned a unique id, ranging from 0x00-0x3F. Flag state can be individually accessed + * or modified by passing the flag id into GET_ITEMGETINF or SET_ITEMGETINF + * + * In some instances where a set of flags share a common accociation, the itemGetInf variable will be accessed directly. + * When this is the case, an ITEMGETINF_*_INDEX constant is defined for accessing a specific itemGetInf variable. */ +#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 +712,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_GREAT_FAIRY_ITEM_INDEX (ITEMGETINF_FARORES_WIND >> 4) +#define ITEMGETINF_FARORES_WIND 0x18 +#define ITEMGETINF_DINS_FIRE 0x19 +#define ITEMGETINF_NAYRUS_LOVE 0x1A #define ITEMGETINF_1B 0x1B #define ITEMGETINF_1C 0x1C @@ -717,14 +739,23 @@ 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 + * infTable is an array of 16 bit flags. Many of these flags track the non-essential interactions with NPCs. + * + * Generally, a flag will be assigned a unique id, ranging from 0x00-0x1D0. Flag state can be individually accessed + * or modified by passing the flag id into GET_INFTABLE, SET_INFTABLE, or CLEAR_INFTABLE + * + * In some instances where a set of flags share a common accociation, the infTable variable will be accessed directly. + * When this is the case, an INFTABLE_*_INDEX constant is defined for accessing a specific infTable variable. */ +#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 @@ -852,117 +883,144 @@ 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 -#define INFTABLE_1A0_SHIFT 0 -#define INFTABLE_1A1_SHIFT 1 -#define INFTABLE_1A2_SHIFT 2 -#define INFTABLE_1A3_SHIFT 3 -#define INFTABLE_1A4_SHIFT 4 -#define INFTABLE_1A5_SHIFT 5 -#define INFTABLE_1A6_SHIFT 6 -#define INFTABLE_1A7_SHIFT 7 -#define INFTABLE_1A8_SHIFT 8 -#define INFTABLE_1A9_SHIFT 9 -#define INFTABLE_1AB_SHIFT 11 -#define INFTABLE_1AD_SHIFT 13 +// INFTABLE 0x199-0x19F +#define INFTABLE_KAKARIKO_CUCCO_INDEX (INFTABLE_199 >> 4) +#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 + +#define INFTABLE_RESET_KAKARIKO_CUCCOS() \ + gSaveContext.save.info.infTable[INFTABLE_KAKARIKO_CUCCO_INDEX] &= \ + (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)); + + +// INFTABLE 0x1A0-0x1AF +#define INFTABLE_OVERWORLD_ENTRANCE_ICON_INDEX (INFTABLE_1A0 >> 4) +#define INFTABLE_1A0 0x1A0 +#define INFTABLE_1A1 0x1A1 +#define INFTABLE_1A2 0x1A2 +#define INFTABLE_1A3 0x1A3 +#define INFTABLE_1A4 0x1A4 +#define INFTABLE_1A5 0x1A5 +#define INFTABLE_1A6 0x1A6 +#define INFTABLE_1A7 0x1A7 +#define INFTABLE_1A8 0x1A8 +#define INFTABLE_1A9 0x1A9 // different +#define INFTABLE_1AB 0x1AB +#define INFTABLE_1AD 0x1AD + +// Functionally the same as GET_INFTABLE +#define MINIMAP_GET_INFTABLE(flag) \ + gSaveContext.save.info.infTable[(flag) >> 4] & gBitFlags[((flag) & 0xF)] + +#define MINIMAP_GET_INFTABLE_SHIFT(flag) ((flag) - INFTABLE_1A0) // 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))) - - /* * SaveContext.eventInf + * eventInf is an array of 16 bit flags. These flags are not permanent. + * + * Generally, a flag will be assigned a unique id, ranging from 0x00-0x30. Flag state can be individually accessed + * or modified by passing the flag id into GET_EVENTINF, SET_EVENTINF, or CLEAR_EVENTINF + * + * In some instances where a set of flags share a common accociation, the eventInf variable will be accessed directly. + * When this is the case, an EVENTINF_*_INDEX constant is defined for accessing a specific eventInf variable. */ -// 0x00-0x0F -// horses related -#define EVENTINF_HORSES_INDEX 0 -#define EVENTINF_HORSES_STATE_SHIFT 0 -#define EVENTINF_HORSES_HORSETYPE_SHIFT 4 -#define EVENTINF_HORSES_05_SHIFT 5 -#define EVENTINF_HORSES_06_SHIFT 6 -#define EVENTINF_HORSES_08_SHIFT 8 -#define EVENTINF_HORSES_0A_SHIFT 10 -#define EVENTINF_HORSES_0F_SHIFT 15 // unused? -#define EVENTINF_HORSES_STATE_MASK (0xF << EVENTINF_HORSES_STATE_SHIFT) -#define EVENTINF_HORSES_HORSETYPE_MASK (1 << EVENTINF_HORSES_HORSETYPE_SHIFT) -#define EVENTINF_HORSES_05_MASK (1 << EVENTINF_HORSES_05_SHIFT) -#define EVENTINF_HORSES_06_MASK (1 << EVENTINF_HORSES_06_SHIFT) -#define EVENTINF_HORSES_0F_MASK (1 << EVENTINF_HORSES_0F_SHIFT) -#define EVENTINF_HORSES_05 ((EVENTINF_HORSES_INDEX << 4) | EVENTINF_HORSES_05_SHIFT) -#define EVENTINF_HORSES_06 ((EVENTINF_HORSES_INDEX << 4) | EVENTINF_HORSES_06_SHIFT) +#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 +// Ingo Race, Lon Lon Ranch minigames, and Horseback Archery minigame flags +#define EVENTINF_INGORACE_INDEX (0x00 >> 4) +// EVENTINF 0x00-0x03 reserved for IngoRaceState +#define EVENTINF_INGORACE_STATE_MASK \ + (GET_EVENTINF_MASK(0x00) | GET_EVENTINF_MASK(0x01) | GET_EVENTINF_MASK(0x02) | GET_EVENTINF_MASK(0x03)) + +typedef enum IngoRaceState { + /* 0 */ INGORACE_STATE_OFFER_RENTAL, + /* 1 */ INGORACE_STATE_HORSE_RENTAL_PERIOD, + /* 2 */ INGORACE_STATE_RACING, + /* 3 */ INGORACE_STATE_PLAYER_LOSE, + /* 4 */ INGORACE_STATE_FIRST_WIN, + /* 5 */ INGORACE_STATE_TRAPPED_WIN_UNUSED, + /* 6 */ INGORACE_STATE_TRAPPED_WIN_EPONA, // Ingo Traps you in Lon Lon + /* 7 */ INGORACE_STATE_REMATCH +} IngoRaceState; + +#define EVENTINF_INGORACE_HORSETYPE 0x04 +#define EVENTINF_INGORACE_LOST_ONCE 0x05 +#define EVENTINF_INGORACE_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 ((EVENTINF_HORSES_INDEX << 4) | EVENTINF_HORSES_08_SHIFT) +#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 ((EVENTINF_HORSES_INDEX << 4) | EVENTINF_HORSES_0A_SHIFT) +#define EVENTINF_HORSES_0A 0x0A #define EVENTINF_CUCCO_GAME_FINISHED EVENTINF_HORSES_0A - -typedef enum EventInfHorsesState { - /* 0 */ EVENTINF_HORSES_STATE_0, - /* 1 */ EVENTINF_HORSES_STATE_1, - /* 2 */ EVENTINF_HORSES_STATE_2, - /* 3 */ EVENTINF_HORSES_STATE_3, - /* 4 */ EVENTINF_HORSES_STATE_4, - /* 5 */ EVENTINF_HORSES_STATE_5, - /* 6 */ EVENTINF_HORSES_STATE_6, - /* 7 */ EVENTINF_HORSES_STATE_7 -} EventInfHorsesState; +#define EVENTINF_INGORACE_0F 0x0F // unused? // "InRaceSeq" -#define GET_EVENTINF_HORSES_STATE() \ - ((gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & EVENTINF_HORSES_STATE_MASK) >> EVENTINF_HORSES_STATE_SHIFT) -#define SET_EVENTINF_HORSES_STATE(v) \ - gSaveContext.eventInf[EVENTINF_HORSES_INDEX] = \ - (gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & ~EVENTINF_HORSES_STATE_MASK) | \ - ((v) << EVENTINF_HORSES_STATE_SHIFT) +#define GET_EVENTINF_INGORACE_STATE() (gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] & EVENTINF_INGORACE_STATE_MASK) + +#define SET_EVENTINF_INGORACE_STATE(v) \ + gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] = \ + (gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] & ~EVENTINF_INGORACE_STATE_MASK) | (v) + +#define SET_EVENTINF_INGORACE_FLAG(flag) \ + gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] = \ + (gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] & 0xFFFF) | (1 << ((flag) & 0xF)) + +#define WRITE_EVENTINF_INGORACE_FLAG(flag, v) \ + gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] = \ + (gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] & ~(1 << ((flag)&0xF))) | ((v) << ((flag) & 0xF)) -#define GET_EVENTINF_HORSES_HORSETYPE() \ - ((gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & EVENTINF_HORSES_HORSETYPE_MASK) >> EVENTINF_HORSES_HORSETYPE_SHIFT) -#define SET_EVENTINF_HORSES_HORSETYPE(v) \ - gSaveContext.eventInf[EVENTINF_HORSES_INDEX] = \ - (gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & ~EVENTINF_HORSES_HORSETYPE_MASK) | \ - ((v) << EVENTINF_HORSES_HORSETYPE_SHIFT) +#define RESET_EVENTINF_INGORACE() \ + gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] &= \ + (u16) ~(EVENTINF_INGORACE_STATE_MASK | GET_EVENTINF_MASK(EVENTINF_INGORACE_HORSETYPE) | \ + GET_EVENTINF_MASK(EVENTINF_INGORACE_LOST_ONCE) | GET_EVENTINF_MASK(EVENTINF_INGORACE_SECOND_RACE) | \ + GET_EVENTINF_MASK(EVENTINF_INGORACE_0F)) -#define SET_EVENTINF_HORSES_0F(v) \ - gSaveContext.eventInf[EVENTINF_HORSES_INDEX] = \ - (gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & ~EVENTINF_HORSES_0F_MASK) | ((v) << EVENTINF_HORSES_0F_SHIFT) +#define GET_EVENTINF_INGORACE_HORSETYPE() \ + (GET_EVENTINF(EVENTINF_INGORACE_HORSETYPE) >> (EVENTINF_INGORACE_HORSETYPE & 0xF)) +#define WRITE_EVENTINF_INGORACE_HORSETYPE(v) WRITE_EVENTINF_INGORACE_FLAG(EVENTINF_INGORACE_HORSETYPE, v) +#define WRITE_EVENTINF_INGORACE_0F(v) WRITE_EVENTINF_INGORACE_FLAG(EVENTINF_INGORACE_0F, v) // Is the running man race active #define EVENTINF_MARATHON_ACTIVE 0x10 -// 0x20-0x24 -#define EVENTINF_20_21_22_23_24_INDEX 2 -#define EVENTINF_20_MASK (1 << 0) -#define EVENTINF_21_MASK (1 << 1) -#define EVENTINF_22_MASK (1 << 2) -#define EVENTINF_23_MASK (1 << 3) -#define EVENTINF_24_MASK (1 << 4) +// EVENTINF 0x20-0x24 +#define EVENTINF_HAGGLING_TOWNSFOLK_INDEX (EVENTINF_20 >> 4) +#define EVENTINF_20 0x20 +#define EVENTINF_21 0x21 +#define EVENTINF_22 0x22 +#define EVENTINF_23 0x23 +#define EVENTINF_24 0x24 -#define EVENTINF_30 0x30 +#define EVENTINF_HAGGLING_TOWNSFOLK_MASK \ + (GET_EVENTINF_MASK(EVENTINF_20) | GET_EVENTINF_MASK(EVENTINF_21) | GET_EVENTINF_MASK(EVENTINF_22) | \ + GET_EVENTINF_MASK(EVENTINF_23) | GET_EVENTINF_MASK(EVENTINF_24)) +#define ENMU_GET_TALK_FLAGS() \ + gSaveContext.eventInf[EVENTINF_HAGGLING_TOWNSFOLK_INDEX] & EVENTINF_HAGGLING_TOWNSFOLK_MASK -#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 ENMU_RESET_TALK_FLAGS() \ + gSaveContext.eventInf[EVENTINF_HAGGLING_TOWNSFOLK_INDEX] &= ~(EVENTINF_HAGGLING_TOWNSFOLK_MASK); + +#define EVENTINF_30 0x30 extern SaveContext gSaveContext; diff --git a/src/code/z_horse.c b/src/code/z_horse.c index d3d66c3de62..af869513f59 100644 --- a/src/code/z_horse.c +++ b/src/code/z_horse.c @@ -173,7 +173,8 @@ void func_8006D684(PlayState* play, Player* player) { Actor_MountHorse(play, player, player->rideActor); func_8002DE74(play, player); gSaveContext.save.info.horseData.sceneId = play->sceneId; - } else if ((play->sceneId == SCENE_LON_LON_RANCH) && (GET_EVENTINF_HORSES_STATE() == EVENTINF_HORSES_STATE_6) && + } else if ((play->sceneId == SCENE_LON_LON_RANCH) && + (GET_EVENTINF_INGORACE_STATE() == INGORACE_STATE_TRAPPED_WIN_EPONA) && !Flags_GetEventChkInf(EVENTCHKINF_EPONA_OBTAINED) && (DREG(1) == 0)) { player->rideActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, 894.0f, 0.0f, -2084.0f, 0, -0x7FFF, 0, 5); @@ -209,7 +210,7 @@ void func_8006D684(PlayState* play, Player* player) { Vec3f sp54; s32 temp = 0; - if (GET_EVENTINF_HORSES_HORSETYPE() != HORSE_EPONA && D_8011F9B8[i].type == 6) { + if (GET_EVENTINF_INGORACE_HORSETYPE() != HORSE_EPONA && D_8011F9B8[i].type == 6) { temp = 0x8000; } @@ -260,7 +261,8 @@ void func_8006DC68(PlayState* play, Player* player) { gSaveContext.save.entranceIndex == ENTR_HYRULE_FIELD_13 || gSaveContext.save.entranceIndex == ENTR_HYRULE_FIELD_15) && (gSaveContext.respawnFlag == 0)) || - ((play->sceneId == SCENE_LON_LON_RANCH) && (GET_EVENTINF_HORSES_STATE() == EVENTINF_HORSES_STATE_6) && + ((play->sceneId == SCENE_LON_LON_RANCH) && + (GET_EVENTINF_INGORACE_STATE() == INGORACE_STATE_TRAPPED_WIN_EPONA) && !Flags_GetEventChkInf(EVENTCHKINF_EPONA_OBTAINED) && (DREG(1) == 0))) { func_8006D684(play, player); } else { diff --git a/src/code/z_map_data.c b/src/code/z_map_data.c index 24721c6234c..380add3e646 100644 --- a/src/code/z_map_data.c +++ b/src/code/z_map_data.c @@ -240,25 +240,25 @@ static s16 sOwEntranceIconPosY[24] = { static u16 sOwEntranceFlag[20] = { 0xFFFF, - INFTABLE_1A8_SHIFT, - INFTABLE_1A7_SHIFT, + MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A8), + MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A7), 0xFFFF, - INFTABLE_1A0_SHIFT, - INFTABLE_1A3_SHIFT, - INFTABLE_1A5_SHIFT, + MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A0), + MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A3), + MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A5), 0xFFFF, - INFTABLE_1A2_SHIFT, + MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A2), 0xFFFF, 0xFFFF, - INFTABLE_1A6_SHIFT, - INFTABLE_1AB_SHIFT, + MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A6), + MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1AB), 0xFFFF, 0xFFFF, - INFTABLE_1A1_SHIFT, - INFTABLE_1A4_SHIFT, + MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A1), + MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A4), 0xFFFF, 0xFFFF, - INFTABLE_1AD_SHIFT, + MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1AD), }; static f32 sFloorCoordY[10][8] = { diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c index 1c82288b7ad..ca9243ba5e6 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_OVERWORLD_ENTRANCE_ICON_INDEX] & gBitFlags[gMapData->owEntranceFlag[mapIndex]]))) { gDPLoadTextureBlock(OVERLAY_DISP++, gMapDungeonEntranceIconTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, @@ -512,8 +512,7 @@ void Minimap_Draw(PlayState* play) { } } - if ((play->sceneId == SCENE_ZORAS_FOUNTAIN) && - (gSaveContext.save.info.infTable[INFTABLE_1AX_INDEX] & gBitFlags[INFTABLE_1A9_SHIFT])) { + if ((play->sceneId == SCENE_ZORAS_FOUNTAIN) && (MINIMAP_GET_INFTABLE(INFTABLE_1A9))) { 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_message.c b/src/code/z_message.c index 368a53723e5..c348f776dbf 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -3444,7 +3444,7 @@ void Message_DrawMain(PlayState* play, Gfx** p) { if (msgCtx->disableWarpSongs || interfaceCtx->restrictions.warpSongs == 3) { Message_StartTextbox(play, 0x88C, NULL); // "You can't warp here!" play->msgCtx.ocarinaMode = OCARINA_MODE_04; - } else if (GET_EVENTINF_HORSES_STATE() != EVENTINF_HORSES_STATE_1) { + } else if (GET_EVENTINF_INGORACE_STATE() != INGORACE_STATE_HORSE_RENTAL_PERIOD) { Message_StartTextbox(play, msgCtx->lastPlayedSong + 0x88D, NULL); // "Warp to [place name]?" play->msgCtx.ocarinaMode = OCARINA_MODE_01; @@ -4247,7 +4247,7 @@ void Message_Update(PlayState* play) { if (Message_ShouldAdvance(play)) { PRINTF("OCARINA_MODE=%d -> ", play->msgCtx.ocarinaMode); play->msgCtx.ocarinaMode = (msgCtx->choiceIndex == 0) ? OCARINA_MODE_02 : OCARINA_MODE_04; - PRINTF("InRaceSeq=%d(%d) OCARINA_MODE=%d --> ", GET_EVENTINF_HORSES_STATE(), 1, + PRINTF("InRaceSeq=%d(%d) OCARINA_MODE=%d --> ", GET_EVENTINF_INGORACE_STATE(), 1, play->msgCtx.ocarinaMode); Message_CloseTextbox(play); PRINTF("OCARINA_MODE=%d\n", play->msgCtx.ocarinaMode); diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 74b0ef5eea0..d0d7c73eb85 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -790,7 +790,7 @@ void func_80083108(PlayState* play) { gSaveContext.hudVisibilityMode = HUD_VISIBILITY_NO_CHANGE; Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_ALL); } - } else if (GET_EVENTINF_HORSES_STATE() == EVENTINF_HORSES_STATE_1) { + } else if (GET_EVENTINF_INGORACE_STATE() == INGORACE_STATE_HORSE_RENTAL_PERIOD) { if (player->stateFlags1 & PLAYER_STATE1_23) { if ((gSaveContext.save.info.equips.buttonItems[0] != ITEM_NONE) && (gSaveContext.save.info.equips.buttonItems[0] != ITEM_BOW)) { @@ -3543,10 +3543,8 @@ 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] &= - (u16) ~(EVENTINF_HORSES_STATE_MASK | EVENTINF_HORSES_HORSETYPE_MASK | EVENTINF_HORSES_05_MASK | - EVENTINF_HORSES_06_MASK | EVENTINF_HORSES_0F_MASK); - PRINTF("EVENT_INF=%x\n", gSaveContext.eventInf[EVENTINF_HORSES_INDEX]); + RESET_EVENTINF_INGORACE(); + PRINTF("EVENT_INF=%x\n", gSaveContext.eventInf[EVENTINF_INGORACE_INDEX]); #endif play->nextEntranceIndex = spoilingItemEntrances[svar1]; INV_CONTENT(gSpoilingItemReverts[svar1]) = gSpoilingItemReverts[svar1]; 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 567b141e722..92ac8eafdd8 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 @@ -242,17 +242,17 @@ void BgDyYoseizo_ChooseType(BgDyYoseizo* this, PlayState* play) { if (play->sceneId != SCENE_GREAT_FAIRYS_FOUNTAIN_MAGIC) { switch (this->fountainType) { case FAIRY_SPELL_FARORES_WIND: - if (!GET_ITEMGETINF(ITEMGETINF_18)) { + if (!GET_ITEMGETINF(ITEMGETINF_FARORES_WIND)) { givingReward = true; } break; case FAIRY_SPELL_DINS_FIRE: - if (!GET_ITEMGETINF(ITEMGETINF_19)) { + if (!GET_ITEMGETINF(ITEMGETINF_DINS_FIRE)) { givingReward = true; } break; case FAIRY_SPELL_NAYRUS_LOVE: - if (!GET_ITEMGETINF(ITEMGETINF_1A)) { + if (!GET_ITEMGETINF(ITEMGETINF_NAYRUS_LOVE)) { givingReward = true; } break; @@ -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 sItemGetFlags[] = { GET_ITEMGETINF_MASK(ITEMGETINF_FARORES_WIND), GET_ITEMGETINF_MASK(ITEMGETINF_DINS_FIRE), + GET_ITEMGETINF_MASK(ITEMGETINF_NAYRUS_LOVE) }; 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_GREAT_FAIRY_ITEM_INDEX] |= sItemGetFlags[cueIdTemp]; Item_Give(play, sItemIds[cueIdTemp]); } } else { diff --git a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c index a9dd2adfa5c..2bd5aac1d28 100644 --- a/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c +++ b/src/overlays/actors/ovl_Bg_Ingate/z_bg_ingate.c @@ -52,7 +52,7 @@ void BgInGate_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->dyna.actor, 0.1f); if ((PARAMS_GET_U(this->dyna.actor.params, 0, 1) != 0) && - (GET_EVENTINF_HORSES_STATE() == EVENTINF_HORSES_STATE_6)) { + (GET_EVENTINF_INGORACE_STATE() == INGORACE_STATE_TRAPPED_WIN_EPONA)) { play->csCtx.curFrame = 0; BgInGate_SetupAction(this, func_80892890); } 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 2cce0323441..b69c6423357 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,8 +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] & - EVENTCHKINF_CARPENTERS_FREE_MASK_ALL); + GET_EVENTCHKINF_CARPENTERS_FREE_FLAGS()); this->dyna.actor.params &= 0xFF; if ((this->dyna.actor.params < 0) || (this->dyna.actor.params >= 5)) { PRINTF("Error : Spot 09 object の arg_data が判別出来ない(%s %d)(arg_data 0x%04x)\n", "../z_bg_spot09_obj.c", 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 0f84c7784a9..1305fe24452 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.c @@ -4,6 +4,8 @@ #define FLAGS (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_4) +#define ENDAIKU_GET_TYPE(thisx) PARAMS_GET_U((thisx)->params, 0, 2) + typedef struct EnDaikuEscapeSubCamParam { Vec3f eyePosDeltaLocal; s32 maxFramesActive; @@ -152,13 +154,13 @@ void EnDaiku_Init(Actor* thisx, PlayState* play) { s32 noKill = true; s32 isFree = false; - if (PARAMS_GET_U(this->actor.params, 0, 2) == 0 && GET_EVENTCHKINF(EVENTCHKINF_CARPENTERS_FREE(0))) { + if (ENDAIKU_GET_TYPE(&this->actor) == ENDAIKU_TYPE0 && GET_EVENTCHKINF(EVENTCHKINF_CARPENTER_0_FREED)) { isFree = true; - } else if (PARAMS_GET_U(this->actor.params, 0, 2) == 1 && GET_EVENTCHKINF(EVENTCHKINF_CARPENTERS_FREE(1))) { + } else if (ENDAIKU_GET_TYPE(&this->actor) == ENDAIKU_TYPE1 && GET_EVENTCHKINF(EVENTCHKINF_CARPENTER_1_FREED)) { isFree = true; - } else if (PARAMS_GET_U(this->actor.params, 0, 2) == 2 && GET_EVENTCHKINF(EVENTCHKINF_CARPENTERS_FREE(2))) { + } else if (ENDAIKU_GET_TYPE(&this->actor) == ENDAIKU_TYPE2 && GET_EVENTCHKINF(EVENTCHKINF_CARPENTER_2_FREED)) { isFree = true; - } else if (PARAMS_GET_U(this->actor.params, 0, 2) == 3 && GET_EVENTCHKINF(EVENTCHKINF_CARPENTERS_FREE(3))) { + } else if (ENDAIKU_GET_TYPE(&this->actor) == ENDAIKU_TYPE3 && GET_EVENTCHKINF(EVENTCHKINF_CARPENTER_3_FREED)) { isFree = true; } @@ -200,7 +202,7 @@ void EnDaiku_Init(Actor* thisx, PlayState* play) { this->stateFlags |= ENDAIKU_STATEFLAG_1 | ENDAIKU_STATEFLAG_2; this->actionFunc = EnDaiku_Jailed; } else { - if (PARAMS_GET_U(this->actor.params, 0, 2) == 1 || PARAMS_GET_U(this->actor.params, 0, 2) == 3) { + if (ENDAIKU_GET_TYPE(&this->actor) == ENDAIKU_TYPE1 || ENDAIKU_GET_TYPE(&this->actor) == ENDAIKU_TYPE3) { EnDaiku_ChangeAnim(this, ENDAIKU_ANIM_SIT, &this->currentAnimIndex); this->stateFlags |= ENDAIKU_STATEFLAG_1; } else { @@ -270,8 +272,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] & - EVENTCHKINF_CARPENTERS_FREE_MASK(carpenterType)) { + if (ENDAIKU_IS_CARPENTER_FREE(carpenterType)) { freedCount++; } } @@ -295,15 +296,15 @@ void EnDaiku_UpdateText(EnDaiku* this, PlayState* play) { this->actor.textId = 0x6007; } } else if (play->sceneId == SCENE_CARPENTERS_TENT) { - switch (PARAMS_GET_U(this->actor.params, 0, 2)) { - case 0: + switch (ENDAIKU_GET_TYPE(&this->actor)) { + case ENDAIKU_TYPE0: if (CHECK_QUEST_ITEM(QUEST_MEDALLION_SPIRIT)) { this->actor.textId = 0x6060; } else { this->actor.textId = 0x605F; } break; - case 1: + case ENDAIKU_TYPE1: if (CHECK_QUEST_ITEM(QUEST_MEDALLION_SPIRIT)) { this->actor.textId = 0x6063; } else { @@ -314,7 +315,7 @@ void EnDaiku_UpdateText(EnDaiku* this, PlayState* play) { } } break; - case 2: + case ENDAIKU_TYPE2: if (CHECK_QUEST_ITEM(QUEST_MEDALLION_SPIRIT)) { this->actor.textId = 0x6066; } else { @@ -325,7 +326,7 @@ void EnDaiku_UpdateText(EnDaiku* this, PlayState* play) { } } break; - case 3: + case ENDAIKU_TYPE3: if (CHECK_QUEST_ITEM(QUEST_MEDALLION_SPIRIT)) { this->actor.textId = 0x6068; } else { @@ -399,11 +400,10 @@ 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] |= - EVENTCHKINF_CARPENTERS_FREE_MASK(PARAMS_GET_U(this->actor.params, 0, 2)); + ENDAIKU_SET_CARPENTER_FREE(ENDAIKU_GET_TYPE(&this->actor)); this->actor.gravity = -1.0f; - this->escapeSubCamTimer = sEscapeSubCamParams[PARAMS_GET_U(this->actor.params, 0, 2)].maxFramesActive; + this->escapeSubCamTimer = sEscapeSubCamParams[ENDAIKU_GET_TYPE(&this->actor)].maxFramesActive; EnDaiku_InitSubCamera(this, play); exitLoop = false; @@ -444,11 +444,11 @@ void EnDaiku_InitSubCamera(EnDaiku* this, PlayState* play) { Vec3f eyePosDeltaWorld; this->subCamActive = true; - this->escapeSubCamTimer = sEscapeSubCamParams[PARAMS_GET_U(this->actor.params, 0, 2)].maxFramesActive; + this->escapeSubCamTimer = sEscapeSubCamParams[ENDAIKU_GET_TYPE(&this->actor)].maxFramesActive; - eyePosDeltaLocal.x = sEscapeSubCamParams[PARAMS_GET_U(this->actor.params, 0, 2)].eyePosDeltaLocal.x; - eyePosDeltaLocal.y = sEscapeSubCamParams[PARAMS_GET_U(this->actor.params, 0, 2)].eyePosDeltaLocal.y; - eyePosDeltaLocal.z = sEscapeSubCamParams[PARAMS_GET_U(this->actor.params, 0, 2)].eyePosDeltaLocal.z; + eyePosDeltaLocal.x = sEscapeSubCamParams[ENDAIKU_GET_TYPE(&this->actor)].eyePosDeltaLocal.x; + eyePosDeltaLocal.y = sEscapeSubCamParams[ENDAIKU_GET_TYPE(&this->actor)].eyePosDeltaLocal.y; + eyePosDeltaLocal.z = sEscapeSubCamParams[ENDAIKU_GET_TYPE(&this->actor)].eyePosDeltaLocal.z; Matrix_RotateY(BINANG_TO_RAD(this->actor.world.rot.y), MTXMODE_NEW); Matrix_MultVec3f(&eyePosDeltaLocal, &eyePosDeltaWorld); @@ -594,13 +594,13 @@ void EnDaiku_Draw(Actor* thisx, PlayState* play) { Gfx_SetupDL_25Opa(play->state.gfxCtx); - if (PARAMS_GET_U(thisx->params, 0, 2) == 0) { + if (ENDAIKU_GET_TYPE(thisx) == ENDAIKU_TYPE0) { gDPSetEnvColor(POLY_OPA_DISP++, 170, 10, 70, 255); - } else if (PARAMS_GET_U(thisx->params, 0, 2) == 1) { + } else if (ENDAIKU_GET_TYPE(thisx) == ENDAIKU_TYPE1) { gDPSetEnvColor(POLY_OPA_DISP++, 170, 200, 255, 255); - } else if (PARAMS_GET_U(thisx->params, 0, 2) == 2) { + } else if (ENDAIKU_GET_TYPE(thisx) == ENDAIKU_TYPE2) { gDPSetEnvColor(POLY_OPA_DISP++, 0, 230, 70, 255); - } else if (PARAMS_GET_U(thisx->params, 0, 2) == 3) { + } else if (ENDAIKU_GET_TYPE(thisx) == ENDAIKU_TYPE3) { gDPSetEnvColor(POLY_OPA_DISP++, 200, 0, 150, 255); } @@ -637,7 +637,7 @@ void EnDaiku_PostLimbDraw(PlayState* play, s32 limb, Gfx** dList, Vec3s* rot, vo if (limb == 15) { // head Matrix_MultVec3f(&targetPosHeadLocal, &this->actor.focus.pos); - gSPDisplayList(POLY_OPA_DISP++, hairDLists[PARAMS_GET_U(this->actor.params, 0, 2)]); + gSPDisplayList(POLY_OPA_DISP++, hairDLists[ENDAIKU_GET_TYPE(&this->actor)]); } CLOSE_DISPS(play->state.gfxCtx, "../z_en_daiku.c", 1330); diff --git a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.h b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.h index 82b7a06346a..69136f6a925 100644 --- a/src/overlays/actors/ovl_En_Daiku/z_en_daiku.h +++ b/src/overlays/actors/ovl_En_Daiku/z_en_daiku.h @@ -8,6 +8,13 @@ struct EnDaiku; typedef void (*EnDaikuActionFunc)(struct EnDaiku*, PlayState*); +typedef enum EnDaikuType { + ENDAIKU_TYPE0, + ENDAIKU_TYPE1, + ENDAIKU_TYPE2, + ENDAIKU_TYPE3 +} EnDaikuType; + typedef struct EnDaiku { /* 0x0000 */ Actor actor; /* 0x014C */ SkelAnime skelAnime; 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 d1bbe15141f..ae571f718b7 100644 --- a/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ b/src/overlays/actors/ovl_En_Fr/z_en_fr.c @@ -114,14 +114,14 @@ static EnFrPointers sEnFrPointers = { 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_Ge1/z_en_ge1.c b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c index 6147ab7a256..5209da4b8f4 100644 --- a/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c +++ b/src/overlays/actors/ovl_En_Ge1/z_en_ge1.c @@ -208,8 +208,8 @@ void EnGe1_SetAnimationIdle(EnGe1* this) { } s32 EnGe1_CheckCarpentersFreed(void) { - if (!(GET_EVENTCHKINF(EVENTCHKINF_CARPENTERS_FREE(0)) && GET_EVENTCHKINF(EVENTCHKINF_CARPENTERS_FREE(1)) && - GET_EVENTCHKINF(EVENTCHKINF_CARPENTERS_FREE(2)) && GET_EVENTCHKINF(EVENTCHKINF_CARPENTERS_FREE(3)))) { + if (!(GET_EVENTCHKINF(EVENTCHKINF_CARPENTER_0_FREED) && GET_EVENTCHKINF(EVENTCHKINF_CARPENTER_1_FREED) && + GET_EVENTCHKINF(EVENTCHKINF_CARPENTER_2_FREED) && GET_EVENTCHKINF(EVENTCHKINF_CARPENTER_3_FREED))) { return false; } return true; 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 da5b3800829..613b6be2515 100644 --- a/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c +++ b/src/overlays/actors/ovl_En_Ge2/z_en_ge2.c @@ -224,12 +224,10 @@ 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] & - (EVENTCHKINF_CARPENTERS_FREE_MASK_ALL | 0xF0), - EVENTCHKINF_CARPENTERS_FREE_MASK_ALL)) { - return 1; + if (GET_EVENTCHKINF_CARPENTERS_FREE_ALL2()) { + return true; } - return 0; + return false; } // Actions diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 843427fc8b9..c6a1d33b407 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -678,7 +678,7 @@ s32 EnHorse_Spawn(EnHorse* this, PlayState* play) { if (play->sceneId != SCENE_LON_LON_RANCH || //! Same flag checked twice (Flags_GetEventChkInf(EVENTCHKINF_EPONA_OBTAINED) && - (GET_EVENTINF_HORSES_STATE() != EVENTINF_HORSES_STATE_6 || + (GET_EVENTINF_INGORACE_STATE() != INGORACE_STATE_TRAPPED_WIN_EPONA || Flags_GetEventChkInf(EVENTCHKINF_EPONA_OBTAINED))) || // always load two spawns inside lon lon ((sHorseSpawns[i].pos.x == 856 && sHorseSpawns[i].pos.y == 0 && sHorseSpawns[i].pos.z == -918) || @@ -797,7 +797,7 @@ void EnHorse_Init(Actor* thisx, PlayState* play2) { if (Flags_GetEventChkInf(EVENTCHKINF_EPONA_OBTAINED) || DREG(1) != 0) { this->stateFlags &= ~ENHORSE_CANT_JUMP; this->stateFlags |= ENHORSE_FLAG_26; - } else if (GET_EVENTINF(EVENTINF_HORSES_06) && this->type == HORSE_HNI) { + } else if (GET_EVENTINF(EVENTINF_INGORACE_SECOND_RACE) && this->type == HORSE_HNI) { this->stateFlags |= ENHORSE_FLAG_21 | ENHORSE_FLAG_20; } } else if (this->actor.params == 1) { @@ -807,7 +807,7 @@ void EnHorse_Init(Actor* thisx, PlayState* play2) { } } - if (play->sceneId == SCENE_LON_LON_RANCH && GET_EVENTINF_HORSES_STATE() == EVENTINF_HORSES_STATE_6 && + if (play->sceneId == SCENE_LON_LON_RANCH && GET_EVENTINF_INGORACE_STATE() == INGORACE_STATE_TRAPPED_WIN_EPONA && !Flags_GetEventChkInf(EVENTCHKINF_EPONA_OBTAINED) && !DREG(1)) { this->stateFlags |= ENHORSE_FLAG_25; } @@ -872,7 +872,7 @@ void EnHorse_Init(Actor* thisx, PlayState* play2) { this->rider = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_IN, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, this->actor.shape.rot.x, this->actor.shape.rot.y, 1, 1); ASSERT(this->rider != NULL, "this->race.rider != NULL", "../z_en_horse.c", 3077); - if (!GET_EVENTINF(EVENTINF_HORSES_06)) { + if (!GET_EVENTINF(EVENTINF_INGORACE_SECOND_RACE)) { this->ingoHorseMaxSpeed = 12.07f; } else { this->ingoHorseMaxSpeed = 12.625f; diff --git a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c index 839b25df2b0..e1746af43d4 100644 --- a/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c +++ b/src/overlays/actors/ovl_En_Horse_Game_Check/z_en_horse_game_check.c @@ -113,22 +113,22 @@ void EnHorseGameCheck_FinishIngoRace(EnHorseGameCheckIngoRace* this, PlayState* gSaveContext.save.cutsceneIndex = 0; if (this->result == INGORACE_PLAYER_WIN) { play->nextEntranceIndex = ENTR_LON_LON_RANCH_7; - if (GET_EVENTINF(EVENTINF_HORSES_06)) { - SET_EVENTINF_HORSES_STATE(EVENTINF_HORSES_STATE_6); - SET_EVENTINF_HORSES_0F(1); + if (GET_EVENTINF(EVENTINF_INGORACE_SECOND_RACE)) { + SET_EVENTINF_INGORACE_STATE(INGORACE_STATE_TRAPPED_WIN_EPONA); + WRITE_EVENTINF_INGORACE_0F(1); play->transitionType = TRANS_TYPE_FADE_WHITE; Environment_ForcePlaySequence(NA_BGM_INGO); } else { - SET_EVENTINF_HORSES_STATE(EVENTINF_HORSES_STATE_4); - SET_EVENTINF_HORSES_0F(1); + SET_EVENTINF_INGORACE_STATE(INGORACE_STATE_FIRST_WIN); + WRITE_EVENTINF_INGORACE_0F(1); Environment_ForcePlaySequence(NA_BGM_INGO); play->transitionType = TRANS_TYPE_CIRCLE(TCA_STARBURST, TCC_WHITE, TCS_FAST); } } else { play->nextEntranceIndex = ENTR_LON_LON_RANCH_8; - SET_EVENTINF_HORSES_STATE(EVENTINF_HORSES_STATE_3); + SET_EVENTINF_INGORACE_STATE(INGORACE_STATE_PLAYER_LOSE); play->transitionType = TRANS_TYPE_CIRCLE(TCA_NORMAL, TCC_BLACK, TCS_FAST); - SET_EVENTINF_HORSES_0F(1); + WRITE_EVENTINF_INGORACE_0F(1); } DREG(25) = 0; play->transitionTrigger = TRANS_TRIGGER_START; 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 9ac751d4e7f..e4184af8a4c 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 (ENHY_CHECK_COPY_EVENTCHKINF(this->talonEventChkInf, 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 (ENHY_CHECK_COPY_EVENTCHKINF(this->talonEventChkInf, 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 = ENHY_GET_COPY_EVENTCHKINF(EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO); } EnHy_InitSetProperties(this); 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 acb7c46e395..308c479baa7 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -140,8 +140,8 @@ u16 EnIn_GetTextIdAdult(PlayState* play) { if (IS_NIGHT) { return 0x204E; } - switch (GET_EVENTINF_HORSES_STATE()) { - case EVENTINF_HORSES_STATE_1: + switch (GET_EVENTINF_INGORACE_STATE()) { + case INGORACE_STATE_HORSE_RENTAL_PERIOD: if (!(player->stateFlags1 & PLAYER_STATE1_23)) { return 0x2036; } else if (GET_EVENTCHKINF(EVENTCHKINF_1B)) { @@ -153,20 +153,20 @@ u16 EnIn_GetTextIdAdult(PlayState* play) { } else { return 0x2037; } - case EVENTINF_HORSES_STATE_3: - if (GET_EVENTINF(EVENTINF_HORSES_06) || GET_EVENTINF(EVENTINF_HORSES_05)) { + case INGORACE_STATE_PLAYER_LOSE: + if (GET_EVENTINF(EVENTINF_INGORACE_SECOND_RACE) || GET_EVENTINF(EVENTINF_INGORACE_LOST_ONCE)) { return 0x203E; } else { return 0x203D; } - case EVENTINF_HORSES_STATE_4: + case INGORACE_STATE_FIRST_WIN: return 0x203A; - case EVENTINF_HORSES_STATE_5: - case EVENTINF_HORSES_STATE_6: + case INGORACE_STATE_TRAPPED_WIN_UNUSED: + case INGORACE_STATE_TRAPPED_WIN_EPONA: return 0x203C; - case EVENTINF_HORSES_STATE_7: + case INGORACE_STATE_REMATCH: return 0x205B; - case EVENTINF_HORSES_STATE_2: + case INGORACE_STATE_RACING: default: if (GET_INFTABLE(INFTABLE_9A)) { return 0x2031; @@ -256,9 +256,9 @@ s16 EnIn_UpdateTalkStateOnChoice(PlayState* play, Actor* thisx) { talkState = NPC_TALK_STATE_ACTION; } else { Message_ContinueTextbox(play, this->actor.textId = 0x2039); - SET_EVENTINF_HORSES_STATE(EVENTINF_HORSES_STATE_0); - CLEAR_EVENTINF(EVENTINF_HORSES_05); - CLEAR_EVENTINF(EVENTINF_HORSES_06); + SET_EVENTINF_INGORACE_STATE(INGORACE_STATE_OFFER_RENTAL); + CLEAR_EVENTINF(EVENTINF_INGORACE_LOST_ONCE); + CLEAR_EVENTINF(EVENTINF_INGORACE_SECOND_RACE); this->actionFunc = func_80A7A4C8; } break; @@ -489,7 +489,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_INGORACE_INDEX] = 0; D_80A7B998 = 1; } this->actionFunc = EnIn_WaitForObject; @@ -515,7 +515,7 @@ void EnIn_WaitForObject(EnIn* this, PlayState* play) { Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sColChkInfoInit); if (func_80A7975C(this, play)) { - SET_EVENTINF_HORSES_0F(0); + WRITE_EVENTINF_INGORACE_0F(0); return; } Actor_SetScale(&this->actor, 0.01f); @@ -544,23 +544,23 @@ void EnIn_WaitForObject(EnIn* this, PlayState* play) { Actor_Kill(&this->actor); break; default: - switch (GET_EVENTINF_HORSES_STATE()) { - case EVENTINF_HORSES_STATE_0: - case EVENTINF_HORSES_STATE_2: - case EVENTINF_HORSES_STATE_3: - case EVENTINF_HORSES_STATE_4: - case EVENTINF_HORSES_STATE_7: + switch (GET_EVENTINF_INGORACE_STATE()) { + case INGORACE_STATE_OFFER_RENTAL: + case INGORACE_STATE_RACING: + case INGORACE_STATE_PLAYER_LOSE: + case INGORACE_STATE_FIRST_WIN: + case INGORACE_STATE_REMATCH: if (this->actor.params == 2) { sp3C = 1; } break; - case EVENTINF_HORSES_STATE_1: + case INGORACE_STATE_HORSE_RENTAL_PERIOD: if (this->actor.params == 3) { sp3C = 1; } break; - case EVENTINF_HORSES_STATE_5: - case EVENTINF_HORSES_STATE_6: + case INGORACE_STATE_TRAPPED_WIN_UNUSED: + case INGORACE_STATE_TRAPPED_WIN_EPONA: if (this->actor.params == 4) { sp3C = 1; } @@ -570,36 +570,36 @@ void EnIn_WaitForObject(EnIn* this, PlayState* play) { Actor_Kill(&this->actor); return; } - switch (GET_EVENTINF_HORSES_STATE()) { - case EVENTINF_HORSES_STATE_0: - case EVENTINF_HORSES_STATE_2: + switch (GET_EVENTINF_INGORACE_STATE()) { + case INGORACE_STATE_OFFER_RENTAL: + case INGORACE_STATE_RACING: EnIn_ChangeAnim(this, ENIN_ANIM_2); this->actionFunc = func_80A7A4C8; - gSaveContext.eventInf[EVENTINF_HORSES_INDEX] = 0; + gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] = 0; break; - case EVENTINF_HORSES_STATE_1: + case INGORACE_STATE_HORSE_RENTAL_PERIOD: this->actor.attentionRangeType = ATTENTION_RANGE_3; EnIn_ChangeAnim(this, ENIN_ANIM_2); this->actionFunc = func_80A7A568; Interface_SetTimer(60); break; - case EVENTINF_HORSES_STATE_3: + case INGORACE_STATE_PLAYER_LOSE: EnIn_ChangeAnim(this, ENIN_ANIM_4); this->actionFunc = func_80A7A770; break; - case EVENTINF_HORSES_STATE_4: + case INGORACE_STATE_FIRST_WIN: EnIn_ChangeAnim(this, ENIN_ANIM_6); this->unk_1EC = 8; this->actionFunc = func_80A7A940; break; - case EVENTINF_HORSES_STATE_5: - case EVENTINF_HORSES_STATE_6: + case INGORACE_STATE_TRAPPED_WIN_UNUSED: + case INGORACE_STATE_TRAPPED_WIN_EPONA: this->actor.attentionRangeType = ATTENTION_RANGE_3; EnIn_ChangeAnim(this, ENIN_ANIM_6); this->unk_1EC = 8; this->actionFunc = func_80A7AA40; break; - case EVENTINF_HORSES_STATE_7: + case INGORACE_STATE_REMATCH: EnIn_ChangeAnim(this, ENIN_ANIM_2); this->actionFunc = func_80A7A848; break; @@ -640,8 +640,8 @@ void func_80A7A4BC(EnIn* this, PlayState* play) { void func_80A7A4C8(EnIn* this, PlayState* play) { if (this->interactInfo.talkState == NPC_TALK_STATE_ACTION) { func_80A79BAC(this, play, 1, TRANS_TYPE_CIRCLE(TCA_NORMAL, TCC_BLACK, TCS_FAST)); - SET_EVENTINF_HORSES_STATE(EVENTINF_HORSES_STATE_1); - SET_EVENTINF_HORSES_0F(1); + SET_EVENTINF_INGORACE_STATE(INGORACE_STATE_HORSE_RENTAL_PERIOD); + WRITE_EVENTINF_INGORACE_0F(1); CLEAR_INFTABLE(INFTABLE_A2); Environment_ForcePlaySequence(NA_BGM_HORSE); play->msgCtx.stateTimer = 0; @@ -672,8 +672,8 @@ void func_80A7A568(EnIn* this, PlayState* play) { this->interactInfo.talkState = NPC_TALK_STATE_IDLE; return; } - SET_EVENTINF_HORSES_HORSETYPE(((EnHorse*)GET_PLAYER(play)->rideActor)->type); - SET_EVENTINF_HORSES_STATE(EVENTINF_HORSES_STATE_2); + WRITE_EVENTINF_INGORACE_HORSETYPE(((EnHorse*)GET_PLAYER(play)->rideActor)->type); + SET_EVENTINF_INGORACE_STATE(INGORACE_STATE_RACING); phi_a2 = 2; transitionType = TRANS_TYPE_FADE_BLACK; } else { @@ -685,13 +685,13 @@ void func_80A7A568(EnIn* this, PlayState* play) { SET_INFTABLE(INFTABLE_AB); } } - SET_EVENTINF_HORSES_STATE(EVENTINF_HORSES_STATE_0); + SET_EVENTINF_INGORACE_STATE(INGORACE_STATE_OFFER_RENTAL); phi_a2 = 0; transitionType = TRANS_TYPE_CIRCLE(TCA_NORMAL, TCC_BLACK, TCS_FAST); } func_80A79BAC(this, play, phi_a2, transitionType); play->msgCtx.stateTimer = 0; - SET_EVENTINF_HORSES_0F(1); + WRITE_EVENTINF_INGORACE_0F(1); play->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; this->interactInfo.talkState = NPC_TALK_STATE_IDLE; } @@ -705,11 +705,10 @@ void func_80A7A770(EnIn* this, PlayState* play) { this->actor.flags &= ~ACTOR_FLAG_TALK_OFFER_AUTO_ACCEPTED; EnIn_ChangeAnim(this, ENIN_ANIM_3); this->actionFunc = func_80A7A848; - SET_EVENTINF_HORSES_STATE(EVENTINF_HORSES_STATE_7); + SET_EVENTINF_INGORACE_STATE(INGORACE_STATE_REMATCH); this->interactInfo.talkState = NPC_TALK_STATE_IDLE; - gSaveContext.eventInf[EVENTINF_HORSES_INDEX] = - (gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & 0xFFFF) | EVENTINF_HORSES_05_MASK; - if (!GET_EVENTINF(EVENTINF_HORSES_06)) { + SET_EVENTINF_INGORACE_FLAG(EVENTINF_INGORACE_LOST_ONCE); + if (!GET_EVENTINF(EVENTINF_INGORACE_SECOND_RACE)) { play->msgCtx.stateTimer = 4; play->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; } @@ -720,18 +719,18 @@ void func_80A7A848(EnIn* this, PlayState* play) { if (this->interactInfo.talkState == NPC_TALK_STATE_ACTION) { if ((play->msgCtx.choiceIndex == 0 && gSaveContext.save.info.playerData.rupees < 50) || play->msgCtx.choiceIndex == 1) { - SET_EVENTINF_HORSES_STATE(EVENTINF_HORSES_STATE_0); + SET_EVENTINF_INGORACE_STATE(INGORACE_STATE_OFFER_RENTAL); this->actionFunc = func_80A7A4C8; } else { func_80A79BAC(this, play, 2, TRANS_TYPE_CIRCLE(TCA_STARBURST, TCC_BLACK, TCS_FAST)); - SET_EVENTINF_HORSES_STATE(EVENTINF_HORSES_STATE_2); - SET_EVENTINF_HORSES_0F(1); + SET_EVENTINF_INGORACE_STATE(INGORACE_STATE_RACING); + WRITE_EVENTINF_INGORACE_0F(1); play->msgCtx.stateTimer = 0; play->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; } this->interactInfo.talkState = NPC_TALK_STATE_IDLE; - CLEAR_EVENTINF(EVENTINF_HORSES_05); - CLEAR_EVENTINF(EVENTINF_HORSES_06); + CLEAR_EVENTINF(EVENTINF_INGORACE_LOST_ONCE); + CLEAR_EVENTINF(EVENTINF_INGORACE_SECOND_RACE); } } @@ -749,13 +748,12 @@ void func_80A7A940(EnIn* this, PlayState* play) { if (this->interactInfo.talkState == NPC_TALK_STATE_ACTION) { this->actor.flags &= ~ACTOR_FLAG_TALK_OFFER_AUTO_ACCEPTED; func_80A79BAC(this, play, 2, TRANS_TYPE_CIRCLE(TCA_STARBURST, TCC_BLACK, TCS_FAST)); - SET_EVENTINF_HORSES_STATE(EVENTINF_HORSES_STATE_2); - SET_EVENTINF_HORSES_0F(1); + SET_EVENTINF_INGORACE_STATE(INGORACE_STATE_RACING); + WRITE_EVENTINF_INGORACE_0F(1); play->msgCtx.stateTimer = 0; play->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; this->interactInfo.talkState = NPC_TALK_STATE_IDLE; - gSaveContext.eventInf[EVENTINF_HORSES_INDEX] = - (gSaveContext.eventInf[EVENTINF_HORSES_INDEX] & 0xFFFF) | EVENTINF_HORSES_06_MASK; + SET_EVENTINF_INGORACE_FLAG(EVENTINF_INGORACE_SECOND_RACE); } } @@ -904,8 +902,8 @@ void func_80A7B024(EnIn* this, PlayState* play) { } func_80A79BAC(this, play, 0, TRANS_TYPE_CIRCLE(TCA_STARBURST, TCC_BLACK, TCS_FAST)); - SET_EVENTINF_HORSES_STATE(EVENTINF_HORSES_STATE_0); - SET_EVENTINF_HORSES_0F(1); + SET_EVENTINF_INGORACE_STATE(INGORACE_STATE_OFFER_RENTAL); + WRITE_EVENTINF_INGORACE_0F(1); play->msgCtx.stateTimer = 4; play->msgCtx.msgMode = MSGMODE_TEXT_CLOSING; this->interactInfo.talkState = NPC_TALK_STATE_IDLE; @@ -925,7 +923,7 @@ void EnIn_Update(Actor* thisx, PlayState* play) { if (this->actionFunc != func_80A7A304) { SkelAnime_Update(&this->skelAnime); if (this->skelAnime.animation == &object_in_Anim_001BE0 && - GET_EVENTINF_HORSES_STATE() != EVENTINF_HORSES_STATE_6) { + GET_EVENTINF_INGORACE_STATE() != INGORACE_STATE_TRAPPED_WIN_EPONA) { func_80A79690(&this->skelAnime, this, play); } Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_2); 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 4e50a89e085..3c24ecbec27 100644 --- a/src/overlays/actors/ovl_En_Mu/z_en_mu.c +++ b/src/overlays/actors/ovl_En_Mu/z_en_mu.c @@ -58,16 +58,15 @@ void EnMu_SetupAction(EnMu* this, EnMuActionFunc actionFunc) { void EnMu_Interact(EnMu* this, PlayState* play) { u8 textIdOffset[] = { 0x42, 0x43, 0x3F, 0x41, 0x3E }; u8 bitmask[] = { - EVENTINF_20_MASK, EVENTINF_21_MASK, EVENTINF_22_MASK, EVENTINF_23_MASK, EVENTINF_24_MASK, + GET_EVENTINF_MASK(EVENTINF_20), GET_EVENTINF_MASK(EVENTINF_21), GET_EVENTINF_MASK(EVENTINF_22), + GET_EVENTINF_MASK(EVENTINF_23), GET_EVENTINF_MASK(EVENTINF_24), }; u8 textFlags; s32 randomIndex; s32 i; - textFlags = gSaveContext.eventInf[EVENTINF_20_21_22_23_24_INDEX] & - (EVENTINF_20_MASK | EVENTINF_21_MASK | EVENTINF_22_MASK | EVENTINF_23_MASK | EVENTINF_24_MASK); - gSaveContext.eventInf[EVENTINF_20_21_22_23_24_INDEX] &= - ~(EVENTINF_20_MASK | EVENTINF_21_MASK | EVENTINF_22_MASK | EVENTINF_23_MASK | EVENTINF_24_MASK); + textFlags = ENMU_GET_TALK_FLAGS(); + ENMU_RESET_TALK_FLAGS(); randomIndex = (play->state.frames + (s32)(Rand_ZeroOne() * 5.0f)) % 5; for (i = 0; i < 5; i++) { @@ -94,8 +93,8 @@ 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; + textFlags &= EVENTINF_HAGGLING_TOWNSFOLK_MASK | 0xE0; + gSaveContext.eventInf[EVENTINF_HAGGLING_TOWNSFOLK_INDEX] |= 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 96c00b42e61..8aabdfd4e24 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,8 +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] & - sKakarikoFlagList[i]) { + if (gSaveContext.save.info.infTable[INFTABLE_KAKARIKO_CUCCO_INDEX] & sKakarikoFlagList[i]) { this->actor.world.pos.x = 300.0f; this->actor.world.pos.y = 100.0f; this->actor.world.pos.z = 1530.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 89948d78c5a..766f66cf6b5 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,8 +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] |= - D_80ABB3B4[currentCucco->unk_2AA]; + gSaveContext.save.info.infTable[INFTABLE_KAKARIKO_CUCCO_INDEX] |= D_80ABB3B4[currentCucco->unk_2AA]; if (BREG(1) != 0) { // "GET inside the chicken fence!" PRINTF(VT_FGCOL(GREEN) "☆ 鶏柵内GET!☆ %x\n" VT_RST, D_80ABB3B4[currentCucco->unk_2AA]); @@ -219,8 +219,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] &= - ~D_80ABB3B4[currentCucco->unk_2AA]; + gSaveContext.save.info.infTable[INFTABLE_KAKARIKO_CUCCO_INDEX] &= ~D_80ABB3B4[currentCucco->unk_2AA]; } } currentCucco = (EnNiw*)currentCucco->actor.next; @@ -276,12 +275,10 @@ 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_KAKARIKO_CUCCO_INDEX]); + INFTABLE_RESET_KAKARIKO_CUCCOS(); 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_KAKARIKO_CUCCO_INDEX]); 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 acf8e5885af..c8849cdee9f 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_SKULLTULA_REWARD_10), + GET_EVENTCHKINF_MASK(EVENTCHKINF_SKULLTULA_REWARD_20), + GET_EVENTCHKINF_MASK(EVENTCHKINF_SKULLTULA_REWARD_30), + GET_EVENTCHKINF_MASK(EVENTCHKINF_SKULLTULA_REWARD_40), + GET_EVENTCHKINF_MASK(EVENTCHKINF_SKULLTULA_REWARD_50), }; static s16 sGetItemIds[6] = { @@ -114,7 +119,7 @@ void EnSth_Init(Actor* thisx, PlayState* play) { } objectId = sObjectIds[params]; - if (objectId != 1) { + if (objectId != OBJECT_GAMEPLAY_KEEP) { objectSlot = Object_GetSlot(&play->objectCtx, objectId); } else { objectSlot = 0; @@ -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_SKULLTULA_REWARD_INDEX] & 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_SKULLTULA_REWARD_INDEX] |= this->eventFlag; } else { EnSth_GivePlayerItem(this, play); } diff --git a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c index 0c229ebb120..a5ac4eb1860 100644 --- a/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c +++ b/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c @@ -81,7 +81,7 @@ void OceffSpot_End(OceffSpot* this, PlayState* play) { } else { Actor_Kill(&this->actor); if (gTimeSpeed != 400 && !play->msgCtx.disableSunsSong && - GET_EVENTINF_HORSES_STATE() != EVENTINF_HORSES_STATE_1) { + GET_EVENTINF_INGORACE_STATE() != INGORACE_STATE_HORSE_RENTAL_PERIOD) { if (play->msgCtx.ocarinaAction != OCARINA_ACTION_CHECK_NOWARP_DONE || play->msgCtx.ocarinaMode != OCARINA_MODE_08) { gSaveContext.sunsSongState = SUNSSONG_START; diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 9d84bf3ab44..e74d0fe3049 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -10753,7 +10753,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_OVERWORLD_ENTRANCE_ICON_INDEX] |= gBitFlags[play->sceneId]; } startMode = PLAYER_GET_START_MODE(thisx); From b26ccfb99238f6f18772ba69ed80a9dd56cffec6 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Wed, 20 Nov 2024 07:10:14 -0500 Subject: [PATCH 2/4] update Sram_InitDebugSave --- include/z64save.h | 2 ++ src/code/z_sram.c | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/z64save.h b/include/z64save.h index 88a332ca77b..ad68c670fea 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -477,6 +477,8 @@ typedef enum LinkAge { #define GET_EVENTCHKINF_VAR(flag) (gSaveContext.save.info.eventChkInf[(flag) >> 4]) #define GET_EVENTCHKINF_MASK(flag) (1 << ((flag) & 0xF)) +#define EVENTCHKINF_00_UNUSED 0x00 +#define EVENTCHKINF_01_UNUSED 0x01 #define EVENTCHKINF_02 0x02 #define EVENTCHKINF_03 0x03 #define EVENTCHKINF_04 0x04 diff --git a/src/code/z_sram.c b/src/code/z_sram.c index 0fcee6f0323..ebde2e66252 100644 --- a/src/code/z_sram.c +++ b/src/code/z_sram.c @@ -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_02) | + 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); From 72540732ef69af2b18b4b3d621a7a778f05a968d Mon Sep 17 00:00:00 2001 From: mzxrules Date: Wed, 20 Nov 2024 07:14:58 -0500 Subject: [PATCH 3/4] minor fix --- include/z64save.h | 2 +- src/code/z_sram.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/z64save.h b/include/z64save.h index ad68c670fea..33d127a08b9 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -924,7 +924,7 @@ typedef enum LinkAge { #define MINIMAP_GET_INFTABLE_SHIFT(flag) ((flag) - INFTABLE_1A0) // 0x1D0-0x1DF -#define INFTABLE_1DX_INDEX 29 +#define INFTABLE_1DX_INDEX (0x1D0 >> 4) /* diff --git a/src/code/z_sram.c b/src/code/z_sram.c index ebde2e66252..1a133b07b21 100644 --- a/src/code/z_sram.c +++ b/src/code/z_sram.c @@ -329,10 +329,10 @@ void Sram_InitDebugSave(void) { 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_02) | - 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); + GET_EVENTCHKINF_MASK(EVENTCHKINF_00_UNUSED) | GET_EVENTCHKINF_MASK(EVENTCHKINF_01_UNUSED) | + GET_EVENTCHKINF_MASK(EVENTCHKINF_02) | 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); From 06e3474eb5e1642ae6557b7f6448ad8f956399b6 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Fri, 13 Dec 2024 22:37:59 -0500 Subject: [PATCH 4/4] suggestions and more macros --- include/z64save.h | 99 +++++++++++-------- src/code/code_80097A00.c | 2 +- src/code/z_game_over.c | 5 +- src/code/z_map_data.c | 22 ++--- src/code/z_map_exp.c | 3 +- src/code/z_message.c | 2 +- src/code/z_parameter.c | 8 +- src/code/z_sram.c | 6 +- .../ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c | 10 +- src/overlays/actors/ovl_En_Fr/z_en_fr.c | 4 +- src/overlays/actors/ovl_En_In/z_en_in.c | 4 +- src/overlays/actors/ovl_En_Mu/z_en_mu.c | 2 +- src/overlays/actors/ovl_En_Niw/z_en_niw.c | 7 +- .../actors/ovl_En_Niw_Lady/z_en_niw_lady.c | 17 +++- src/overlays/actors/ovl_En_Sth/z_en_sth.c | 6 +- .../actors/ovl_player_actor/z_player.c | 2 +- .../ovl_file_choose/z_file_choose.c | 1 + .../ovl_kaleido_scope/z_kaleido_equipment.c | 2 +- 18 files changed, 117 insertions(+), 85 deletions(-) diff --git a/include/z64save.h b/include/z64save.h index 33d127a08b9..b89f8b033f8 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -462,12 +462,12 @@ typedef enum LinkAge { /* * SaveContext.eventChkInf - * eventChkInf is an array of 16 bit flags. These typically track main quest events. + * eventChkInf is an array of 16 bit values, where each bit is a flag. These flags typically track main quest events. * Generally, a flag will be assigned a unique id, ranging from 0x00-0xDE. Flag state can be individually accessed * or modified by passing the flag id into GET_EVENTCHKINF, SET_EVENTCHKINF, and CLEAR_EVENTCHKINF * - * In some instances where a set of flags share a common accociation, the eventChkInf variable will be accessed directly. - * When this is the case, an EVENTCHKINF_*_INDEX constant is defined for accessing a specific eventChkInf variable. + * In some instances where a set of flags share a common association, the eventChkInf variable will be accessed directly. + * When this is the case, an EVENTCHKINF_INDEX_* constant is defined for accessing a specific eventChkInf variable. */ #define GET_EVENTCHKINF(flag) (gSaveContext.save.info.eventChkInf[(flag) >> 4] & (1 << ((flag) & 0xF))) @@ -477,8 +477,9 @@ typedef enum LinkAge { #define GET_EVENTCHKINF_VAR(flag) (gSaveContext.save.info.eventChkInf[(flag) >> 4]) #define GET_EVENTCHKINF_MASK(flag) (1 << ((flag) & 0xF)) -#define EVENTCHKINF_00_UNUSED 0x00 -#define EVENTCHKINF_01_UNUSED 0x01 +// 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_02 0x02 #define EVENTCHKINF_03 0x03 #define EVENTCHKINF_04 0x04 @@ -523,8 +524,7 @@ typedef enum LinkAge { #define EVENTCHKINF_3C 0x3C // EVENTCHKINF 0x40 -#define EVENTCHKINF_40_INDEX (EVENTCHKINF_40 >> 4) -#define EVENTCHKINF_40_MASK GET_EVENTCHKINF_MASK(EVENTCHKINF_40) +#define EVENTCHKINF_INDEX_40 (EVENTCHKINF_40 >> 4) #define EVENTCHKINF_40 0x40 #define EVENTCHKINF_41 0x41 @@ -580,7 +580,7 @@ typedef enum LinkAge { // EVENTCHKINF 0x90-0x93 // carpenters freed from the gerudo -#define EVENTCHKINF_CARPENTERS_FREED_INDEX (EVENTCHKINF_CARPENTER_0_FREED >> 4) +#define EVENTCHKINF_INDEX_CARPENTERS_FREED (EVENTCHKINF_CARPENTER_0_FREED >> 4) #define EVENTCHKINF_CARPENTER_0_FREED 0x90 #define EVENTCHKINF_CARPENTER_1_FREED 0x91 #define EVENTCHKINF_CARPENTER_2_FREED 0x92 @@ -593,25 +593,25 @@ typedef enum LinkAge { | GET_EVENTCHKINF_MASK(EVENTCHKINF_CARPENTER_3_FREED)) #define GET_EVENTCHKINF_CARPENTERS_FREE_ALL() \ - CHECK_FLAG_ALL(gSaveContext.save.info.eventChkInf[EVENTCHKINF_CARPENTERS_FREED_INDEX], \ + CHECK_FLAG_ALL(gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_CARPENTERS_FREED], \ EVENTCHKINF_CARPENTERS_FREE_MASK_ALL) #define GET_EVENTCHKINF_CARPENTERS_FREE_ALL2() \ - CHECK_FLAG_ALL(gSaveContext.save.info.eventChkInf[EVENTCHKINF_CARPENTERS_FREED_INDEX] & \ + CHECK_FLAG_ALL(gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_CARPENTERS_FREED] & \ (EVENTCHKINF_CARPENTERS_FREE_MASK_ALL | 0xF0), \ EVENTCHKINF_CARPENTERS_FREE_MASK_ALL) #define ENDAIKU_CARPENTER_FREE_MASK(carpenterType) (1 << ((EVENTCHKINF_CARPENTER_0_FREED & 0xF) + (carpenterType))) #define ENDAIKU_IS_CARPENTER_FREE(carpenterType) \ - gSaveContext.save.info.eventChkInf[EVENTCHKINF_CARPENTERS_FREED_INDEX] & \ + gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_CARPENTERS_FREED] & \ ENDAIKU_CARPENTER_FREE_MASK(carpenterType) #define ENDAIKU_SET_CARPENTER_FREE(carpenterType) \ - gSaveContext.save.info.eventChkInf[EVENTCHKINF_CARPENTERS_FREED_INDEX] |= \ + gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_CARPENTERS_FREED] |= \ ENDAIKU_CARPENTER_FREE_MASK((carpenterType)) #define GET_EVENTCHKINF_CARPENTERS_FREE_FLAGS() \ - gSaveContext.save.info.eventChkInf[EVENTCHKINF_CARPENTERS_FREED_INDEX] & \ + gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_CARPENTERS_FREED] & \ EVENTCHKINF_CARPENTERS_FREE_MASK_ALL #define EVENTCHKINF_94 0x94 @@ -657,7 +657,7 @@ typedef enum LinkAge { #define EVENTCHKINF_C9 0xC9 // EVENTCHKINF 0xD0-0xD6 -#define EVENTCHKINF_SONGS_FOR_FROGS_INDEX (EVENTCHKINF_SONGS_FOR_FROGS_CHOIR >> 4) +#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 @@ -667,7 +667,7 @@ typedef enum LinkAge { #define EVENTCHKINF_SONGS_FOR_FROGS_STORMS 0xD6 // EVENTCHKINF 0xDA-0xDE -#define EVENTCHKINF_SKULLTULA_REWARD_INDEX (EVENTCHKINF_SKULLTULA_REWARD_10 >> 4) +#define EVENTCHKINF_INDEX_SKULLTULA_REWARD (EVENTCHKINF_SKULLTULA_REWARD_10 >> 4) #define EVENTCHKINF_SKULLTULA_REWARD_10 0xDA #define EVENTCHKINF_SKULLTULA_REWARD_20 0xDB #define EVENTCHKINF_SKULLTULA_REWARD_30 0xDC @@ -683,8 +683,8 @@ typedef enum LinkAge { * Generally, a flag will be assigned a unique id, ranging from 0x00-0x3F. Flag state can be individually accessed * or modified by passing the flag id into GET_ITEMGETINF or SET_ITEMGETINF * - * In some instances where a set of flags share a common accociation, the itemGetInf variable will be accessed directly. - * When this is the case, an ITEMGETINF_*_INDEX constant is defined for accessing a specific itemGetInf variable. + * In some instances where a set of flags share a common association, the itemGetInf variable will be accessed directly. + * When this is the case, an ITEMGETINF_INDEX_* constant is defined for accessing a specific itemGetInf variable. */ #define GET_ITEMGETINF(flag) (gSaveContext.save.info.itemGetInf[(flag) >> 4] & (1 << ((flag) & 0xF))) @@ -715,7 +715,7 @@ typedef enum LinkAge { #define ITEMGETINF_17 0x17 // ITEMGETINF 0x18-0x1A -#define ITEMGETINF_GREAT_FAIRY_ITEM_INDEX (ITEMGETINF_FARORES_WIND >> 4) +#define ITEMGETINF_INDEX_GREAT_FAIRY_ITEM (ITEMGETINF_FARORES_WIND >> 4) #define ITEMGETINF_FARORES_WIND 0x18 #define ITEMGETINF_DINS_FIRE 0x19 #define ITEMGETINF_NAYRUS_LOVE 0x1A @@ -748,8 +748,8 @@ typedef enum LinkAge { * Generally, a flag will be assigned a unique id, ranging from 0x00-0x1D0. Flag state can be individually accessed * or modified by passing the flag id into GET_INFTABLE, SET_INFTABLE, or CLEAR_INFTABLE * - * In some instances where a set of flags share a common accociation, the infTable variable will be accessed directly. - * When this is the case, an INFTABLE_*_INDEX constant is defined for accessing a specific infTable variable. + * In some instances where a set of flags share a common association, the infTable variable will be accessed directly. + * When this is the case, an INFTABLE_INDEX_* constant is defined for accessing a specific infTable variable. */ #define GET_INFTABLE(flag) (gSaveContext.save.info.infTable[(flag) >> 4] & (1 << ((flag) & 0xF))) @@ -886,7 +886,7 @@ typedef enum LinkAge { #define INFTABLE_198 0x198 // INFTABLE 0x199-0x19F -#define INFTABLE_KAKARIKO_CUCCO_INDEX (INFTABLE_199 >> 4) +#define INFTABLE_INDEX_KAKARIKO_CUCCO (INFTABLE_199 >> 4) #define INFTABLE_199 0x199 #define INFTABLE_19A 0x19A #define INFTABLE_19B 0x19B @@ -896,14 +896,14 @@ typedef enum LinkAge { #define INFTABLE_19F 0x19F #define INFTABLE_RESET_KAKARIKO_CUCCOS() \ - gSaveContext.save.info.infTable[INFTABLE_KAKARIKO_CUCCO_INDEX] &= \ + gSaveContext.save.info.infTable[INFTABLE_INDEX_KAKARIKO_CUCCO] &= \ (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)); // INFTABLE 0x1A0-0x1AF -#define INFTABLE_OVERWORLD_ENTRANCE_ICON_INDEX (INFTABLE_1A0 >> 4) +#define INFTABLE_INDEX_OVERWORLD_ENTRANCE_ICON (INFTABLE_1A0 >> 4) #define INFTABLE_1A0 0x1A0 #define INFTABLE_1A1 0x1A1 #define INFTABLE_1A2 0x1A2 @@ -913,7 +913,7 @@ typedef enum LinkAge { #define INFTABLE_1A6 0x1A6 #define INFTABLE_1A7 0x1A7 #define INFTABLE_1A8 0x1A8 -#define INFTABLE_1A9 0x1A9 // different +#define INFTABLE_1A9 0x1A9 #define INFTABLE_1AB 0x1AB #define INFTABLE_1AD 0x1AD @@ -921,10 +921,19 @@ typedef enum LinkAge { #define MINIMAP_GET_INFTABLE(flag) \ gSaveContext.save.info.infTable[(flag) >> 4] & gBitFlags[((flag) & 0xF)] -#define MINIMAP_GET_INFTABLE_SHIFT(flag) ((flag) - INFTABLE_1A0) +#define MINIMAP_GET_INFTABLE_FROM_OW_ENTRANCE_FLAG(shift) \ + (gSaveContext.save.info.infTable[INFTABLE_INDEX_OVERWORLD_ENTRANCE_ICON] & \ + gBitFlags[(shift)]) + +#define MINIMAP_SET_INFTABLE_FROM_OW_ENTRANCE_FLAG(shift) \ + (gSaveContext.save.info.infTable[INFTABLE_INDEX_OVERWORLD_ENTRANCE_ICON] |= \ + gBitFlags[(shift)]) + +#define MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(flag) ((flag) - INFTABLE_1A0) // 0x1D0-0x1DF -#define INFTABLE_1DX_INDEX (0x1D0 >> 4) +#define INFTABLE_INDEX_1DX (0x1D0 >> 4) +#define INFTABLE_1D0 0x1D0 /* @@ -934,19 +943,26 @@ typedef enum LinkAge { * Generally, a flag will be assigned a unique id, ranging from 0x00-0x30. Flag state can be individually accessed * or modified by passing the flag id into GET_EVENTINF, SET_EVENTINF, or CLEAR_EVENTINF * - * In some instances where a set of flags share a common accociation, the eventInf variable will be accessed directly. - * When this is the case, an EVENTINF_*_INDEX constant is defined for accessing a specific eventInf variable. + * In some instances where a set of flags share a common association, the eventInf variable will be accessed directly. + * When this is the case, an EVENTINF_INDEX_* constant is defined for accessing a specific eventInf variable. */ #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 RESET_EVENTINF() \ + gSaveContext.eventInf[0] = 0; \ + gSaveContext.eventInf[1] = 0; \ + gSaveContext.eventInf[2] = 0; \ + gSaveContext.eventInf[3] = 0; +#define RESET_EVENTINF2() \ + gSaveContext.eventInf[0] = gSaveContext.eventInf[1] = gSaveContext.eventInf[2] = gSaveContext.eventInf[3] = 0; #define GET_EVENTINF_MASK(flag) (1 << ((flag) & 0xF)) // EVENTINF 0x00-0x0F // Ingo Race, Lon Lon Ranch minigames, and Horseback Archery minigame flags -#define EVENTINF_INGORACE_INDEX (0x00 >> 4) +#define EVENTINF_INDEX_INGORACE (0x00 >> 4) // EVENTINF 0x00-0x03 reserved for IngoRaceState #define EVENTINF_INGORACE_STATE_MASK \ (GET_EVENTINF_MASK(0x00) | GET_EVENTINF_MASK(0x01) | GET_EVENTINF_MASK(0x02) | GET_EVENTINF_MASK(0x03)) @@ -975,26 +991,29 @@ typedef enum IngoRaceState { #define EVENTINF_INGORACE_0F 0x0F // unused? // "InRaceSeq" -#define GET_EVENTINF_INGORACE_STATE() (gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] & EVENTINF_INGORACE_STATE_MASK) +#define GET_EVENTINF_INGORACE_STATE() (gSaveContext.eventInf[EVENTINF_INDEX_INGORACE] & EVENTINF_INGORACE_STATE_MASK) #define SET_EVENTINF_INGORACE_STATE(v) \ - gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] = \ - (gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] & ~EVENTINF_INGORACE_STATE_MASK) | (v) + gSaveContext.eventInf[EVENTINF_INDEX_INGORACE] = \ + (gSaveContext.eventInf[EVENTINF_INDEX_INGORACE] & ~EVENTINF_INGORACE_STATE_MASK) | (v) #define SET_EVENTINF_INGORACE_FLAG(flag) \ - gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] = \ - (gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] & 0xFFFF) | (1 << ((flag) & 0xF)) + gSaveContext.eventInf[EVENTINF_INDEX_INGORACE] = \ + (gSaveContext.eventInf[EVENTINF_INDEX_INGORACE] & 0xFFFF) | (1 << ((flag) & 0xF)) #define WRITE_EVENTINF_INGORACE_FLAG(flag, v) \ - gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] = \ - (gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] & ~(1 << ((flag)&0xF))) | ((v) << ((flag) & 0xF)) + gSaveContext.eventInf[EVENTINF_INDEX_INGORACE] = \ + (gSaveContext.eventInf[EVENTINF_INDEX_INGORACE] & ~(1 << ((flag)&0xF))) | ((v) << ((flag) & 0xF)) #define RESET_EVENTINF_INGORACE() \ - gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] &= \ + gSaveContext.eventInf[EVENTINF_INDEX_INGORACE] &= \ (u16) ~(EVENTINF_INGORACE_STATE_MASK | GET_EVENTINF_MASK(EVENTINF_INGORACE_HORSETYPE) | \ GET_EVENTINF_MASK(EVENTINF_INGORACE_LOST_ONCE) | GET_EVENTINF_MASK(EVENTINF_INGORACE_SECOND_RACE) | \ GET_EVENTINF_MASK(EVENTINF_INGORACE_0F)) +#define RESET_EVENTINF_INGORACE2() \ + gSaveContext.eventInf[EVENTINF_INDEX_INGORACE] = 0; + #define GET_EVENTINF_INGORACE_HORSETYPE() \ (GET_EVENTINF(EVENTINF_INGORACE_HORSETYPE) >> (EVENTINF_INGORACE_HORSETYPE & 0xF)) #define WRITE_EVENTINF_INGORACE_HORSETYPE(v) WRITE_EVENTINF_INGORACE_FLAG(EVENTINF_INGORACE_HORSETYPE, v) @@ -1005,7 +1024,7 @@ typedef enum IngoRaceState { #define EVENTINF_MARATHON_ACTIVE 0x10 // EVENTINF 0x20-0x24 -#define EVENTINF_HAGGLING_TOWNSFOLK_INDEX (EVENTINF_20 >> 4) +#define EVENTINF_INDEX_HAGGLING_TOWNSFOLK (EVENTINF_20 >> 4) #define EVENTINF_20 0x20 #define EVENTINF_21 0x21 #define EVENTINF_22 0x22 @@ -1017,10 +1036,10 @@ typedef enum IngoRaceState { GET_EVENTINF_MASK(EVENTINF_23) | GET_EVENTINF_MASK(EVENTINF_24)) #define ENMU_GET_TALK_FLAGS() \ - gSaveContext.eventInf[EVENTINF_HAGGLING_TOWNSFOLK_INDEX] & EVENTINF_HAGGLING_TOWNSFOLK_MASK + gSaveContext.eventInf[EVENTINF_INDEX_HAGGLING_TOWNSFOLK] & EVENTINF_HAGGLING_TOWNSFOLK_MASK #define ENMU_RESET_TALK_FLAGS() \ - gSaveContext.eventInf[EVENTINF_HAGGLING_TOWNSFOLK_INDEX] &= ~(EVENTINF_HAGGLING_TOWNSFOLK_MASK); + gSaveContext.eventInf[EVENTINF_INDEX_HAGGLING_TOWNSFOLK] &= ~(EVENTINF_HAGGLING_TOWNSFOLK_MASK); #define EVENTINF_30 0x30 diff --git a/src/code/code_80097A00.c b/src/code/code_80097A00.c index b452a92e16d..2f89c0565be 100644 --- a/src/code/code_80097A00.c +++ b/src/code/code_80097A00.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_game_over.c b/src/code/z_game_over.c index f0390a96116..f5c0cdc32ac 100644 --- a/src/code/z_game_over.c +++ b/src/code/z_game_over.c @@ -71,10 +71,7 @@ void GameOver_Update(PlayState* play) { gSaveContext.save.info.playerData.naviTimer = 0; gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.natureAmbienceId = NATURE_ID_DISABLED; - gSaveContext.eventInf[0] = 0; - gSaveContext.eventInf[1] = 0; - gSaveContext.eventInf[2] = 0; - gSaveContext.eventInf[3] = 0; + RESET_EVENTINF(); gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[4] = BTN_ENABLED; gSaveContext.forceRisingButtonAlphas = gSaveContext.nextHudVisibilityMode = gSaveContext.hudVisibilityMode = diff --git a/src/code/z_map_data.c b/src/code/z_map_data.c index 380add3e646..1131d8b3dc7 100644 --- a/src/code/z_map_data.c +++ b/src/code/z_map_data.c @@ -240,25 +240,25 @@ static s16 sOwEntranceIconPosY[24] = { static u16 sOwEntranceFlag[20] = { 0xFFFF, - MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A8), - MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A7), + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1A8), + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1A7), 0xFFFF, - MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A0), - MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A3), - MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A5), + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1A0), + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1A3), + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1A5), 0xFFFF, - MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A2), + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1A2), 0xFFFF, 0xFFFF, - MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A6), - MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1AB), + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1A6), + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1AB), 0xFFFF, 0xFFFF, - MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A1), - MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1A4), + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1A1), + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1A4), 0xFFFF, 0xFFFF, - MINIMAP_GET_INFTABLE_SHIFT(INFTABLE_1AD), + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1AD), }; static f32 sFloorCoordY[10][8] = { diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c index ca9243ba5e6..bb1ef57b7bf 100644 --- a/src/code/z_map_exp.c +++ b/src/code/z_map_exp.c @@ -496,8 +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_OVERWORLD_ENTRANCE_ICON_INDEX] & - gBitFlags[gMapData->owEntranceFlag[mapIndex]]))) { + MINIMAP_GET_INFTABLE_FROM_OW_ENTRANCE_FLAG(gMapData->owEntranceFlag[mapIndex]))) { 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, diff --git a/src/code/z_message.c b/src/code/z_message.c index c348f776dbf..4e4bf1646db 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -2518,7 +2518,7 @@ void Message_OpenText(PlayState* play, u16 textId) { PRINTF(VT_FGCOL(YELLOW)); PRINTF("???????????????? z_message.c ??????????????????\n"); PRINTF(VT_RST); - gSaveContext.eventInf[0] = gSaveContext.eventInf[1] = gSaveContext.eventInf[2] = gSaveContext.eventInf[3] = 0; + RESET_EVENTINF2(); } if (sTextIsCredits) { diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index d0d7c73eb85..799f5e32038 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); } @@ -3544,7 +3544,7 @@ void Interface_Draw(PlayState* play) { if (INV_CONTENT(ITEM_TRADE_ADULT) == gSpoilingItems[svar1]) { #if OOT_VERSION >= NTSC_1_1 RESET_EVENTINF_INGORACE(); - PRINTF("EVENT_INF=%x\n", gSaveContext.eventInf[EVENTINF_INGORACE_INDEX]); + PRINTF("EVENT_INF=%x\n", gSaveContext.eventInf[EVENTINF_INDEX_INGORACE]); #endif play->nextEntranceIndex = spoilingItemEntrances[svar1]; INV_CONTENT(gSpoilingItemReverts[svar1]) = gSpoilingItemReverts[svar1]; diff --git a/src/code/z_sram.c b/src/code/z_sram.c index 1a133b07b21..0dd8d11dc5c 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; } @@ -505,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 92ac8eafdd8..ca02e5ab849 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,12 @@ 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[] = { GET_ITEMGETINF_MASK(ITEMGETINF_FARORES_WIND), GET_ITEMGETINF_MASK(ITEMGETINF_DINS_FIRE), - GET_ITEMGETINF_MASK(ITEMGETINF_NAYRUS_LOVE) }; +#define GREAT_FAIRY_SET_MAGIC_SPELL_OBTAINED(exItemIndex) \ + gSaveContext.save.info.itemGetInf[ITEMGETINF_INDEX_GREAT_FAIRY_ITEM] |= sItemGetFlagMasks[exItemIndex]; + +static s16 sItemGetFlagMasks[] = { GET_ITEMGETINF_MASK(ITEMGETINF_FARORES_WIND), + GET_ITEMGETINF_MASK(ITEMGETINF_DINS_FIRE), + GET_ITEMGETINF_MASK(ITEMGETINF_NAYRUS_LOVE) }; static u8 sItemIds[] = { ITEM_FARORES_WIND, ITEM_DINS_FIRE, ITEM_NAYRUS_LOVE }; @@ -809,7 +813,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_GREAT_FAIRY_ITEM_INDEX] |= sItemGetFlags[cueIdTemp]; + GREAT_FAIRY_SET_MAGIC_SPELL_OBTAINED(cueIdTemp); Item_Give(play, sItemIds[cueIdTemp]); } } else { 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 ae571f718b7..2665254d2c3 100644 --- a/src/overlays/actors/ovl_En_Fr/z_en_fr.c +++ b/src/overlays/actors/ovl_En_Fr/z_en_fr.c @@ -106,11 +106,11 @@ 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[] = { 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 308c479baa7..754cdfe526d 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -489,7 +489,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_INGORACE_INDEX] = 0; + RESET_EVENTINF_INGORACE2(); D_80A7B998 = 1; } this->actionFunc = EnIn_WaitForObject; @@ -575,7 +575,7 @@ void EnIn_WaitForObject(EnIn* this, PlayState* play) { case INGORACE_STATE_RACING: EnIn_ChangeAnim(this, ENIN_ANIM_2); this->actionFunc = func_80A7A4C8; - gSaveContext.eventInf[EVENTINF_INGORACE_INDEX] = 0; + RESET_EVENTINF_INGORACE2(); break; case INGORACE_STATE_HORSE_RENTAL_PERIOD: this->actor.attentionRangeType = ATTENTION_RANGE_3; 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 3c24ecbec27..d24462c4ee5 100644 --- a/src/overlays/actors/ovl_En_Mu/z_en_mu.c +++ b/src/overlays/actors/ovl_En_Mu/z_en_mu.c @@ -94,7 +94,7 @@ void EnMu_Interact(EnMu* this, PlayState* play) { textFlags |= bitmask[randomIndex]; this->defaultTextId = textIdOffset[randomIndex] | 0x7000; textFlags &= EVENTINF_HAGGLING_TOWNSFOLK_MASK | 0xE0; - gSaveContext.eventInf[EVENTINF_HAGGLING_TOWNSFOLK_INDEX] |= textFlags; + gSaveContext.eventInf[EVENTINF_INDEX_HAGGLING_TOWNSFOLK] |= 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 8aabdfd4e24..83f4923826f 100644 --- a/src/overlays/actors/ovl_En_Niw/z_en_niw.c +++ b/src/overlays/actors/ovl_En_Niw/z_en_niw.c @@ -65,7 +65,10 @@ static Vec3f sKakarikoPosList[] = { { -60.0f, 0.0f, -46.0f }, { -247.0f, 80.0f, 854.0f }, { 1079.0f, 80.0f, -47.0f }, }; -static s16 sKakarikoFlagList[] = { +#define KAKARIKO_CUCCO_HAS_BEEN_RETURNED(cuccoIndex) \ + gSaveContext.save.info.infTable[INFTABLE_INDEX_KAKARIKO_CUCCO] & sKakarikoFlagMaskList[(cuccoIndex)] + +static s16 sKakarikoFlagMaskList[] = { 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), @@ -163,7 +166,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_KAKARIKO_CUCCO_INDEX] & sKakarikoFlagList[i]) { + if (KAKARIKO_CUCCO_HAS_BEEN_RETURNED(i)) { this->actor.world.pos.x = 300.0f; this->actor.world.pos.y = 100.0f; this->actor.world.pos.z = 1530.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 766f66cf6b5..7896eb124de 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 @@ -42,6 +42,15 @@ static s16 sMissingCuccoTextIds[] = { 0x5036, 0x5070, 0x5072, 0x5037, 0x5038, 0x5039, 0x503A, 0x503B, 0x503D, 0x503C, }; +#define KAKARIKO_CUCCO_SET_RETURNED(cuccoIndex) \ + gSaveContext.save.info.infTable[INFTABLE_INDEX_KAKARIKO_CUCCO] |= D_80ABB3B4[(cuccoIndex)] + +#define KAKARIKO_CUCCO_RESET_RETURNED(cuccoIndex) \ + gSaveContext.save.info.infTable[INFTABLE_INDEX_KAKARIKO_CUCCO] &= ~D_80ABB3B4[(cuccoIndex)] + +#define KAKARIKO_CUCCO_HAS_BEEN_RETURNED(cuccoIndex) \ + gSaveContext.save.info.infTable[INFTABLE_INDEX_KAKARIKO_CUCCO] & D_80ABB3B4[(cuccoIndex)] + 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), @@ -211,7 +220,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_KAKARIKO_CUCCO_INDEX] |= D_80ABB3B4[currentCucco->unk_2AA]; + KAKARIKO_CUCCO_SET_RETURNED(currentCucco->unk_2AA); if (BREG(1) != 0) { // "GET inside the chicken fence!" PRINTF(VT_FGCOL(GREEN) "☆ 鶏柵内GET!☆ %x\n" VT_RST, D_80ABB3B4[currentCucco->unk_2AA]); @@ -219,7 +228,7 @@ void func_80ABA244(EnNiwLady* this, PlayState* play) { } this->cuccosInPen++; } else if (this->unk_26C == 0) { - gSaveContext.save.info.infTable[INFTABLE_KAKARIKO_CUCCO_INDEX] &= ~D_80ABB3B4[currentCucco->unk_2AA]; + KAKARIKO_CUCCO_RESET_RETURNED(currentCucco->unk_2AA); } } currentCucco = (EnNiw*)currentCucco->actor.next; @@ -275,10 +284,10 @@ 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_KAKARIKO_CUCCO_INDEX]); + gSaveContext.save.info.infTable[INFTABLE_INDEX_KAKARIKO_CUCCO]); INFTABLE_RESET_KAKARIKO_CUCCOS(); PRINTF(VT_FGCOL(CYAN) "☆☆☆☆☆ 柵内BIT変更後 ☆☆ %x\n" VT_RST, - gSaveContext.save.info.infTable[INFTABLE_KAKARIKO_CUCCO_INDEX]); + gSaveContext.save.info.infTable[INFTABLE_INDEX_KAKARIKO_CUCCO]); 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 c8849cdee9f..990d84362f9 100644 --- a/src/overlays/actors/ovl_En_Sth/z_en_sth.c +++ b/src/overlays/actors/ovl_En_Sth/z_en_sth.c @@ -159,9 +159,9 @@ void EnSth_SetupAfterObjectLoaded(EnSth* this, PlayState* play) { 16); Animation_PlayLoop(&this->skelAnime, sAnimations[this->actor.params]); - this->eventFlag = sEventFlags[this->actor.params]; params = &this->actor.params; - if (gSaveContext.save.info.eventChkInf[EVENTCHKINF_SKULLTULA_REWARD_INDEX] & this->eventFlag) { + this->eventFlag = sEventFlags[*params]; + if (gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_SKULLTULA_REWARD] & this->eventFlag) { EnSth_SetupAction(this, sRewardObtainedWaitActions[*params]); } else { EnSth_SetupAction(this, EnSth_RewardUnobtainedWait); @@ -261,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_SKULLTULA_REWARD_INDEX] |= this->eventFlag; + gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_SKULLTULA_REWARD] |= 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 e74d0fe3049..db3f996b631 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -10753,7 +10753,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_OVERWORLD_ENTRANCE_ICON_INDEX] |= gBitFlags[play->sceneId]; + MINIMAP_SET_INFTABLE_FROM_OW_ENTRANCE_FLAG(play->sceneId); } startMode = PLAYER_GET_START_MODE(thisx); diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 3288f115c48..d8490f3aa11 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -1878,6 +1878,7 @@ void FileSelect_LoadGame(GameState* thisx) { gSaveContext.dogParams = 0; gSaveContext.timerState = TIMER_STATE_OFF; gSaveContext.subTimerState = SUBTIMER_STATE_OFF; + // RESET_EVENTINF() gSaveContext.eventInf[0] = 0; gSaveContext.eventInf[1] = 0; gSaveContext.eventInf[2] = 0; 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)) {