From e545a95141c01cea37301a3fd44439c8d8aed88c Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Thu, 21 Nov 2024 21:01:04 +0000 Subject: [PATCH] options_menu: implemented Voice Language (and some misc. clean-up) --- UnleashedRecomp/api/SWA.h | 1 + UnleashedRecomp/api/SWA/HUD/Loading/Loading.h | 30 +++++++++++++++++++ .../api/SWA/System/ApplicationDocument.h | 10 ++++++- UnleashedRecomp/app.cpp | 2 +- UnleashedRecomp/patches/audio_patches.cpp | 11 +++++++ UnleashedRecomp/patches/resident_patches.cpp | 22 ++++---------- UnleashedRecomp/ui/options_menu.cpp | 4 +-- 7 files changed, 60 insertions(+), 20 deletions(-) create mode 100644 UnleashedRecomp/api/SWA/HUD/Loading/Loading.h diff --git a/UnleashedRecomp/api/SWA.h b/UnleashedRecomp/api/SWA.h index dfda8889..46c23437 100644 --- a/UnleashedRecomp/api/SWA.h +++ b/UnleashedRecomp/api/SWA.h @@ -36,6 +36,7 @@ #include "SWA/CSD/CsdProject.h" #include "SWA/CSD/CsdTexListMirage.h" #include "SWA/CSD/GameObjectCSD.h" +#include "SWA/HUD/Loading/Loading.h" #include "SWA/HUD/Pause/HudPause.h" #include "SWA/Player/Character/EvilSonic/Hud/EvilHudGuide.h" #include "SWA/Player/Character/EvilSonic/EvilSonic.h" diff --git a/UnleashedRecomp/api/SWA/HUD/Loading/Loading.h b/UnleashedRecomp/api/SWA/HUD/Loading/Loading.h new file mode 100644 index 00000000..a70dad0d --- /dev/null +++ b/UnleashedRecomp/api/SWA/HUD/Loading/Loading.h @@ -0,0 +1,30 @@ +#pragma once + +#include + +namespace SWA +{ + enum ELoadingDisplayType + { + eLoadingDisplayType_MilesElectric, + eLoadingDisplayType_None, + eLoadingDisplayType_WerehogMovie, + eLoadingDisplayType_MilesElectricContext, + eLoadingDisplayType_Arrows, + eLoadingDisplayType_NowLoading, + eLoadingDisplayType_EventGallery, + eLoadingDisplayType_ChangeTimeOfDay, + eLoadingDisplayType_Blank + }; + + class CLoading + { + public: + SWA_INSERT_PADDING(0x128); + bool m_IsVisible; + SWA_INSERT_PADDING(0x0C); + be m_LoadingDisplayType; + SWA_INSERT_PADDING(0x65); + bool m_IsNightToDay; + }; +} diff --git a/UnleashedRecomp/api/SWA/System/ApplicationDocument.h b/UnleashedRecomp/api/SWA/System/ApplicationDocument.h index fcc39529..c712e84b 100644 --- a/UnleashedRecomp/api/SWA/System/ApplicationDocument.h +++ b/UnleashedRecomp/api/SWA/System/ApplicationDocument.h @@ -5,6 +5,12 @@ namespace SWA { + enum EVoiceLanguage : uint32_t + { + eVoiceLanguage_English, + eVoiceLanguage_Japanese + }; + class CApplicationDocument // : public Hedgehog::Base::CSynchronizedObject { public: @@ -22,7 +28,9 @@ namespace SWA xpointer m_pVftable; xpointer m_pMember; - SWA_INSERT_PADDING(0x14); + SWA_INSERT_PADDING(0x04); + be m_VoiceLanguage; + SWA_INSERT_PADDING(0x0C); be m_Region; }; } diff --git a/UnleashedRecomp/app.cpp b/UnleashedRecomp/app.cpp index e94176b1..18187e51 100644 --- a/UnleashedRecomp/app.cpp +++ b/UnleashedRecomp/app.cpp @@ -1,6 +1,6 @@ +#include #include #include -#include #include double g_deltaTime; diff --git a/UnleashedRecomp/patches/audio_patches.cpp b/UnleashedRecomp/patches/audio_patches.cpp index e1a2c403..a6527aae 100644 --- a/UnleashedRecomp/patches/audio_patches.cpp +++ b/UnleashedRecomp/patches/audio_patches.cpp @@ -2,6 +2,7 @@ #include #include #include +#include be* GetVolume(bool isMusic = true) { @@ -26,5 +27,15 @@ void AudioPatches::Update(float deltaTime) *pEffectsVolume = Config::EffectsVolume; } +PPC_FUNC_IMPL(__imp__sub_824EB9B0); +PPC_FUNC(sub_824EB9B0) +{ + auto pApplicationDocument = (SWA::CApplicationDocument*)g_memory.Translate(ctx.r4.u32); + + pApplicationDocument->m_VoiceLanguage = (SWA::EVoiceLanguage)Config::VoiceLanguage.Value; + + __imp__sub_824EB9B0(ctx, base); +} + // Stub volume setter. GUEST_FUNCTION_STUB(sub_82E58728); diff --git a/UnleashedRecomp/patches/resident_patches.cpp b/UnleashedRecomp/patches/resident_patches.cpp index 6e72c065..7e4b582f 100644 --- a/UnleashedRecomp/patches/resident_patches.cpp +++ b/UnleashedRecomp/patches/resident_patches.cpp @@ -1,5 +1,6 @@ #include #include +#include const char* m_pStageID; @@ -12,30 +13,19 @@ void GetStageIDMidAsmHook(PPCRegister& r5) PPC_FUNC_IMPL(__imp__sub_824DCF38); PPC_FUNC(sub_824DCF38) { - // TODO: use the actual PS3 loading screen. + // TODO: use the actual PS3 loading screen ("n_2_d"). if (Config::TimeOfDayTransition == ETimeOfDayTransition::PlayStation) { - /* - 0 - Tails Electric NOW LOADING - 1 - No Transition - 2 - Werehog Transition - 3 - Tails Electric NOW LOADING w/ Info (requires context) - 4 - Arrows In/Out - 5 - NOW LOADING - 6 - Event Gallery - 7 - NOW LOADING - 8 - Black Screen - */ - if (ctx.r4.u32 == 2) - ctx.r4.u32 = 4; + if (ctx.r4.u32 == SWA::eLoadingDisplayType_WerehogMovie) + ctx.r4.u32 = SWA::eLoadingDisplayType_Arrows; } if (m_pStageID) { /* Fix restarting Eggmanland as the Werehog erroneously using the Event Gallery transition. */ - if (ctx.r4.u32 == 6 && !strcmp(m_pStageID, "Act_EggmanLand")) - ctx.r4.u32 = 5; + if (ctx.r4.u32 == SWA::eLoadingDisplayType_EventGallery && !strcmp(m_pStageID, "Act_EggmanLand")) + ctx.r4.u32 = SWA::eLoadingDisplayType_NowLoading; } __imp__sub_824DCF38(ctx, base); diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index 0336dcb8..7311f506 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -860,14 +860,14 @@ static void DrawConfigOptions() case 1: // INPUT DrawConfigOption(rowCount++, yOffset, &Config::InvertCameraX, true); DrawConfigOption(rowCount++, yOffset, &Config::InvertCameraY, true); - DrawConfigOption(rowCount++, yOffset, &Config::XButtonHoming, OptionsMenu::s_pauseMenuType == SWA::eMenuType_WorldMap, cmnReason); // TODO: make this editable in stages? + DrawConfigOption(rowCount++, yOffset, &Config::XButtonHoming, OptionsMenu::s_pauseMenuType == SWA::eMenuType_WorldMap, cmnReason); DrawConfigOption(rowCount++, yOffset, &Config::AllowCancellingUnleash, true); DrawConfigOption(rowCount++, yOffset, &Config::AllowBackgroundInput, true); break; case 2: // AUDIO DrawConfigOption(rowCount++, yOffset, &Config::MusicVolume, true); DrawConfigOption(rowCount++, yOffset, &Config::EffectsVolume, true); - DrawConfigOption(rowCount++, yOffset, &Config::VoiceLanguage, true); + DrawConfigOption(rowCount++, yOffset, &Config::VoiceLanguage, OptionsMenu::s_pauseMenuType == SWA::eMenuType_WorldMap, cmnReason); DrawConfigOption(rowCount++, yOffset, &Config::Subtitles, true); DrawConfigOption(rowCount++, yOffset, &Config::BattleTheme, true); break;