GBA Timer: Fix timers sometimes being late (fixes #1012)

This commit is contained in:
Vicki Pfau 2018-03-27 20:33:13 -07:00
parent 016e1596f7
commit fc53fc9647
2 changed files with 3 additions and 2 deletions

View File

@ -55,6 +55,7 @@ Bugfixes:
- Python: Fix package directory - Python: Fix package directory
- GB Memory: Fix OAM DMA blocking regions (fixes mgba.io/i/1013) - 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) - 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: Misc:
- GBA Timer: Use global cycles for timers - GBA Timer: Use global cycles for timers
- GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722) - GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722)

View File

@ -51,7 +51,7 @@ static void GBATimerUpdate(struct GBA* gba, int timerId, uint32_t cyclesLate) {
int32_t tickMask = (1 << GBATimerFlagsGetPrescaleBits(timer->flags)) - 1; int32_t tickMask = (1 << GBATimerFlagsGetPrescaleBits(timer->flags)) - 1;
currentTime &= ~tickMask; currentTime &= ~tickMask;
timer->lastEvent = currentTime; timer->lastEvent = currentTime;
GBATimerUpdateRegister(gba, timerId, 0); GBATimerUpdateRegister(gba, timerId, TIMER_RELOAD_DELAY + cyclesLate);
if (GBATimerFlagsIsDoIrq(timer->flags)) { if (GBATimerFlagsIsDoIrq(timer->flags)) {
timer->flags = GBATimerFlagsFillIrqPending(timer->flags); timer->flags = GBATimerFlagsFillIrqPending(timer->flags);
@ -155,7 +155,7 @@ void GBATimerUpdateRegister(struct GBA* gba, int timer, int32_t cyclesLate) {
if (!mTimingIsScheduled(&gba->timing, &currentTimer->event)) { if (!mTimingIsScheduled(&gba->timing, &currentTimer->event)) {
tickIncrement = (0x10000 - tickIncrement) << prescaleBits; tickIncrement = (0x10000 - tickIncrement) << prescaleBits;
currentTime -= mTimingCurrentTime(&gba->timing) - cyclesLate; currentTime -= mTimingCurrentTime(&gba->timing) - cyclesLate;
mTimingSchedule(&gba->timing, &currentTimer->event, TIMER_RELOAD_DELAY + tickIncrement + currentTime); mTimingSchedule(&gba->timing, &currentTimer->event, tickIncrement + currentTime);
} }
} }