Skip to content

Commit

Permalink
Fix Saria's hints and external texture mods (#605)
Browse files Browse the repository at this point in the history
* Don't touch Link's model if custom tunics are off

* Register Saria's hints after talking to stone
  • Loading branch information
HylianFreddy committed Dec 11, 2022
1 parent a4c1864 commit aaf14ed
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 8 deletions.
4 changes: 4 additions & 0 deletions code/oot.ld
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ SECTIONS
*(.patch_KotakeDontPlayBattleMusic)
}

.patch_GossipStoneAddSariaHint 0x1B3968 : {
*(.patch_GossipStoneAddSariaHint)
}

.patch_ReadGossipStoneHints 0x1B3A44 : {
*(.patch_ReadGossipStoneHints)
}
Expand Down
4 changes: 4 additions & 0 deletions code/oot_e.ld
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ SECTIONS
*(.patch_KotakeDontPlayBattleMusic)
}

.patch_GossipStoneAddSariaHint 0x1B3968 : {
*(.patch_GossipStoneAddSariaHint)
}

.patch_ReadGossipStoneHints 0x1B3A44 : {
*(.patch_ReadGossipStoneHints)
}
Expand Down
22 changes: 15 additions & 7 deletions code/src/actors/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,23 @@ u8 storedMask = 0;
void* Player_EditAndRetrieveCMB(ZARInfo* zarInfo, u32 objModelIdx) {
void* cmbMan = ZAR_GetCMBByIndex(zarInfo, objModelIdx);

if (gSaveContext.linkAge == 0) {
void* cmb = (void*)(((char*)zarInfo->buf) + 0xDAE8);
CustomModel_EditLinkToCustomTunic(cmb);
} else {
void* cmb = (void*)(((char*)zarInfo->buf) + 0xDACC);
CustomModel_EditChildLinkToCustomTunic(cmb);
if (gSettingsContext.customTunicColors == ON) {
if (gSaveContext.linkAge == 0) {
void* cmb = (void*)(((char*)zarInfo->buf) + 0xDAE8);
CustomModel_EditLinkToCustomTunic(cmb);
} else {
void* cmb = (void*)(((char*)zarInfo->buf) + 0xDACC);
CustomModel_EditChildLinkToCustomTunic(cmb);
}
}

return cmbMan;
}

void* Player_GetCustomTunicCMAB(void) {
void* Player_GetCustomTunicCMAB(ZARInfo* originalZarInfo, u32 originalIndex) {
if (gSettingsContext.customTunicColors == OFF) {
return ZAR_GetCMABByIndex(originalZarInfo, originalIndex);
}
s16 exObjectBankIdx = Object_GetIndex(&rExtendedObjectCtx, OBJECT_CUSTOM_GENERAL_ASSETS);
if (exObjectBankIdx < 0) {
exObjectBankIdx = Object_Spawn(&rExtendedObjectCtx, OBJECT_CUSTOM_GENERAL_ASSETS);
Expand All @@ -57,6 +62,9 @@ void* Player_GetCustomTunicCMAB(void) {
}

void Player_SetChildCustomTunicCMAB(void) {
if (gSettingsContext.customTunicColors == OFF) {
return;
}
s16 exObjectBankIdx = Object_GetIndex(&rExtendedObjectCtx, OBJECT_CUSTOM_GENERAL_ASSETS);
void* cmabMan;
if (exObjectBankIdx < 0) {
Expand Down
3 changes: 3 additions & 0 deletions code/src/hints.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ u8 Hints_GetHintsSetting(void) {
}

void Hints_AddSariasSongHint(u16 textId) {
if ((textId & 0xFF00) != 0xA00) { // Skip non-hint texts from Gossip Stones
return;
}
u8 textIdSceneOffset = (textId & 0xF0) >> 4;
u8 textIdLookupBit = textId & 0xF;

Expand Down
6 changes: 5 additions & 1 deletion code/src/hooks.s
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,11 @@ hook_CanReadHints:
ldrh r0,[r4,#0x1C]
and r0,r0,#0xFF
add r0,r0,#0x400
# Register hint for Saria's Song
bx lr

.global hook_GossipStoneAddSariaHint
hook_GossipStoneAddSariaHint:
ldrh r0,[r5,#0x16]
push {r0-r12, lr}
add r0,r0,#0x600
bl Hints_AddSariasSongHint
Expand Down
5 changes: 5 additions & 0 deletions code/src/patches.s
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,11 @@ ReadGossipStoneHints_patch:
nop
nop

.section .patch_GossipStoneAddSariaHint
.global GossipStoneAddSariaHint_patch
GossipStoneAddSariaHint_patch:
bl hook_GossipStoneAddSariaHint

.section .patch_DecoratedChest
.global DecoratedChest_patch
DecoratedChest_patch:
Expand Down

0 comments on commit aaf14ed

Please sign in to comment.