From 3c87c1ec98113d4da11c5d08d5a208ab982ba6f1 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Wed, 8 May 2024 02:25:50 -0400 Subject: [PATCH] Lus window bump (#4131) --- libultraship | 2 +- soh/soh/OTRGlobals.cpp | 27 ++++++++++++++++++--------- soh/soh/SohMenuBar.cpp | 1 + soh/src/code/graph.c | 6 ++++-- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/libultraship b/libultraship index 97b11c960..61e304d21 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 97b11c9601178ff02e141b7398f5d50ddf91fdc4 +Subproject commit 61e304d21fe00b5b1de49998b16c510615ad7b44 diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 518e9c1f3..12f94e5fd 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -7,6 +7,7 @@ #include #include +#include "graphic/Fast3D/Fast3dWindow.h" #include #include #include @@ -1253,11 +1254,6 @@ extern "C" uint64_t GetUnixTimestamp() { return (uint64_t)millis.count(); } -// C->C++ Bridge -extern "C" void Graph_ProcessFrame(void (*run_one_game_iter)(void)) { - OTRGlobals::Instance->context->GetWindow()->MainLoop(run_one_game_iter); -} - extern bool ToggleAltAssetsAtEndOfFrame; extern "C" void Graph_StartFrame() { @@ -1381,6 +1377,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { static int time; int fps = target_fps; int original_fps = 60 / R_UPDATE_RATE; + auto wnd = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); if (target_fps == 20 || original_fps > target_fps) { fps = original_fps; @@ -1404,10 +1401,12 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { time -= fps; - OTRGlobals::Instance->context->GetWindow()->SetTargetFps(fps); + if (wnd != nullptr) { + wnd->SetTargetFps(fps); + } int threshold = CVarGetInteger(CVAR_SETTING("ExtraLatencyThreshold"), 80); - OTRGlobals::Instance->context->GetWindow()->SetMaximumFrameLatency(threshold > 0 && target_fps >= threshold ? 2 : 1); + wnd->SetMaximumFrameLatency(threshold > 0 && target_fps >= threshold ? 2 : 1); RunCommands(commands, mtx_replacements); @@ -1440,11 +1439,21 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { float divisor_num = 0.0f; extern "C" void OTRGetPixelDepthPrepare(float x, float y) { - OTRGlobals::Instance->context->GetWindow()->GetPixelDepthPrepare(x, y); + auto wnd = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + if (wnd == nullptr) { + return; + } + + wnd->GetPixelDepthPrepare(x, y); } extern "C" uint16_t OTRGetPixelDepth(float x, float y) { - return OTRGlobals::Instance->context->GetWindow()->GetPixelDepth(x, y); + auto wnd = std::dynamic_pointer_cast(Ship::Context::GetInstance()->GetWindow()); + if (wnd == nullptr) { + return 0; + } + + return wnd->GetPixelDepth(x, y); } extern "C" uint32_t ResourceMgr_GetNumGameVersions() { diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 35274e5ac..f60983c59 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -8,6 +8,7 @@ #include #include "UIWidgets.hpp" #include "include/z64audio.h" +#include "graphic/Fast3D/gfx_rendering_api.h" #include "OTRGlobals.h" #include "z64.h" #include "Enhancements/game-interactor/GameInteractor.h" diff --git a/soh/src/code/graph.c b/soh/src/code/graph.c index f5d620e72..db0e8bca3 100644 --- a/soh/src/code/graph.c +++ b/soh/src/code/graph.c @@ -10,6 +10,7 @@ #include "soh/Enhancements/debugger/valueViewer.h" #include "soh/Enhancements/gameconsole.h" #include "soh/OTRGlobals.h" +#include "libultraship/bridge.h" #define GFXPOOL_HEAD_MAGIC 0x1234 #define GFXPOOL_TAIL_MAGIC 0x5678 @@ -541,8 +542,9 @@ static void RunFrame() } void Graph_ThreadEntry(void* arg0) { - - Graph_ProcessFrame(RunFrame); + while (WindowIsRunning()) { + RunFrame(); + } } void* Graph_Alloc(GraphicsContext* gfxCtx, size_t size) {