DS: Backport GBA event changes
Vicki Pfau vi@endrift.com
Sat, 18 Jul 2020 15:41:46 -0700
1 files changed,
19 insertions(+),
16 deletions(-)
jump to
M
src/ds/ds.c
→
src/ds/ds.c
@@ -418,26 +418,22 @@ }
int32_t nextEvent = cpu->nextEvent; while (cpu->cycles >= nextEvent) { - int32_t cycles = cpu->cycles; - - cpu->cycles = 0; - cpu->nextEvent = 0; - + cpu->nextEvent = INT_MAX; + nextEvent = 0; + do { + 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); - } + if (cycles < 0) { + mLOG(DS, FATAL, "Negative cycles passed: %i", cycles); + } #endif - nextEvent = cycles; - do { - nextEvent = mTimingTick(&dscore->timing, nextEvent); + 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 @@ else if (nextEvent < 0) {
mLOG(DS, FATAL, "Negative cycles will pass: %i", nextEvent); } #endif + if (ds->earlyExit) { + break; + } + } + ds->earlyExit = false; + if (ds->cpuBlocked) { + cpu->cycles = cpu->nextEvent; } }