GB: Fix div reseting
Jeffrey Pfau jeffrey@endrift.com
Sun, 28 Aug 2016 10:06:44 -0700
1 files changed,
4 insertions(+),
3 deletions(-)
jump to
M
src/gb/timer.c
→
src/gb/timer.c
@@ -30,8 +30,9 @@ timer->irqPending = false;
timer->nextEvent += timer->nextDiv; } if (timer->nextDiv <= 0) { - ++timer->internalDiv; - timer->p->memory.io[REG_DIV] = timer->internalDiv >> 4; + if ((timer->internalDiv & 15) == 15) { + ++timer->p->memory.io[REG_DIV]; + } timer->nextDiv += GB_DMG_DIV_PERIOD; timer->nextEvent += GB_DMG_DIV_PERIOD;@@ -43,6 +44,7 @@ timer->irqPending = true;
timer->nextEvent += 4; } } + ++timer->internalDiv; } timer->eventDiff = 0; }@@ -51,7 +53,6 @@ }
void GBTimerDivReset(struct GBTimer* timer) { timer->p->memory.io[REG_DIV] = 0; - timer->internalDiv = 0; } uint8_t GBTimerUpdateTAC(struct GBTimer* timer, GBRegisterTAC tac) {