all repos — mgba @ a85ae6563c1008685ccd91fcedc1bb2846139ad6

mGBA Game Boy Advance Emulator

GBA: Fix timing of reading from timer registers
Jeffrey Pfau jeffrey@endrift.com
Mon, 22 Jun 2015 22:32:46 -0700
commit

a85ae6563c1008685ccd91fcedc1bb2846139ad6

parent

9cc4c9e43da7e37c0a88d026fec9ab52a1b3ae2b

2 files changed, 3 insertions(+), 1 deletions(-)

jump to
M CHANGESCHANGES

@@ -48,6 +48,7 @@ - GBA: Fix calls to endian-independent loadstores

- GBA Video: Fix windows not affecting sprites - VFS: Fix line-reading to return proper values - GBA Memory: Fix load/store multiple video memory waitstates + - GBA: Fix timing of reading from timer registers Misc: - Qt: Handle saving input settings better - Debugger: Free watchpoints in addition to breakpoints
M src/gba/gba.csrc/gba/gba.c

@@ -451,7 +451,8 @@

void GBATimerUpdateRegister(struct GBA* gba, int timer) { struct GBATimer* currentTimer = &gba->timers[timer]; if (currentTimer->enable && !currentTimer->countUp) { - gba->memory.io[(REG_TM0CNT_LO + (timer << 2)) >> 1] = currentTimer->oldReload + ((gba->cpu->cycles - currentTimer->lastEvent) >> currentTimer->prescaleBits); + // Reading this takes two cycles (1N+1I), so let's remove them preemptively + gba->memory.io[(REG_TM0CNT_LO + (timer << 2)) >> 1] = currentTimer->oldReload + ((gba->cpu->cycles - currentTimer->lastEvent - 2) >> currentTimer->prescaleBits); } }