diff --git a/include/z64save.h b/include/z64save.h index 3d61f485f82..b1ac97cd44a 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -462,6 +462,12 @@ typedef enum LinkAge { /* * SaveContext.eventChkInf + * 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 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 EVENTCHKINF_INDEX(flag) ((flag) >> 4) @@ -471,6 +477,9 @@ typedef enum LinkAge { #define SET_EVENTCHKINF(flag) (gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX(flag)] |= EVENTCHKINF_MASK(flag)) #define CLEAR_EVENTCHKINF(flag) (gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX(flag)] &= ~EVENTCHKINF_MASK(flag)) +#define GET_EVENTCHKINF_VAR(flag) (gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX(flag)]) +#define EVENTCHKINF_MASK(flag) (1 << ((flag) & 0xF)) + // EVENTCHKINF 0x00-0x0F #define EVENTCHKINF_INDEX_0 0 #define EVENTCHKINF_00_UNUSED 0x00 // flag is set in the debug save, but has no functionality @@ -553,6 +562,9 @@ typedef enum LinkAge { #define EVENTCHKINF_INDEX_TALON_RETURNED_FROM_KAKARIKO EVENTCHKINF_INDEX(EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO) #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) & EVENTCHKINF_MASK((flag))) + #define EVENTCHKINF_6E 0x6E #define EVENTCHKINF_6F 0x6F #define EVENTCHKINF_BEGAN_GOHMA_BATTLE 0x70 @@ -668,6 +680,14 @@ typedef enum LinkAge { /* * 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 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 ITEMGETINF_INDEX(flag) ((flag) >> 4) @@ -699,10 +719,10 @@ typedef enum LinkAge { #define ITEMGETINF_17 0x17 // ITEMGETINF 0x18-0x1A -#define ITEMGETINF_INDEX_18_19_1A 1 -#define ITEMGETINF_18 0x18 -#define ITEMGETINF_19 0x19 -#define ITEMGETINF_1A 0x1A +#define ITEMGETINF_INDEX_GREAT_FAIRY_ITEM 1 +#define ITEMGETINF_FARORES_WIND 0x18 +#define ITEMGETINF_DINS_FIRE 0x19 +#define ITEMGETINF_NAYRUS_LOVE 0x1A #define ITEMGETINF_1B 0x1B #define ITEMGETINF_1C 0x1C @@ -730,6 +750,13 @@ typedef enum LinkAge { /* * 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 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 INFTABLE_INDEX(flag) ((flag) >> 4) @@ -869,7 +896,7 @@ typedef enum LinkAge { #define INFTABLE_198 0x198 // INFTABLE 0x199-0x19F -#define INFTABLE_INDEX_199_19A_19B_19C_19D_19E_19F 25 +#define INFTABLE_INDEX_KAKARIKO_CUCCO (INFTABLE_199 >> 4) #define INFTABLE_199 0x199 #define INFTABLE_19A 0x19A #define INFTABLE_19B 0x19B @@ -878,28 +905,56 @@ typedef enum LinkAge { #define INFTABLE_19E 0x19E #define INFTABLE_19F 0x19F +#define INFTABLE_RESET_KAKARIKO_CUCCOS() \ + gSaveContext.save.info.infTable[INFTABLE_INDEX_KAKARIKO_CUCCO] &= \ + (u16) ~(INFTABLE_MASK(INFTABLE_199) | INFTABLE_MASK(INFTABLE_19A) | INFTABLE_MASK(INFTABLE_19B) | \ + INFTABLE_MASK(INFTABLE_19C) | INFTABLE_MASK(INFTABLE_19D) | INFTABLE_MASK(INFTABLE_19E) | \ + INFTABLE_MASK(INFTABLE_19F)); + + // INFTABLE 0x1A0-0x1AF -#define INFTABLE_INDEX_1AX 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 0x1D0-0x1DF +#define INFTABLE_INDEX_OVERWORLD_ENTRANCE_ICON INFTABLE_INDEX(INFTABLE_1A0) +#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 +#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_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_INDEX_1DX INFTABLE_INDEX(INFTABLE_1D0) #define INFTABLE_1D0 0x1D0 /* * 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 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 EVENTINF_INDEX(flag) ((flag) >> 4) @@ -908,12 +963,21 @@ typedef enum LinkAge { #define GET_EVENTINF(flag) (gSaveContext.eventInf[EVENTINF_INDEX(flag)] & EVENTINF_MASK(flag)) #define SET_EVENTINF(flag) (gSaveContext.eventInf[EVENTINF_INDEX(flag)] |= EVENTINF_MASK(flag)) #define CLEAR_EVENTINF(flag) (gSaveContext.eventInf[EVENTINF_INDEX(flag)] &= ~EVENTINF_MASK(flag)) +#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; // EVENTINF 0x00-0x0F // Ingo Race, Lon Lon Ranch minigames, and Horseback Archery minigame flags -#define EVENTINF_INDEX_HORSES 0 +#define EVENTINF_INDEX_INGO_RACE 0 // EVENTINF 0x00-0x03 reserved for IngoRaceState -#define EVENTINF_INGO_RACE_STATE_MASK (0xF << 0x00) +#define EVENTINF_INGO_RACE_STATE_MASK \ + (EVENTINF_MASK(0x00) | EVENTINF_MASK(0x01) | EVENTINF_MASK(0x02) | EVENTINF_MASK(0x03)) + typedef enum IngoRaceState { /* 0 */ INGO_RACE_STATE_OFFER_RENTAL, /* 1 */ INGO_RACE_STATE_HORSE_RENTAL_PERIOD, @@ -938,24 +1002,31 @@ typedef enum IngoRaceState { #define EVENTINF_INGO_RACE_0F 0x0F // unused? // "InRaceSeq" -#define GET_EVENTINF_INGO_RACE_STATE() (gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & EVENTINF_INGO_RACE_STATE_MASK) +#define GET_EVENTINF_INGO_RACE_STATE() (gSaveContext.eventInf[EVENTINF_INDEX_INGO_RACE] & EVENTINF_INGO_RACE_STATE_MASK) + +#define SET_EVENTINF_INGO_RACE_STATE(v) \ + gSaveContext.eventInf[EVENTINF_INDEX_INGO_RACE] = \ + (gSaveContext.eventInf[EVENTINF_INDEX_INGO_RACE] & ~EVENTINF_INGO_RACE_STATE_MASK) | (v) -#define SET_EVENTINF_INGO_RACE_STATE(v) \ - gSaveContext.eventInf[EVENTINF_INDEX_HORSES] = \ - (gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & ~EVENTINF_INGO_RACE_STATE_MASK) | (v) +#define SET_EVENTINF_INGO_RACE_FLAG(flag) \ + gSaveContext.eventInf[EVENTINF_INDEX_INGO_RACE] = \ + (gSaveContext.eventInf[EVENTINF_INDEX_INGO_RACE] & 0xFFFF) | (1 << ((flag) & 0xF)) -#define GET_EVENTINF_INGO_RACE_FLAG(flag) \ - ((gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & EVENTINF_MASK(flag)) >> ((flag) & 0xF)) +#define WRITE_EVENTINF_INGO_RACE_FLAG(flag, v) \ + gSaveContext.eventInf[EVENTINF_INDEX_INGO_RACE] = \ + (gSaveContext.eventInf[EVENTINF_INDEX_INGO_RACE] & ~(1 << ((flag)&0xF))) | ((v) << ((flag) & 0xF)) -#define SET_EVENTINF_INGO_RACE_FLAG(flag) \ - gSaveContext.eventInf[EVENTINF_INDEX_HORSES] = \ - (gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & 0xFFFF) | EVENTINF_MASK(flag) +#define RESET_EVENTINF_INGO_RACE() \ + gSaveContext.eventInf[EVENTINF_INDEX_INGO_RACE] &= \ + (u16) ~(EVENTINF_INGO_RACE_STATE_MASK | EVENTINF_MASK(EVENTINF_INGO_RACE_HORSETYPE) | \ + EVENTINF_MASK(EVENTINF_INGO_RACE_LOST_ONCE) | EVENTINF_MASK(EVENTINF_INGO_RACE_SECOND_RACE) | \ + EVENTINF_MASK(EVENTINF_INGO_RACE_0F)) -#define WRITE_EVENTINF_INGO_RACE_FLAG(flag, v) \ - gSaveContext.eventInf[EVENTINF_INDEX_HORSES] = \ - (gSaveContext.eventInf[EVENTINF_INDEX_HORSES] & ~EVENTINF_MASK(flag)) | ((v) << ((flag) & 0xF)) +#define RESET_EVENTINF_INGO_RACE2() \ + gSaveContext.eventInf[EVENTINF_INDEX_INGO_RACE] = 0; -#define GET_EVENTINF_INGO_RACE_HORSETYPE() GET_EVENTINF_INGO_RACE_FLAG(EVENTINF_INGO_RACE_HORSETYPE) +#define GET_EVENTINF_INGO_RACE_HORSETYPE() \ + (GET_EVENTINF(EVENTINF_INGO_RACE_HORSETYPE) >> (EVENTINF_INGO_RACE_HORSETYPE & 0xF)) #define WRITE_EVENTINF_INGO_RACE_HORSETYPE(v) WRITE_EVENTINF_INGO_RACE_FLAG(EVENTINF_INGO_RACE_HORSETYPE, v) #define WRITE_EVENTINF_INGO_RACE_0F(v) WRITE_EVENTINF_INGO_RACE_FLAG(EVENTINF_INGO_RACE_0F, v) @@ -964,12 +1035,22 @@ typedef enum IngoRaceState { #define EVENTINF_MARATHON_ACTIVE 0x10 // EVENTINF 0x20-0x24 -#define EVENTINF_INDEX_20_21_22_23_24 2 -#define EVENTINF_20_MASK (1 << 0) -#define EVENTINF_21_MASK (1 << 1) -#define EVENTINF_22_MASK (1 << 2) -#define EVENTINF_23_MASK (1 << 3) -#define EVENTINF_24_MASK (1 << 4) +#define EVENTINF_INDEX_HAGGLING_TOWNSFOLK (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_HAGGLING_TOWNSFOLK_MASK \ + (EVENTINF_MASK(EVENTINF_20) | EVENTINF_MASK(EVENTINF_21) | EVENTINF_MASK(EVENTINF_22) | \ + EVENTINF_MASK(EVENTINF_23) | EVENTINF_MASK(EVENTINF_24)) + +#define ENMU_GET_TALK_FLAGS() \ + gSaveContext.eventInf[EVENTINF_INDEX_HAGGLING_TOWNSFOLK] & EVENTINF_HAGGLING_TOWNSFOLK_MASK + +#define ENMU_RESET_TALK_FLAGS() \ + gSaveContext.eventInf[EVENTINF_INDEX_HAGGLING_TOWNSFOLK] &= ~(EVENTINF_HAGGLING_TOWNSFOLK_MASK); #define EVENTINF_30 0x30 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 24721c6234c..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, - INFTABLE_1A8_SHIFT, - INFTABLE_1A7_SHIFT, + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1A8), + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1A7), 0xFFFF, - INFTABLE_1A0_SHIFT, - INFTABLE_1A3_SHIFT, - INFTABLE_1A5_SHIFT, + 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, - INFTABLE_1A2_SHIFT, + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1A2), 0xFFFF, 0xFFFF, - INFTABLE_1A6_SHIFT, - INFTABLE_1AB_SHIFT, + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1A6), + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1AB), 0xFFFF, 0xFFFF, - INFTABLE_1A1_SHIFT, - INFTABLE_1A4_SHIFT, + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1A1), + MINIMAP_INFTABLE_TO_OW_ENTRANCE_FLAG(INFTABLE_1A4), 0xFFFF, 0xFFFF, - INFTABLE_1AD_SHIFT, + 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 52e88c1f6f6..e545630966e 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_INDEX_1AX] & - 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, @@ -512,8 +511,7 @@ void Minimap_Draw(PlayState* play) { } } - if ((play->sceneId == SCENE_ZORAS_FOUNTAIN) && - (gSaveContext.save.info.infTable[INFTABLE_INDEX_1AX] & 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 e17b5f3aad3..e50371bd517 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 7987cccd1ce..eeba2b63343 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -3545,11 +3545,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_INDEX_HORSES] &= - (u16) ~(EVENTINF_INGO_RACE_STATE_MASK | EVENTINF_MASK(EVENTINF_INGO_RACE_HORSETYPE) | - EVENTINF_MASK(EVENTINF_INGO_RACE_LOST_ONCE) | - EVENTINF_MASK(EVENTINF_INGO_RACE_SECOND_RACE) | EVENTINF_MASK(EVENTINF_INGO_RACE_0F)); - PRINTF("EVENT_INF=%x\n", gSaveContext.eventInf[EVENTINF_INDEX_HORSES]); + RESET_EVENTINF_INGO_RACE(); + PRINTF("EVENT_INF=%x\n", gSaveContext.eventInf[EVENTINF_INDEX_INGO_RACE]); #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 c8877e0e644..f8b1d98cb52 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,8 +696,11 @@ static s16 sDemoEffectLightColors[] = { DEMO_EFFECT_LIGHT_GREEN, DEMO_EFFECT_LIG static s16 sExItemTypes[] = { EXITEM_MAGIC_WIND, EXITEM_MAGIC_FIRE, EXITEM_MAGIC_DARK }; -static s16 sItemGetFlagMasks[] = { ITEMGETINF_MASK(ITEMGETINF_18), ITEMGETINF_MASK(ITEMGETINF_19), - ITEMGETINF_MASK(ITEMGETINF_1A) }; +#define GREAT_FAIRY_SET_MAGIC_SPELL_OBTAINED(exItemIndex) \ + gSaveContext.save.info.itemGetInf[ITEMGETINF_INDEX_GREAT_FAIRY_ITEM] |= sItemGetFlagMasks[exItemIndex]; + +static s16 sItemGetFlagMasks[] = { ITEMGETINF_MASK(ITEMGETINF_FARORES_WIND), ITEMGETINF_MASK(ITEMGETINF_DINS_FIRE), + ITEMGETINF_MASK(ITEMGETINF_NAYRUS_LOVE) }; static u8 sItemIds[] = { ITEM_FARORES_WIND, ITEM_DINS_FIRE, ITEM_NAYRUS_LOVE }; @@ -809,7 +812,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_INDEX_18_19_1A] |= sItemGetFlagMasks[cueIdTemp]; + GREAT_FAIRY_SET_MAGIC_SPELL_OBTAINED(cueIdTemp); Item_Give(play, sItemIds[cueIdTemp]); } } else { 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 2aa163d0fbc..ce859a4ad88 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_MASK(EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO)) + 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_MASK(EVENTCHKINF_TALON_RETURNED_FROM_KAKARIKO)) + 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_INDEX_TALON_RETURNED_FROM_KAKARIKO]; + 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 7ce346f6333..4d9a9a8bffe 100644 --- a/src/overlays/actors/ovl_En_In/z_en_in.c +++ b/src/overlays/actors/ovl_En_In/z_en_in.c @@ -500,7 +500,7 @@ void EnIn_Init(Actor* thisx, PlayState* play) { respawnPos = respawn->pos; // hardcoded coords for lon lon entrance if (D_80A7B998 == 0 && respawnPos.x == 1107.0f && respawnPos.y == 0.0f && respawnPos.z == -3740.0f) { - gSaveContext.eventInf[EVENTINF_INDEX_HORSES] = 0; + RESET_EVENTINF_INGO_RACE2(); D_80A7B998 = 1; } this->actionFunc = EnIn_WaitForObject; @@ -586,7 +586,7 @@ void EnIn_WaitForObject(EnIn* this, PlayState* play) { case INGO_RACE_STATE_RACING: EnIn_ChangeAnim(this, ENIN_ANIM_2); this->actionFunc = func_80A7A4C8; - gSaveContext.eventInf[EVENTINF_INDEX_HORSES] = 0; + RESET_EVENTINF_INGO_RACE2(); break; case INGO_RACE_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 dbe5e1b15c8..e88ba8fc9c0 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, + EVENTINF_MASK(EVENTINF_20), EVENTINF_MASK(EVENTINF_21), EVENTINF_MASK(EVENTINF_22), + EVENTINF_MASK(EVENTINF_23), EVENTINF_MASK(EVENTINF_24), }; u8 textFlags; s32 randomIndex; s32 i; - textFlags = gSaveContext.eventInf[EVENTINF_INDEX_20_21_22_23_24] & - (EVENTINF_20_MASK | EVENTINF_21_MASK | EVENTINF_22_MASK | EVENTINF_23_MASK | EVENTINF_24_MASK); - gSaveContext.eventInf[EVENTINF_INDEX_20_21_22_23_24] &= - ~(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_INDEX_20_21_22_23_24] |= textFlags; + textFlags &= EVENTINF_HAGGLING_TOWNSFOLK_MASK | 0xE0; + 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 144c76b2cbb..1f4842e298b 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[] = { INFTABLE_MASK(INFTABLE_199), INFTABLE_MASK(INFTABLE_19A), INFTABLE_MASK(INFTABLE_19B), INFTABLE_MASK(INFTABLE_19C), INFTABLE_MASK(INFTABLE_19D), INFTABLE_MASK(INFTABLE_19E), INFTABLE_MASK(INFTABLE_19F), }; @@ -162,8 +165,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_INDEX_199_19A_19B_19C_19D_19E_19F] & - 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 0415f95bb93..1164f8ab612 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[] = { INFTABLE_MASK(INFTABLE_199), INFTABLE_MASK(INFTABLE_19A), INFTABLE_MASK(INFTABLE_19B), INFTABLE_MASK(INFTABLE_19C), INFTABLE_MASK(INFTABLE_19D), INFTABLE_MASK(INFTABLE_19E), INFTABLE_MASK(INFTABLE_19F), @@ -210,8 +219,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_INDEX_199_19A_19B_19C_19D_19E_19F] |= - 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,8 +227,7 @@ void func_80ABA244(EnNiwLady* this, PlayState* play) { } this->cuccosInPen++; } else if (this->unk_26C == 0) { - gSaveContext.save.info.infTable[INFTABLE_INDEX_199_19A_19B_19C_19D_19E_19F] &= - ~D_80ABB3B4[currentCucco->unk_2AA]; + KAKARIKO_CUCCO_RESET_RETURNED(currentCucco->unk_2AA); } } currentCucco = (EnNiw*)currentCucco->actor.next; @@ -276,13 +283,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_INDEX_199_19A_19B_19C_19D_19E_19F]); - gSaveContext.save.info.infTable[INFTABLE_INDEX_199_19A_19B_19C_19D_19E_19F] &= - (u16) ~(INFTABLE_MASK(INFTABLE_199) | INFTABLE_MASK(INFTABLE_19A) | INFTABLE_MASK(INFTABLE_19B) | - INFTABLE_MASK(INFTABLE_19C) | INFTABLE_MASK(INFTABLE_19D) | INFTABLE_MASK(INFTABLE_19E) | - INFTABLE_MASK(INFTABLE_19F)); + 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_INDEX_199_19A_19B_19C_19D_19E_19F]); + gSaveContext.save.info.infTable[INFTABLE_INDEX_KAKARIKO_CUCCO]); PRINTF("\n\n"); this->actionFunc = func_80ABA654; return; diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index e7433105ae3..37ff780581f 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -10760,7 +10760,7 @@ void Player_Init(Actor* thisx, PlayState* play2) { gSaveContext.respawn[RESPAWN_MODE_DOWN].data = 1; if (play->sceneId <= SCENE_INSIDE_GANONS_CASTLE_COLLAPSE) { - gSaveContext.save.info.infTable[INFTABLE_INDEX_1AX] |= 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;