Skip to content
Permalink
Browse files

Merge pull request #4836 from lioncash/enum

DSPCore: Convert the DSPCoreState enum into an enum class
  • Loading branch information
Parlane committed Feb 6, 2017
2 parents 0c7d9bb + 063e4df commit 2835cfde52c800805bfcb4de4c1fa0ee147e3d1d
@@ -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<JIT::x86::DSPEmitter> 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,42 +261,42 @@ 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();
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();
}

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

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

0 comments on commit 2835cfd

Please sign in to comment.
You can’t perform that action at this time.