Permalink
Browse files

Core: Process stepping on other platforms.

This includes Android.
  • Loading branch information...
unknownbrackets committed Apr 30, 2018
1 parent c15ade3 commit 2e2d8f29893fdadf5d81e2cee77f49c724ad41b0
Showing with 29 additions and 19 deletions.
  1. +13 −11 Core/Core.cpp
  2. +14 −0 Core/System.cpp
  3. +1 −0 Core/System.h
  4. +1 −8 UI/EmuScreen.cpp
View
@@ -239,6 +239,8 @@ void Core_UpdateSingleStep() {
void Core_SingleStep() {
currentMIPS->SingleStep();
if (coreState == CORE_STEPPING)
steppingCounter++;
}
static inline void CoreStateProcessed() {
@@ -249,10 +251,14 @@ static inline void CoreStateProcessed() {
}
}
static inline void Core_WaitStepping() {
static inline bool Core_WaitStepping() {
std::unique_lock<std::mutex> guard(m_hStepMutex);
if (!singleStepPending && coreState == CORE_STEPPING)
m_StepCond.wait(guard);
bool result = singleStepPending;
singleStepPending = false;
return result;
}
void Core_ProcessStepping() {
@@ -268,12 +274,10 @@ void Core_ProcessStepping() {
host->UpdateMemView();
// Need to check inside the lock to avoid races.
Core_WaitStepping();
bool doStep = Core_WaitStepping();
// We may still be stepping without singleStepPending to process a save state.
if (singleStepPending && coreState == CORE_STEPPING) {
singleStepPending = false;
if (doStep && coreState == CORE_STEPPING) {
Core_SingleStep();
// Update disasm dialog.
host->UpdateDisassembly();
@@ -298,15 +302,13 @@ void Core_Run(GraphicsContext *ctx) {
switch (coreState) {
case CORE_RUNNING:
case CORE_STEPPING:
// enter a fast runloop
Core_RunLoop(ctx);
break;
// We should never get here on Android.
case CORE_STEPPING:
Core_ProcessStepping();
if (coreState == CORE_POWERDOWN)
if (coreState == CORE_POWERDOWN) {
CoreStateProcessed();
return;
}
break;
case CORE_POWERUP:
View
@@ -430,10 +430,24 @@ void PSP_EndHostFrame() {
}
}
void PSP_RunLoopWhileState() {
// We just run the CPU until we get to vblank. This will quickly sync up pretty nicely.
// The actual number of cycles doesn't matter so much here as we will break due to CORE_NEXTFRAME, most of the time hopefully...
int blockTicks = usToCycles(1000000 / 10);
// Run until CORE_NEXTFRAME
while (coreState == CORE_RUNNING || coreState == CORE_STEPPING) {
PSP_RunLoopFor(blockTicks);
}
}
void PSP_RunLoopUntil(u64 globalticks) {
SaveState::Process();
if (coreState == CORE_POWERDOWN || coreState == CORE_ERROR) {
return;
} else if (coreState == CORE_STEPPING) {
Core_ProcessStepping();
return;
}
mipsr4k.RunLoopUntil(globalticks);
View
@@ -70,6 +70,7 @@ void PSP_Shutdown();
void PSP_BeginHostFrame();
void PSP_EndHostFrame();
void PSP_RunLoopWhileState();
void PSP_RunLoopUntil(u64 globalticks);
void PSP_RunLoopFor(int cycles);
View
@@ -1193,14 +1193,7 @@ void EmuScreen::render() {
PSP_BeginHostFrame();
// We just run the CPU until we get to vblank. This will quickly sync up pretty nicely.
// The actual number of cycles doesn't matter so much here as we will break due to CORE_NEXTFRAME, most of the time hopefully...
int blockTicks = usToCycles(1000000 / 10);
// Run until CORE_NEXTFRAME
while (coreState == CORE_RUNNING) {
PSP_RunLoopFor(blockTicks);
}
PSP_RunLoopWhileState();
// Hopefully coreState is now CORE_NEXTFRAME
if (coreState == CORE_NEXTFRAME) {

0 comments on commit 2e2d8f2

Please sign in to comment.