GB Video: Setting LYC=LY during mode 2 should trigger an IRQ

This commit is contained in:
Jeffrey Pfau 2016-09-20 10:44:49 -07:00
parent b4e0ab93fe
commit 4d75576229
2 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -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;