From 026b6a3e0f9a6a143207a54ccfbf9dd426ae37a4 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sun, 12 Mar 2023 17:38:48 +0100 Subject: [PATCH] HW: Pass System to functions. --- Source/Core/Core/Core.cpp | 5 +++-- Source/Core/Core/HW/HW.cpp | 10 +++------- Source/Core/Core/HW/HW.h | 10 +++++++--- Source/Core/Core/State.cpp | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index b1da318c65..5b1b9e6ebc 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -531,13 +531,14 @@ static void EmuThread(std::unique_ptr boot, WindowSystemInfo wsi AudioCommon::InitSoundStream(system); Common::ScopeGuard audio_guard([&system] { AudioCommon::ShutdownSoundStream(system); }); - HW::Init(NetPlay::IsNetPlayRunning() ? &(boot_session_data.GetNetplaySettings()->sram) : nullptr); + HW::Init(system, + NetPlay::IsNetPlayRunning() ? &(boot_session_data.GetNetplaySettings()->sram) : nullptr); Common::ScopeGuard hw_guard{[&system] { // We must set up this flag before executing HW::Shutdown() s_hardware_initialized = false; INFO_LOG_FMT(CONSOLE, "{}", StopMessage(false, "Shutting down HW")); - HW::Shutdown(); + HW::Shutdown(system); INFO_LOG_FMT(CONSOLE, "{}", StopMessage(false, "HW shutdown")); // Clear on screen messages that haven't expired diff --git a/Source/Core/Core/HW/HW.cpp b/Source/Core/Core/HW/HW.cpp index a8e8ae466f..b031d24cad 100644 --- a/Source/Core/Core/HW/HW.cpp +++ b/Source/Core/Core/HW/HW.cpp @@ -31,9 +31,8 @@ namespace HW { -void Init(const Sram* override_sram) +void Init(Core::System& system, const Sram* override_sram) { - auto& system = Core::System::GetInstance(); system.GetCoreTiming().Init(); SystemTimers::PreInit(); @@ -62,10 +61,8 @@ void Init(const Sram* override_sram) } } -void Shutdown() +void Shutdown(Core::System& system) { - auto& system = Core::System::GetInstance(); - // IOS should always be shut down regardless of bWii because it can be running in GC mode (MIOS). IOS::HLE::Shutdown(); // Depends on Memory IOS::Shutdown(); @@ -86,9 +83,8 @@ void Shutdown() system.GetCoreTiming().Shutdown(); } -void DoState(PointerWrap& p) +void DoState(Core::System& system, PointerWrap& p) { - auto& system = Core::System::GetInstance(); system.GetMemory().DoState(p); p.DoMarker("Memory"); system.GetMemoryInterface().DoState(p); diff --git a/Source/Core/Core/HW/HW.h b/Source/Core/Core/HW/HW.h index 1122ca5e2d..d70ad72fa6 100644 --- a/Source/Core/Core/HW/HW.h +++ b/Source/Core/Core/HW/HW.h @@ -5,10 +5,14 @@ class PointerWrap; struct Sram; +namespace Core +{ +class System; +} namespace HW { -void Init(const Sram* override_sram); -void Shutdown(); -void DoState(PointerWrap& p); +void Init(Core::System& system, const Sram* override_sram); +void Shutdown(Core::System& system); +void DoState(Core::System& system, PointerWrap& p); } // namespace HW diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp index 8eb59fe938..fa26b3339a 100644 --- a/Source/Core/Core/State.cpp +++ b/Source/Core/Core/State.cpp @@ -230,7 +230,7 @@ static void DoState(PointerWrap& p) p.DoMarker("CoreTiming"); // HW needs to be restored before PowerPC because the data cache might need to be flushed. - HW::DoState(p); + HW::DoState(system, p); p.DoMarker("HW"); PowerPC::DoState(p);