all repos — mgba @ fc53fc9647353e3757a8538c01d6fd1e9a0ed3ca

mGBA Game Boy Advance Emulator

GBA Timer: Fix timers sometimes being late (fixes #1012)
Vicki Pfau vi@endrift.com
Tue, 27 Mar 2018 20:33:13 -0700
commit

fc53fc9647353e3757a8538c01d6fd1e9a0ed3ca

parent

016e1596f7a526f1f9d6b1f13a8906aa11735693

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

jump to
M CHANGESCHANGES

@@ -55,6 +55,7 @@ - Qt: Fix opening in fullscreen (fixes mgba.io/i/993)

- Python: Fix package directory - GB Memory: Fix OAM DMA blocking regions (fixes mgba.io/i/1013) - Wii: Fix various setup and teardown drawing issues (fixes mgba.io/i/988) + - GBA Timer: Fix timers sometimes being late (fixes mgba.io/i/1012) Misc: - GBA Timer: Use global cycles for timers - GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722)
M src/gba/timer.csrc/gba/timer.c

@@ -51,7 +51,7 @@ int32_t currentTime = mTimingCurrentTime(&gba->timing) - cyclesLate;

int32_t tickMask = (1 << GBATimerFlagsGetPrescaleBits(timer->flags)) - 1; currentTime &= ~tickMask; timer->lastEvent = currentTime; - GBATimerUpdateRegister(gba, timerId, 0); + GBATimerUpdateRegister(gba, timerId, TIMER_RELOAD_DELAY + cyclesLate); if (GBATimerFlagsIsDoIrq(timer->flags)) { timer->flags = GBATimerFlagsFillIrqPending(timer->flags);

@@ -155,7 +155,7 @@ gba->memory.io[(REG_TM0CNT_LO + (timer << 2)) >> 1] = tickIncrement;

if (!mTimingIsScheduled(&gba->timing, &currentTimer->event)) { tickIncrement = (0x10000 - tickIncrement) << prescaleBits; currentTime -= mTimingCurrentTime(&gba->timing) - cyclesLate; - mTimingSchedule(&gba->timing, &currentTimer->event, TIMER_RELOAD_DELAY + tickIncrement + currentTime); + mTimingSchedule(&gba->timing, &currentTimer->event, tickIncrement + currentTime); } }