all repos — mgba @ fc2a0955f4031992f694662cbaf2f7185240417f

mGBA Game Boy Advance Emulator

GBA Timer: Fix timer regression when prefetch is enabled (fixes #781)
Vicki Pfau vi@endrift.com
Sat, 08 Jul 2017 17:04:05 -0700
commit

fc2a0955f4031992f694662cbaf2f7185240417f

parent

4c439e3819c6c749a2a9a3592ce8ee4dc529be32

2 files changed, 4 insertions(+), 8 deletions(-)

jump to
M src/gba/io.csrc/gba/io.c

@@ -709,16 +709,16 @@

switch (address) { // Reading this takes two cycles (1N+1I), so let's remove them preemptively case REG_TM0CNT_LO: - GBATimerUpdateRegister(gba, 0, 2); + GBATimerUpdateRegister(gba, 0, 4); break; case REG_TM1CNT_LO: - GBATimerUpdateRegister(gba, 1, 2); + GBATimerUpdateRegister(gba, 1, 4); break; case REG_TM2CNT_LO: - GBATimerUpdateRegister(gba, 2, 2); + GBATimerUpdateRegister(gba, 2, 4); break; case REG_TM3CNT_LO: - GBATimerUpdateRegister(gba, 3, 2); + GBATimerUpdateRegister(gba, 3, 4); break; case REG_KEYINPUT:
M src/gba/timer.csrc/gba/timer.c

@@ -143,10 +143,6 @@ if (!GBATimerFlagsIsEnable(currentTimer->flags) || GBATimerFlagsIsCountUp(currentTimer->flags)) {

return; } - if (gba->memory.lastPrefetchedPc > (uint32_t) gba->cpu->gprs[ARM_PC]) { - cyclesLate -= ((gba->memory.lastPrefetchedPc - gba->cpu->gprs[ARM_PC]) * gba->cpu->memory.activeSeqCycles16) / WORD_SIZE_THUMB; - } - int prescaleBits = GBATimerFlagsGetPrescaleBits(currentTimer->flags); int32_t currentTime = mTimingCurrentTime(&gba->timing) - cyclesLate; int32_t tickMask = (1 << prescaleBits) - 1;