GB: Fix DIV reseting timing

This commit is contained in:
Jeffrey Pfau 2016-01-28 01:27:02 -08:00
parent d7d2a552d2
commit 2399219663
1 changed files with 5 additions and 3 deletions

View File

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