From fc2a0955f4031992f694662cbaf2f7185240417f Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 8 Jul 2017 17:04:05 -0700 Subject: [PATCH] GBA Timer: Fix timer regression when prefetch is enabled (fixes #781) --- src/gba/io.c | 8 ++++---- src/gba/timer.c | 4 ---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/gba/io.c b/src/gba/io.c index ae76e09e4..60d1a7c83 100644 --- a/src/gba/io.c +++ b/src/gba/io.c @@ -709,16 +709,16 @@ uint16_t GBAIORead(struct GBA* gba, uint32_t address) { 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: diff --git a/src/gba/timer.c b/src/gba/timer.c index d4ee0776a..305660aa9 100644 --- a/src/gba/timer.c +++ b/src/gba/timer.c @@ -143,10 +143,6 @@ void GBATimerUpdateRegister(struct GBA* gba, int timer, int32_t cyclesLate) { 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;