summaryrefslogtreecommitdiff
path: root/src/port
diff options
context:
space:
mode:
authorMegaMech <MegaMech@users.noreply.github.com>2025-05-15 15:25:18 -0600
committerGitHub <noreply@github.com>2025-05-15 15:25:18 -0600
commit7cc9894aa12175f10ad91174cff41ef1701df166 (patch)
tree8a24f90b69a06ed36d5aa8e53a003ae4f0f8aaa6 /src/port
parente7415ec072ee1cdc99a49db658062d4de0b3301c (diff)
Fix compile (#199)
* Fixes made so far * Fixes up until linking * Moved GetInterpreter() to a single function under the Engine.h * Updated shader files included with assets, added exception for Linux for including SDL2_net * Removed osSetTime stub(for now) * Adjustments to get it to compile + run * Decoupled GetInterpreter() from the GameEngine Class, corrected a invalid include in SpaghettiGui.cpp --------- Co-authored-by: sitton76 <58642183+sitton76@users.noreply.github.com>
Diffstat (limited to 'src/port')
-rw-r--r--src/port/Engine.cpp30
-rw-r--r--src/port/Engine.h6
-rw-r--r--src/port/SpaghettiGui.cpp2
-rw-r--r--src/port/ui/ImguiUI.cpp8
-rw-r--r--src/port/ui/ResolutionEditor.cpp12
5 files changed, 25 insertions, 33 deletions
diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp
index 440363efa..788af51ab 100644
--- a/src/port/Engine.cpp
+++ b/src/port/Engine.cpp
@@ -49,14 +49,11 @@ float gInterpolationStep = 0.0f;
#include "audio/GameAudio.h"
}
-std::weak_ptr<Fast::Interpreter> GameEngine::mInterpreter;
-
-std::shared_ptr<Fast::Interpreter> GameEngine::GetInterpreter() {
- auto intP = mInterpreter.lock();
- if (!intP) {
- assert(false && "Lost reference to Fast::Interpreter");
- }
- return intP;
+Fast::Interpreter* GetInterpreter() {
+ return static_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetInstance()->GetWindow())
+ ->GetInterpreterWeak()
+ .lock()
+ .get();
}
GameEngine* GameEngine::Instance;
@@ -543,7 +540,7 @@ extern "C" void GameEngine_UnloadSequence(const uint8_t seqId) {
}
extern "C" float GameEngine_GetAspectRatio() {
- auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
+ auto gfx_current_dimensions = GetInterpreter()->mCurDimensions;
return gfx_current_dimensions.aspect_ratio;
}
@@ -617,8 +614,7 @@ extern "C" void Timer_SetValue(int32_t* address, int32_t value) {
// }
extern "C" float OTRGetAspectRatio() {
- auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
- return gfx_current_dimensions.aspect_ratio;
+ return GetInterpreter()->mCurDimensions.aspect_ratio;
}
extern "C" float OTRGetDimensionFromLeftEdge(float v) {
@@ -661,22 +657,18 @@ extern "C" uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center) {
// Gets the width of the current render target area
extern "C" uint32_t OTRGetGameRenderWidth() {
- auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
- return gfx_current_dimensions.width;
+ return GetInterpreter()->mCurDimensions.width;
}
// Gets the height of the current render target area
extern "C" uint32_t OTRGetGameRenderHeight() {
- auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
- return gfx_current_dimensions.height;
+ return GetInterpreter()->mCurDimensions.height;
}
extern "C" uint32_t OTRGetGameViewportWidth() {
- auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
- return gfx_current_game_window_viewport.width;
+ return GetInterpreter()->mGameWindowViewport.width;
}
extern "C" uint32_t OTRGetGameViewportHeight() {
- auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
- return gfx_current_game_window_viewport.height;
+ return GetInterpreter()->mGameWindowViewport.height;
} \ No newline at end of file
diff --git a/src/port/Engine.h b/src/port/Engine.h
index 6136ff06a..bd6cf1ce0 100644
--- a/src/port/Engine.h
+++ b/src/port/Engine.h
@@ -25,6 +25,8 @@
#define NUM_AUDIO_CHANNELS 2
#define SAMPLES_PER_FRAME (SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 2)
+Fast::Interpreter* GetInterpreter();
+
struct CtlEntry;
struct AudioBankSample;
struct AudioSequenceData;
@@ -46,9 +48,6 @@ class GameEngine {
ImFont* fontMonoLarger;
ImFont* fontMonoLargest;
- static std::weak_ptr<Fast::Interpreter> mInterpreter;
- static std::shared_ptr<Fast::Interpreter> GetInterpreter();
-
std::unordered_map<std::string, uint8_t> bankMapTable;
GameEngine();
static bool GenAssetFile();
@@ -82,6 +81,7 @@ class GameEngine {
private:
ImFont* CreateFontWithSize(float size, std::string fontPath = "");
};
+
#endif
#ifdef __cplusplus
diff --git a/src/port/SpaghettiGui.cpp b/src/port/SpaghettiGui.cpp
index 1e0618ff2..3f096c5fa 100644
--- a/src/port/SpaghettiGui.cpp
+++ b/src/port/SpaghettiGui.cpp
@@ -27,7 +27,7 @@
#endif
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
-#include <graphic/Fast3D/gfx_direct3d11.h>
+#include <graphic/Fast3D/backends/gfx_direct3d11.h>
#include <imgui_impl_dx11.h>
#include <imgui_impl_win32.h>
diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp
index 3b1a33ed8..237e8d27f 100644
--- a/src/port/ui/ImguiUI.cpp
+++ b/src/port/ui/ImguiUI.cpp
@@ -50,10 +50,10 @@ void SetupGuiElements() {
mPortMenu = std::make_shared<PortMenu>("gOpenMenu", "Port Menu");
gui->SetMenu(mPortMenu);
- mMultiplayerWindow = gui->GetGuiWindow("Multiplayer");
- if (mMultiplayerWindow == nullptr) {
- SPDLOG_ERROR("Could not find multiplayer window");
- }
+ //mMultiplayerWindow = gui->GetGuiWindow("Multiplayer");
+ //if (mMultiplayerWindow == nullptr) {
+ // SPDLOG_ERROR("Could not find multiplayer window");
+ //}
mStatsWindow = gui->GetGuiWindow("Stats");
if (mStatsWindow == nullptr) {
diff --git a/src/port/ui/ResolutionEditor.cpp b/src/port/ui/ResolutionEditor.cpp
index 4bf44ee7e..ca47cb15e 100644
--- a/src/port/ui/ResolutionEditor.cpp
+++ b/src/port/ui/ResolutionEditor.cpp
@@ -96,12 +96,12 @@ void RegisterResolutionWidgets() {
// Resolution visualiser
mPortMenu->AddWidget(path, "Viewport dimensions: {} x {}", WIDGET_TEXT).PreFunc([](WidgetInfo& info) {
- auto captured_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
+ auto captured_window_viewport = GetInterpreter()->mGameWindowViewport;
info.name = fmt::format("Viewport dimensions: {} x {}", captured_window_viewport.width,
captured_window_viewport.height);
});
mPortMenu->AddWidget(path, "Internal resolution: {} x {}", WIDGET_TEXT).PreFunc([](WidgetInfo& info) {
- auto captured_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
+ auto captured_current_dimensions = GetInterpreter()->mCurDimensions;
info.name =
fmt::format("Internal resolution: {} x {}", captured_current_dimensions.width, captured_current_dimensions.height);
});
@@ -174,8 +174,8 @@ void RegisterResolutionWidgets() {
}
} else if (showHorizontalResField) { // Show calculated aspect ratio
if (item_aspectRatio) {
- auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
- auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
+ auto gfx_current_game_window_viewport = GetInterpreter()->mGameWindowViewport;
+ auto gfx_current_dimensions = GetInterpreter()->mCurDimensions;
ImGui::Dummy({ 0, 2 });
const float resolvedAspectRatio = (float)gfx_current_dimensions.width / gfx_current_dimensions.height;
ImGui::Text("Aspect ratio: %.2f:1", resolvedAspectRatio);
@@ -502,8 +502,8 @@ void UpdateResolutionVars() {
short integerScale_maximumBounds = 1; // can change when window is resized
// This is mostly just for UX purposes, as Fit Automatically logic is part of LUS.
- auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
- auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
+ auto gfx_current_game_window_viewport = GetInterpreter()->mGameWindowViewport;
+ auto gfx_current_dimensions = GetInterpreter()->mCurDimensions;
if (((float)gfx_current_game_window_viewport.width / gfx_current_game_window_viewport.height) >
((float)gfx_current_dimensions.width / gfx_current_dimensions.height)) {
// Scale to window height