From 685b0bfd5e29dc7ced962c2dd2c4b49ed43efb06 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Mon, 15 Jul 2024 14:22:47 -0700 Subject: [PATCH] Fix missing logging on memory manager initalization. --- src/emulator.cpp | 17 +++++++++++------ src/emulator.h | 6 +++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/emulator.cpp b/src/emulator.cpp index 8a70044c..5e584eee 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -32,10 +32,7 @@ namespace Core { static constexpr s32 WindowWidth = 1280; static constexpr s32 WindowHeight = 720; -Emulator::Emulator() - : memory{Core::Memory::Instance()}, window{WindowWidth, WindowHeight, controller} { - g_window = &window; - +Emulator::Emulator() { // Read configuration file. const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir); Config::load(config_dir / "config.toml"); @@ -49,6 +46,14 @@ Emulator::Emulator() Common::Log::Initialize(); Common::Log::Start(); LOG_INFO(Loader, "Starting shadps4 emulator v{} ", Common::VERSION); + + // Defer until after logging is initialized. + memory = Core::Memory::Instance(); + controller = Common::Singleton::Instance(); + linker = Common::Singleton::Instance(); + window = std::make_unique(WindowWidth, WindowHeight, controller); + + g_window = window.get(); } Emulator::~Emulator() { @@ -134,8 +139,8 @@ void Emulator::Run(const std::filesystem::path& file) { // Begin main window loop until the application exits static constexpr std::chrono::milliseconds FlipPeriod{16}; - while (window.isOpen()) { - window.waitEvent(); + while (window->isOpen()) { + window->waitEvent(); Libraries::VideoOut::Flip(FlipPeriod); Libraries::VideoOut::Vblank(); FRAME_END; diff --git a/src/emulator.h b/src/emulator.h index b61ce95e..323170e3 100644 --- a/src/emulator.h +++ b/src/emulator.h @@ -31,9 +31,9 @@ private: void LoadSystemModules(const std::filesystem::path& file); Core::MemoryManager* memory; - Input::GameController* controller = Common::Singleton::Instance(); - Core::Linker* linker = Common::Singleton::Instance(); - Frontend::WindowSDL window; + Input::GameController* controller; + Core::Linker* linker; + std::unique_ptr window; }; } // namespace Core