all repos — mgba @ 3e178f3dd7d08e6b556167909940411e1f8c3be1

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

3e178f3dd7d08e6b556167909940411e1f8c3be1

parent

8796f75fd3374c05d3452e284434c46eb9b178d4

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

jump to
M CHANGESCHANGES

@@ -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.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 {