From 6edccc00b975b0a7cea03afb12f554609e4548bb Mon Sep 17 00:00:00 2001 From: Sour Date: Sun, 31 May 2020 15:31:35 -0400 Subject: [PATCH] GB: Update coincidence flag and STAT IRQ when writing to LYC Fixes ly_lyc_153_write-GS --- Core/GbPpu.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Core/GbPpu.cpp b/Core/GbPpu.cpp index d4a1703..13268d2 100644 --- a/Core/GbPpu.cpp +++ b/Core/GbPpu.cpp @@ -726,7 +726,15 @@ void GbPpu::Write(uint16_t addr, uint8_t value) case 0xFF42: _state.ScrollY = value; break; case 0xFF43: _state.ScrollX = value; break; - case 0xFF45: _state.LyCompare = value; _state.IdleCycles = 0; break; + case 0xFF45: + _state.LyCompare = value; + if(_state.LcdEnabled) { + _state.IdleCycles = 0; + _state.LyCoincidenceFlag = (_state.LyCompare == _state.LyForCompare); + UpdateStatIrq(); + } + break; + case 0xFF47: _state.BgPalette = value; break; case 0xFF48: _state.ObjPalette0 = value; break; case 0xFF49: _state.ObjPalette1 = value; break;