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);
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

View File

@ -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);

View File

@ -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

View File

@ -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);