HW: Pass System to functions.

This commit is contained in:
Admiral H. Curtiss 2023-03-12 17:38:48 +01:00
parent 137b9d1da1
commit 026b6a3e0f
No known key found for this signature in database
GPG Key ID: F051B4C4044F33FB
4 changed files with 14 additions and 13 deletions

View File

@ -531,13 +531,14 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
AudioCommon::InitSoundStream(system); AudioCommon::InitSoundStream(system);
Common::ScopeGuard audio_guard([&system] { AudioCommon::ShutdownSoundStream(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] { Common::ScopeGuard hw_guard{[&system] {
// We must set up this flag before executing HW::Shutdown() // We must set up this flag before executing HW::Shutdown()
s_hardware_initialized = false; s_hardware_initialized = false;
INFO_LOG_FMT(CONSOLE, "{}", StopMessage(false, "Shutting down HW")); INFO_LOG_FMT(CONSOLE, "{}", StopMessage(false, "Shutting down HW"));
HW::Shutdown(); HW::Shutdown(system);
INFO_LOG_FMT(CONSOLE, "{}", StopMessage(false, "HW shutdown")); INFO_LOG_FMT(CONSOLE, "{}", StopMessage(false, "HW shutdown"));
// Clear on screen messages that haven't expired // Clear on screen messages that haven't expired

View File

@ -31,9 +31,8 @@
namespace HW 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(); system.GetCoreTiming().Init();
SystemTimers::PreInit(); 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 should always be shut down regardless of bWii because it can be running in GC mode (MIOS).
IOS::HLE::Shutdown(); // Depends on Memory IOS::HLE::Shutdown(); // Depends on Memory
IOS::Shutdown(); IOS::Shutdown();
@ -86,9 +83,8 @@ void Shutdown()
system.GetCoreTiming().Shutdown(); system.GetCoreTiming().Shutdown();
} }
void DoState(PointerWrap& p) void DoState(Core::System& system, PointerWrap& p)
{ {
auto& system = Core::System::GetInstance();
system.GetMemory().DoState(p); system.GetMemory().DoState(p);
p.DoMarker("Memory"); p.DoMarker("Memory");
system.GetMemoryInterface().DoState(p); system.GetMemoryInterface().DoState(p);

View File

@ -5,10 +5,14 @@
class PointerWrap; class PointerWrap;
struct Sram; struct Sram;
namespace Core
{
class System;
}
namespace HW namespace HW
{ {
void Init(const Sram* override_sram); void Init(Core::System& system, const Sram* override_sram);
void Shutdown(); void Shutdown(Core::System& system);
void DoState(PointerWrap& p); void DoState(Core::System& system, PointerWrap& p);
} // namespace HW } // namespace HW

View File

@ -230,7 +230,7 @@ static void DoState(PointerWrap& p)
p.DoMarker("CoreTiming"); p.DoMarker("CoreTiming");
// HW needs to be restored before PowerPC because the data cache might need to be flushed. // 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"); p.DoMarker("HW");
PowerPC::DoState(p); PowerPC::DoState(p);