From ec306ce40690889c0960128661067e30de2d01e4 Mon Sep 17 00:00:00 2001 From: Sour Date: Thu, 4 Apr 2019 17:50:23 -0400 Subject: [PATCH] IRQ: Enabling vertical irqs on the scanline that matches the settings should trigger an IRQ right away --- Core/InternalRegisters.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Core/InternalRegisters.cpp b/Core/InternalRegisters.cpp index 2522bad..6fc0f8d 100644 --- a/Core/InternalRegisters.cpp +++ b/Core/InternalRegisters.cpp @@ -128,6 +128,11 @@ void InternalRegisters::Write(uint16_t addr, uint8_t value) { switch(addr) { case 0x4200: + if((value & 0x20) && !_enableVerticalIrq && _console->GetPpu()->GetScanline() == _verticalTimer) { + //When enabling vertical irqs, if the current scanline matches the target scanline, set the irq flag right away + _console->GetCpu()->SetIrqSource(IrqSource::Ppu); + } + _enableNmi = (value & 0x80) != 0; _enableVerticalIrq = (value & 0x20) != 0; _enableHorizontalIrq = (value & 0x10) != 0; @@ -136,7 +141,7 @@ void InternalRegisters::Write(uint16_t addr, uint8_t value) //TODO VERIFY _console->GetCpu()->ClearIrqSource(IrqSource::Ppu); } - + _enableAutoJoypadRead = (value & 0x01) != 0; break;