From ec0a080956fd0277f776273b9bfe284f58014498 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Tue, 12 Jul 2022 22:08:25 -0700 Subject: [PATCH 01/19] Rando: Minor feature - quest item fanfares In rando, when we find a special quest item somewhere (e.g. a medallion, stone, or song), play that item's unique fanfare instead of the default "get item" fanfare Closes HarbourMasters/Shipwright#716 --- .../actors/ovl_player_actor/z_player.c | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 1973a09a44..4e1b054df3 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -12675,6 +12675,33 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { else { temp1 = temp2 = (this->getItemId == GI_HEART_PIECE) ? NA_BGM_SMALL_ITEM_GET : NA_BGM_ITEM_GET | 0x900; } + + // In Rando, if we get special quest items (medallions/stones/songs), play their respective unique fanfares + // instead of the default "get item" fanfare + if (gSaveContext.n64ddFlag) { + // If the item we're getting is a medallion, play the "get a medallion" fanfare + if ((this->getItemId == GI_MEDALLION_FOREST) || (this->getItemId == GI_MEDALLION_FIRE) || + (this->getItemId == GI_MEDALLION_WATER) || (this->getItemId == GI_MEDALLION_SHADOW) || + (this->getItemId == GI_MEDALLION_SPIRIT) || (this->getItemId == GI_MEDALLION_LIGHT)) { + temp1 = NA_BGM_MEDALLION_GET | 0x900; + } + // If it's a Spiritual Stone, play the "get a spiritual stone" fanfare + if ((this->getItemId == GI_STONE_KOKIRI) || (this->getItemId == GI_STONE_GORON) || + (this->getItemId == GI_STONE_ZORA)) { + temp1 = NA_BGM_SPIRITUAL_STONE | 0x900; + } + // If the item we're getting is a song, play the "learned a song" fanfare + if ((this->getItemId == GI_SONG_OF_STORMS) || (this->getItemId == GI_SERENADE_OF_WATER) || + (this->getItemId == GI_EPONAS_SONG) || (this->getItemId == GI_SARIAS_SONG) || + (this->getItemId == GI_SUNS_SONG) || (this->getItemId == GI_SONG_OF_TIME) || + (this->getItemId == GI_PRELUDE_OF_LIGHT) || (this->getItemId == GI_MINUET_OF_FOREST) || + (this->getItemId == GI_BOLERO_OF_FIRE) || (this->getItemId == GI_NOCTURNE_OF_SHADOW) || + (this->getItemId == GI_REQUIEM_OF_SPIRIT) || (this->getItemId == GI_PRELUDE_OF_LIGHT)) { + temp1 = NA_BGM_OCA_FAIRY_GET | 0x900; + } + } + // *************************************************************************************** + Audio_PlayFanfare(temp1); } } From d424ee6fa88658852d76f08a1915a2f7ae9fec27 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Tue, 12 Jul 2022 22:21:30 -0700 Subject: [PATCH 02/19] Fix Zelda's Lullaby Accidentally had prelude in there twice --- soh/src/overlays/actors/ovl_player_actor/z_player.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 4e1b054df3..b78a8cce33 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -12696,7 +12696,7 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { (this->getItemId == GI_SUNS_SONG) || (this->getItemId == GI_SONG_OF_TIME) || (this->getItemId == GI_PRELUDE_OF_LIGHT) || (this->getItemId == GI_MINUET_OF_FOREST) || (this->getItemId == GI_BOLERO_OF_FIRE) || (this->getItemId == GI_NOCTURNE_OF_SHADOW) || - (this->getItemId == GI_REQUIEM_OF_SPIRIT) || (this->getItemId == GI_PRELUDE_OF_LIGHT)) { + (this->getItemId == GI_REQUIEM_OF_SPIRIT) || (this->getItemId == GI_ZELDAS_LULLABY)) { temp1 = NA_BGM_OCA_FAIRY_GET | 0x900; } } From dd761295fc7a6ba022684e417c96e5bcc352a8ba Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Wed, 13 Jul 2022 13:34:01 -0700 Subject: [PATCH 03/19] Add logic to also check for a toggle setting Added && for the gRandoFanfareByItemType to allow this to be a toggle setting --- soh/src/overlays/actors/ovl_player_actor/z_player.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index b78a8cce33..073a25f0b5 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -12677,8 +12677,8 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { } // In Rando, if we get special quest items (medallions/stones/songs), play their respective unique fanfares - // instead of the default "get item" fanfare - if (gSaveContext.n64ddFlag) { + // instead of the default "get item" fanfare (if we have the setting toggled on) + if (gSaveContext.n64ddFlag && CVar_GetS32("gRandoFanfareByItemType", 0)) { // If the item we're getting is a medallion, play the "get a medallion" fanfare if ((this->getItemId == GI_MEDALLION_FOREST) || (this->getItemId == GI_MEDALLION_FIRE) || (this->getItemId == GI_MEDALLION_WATER) || (this->getItemId == GI_MEDALLION_SHADOW) || From fa1327553d4a37b6253def5874b71d0b802c1a6b Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Wed, 13 Jul 2022 15:12:44 -0700 Subject: [PATCH 04/19] Fix syntax I think the !=0 is needed --- soh/src/overlays/actors/ovl_player_actor/z_player.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 073a25f0b5..f1d0fa6b48 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -12678,7 +12678,7 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { // In Rando, if we get special quest items (medallions/stones/songs), play their respective unique fanfares // instead of the default "get item" fanfare (if we have the setting toggled on) - if (gSaveContext.n64ddFlag && CVar_GetS32("gRandoFanfareByItemType", 0)) { + if (gSaveContext.n64ddFlag && CVar_GetS32("gRandoFanfareByItemType", 0) != 0) { // If the item we're getting is a medallion, play the "get a medallion" fanfare if ((this->getItemId == GI_MEDALLION_FOREST) || (this->getItemId == GI_MEDALLION_FIRE) || (this->getItemId == GI_MEDALLION_WATER) || (this->getItemId == GI_MEDALLION_SHADOW) || From cf0b68c572154a6df703bbb4e19a84e96990af8f Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Sat, 16 Jul 2022 00:24:38 -0700 Subject: [PATCH 05/19] Allow Equipment Toggle Allow player to toggle equipment on/off on the equipment subscreen. For tunics and boots, this will revert them to Kokiri Tunic/Kokiri Boots. For shields, it will un-equip the shield entirely. For swords, only BGS/Giant's Knife is affected, and it will revert to Master Sword. --- .../ovl_kaleido_scope/z_kaleido_equipment.c | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c index a7d22e5845..7309193518 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c @@ -503,12 +503,48 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) { (gEquipAgeReqs[pauseCtx->cursorY[PAUSE_EQUIP]][pauseCtx->cursorX[PAUSE_EQUIP]] == ((void)0, gSaveContext.linkAge))) { if (CHECK_BTN_ALL(input->press.button, BTN_A)) { + + // Allow Link to remove his equipment from the equipment subscreen by toggling on/off + // Shields will be un-equipped entirely, and tunics/boots will revert to Kokiri Tunic/Kokiri Boots + // Only BGS/Giant's Knife is affected, and it will revert to Master Sword. + + // If we have the feature toggled on + if (CVar_GetS32("gEquipmentCanBeRemoved", 0)) { + + // If we're on the "swords" section of the equipment screen AND we're on a currently-equipped BGS/Giant's Knife + if (pauseCtx->cursorY[PAUSE_EQUIP] == 0 && pauseCtx->cursorX[PAUSE_EQUIP] == 3 && CUR_EQUIP_VALUE(EQUIP_SWORD) == 3) { + Inventory_ChangeEquipment(EQUIP_SWORD, 2); // "Unequip" it by equipping Master Sword + gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; + gSaveContext.infTable[29] = 0; + goto RESUME_EQUIPMENT_SWORD; // Skip to here so we don't re-equip it + } + + // If we're on the "shields" section of the equipment screen AND we're on a currently-equipped shield + if (pauseCtx->cursorY[PAUSE_EQUIP] == 1 && pauseCtx->cursorX[PAUSE_EQUIP] == CUR_EQUIP_VALUE(EQUIP_SHIELD)) { + Inventory_ChangeEquipment(EQUIP_SHIELD, 0); // Unequip it + goto RESUME_EQUIPMENT; // Skip to here so we don't re-equip it + } + + // If we're on the "tunics" section of the equipment screen AND we're on a currently-equipped tunic + if (pauseCtx->cursorY[PAUSE_EQUIP] == 2 && pauseCtx->cursorX[PAUSE_EQUIP] == CUR_EQUIP_VALUE(EQUIP_TUNIC)) { + Inventory_ChangeEquipment(EQUIP_TUNIC, 1); // "Unequip" it (by equipping Kokiri Tunic) + goto RESUME_EQUIPMENT; // Skip to here so we don't re-equip it + } + + // If we're on the "boots" section of the equipment screen AND we're on currently-equipped boots + if (pauseCtx->cursorY[PAUSE_EQUIP] == 3 && pauseCtx->cursorX[PAUSE_EQUIP] == CUR_EQUIP_VALUE(EQUIP_BOOTS)) { + Inventory_ChangeEquipment(EQUIP_BOOTS, 1); // "Unequip" it (by equipping Kokiri Boots) + goto RESUME_EQUIPMENT; // Skip to here so we don't re-equip it + } + } + if (CHECK_OWNED_EQUIP(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP] - 1)) { Inventory_ChangeEquipment(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP]); } else { goto EQUIP_FAIL; } + RESUME_EQUIPMENT: if (pauseCtx->cursorY[PAUSE_EQUIP] == 0) { gSaveContext.infTable[29] = 0; gSaveContext.equips.buttonItems[0] = cursorItem; @@ -525,7 +561,7 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_KNIFE; } } - + RESUME_EQUIPMENT_SWORD: Interface_LoadItemIcon1(globalCtx, 0); } From efe3294f1c08956441d0100a106fcaea39fbfe34 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Sat, 16 Jul 2022 10:10:34 -0700 Subject: [PATCH 06/19] Set up Cvar and check for MS Set up the cvar/imgui and add a check that we own the Master Sword (in case we're in the Ganon fight) --- libultraship/libultraship/ImGuiImpl.cpp | 2 ++ soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index 153a193e8d..d14f99128c 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -1001,6 +1001,8 @@ namespace SohImGui { Tooltip("Displays an icon and plays a sound when Stone of Agony\nshould be activated, for those without rumble"); EnhancementCheckbox("Assignable Tunics and Boots", "gAssignableTunicsAndBoots"); Tooltip("Allows equipping the tunic and boots to c-buttons"); + EnhancementCheckbox("Equipment Toggle", "gEquipmentCanBeRemoved"); + Tooltip("Allows equipment to be removed by toggling it off on\nthe equipment subscreen."); EnhancementCheckbox("Link's Cow in Both Time Periods", "gCowOfTime"); Tooltip("Allows the Lon Lon Ranch obstacle course reward to be\nshared across time periods"); EnhancementCheckbox("Enable visible guard vision", "gGuardVision"); diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c index 7309193518..f08fc9abaa 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c @@ -512,7 +512,8 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) { if (CVar_GetS32("gEquipmentCanBeRemoved", 0)) { // If we're on the "swords" section of the equipment screen AND we're on a currently-equipped BGS/Giant's Knife - if (pauseCtx->cursorY[PAUSE_EQUIP] == 0 && pauseCtx->cursorX[PAUSE_EQUIP] == 3 && CUR_EQUIP_VALUE(EQUIP_SWORD) == 3) { + if (pauseCtx->cursorY[PAUSE_EQUIP] == 0 && pauseCtx->cursorX[PAUSE_EQUIP] == 3 + && CUR_EQUIP_VALUE(EQUIP_SWORD) == 3 && CHECK_OWNED_EQUIP(0,1)){ // And we have the Master Sword Inventory_ChangeEquipment(EQUIP_SWORD, 2); // "Unequip" it by equipping Master Sword gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; gSaveContext.infTable[29] = 0; From 3de4e955db89b176e72654022dff34ba96be96fd Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Mon, 18 Jul 2022 14:44:55 -0700 Subject: [PATCH 07/19] Giant's Knife Behaviour Fixes Fixes a case where Giant's Knife (specifically, breaking and re-buying it) can behave unexpectedly if you don't have a Kokiri Sword in your inventory. Also fixes the broken icon not showing up in inventory after you break it. --- soh/src/code/z_parameter.c | 7 +++++-- .../overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 0ac1e1048c..9266343397 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -1676,13 +1676,16 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { if (item == ITEM_SWORD_BGS) { gSaveContext.swordHealth = 8; - if (ALL_EQUIP_VALUE(EQUIP_SWORD) == 0xF) { - gSaveContext.inventory.equipment ^= 8 << gEquipShifts[EQUIP_SWORD]; + if (ALL_EQUIP_VALUE(EQUIP_SWORD) == 0xF + ||(gSaveContext.n64ddFlag && ALL_EQUIP_VALUE(EQUIP_SWORD))) { // In rando, when buying Giant's Knife, also check + gSaveContext.inventory.equipment ^= 8 << gEquipShifts[EQUIP_SWORD]; // for 0xE in case we don't have Kokiri Sword if (gSaveContext.equips.buttonItems[0] == ITEM_SWORD_KNIFE) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_BGS; Interface_LoadItemIcon1(globalCtx, 0); } } + + } else if (item == ITEM_SWORD_MASTER) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; gSaveContext.equips.equipment &= 0xFFF0; diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c index a7d22e5845..79b43eb3cc 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c @@ -652,7 +652,10 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) { gsDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109, 255); gsSPGrayscale(POLY_KAL_DISP++, true); } - KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gItemIcons[itemId], 32, 32, point); + + if (!((i == 0) && (k == 2) && (gBitFlags[bit + 1] & gSaveContext.inventory.equipment))) { // Don't draw the full BGS icon when we have a broken Giant's Knife + KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gItemIcons[itemId], 32, 32, point); + } gsSPGrayscale(POLY_KAL_DISP++, false); } } From b188ed8fb4770945cb99b5e4811c7cff44dc5540 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Mon, 18 Jul 2022 14:47:15 -0700 Subject: [PATCH 08/19] less whitespace --- soh/src/code/z_parameter.c | 1 - 1 file changed, 1 deletion(-) diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 9266343397..3baf7dd772 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -1685,7 +1685,6 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { } } - } else if (item == ITEM_SWORD_MASTER) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; gSaveContext.equips.equipment &= 0xFFF0; From cb1b725cdab2c7b1309f8076454c0ae914600253 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Mon, 18 Jul 2022 18:39:24 -0700 Subject: [PATCH 09/19] Shorten code Shortened the code --- .../actors/ovl_player_actor/z_player.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 916116156f..c518e7c2e9 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -12679,28 +12679,18 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { // In Rando, if we get special quest items (medallions/stones/songs), play their respective unique fanfares // instead of the default "get item" fanfare (if we have the setting toggled on) if (gSaveContext.n64ddFlag && CVar_GetS32("gRandoFanfareByItemType", 0) != 0) { - // If the item we're getting is a medallion, play the "get a medallion" fanfare - if ((this->getItemId == GI_MEDALLION_FOREST) || (this->getItemId == GI_MEDALLION_FIRE) || - (this->getItemId == GI_MEDALLION_WATER) || (this->getItemId == GI_MEDALLION_SHADOW) || - (this->getItemId == GI_MEDALLION_SPIRIT) || (this->getItemId == GI_MEDALLION_LIGHT)) { + if ((this->getItemId >= GI_MEDALLION_LIGHT) && (this->getItemId <= GI_MEDALLION_SPIRIT)) { temp1 = NA_BGM_MEDALLION_GET | 0x900; } // If it's a Spiritual Stone, play the "get a spiritual stone" fanfare - if ((this->getItemId == GI_STONE_KOKIRI) || (this->getItemId == GI_STONE_GORON) || - (this->getItemId == GI_STONE_ZORA)) { + if ((this->getItemId >= GI_STONE_KOKIRI) && (this->getItemId <= GI_STONE_ZORA)) { temp1 = NA_BGM_SPIRITUAL_STONE | 0x900; } // If the item we're getting is a song, play the "learned a song" fanfare - if ((this->getItemId == GI_SONG_OF_STORMS) || (this->getItemId == GI_SERENADE_OF_WATER) || - (this->getItemId == GI_EPONAS_SONG) || (this->getItemId == GI_SARIAS_SONG) || - (this->getItemId == GI_SUNS_SONG) || (this->getItemId == GI_SONG_OF_TIME) || - (this->getItemId == GI_PRELUDE_OF_LIGHT) || (this->getItemId == GI_MINUET_OF_FOREST) || - (this->getItemId == GI_BOLERO_OF_FIRE) || (this->getItemId == GI_NOCTURNE_OF_SHADOW) || - (this->getItemId == GI_REQUIEM_OF_SPIRIT) || (this->getItemId == GI_ZELDAS_LULLABY)) { + if ((this->getItemId >= GI_ZELDAS_LULLABY) && (this->getItemId <= GI_PRELUDE_OF_LIGHT)) { temp1 = NA_BGM_OCA_FAIRY_GET | 0x900; } - } - // *************************************************************************************** + } // *************************************************************************************** Audio_PlayFanfare(temp1); } From d9f4314f5c65154e5824e8f6a6060863bd9986d9 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Mon, 18 Jul 2022 19:01:47 -0700 Subject: [PATCH 10/19] Undo accidental commit I'm a dummy and accidentally committed changes from other branches I was working on. --- libultraship/libultraship/ImGuiImpl.cpp | 2 - soh/src/code/z_parameter.c | 6 +-- .../ovl_kaleido_scope/z_kaleido_equipment.c | 44 +------------------ 3 files changed, 4 insertions(+), 48 deletions(-) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index 55316f2e34..b9ce62aee9 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -1105,8 +1105,6 @@ namespace SohImGui { Tooltip("Displays an icon and plays a sound when Stone of Agony\nshould be activated, for those without rumble"); EnhancementCheckbox("Assignable Tunics and Boots", "gAssignableTunicsAndBoots"); Tooltip("Allows equipping the tunic and boots to c-buttons"); - EnhancementCheckbox("Equipment Toggle", "gEquipmentCanBeRemoved"); - Tooltip("Allows equipment to be removed by toggling it off on\nthe equipment subscreen."); EnhancementCheckbox("Link's Cow in Both Time Periods", "gCowOfTime"); Tooltip("Allows the Lon Lon Ranch obstacle course reward to be\nshared across time periods"); EnhancementCheckbox("Enable visible guard vision", "gGuardVision"); diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 713ac3f9cd..4a79bd3bc5 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -1676,15 +1676,13 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { if (item == ITEM_SWORD_BGS) { gSaveContext.swordHealth = 8; - if (ALL_EQUIP_VALUE(EQUIP_SWORD) == 0xF - ||(gSaveContext.n64ddFlag && ALL_EQUIP_VALUE(EQUIP_SWORD))) { // In rando, when buying Giant's Knife, also check - gSaveContext.inventory.equipment ^= 8 << gEquipShifts[EQUIP_SWORD]; // for 0xE in case we don't have Kokiri Sword + if (ALL_EQUIP_VALUE(EQUIP_SWORD) == 0xF) { + gSaveContext.inventory.equipment ^= 8 << gEquipShifts[EQUIP_SWORD]; if (gSaveContext.equips.buttonItems[0] == ITEM_SWORD_KNIFE) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_BGS; Interface_LoadItemIcon1(globalCtx, 0); } } - } else if (item == ITEM_SWORD_MASTER) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; gSaveContext.equips.equipment &= 0xFFF0; diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c index f0af1a5aa7..a7d22e5845 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c @@ -503,49 +503,12 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) { (gEquipAgeReqs[pauseCtx->cursorY[PAUSE_EQUIP]][pauseCtx->cursorX[PAUSE_EQUIP]] == ((void)0, gSaveContext.linkAge))) { if (CHECK_BTN_ALL(input->press.button, BTN_A)) { - - // Allow Link to remove his equipment from the equipment subscreen by toggling on/off - // Shields will be un-equipped entirely, and tunics/boots will revert to Kokiri Tunic/Kokiri Boots - // Only BGS/Giant's Knife is affected, and it will revert to Master Sword. - - // If we have the feature toggled on - if (CVar_GetS32("gEquipmentCanBeRemoved", 0)) { - - // If we're on the "swords" section of the equipment screen AND we're on a currently-equipped BGS/Giant's Knife - if (pauseCtx->cursorY[PAUSE_EQUIP] == 0 && pauseCtx->cursorX[PAUSE_EQUIP] == 3 - && CUR_EQUIP_VALUE(EQUIP_SWORD) == 3 && CHECK_OWNED_EQUIP(0,1)){ // And we have the Master Sword - Inventory_ChangeEquipment(EQUIP_SWORD, 2); // "Unequip" it by equipping Master Sword - gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; - gSaveContext.infTable[29] = 0; - goto RESUME_EQUIPMENT_SWORD; // Skip to here so we don't re-equip it - } - - // If we're on the "shields" section of the equipment screen AND we're on a currently-equipped shield - if (pauseCtx->cursorY[PAUSE_EQUIP] == 1 && pauseCtx->cursorX[PAUSE_EQUIP] == CUR_EQUIP_VALUE(EQUIP_SHIELD)) { - Inventory_ChangeEquipment(EQUIP_SHIELD, 0); // Unequip it - goto RESUME_EQUIPMENT; // Skip to here so we don't re-equip it - } - - // If we're on the "tunics" section of the equipment screen AND we're on a currently-equipped tunic - if (pauseCtx->cursorY[PAUSE_EQUIP] == 2 && pauseCtx->cursorX[PAUSE_EQUIP] == CUR_EQUIP_VALUE(EQUIP_TUNIC)) { - Inventory_ChangeEquipment(EQUIP_TUNIC, 1); // "Unequip" it (by equipping Kokiri Tunic) - goto RESUME_EQUIPMENT; // Skip to here so we don't re-equip it - } - - // If we're on the "boots" section of the equipment screen AND we're on currently-equipped boots - if (pauseCtx->cursorY[PAUSE_EQUIP] == 3 && pauseCtx->cursorX[PAUSE_EQUIP] == CUR_EQUIP_VALUE(EQUIP_BOOTS)) { - Inventory_ChangeEquipment(EQUIP_BOOTS, 1); // "Unequip" it (by equipping Kokiri Boots) - goto RESUME_EQUIPMENT; // Skip to here so we don't re-equip it - } - } - if (CHECK_OWNED_EQUIP(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP] - 1)) { Inventory_ChangeEquipment(pauseCtx->cursorY[PAUSE_EQUIP], pauseCtx->cursorX[PAUSE_EQUIP]); } else { goto EQUIP_FAIL; } - RESUME_EQUIPMENT: if (pauseCtx->cursorY[PAUSE_EQUIP] == 0) { gSaveContext.infTable[29] = 0; gSaveContext.equips.buttonItems[0] = cursorItem; @@ -562,7 +525,7 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_KNIFE; } } - RESUME_EQUIPMENT_SWORD: + Interface_LoadItemIcon1(globalCtx, 0); } @@ -689,10 +652,7 @@ void KaleidoScope_DrawEquipment(GlobalContext* globalCtx) { gsDPSetGrayscaleColor(POLY_KAL_DISP++, 109, 109, 109, 255); gsSPGrayscale(POLY_KAL_DISP++, true); } - - if (!((i == 0) && (k == 2) && (gBitFlags[bit + 1] & gSaveContext.inventory.equipment))) { // Don't draw the full BGS icon when we have a broken Giant's Knife - KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gItemIcons[itemId], 32, 32, point); - } + KaleidoScope_DrawQuadTextureRGBA32(globalCtx->state.gfxCtx, gItemIcons[itemId], 32, 32, point); gsSPGrayscale(POLY_KAL_DISP++, false); } } From 068f3426d754b569050d5509ff17cc12a85342ad Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Sat, 23 Jul 2022 23:25:35 -0700 Subject: [PATCH 11/19] Account for tokensanity Added changes to restore small item fanfares to rupees, heart containers, and items when picked up from skulltulas in tokensanity. --- soh/src/overlays/actors/ovl_En_Si/z_en_si.c | 45 ++++++++++++++++++- .../actors/ovl_player_actor/z_player.c | 35 +++++++++------ 2 files changed, 65 insertions(+), 15 deletions(-) diff --git a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c index aa67f1a20f..a7d4271d8c 100644 --- a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -115,7 +115,50 @@ void func_80AFB768(EnSi* this, GlobalContext* globalCtx) { player->actor.freezeTimer = 20; } Message_StartTextbox(globalCtx, textId, NULL); - Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); + + // Restore appropriate item fanfares in rando when we're obtaining items outside of their + // normal contexts (this code more or less copied from z_player.c) + if (gSaveContext.n64ddFlag) { + s32 temp1; + + if (((getItemId >= GI_RUPEE_GREEN) && (getItemId <= GI_RUPEE_RED)) || + ((getItemId >= GI_RUPEE_PURPLE) && (getItemId <= GI_RUPEE_GOLD)) || + ((getItemId >= GI_RUPEE_GREEN_LOSE) && (getItemId <= GI_RUPEE_PURPLE_LOSE)) || + (getItemId == GI_HEART)) { + Audio_PlaySoundGeneral(NA_SE_SY_GET_BOXITEM, &D_801333D4, 4, &D_801333E0, &D_801333E0, + &D_801333E8); + } else { + if ((getItemId == GI_HEART_CONTAINER_2) || (getItemId == GI_HEART_CONTAINER) || + ((getItemId == GI_HEART_PIECE) && + ((gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000))) { + temp1 = NA_BGM_HEART_GET | 0x900; + } else { + temp1 = (getItemId == GI_HEART_PIECE) ? NA_BGM_SMALL_ITEM_GET : NA_BGM_ITEM_GET | 0x900; + } + // If we get a skulltula token, play "get small item" + if (getItemId == GI_SKULL_TOKEN) { + temp1 = NA_BGM_SMALL_ITEM_GET | 0x900; + } + // If the setting is toggled on and we get special quest items (longer fanfares): + if (CVar_GetS32("gRandoFanfareByItemType", 0) != 0) { + // If we get a medallion, play the "get a medallion" fanfare + if ((getItemId >= GI_MEDALLION_LIGHT) && (getItemId <= GI_MEDALLION_SPIRIT)) { + temp1 = NA_BGM_MEDALLION_GET | 0x900; + } + // If it's a Spiritual Stone, play the "get a spiritual stone" fanfare + if ((getItemId >= GI_STONE_KOKIRI) && (getItemId <= GI_STONE_ZORA)) { + temp1 = NA_BGM_SPIRITUAL_STONE | 0x900; + } + // If the item we're getting is a song, play the "learned a song" fanfare + if ((getItemId >= GI_ZELDAS_LULLABY) && (getItemId <= GI_PRELUDE_OF_LIGHT)) { + temp1 = NA_BGM_OCA_FAIRY_GET | 0x900; + } + } + Audio_PlayFanfare(temp1); + }// ********************************************* + } else { + Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); + } this->actionFunc = func_80AFB950; } else { Collider_UpdateCylinder(&this->actor, &this->collider); diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index c53be404fa..8f2091bca4 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -12700,21 +12700,28 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { temp1 = temp2 = (this->getItemId == GI_HEART_PIECE) ? NA_BGM_SMALL_ITEM_GET : NA_BGM_ITEM_GET | 0x900; } - // In Rando, if we get special quest items (medallions/stones/songs), play their respective unique fanfares - // instead of the default "get item" fanfare (if we have the setting toggled on) - if (gSaveContext.n64ddFlag && CVar_GetS32("gRandoFanfareByItemType", 0) != 0) { - if ((this->getItemId >= GI_MEDALLION_LIGHT) && (this->getItemId <= GI_MEDALLION_SPIRIT)) { - temp1 = NA_BGM_MEDALLION_GET | 0x900; + // Restore appropriate item fanfares in rando when we're obtaining items outside of their normal contexts + if (gSaveContext.n64ddFlag) { + // If we get a skulltula token, play "get small item" (for tokensanity) + if (this->getItemId == GI_SKULL_TOKEN) { + temp1 = NA_BGM_SMALL_ITEM_GET | 0x900; + } + // If the setting is toggled on and we get special quest items (longer fanfares): + if (CVar_GetS32("gRandoFanfareByItemType", 0) != 0) { + // If we get a medallion, play the "get a medallion" fanfare + if ((this->getItemId >= GI_MEDALLION_LIGHT) && (this->getItemId <= GI_MEDALLION_SPIRIT)) { + temp1 = NA_BGM_MEDALLION_GET | 0x900; + } + // If it's a Spiritual Stone, play the "get a spiritual stone" fanfare + if ((this->getItemId >= GI_STONE_KOKIRI) && (this->getItemId <= GI_STONE_ZORA)) { + temp1 = NA_BGM_SPIRITUAL_STONE | 0x900; + } + // If the item we're getting is a song, play the "learned a song" fanfare + if ((this->getItemId >= GI_ZELDAS_LULLABY) && (this->getItemId <= GI_PRELUDE_OF_LIGHT)) { + temp1 = NA_BGM_OCA_FAIRY_GET | 0x900; + } } - // If it's a Spiritual Stone, play the "get a spiritual stone" fanfare - if ((this->getItemId >= GI_STONE_KOKIRI) && (this->getItemId <= GI_STONE_ZORA)) { - temp1 = NA_BGM_SPIRITUAL_STONE | 0x900; - } - // If the item we're getting is a song, play the "learned a song" fanfare - if ((this->getItemId >= GI_ZELDAS_LULLABY) && (this->getItemId <= GI_PRELUDE_OF_LIGHT)) { - temp1 = NA_BGM_OCA_FAIRY_GET | 0x900; - } - } // *************************************************************************************** + }// *************************************************************************************** Audio_PlayFanfare(temp1); } From 70e4f216edb49b0dfe63212ece07377fefdeeb28 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Sun, 24 Jul 2022 00:53:37 -0700 Subject: [PATCH 12/19] Account for boomerang/hookshot tokens Fixed the case where you get the token via the boomerang or hookshot. Done by separating out the code into its own function and then calling it in the two appropriate spots. --- soh/src/overlays/actors/ovl_En_Si/z_en_si.c | 86 +++++++++++---------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c index a7d4271d8c..922f4ae69d 100644 --- a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -17,6 +17,7 @@ s32 func_80AFB748(EnSi* this, GlobalContext* globalCtx); void func_80AFB768(EnSi* this, GlobalContext* globalCtx); void func_80AFB89C(EnSi* this, GlobalContext* globalCtx); void func_80AFB950(EnSi* this, GlobalContext* globalCtx); +void Audio_PlayFanfare_Rando(); s32 textId = 0xB4; s32 giveItemId = ITEM_SKULL_TOKEN; @@ -116,46 +117,8 @@ void func_80AFB768(EnSi* this, GlobalContext* globalCtx) { } Message_StartTextbox(globalCtx, textId, NULL); - // Restore appropriate item fanfares in rando when we're obtaining items outside of their - // normal contexts (this code more or less copied from z_player.c) if (gSaveContext.n64ddFlag) { - s32 temp1; - - if (((getItemId >= GI_RUPEE_GREEN) && (getItemId <= GI_RUPEE_RED)) || - ((getItemId >= GI_RUPEE_PURPLE) && (getItemId <= GI_RUPEE_GOLD)) || - ((getItemId >= GI_RUPEE_GREEN_LOSE) && (getItemId <= GI_RUPEE_PURPLE_LOSE)) || - (getItemId == GI_HEART)) { - Audio_PlaySoundGeneral(NA_SE_SY_GET_BOXITEM, &D_801333D4, 4, &D_801333E0, &D_801333E0, - &D_801333E8); - } else { - if ((getItemId == GI_HEART_CONTAINER_2) || (getItemId == GI_HEART_CONTAINER) || - ((getItemId == GI_HEART_PIECE) && - ((gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000))) { - temp1 = NA_BGM_HEART_GET | 0x900; - } else { - temp1 = (getItemId == GI_HEART_PIECE) ? NA_BGM_SMALL_ITEM_GET : NA_BGM_ITEM_GET | 0x900; - } - // If we get a skulltula token, play "get small item" - if (getItemId == GI_SKULL_TOKEN) { - temp1 = NA_BGM_SMALL_ITEM_GET | 0x900; - } - // If the setting is toggled on and we get special quest items (longer fanfares): - if (CVar_GetS32("gRandoFanfareByItemType", 0) != 0) { - // If we get a medallion, play the "get a medallion" fanfare - if ((getItemId >= GI_MEDALLION_LIGHT) && (getItemId <= GI_MEDALLION_SPIRIT)) { - temp1 = NA_BGM_MEDALLION_GET | 0x900; - } - // If it's a Spiritual Stone, play the "get a spiritual stone" fanfare - if ((getItemId >= GI_STONE_KOKIRI) && (getItemId <= GI_STONE_ZORA)) { - temp1 = NA_BGM_SPIRITUAL_STONE | 0x900; - } - // If the item we're getting is a song, play the "learned a song" fanfare - if ((getItemId >= GI_ZELDAS_LULLABY) && (getItemId <= GI_PRELUDE_OF_LIGHT)) { - temp1 = NA_BGM_OCA_FAIRY_GET | 0x900; - } - } - Audio_PlayFanfare(temp1); - }// ********************************************* + Audio_PlayFanfare_Rando(); } else { Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); } @@ -192,11 +155,54 @@ void func_80AFB89C(EnSi* this, GlobalContext* globalCtx) { Item_Give(globalCtx, giveItemId); } Message_StartTextbox(globalCtx, textId, NULL); - Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); + if (gSaveContext.n64ddFlag) { + Audio_PlayFanfare_Rando(); + } else { + Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); + } this->actionFunc = func_80AFB950; } } +// Function to play "get-item" fanfares according to the type of item obtained (used in rando) +// Longer fanfares for medallions/stones/songs are behind the Cvar +void Audio_PlayFanfare_Rando() { + s32 temp1; + + if (((getItemId >= GI_RUPEE_GREEN) && (getItemId <= GI_RUPEE_RED)) || + ((getItemId >= GI_RUPEE_PURPLE) && (getItemId <= GI_RUPEE_GOLD)) || + ((getItemId >= GI_RUPEE_GREEN_LOSE) && (getItemId <= GI_RUPEE_PURPLE_LOSE)) || (getItemId == GI_HEART)) { + Audio_PlaySoundGeneral(NA_SE_SY_GET_BOXITEM, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else { + if ((getItemId == GI_HEART_CONTAINER_2) || (getItemId == GI_HEART_CONTAINER) || + ((getItemId == GI_HEART_PIECE) && ((gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000))) { + temp1 = NA_BGM_HEART_GET | 0x900; + } else { + temp1 = (getItemId == GI_HEART_PIECE) ? NA_BGM_SMALL_ITEM_GET : NA_BGM_ITEM_GET | 0x900; + } + // If we get a skulltula token, play "get small item" + if (getItemId == GI_SKULL_TOKEN) { + temp1 = NA_BGM_SMALL_ITEM_GET | 0x900; + } + // If the setting is toggled on and we get special quest items (longer fanfares): + if (CVar_GetS32("gRandoFanfareByItemType", 0) != 0) { + // If we get a medallion, play the "get a medallion" fanfare + if ((getItemId >= GI_MEDALLION_LIGHT) && (getItemId <= GI_MEDALLION_SPIRIT)) { + temp1 = NA_BGM_MEDALLION_GET | 0x900; + } + // If it's a Spiritual Stone, play the "get a spiritual stone" fanfare + if ((getItemId >= GI_STONE_KOKIRI) && (getItemId <= GI_STONE_ZORA)) { + temp1 = NA_BGM_SPIRITUAL_STONE | 0x900; + } + // If the item we're getting is a song, play the "learned a song" fanfare + if ((getItemId >= GI_ZELDAS_LULLABY) && (getItemId <= GI_PRELUDE_OF_LIGHT)) { + temp1 = NA_BGM_OCA_FAIRY_GET | 0x900; + } + } + Audio_PlayFanfare(temp1); + } +} + void func_80AFB950(EnSi* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); From 6c72d39f79ecef7551648a6e25ea8f2340b9386f Mon Sep 17 00:00:00 2001 From: Sarge-117 <108380086+Sarge-117@users.noreply.github.com> Date: Sun, 24 Jul 2022 11:01:57 -0700 Subject: [PATCH 13/19] Remove comment border Co-authored-by: PurpleHato --- soh/src/overlays/actors/ovl_player_actor/z_player.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 8f2091bca4..9d05830d45 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -12721,7 +12721,7 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { temp1 = NA_BGM_OCA_FAIRY_GET | 0x900; } } - }// *************************************************************************************** + } Audio_PlayFanfare(temp1); } From 5ad90bf71b9b1a3c1614199219beb0ede9ed3afd Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Sun, 24 Jul 2022 12:51:55 -0700 Subject: [PATCH 14/19] Change cvar name for accuracy Changed Cvar from "gRandoFanfareByItemType" to "gRandoQuestItemFanfares" for better accuracy --- soh/src/overlays/actors/ovl_En_Si/z_en_si.c | 2 +- soh/src/overlays/actors/ovl_player_actor/z_player.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c index 922f4ae69d..9c3ede3d31 100644 --- a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -185,7 +185,7 @@ void Audio_PlayFanfare_Rando() { temp1 = NA_BGM_SMALL_ITEM_GET | 0x900; } // If the setting is toggled on and we get special quest items (longer fanfares): - if (CVar_GetS32("gRandoFanfareByItemType", 0) != 0) { + if (CVar_GetS32("gRandoQuestItemFanfares", 0) != 0) { // If we get a medallion, play the "get a medallion" fanfare if ((getItemId >= GI_MEDALLION_LIGHT) && (getItemId <= GI_MEDALLION_SPIRIT)) { temp1 = NA_BGM_MEDALLION_GET | 0x900; diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 9d05830d45..c906eb1629 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -12707,7 +12707,7 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { temp1 = NA_BGM_SMALL_ITEM_GET | 0x900; } // If the setting is toggled on and we get special quest items (longer fanfares): - if (CVar_GetS32("gRandoFanfareByItemType", 0) != 0) { + if (CVar_GetS32("gRandoQuestItemFanfares", 0) != 0) { // If we get a medallion, play the "get a medallion" fanfare if ((this->getItemId >= GI_MEDALLION_LIGHT) && (this->getItemId <= GI_MEDALLION_SPIRIT)) { temp1 = NA_BGM_MEDALLION_GET | 0x900; From c6cd0f5e03610c0d8cf6d63aebf2db28a949e5b3 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Mon, 25 Jul 2022 12:43:36 -0700 Subject: [PATCH 15/19] Fix special case with the "WINNER" heart The "WINNER" heart is its own unique item rather than just another piece of heart, so it needed its own check to make it consistent with other pieces of heart --- soh/src/overlays/actors/ovl_En_Si/z_en_si.c | 8 ++++++-- soh/src/overlays/actors/ovl_player_actor/z_player.c | 11 ++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c index 9c3ede3d31..1aba4fae3a 100644 --- a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -180,10 +180,14 @@ void Audio_PlayFanfare_Rando() { } else { temp1 = (getItemId == GI_HEART_PIECE) ? NA_BGM_SMALL_ITEM_GET : NA_BGM_ITEM_GET | 0x900; } - // If we get a skulltula token, play "get small item" - if (getItemId == GI_SKULL_TOKEN) { + // If we get a skulltula token or the "WINNER" heart, play "get small item" + if (getItemId == GI_SKULL_TOKEN || getItemId == GI_HEART_PIECE_WIN) { temp1 = NA_BGM_SMALL_ITEM_GET | 0x900; } + // But if the "WINNER" heart is the 4th heart piece collected, play "get heart container" + if (getItemId == GI_HEART_PIECE_WIN && ((gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000)) { + temp1 = NA_BGM_HEART_GET | 0x900; + } // If the setting is toggled on and we get special quest items (longer fanfares): if (CVar_GetS32("gRandoQuestItemFanfares", 0) != 0) { // If we get a medallion, play the "get a medallion" fanfare diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index c906eb1629..cdc63422f4 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -12702,10 +12702,15 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { // Restore appropriate item fanfares in rando when we're obtaining items outside of their normal contexts if (gSaveContext.n64ddFlag) { - // If we get a skulltula token, play "get small item" (for tokensanity) - if (this->getItemId == GI_SKULL_TOKEN) { + // If we get a skulltula token (in tokensanity) or the "WINNER" heart, play "get small item" + if (this->getItemId == GI_SKULL_TOKEN || this->getItemId == GI_HEART_PIECE_WIN) { temp1 = NA_BGM_SMALL_ITEM_GET | 0x900; - } + } + // But if the "WINNER" heart is the 4th heart piece collected, play "get heart container" + if (this->getItemId == GI_HEART_PIECE_WIN && + ((gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000)) { + temp1 = NA_BGM_HEART_GET | 0x900; + } // If the setting is toggled on and we get special quest items (longer fanfares): if (CVar_GetS32("gRandoQuestItemFanfares", 0) != 0) { // If we get a medallion, play the "get a medallion" fanfare From 0c6ed553a2b048ae802c982a4e89ff6337495e56 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Tue, 26 Jul 2022 18:14:28 -0700 Subject: [PATCH 16/19] Shorten code by calling new function Reduced duplicate code by calling the new Audio_PlayFanfare_Rando function from z_player.c --- soh/src/overlays/actors/ovl_En_Si/z_en_si.c | 6 +-- .../actors/ovl_player_actor/z_player.c | 38 +++++-------------- 2 files changed, 13 insertions(+), 31 deletions(-) diff --git a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c index 1aba4fae3a..5597c53ebe 100644 --- a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -118,7 +118,7 @@ void func_80AFB768(EnSi* this, GlobalContext* globalCtx) { Message_StartTextbox(globalCtx, textId, NULL); if (gSaveContext.n64ddFlag) { - Audio_PlayFanfare_Rando(); + Audio_PlayFanfare_Rando(getItemId); } else { Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); } @@ -156,7 +156,7 @@ void func_80AFB89C(EnSi* this, GlobalContext* globalCtx) { } Message_StartTextbox(globalCtx, textId, NULL); if (gSaveContext.n64ddFlag) { - Audio_PlayFanfare_Rando(); + Audio_PlayFanfare_Rando(getItemId); } else { Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); } @@ -166,7 +166,7 @@ void func_80AFB89C(EnSi* this, GlobalContext* globalCtx) { // Function to play "get-item" fanfares according to the type of item obtained (used in rando) // Longer fanfares for medallions/stones/songs are behind the Cvar -void Audio_PlayFanfare_Rando() { +void Audio_PlayFanfare_Rando(ItemID getItemId) { s32 temp1; if (((getItemId >= GI_RUPEE_GREEN) && (getItemId <= GI_RUPEE_RED)) || diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index cdc63422f4..11cbf02e25 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -12684,6 +12684,11 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { Message_StartTextbox(globalCtx, giEntry->textId, &this->actor); Item_Give(globalCtx, giEntry->itemId); + // In rando the fanfares are handled in z_en_si.c, so we can skip down a bit + if (gSaveContext.n64ddFlag) { + goto RandoFanfareSkip; + } + if (((this->getItemId >= GI_RUPEE_GREEN) && (this->getItemId <= GI_RUPEE_RED)) || ((this->getItemId >= GI_RUPEE_PURPLE) && (this->getItemId <= GI_RUPEE_GOLD)) || ((this->getItemId >= GI_RUPEE_GREEN_LOSE) && (this->getItemId <= GI_RUPEE_PURPLE_LOSE)) || @@ -12699,36 +12704,13 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { else { temp1 = temp2 = (this->getItemId == GI_HEART_PIECE) ? NA_BGM_SMALL_ITEM_GET : NA_BGM_ITEM_GET | 0x900; } - - // Restore appropriate item fanfares in rando when we're obtaining items outside of their normal contexts + + RandoFanfareSkip: if (gSaveContext.n64ddFlag) { - // If we get a skulltula token (in tokensanity) or the "WINNER" heart, play "get small item" - if (this->getItemId == GI_SKULL_TOKEN || this->getItemId == GI_HEART_PIECE_WIN) { - temp1 = NA_BGM_SMALL_ITEM_GET | 0x900; - } - // But if the "WINNER" heart is the 4th heart piece collected, play "get heart container" - if (this->getItemId == GI_HEART_PIECE_WIN && - ((gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000)) { - temp1 = NA_BGM_HEART_GET | 0x900; - } - // If the setting is toggled on and we get special quest items (longer fanfares): - if (CVar_GetS32("gRandoQuestItemFanfares", 0) != 0) { - // If we get a medallion, play the "get a medallion" fanfare - if ((this->getItemId >= GI_MEDALLION_LIGHT) && (this->getItemId <= GI_MEDALLION_SPIRIT)) { - temp1 = NA_BGM_MEDALLION_GET | 0x900; - } - // If it's a Spiritual Stone, play the "get a spiritual stone" fanfare - if ((this->getItemId >= GI_STONE_KOKIRI) && (this->getItemId <= GI_STONE_ZORA)) { - temp1 = NA_BGM_SPIRITUAL_STONE | 0x900; - } - // If the item we're getting is a song, play the "learned a song" fanfare - if ((this->getItemId >= GI_ZELDAS_LULLABY) && (this->getItemId <= GI_PRELUDE_OF_LIGHT)) { - temp1 = NA_BGM_OCA_FAIRY_GET | 0x900; - } - } + Audio_PlayFanfare_Rando(this->getItemId); + } else { + Audio_PlayFanfare(temp1); } - - Audio_PlayFanfare(temp1); } } else { From 430d3275bc8f54b9c0d33c5f1d3176c3ee830f3b Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Tue, 26 Jul 2022 18:25:25 -0700 Subject: [PATCH 17/19] Fix declaration Forgot to include the argument in the declaration at the top. It worked fine even without it, but figured this is safer --- soh/src/overlays/actors/ovl_En_Si/z_en_si.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c index 5597c53ebe..98289a87e3 100644 --- a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -17,7 +17,7 @@ s32 func_80AFB748(EnSi* this, GlobalContext* globalCtx); void func_80AFB768(EnSi* this, GlobalContext* globalCtx); void func_80AFB89C(EnSi* this, GlobalContext* globalCtx); void func_80AFB950(EnSi* this, GlobalContext* globalCtx); -void Audio_PlayFanfare_Rando(); +void Audio_PlayFanfare_Rando(ItemID getItemId); s32 textId = 0xB4; s32 giveItemId = ITEM_SKULL_TOKEN; From 4e2da51c54ef6ee29f35852fbf059217d22b5bb5 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Wed, 27 Jul 2022 17:21:09 -0700 Subject: [PATCH 18/19] Code cleanup Some optimizations per suggestions --- .../overlays/actors/ovl_player_actor/z_player.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 11cbf02e25..24c1fc90de 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -12684,12 +12684,11 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { Message_StartTextbox(globalCtx, giEntry->textId, &this->actor); Item_Give(globalCtx, giEntry->itemId); - // In rando the fanfares are handled in z_en_si.c, so we can skip down a bit + // In rando the fanfares are handled by a function in z_en_si.c if (gSaveContext.n64ddFlag) { - goto RandoFanfareSkip; - } - - if (((this->getItemId >= GI_RUPEE_GREEN) && (this->getItemId <= GI_RUPEE_RED)) || + Audio_PlayFanfare_Rando(this->getItemId); + } + else if (((this->getItemId >= GI_RUPEE_GREEN) && (this->getItemId <= GI_RUPEE_RED)) || ((this->getItemId >= GI_RUPEE_PURPLE) && (this->getItemId <= GI_RUPEE_GOLD)) || ((this->getItemId >= GI_RUPEE_GREEN_LOSE) && (this->getItemId <= GI_RUPEE_PURPLE_LOSE)) || (this->getItemId == GI_HEART)) { @@ -12704,13 +12703,7 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { else { temp1 = temp2 = (this->getItemId == GI_HEART_PIECE) ? NA_BGM_SMALL_ITEM_GET : NA_BGM_ITEM_GET | 0x900; } - - RandoFanfareSkip: - if (gSaveContext.n64ddFlag) { - Audio_PlayFanfare_Rando(this->getItemId); - } else { - Audio_PlayFanfare(temp1); - } + Audio_PlayFanfare(temp1); } } else { From 9f41ea0ab427f663648b68bb78d2190e90c29ef8 Mon Sep 17 00:00:00 2001 From: Sarge-117 Date: Wed, 27 Jul 2022 18:14:26 -0700 Subject: [PATCH 19/19] Move function to code_800EC960.c Moved Audio_PlayFanfare_Rando to a better home --- soh/src/code/code_800EC960.c | 44 +++++++++++++++++++ soh/src/overlays/actors/ovl_En_Si/z_en_si.c | 44 ------------------- .../actors/ovl_player_actor/z_player.c | 2 +- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/soh/src/code/code_800EC960.c b/soh/src/code/code_800EC960.c index c5d1509847..0a1d61f4e4 100644 --- a/soh/src/code/code_800EC960.c +++ b/soh/src/code/code_800EC960.c @@ -1246,6 +1246,7 @@ void Audio_StepFreqLerp(FreqLerp* lerp); void func_800F56A8(void); void Audio_PlayNatureAmbienceSequence(u8 natureAmbienceId); s32 Audio_SetGanonDistVol(u8 targetVol); +void Audio_PlayFanfare_Rando(ItemID getItemId); // Function originally not called, so repurposing for DPad input void func_800EC960(u8 dpad) { @@ -3887,6 +3888,49 @@ void Audio_ResetSfxChannelState(void) { sAudioCodeReverb = 0; } +// Function to play "get-item" fanfares according to the type of item obtained (used in rando) +// Longer fanfares for medallions/stones/songs are behind the Cvar +void Audio_PlayFanfare_Rando(ItemID getItemId) { + s32 temp1; + + if (((getItemId >= GI_RUPEE_GREEN) && (getItemId <= GI_RUPEE_RED)) || + ((getItemId >= GI_RUPEE_PURPLE) && (getItemId <= GI_RUPEE_GOLD)) || + ((getItemId >= GI_RUPEE_GREEN_LOSE) && (getItemId <= GI_RUPEE_PURPLE_LOSE)) || (getItemId == GI_HEART)) { + Audio_PlaySoundGeneral(NA_SE_SY_GET_BOXITEM, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); + } else { + if ((getItemId == GI_HEART_CONTAINER_2) || (getItemId == GI_HEART_CONTAINER) || + ((getItemId == GI_HEART_PIECE) && ((gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000))) { + temp1 = NA_BGM_HEART_GET | 0x900; + } else { + temp1 = (getItemId == GI_HEART_PIECE) ? NA_BGM_SMALL_ITEM_GET : NA_BGM_ITEM_GET | 0x900; + } + // If we get a skulltula token or the "WINNER" heart, play "get small item" + if (getItemId == GI_SKULL_TOKEN || getItemId == GI_HEART_PIECE_WIN) { + temp1 = NA_BGM_SMALL_ITEM_GET | 0x900; + } + // But if the "WINNER" heart is the 4th heart piece collected, play "get heart container" + if (getItemId == GI_HEART_PIECE_WIN && ((gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000)) { + temp1 = NA_BGM_HEART_GET | 0x900; + } + // If the setting is toggled on and we get special quest items (longer fanfares): + if (CVar_GetS32("gRandoQuestItemFanfares", 0) != 0) { + // If we get a medallion, play the "get a medallion" fanfare + if ((getItemId >= GI_MEDALLION_LIGHT) && (getItemId <= GI_MEDALLION_SPIRIT)) { + temp1 = NA_BGM_MEDALLION_GET | 0x900; + } + // If it's a Spiritual Stone, play the "get a spiritual stone" fanfare + if ((getItemId >= GI_STONE_KOKIRI) && (getItemId <= GI_STONE_ZORA)) { + temp1 = NA_BGM_SPIRITUAL_STONE | 0x900; + } + // If the item we're getting is a song, play the "learned a song" fanfare + if ((getItemId >= GI_ZELDAS_LULLABY) && (getItemId <= GI_PRELUDE_OF_LIGHT)) { + temp1 = NA_BGM_OCA_FAIRY_GET | 0x900; + } + } + Audio_PlayFanfare(temp1); + } +} + void func_800F3F3C(u8 arg0) { if (gSoundBankMuted[0] != 1) { Audio_StartSeq(SEQ_PLAYER_BGM_SUB, 0, NA_BGM_VARIOUS_SFX); diff --git a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c index 98289a87e3..944a628507 100644 --- a/soh/src/overlays/actors/ovl_En_Si/z_en_si.c +++ b/soh/src/overlays/actors/ovl_En_Si/z_en_si.c @@ -17,7 +17,6 @@ s32 func_80AFB748(EnSi* this, GlobalContext* globalCtx); void func_80AFB768(EnSi* this, GlobalContext* globalCtx); void func_80AFB89C(EnSi* this, GlobalContext* globalCtx); void func_80AFB950(EnSi* this, GlobalContext* globalCtx); -void Audio_PlayFanfare_Rando(ItemID getItemId); s32 textId = 0xB4; s32 giveItemId = ITEM_SKULL_TOKEN; @@ -164,49 +163,6 @@ void func_80AFB89C(EnSi* this, GlobalContext* globalCtx) { } } -// Function to play "get-item" fanfares according to the type of item obtained (used in rando) -// Longer fanfares for medallions/stones/songs are behind the Cvar -void Audio_PlayFanfare_Rando(ItemID getItemId) { - s32 temp1; - - if (((getItemId >= GI_RUPEE_GREEN) && (getItemId <= GI_RUPEE_RED)) || - ((getItemId >= GI_RUPEE_PURPLE) && (getItemId <= GI_RUPEE_GOLD)) || - ((getItemId >= GI_RUPEE_GREEN_LOSE) && (getItemId <= GI_RUPEE_PURPLE_LOSE)) || (getItemId == GI_HEART)) { - Audio_PlaySoundGeneral(NA_SE_SY_GET_BOXITEM, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else { - if ((getItemId == GI_HEART_CONTAINER_2) || (getItemId == GI_HEART_CONTAINER) || - ((getItemId == GI_HEART_PIECE) && ((gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000))) { - temp1 = NA_BGM_HEART_GET | 0x900; - } else { - temp1 = (getItemId == GI_HEART_PIECE) ? NA_BGM_SMALL_ITEM_GET : NA_BGM_ITEM_GET | 0x900; - } - // If we get a skulltula token or the "WINNER" heart, play "get small item" - if (getItemId == GI_SKULL_TOKEN || getItemId == GI_HEART_PIECE_WIN) { - temp1 = NA_BGM_SMALL_ITEM_GET | 0x900; - } - // But if the "WINNER" heart is the 4th heart piece collected, play "get heart container" - if (getItemId == GI_HEART_PIECE_WIN && ((gSaveContext.inventory.questItems & 0xF0000000) == 0x40000000)) { - temp1 = NA_BGM_HEART_GET | 0x900; - } - // If the setting is toggled on and we get special quest items (longer fanfares): - if (CVar_GetS32("gRandoQuestItemFanfares", 0) != 0) { - // If we get a medallion, play the "get a medallion" fanfare - if ((getItemId >= GI_MEDALLION_LIGHT) && (getItemId <= GI_MEDALLION_SPIRIT)) { - temp1 = NA_BGM_MEDALLION_GET | 0x900; - } - // If it's a Spiritual Stone, play the "get a spiritual stone" fanfare - if ((getItemId >= GI_STONE_KOKIRI) && (getItemId <= GI_STONE_ZORA)) { - temp1 = NA_BGM_SPIRITUAL_STONE | 0x900; - } - // If the item we're getting is a song, play the "learned a song" fanfare - if ((getItemId >= GI_ZELDAS_LULLABY) && (getItemId <= GI_PRELUDE_OF_LIGHT)) { - temp1 = NA_BGM_OCA_FAIRY_GET | 0x900; - } - } - Audio_PlayFanfare(temp1); - } -} - void func_80AFB950(EnSi* this, GlobalContext* globalCtx) { Player* player = GET_PLAYER(globalCtx); diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index 24c1fc90de..5c680e8fa5 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -12684,7 +12684,7 @@ s32 func_8084DFF4(GlobalContext* globalCtx, Player* this) { Message_StartTextbox(globalCtx, giEntry->textId, &this->actor); Item_Give(globalCtx, giEntry->itemId); - // In rando the fanfares are handled by a function in z_en_si.c + // In rando the fanfares are handled by a function in code_800EC960.c if (gSaveContext.n64ddFlag) { Audio_PlayFanfare_Rando(this->getItemId); }