api: added globals struct

This commit is contained in:
Hyper 2025-01-12 21:28:13 +00:00
parent 023fc0edf7
commit 7788e36704
9 changed files with 126 additions and 68 deletions

View file

@ -57,6 +57,7 @@
#include "SWA/CSD/CsdTexListMirage.h" #include "SWA/CSD/CsdTexListMirage.h"
#include "SWA/CSD/GameObjectCSD.h" #include "SWA/CSD/GameObjectCSD.h"
#include "SWA/Camera/Camera.h" #include "SWA/Camera/Camera.h"
#include "SWA/Globals.h"
#include "SWA/HUD/GeneralWindow/GeneralWindow.h" #include "SWA/HUD/GeneralWindow/GeneralWindow.h"
#include "SWA/HUD/Loading/Loading.h" #include "SWA/HUD/Loading/Loading.h"
#include "SWA/HUD/Pause/HudPause.h" #include "SWA/HUD/Pause/HudPause.h"

View file

@ -0,0 +1,69 @@
#pragma once
#include <SWA.inl>
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*)g_memory.Translate(0x83367BCE);
ms_IgnoreLightFieldData = (bool*)g_memory.Translate(0x83367BCF);
ms_IsCollisionRender = (bool*)g_memory.Translate(0x833678A6);
ms_IsLoading = (bool*)MmGetHostAddress(0x83367A4C);
ms_IsObjectCollisionRender = (bool*)g_memory.Translate(0x83367905);
ms_IsRenderDebugDraw = (bool*)g_memory.Translate(0x8328BB23);
ms_IsRenderDebugDrawText = (bool*)g_memory.Translate(0x8328BB25);
ms_IsRenderDebugPositionDraw = (bool*)g_memory.Translate(0x8328BB24);
ms_IsRenderGameMainHud = (bool*)g_memory.Translate(0x8328BB27);
ms_IsRenderHud = (bool*)MmGetHostAddress(0x8328BB26);
ms_IsRenderHudPause = (bool*)g_memory.Translate(0x8328BB28);
ms_IsTriggerRender = (bool*)g_memory.Translate(0x83367904);
ms_LightFieldDebug = (bool*)g_memory.Translate(0x83367BCD);
ms_VisualizeLoadedLevel = (bool*)g_memory.Translate(0x833678C1);
}
};
}

View file

@ -1,4 +1,5 @@
#include <app.h> #include <app.h>
#include <api/SWA.h>
#include <gpu/video.h> #include <gpu/video.h>
#include <install/installer.h> #include <install/installer.h>
#include <kernel/function.h> #include <kernel/function.h>
@ -33,6 +34,8 @@ PPC_FUNC(sub_824EB490)
App::s_isMissingDLC = !Installer::checkAllDLC(GetGamePath()); App::s_isMissingDLC = !Installer::checkAllDLC(GetGamePath());
App::s_language = Config::Language; App::s_language = Config::Language;
SWA::SGlobals::Init();
__imp__sub_824EB490(ctx, base); __imp__sub_824EB490(ctx, base);
} }

View file

@ -3312,7 +3312,7 @@ static RenderPipeline* CreateGraphicsPipelineInRenderThread(PipelineState pipeli
pipeline = CreateGraphicsPipeline(pipelineState); pipeline = CreateGraphicsPipeline(pipelineState);
#ifdef ASYNC_PSO_DEBUG #ifdef ASYNC_PSO_DEBUG
bool loading = *reinterpret_cast<bool*>(g_memory.Translate(0x83367A4C)); bool loading = *SWA::SGlobals::ms_IsLoading;
if (loading) if (loading)
++g_pipelinesCreatedAsynchronously; ++g_pipelinesCreatedAsynchronously;

View file

@ -94,8 +94,7 @@ bool LoadingUpdateMidAsmHook(PPCRegister& r31)
g_ppcContext->f1.f64 = deltaTime; g_ppcContext->f1.f64 = deltaTime;
g_memory.FindFunction(update)(*g_ppcContext, base); g_memory.FindFunction(update)(*g_ppcContext, base);
bool loading = PPC_LOAD_U8(0x83367A4C); if (*SWA::SGlobals::ms_IsLoading)
if (loading)
{ {
now = std::chrono::steady_clock::now(); now = std::chrono::steady_clock::now();
constexpr auto INTERVAL = 1000000000ns / 30; constexpr auto INTERVAL = 1000000000ns / 30;
@ -104,7 +103,7 @@ bool LoadingUpdateMidAsmHook(PPCRegister& r31)
std::this_thread::sleep_until(next); std::this_thread::sleep_until(next);
} }
return loading; return *SWA::SGlobals::ms_IsLoading;
} }
// ADXM_WaitVsync // ADXM_WaitVsync

View file

@ -159,9 +159,7 @@ PPC_FUNC(sub_824B0930)
{ {
g_achievementMenuIntroTime = 0; g_achievementMenuIntroTime = 0;
const auto ms_IsRenderHud = (bool*)g_memory.Translate(0x8328BB26); if (*SWA::SGlobals::ms_IsRenderHud && pHudPause->m_IsShown && pHudPause->m_Transition == SWA::eTransitionType_Undefined)
if (*ms_IsRenderHud && pHudPause->m_IsShown && pHudPause->m_Transition == SWA::eTransitionType_Undefined)
{ {
ButtonGuide::Open(Button(Localise("Achievements_Name"), EButtonIcon::Back, EButtonAlignment::Left, EFontQuality::Low)); ButtonGuide::Open(Button(Localise("Achievements_Name"), EButtonIcon::Back, EButtonAlignment::Left, EFontQuality::Low));
g_isClosed = false; g_isClosed = false;

View file

@ -1,3 +1,34 @@
#include "frontend_listener.h" #include "frontend_listener.h"
#include <api/SWA.h>
#include <kernel/memory.h>
#include <os/logger.h>
#include <ui/options_menu.h>
FrontendListener m_frontendListener; FrontendListener g_frontendListener;
void FrontendListener::OnSDLEvent(SDL_Event* event)
{
if (OptionsMenu::s_isVisible)
return;
switch (event->type)
{
case SDL_KEYDOWN:
{
if (event->key.keysym.sym != SDLK_F8 || m_isF8KeyDown)
break;
*SWA::SGlobals::ms_IsRenderHud = !*SWA::SGlobals::ms_IsRenderHud;
LOGFN("HUD {}", *SWA::SGlobals::ms_IsRenderHud ? "ON" : "OFF");
m_isF8KeyDown = true;
break;
}
case SDL_KEYUP:
m_isF8KeyDown = event->key.keysym.sym != SDLK_F8;
break;
}
}

View file

@ -1,42 +1,11 @@
#pragma once #pragma once
#include <kernel/memory.h>
#include <ui/sdl_listener.h> #include <ui/sdl_listener.h>
#include <ui/options_menu.h>
#include <os/logger.h>
class FrontendListener : public SDLEventListener class FrontendListener : public SDLEventListener
{ {
bool m_isF8KeyDown = false; bool m_isF8KeyDown = false;
public: public:
void OnSDLEvent(SDL_Event* event) override void OnSDLEvent(SDL_Event* event) override;
{
if (OptionsMenu::s_isVisible)
return;
switch (event->type)
{
case SDL_KEYDOWN:
{
if (event->key.keysym.sym != SDLK_F8 || m_isF8KeyDown)
break;
// アプリケーション設定 / 開発用 / デバッグ / HUD / 全 HUD 描画
const auto ms_IsRenderHud = (bool*)g_memory.Translate(0x8328BB26);
*ms_IsRenderHud = !*ms_IsRenderHud;
LOGFN("HUD {}", *ms_IsRenderHud ? "ON" : "OFF");
m_isF8KeyDown = true;
break;
}
case SDL_KEYUP:
m_isF8KeyDown = event->key.keysym.sym != SDLK_F8;
break;
}
}
}; };

View file

@ -1,4 +1,5 @@
#include "view_window.h" #include "view_window.h"
#include <api/SWA.h>
#include <gpu/video.h> #include <gpu/video.h>
#include <kernel/memory.h> #include <kernel/memory.h>
#include <ui/reddog/reddog_controls.h> #include <ui/reddog/reddog_controls.h>
@ -15,47 +16,34 @@ void ViewWindow::Draw()
Reddog::Checkbox("Render FPS", &Config::ShowFPS.Value); Reddog::Checkbox("Render FPS", &Config::ShowFPS.Value);
Reddog::Checkbox("Render Debug Lines", &Reddog::DebugDraw::ms_IsDrawLine); Reddog::Checkbox("Render Debug Lines", &Reddog::DebugDraw::ms_IsDrawLine);
Reddog::Checkbox("Render Debug Text", &Reddog::DebugDraw::ms_IsDrawText); Reddog::Checkbox("Render Debug Text", &Reddog::DebugDraw::ms_IsDrawText);
Reddog::Checkbox("Render HUD (F8)", (bool*)g_memory.Translate(0x8328BB26)); Reddog::Checkbox("Render HUD (F8)", SWA::SGlobals::ms_IsRenderHud);
Reddog::Separator(); Reddog::Separator();
//// デバッグ描画 // Reddog::Checkbox((const char*)u8"Render Debug Draw", SWA::SGlobals::ms_IsRenderDebugDraw);
//Reddog::Checkbox((const char*)u8"Render Debug Draw", (bool*)g_memory.Translate(0x8328BB23)); // Reddog::Checkbox((const char*)u8"Render Debug Position Draw", SWA::SGlobals::ms_IsRenderDebugPositionDraw);
//// デバッグ位置描画 // Reddog::Checkbox((const char*)u8"Render Debug Draw Text", SWA::SGlobals::ms_IsRenderDebugDrawText);
//Reddog::Checkbox((const char*)u8"Render Debug Position Draw", (bool*)g_memory.Translate(0x8328BB24));
//// デバッグ文字描画
//Reddog::Checkbox((const char*)u8"Render Debug Draw Text", (bool*)g_memory.Translate(0x8328BB25));
// Reddog::Separator(); // Reddog::Separator();
//// 全 HUD 描画 // Reddog::Checkbox((const char*)g_memory.Translate(0x82031850), SWA::SGlobals::ms_IsRenderHud);
//Reddog::Checkbox((const char*)g_memory.Translate(0x82031850), (bool*)g_memory.Translate(0x8328BB26)); Reddog::Checkbox((const char*)u8"Render Main Game HUD", SWA::SGlobals::ms_IsRenderGameMainHud);
// ゲームメインHUD 描画 Reddog::Checkbox((const char*)u8"Render Pause HUD", SWA::SGlobals::ms_IsRenderHudPause);
Reddog::Checkbox((const char*)u8"Render Main Game HUD", (bool*)g_memory.Translate(0x8328BB27));
// ポーズメニュー 描画
Reddog::Checkbox((const char*)u8"Render Pause HUD", (bool*)g_memory.Translate(0x8328BB28));
Reddog::Separator(); Reddog::Separator();
// 値をデバッグ表示 Reddog::Checkbox((const char*)u8"Light Field Debug", SWA::SGlobals::ms_LightFieldDebug);
Reddog::Checkbox((const char*)u8"Light Field Debug", (bool*)g_memory.Translate(0x83367BCD)); Reddog::Checkbox((const char*)u8"Draw Light Field Sampling Point", SWA::SGlobals::ms_DrawLightFieldSamplingPoint);
// サンプリング点をデバッグ表示 Reddog::Checkbox((const char*)u8"Ignore Light Field Data", SWA::SGlobals::ms_IgnoreLightFieldData);
Reddog::Checkbox((const char*)u8"Draw Light Field Sampling Point", (bool*)g_memory.Translate(0x83367BCE));
// データを無視する
Reddog::Checkbox((const char*)u8"Ignore Light Field Data", (bool*)g_memory.Translate(0x83367BCF));
Reddog::Separator(); Reddog::Separator();
// ミップレベルを視覚化 赤=0, 緑=1, 青=2, 黄=未ロード Reddog::Checkbox((const char*)u8"Visualize Loaded GI Mip Level", SWA::SGlobals::ms_VisualizeLoadedLevel);
Reddog::Checkbox((const char*)u8"Visualize Loaded GI Mip Level", (bool*)g_memory.Translate(0x833678C1));
Reddog::Separator(); Reddog::Separator();
// IsCollisionRender Reddog::Checkbox((const char*)u8"Render Stage Collision", SWA::SGlobals::ms_IsCollisionRender);
Reddog::Checkbox((const char*)u8"Render Stage Collision", (bool*)g_memory.Translate(0x833678A6)); Reddog::Checkbox((const char*)u8"Render Event Collision", SWA::SGlobals::ms_IsTriggerRender);
// IsTriggerRender Reddog::Checkbox((const char*)u8"Render Rigid Body Collision", SWA::SGlobals::ms_IsObjectCollisionRender);
Reddog::Checkbox((const char*)u8"Render Event Collision", (bool*)g_memory.Translate(0x83367904));
// IsObjectCollisionRender
Reddog::Checkbox((const char*)u8"Render Rigid Body Collision", (bool*)g_memory.Translate(0x83367905));
Reddog::Separator(); Reddog::Separator();