Skip to content

Commit

Permalink
Fully adjust chest drawing to ensure large chests draw properly. (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhlexPlexico authored Feb 25, 2024
1 parent ffa1f85 commit 8182417
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion code/include/rnd/chest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions code/mm.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 3 additions & 1 deletion code/source/asm/hooks.s
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,16 @@ 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
pop {r0-r12,lr}
bx lr
drawFancyMapChests:
pop {r0-r12,lr}
cmp r0,#0x3C
cmpne r0,#0x3C
bx lr

.global hook_changeChestTypeToMatchContents
Expand Down
8 changes: 6 additions & 2 deletions code/source/rnd/chest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
12 changes: 6 additions & 6 deletions code/source/rnd/custom_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions code/source/rnd/item_override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8182417

Please sign in to comment.