GBA Timer: Fix timer regression when prefetch is enabled (fixes #781)
Vicki Pfau vi@endrift.com
Sat, 08 Jul 2017 17:04:05 -0700
2 files changed,
4 insertions(+),
8 deletions(-)
M
src/gba/io.c
→
src/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.c
→
src/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;