GB: Fix div reseting

This commit is contained in:
Jeffrey Pfau 2016-08-28 10:06:44 -07:00
parent 70e01030d1
commit 9e4f53aa24
1 changed files with 4 additions and 3 deletions

View File

@ -30,8 +30,9 @@ int32_t GBTimerProcessEvents(struct GBTimer* timer, int32_t cycles) {
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 @@ int32_t GBTimerProcessEvents(struct GBTimer* timer, int32_t cycles) {
timer->nextEvent += 4;
}
}
++timer->internalDiv;
}
timer->eventDiff = 0;
}
@ -51,7 +53,6 @@ int32_t GBTimerProcessEvents(struct GBTimer* timer, int32_t cycles) {
void GBTimerDivReset(struct GBTimer* timer) {
timer->p->memory.io[REG_DIV] = 0;
timer->internalDiv = 0;
}
uint8_t GBTimerUpdateTAC(struct GBTimer* timer, GBRegisterTAC tac) {