Skip to content

Commit

Permalink
Fix get item issues that may be plaguing several things, including tw…
Browse files Browse the repository at this point in the history
…inmold.
  • Loading branch information
PhlexPlexico committed Jan 29, 2024
1 parent a135662 commit ab41c3e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 27 deletions.
2 changes: 1 addition & 1 deletion code/include/rnd/savefile.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace rnd {
BitField<28, 1, u32> enFsnANMGivenItem;
BitField<29, 1, u32> enOshGivenItem;
BitField<30, 1, u32> enGoGivenItem;
BitField<31, 1, u32> unused;
BitField<31, 1, u32> enBoss02GivenItem;
};
GivenItemRegister givenItemChecks;
union FairyCollectRegister {
Expand Down
8 changes: 0 additions & 8 deletions code/mm.ld
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ SECTIONS{
*(.patch_CheckCurrentInventoryOverrideItem)
}

/* .patch_CheckCurrentInventoryOverrideItemTwo 0x201060 : {
*(.patch_CheckCurrentInventoryOverrideItemTwo)
} */

/* .patch_OverrideItemIDFour 0x1FBD10 : {
*(.patch_OverrideItemIdIndex)
} */
Expand Down Expand Up @@ -267,10 +263,6 @@ SECTIONS{
*(.patch_EnteringLocation)
}

.patch_TwinmoldRemoveGiantMaskCheck 0x2652D8 : {
*(.patch_TwinmoldRemoveGiantMaskCheck)
}

/* .patch_TwinmoldConsistentDamage 0x28E544 : {
*(.patch_TwinmoldConsistentDamage)
} */
Expand Down
5 changes: 3 additions & 2 deletions code/source/asm/hooks.s
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ hook_SpawnFastElegyStatues:

.global hook_CheckCurrentInventory
hook_CheckCurrentInventory:
push {lr}
push {r1-r12, lr}
bl ItemOverride_CheckInventoryItemOverride
pop {pc}
pop {r1-r12, lr}
b 0x1F3D6C

.global hook_CheckOcarinaDive
hook_CheckOcarinaDive:
Expand Down
13 changes: 0 additions & 13 deletions code/source/asm/patches.s
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,6 @@ patch_SpawnFastElegyStatues:
patch_CheckCurrentInventoryOverrideItem:
b hook_CheckCurrentInventory

.section .patch_CheckCurrentInventoryOverrideItemTwo
.global patch_CheckCurrentInventoryOverrideItemTwo
patch_CheckCurrentInventoryOverrideItemTwo:
b hook_CheckCurrentInventory



.section .patch_ForceSwordUpgradeOnHuman
.global patch_ForceSwordUpgradeOnHuman
patch_ForceSwordUpgradeOnHuman:
Expand Down Expand Up @@ -289,12 +282,6 @@ OverrideItemID_patch:
patch_EnteringLocation:
bl hook_EnteringLocation

@ NOP the branch for checking if we have giant's mask and set flag anyway.
.section .patch_TwinmoldRemoveGiantMaskCheck
.global patch_TwinmoldRemoveGiantMaskCheck
patch_TwinmoldRemoveGiantMaskCheck:
nop

.section .patch_RemoveGoronMaskCheckDarmani
.global patch_RemoveGoronMaskCheckDarmani
patch_RemoveGoronMaskCheckDarmani:
Expand Down
15 changes: 12 additions & 3 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 = 0x34;
rItemOverrides[1].value.looksLikeItemId = 0x34;
rItemOverrides[1].value.getItemId = 0xA1;
rItemOverrides[1].value.looksLikeItemId = 0xA1;
rItemOverrides[2].key.scene = 0x12;
rItemOverrides[2].key.type = ItemOverride_Type::OVR_COLLECTABLE;
rItemOverrides[2].value.getItemId = 0x37;
Expand Down Expand Up @@ -467,6 +467,8 @@ namespace rnd {
gExtSaveData.givenItemChecks.enOshGivenItem = 1;
} else if (storedGetItemId == rnd::GetItemID::GI_POWDER_KEG) {
gExtSaveData.givenItemChecks.enGoGivenItem = 1;
} else if ((s16)storedGetItemId == -(s16)rnd::GetItemID::GI_MASK_GIANTS) {
gExtSaveData.givenItemChecks.enBoss02GivenItem = 1;
}
}

Expand Down Expand Up @@ -761,9 +763,16 @@ namespace rnd {

return givenItems.enGoGivenItem ? (int) currentItem
: (int)0xFF;
} else if (currentItem == game::ItemId::GiantMask) {
return givenItems.enBoss02GivenItem ? (int) currentItem
: (int)0xFF;
}
// Use the standard pointer to array as this seems to mess with
// some issues in checking items such as trade items, and Giant's Mask.
auto& inventory = game::GetCommonData().save.inventory.items;
return (int)inventory[(int)currentItem];
u8* slotArray = (u8*)0x626cdc;
u8 slot = slotArray[(int)currentItem];
return (int)inventory[slot];
}

// clang-format on
Expand Down

0 comments on commit ab41c3e

Please sign in to comment.