diff --git a/UnleashedRecomp/api/SWA.h b/UnleashedRecomp/api/SWA.h index 8882888..6a30e75 100644 --- a/UnleashedRecomp/api/SWA.h +++ b/UnleashedRecomp/api/SWA.h @@ -62,6 +62,7 @@ #include "SWA/Camera/Camera.h" #include "SWA/Camera/CameraController.h" #include "SWA/CharacterUtility/CharacterProxy.h" +#include "SWA/Globals.h" #include "SWA/HUD/GeneralWindow/GeneralWindow.h" #include "SWA/HUD/Loading/Loading.h" #include "SWA/HUD/Pause/HudPause.h" diff --git a/UnleashedRecomp/api/SWA/Globals.h b/UnleashedRecomp/api/SWA/Globals.h new file mode 100644 index 0000000..34dc697 --- /dev/null +++ b/UnleashedRecomp/api/SWA/Globals.h @@ -0,0 +1,69 @@ +#pragma once + +#include + +namespace SWA +{ + struct SGlobals + { + // ms_DrawLightFieldSamplingPoint: サンプリング点をデバッグ表示 + static inline bool* ms_DrawLightFieldSamplingPoint; + + // ms_IgnoreLightFieldData: データを無視する + static inline bool* ms_IgnoreLightFieldData; + + // IsCollisionRender + static inline bool* ms_IsCollisionRender; + + // N/A + static inline bool* ms_IsLoading; + + // IsObjectCollisionRender + static inline bool* ms_IsObjectCollisionRender; + + // ms_IsRenderDebugDraw: デバッグ描画 + static inline bool* ms_IsRenderDebugDraw; + + // ms_IsRenderDebugDrawText: デバッグ文字描画 + static inline bool* ms_IsRenderDebugDrawText; + + // ms_IsRenderDebugPositionDraw: デバッグ位置描画 + static inline bool* ms_IsRenderDebugPositionDraw; + + // ms_IsRenderGameMainHud: ゲームメインHUD 描画 + static inline bool* ms_IsRenderGameMainHud; + + // ms_IsRenderHud: 全 HUD 描画 + static inline bool* ms_IsRenderHud; + + // ms_IsRenderHudPause: ポーズメニュー 描画 + static inline bool* ms_IsRenderHudPause; + + // IsTriggerRender + static inline bool* ms_IsTriggerRender; + + // ms_LightFieldDebug: 値をデバッグ表示 + static inline bool* ms_LightFieldDebug; + + // VisualizeLoadedLevel: ミップレベルを視覚化 赤=0, 緑=1, 青=2, 黄=未ロード + static inline bool* ms_VisualizeLoadedLevel; + + static void Init() + { + ms_DrawLightFieldSamplingPoint = (bool*)MmGetHostAddress(0x83367BCE); + ms_IgnoreLightFieldData = (bool*)MmGetHostAddress(0x83367BCF); + ms_IsCollisionRender = (bool*)MmGetHostAddress(0x833678A6); + ms_IsLoading = (bool*)MmGetHostAddress(0x83367A4C); + ms_IsObjectCollisionRender = (bool*)MmGetHostAddress(0x83367905); + ms_IsRenderDebugDraw = (bool*)MmGetHostAddress(0x8328BB23); + ms_IsRenderDebugDrawText = (bool*)MmGetHostAddress(0x8328BB25); + ms_IsRenderDebugPositionDraw = (bool*)MmGetHostAddress(0x8328BB24); + ms_IsRenderGameMainHud = (bool*)MmGetHostAddress(0x8328BB27); + ms_IsRenderHud = (bool*)MmGetHostAddress(0x8328BB26); + ms_IsRenderHudPause = (bool*)MmGetHostAddress(0x8328BB28); + ms_IsTriggerRender = (bool*)MmGetHostAddress(0x83367904); + ms_LightFieldDebug = (bool*)MmGetHostAddress(0x83367BCD); + ms_VisualizeLoadedLevel = (bool*)MmGetHostAddress(0x833678C1); + } + }; +} diff --git a/UnleashedRecomp/app.cpp b/UnleashedRecomp/app.cpp index 710aeea..5b6c163 100644 --- a/UnleashedRecomp/app.cpp +++ b/UnleashedRecomp/app.cpp @@ -1,4 +1,5 @@ -#include +#include "app.h" +#include #include #include #include @@ -34,6 +35,8 @@ PPC_FUNC(sub_824EB490) App::s_isInit = true; App::s_isMissingDLC = !Installer::checkAllDLC(GetGamePath()); App::s_language = Config::Language; + + SWA::SGlobals::Init(); Registry::Save(); __imp__sub_824EB490(ctx, base); diff --git a/UnleashedRecomp/gpu/video.cpp b/UnleashedRecomp/gpu/video.cpp index 41f8bf1..9baf2f6 100644 --- a/UnleashedRecomp/gpu/video.cpp +++ b/UnleashedRecomp/gpu/video.cpp @@ -3435,7 +3435,7 @@ static RenderPipeline* CreateGraphicsPipelineInRenderThread(PipelineState pipeli pipeline = CreateGraphicsPipeline(pipelineState); #ifdef ASYNC_PSO_DEBUG - bool loading = *reinterpret_cast(g_memory.Translate(0x83367A4C)); + bool loading = *SWA::SGlobals::ms_IsLoading; if (loading) ++g_pipelinesCreatedAsynchronously; @@ -5407,7 +5407,7 @@ static void PipelineCompilerThread() #ifdef _WIN32 int newThreadPriority = threadPriority; - bool loading = *reinterpret_cast(g_memory.Translate(0x83367A4C)); + bool loading = *SWA::SGlobals::ms_IsLoading; if (loading) newThreadPriority = THREAD_PRIORITY_HIGHEST; else @@ -5468,7 +5468,7 @@ static void EnqueueGraphicsPipelineCompilation( if (shouldCompile) { - bool loading = *reinterpret_cast(g_memory.Translate(0x83367A4C)); + bool loading = *SWA::SGlobals::ms_IsLoading; if (!loading && isPrecompiledPipeline) { // We can just compile here during the logos. @@ -5805,7 +5805,7 @@ static void CompileMeshPipeline(const Mesh& mesh, CompilationArgs& args) // We cannot rely on this being accurate during loading as SceneEffect.prm.xml gets loaded a bit later. bool planarReflectionEnabled = *reinterpret_cast(g_memory.Translate(0x832FA0D8)); - bool loading = *reinterpret_cast(g_memory.Translate(0x83367A4C)); + bool loading = *SWA::SGlobals::ms_IsLoading; bool compileNoMsaaPipeline = pipelineState.sampleCount != 1 && (loading || planarReflectionEnabled); auto noMsaaPipeline = pipelineState; diff --git a/UnleashedRecomp/patches/CHudPause_patches.cpp b/UnleashedRecomp/patches/CHudPause_patches.cpp index a648140..45a47f7 100644 --- a/UnleashedRecomp/patches/CHudPause_patches.cpp +++ b/UnleashedRecomp/patches/CHudPause_patches.cpp @@ -161,9 +161,7 @@ PPC_FUNC(sub_824B0930) { g_achievementMenuIntroTime = 0; - const auto ms_IsRenderHud = (bool*)g_memory.Translate(0x8328BB26); - - if (*ms_IsRenderHud && pHudPause->m_IsShown && !pHudPause->m_Submenu && pHudPause->m_Transition == SWA::eTransitionType_Undefined) + if (*SWA::SGlobals::ms_IsRenderHud && pHudPause->m_IsShown && !pHudPause->m_Submenu && pHudPause->m_Transition == SWA::eTransitionType_Undefined) { ButtonGuide::Open(Button(Localise("Achievements_Name"), EButtonIcon::Back, EButtonAlignment::Left, EFontQuality::Low)); g_isClosed = false; diff --git a/UnleashedRecomp/patches/fps_patches.cpp b/UnleashedRecomp/patches/fps_patches.cpp index aac1be6..41cc7e0 100644 --- a/UnleashedRecomp/patches/fps_patches.cpp +++ b/UnleashedRecomp/patches/fps_patches.cpp @@ -94,7 +94,7 @@ bool LoadingUpdateMidAsmHook(PPCRegister& r31) g_ppcContext->f1.f64 = deltaTime; g_memory.FindFunction(update)(*g_ppcContext, base); - bool loading = PPC_LOAD_U8(0x83367A4C); + bool loading = *SWA::SGlobals::ms_IsLoading; if (loading) { now = std::chrono::steady_clock::now(); diff --git a/UnleashedRecomp/patches/frontend_listener.cpp b/UnleashedRecomp/patches/frontend_listener.cpp index 9061948..c66224a 100644 --- a/UnleashedRecomp/patches/frontend_listener.cpp +++ b/UnleashedRecomp/patches/frontend_listener.cpp @@ -21,12 +21,9 @@ public: if (event->key.keysym.sym != SDLK_F8 || m_isF8KeyDown) break; - // アプリケーション設定 / 開発用 / デバッグ / HUD / 全 HUD 描画 - const auto ms_IsRenderHud = (bool*)g_memory.Translate(0x8328BB26); + *SWA::SGlobals::ms_IsRenderHud = !*SWA::SGlobals::ms_IsRenderHud; - *ms_IsRenderHud = !*ms_IsRenderHud; - - LOGFN("HUD {}", *ms_IsRenderHud ? "ON" : "OFF"); + LOGFN("HUD {}", *SWA::SGlobals::ms_IsRenderHud ? "ON" : "OFF"); m_isF8KeyDown = true; @@ -38,4 +35,5 @@ public: break; } } -} g_frontendlistener; +} +g_frontendListener; diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index 78c5942..8e6a79b 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -1430,7 +1430,7 @@ static void DrawInfoPanel(ImVec2 infoMin, ImVec2 infoMax) static void SetOptionsMenuVisible(bool isVisible) { OptionsMenu::s_isVisible = isVisible; - *(bool*)g_memory.Translate(0x8328BB26) = !isVisible; + *SWA::SGlobals::ms_IsRenderHud = !isVisible; } static bool DrawMilesElectric() diff --git a/UnleashedRecomp/user/config_def.h b/UnleashedRecomp/user/config_def.h index cace946..3bbc122 100644 --- a/UnleashedRecomp/user/config_def.h +++ b/UnleashedRecomp/user/config_def.h @@ -81,7 +81,7 @@ CONFIG_DEFINE_HIDDEN("Exports", bool, DisableDLCIcon, false); CONFIG_DEFINE_HIDDEN("Exports", bool, DisableDWMRoundedCorners, false); CONFIG_DEFINE_HIDDEN("Exports", bool, FixUnleashOutOfControlDrain, false); CONFIG_DEFINE_HIDDEN("Exports", bool, HomingAttackOnBoost, true); +CONFIG_DEFINE_HIDDEN("Exports", bool, HUDToggleHotkey, false); CONFIG_DEFINE_HIDDEN("Exports", bool, SaveScoreAtCheckpoints, false); CONFIG_DEFINE_HIDDEN("Exports", bool, SkipIntroLogos, false); CONFIG_DEFINE_HIDDEN("Exports", bool, UseOfficialTitleOnTitleBar, false); -CONFIG_DEFINE_HIDDEN("Exports", bool, HUDToggleHotkey, false);