DS: Backport GBA event changes

This commit is contained in:
Vicki Pfau 2020-07-18 15:41:46 -07:00
parent b9415b9f74
commit 000b49e45b
1 changed files with 20 additions and 17 deletions

View File

@ -418,26 +418,22 @@ static void DSProcessEvents(struct DSCommon* dscore) {
int32_t nextEvent = cpu->nextEvent;
while (cpu->cycles >= nextEvent) {
int32_t cycles = cpu->cycles;
cpu->cycles = 0;
cpu->nextEvent = 0;
#ifndef NDEBUG
if (cycles < 0) {
mLOG(DS, FATAL, "Negative cycles passed: %i", cycles);
}
#endif
nextEvent = cycles;
cpu->nextEvent = INT_MAX;
nextEvent = 0;
do {
nextEvent = mTimingTick(&dscore->timing, nextEvent);
int32_t cycles = cpu->cycles;
cpu->cycles = 0;
#ifdef USE_DEBUGGERS
dscore->timing.globalCycles += cycles;
#endif
#ifndef NDEBUG
if (cycles < 0) {
mLOG(DS, FATAL, "Negative cycles passed: %i", cycles);
}
#endif
nextEvent = mTimingTick(&dscore->timing, cycles < nextEvent ? nextEvent : cycles);
} while (ds->cpuBlocked && !ds->earlyExit);
if (ds->earlyExit) {
ds->earlyExit = false;
break;
}
cpu->nextEvent = nextEvent;
if (cpu->halted) {
cpu->cycles = nextEvent;
@ -447,6 +443,13 @@ static void DSProcessEvents(struct DSCommon* dscore) {
mLOG(DS, FATAL, "Negative cycles will pass: %i", nextEvent);
}
#endif
if (ds->earlyExit) {
break;
}
}
ds->earlyExit = false;
if (ds->cpuBlocked) {
cpu->cycles = cpu->nextEvent;
}
}