From 063e4df5a19412e322b668c68004ab97b8ef5906 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 6 Feb 2017 11:44:10 -0500 Subject: [PATCH] DSPCore: Convert the DSPCoreState enum into an enum class --- Source/Core/Core/DSP/DSPCore.cpp | 24 +++++++++---------- Source/Core/Core/DSP/DSPCore.h | 12 +++++----- .../Core/DSP/Interpreter/DSPInterpreter.cpp | 6 ++--- .../Core/Core/HW/DSPLLE/DSPDebugInterface.cpp | 2 +- .../DolphinWX/Debugger/DSPDebugWindow.cpp | 14 +++++------ 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Source/Core/Core/DSP/DSPCore.cpp b/Source/Core/Core/DSP/DSPCore.cpp index 3fbfe5e9c0..09856660ab 100644 --- a/Source/Core/Core/DSP/DSPCore.cpp +++ b/Source/Core/Core/DSP/DSPCore.cpp @@ -28,7 +28,7 @@ namespace DSP { SDSP g_dsp; DSPBreakpoints g_dsp_breakpoints; -static DSPCoreState core_state = DSPCORE_STOP; +static State core_state = State::Stopped; u16 g_cycles_left = 0; bool g_init_hax = false; std::unique_ptr g_dsp_jit; @@ -154,16 +154,16 @@ bool DSPCore_Init(const DSPInitOptions& opts) g_dsp_cap.reset(opts.capture_logger); - core_state = DSPCORE_RUNNING; + core_state = State::Running; return true; } void DSPCore_Shutdown() { - if (core_state == DSPCORE_STOP) + if (core_state == State::Stopped) return; - core_state = DSPCORE_STOP; + core_state = State::Stopped; g_dsp_jit.reset(); @@ -252,7 +252,7 @@ int DSPCore_RunCycles(int cycles) { switch (core_state) { - case DSPCORE_RUNNING: + case State::Running: // Seems to slow things down #if defined(_DEBUG) || defined(DEBUGFAST) cycles = Interpreter::RunCyclesDebug(cycles); @@ -261,9 +261,9 @@ int DSPCore_RunCycles(int cycles) #endif break; - case DSPCORE_STEPPING: + case State::Stepping: step_event.Wait(); - if (core_state != DSPCORE_STEPPING) + if (core_state != State::Stepping) continue; Interpreter::Step(); @@ -271,32 +271,32 @@ int DSPCore_RunCycles(int cycles) Host::UpdateDebugger(); break; - case DSPCORE_STOP: + case State::Stopped: break; } } return cycles; } -void DSPCore_SetState(DSPCoreState new_state) +void DSPCore_SetState(State new_state) { core_state = new_state; // kick the event, in case we are waiting - if (new_state == DSPCORE_RUNNING) + if (new_state == State::Running) step_event.Set(); Host::UpdateDebugger(); } -DSPCoreState DSPCore_GetState() +State DSPCore_GetState() { return core_state; } void DSPCore_Step() { - if (core_state == DSPCORE_STEPPING) + if (core_state == State::Stepping) step_event.Set(); } diff --git a/Source/Core/Core/DSP/DSPCore.h b/Source/Core/Core/DSP/DSPCore.h index 13d331c71f..c2ad870fe1 100644 --- a/Source/Core/Core/DSP/DSPCore.h +++ b/Source/Core/Core/DSP/DSPCore.h @@ -355,18 +355,18 @@ void DSPCore_SetExternalInterrupt(bool val); // sets a flag in the pending exception register. void DSPCore_SetException(u8 level); -enum DSPCoreState +enum class State { - DSPCORE_STOP = 0, - DSPCORE_RUNNING, - DSPCORE_STEPPING, + Stopped, + Running, + Stepping, }; int DSPCore_RunCycles(int cycles); // These are meant to be called from the UI thread. -void DSPCore_SetState(DSPCoreState new_state); -DSPCoreState DSPCore_GetState(); +void DSPCore_SetState(State new_state); +State DSPCore_GetState(); void DSPCore_Step(); diff --git a/Source/Core/Core/DSP/Interpreter/DSPInterpreter.cpp b/Source/Core/Core/DSP/Interpreter/DSPInterpreter.cpp index d874f878bb..ac372f7e15 100644 --- a/Source/Core/Core/DSP/Interpreter/DSPInterpreter.cpp +++ b/Source/Core/Core/DSP/Interpreter/DSPInterpreter.cpp @@ -134,7 +134,7 @@ int RunCyclesDebug(int cycles) return 0; if (g_dsp_breakpoints.IsAddressBreakPoint(g_dsp.pc)) { - DSPCore_SetState(DSPCORE_STEPPING); + DSPCore_SetState(State::Stepping); return cycles; } Step(); @@ -153,7 +153,7 @@ int RunCyclesDebug(int cycles) return 0; if (g_dsp_breakpoints.IsAddressBreakPoint(g_dsp.pc)) { - DSPCore_SetState(DSPCORE_STEPPING); + DSPCore_SetState(State::Stepping); return cycles; } // Idle skipping. @@ -170,7 +170,7 @@ int RunCyclesDebug(int cycles) { if (g_dsp_breakpoints.IsAddressBreakPoint(g_dsp.pc)) { - DSPCore_SetState(DSPCORE_STEPPING); + DSPCore_SetState(State::Stepping); return cycles; } Step(); diff --git a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp index 1b83093b73..c77eaa75e3 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPDebugInterface.cpp @@ -24,7 +24,7 @@ std::string DSPDebugInterface::Disassemble(unsigned int address) std::string DSPDebugInterface::GetRawMemoryString(int memory, unsigned int address) { - if (DSPCore_GetState() == DSPCORE_STOP) + if (DSPCore_GetState() == State::Stopped) return ""; switch (memory) diff --git a/Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp b/Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp index 1777cc531a..922fd3c0c7 100644 --- a/Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/DSPDebugWindow.cpp @@ -115,22 +115,22 @@ DSPDebuggerLLE::~DSPDebuggerLLE() void DSPDebuggerLLE::OnChangeState(wxCommandEvent& event) { - const DSP::DSPCoreState dsp_state = DSP::DSPCore_GetState(); + const DSP::State dsp_state = DSP::DSPCore_GetState(); - if (dsp_state == DSP::DSPCORE_STOP) + if (dsp_state == DSP::State::Stopped) return; switch (event.GetId()) { case ID_RUNTOOL: - if (dsp_state == DSP::DSPCORE_RUNNING) - DSP::DSPCore_SetState(DSP::DSPCORE_STEPPING); + if (dsp_state == DSP::State::Running) + DSP::DSPCore_SetState(DSP::State::Stepping); else - DSP::DSPCore_SetState(DSP::DSPCORE_RUNNING); + DSP::DSPCore_SetState(DSP::State::Running); break; case ID_STEPTOOL: - if (dsp_state == DSP::DSPCORE_STEPPING) + if (dsp_state == DSP::State::Stepping) { DSP::DSPCore_Step(); Repopulate(); @@ -175,7 +175,7 @@ void DSPDebuggerLLE::FocusOnPC() void DSPDebuggerLLE::UpdateState() { - if (DSP::DSPCore_GetState() == DSP::DSPCORE_RUNNING) + if (DSP::DSPCore_GetState() == DSP::State::Running) { m_Toolbar->SetToolLabel(ID_RUNTOOL, _("Pause")); m_Toolbar->SetToolBitmap(