Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Twinmold And Various Item Checks #15

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 0 additions & 4 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
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
7 changes: 0 additions & 7 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
18 changes: 12 additions & 6 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 @@ -755,18 +757,22 @@ namespace rnd {
auto* gctx = rnd::GetContext().gctx;

if (gctx->scene == game::SceneId::BombShop) {
#if defined ENABLE_DEBUG || defined DEBUG_PRINT
rnd::util::Print("%s: Do we have powder keg? Item %u is %u\n", __func__, currentItem, game::HasItem((game::ItemId)currentItem));
#endif
return game::HasItem((game::ItemId)currentItem) ? (int) currentItem
: (int)0xFF;
}

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
2 changes: 1 addition & 1 deletion code/source/rnd/savefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ namespace rnd {
saveData.meeting_happy_mask_salesman_0x01 = 0x01;
saveData.skullkid_backstory_cutscene_0x10 = 0x10;
saveData.cut_scene_flag_bundle.owl_statue_cut_scene = 1;
saveData.dungeon_skip_portal_cutscene_0x3C_to_skip_all = 0x3C;
// saveData.dungeon_skip_portal_cutscene_0x3C_to_skip_all = 0x3C;
saveData.turtle_flags.skip_swimming_to_great_bay_temple_cutscene = 1;

// Needs to be greater than zero to skip first time song of time cutscene
Expand Down
Loading