1
// Copyright 2013 Dolphin Emulator Project
2
// Licensed under GPLv2
3
// Refer to the license.txt file included.
8
#include "../DSPEmulator.h"
9
#include "../PowerPC/PowerPC.h"
16
#include "VideoBackendBase.h"
20
static Common::Event m_StepEvent;
21
static Common::Event *m_SyncEvent = NULL;
22
static std::mutex m_csCpuOccupied;
25
void CCPU::Init(int cpu_core)
27
PowerPC::Init(cpu_core);
39
std::lock_guard<std::mutex> lk(m_csCpuOccupied);
40
Host_UpdateDisasmDialog();
45
switch (PowerPC::GetState())
47
case PowerPC::CPU_RUNNING:
48
//1: enter a fast runloop
52
case PowerPC::CPU_STEPPING:
53
m_csCpuOccupied.unlock();
55
//1: wait for step command..
58
m_csCpuOccupied.lock();
59
if (PowerPC::GetState() == PowerPC::CPU_POWERDOWN)
61
if (PowerPC::GetState() != PowerPC::CPU_STEPPING)
65
PowerPC::SingleStep();
67
//4: update disasm dialog
73
Host_UpdateDisasmDialog();
76
case PowerPC::CPU_POWERDOWN:
89
bool CCPU::IsStepping()
91
return PowerPC::GetState() == PowerPC::CPU_STEPPING;
99
void CCPU::StepOpcode(Common::Event *event)
102
if (PowerPC::GetState() == PowerPC::CPU_STEPPING)
108
void CCPU::EnableStepping(const bool _bStepping)
114
g_video_backend->EmuStateChange(EMUSTATE_CHANGE_PAUSE);
115
DSP::GetDSPEmulator()->DSP_ClearAudioBuffer(true);
121
g_video_backend->EmuStateChange(EMUSTATE_CHANGE_PLAY);
122
DSP::GetDSPEmulator()->DSP_ClearAudioBuffer(false);
128
EnableStepping(true);
131
bool CCPU::PauseAndLock(bool doLock, bool unpauseOnUnlock)
133
bool wasUnpaused = !IsStepping();
136
// we can't use EnableStepping, that would causes deadlocks with both audio and video
138
if (!Core::IsCPUThread())
139
m_csCpuOccupied.lock();
149
if (!Core::IsCPUThread())
150
m_csCpuOccupied.unlock();