From eb761bc62f176ec3eb012660c4a640a34b57fee0 Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Fri, 13 Nov 2020 14:50:12 +0000 Subject: [PATCH] LR35902: Whoops: correct broken timer (when it begins at zero!) Signed-off-by: Adrian Conlon --- LR35902/src/IoRegisters.cpp | 2 +- LR35902/src/LR35902.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/LR35902/src/IoRegisters.cpp b/LR35902/src/IoRegisters.cpp index 47bded6..a86ba4e 100644 --- a/LR35902/src/IoRegisters.cpp +++ b/LR35902/src/IoRegisters.cpp @@ -153,7 +153,7 @@ void EightBit::GameBoy::IoRegisters::incrementTimers() { void EightBit::GameBoy::IoRegisters::incrementTimer() { if (timerEnabled()) { - if (--m_timerCounter == 0) { + if (--m_timerCounter <= 0) { m_timerCounter += m_timerRate; incrementTIMA(); } diff --git a/LR35902/src/LR35902.cpp b/LR35902/src/LR35902.cpp index 81ee835..2b10635 100644 --- a/LR35902/src/LR35902.cpp +++ b/LR35902/src/LR35902.cpp @@ -340,6 +340,7 @@ int EightBit::GameBoy::LR35902::step() { } } ExecutedInstruction.fire(*this); + assert(cycles() % 4 == 0); return cycles(); }