Skip to content

Commit

Permalink
Check settings before drawing small fancy chests. (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhlexPlexico authored Feb 23, 2024
1 parent f1ab074 commit 3944441
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
5 changes: 4 additions & 1 deletion code/include/rnd/chest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion code/mm.ld
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ SECTIONS{
*(.patch_AdjustMapAndCompassChests)
}

/*0x31cad4*/
.patch_changeChestTypeToMatchContents 0x31CE0C : {
*(.patch_changeChestTypeToMatchContents)
}
Expand Down
13 changes: 13 additions & 0 deletions code/source/asm/hooks.s
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion code/source/asm/patches.s
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ patch_IceArrowsAnywhere:
.section .patch_AdjustMapAndCompassChests
.global patch_AdjustMapAndCompassChests
patch_AdjustMapAndCompassChests:
nop
bl hook_checkChestContentSetting

.section .patch_changeChestTypeToMatchContents
.global patch_changeChestTypeToMatchContents
Expand Down
5 changes: 3 additions & 2 deletions code/source/rnd/chest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -26,6 +24,9 @@ namespace rnd {
}
return (game::actors::EnBoxType)0xFF;
}
u8 Chest_IsOverrideEnabled() {
return gSettingsContext.chestSize;
}
}

} // namespace rnd

0 comments on commit 3944441

Please sign in to comment.