Merge pull request #4828 from lioncash/state

Core: Convert State enum into an enum class
This commit is contained in:
Matthew Parlane 2017-02-06 17:38:46 +13:00 committed by GitHub
commit d022913fb3
25 changed files with 103 additions and 103 deletions

View File

@ -471,13 +471,13 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_UnPauseEmula
jobject obj) jobject obj)
{ {
std::lock_guard<std::mutex> guard(s_host_identity_lock); std::lock_guard<std::mutex> guard(s_host_identity_lock);
Core::SetState(Core::CORE_RUN); Core::SetState(Core::State::Running);
} }
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_PauseEmulation(JNIEnv* env, JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_PauseEmulation(JNIEnv* env,
jobject obj) jobject obj)
{ {
std::lock_guard<std::mutex> guard(s_host_identity_lock); std::lock_guard<std::mutex> guard(s_host_identity_lock);
Core::SetState(Core::CORE_PAUSE); Core::SetState(Core::State::Paused);
} }
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulation(JNIEnv* env, JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_StopEmulation(JNIEnv* env,
@ -695,10 +695,10 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling
jboolean enable) jboolean enable)
{ {
std::lock_guard<std::mutex> guard(s_host_identity_lock); std::lock_guard<std::mutex> guard(s_host_identity_lock);
Core::SetState(Core::CORE_PAUSE); Core::SetState(Core::State::Paused);
JitInterface::ClearCache(); JitInterface::ClearCache();
Profiler::g_ProfileBlocks = enable; Profiler::g_ProfileBlocks = enable;
Core::SetState(Core::CORE_RUN); Core::SetState(Core::State::Running);
} }
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfileResults(JNIEnv* env, JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfileResults(JNIEnv* env,

View File

@ -188,7 +188,7 @@ void DisplayMessage(const std::string& message, int time_in_ms)
bool IsRunning() bool IsRunning()
{ {
return (GetState() != CORE_UNINITIALIZED || s_hardware_initialized) && !s_is_stopping; return (GetState() != State::Uninitialized || s_hardware_initialized) && !s_is_stopping;
} }
bool IsRunningAndStarted() bool IsRunningAndStarted()
@ -263,7 +263,7 @@ bool Init()
// Called from GUI thread // Called from GUI thread
void Stop() // - Hammertime! void Stop() // - Hammertime!
{ {
if (GetState() == CORE_STOPPING) if (GetState() == State::Stopping)
return; return;
const SConfig& _CoreParameter = SConfig::GetInstance(); const SConfig& _CoreParameter = SConfig::GetInstance();
@ -327,7 +327,7 @@ void UndeclareAsCPUThread()
static void CPUSetInitialExecutionState() static void CPUSetInitialExecutionState()
{ {
QueueHostJob([] { QueueHostJob([] {
SetState(SConfig::GetInstance().bBootToPause ? CORE_PAUSE : CORE_RUN); SetState(SConfig::GetInstance().bBootToPause ? State::Paused : State::Running);
Host_UpdateMainFrame(); Host_UpdateMainFrame();
}); });
} }
@ -363,7 +363,7 @@ static void CpuThread()
QueueHostJob([] { QueueHostJob([] {
// Recheck in case Movie cleared it since. // Recheck in case Movie cleared it since.
if (!s_state_filename.empty()) if (!s_state_filename.empty())
State::LoadAs(s_state_filename); ::State::LoadAs(s_state_filename);
}); });
} }
@ -678,7 +678,7 @@ void EmuThread()
// Set or get the running state // Set or get the running state
void SetState(EState state) void SetState(State state)
{ {
// State cannot be controlled until the CPU Thread is operational // State cannot be controlled until the CPU Thread is operational
if (!IsRunningAndStarted()) if (!IsRunningAndStarted())
@ -686,8 +686,8 @@ void SetState(EState state)
switch (state) switch (state)
{ {
case CORE_PAUSE: case State::Paused:
// NOTE: GetState() will return CORE_PAUSE immediately, even before anything has // NOTE: GetState() will return State::Paused immediately, even before anything has
// stopped (including the CPU). // stopped (including the CPU).
CPU::EnableStepping(true); // Break CPU::EnableStepping(true); // Break
Wiimote::Pause(); Wiimote::Pause();
@ -695,7 +695,7 @@ void SetState(EState state)
GCAdapter::ResetRumble(); GCAdapter::ResetRumble();
#endif #endif
break; break;
case CORE_RUN: case State::Running:
CPU::EnableStepping(false); CPU::EnableStepping(false);
Wiimote::Resume(); Wiimote::Resume();
break; break;
@ -705,20 +705,20 @@ void SetState(EState state)
} }
} }
EState GetState() State GetState()
{ {
if (s_is_stopping) if (s_is_stopping)
return CORE_STOPPING; return State::Stopping;
if (s_hardware_initialized) if (s_hardware_initialized)
{ {
if (CPU::IsStepping()) if (CPU::IsStepping())
return CORE_PAUSE; return State::Paused;
return CORE_RUN; return State::Running;
} }
return CORE_UNINITIALIZED; return State::Uninitialized;
} }
static std::string GenerateScreenshotFolderPath() static std::string GenerateScreenshotFolderPath()
@ -753,28 +753,28 @@ static std::string GenerateScreenshotName()
void SaveScreenShot() void SaveScreenShot()
{ {
const bool bPaused = (GetState() == CORE_PAUSE); const bool bPaused = GetState() == State::Paused;
SetState(CORE_PAUSE); SetState(State::Paused);
Renderer::SetScreenshot(GenerateScreenshotName()); Renderer::SetScreenshot(GenerateScreenshotName());
if (!bPaused) if (!bPaused)
SetState(CORE_RUN); SetState(State::Running);
} }
void SaveScreenShot(const std::string& name) void SaveScreenShot(const std::string& name)
{ {
const bool bPaused = (GetState() == CORE_PAUSE); const bool bPaused = GetState() == State::Paused;
SetState(CORE_PAUSE); SetState(State::Paused);
std::string filePath = GenerateScreenshotFolderPath() + name + ".png"; std::string filePath = GenerateScreenshotFolderPath() + name + ".png";
Renderer::SetScreenshot(filePath); Renderer::SetScreenshot(filePath);
if (!bPaused) if (!bPaused)
SetState(CORE_RUN); SetState(State::Running);
} }
void RequestRefreshInfo() void RequestRefreshInfo()
@ -1015,7 +1015,7 @@ void HostDispatchJobs()
// NOTE: Memory ordering is important. The booting flag needs to be // NOTE: Memory ordering is important. The booting flag needs to be
// checked first because the state transition is: // checked first because the state transition is:
// CORE_UNINITIALIZED: s_is_booting -> s_hardware_initialized // Core::State::Uninitialized: s_is_booting -> s_hardware_initialized
// We need to check variables in the same order as the state // We need to check variables in the same order as the state
// transition, otherwise we race and get transient failures. // transition, otherwise we race and get transient failures.
if (!job.run_after_stop && !s_is_booting.IsSet() && !IsRunning()) if (!job.run_after_stop && !s_is_booting.IsSet() && !IsRunning())

View File

@ -28,12 +28,12 @@ void SetIsThrottlerTempDisabled(bool disable);
void Callback_VideoCopiedToXFB(bool video_update); void Callback_VideoCopiedToXFB(bool video_update);
enum EState enum State
{ {
CORE_UNINITIALIZED, Uninitialized,
CORE_PAUSE, Paused,
CORE_RUN, Running,
CORE_STOPPING Stopping
}; };
bool Init(); bool Init();
@ -52,8 +52,8 @@ bool IsCPUThread(); // this tells us whether we are the CPU thread
bool IsGPUThread(); bool IsGPUThread();
// [NOT THREADSAFE] For use by Host only // [NOT THREADSAFE] For use by Host only
void SetState(EState state); void SetState(State state);
EState GetState(); State GetState();
void SaveScreenShot(); void SaveScreenShot();
void SaveScreenShot(const std::string& name); void SaveScreenShot(const std::string& name);

View File

@ -21,7 +21,7 @@ std::string PPCDebugInterface::Disassemble(unsigned int address)
if (!IsAlive()) if (!IsAlive())
return ""; return "";
if (Core::GetState() == Core::CORE_PAUSE) if (Core::GetState() == Core::State::Paused)
{ {
if (!PowerPC::HostIsRAMAddress(address)) if (!PowerPC::HostIsRAMAddress(address))
{ {

View File

@ -67,7 +67,7 @@ unsigned int DSPDebugInterface::ReadInstruction(unsigned int address)
bool DSPDebugInterface::IsAlive() bool DSPDebugInterface::IsAlive()
{ {
return true; // Core::GetState() != Core::CORE_UNINITIALIZED; return true;
} }
bool DSPDebugInterface::IsBreakpoint(unsigned int address) bool DSPDebugInterface::IsBreakpoint(unsigned int address)

View File

@ -281,17 +281,17 @@ void SetPolledDevice()
// NOTE: Host Thread // NOTE: Host Thread
void DoFrameStep() void DoFrameStep()
{ {
if (Core::GetState() == Core::CORE_PAUSE) if (Core::GetState() == Core::State::Paused)
{ {
// if already paused, frame advance for 1 frame // if already paused, frame advance for 1 frame
s_bFrameStep = true; s_bFrameStep = true;
Core::RequestRefreshInfo(); Core::RequestRefreshInfo();
Core::SetState(Core::CORE_RUN); Core::SetState(Core::State::Running);
} }
else if (!s_bFrameStep) else if (!s_bFrameStep)
{ {
// if not paused yet, pause immediately instead // if not paused yet, pause immediately instead
Core::SetState(Core::CORE_PAUSE); Core::SetState(Core::State::Paused);
} }
} }

View File

@ -544,7 +544,7 @@ void JitArm64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBlock*
{ {
if (em_address == 0) if (em_address == 0)
{ {
Core::SetState(Core::CORE_PAUSE); Core::SetState(Core::State::Paused);
WARN_LOG(DYNA_REC, "ERROR: Compiling at 0. LR=%08x CTR=%08x", LR, CTR); WARN_LOG(DYNA_REC, "ERROR: Compiling at 0. LR=%08x CTR=%08x", LR, CTR);
} }

View File

@ -135,9 +135,9 @@ void GetProfileResults(ProfileStats* prof_stats)
prof_stats->timecost_sum = 0; prof_stats->timecost_sum = 0;
prof_stats->block_stats.clear(); prof_stats->block_stats.clear();
Core::EState old_state = Core::GetState(); Core::State old_state = Core::GetState();
if (old_state == Core::CORE_RUN) if (old_state == Core::State::Running)
Core::SetState(Core::CORE_PAUSE); Core::SetState(Core::State::Paused);
QueryPerformanceFrequency((LARGE_INTEGER*)&prof_stats->countsPerSec); QueryPerformanceFrequency((LARGE_INTEGER*)&prof_stats->countsPerSec);
g_jit->GetBlockCache()->RunOnBlocks([&prof_stats](const JitBlock& block) { g_jit->GetBlockCache()->RunOnBlocks([&prof_stats](const JitBlock& block) {
@ -153,8 +153,8 @@ void GetProfileResults(ProfileStats* prof_stats)
}); });
sort(prof_stats->block_stats.begin(), prof_stats->block_stats.end()); sort(prof_stats->block_stats.begin(), prof_stats->block_stats.end());
if (old_state == Core::CORE_RUN) if (old_state == Core::State::Running)
Core::SetState(Core::CORE_RUN); Core::SetState(Core::State::Running);
} }
int GetHostCode(u32* address, const u8** code, u32* code_size) int GetHostCode(u32* address, const u8** code, u32* code_size)

View File

@ -140,7 +140,7 @@ void DoState(PointerWrap& p);
void ScheduleInvalidateCacheThreadSafe(u32 address); void ScheduleInvalidateCacheThreadSafe(u32 address);
CoreMode GetMode(); CoreMode GetMode();
// [NOT THREADSAFE] CPU Thread or CPU::PauseAndLock or CORE_UNINITIALIZED // [NOT THREADSAFE] CPU Thread or CPU::PauseAndLock or Core::State::Uninitialized
void SetMode(CoreMode _coreType); void SetMode(CoreMode _coreType);
const char* GetCPUName(); const char* GetCPUName();

View File

@ -110,7 +110,7 @@ void CheckFile(const std::string& file, u64 size)
void FindFilename(u64 offset) void FindFilename(u64 offset)
{ {
// Don't do anything if a game is not running // Don't do anything if a game is not running
if (Core::GetState() != Core::CORE_RUN) if (Core::GetState() != Core::State::Running)
return; return;
// Or if the log is unselected // Or if the log is unselected

View File

@ -150,9 +150,9 @@ void MainWindow::Play()
// Otherwise, play the default game. // Otherwise, play the default game.
// Otherwise, play the last played game, if there is one. // Otherwise, play the last played game, if there is one.
// Otherwise, prompt for a new game. // Otherwise, prompt for a new game.
if (Core::GetState() == Core::CORE_PAUSE) if (Core::GetState() == Core::State::Paused)
{ {
Core::SetState(Core::CORE_RUN); Core::SetState(Core::State::Running);
emit EmulationStarted(); emit EmulationStarted();
} }
else else
@ -183,7 +183,7 @@ void MainWindow::Play()
void MainWindow::Pause() void MainWindow::Pause()
{ {
Core::SetState(Core::CORE_PAUSE); Core::SetState(Core::State::Paused);
emit EmulationPaused(); emit EmulationPaused();
} }
@ -251,7 +251,7 @@ void MainWindow::ScreenShot()
void MainWindow::StartGame(const QString& path) void MainWindow::StartGame(const QString& path)
{ {
// If we're running, only start a new game once we've stopped the last. // If we're running, only start a new game once we've stopped the last.
if (Core::GetState() != Core::CORE_UNINITIALIZED) if (Core::GetState() != Core::State::Uninitialized)
{ {
if (!Stop()) if (!Stop())
return; return;

View File

@ -234,7 +234,7 @@ void CheatSearchTab::OnListViewItemSelected(wxListEvent&)
void CheatSearchTab::OnTimerUpdate(wxTimerEvent&) void CheatSearchTab::OnTimerUpdate(wxTimerEvent&)
{ {
if (Core::GetState() != Core::CORE_RUN) if (Core::GetState() != Core::State::Running)
return; return;
// Only update the currently visible list rows. // Only update the currently visible list rows.

View File

@ -88,7 +88,7 @@ void ControllerConfigDiag::UpdateUI()
m_wiimote_sources[i]->Select(g_wiimote_sources[i]); m_wiimote_sources[i]->Select(g_wiimote_sources[i]);
const bool wii_game_started = const bool wii_game_started =
SConfig::GetInstance().bWii || Core::GetState() == Core::CORE_UNINITIALIZED; SConfig::GetInstance().bWii || Core::GetState() == Core::State::Uninitialized;
if (Core::g_want_determinism || !wii_game_started) if (Core::g_want_determinism || !wii_game_started)
m_wiimote_sources[i]->Disable(); m_wiimote_sources[i]->Disable();
if (!wii_game_started || if (!wii_game_started ||

View File

@ -457,7 +457,7 @@ void CCodeWindow::UpdateLists()
void CCodeWindow::UpdateCallstack() void CCodeWindow::UpdateCallstack()
{ {
if (Core::GetState() == Core::CORE_STOPPING) if (Core::GetState() == Core::State::Stopping)
return; return;
callstack->Clear(); callstack->Clear();

View File

@ -123,17 +123,17 @@ void CCodeWindow::OnProfilerMenu(wxCommandEvent& event)
switch (event.GetId()) switch (event.GetId())
{ {
case IDM_PROFILE_BLOCKS: case IDM_PROFILE_BLOCKS:
Core::SetState(Core::CORE_PAUSE); Core::SetState(Core::State::Paused);
if (g_jit != nullptr) if (g_jit != nullptr)
g_jit->ClearCache(); g_jit->ClearCache();
Profiler::g_ProfileBlocks = GetParentMenuBar()->IsChecked(IDM_PROFILE_BLOCKS); Profiler::g_ProfileBlocks = GetParentMenuBar()->IsChecked(IDM_PROFILE_BLOCKS);
Core::SetState(Core::CORE_RUN); Core::SetState(Core::State::Running);
break; break;
case IDM_WRITE_PROFILE: case IDM_WRITE_PROFILE:
if (Core::GetState() == Core::CORE_RUN) if (Core::GetState() == Core::State::Running)
Core::SetState(Core::CORE_PAUSE); Core::SetState(Core::State::Paused);
if (Core::GetState() == Core::CORE_PAUSE && PowerPC::GetMode() == PowerPC::CoreMode::JIT) if (Core::GetState() == Core::State::Paused && PowerPC::GetMode() == PowerPC::CoreMode::JIT)
{ {
if (g_jit != nullptr) if (g_jit != nullptr)
{ {

View File

@ -164,7 +164,7 @@ WXLRESULT CRenderFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPa
{ {
case SC_SCREENSAVE: case SC_SCREENSAVE:
case SC_MONITORPOWER: case SC_MONITORPOWER:
if (Core::GetState() == Core::CORE_RUN && SConfig::GetInstance().bDisableScreenSaver) if (Core::GetState() == Core::State::Running && SConfig::GetInstance().bDisableScreenSaver)
break; break;
default: default:
return wxFrame::MSWWindowProc(nMsg, wParam, lParam); return wxFrame::MSWWindowProc(nMsg, wParam, lParam);
@ -180,7 +180,7 @@ WXLRESULT CRenderFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPa
case WM_USER_SETCURSOR: case WM_USER_SETCURSOR:
if (SConfig::GetInstance().bHideCursor && main_frame->RendererHasFocus() && if (SConfig::GetInstance().bHideCursor && main_frame->RendererHasFocus() &&
Core::GetState() == Core::CORE_RUN) Core::GetState() == Core::State::Running)
SetCursor(wxCURSOR_BLANK); SetCursor(wxCURSOR_BLANK);
else else
SetCursor(wxNullCursor); SetCursor(wxNullCursor);
@ -501,7 +501,7 @@ bool CFrame::RendererIsFullscreen()
{ {
bool fullscreen = false; bool fullscreen = false;
if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE) if (Core::GetState() == Core::State::Running || Core::GetState() == Core::State::Paused)
{ {
fullscreen = m_RenderFrame->IsFullScreen(); fullscreen = m_RenderFrame->IsFullScreen();
} }
@ -519,7 +519,7 @@ void CFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
void CFrame::OnActive(wxActivateEvent& event) void CFrame::OnActive(wxActivateEvent& event)
{ {
m_bRendererHasFocus = (event.GetActive() && event.GetEventObject() == m_RenderFrame); m_bRendererHasFocus = (event.GetActive() && event.GetEventObject() == m_RenderFrame);
if (Core::GetState() == Core::CORE_RUN || Core::GetState() == Core::CORE_PAUSE) if (Core::GetState() == Core::State::Running || Core::GetState() == Core::State::Paused)
{ {
if (m_bRendererHasFocus) if (m_bRendererHasFocus)
{ {
@ -528,15 +528,15 @@ void CFrame::OnActive(wxActivateEvent& event)
else if (RendererIsFullscreen() && g_ActiveConfig.ExclusiveFullscreenEnabled()) else if (RendererIsFullscreen() && g_ActiveConfig.ExclusiveFullscreenEnabled())
DoExclusiveFullscreen(true); // Regain exclusive mode DoExclusiveFullscreen(true); // Regain exclusive mode
if (SConfig::GetInstance().m_PauseOnFocusLost && Core::GetState() == Core::CORE_PAUSE) if (SConfig::GetInstance().m_PauseOnFocusLost && Core::GetState() == Core::State::Paused)
DoPause(); DoPause();
if (SConfig::GetInstance().bHideCursor && Core::GetState() == Core::CORE_RUN) if (SConfig::GetInstance().bHideCursor && Core::GetState() == Core::State::Running)
m_RenderParent->SetCursor(wxCURSOR_BLANK); m_RenderParent->SetCursor(wxCURSOR_BLANK);
} }
else else
{ {
if (SConfig::GetInstance().m_PauseOnFocusLost && Core::GetState() == Core::CORE_RUN) if (SConfig::GetInstance().m_PauseOnFocusLost && Core::GetState() == Core::State::Running)
DoPause(); DoPause();
if (SConfig::GetInstance().bHideCursor) if (SConfig::GetInstance().bHideCursor)
@ -550,7 +550,7 @@ void CFrame::OnClose(wxCloseEvent& event)
{ {
// Before closing the window we need to shut down the emulation core. // Before closing the window we need to shut down the emulation core.
// We'll try to close this window again once that is done. // We'll try to close this window again once that is done.
if (Core::GetState() != Core::CORE_UNINITIALIZED) if (Core::GetState() != Core::State::Uninitialized)
{ {
DoStop(); DoStop();
if (event.CanVeto()) if (event.CanVeto())
@ -618,7 +618,7 @@ void CFrame::OnResize(wxSizeEvent& event)
if (!IsMaximized() && !IsIconized() && if (!IsMaximized() && !IsIconized() &&
!(SConfig::GetInstance().bRenderToMain && RendererIsFullscreen()) && !(SConfig::GetInstance().bRenderToMain && RendererIsFullscreen()) &&
!(Core::GetState() != Core::CORE_UNINITIALIZED && SConfig::GetInstance().bRenderToMain && !(Core::GetState() != Core::State::Uninitialized && SConfig::GetInstance().bRenderToMain &&
SConfig::GetInstance().bRenderWindowAutoSize)) SConfig::GetInstance().bRenderWindowAutoSize))
{ {
SConfig::GetInstance().iWidth = GetSize().GetWidth(); SConfig::GetInstance().iWidth = GetSize().GetWidth();
@ -678,7 +678,7 @@ void CFrame::OnHostMessage(wxCommandEvent& event)
switch (event.GetId()) switch (event.GetId())
{ {
case IDM_UPDATE_DISASM_DIALOG: // For breakpoints causing pausing case IDM_UPDATE_DISASM_DIALOG: // For breakpoints causing pausing
if (!g_pCodeWindow || Core::GetState() != Core::CORE_PAUSE) if (!g_pCodeWindow || Core::GetState() != Core::State::Paused)
return; return;
// fallthrough // fallthrough
@ -1202,10 +1202,10 @@ void CFrame::PollHotkeys(wxTimerEvent& event)
if (!HotkeyManagerEmu::IsEnabled()) if (!HotkeyManagerEmu::IsEnabled())
return; return;
if (Core::GetState() == Core::CORE_UNINITIALIZED || Core::GetState() == Core::CORE_PAUSE) if (Core::GetState() == Core::State::Uninitialized || Core::GetState() == Core::State::Paused)
g_controller_interface.UpdateInput(); g_controller_interface.UpdateInput();
if (Core::GetState() != Core::CORE_STOPPING) if (Core::GetState() != Core::State::Stopping)
{ {
HotkeyManagerEmu::GetStatus(); HotkeyManagerEmu::GetStatus();
ParseHotkeys(); ParseHotkeys();

View File

@ -275,7 +275,7 @@ void CFrame::BootGame(const std::string& filename)
std::string bootfile = filename; std::string bootfile = filename;
SConfig& StartUp = SConfig::GetInstance(); SConfig& StartUp = SConfig::GetInstance();
if (Core::GetState() != Core::CORE_UNINITIALIZED) if (Core::GetState() != Core::State::Uninitialized)
return; return;
// Start filename if non empty. // Start filename if non empty.
@ -322,7 +322,7 @@ void CFrame::BootGame(const std::string& filename)
// Open file to boot // Open file to boot
void CFrame::OnOpen(wxCommandEvent& WXUNUSED(event)) void CFrame::OnOpen(wxCommandEvent& WXUNUSED(event))
{ {
if (Core::GetState() == Core::CORE_UNINITIALIZED) if (Core::GetState() == Core::State::Uninitialized)
DoOpen(true); DoOpen(true);
} }
@ -431,11 +431,11 @@ void CFrame::OnShowRTCDisplay(wxCommandEvent& WXUNUSED(event))
void CFrame::OnFrameStep(wxCommandEvent& event) void CFrame::OnFrameStep(wxCommandEvent& event)
{ {
bool wasPaused = (Core::GetState() == Core::CORE_PAUSE); bool wasPaused = Core::GetState() == Core::State::Paused;
Movie::DoFrameStep(); Movie::DoFrameStep();
bool isPaused = (Core::GetState() == Core::CORE_PAUSE); bool isPaused = Core::GetState() == Core::State::Paused;
if (isPaused && !wasPaused) // don't update on unpause, otherwise the status would be wrong when if (isPaused && !wasPaused) // don't update on unpause, otherwise the status would be wrong when
// pausing next frame // pausing next frame
UpdateGUI(); UpdateGUI();
@ -534,7 +534,7 @@ void CFrame::OnRenderParentClose(wxCloseEvent& event)
{ {
// Before closing the window we need to shut down the emulation core. // Before closing the window we need to shut down the emulation core.
// We'll try to close this window again once that is done. // We'll try to close this window again once that is done.
if (Core::GetState() != Core::CORE_UNINITIALIZED) if (Core::GetState() != Core::State::Uninitialized)
{ {
DoStop(); DoStop();
if (event.CanVeto()) if (event.CanVeto())
@ -549,7 +549,7 @@ void CFrame::OnRenderParentClose(wxCloseEvent& event)
void CFrame::OnRenderParentMove(wxMoveEvent& event) void CFrame::OnRenderParentMove(wxMoveEvent& event)
{ {
if (Core::GetState() != Core::CORE_UNINITIALIZED && !RendererIsFullscreen() && if (Core::GetState() != Core::State::Uninitialized && !RendererIsFullscreen() &&
!m_RenderFrame->IsMaximized() && !m_RenderFrame->IsIconized()) !m_RenderFrame->IsMaximized() && !m_RenderFrame->IsIconized())
{ {
SConfig::GetInstance().iRenderWindowXPos = m_RenderFrame->GetPosition().x; SConfig::GetInstance().iRenderWindowXPos = m_RenderFrame->GetPosition().x;
@ -560,7 +560,7 @@ void CFrame::OnRenderParentMove(wxMoveEvent& event)
void CFrame::OnRenderParentResize(wxSizeEvent& event) void CFrame::OnRenderParentResize(wxSizeEvent& event)
{ {
if (Core::GetState() != Core::CORE_UNINITIALIZED) if (Core::GetState() != Core::State::Uninitialized)
{ {
int width, height; int width, height;
if (!SConfig::GetInstance().bRenderToMain && !RendererIsFullscreen() && if (!SConfig::GetInstance().bRenderToMain && !RendererIsFullscreen() &&
@ -751,16 +751,16 @@ void CFrame::OnScreenshot(wxCommandEvent& WXUNUSED(event))
// Pause the emulation // Pause the emulation
void CFrame::DoPause() void CFrame::DoPause()
{ {
if (Core::GetState() == Core::CORE_RUN) if (Core::GetState() == Core::State::Running)
{ {
Core::SetState(Core::CORE_PAUSE); Core::SetState(Core::State::Paused);
if (SConfig::GetInstance().bHideCursor) if (SConfig::GetInstance().bHideCursor)
m_RenderParent->SetCursor(wxNullCursor); m_RenderParent->SetCursor(wxNullCursor);
Core::UpdateTitle(); Core::UpdateTitle();
} }
else else
{ {
Core::SetState(Core::CORE_RUN); Core::SetState(Core::State::Running);
if (SConfig::GetInstance().bHideCursor && RendererHasFocus()) if (SConfig::GetInstance().bHideCursor && RendererHasFocus())
m_RenderParent->SetCursor(wxCURSOR_BLANK); m_RenderParent->SetCursor(wxCURSOR_BLANK);
} }
@ -779,7 +779,7 @@ void CFrame::DoStop()
m_confirmStop = true; m_confirmStop = true;
m_bGameLoading = false; m_bGameLoading = false;
if (Core::GetState() != Core::CORE_UNINITIALIZED || m_RenderParent != nullptr) if (Core::GetState() != Core::State::Uninitialized || m_RenderParent != nullptr)
{ {
#if defined __WXGTK__ #if defined __WXGTK__
wxMutexGuiLeave(); wxMutexGuiLeave();
@ -793,7 +793,7 @@ void CFrame::DoStop()
DoFullscreen(false); DoFullscreen(false);
// Pause the state during confirmation and restore it afterwards // Pause the state during confirmation and restore it afterwards
Core::EState state = Core::GetState(); Core::State state = Core::GetState();
// Do not pause if netplay is running as CPU thread might be blocked // Do not pause if netplay is running as CPU thread might be blocked
// waiting on inputs // waiting on inputs
@ -801,7 +801,7 @@ void CFrame::DoStop()
if (should_pause) if (should_pause)
{ {
Core::SetState(Core::CORE_PAUSE); Core::SetState(Core::State::Paused);
} }
wxMessageDialog m_StopDlg( wxMessageDialog m_StopDlg(
@ -866,7 +866,7 @@ bool CFrame::TriggerSTMPowerEvent()
Core::DisplayMessage("Shutting down", 30000); Core::DisplayMessage("Shutting down", 30000);
// Unpause because gracefully shutting down needs the game to actually request a shutdown // Unpause because gracefully shutting down needs the game to actually request a shutdown
if (Core::GetState() == Core::CORE_PAUSE) if (Core::GetState() == Core::State::Paused)
DoPause(); DoPause();
ProcessorInterface::PowerButton_Tap(); ProcessorInterface::PowerButton_Tap();
m_confirmStop = false; m_confirmStop = false;
@ -943,7 +943,7 @@ void CFrame::OnStopped()
void CFrame::DoRecordingSave() void CFrame::DoRecordingSave()
{ {
bool paused = (Core::GetState() == Core::CORE_PAUSE); bool paused = Core::GetState() == Core::State::Paused;
if (!paused) if (!paused)
DoPause(); DoPause();
@ -1007,9 +1007,9 @@ void CFrame::OnConfigHotkey(wxCommandEvent& WXUNUSED(event))
// check if game is running // check if game is running
bool game_running = false; bool game_running = false;
if (Core::GetState() == Core::CORE_RUN) if (Core::GetState() == Core::State::Running)
{ {
Core::SetState(Core::CORE_PAUSE); Core::SetState(Core::State::Paused);
game_running = true; game_running = true;
} }
@ -1029,7 +1029,7 @@ void CFrame::OnConfigHotkey(wxCommandEvent& WXUNUSED(event))
// if game isn't running // if game isn't running
if (game_running) if (game_running)
{ {
Core::SetState(Core::CORE_RUN); Core::SetState(Core::State::Running);
} }
// Update the GUI in case menu accelerators were changed // Update the GUI in case menu accelerators were changed
@ -1383,9 +1383,9 @@ void CFrame::UpdateGUI()
{ {
// Save status // Save status
bool Initialized = Core::IsRunning(); bool Initialized = Core::IsRunning();
bool Running = Core::GetState() == Core::CORE_RUN; bool Running = Core::GetState() == Core::State::Running;
bool Paused = Core::GetState() == Core::CORE_PAUSE; bool Paused = Core::GetState() == Core::State::Paused;
bool Stopping = Core::GetState() == Core::CORE_STOPPING; bool Stopping = Core::GetState() == Core::State::Stopping;
GetToolBar()->Refresh(false); GetToolBar()->Refresh(false);
GetMenuBar()->Refresh(false); GetMenuBar()->Refresh(false);

View File

@ -291,7 +291,7 @@ void CGameListCtrl::ReloadList()
{ {
int scrollPos = wxWindow::GetScrollPos(wxVERTICAL); int scrollPos = wxWindow::GetScrollPos(wxVERTICAL);
// Don't let the user refresh it while a game is running // Don't let the user refresh it while a game is running
if (Core::GetState() != Core::CORE_UNINITIALIZED) if (Core::GetState() != Core::State::Uninitialized)
return; return;
ScanForISOs(); ScanForISOs();

View File

@ -512,7 +512,7 @@ void MainMenuBar::RefreshPlayMenuLabel() const
{ {
auto* const item = FindItem(IDM_PLAY); auto* const item = FindItem(IDM_PLAY);
if (Core::GetState() == Core::CORE_RUN) if (Core::GetState() == Core::State::Running)
item->SetItemLabel(_("&Pause")); item->SetItemLabel(_("&Pause"));
else else
item->SetItemLabel(_("&Play")); item->SetItemLabel(_("&Play"));

View File

@ -261,17 +261,17 @@ class PlatformX11 : public Platform
key = XLookupKeysym((XKeyEvent*)&event, 0); key = XLookupKeysym((XKeyEvent*)&event, 0);
if (key == XK_Escape) if (key == XK_Escape)
{ {
if (Core::GetState() == Core::CORE_RUN) if (Core::GetState() == Core::State::Running)
{ {
if (SConfig::GetInstance().bHideCursor) if (SConfig::GetInstance().bHideCursor)
XUndefineCursor(dpy, win); XUndefineCursor(dpy, win);
Core::SetState(Core::CORE_PAUSE); Core::SetState(Core::State::Paused);
} }
else else
{ {
if (SConfig::GetInstance().bHideCursor) if (SConfig::GetInstance().bHideCursor)
XDefineCursor(dpy, win, blankCursor); XDefineCursor(dpy, win, blankCursor);
Core::SetState(Core::CORE_RUN); Core::SetState(Core::State::Running);
} }
} }
else if ((key == XK_Return) && (event.xkey.state & Mod1Mask)) else if ((key == XK_Return) && (event.xkey.state & Mod1Mask))
@ -304,7 +304,7 @@ class PlatformX11 : public Platform
break; break;
case FocusIn: case FocusIn:
rendererHasFocus = true; rendererHasFocus = true;
if (SConfig::GetInstance().bHideCursor && Core::GetState() != Core::CORE_PAUSE) if (SConfig::GetInstance().bHideCursor && Core::GetState() != Core::State::Paused)
XDefineCursor(dpy, win, blankCursor); XDefineCursor(dpy, win, blankCursor);
break; break;
case FocusOut: case FocusOut:

View File

@ -223,7 +223,7 @@ void MainToolBar::RefreshPlayButton()
ToolBarBitmapID bitmap_id; ToolBarBitmapID bitmap_id;
wxString label; wxString label;
if (Core::GetState() == Core::CORE_RUN) if (Core::GetState() == Core::State::Running)
{ {
bitmap_id = TOOLBAR_PAUSE; bitmap_id = TOOLBAR_PAUSE;
label = _("Pause"); label = _("Pause");

View File

@ -74,7 +74,7 @@ SoftwareVideoConfigDialog::SoftwareVideoConfigDialog(wxWindow* parent, const std
szr_rendering->Add(label_backend, 0, wxALIGN_CENTER_VERTICAL); szr_rendering->Add(label_backend, 0, wxALIGN_CENTER_VERTICAL);
szr_rendering->Add(choice_backend, 0, wxALIGN_CENTER_VERTICAL); szr_rendering->Add(choice_backend, 0, wxALIGN_CENTER_VERTICAL);
if (Core::GetState() != Core::CORE_UNINITIALIZED) if (Core::GetState() != Core::State::Uninitialized)
{ {
label_backend->Disable(); label_backend->Disable();
choice_backend->Disable(); choice_backend->Disable();

View File

@ -13,12 +13,12 @@ namespace WxEventUtils
{ {
void OnEnableIfCoreInitialized(wxUpdateUIEvent& event) void OnEnableIfCoreInitialized(wxUpdateUIEvent& event)
{ {
event.Enable(Core::GetState() != Core::CORE_UNINITIALIZED); event.Enable(Core::GetState() != Core::State::Uninitialized);
} }
void OnEnableIfCoreUninitialized(wxUpdateUIEvent& event) void OnEnableIfCoreUninitialized(wxUpdateUIEvent& event)
{ {
event.Enable(Core::GetState() == Core::CORE_UNINITIALIZED); event.Enable(Core::GetState() == Core::State::Uninitialized);
} }
void OnEnableIfCoreRunning(wxUpdateUIEvent& event) void OnEnableIfCoreRunning(wxUpdateUIEvent& event)
@ -33,14 +33,14 @@ void OnEnableIfCoreNotRunning(wxUpdateUIEvent& event)
void OnEnableIfCorePaused(wxUpdateUIEvent& event) void OnEnableIfCorePaused(wxUpdateUIEvent& event)
{ {
event.Enable(Core::GetState() == Core::CORE_PAUSE); event.Enable(Core::GetState() == Core::State::Paused);
} }
void OnEnableIfCoreRunningOrPaused(wxUpdateUIEvent& event) void OnEnableIfCoreRunningOrPaused(wxUpdateUIEvent& event)
{ {
const auto state = Core::GetState(); const auto state = Core::GetState();
event.Enable(state == Core::CORE_RUN || state == Core::CORE_PAUSE); event.Enable(state == Core::State::Running || state == Core::State::Paused);
} }
void OnEnableIfCPUCanStep(wxUpdateUIEvent& event) void OnEnableIfCPUCanStep(wxUpdateUIEvent& event)

View File

@ -158,7 +158,7 @@ void Init()
if (s_handle != nullptr) if (s_handle != nullptr)
return; return;
if (Core::GetState() != Core::CORE_UNINITIALIZED) if (Core::GetState() != Core::State::Uninitialized)
{ {
if ((CoreTiming::GetTicks() - s_last_init) < SystemTimers::GetTicksPerSecond()) if ((CoreTiming::GetTicks() - s_last_init) < SystemTimers::GetTicksPerSecond())
return; return;

View File

@ -194,7 +194,7 @@ void Init()
if (s_fd) if (s_fd)
return; return;
if (Core::GetState() != Core::CORE_UNINITIALIZED) if (Core::GetState() != Core::State::Uninitialized)
{ {
if ((CoreTiming::GetTicks() - s_last_init) < SystemTimers::GetTicksPerSecond()) if ((CoreTiming::GetTicks() - s_last_init) < SystemTimers::GetTicksPerSecond())
return; return;