Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure event flags in z64save.h #2303

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 122 additions & 41 deletions include/z64save.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Copy link
Contributor

@Feacur Feacur Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given the other suggestions have been accepted, these might be renamed as

INFTABLE_INDEX_KAKARIKO_CUCCOS
INFTABLE_KAKARIKO_CUCCO_*

for context: #2303 (comment)

#define INFTABLE_19A 0x19A
#define INFTABLE_19B 0x19B
Expand All @@ -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)
Expand All @@ -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,
Expand All @@ -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)
Expand All @@ -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() \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe these defines should keep EVENTINF_ in their names as a prefix?

gSaveContext.eventInf[EVENTINF_INDEX_HAGGLING_TOWNSFOLK] &= ~(EVENTINF_HAGGLING_TOWNSFOLK_MASK);

#define EVENTINF_30 0x30

Expand Down
5 changes: 1 addition & 4 deletions src/code/z_game_over.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
22 changes: 11 additions & 11 deletions src/code/z_map_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {
Expand Down
6 changes: 2 additions & 4 deletions src/code/z_map_exp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/code/z_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 2 additions & 5 deletions src/code/z_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
15 changes: 9 additions & 6 deletions src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 };

Expand Down Expand Up @@ -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 {
Expand Down
Loading