Fixes made so far (#198)

* Fixed compile

* Moved GetInterpreter() to a single function under the Engine.h
This commit is contained in:
MegaMech
2025-05-15 10:30:39 -06:00
committed by GitHub
parent 0e35858050
commit e7415ec072
18 changed files with 76 additions and 36 deletions
+19 -3
View File
@@ -19,14 +19,14 @@
#include "resource/importers/UnkActorSpawnDataFactory.h"
#include "resource/importers/ArrayFactory.h"
#include "resource/importers/MinimapFactory.h"
#include <Fast3D/Fast3dWindow.h>
#include <Fonts.h>
#include "window/gui/resource/Font.h"
#include "window/gui/resource/FontFactory.h"
#include "SpaghettiGui.h"
#include <Fast3D/gfx_pc.h>
#include <Fast3D/gfx_rendering_api.h>
#include <graphic/Fast3D/Fast3dWindow.h>
#include <graphic/Fast3D/interpreter.h>
//#include <Fast3D/gfx_rendering_api.h>
#include <SDL2/SDL.h>
#include <utility>
@@ -49,6 +49,16 @@ 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;
}
GameEngine* GameEngine::Instance;
GameEngine::GameEngine() {
@@ -533,6 +543,7 @@ extern "C" void GameEngine_UnloadSequence(const uint8_t seqId) {
}
extern "C" float GameEngine_GetAspectRatio() {
auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
return gfx_current_dimensions.aspect_ratio;
}
@@ -606,6 +617,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;
}
@@ -649,18 +661,22 @@ 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;
}
// 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;
}
extern "C" uint32_t OTRGetGameViewportWidth() {
auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
return gfx_current_game_window_viewport.width;
}
extern "C" uint32_t OTRGetGameViewportHeight() {
auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
return gfx_current_game_window_viewport.height;
}