From 4738e558f2a3ea034808ff11618fadbcb8bd64e0 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 3 Feb 2023 01:43:34 -0800 Subject: [PATCH] GBA Timers: Cascading timers don't tick when disabled (fixes #2812) --- CHANGES | 1 + src/gba/timer.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 6050fce13..1a3f283eb 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,7 @@ Emulation fixes: - GBA Audio: Fix improperly deserializing GB audio registers (fixes mgba.io/i/2793) - GBA Memory: Make VRAM access stalls only apply to BG RAM - GBA SIO: Fix SIOCNT SI pin value after attaching player 2 (fixes mgba.io/i/2805) + - GBA Timers: Cascading timers don't tick when disabled (fixes mgba.io/i/2812) Other fixes: - Core: Allow sending thread requests to a crashed core (fixes mgba.io/i/2784) - Qt: Fix crash when attempting to use OpenGL 2.1 to 3.1 (fixes mgba.io/i/2794) diff --git a/src/gba/timer.c b/src/gba/timer.c index 8a3a3e8f6..da054e12a 100644 --- a/src/gba/timer.c +++ b/src/gba/timer.c @@ -34,7 +34,7 @@ static void GBATimerUpdate(struct GBA* gba, int timerId, uint32_t cyclesLate) { if (timerId < 3) { struct GBATimer* nextTimer = &gba->timers[timerId + 1]; - if (GBATimerFlagsIsCountUp(nextTimer->flags)) { // TODO: Does this increment while disabled? + if (GBATimerFlagsIsCountUp(nextTimer->flags) && GBATimerFlagsIsEnable(nextTimer->flags)) { ++gba->memory.io[REG_TMCNT_LO(timerId + 1) >> 1]; if (!gba->memory.io[REG_TMCNT_LO(timerId + 1) >> 1] && GBATimerFlagsIsEnable(nextTimer->flags)) { GBATimerUpdate(gba, timerId + 1, cyclesLate);