all repos — mgba @ 69aa7ac3aed1b77f214ece118eefbaa25a2545f4

mGBA Game Boy Advance Emulator

GBA: Timing cleanup
Vicki Pfau vi@endrift.com
Thu, 04 Jan 2018 21:34:07 -0800
commit

69aa7ac3aed1b77f214ece118eefbaa25a2545f4

parent

16131c9702ca1469008f2263dc990be369049b09

1 files changed, 6 insertions(+), 13 deletions(-)

jump to
M src/gba/gba.csrc/gba/gba.c

@@ -243,24 +243,17 @@ }

int32_t nextEvent = cpu->nextEvent; while (cpu->cycles >= nextEvent) { - int32_t cycles = cpu->cycles; - - cpu->cycles = 0; cpu->nextEvent = INT_MAX; - -#ifndef NDEBUG - if (cycles < 0) { - mLOG(GBA, FATAL, "Negative cycles passed: %i", cycles); - } -#endif - nextEvent = cycles; + nextEvent = 0; do { + int32_t cycles = cpu->cycles; + cpu->cycles = 0; #ifndef NDEBUG - if (cpu->cycles) { - mLOG(GBA, FATAL, "Cycles passed inexplicably: %i", cpu->cycles); + if (cycles < 0) { + mLOG(GBA, FATAL, "Negative cycles passed: %i", cycles); } #endif - nextEvent = mTimingTick(&gba->timing, nextEvent); + nextEvent = mTimingTick(&gba->timing, nextEvent + cycles); } while (gba->cpuBlocked); cpu->nextEvent = nextEvent;