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

Adjust overrides for tokensanity to ensure proper IDs are being given. #90

Merged
merged 1 commit into from
Jul 22, 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/item_override.h
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ namespace rnd {
bool ItemOverride_CheckTingleMaps(u16, game::GlobalContext*);
u32 ItemOverride_GetGaboraExtData();
u32 ItemOverride_GetOshExtData();
u8 ItemOverride_OverrideSkullToken(game::GlobalContext*, game::act::Actor*);
u8 ItemOverride_OverrideSkullToken(game::act::Actor*);
u8 ItemOverride_CheckBossStatus();
}
extern "C" u32 rActiveItemGraphicId;
Expand Down
7 changes: 5 additions & 2 deletions code/mm.ld
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,17 @@ SECTIONS{
*(.patch_OverrideItemID)
}

.patch_TwinmoldConsistentDamage 0x28E544 : {
*(.patch_TwinmoldConsistentDamage)
.patch_RemoveAddingSkulltulaTokenIfOverridden 0x23975C : {
*(.patch_RemoveAddingSkulltulaTokenIfOverridden)
}

.patch_EnteringLocation 0x23AA54 : {
*(.patch_EnteringLocation)
}

.patch_TwinmoldConsistentDamage 0x28E544 : {
*(.patch_TwinmoldConsistentDamage)
}

.patch_FasterBlockMovement 0x2AC634 : {
*(.patch_FasterBlockMovement)
Expand Down
17 changes: 14 additions & 3 deletions code/source/asm/item_override_hooks.s
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,18 @@ noOverrideItemID:
cpy r0,r7
b 0x23110C


.global hook_RemoveAddingSkulltulaTokenIfOverridden
hook_RemoveAddingSkulltulaTokenIfOverridden:
push {r1}
ldr r1,.rActiveItemRow_addr
ldr r1,[r1]
cmp r1,#0x0
pop {r1}
bne doNotIncreaseSkulltulaCount
cmp r0, #0x27
b 0x239760
doNotIncreaseSkulltulaCount:
bx lr

.global hook_DarmaniRewardCheck
hook_DarmaniRewardCheck:
Expand Down Expand Up @@ -284,7 +295,7 @@ hook_ChangeSOHToCustomText:
.global hook_SkulltulaOverrideOne
hook_SkulltulaOverrideOne:
push {r0-r12,lr}
cpy r1,r5
cpy r0,r5
bl ItemOverride_OverrideSkullToken
cmp r0,#0x0
pop {r0-r12,lr}
Expand All @@ -297,7 +308,7 @@ skulltulaOverridden:
.global hook_SkulltulaOverrideTwo
hook_SkulltulaOverrideTwo:
push {r0-r12,lr}
cpy r1,r5
cpy r0,r4
bl ItemOverride_OverrideSkullToken
cmp r0,#0x0
pop {r0-r12,lr}
Expand Down
5 changes: 5 additions & 0 deletions code/source/asm/item_override_patches.s
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ OverrideTextID_patch:
OverrideItemID_patch:
b hook_OverrideItemID

.section .patch_RemoveAddingSkulltulaTokenIfOverridden
.global patch_RemoveAddingSkulltulaTokenIfOverridden
patch_RemoveAddingSkulltulaTokenIfOverridden:
b hook_RemoveAddingSkulltulaTokenIfOverridden

.section .patch_RemoveGoronMaskCheckDarmani
.global patch_RemoveGoronMaskCheckDarmani
patch_RemoveGoronMaskCheckDarmani:
Expand Down
10 changes: 6 additions & 4 deletions code/source/rnd/item_override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,8 @@ namespace rnd {
gExtSaveData.givenItemChecks.letterToKafeiGiven == 1) ||
(incomingGetItemId == (s16)GetItemID::GI_PENDANT_OF_MEMORIES &&
gExtSaveData.givenItemChecks.pendantGiven == 1)) {
player->get_item_id = (s16)GetItemID::GI_FISHING_HOLE_PASS;
if (incomingGetItemId != 0x44 && incomingGetItemId != 0x6D && incomingGetItemId != 0x52)
player->get_item_id = (s16)GetItemID::GI_FISHING_HOLE_PASS;
ItemOverride_Clear();
return;
}
Expand Down Expand Up @@ -812,8 +813,8 @@ namespace rnd {
rActiveItemRow->effectArg1 = override.key.all >> 16;
rActiveItemRow->effectArg2 = override.key.all & 0xFFFF;
}

player->get_item_id = incomingNegative ? -baseItemId : baseItemId;
if (incomingGetItemId != 0x44 && incomingGetItemId != 0x6D && incomingGetItemId != 0x52)
player->get_item_id = incomingNegative ? -baseItemId : baseItemId;
// Weird edge case with the way text and masks are handled with Couples' Mask.
// Set the text and apply it later in a different patch.
if (incomingGetItemId == 0x85) {
Expand Down Expand Up @@ -1045,7 +1046,8 @@ namespace rnd {
return (u32)gExtSaveData.givenItemChecks.enOshGivenItem;
}

u8 ItemOverride_OverrideSkullToken(game::GlobalContext* gctx, game::act::Actor* actor) {
u8 ItemOverride_OverrideSkullToken(game::act::Actor* actor) {
game::GlobalContext* gctx = GetContext().gctx;
s16 getItemId = gctx->scene == game::SceneId::SwampSpiderHouse ? 0x44 : 0x6D;
ItemOverride_GetItem(gctx, actor, gctx->GetPlayerActor(), getItemId);
if (rActiveItemRow != NULL) {
Expand Down
Loading