From 4bf576ab1c2bea5cdcf32bf12654ce9ea2718219 Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Mon, 4 Nov 2024 12:46:58 +0000 Subject: [PATCH] Implemented control tutorial toggle --- UnleashedRecomp/api/SWA.h | 1 + .../Character/EvilSonic/EvilSonicContext.h | 8 ++++- .../Character/EvilSonic/Hud/EvilHudGuide.h | 29 +++++++++++++++++++ UnleashedRecomp/config.h | 1 + UnleashedRecomp/game.cpp | 15 +++++++++- UnleashedRecompLib/config/SWA.toml | 13 +++++++++ 6 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 UnleashedRecomp/api/SWA/Player/Character/EvilSonic/Hud/EvilHudGuide.h diff --git a/UnleashedRecomp/api/SWA.h b/UnleashedRecomp/api/SWA.h index a544cf7..7a93b52 100644 --- a/UnleashedRecomp/api/SWA.h +++ b/UnleashedRecomp/api/SWA.h @@ -1,6 +1,7 @@ #pragma once #include "SWA/Camera/Camera.h" +#include "SWA/Player/Character/EvilSonic/Hud/EvilHudGuide.h" #include "SWA/Player/Character/EvilSonic/EvilSonic.h" #include "SWA/Player/Character/EvilSonic/EvilSonicContext.h" #include "SWA/System/ApplicationDocument.h" diff --git a/UnleashedRecomp/api/SWA/Player/Character/EvilSonic/EvilSonicContext.h b/UnleashedRecomp/api/SWA/Player/Character/EvilSonic/EvilSonicContext.h index ebc786d..d8f38ae 100644 --- a/UnleashedRecomp/api/SWA/Player/Character/EvilSonic/EvilSonicContext.h +++ b/UnleashedRecomp/api/SWA/Player/Character/EvilSonic/EvilSonicContext.h @@ -1,6 +1,7 @@ #pragma once #include "SWA.inl" +#include "SWA/Player/Character/EvilSonic/Hud/EvilHudGuide.h" namespace SWA::Player { @@ -11,7 +12,12 @@ namespace SWA::Player be m_DarkGaiaEnergy; SWA_INSERT_PADDING(0x138); be m_AnimationID; - SWA_INSERT_PADDING(0x104); + SWA_INSERT_PADDING(0x38); + be m_UnkHudGuideF32; + be m_UnkHudGuideU32; + SWA_INSERT_PADDING(0x18); + be m_GuideType; + SWA_INSERT_PADDING(0xA8); be m_OutOfControlCount; }; } diff --git a/UnleashedRecomp/api/SWA/Player/Character/EvilSonic/Hud/EvilHudGuide.h b/UnleashedRecomp/api/SWA/Player/Character/EvilSonic/Hud/EvilHudGuide.h new file mode 100644 index 0000000..090d5b0 --- /dev/null +++ b/UnleashedRecomp/api/SWA/Player/Character/EvilSonic/Hud/EvilHudGuide.h @@ -0,0 +1,29 @@ +#pragma once + +#include "SWA.inl" + +namespace SWA::Player +{ + enum EGuideAction : uint32_t + { + eGuideAction_Single, + eGuideAction_Chain + }; + + enum EGuideType : uint32_t + { + eGuideType_A, + eGuideType_B, + eGuideType_X, + eGuideType_Y + }; + + class CEvilHudGuide + { + public: + SWA_INSERT_PADDING(0x14D); + bool m_IsShown; + bool m_IsVisible; + EGuideType m_GuideType; + }; +} diff --git a/UnleashedRecomp/config.h b/UnleashedRecomp/config.h index e3e7caf..652ed07 100644 --- a/UnleashedRecomp/config.h +++ b/UnleashedRecomp/config.h @@ -9,6 +9,7 @@ public: CONFIG_DEFINE_ENUM("System", ELanguage, Language, ELanguage::English); CONFIG_DEFINE("System", bool, Hints, true); + CONFIG_DEFINE("System", bool, ControlTutorial, true); CONFIG_DEFINE_ENUM("System", EScoreBehaviour, ScoreBehaviour, EScoreBehaviour::CheckpointReset); CONFIG_DEFINE("System", bool, UnleashOutOfControlDrain, true); CONFIG_DEFINE("System", bool, WerehogHubTransformVideo, true); diff --git a/UnleashedRecomp/game.cpp b/UnleashedRecomp/game.cpp index 848676e..dfc032f 100644 --- a/UnleashedRecomp/game.cpp +++ b/UnleashedRecomp/game.cpp @@ -100,7 +100,7 @@ PPC_FUNC(sub_8245F048) if (!pGameDocument) return; - printf("Resetting score to %d\n", m_lastCheckpointScore); + printf("[*] Resetting score to %d\n", m_lastCheckpointScore); pGameDocument->m_pMember->m_Score = m_lastCheckpointScore; } @@ -202,6 +202,19 @@ bool DisableHintsMidAsmHook() return !Config::Hints; } +bool DisableControlTutorialMidAsmHook() +{ + return !Config::ControlTutorial; +} + +bool DisableEvilControlTutorialMidAsmHook(PPCRegister& r4, PPCRegister& r5) +{ + if (Config::ControlTutorial) + return true; + + return r4.u32 == 1 && r5.u32 == 1; +} + void SetXButtonHomingMidAsmHook(PPCRegister& r30) { r30.u32 = Config::XButtonHoming; diff --git a/UnleashedRecompLib/config/SWA.toml b/UnleashedRecompLib/config/SWA.toml index 0c5e522..204555b 100644 --- a/UnleashedRecompLib/config/SWA.toml +++ b/UnleashedRecompLib/config/SWA.toml @@ -122,6 +122,19 @@ name = "DisableHintsMidAsmHook" address = 0x827A2E34 jump_address_on_true = 0x827A2E4C +# Disable navigation volumes +[[midasm_hook]] +name = "DisableControlTutorialMidAsmHook" +address = 0x827AA5EC +jump_address_on_true = 0x827AA604 + +# Disable Werehog button prompts +[[midasm_hook]] +name = "DisableEvilControlTutorialMidAsmHook" +address = 0x823A4FF0 +registers = ["r4", "r5"] +return_on_false = true + [[midasm_hook]] name = "SetXButtonHomingMidAsmHook" address = 0x8237AC88