all repos — mgba @ 67fedf8618e7e0f884f3c6ce749c537758cf1962

mGBA Game Boy Advance Emulator

GB Timer: Fix timing adjustments when writing to TAC (fixes #1340)
Vicki Pfau vi@endrift.com
Sat, 23 Mar 2019 22:46:58 -0700
commit

67fedf8618e7e0f884f3c6ce749c537758cf1962

parent

a58e0ce525af9a89ab82f694891b3abc0d9f4892

2 files changed, 5 insertions(+), 3 deletions(-)

jump to
M CHANGESCHANGES

@@ -4,6 +4,7 @@ - GBA Video: Fix scanline cache with scale factor change edge cases

- GBA DMA: Fix DMA0-2 lengths (fixes mgba.io/i/1344) - GB Video: Fix window y changing mid-window (fixes mgba.io/i/1345) - GB Video: Fix more window edge cases (fixes mgba.io/i/1346) + - GB Timer: Fix timing adjustments when writing to TAC (fixes mgba.io/i/1340) Other fixes: - Qt: More app metadata fixes - Qt: Fix load recent from archive (fixes mgba.io/i/1325)
M src/gb/timer.csrc/gb/timer.c

@@ -92,6 +92,10 @@ }

uint8_t GBTimerUpdateTAC(struct GBTimer* timer, GBRegisterTAC tac) { if (GBRegisterTACIsRun(tac)) { + timer->nextDiv -= mTimingUntil(&timer->p->timing, &timer->event); + mTimingDeschedule(&timer->p->timing, &timer->event); + _GBTimerDivIncrement(timer, (timer->p->cpu->executionState + 2) & 3); + switch (GBRegisterTACGetClock(tac)) { case 0: timer->timaPeriod = 1024 >> 4;

@@ -107,9 +111,6 @@ timer->timaPeriod = 256 >> 4;

break; } - timer->nextDiv -= mTimingUntil(&timer->p->timing, &timer->event); - mTimingDeschedule(&timer->p->timing, &timer->event); - _GBTimerDivIncrement(timer, (timer->p->cpu->executionState + 2) & 3); timer->nextDiv += GB_DMG_DIV_PERIOD; mTimingSchedule(&timer->p->timing, &timer->event, timer->nextDiv); } else {