Skip to content

Commit

Permalink
Fix chest content matching issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
PhlexPlexico committed Feb 20, 2024
1 parent 6e46935 commit 7c67cde
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 19 deletions.
4 changes: 2 additions & 2 deletions code/mm.ld
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ SECTIONS{
*(.patch_IceArrowsAnywhere)
}

/* .patch_changeChestTypeToMatchContents 0x31cad4 : {
.patch_changeChestTypeToMatchContents 0x31cad4 : {
*(.patch_changeChestTypeToMatchContents)
} */
}

.patch_RemoveZoraMaskCheckMikau 0x32BBB8 : {
*(.patch_RemoveZoraMaskCheckMikau)
Expand Down
6 changes: 3 additions & 3 deletions code/source/asm/hooks.s
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ hook_OwlExtDataSave:

.global hook_changeChestTypeToMatchContents
hook_changeChestTypeToMatchContents:
push {r0-r2, lr}
push {r0-r3, lr}
cpy r0, r4
cpy r1, r5
ldrh r2,[r4,#0x1C]
Expand All @@ -359,10 +359,10 @@ hook_changeChestTypeToMatchContents:
cmp r0,#0xFF
beq doNotOverrideChestType
strb r0,[r4,#0x3e9]
pop {r0-r2, lr}
pop {r0-r3, lr}
bx lr
doNotOverrideChestType:
pop {r0-r2, lr}
pop {r0-r12, lr}
strb r2,[r4,#0x3e9]
bx lr

Expand Down
1 change: 0 additions & 1 deletion code/source/asm/patches.s
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ patch_IceArrowsAnywhere:
.global patch_changeChestTypeToMatchContents
patch_changeChestTypeToMatchContents:
bl hook_changeChestTypeToMatchContents
@mov r2, #0x02

.section .patch_RemoveZoraMaskCheckMikau
.global patch_RemoveZoraMaskCheckMikau
Expand Down
38 changes: 28 additions & 10 deletions code/source/rnd/chest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,44 @@ namespace rnd {
game::actors::EnBoxType Chest_OverrideSize(game::actors::En_Box* actor, game::GlobalContext* gctx, s16 gid) {
// First check to see if setting is enabled.
// TODO: Create setting
if (gSettingsContext.chestSize == 0) {
if (gSettingsContext.chestSize == 1) {
return (game::actors::EnBoxType)0xFF;
}
game::SceneId scene = gctx->scene;
ItemOverride override = ItemOverride_Lookup((game::act::Actor*)&actor->dyna, (u16)scene, gid);
game::actors::EnBoxType boxType = (game::actors::EnBoxType)(actor->dyna.params >> 0xC);
if (override.key.all != 0) {
ItemRow* itemToBeGiven = ItemTable_GetItemRow(override.value.getItemId);
if (actor->chest_type == game::actors::EnBoxType::ENBOX_TYPE_SMALL ||
actor->chest_type == game::actors::EnBoxType::ENBOX_TYPE_BIG ||
actor->chest_type == game::actors::EnBoxType::ENBOX_TYPE_BIG_ORNATE) {
if (itemToBeGiven->baseItemId == 0x02)
if (boxType == game::actors::EnBoxType::ENBOX_TYPE_SMALL || boxType == game::actors::EnBoxType::ENBOX_TYPE_BIG ||
boxType == game::actors::EnBoxType::ENBOX_TYPE_BIG_ORNATE) {
if (itemToBeGiven->baseItemId == 0x02) {
return game::actors::EnBoxType::ENBOX_TYPE_SMALL;
else if (itemToBeGiven->baseItemId == 0x2B || itemToBeGiven->baseItemId == 0x78)
} else if (itemToBeGiven->baseItemId == 0x2B || itemToBeGiven->baseItemId == 0x78) {
return game::actors::EnBoxType::ENBOX_TYPE_BIG;
} else if (actor->chest_type == game::actors::EnBoxType::ENBOX_TYPE_BIG_INVISIBLE ||
actor->chest_type == game::actors::EnBoxType::ENBOX_TYPE_SMALL_INVISIBLE) {
if (itemToBeGiven->baseItemId == 0x02)
}
} else if (boxType == game::actors::EnBoxType::ENBOX_TYPE_BIG_INVISIBLE ||
boxType == game::actors::EnBoxType::ENBOX_TYPE_SMALL_INVISIBLE) {
if (itemToBeGiven->baseItemId == 0x02) {
boxType = game::actors::EnBoxType::ENBOX_TYPE_SMALL_INVISIBLE;
return game::actors::EnBoxType::ENBOX_TYPE_SMALL_INVISIBLE;
else if (itemToBeGiven->baseItemId == 0x2B || itemToBeGiven->baseItemId == 0x78)
} else if (itemToBeGiven->baseItemId == 0x2B || itemToBeGiven->baseItemId == 0x78) {
boxType = game::actors::EnBoxType::ENBOX_TYPE_BIG_INVISIBLE;
return game::actors::EnBoxType::ENBOX_TYPE_BIG_INVISIBLE;
}
} else if (boxType == game::actors::EnBoxType::ENBOX_TYPE_BIG_ROOM_CLEAR ||
boxType == game::actors::EnBoxType::ENBOX_TYPE_SMALL_ROOM_CLEAR) {
if (itemToBeGiven->baseItemId == 0x02) {
return game::actors::EnBoxType::ENBOX_TYPE_SMALL_ROOM_CLEAR;
} else if (itemToBeGiven->baseItemId == 0x2B || itemToBeGiven->baseItemId == 0x78) {
return game::actors::EnBoxType::ENBOX_TYPE_BIG_ROOM_CLEAR;
}
} else if (boxType == game::actors::EnBoxType::ENBOX_TYPE_SMALL_SWITCH_FLAG ||
boxType == game::actors::EnBoxType::ENBOX_TYPE_BIG_SWITCH_FLAG) {
if (itemToBeGiven->baseItemId == 0x02) {
return game::actors::EnBoxType::ENBOX_TYPE_SMALL_SWITCH_FLAG;
} else if (itemToBeGiven->baseItemId == 0x2B || itemToBeGiven->baseItemId == 0x78) {
return game::actors::EnBoxType::ENBOX_TYPE_BIG_SWITCH_FLAG;
}
}
} else {
return (game::actors::EnBoxType)0xFF;
Expand Down
6 changes: 3 additions & 3 deletions code/source/rnd/item_override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ namespace rnd {
rItemOverrides[0].value.getItemId = 0x26;
rItemOverrides[0].value.looksLikeItemId = 0x26;
rItemOverrides[1].key.scene = 0x6F;
rItemOverrides[1].key.type = ItemOverride_Type::OVR_COLLECTABLE;
rItemOverrides[1].value.getItemId = 0x0C;
rItemOverrides[1].value.looksLikeItemId = 0x0C;
rItemOverrides[1].key.type = ItemOverride_Type::OVR_CHEST;
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 7c67cde

Please sign in to comment.