From 18e4aead81ba8006e88370deac7ad8503d0ee9ec Mon Sep 17 00:00:00 2001 From: Phlex Date: Tue, 23 Jan 2024 21:43:08 -0600 Subject: [PATCH] Full fix for extData checks. --- code/mm.ld | 10 ++- code/source/asm/hooks.s | 9 +-- code/source/asm/patches.s | 11 ++++ code/source/rnd/item_override.cpp | 103 +++++++++++++++++++----------- 4 files changed, 87 insertions(+), 46 deletions(-) diff --git a/code/mm.ld b/code/mm.ld index b0690df9..5becd553 100644 --- a/code/mm.ld +++ b/code/mm.ld @@ -51,6 +51,10 @@ SECTIONS{ *(.patch_RemoveMeetMaskCutScene) } */ + .patch_KeepBowOnEpona 0x188794 : { + *(.patch_KeepBowOnEpona) + } + .patch_OverrideCutsceneNextEntrance 0x1B1834 : { *(.patch_OverrideCutsceneNextEntrance) } @@ -115,10 +119,14 @@ SECTIONS{ *(.patch_ZoraInWaterFastSwim) } - .patch_CheckCurrentInventoryOverrideItem 0x1F3D6C : { + .patch_CheckCurrentInventoryOverrideItem 0x1F3D5C : { *(.patch_CheckCurrentInventoryOverrideItem) } + .patch_CheckCurrentInventoryOverrideItemTwo 0x201060 : { + *(.patch_CheckCurrentInventoryOverrideItemTwo) + } + /* .patch_OverrideItemIDFour 0x1FBD10 : { *(.patch_OverrideItemIdIndex) } */ diff --git a/code/source/asm/hooks.s b/code/source/asm/hooks.s index 05ca60e3..0ffd5c96 100644 --- a/code/source/asm/hooks.s +++ b/code/source/asm/hooks.s @@ -105,14 +105,9 @@ hook_SpawnFastElegyStatues: .global hook_CheckCurrentInventory hook_CheckCurrentInventory: - push {r1, lr} + push {lr} bl ItemOverride_CheckInventoryItemOverride - cmp r0,#0xFF - pop {r1, lr} - bne DoNotOverrideInventoryCheck - bx lr -DoNotOverrideInventoryCheck: - bx lr + pop {pc} .global hook_CheckOcarinaDive hook_CheckOcarinaDive: diff --git a/code/source/asm/patches.s b/code/source/asm/patches.s index 36481742..18a8cf18 100644 --- a/code/source/asm/patches.s +++ b/code/source/asm/patches.s @@ -76,6 +76,10 @@ patch_RemoveSOHCutesceneAfterMessage: patch_OverrideBombersNotebook: b hook_OverrideHMSBombers +.section .patch_KeepBowOnEpona +.global patch_KeepBowOnEpona +patch_KeepBowOnEpona: + nop .section .patch_OverrideCutsceneNextEntrance .global patch_OverrideCutsceneNextEntrance @@ -157,6 +161,13 @@ patch_SpawnFastElegyStatues: patch_CheckCurrentInventoryOverrideItem: b hook_CheckCurrentInventory +.section .patch_CheckCurrentInventoryOverrideItemTwo +.global patch_CheckCurrentInventoryOverrideItemTwo +patch_CheckCurrentInventoryOverrideItemTwo: + b hook_CheckCurrentInventory + + + .section .patch_ForceSwordUpgradeOnHuman .global patch_ForceSwordUpgradeOnHuman patch_ForceSwordUpgradeOnHuman: diff --git a/code/source/rnd/item_override.cpp b/code/source/rnd/item_override.cpp index 2d7156ab..50d5ff7c 100644 --- a/code/source/rnd/item_override.cpp +++ b/code/source/rnd/item_override.cpp @@ -416,6 +416,9 @@ namespace rnd { } void SetExtData() { +#if defined ENABLE_DEBUG || defined DEBUG_PRINT + rnd::util::Print("%s: Settomg extdata for actor %#04x\n", __func__, storedActorId); +#endif if (storedActorId == game::act::Id::NpcEnNb) { gExtSaveData.givenItemChecks.enNbGivenItem = 1; } else if (storedActorId == game::act::Id::NpcInvisibleGuard) { @@ -427,6 +430,9 @@ namespace rnd { } else if (storedActorId == game::act::Id::NpcEnYb) { gExtSaveData.givenItemChecks.enYbGivenItem = 1; } else if (storedActorId == game::act::Id::NpcEnBaba) { +#if defined ENABLE_DEBUG || defined DEBUG_PRINT + rnd::util::Print("%s: GAVE EN BABA A TALKING TO, NO MORE ITEMS.\n", __func__); +#endif gExtSaveData.givenItemChecks.enBabaGivenItem = 1; } else if (storedActorId == game::act::Id::NpcEnFsn) { gExtSaveData.givenItemChecks.enFsnGivenItem = 1; @@ -642,47 +648,68 @@ namespace rnd { void ItemOverride_RemoveTextId() { rStoredTextId = 0; } - + // clang-format off int ItemOverride_CheckInventoryItemOverride(game::ItemId currentItem) { - if (currentItem == game::ItemId::BlastMask && gExtSaveData.givenItemChecks.enBabaGivenItem == 0) { - return (int)0xFF; - } else if (currentItem == game::ItemId::BremenMask && gExtSaveData.givenItemChecks.enGuruGuruGivenItem == 0) { - return (int)0xFF; - } else if (currentItem == game::ItemId::KamaroMask && gExtSaveData.givenItemChecks.enYbGivenItem == 0) { - return (int)0xFF; - } else if (currentItem == game::ItemId::DonGeroMask && gExtSaveData.givenItemChecks.enGegGivenItem == 0) { - return (int)0xFF; - } else if (currentItem == game::ItemId::ZoraMask && gExtSaveData.givenItemChecks.enZogGivenItem == 0) { - return (int)0xFF; - } else if (currentItem == game::ItemId::LetterToMama && gExtSaveData.givenItemChecks.enBabaGivenItem == 0) { - return (int)0xFF; - } else if (currentItem == game::ItemId::KeatonMask && gExtSaveData.givenItemChecks.enFsnGivenItem == 0) { - return (int)0xFF; - } else if (currentItem == game::ItemId::PostmanHat && gExtSaveData.givenItemChecks.enPmGivenItem == 0) { - return (int)0xFF; - } else if (currentItem == game::ItemId::StoneMask && gExtSaveData.givenItemChecks.enStoneHeishiGivenItem == 0) { - return (int)0xFF; - } else if (currentItem == game::ItemId::MaskOfTruth && gExtSaveData.givenItemChecks.enSshGivenItem == 0) { - return (int)0xFF; - } else if (currentItem == game::ItemId::MaskOfScents && gExtSaveData.givenItemChecks.enDnoGivenItem == 0) { - return (int)0xFF; - } else if (currentItem == game::ItemId::GreatFairyMask && gExtSaveData.givenItemChecks.bgDyYoseizoGivenItem == 0) { - return (int)0xFF; - } else if (currentItem == game::ItemId::GaroMask && gExtSaveData.givenItemChecks.enInGivenItem == 0) { - return (int)0xFF; - } else if (currentItem == game::ItemId::PictographBox && gExtSaveData.givenItemChecks.enTruGivenItem == 0) { - return (int)0xFF; - } else if (currentItem == game::ItemId::BunnyHood && gExtSaveData.givenItemChecks.enHsGivenItem == 0) { - return (int)0xFF; - } else if (currentItem == game::ItemId::GibdoMask && gExtSaveData.givenItemChecks.enHgoGivenItem == 0) { - return (int)0xFF; - } else if (currentItem == game::ItemId::RomaniMask && gExtSaveData.givenItemChecks.enMaYtoGivenItem == 0) { - return (int)0xFF; - } else if (currentItem == game::ItemId::CaptainHat && gExtSaveData.givenItemChecks.enOskGivenItem == 0) { - return (int)0xFF; + auto& givenItems = gExtSaveData.givenItemChecks; + if (currentItem == game::ItemId::BlastMask) { + return givenItems.enBabaGivenItem ? (int)currentItem : (int)0xFF; + } else if (currentItem == game::ItemId::BremenMask) { + return givenItems.enGuruGuruGivenItem ? (int)currentItem + : (int)0xFF; + } else if (currentItem == game::ItemId::KamaroMask) { + return givenItems.enYbGivenItem ? (int)currentItem + : (int)0xFF; + } else if (currentItem == game::ItemId::DonGeroMask) { + return givenItems.enGegGivenItem ? (int)currentItem + : (int)0xFF; + } else if (currentItem == game::ItemId::ZoraMask) { + return givenItems.enZogGivenItem ? (int)currentItem + : (int)0xFF; + } else if (currentItem == game::ItemId::LetterToMama) { + return givenItems.enBabaGivenItem ? (int)currentItem + : (int)0xFF; + } else if (currentItem == game::ItemId::KeatonMask) { + return givenItems.enFsnGivenItem ? (int)currentItem + : (int)0xFF; + } else if (currentItem == game::ItemId::PostmanHat) { + return givenItems.enPmGivenItem ? (int)currentItem + : (int)0xFF; + } else if (currentItem == game::ItemId::StoneMask) { + return givenItems.enStoneHeishiGivenItem ? (int)currentItem + : (int)0xFF; + } else if (currentItem == game::ItemId::MaskOfTruth) { + return givenItems.enSshGivenItem ? (int)currentItem + : (int)0xFF; + } else if (currentItem == game::ItemId::MaskOfScents) { + return givenItems.enDnoGivenItem ? (int)currentItem + : (int)0xFF; + } else if (currentItem == game::ItemId::GreatFairyMask) { + return givenItems.bgDyYoseizoGivenItem ? (int)currentItem + : (int)0xFF; + } else if (currentItem == game::ItemId::GaroMask) { + return givenItems.enInGivenItem ? (int)currentItem + : (int)0xFF; + } else if (currentItem == game::ItemId::PictographBox) { + return givenItems.enTruGivenItem ? (int)currentItem + : (int)0xFF; + } else if (currentItem == game::ItemId::BunnyHood) { + return givenItems.enHsGivenItem ? (int)currentItem + : (int)0xFF; + } else if (currentItem == game::ItemId::GibdoMask) { + return givenItems.enHgoGivenItem ? (int)currentItem + : (int)0xFF; + } else if (currentItem == game::ItemId::RomaniMask) { + return givenItems.enMaYtoGivenItem ? (int)currentItem + : (int)0xFF; + } else if (currentItem == game::ItemId::CaptainHat) { + return givenItems.enOskGivenItem ? (int)currentItem + : (int)0xFF; } - return (int)currentItem; + auto& inventory = game::GetCommonData().save.inventory.items; + return (int)inventory[(int)currentItem]; } + + // clang-format on void ItemOverride_SwapSoHGetItemText(game::GlobalContext* gctx, u16 textId, game::act::Actor* fromActor) { // Check which text ID is coming in. If it's any mask from Song of Healing, replace it with active item text. if (textId == 0x79 || textId == 0x7a || textId == 0x87 || textId == 0x78) {