all repos — mgba @ a382c1ee9bb7bc79ce0445658eb2d4d771554766

mGBA Game Boy Advance Emulator

GB Timer: Fix low bit of DIV resetting
Vicki Pfau vi@endrift.com
Sat, 03 Feb 2018 21:47:10 -0800
commit

a382c1ee9bb7bc79ce0445658eb2d4d771554766

parent

0ce3b9a2b7ae866a850d5bae19de5fe67d2ca628

2 files changed, 1 insertions(+), 2 deletions(-)

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

@@ -70,7 +70,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));