From 154b447ae6c78017f6daa3c7bb0cab42a7fe17c6 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 3 Feb 2018 21:47:10 -0800 Subject: [PATCH] GB Timer: Fix low bit of DIV resetting --- src/gb/timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gb/timer.c b/src/gb/timer.c index 0e587410d..0839ab28f 100644 --- a/src/gb/timer.c +++ b/src/gb/timer.c @@ -71,7 +71,7 @@ void GBTimerDivReset(struct GBTimer* timer) { timer->nextDiv -= mTimingUntil(&timer->p->timing, &timer->event); mTimingDeschedule(&timer->p->timing, &timer->event); _GBTimerDivIncrement(timer, (timer->p->cpu->executionState + 1) & 3); - if (timer->internalDiv & (timer->timaPeriod >> 1)) { + if (((timer->internalDiv << 1) | ((timer->nextDiv >> 3) & 1)) & timer->timaPeriod) { ++timer->p->memory.io[REG_TIMA]; if (!timer->p->memory.io[REG_TIMA]) { mTimingSchedule(&timer->p->timing, &timer->irq, 4 - ((timer->p->cpu->executionState + 1) & 3));