GB: PPU - Implement STAT bug emulation

Fixes Zerd no Densetsu and Road Rash
This commit is contained in:
Sour 2020-05-31 16:20:29 -04:00
parent 6edccc00b9
commit 67f000c18c

View file

@ -274,7 +274,13 @@ void GbPpu::ProcessVisibleScanline()
_spriteCount = 0;
_state.LyForCompare = _state.Scanline;
_state.Mode = PpuMode::OamEvaluation;
_state.IrqMode = PpuMode::OamEvaluation; //TODO set to noirq?
_state.IrqMode = PpuMode::OamEvaluation;
break;
case 5:
//Turning on OAM IRQs in the middle of evaluation has no effect?
//Or is this a patch to get the proper behavior for the STAT write bug?
_state.IrqMode = PpuMode::NoIrq;
break;
case 84:
@ -720,7 +726,14 @@ void GbPpu::Write(uint16_t addr, uint8_t value)
break;
case 0xFF41:
_state.Status = value & 0xF8;
if(!_gameboy->IsCgb()) {
//STAT write bug (DMG ONLY)
//Writing to STAT causes all IRQ types to be turned on for a single cycle
_state.Status = 0xF8 | (_state.Status & 0x07);
UpdateStatIrq();
}
_state.Status = value & 0xF8;
UpdateStatIrq();
break;