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 575a37fd83
commit 1cb054ec67
4 changed files with 15 additions and 1 deletions

View File

@ -1,6 +1,7 @@
0.6.0: (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,9 @@ 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:
GBVideoWriteLYC(&gb->video, value);
break;
case REG_DMA:
GBMemoryDMA(gb, value << 8);
break;

View File

@ -312,6 +312,16 @@ void GBVideoWriteSTAT(struct GBVideo* video, GBRegisterSTAT value) {
}
}
void GBVideoWriteLYC(struct GBVideo* video, uint8_t value) {
if (video->mode == 2) {
video->stat = GBRegisterSTATSetLYC(video->stat, value == video->ly);
if (GBRegisterSTATIsLYCIRQ(video->stat) && value == video->ly) {
video->p->memory.io[REG_IF] |= (1 << GB_IRQ_LCDSTAT);
GBUpdateIRQs(video->p);
}
}
}
void GBVideoWritePalette(struct GBVideo* video, uint16_t address, uint8_t value) {
static const uint16_t dmgPalette[4] = { 0x7FFF, 0x56B5, 0x294A, 0x0000};
if (video->p->model < GB_MODEL_CGB) {

View File

@ -135,6 +135,7 @@ void GBVideoProcessDots(struct GBVideo* video);
void GBVideoWriteLCDC(struct GBVideo* video, GBRegisterLCDC value);
void GBVideoWriteSTAT(struct GBVideo* video, GBRegisterSTAT value);
void GBVideoWriteLYC(struct GBVideo* video, uint8_t value);
void GBVideoWritePalette(struct GBVideo* video, uint16_t address, uint8_t value);
void GBVideoSwitchBank(struct GBVideo* video, uint8_t value);