From 81824176f41e5eb862809e96e08dacf9ece0bae4 Mon Sep 17 00:00:00 2001 From: PhlexPlexico Date: Sat, 24 Feb 2024 22:47:57 -0600 Subject: [PATCH] Fully adjust chest drawing to ensure large chests draw properly. (#43) --- code/include/rnd/chest.h | 2 +- code/mm.ld | 8 ++++---- code/source/asm/hooks.s | 4 +++- code/source/rnd/chest.cpp | 8 ++++++-- code/source/rnd/custom_messages.cpp | 12 ++++++------ code/source/rnd/item_override.cpp | 4 ++-- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/code/include/rnd/chest.h b/code/include/rnd/chest.h index 861ee0c6..82648eef 100644 --- a/code/include/rnd/chest.h +++ b/code/include/rnd/chest.h @@ -32,7 +32,7 @@ namespace rnd { extern "C" { game::actors::EnBoxType Chest_OverrideSize(game::actors::En_Box*, game::GlobalContext*); - u8 Chest_IsOverrideEnabled(); + u8 Chest_IsOverrideEnabled(game::actors::En_Box*, u16); } // void EnBox_rInit(game::act::Actor* thisx, game::GlobalContext* globalCtx); // void EnBox_rUpdate(game::act::Actor* thisx, game::GlobalContext* globalCtx); diff --git a/code/mm.ld b/code/mm.ld index 46904913..dd8584da 100644 --- a/code/mm.ld +++ b/code/mm.ld @@ -359,14 +359,14 @@ SECTIONS{ *(.patch_IceArrowsAnywhere) } - .patch_AdjustMapAndCompassChests 0x31CE9C : { - *(.patch_AdjustMapAndCompassChests) - } - .patch_changeChestTypeToMatchContents 0x31CE0C : { *(.patch_changeChestTypeToMatchContents) } + .patch_AdjustMapAndCompassChests 0x31CE9C : { + *(.patch_AdjustMapAndCompassChests) + } + .patch_RemoveZoraMaskCheckMikau 0x32BBB8 : { *(.patch_RemoveZoraMaskCheckMikau) } diff --git a/code/source/asm/hooks.s b/code/source/asm/hooks.s index c435737a..8ec3c8b2 100644 --- a/code/source/asm/hooks.s +++ b/code/source/asm/hooks.s @@ -191,6 +191,8 @@ hook_HandleOcarina: .global hook_checkChestContentSetting hook_checkChestContentSetting: push {r0-r12, lr} + cpy r0,r4 + ldrb r1,[r4,#0x3E9] bl Chest_IsOverrideEnabled cmp r0,#0x0 beq drawFancyMapChests @@ -198,7 +200,7 @@ hook_checkChestContentSetting: bx lr drawFancyMapChests: pop {r0-r12,lr} - cmp r0,#0x3C + cmpne r0,#0x3C bx lr .global hook_changeChestTypeToMatchContents diff --git a/code/source/rnd/chest.cpp b/code/source/rnd/chest.cpp index 4608a2d8..ccfd6a8d 100644 --- a/code/source/rnd/chest.cpp +++ b/code/source/rnd/chest.cpp @@ -24,8 +24,12 @@ namespace rnd { } return (game::actors::EnBoxType)0xFF; } - u8 Chest_IsOverrideEnabled() { - return gSettingsContext.chestSize; + u8 Chest_IsOverrideEnabled(game::actors::En_Box* actor, u16 chestType) { + s16 gid = (actor->dyna.params << 0x14) >> 0x19; + if (gid == 0x3C && gSettingsContext.chestSize == 0) return false; + if (gid == 0x3C && gSettingsContext.chestSize == 1 && chestType == (u16)game::actors::EnBoxType::ENBOX_TYPE_SMALL) return true; + else if (chestType == (u16)game::actors::EnBoxType::ENBOX_TYPE_SMALL) return true; + else return false; } } diff --git a/code/source/rnd/custom_messages.cpp b/code/source/rnd/custom_messages.cpp index 655d8fe5..6dfa71ed 100644 --- a/code/source/rnd/custom_messages.cpp +++ b/code/source/rnd/custom_messages.cpp @@ -379,12 +379,12 @@ volatile const UnformattedMessage rCustomMessages[512] = {0}; volatile const u32 numCustomMessageEntries = {0}; bool SetCustomMessage(u16 id, game::MessageResEntry* msgResEntry) { -#if defined ENABLE_DEBUG || defined DEBUG_PRINT - static u16 lastId; - if (id && id != lastId) - rnd::util::Print("Message ID is %#06x\n", id); - lastId = id; -#endif +// #if defined ENABLE_DEBUG || defined DEBUG_PRINT +// static u16 lastId; +// if (id && id != lastId) +// rnd::util::Print("Message ID is %#06x\n", id); +// lastId = id; +// #endif UnformattedMessage customMsgData; s32 start = 0, end = numCustomMessageEntries - 1, current; diff --git a/code/source/rnd/item_override.cpp b/code/source/rnd/item_override.cpp index 9444ca6d..1caae5eb 100644 --- a/code/source/rnd/item_override.cpp +++ b/code/source/rnd/item_override.cpp @@ -45,8 +45,8 @@ namespace rnd { rItemOverrides[0].value.looksLikeItemId = 0x26; rItemOverrides[1].key.scene = 0x6F; rItemOverrides[1].key.type = ItemOverride_Type::OVR_COLLECTABLE; - rItemOverrides[1].value.getItemId = 0x6E; - rItemOverrides[1].value.looksLikeItemId = 0x6E; + rItemOverrides[1].value.getItemId = 0x02; + rItemOverrides[1].value.looksLikeItemId = 0x02; rItemOverrides[2].key.scene = 0x12; rItemOverrides[2].key.type = ItemOverride_Type::OVR_COLLECTABLE; rItemOverrides[2].value.getItemId = 0x37;