diff --git a/CHANGES b/CHANGES index 47863f4fe..c7ca6135a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,7 @@ 0.5.1: (Future) Bugfixes: - GB MBC: Fix MBC7 when size is incorrectly specified + - GB Video: Setting LYC=LY during mode 2 should trigger an IRQ Misc: - All: Only update version info if needed diff --git a/src/gb/io.c b/src/gb/io.c index e09a33173..f79dd2647 100644 --- a/src/gb/io.c +++ b/src/gb/io.c @@ -341,7 +341,6 @@ void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) { case REG_SB: case REG_TIMA: case REG_TMA: - case REG_LYC: // Handled transparently by the registers break; case REG_TAC: @@ -357,6 +356,15 @@ void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) { value = gb->video.renderer->writeVideoRegister(gb->video.renderer, address, value); GBVideoWriteLCDC(&gb->video, value); break; + case REG_LYC: + if (gb->video.mode == 2) { + gb->video.stat = GBRegisterSTATSetLYC(gb->video.stat, value == gb->video.ly); + if (GBRegisterSTATIsLYCIRQ(gb->video.stat) && value == gb->video.ly) { + gb->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT); + GBUpdateIRQs(gb->video.p); + } + } + break; case REG_DMA: GBMemoryDMA(gb, value << 8); break;