From 3944441059dc1d1870b53edd9ad9e3027031aac1 Mon Sep 17 00:00:00 2001 From: PhlexPlexico Date: Fri, 23 Feb 2024 00:00:18 -0600 Subject: [PATCH] Check settings before drawing small fancy chests. (#41) --- code/include/rnd/chest.h | 5 ++++- code/mm.ld | 1 - code/source/asm/hooks.s | 13 +++++++++++++ code/source/asm/patches.s | 2 +- code/source/rnd/chest.cpp | 5 +++-- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/code/include/rnd/chest.h b/code/include/rnd/chest.h index ce37e01d..861ee0c6 100644 --- a/code/include/rnd/chest.h +++ b/code/include/rnd/chest.h @@ -30,7 +30,10 @@ namespace rnd { DECORATED_SMALL, }; - extern "C" game::actors::EnBoxType Chest_OverrideSize(game::actors::En_Box*, game::GlobalContext*); + extern "C" { + game::actors::EnBoxType Chest_OverrideSize(game::actors::En_Box*, game::GlobalContext*); + u8 Chest_IsOverrideEnabled(); + } // void EnBox_rInit(game::act::Actor* thisx, game::GlobalContext* globalCtx); // void EnBox_rUpdate(game::act::Actor* thisx, game::GlobalContext* globalCtx); // u8 Chest_OverrideAnimation(); diff --git a/code/mm.ld b/code/mm.ld index 7d1ed0ab..46904913 100644 --- a/code/mm.ld +++ b/code/mm.ld @@ -363,7 +363,6 @@ SECTIONS{ *(.patch_AdjustMapAndCompassChests) } - /*0x31cad4*/ .patch_changeChestTypeToMatchContents 0x31CE0C : { *(.patch_changeChestTypeToMatchContents) } diff --git a/code/source/asm/hooks.s b/code/source/asm/hooks.s index 1f7c2b67..993a42bc 100644 --- a/code/source/asm/hooks.s +++ b/code/source/asm/hooks.s @@ -380,6 +380,19 @@ hook_OwlExtDataSave: cpy r6,r0 b 0x317008 +.global hook_checkChestContentSetting +hook_checkChestContentSetting: + push {r0-r12, lr} + bl Chest_IsOverrideEnabled + cmp r0,#0x0 + beq drawFancyMapChests + pop {r0-r12,lr} + bx lr +drawFancyMapChests: + pop {r0-r12,lr} + cmp r0,#0x3C + bx lr + .global hook_changeChestTypeToMatchContents hook_changeChestTypeToMatchContents: push {r0-r3, r5-r12, lr} diff --git a/code/source/asm/patches.s b/code/source/asm/patches.s index 017e1341..6db9c72e 100644 --- a/code/source/asm/patches.s +++ b/code/source/asm/patches.s @@ -389,7 +389,7 @@ patch_IceArrowsAnywhere: .section .patch_AdjustMapAndCompassChests .global patch_AdjustMapAndCompassChests patch_AdjustMapAndCompassChests: - nop + bl hook_checkChestContentSetting .section .patch_changeChestTypeToMatchContents .global patch_changeChestTypeToMatchContents diff --git a/code/source/rnd/chest.cpp b/code/source/rnd/chest.cpp index f462df55..4608a2d8 100644 --- a/code/source/rnd/chest.cpp +++ b/code/source/rnd/chest.cpp @@ -4,8 +4,6 @@ namespace rnd { extern "C" { game::actors::EnBoxType Chest_OverrideSize(game::actors::En_Box* actor, game::GlobalContext* gctx) { - // First check to see if setting is enabled. - // TODO: Create setting if (gSettingsContext.chestSize == 0) { return (game::actors::EnBoxType)0xFF; } @@ -26,6 +24,9 @@ namespace rnd { } return (game::actors::EnBoxType)0xFF; } + u8 Chest_IsOverrideEnabled() { + return gSettingsContext.chestSize; + } } } // namespace rnd \ No newline at end of file