mirror of https://github.com/mgba-emu/mgba.git
GBA Timer: Fix timer regression when prefetch is enabled (fixes #781)
This commit is contained in:
parent
4c439e3819
commit
fc2a0955f4
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue