From 825a1c36fb91138c3def1d7422892786f412ed66 Mon Sep 17 00:00:00 2001 From: Phlex Date: Tue, 27 Feb 2024 21:28:57 -0600 Subject: [PATCH] Include option to enable restoration twinmold. --- code/include/rnd/boss.h | 5 ++++- code/include/rnd/settings.h | 1 + code/source/asm/boss_hooks.s | 13 +++++++++++++ code/source/asm/boss_patches.s | 9 ++++++++- code/source/asm/patches.s | 6 ------ code/source/rnd/boss.cpp | 9 ++++++++- 6 files changed, 34 insertions(+), 9 deletions(-) diff --git a/code/include/rnd/boss.h b/code/include/rnd/boss.h index ac9f1680..27692f4f 100644 --- a/code/include/rnd/boss.h +++ b/code/include/rnd/boss.h @@ -18,6 +18,9 @@ extern "C" { namespace rnd { void FixBosses(); -} // namespace rnd + extern "C" { + u8 IsTwinmoldSetToRestoration(); + } +} // namespace rnd #endif \ No newline at end of file diff --git a/code/include/rnd/settings.h b/code/include/rnd/settings.h index cc760dbd..9f5ee5af 100644 --- a/code/include/rnd/settings.h +++ b/code/include/rnd/settings.h @@ -402,6 +402,7 @@ namespace rnd { u8 enableFastMaskTransform; u8 enableFastOcarina; u8 enableFastArrowSwap; + u8 twinmoldRestoration; // Cutscene Skips u8 skipHMSCutscenes; diff --git a/code/source/asm/boss_hooks.s b/code/source/asm/boss_hooks.s index 65e9cb44..183e80b6 100644 --- a/code/source/asm/boss_hooks.s +++ b/code/source/asm/boss_hooks.s @@ -7,4 +7,17 @@ hook_PostActorCalc: bl PostActorCalc @ found in main.cpp pop {r0-r12,lr} add r3,r5,#0x10 + bx lr + +.global hook_TwinmoldConsistentDamage +hook_TwinmoldConsistentDamage: + push {r0-r12, lr} + bl IsTwinmoldSetToRestoration + cmp r0,#0x1 + beq restorationTwinmold + pop {r0-r12,lr} + sub r0,r2,r0 + bx lr +restorationTwinmold: + pop {r0-r12,lr} bx lr \ No newline at end of file diff --git a/code/source/asm/boss_patches.s b/code/source/asm/boss_patches.s index 0143334b..4bfd3b6f 100644 --- a/code/source/asm/boss_patches.s +++ b/code/source/asm/boss_patches.s @@ -1,6 +1,13 @@ .arm + .section .patch_PostActorCalc .global patch_PostActorCalc patch_PostActorCalc: - bl hook_PostActorCalc \ No newline at end of file + bl hook_PostActorCalc + +@ Remove call from twinmold->life -= twinmold_min_damage. +.section .patch_TwinmoldConsistentDamage +.global patch_TwinmoldConsistentDamage +patch_TwinmoldConsistentDamage: + bl hook_TwinmoldConsistentDamage diff --git a/code/source/asm/patches.s b/code/source/asm/patches.s index 0b4e45c1..0e59c1a4 100644 --- a/code/source/asm/patches.s +++ b/code/source/asm/patches.s @@ -192,12 +192,6 @@ patch_ItemCloseOnSelect: patch_HandleOcarinaHooks: b hook_HandleOcarina -@ Remove call from twinmold->life -= twinmold_min_damage. -.section .patch_TwinmoldConsistentDamage -.global patch_TwinmoldConsistentDamage -patch_TwinmoldConsistentDamage: - nop - .section .patch_FasterBlockMovement .global patch_FasterBlockMovement patch_FasterBlockMovement: diff --git a/code/source/rnd/boss.cpp b/code/source/rnd/boss.cpp index 6442fd81..82817537 100644 --- a/code/source/rnd/boss.cpp +++ b/code/source/rnd/boss.cpp @@ -88,6 +88,13 @@ namespace rnd { state->red_prev_hit_counter = red_twinmold->hit_counter; } void FixBosses() { - FixTwinmold(); + if (IsTwinmoldSetToRestoration()) + FixTwinmold(); + } + + extern "C" { + u8 IsTwinmoldSetToRestoration() { + return gSettingsContext.twinmoldRestoration; + } } } // namespace rnd