all repos — mgba @ 239921966332f0a749ff35f5daa17f06132643ab

mGBA Game Boy Advance Emulator

GB: Fix DIV reseting timing
Jeffrey Pfau jeffrey@endrift.com
Thu, 28 Jan 2016 01:27:02 -0800
commit

239921966332f0a749ff35f5daa17f06132643ab

parent

d7d2a552d29550d49fad32c4411b693d3ea0d69f

1 files changed, 5 insertions(+), 3 deletions(-)

jump to
M src/gb/timer.csrc/gb/timer.c

@@ -49,9 +49,11 @@

void GBTimerDivReset(struct GBTimer* timer) { timer->p->memory.io[REG_DIV] = 0; timer->nextDiv = timer->eventDiff + timer->p->cpu->cycles + GB_DMG_DIV_PERIOD; - timer->nextEvent = timer->nextTima; - if (timer->nextDiv < timer->nextEvent) { - timer->nextEvent = timer->nextDiv; + if (timer->eventDiff + GB_DMG_DIV_PERIOD < timer->nextEvent) { + timer->nextEvent = timer->eventDiff + GB_DMG_DIV_PERIOD; + if (timer->nextEvent < timer->p->cpu->nextEvent) { + timer->p->cpu->nextEvent = timer->nextEvent; + } } }