GB Timer: Fix timing adjustments when writing to TAC (fixes #1340)
Vicki Pfau vi@endrift.com
Sat, 23 Mar 2019 22:46:58 -0700
2 files changed,
5 insertions(+),
3 deletions(-)
M
CHANGES
→
CHANGES
@@ -17,6 +17,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.c
→
src/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 {