Core::SetState: Avoid Global System Accessor

This commit is contained in:
mitaclaw committed 2024-05-03 21:04:44 -07:00
1 parent c23562b7b5
commit 0b04975c26
7 files changed
+20 -21

No files matched your search

+5 -6
View File
@@ -354,9 +354,9 @@ static void CPUSetInitialExecutionState(bool force_paused = false)
{
// The CPU starts in stepping state, and will wait until a new state is set before executing.
// SetState must be called on the host thread, so we defer it for later.
QueueHostJob([force_paused](Core::System&) {
QueueHostJob([force_paused](Core::System& system) {
bool paused = SConfig::GetInstance().bBootToPause || force_paused;
SetState(paused ? State::Paused : State::Running);
SetState(system, paused ? State::Paused : State::Running);
Host_UpdateDisasmDialog();
Host_UpdateMainFrame();
Host_Message(HostMessageID::WMUserCreate);
@@ -700,13 +700,12 @@ static void EmuThread(Core::System& system, std::unique_ptr<BootParameters> boot
// Set or get the running state
void SetState(State state, bool report_state_change)
void SetState(Core::System& system, State state, bool report_state_change)
{
// State cannot be controlled until the CPU Thread is operational
if (!IsRunningAndStarted())
return;
auto& system = Core::System::GetInstance();
switch (state)
{
case State::Paused:
@@ -1061,12 +1060,12 @@ void DoFrameStep(Core::System& system)
// if already paused, frame advance for 1 frame
s_stop_frame_step = false;
s_frame_step = true;
SetState(State::Running, false);
SetState(system, State::Running, false);
}
else if (!s_frame_step)
{
// if not paused yet, pause immediately instead
SetState(State::Paused);
SetState(system, State::Paused);
}
}
+1 -1
View File
@@ -143,7 +143,7 @@ bool IsHostThread();
bool WantsDeterminism();
// [NOT THREADSAFE] For use by Host only
void SetState(State state, bool report_state_change = true);
void SetState(Core::System& system, State state, bool report_state_change = true);
State GetState(Core::System& system);
void SaveScreenShot();