mirror of https://github.com/mgba-emu/mgba.git
DS: Backport GBA event changes
This commit is contained in:
parent
b9415b9f74
commit
000b49e45b
37
src/ds/ds.c
37
src/ds/ds.c
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue