From bd3ee6f45cd1a5287d5fc3708eab8ab235c0d725 Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Sat, 24 Oct 2020 21:46:31 -0400 Subject: [PATCH] GBHawk: don't clear timer/serial interrupts when they happen at the same time as a set --- .../Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs | 6 +++--- .../Consoles/Nintendo/GBHawk/Timer.cs | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs index b14ca47467..4c07f8dd95 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/GBHawk.IEmulator.cs @@ -364,9 +364,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public void SetIntRegs(byte r) { // For timer interrupts or serial interrupts that occur on the same cycle as the IRQ clear - // the clear wins on GB but the set wins on GBC - if (((REG_FF0F & 4) == 4) && ((r & 4) == 0) && timer.IRQ_block && !is_GBC) { r |= 4; } - if (((REG_FF0F & 8) == 8) && ((r & 8) == 0) && serialport.IRQ_block && !is_GBC) { r |= 8; } + // the cear wins on GB and GBA (tested on GBP.) Assuming true for GBC E too. + if (((REG_FF0F & 4) == 4) && ((r & 4) == 0) && timer.IRQ_block) { r |= 4; } + if (((REG_FF0F & 8) == 8) && ((r & 8) == 0) && serialport.IRQ_block) { r |= 8; } REG_FF0F = r; } diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs index d6febab9e7..34316d7243 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs @@ -7,8 +7,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk // Timer Emulation // NOTES: // - // For GB, it looks like divider reg should start at 1 on reset. - // for GBC, a starting value of 0xFFFF passes all tests. GBA is not explicitly tested but for now is set to 0xFFFF as well. + // Currently, a starting value of 0xFFFE passes all tests. GBA is not explicitly tested but for now is set to 0xFFFE as well. // // Some additional glitches happen on GBC, but they are non-deterministic and not emulated here // @@ -29,7 +28,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk public byte timer_old; public byte timer_control; public byte pending_reload; - public bool IRQ_block; // if the timer IRQ happens on the same cycle as a previous one was cleared, the IRQ is blocked, only on GBC + public bool IRQ_block; // if the timer IRQ happens on the same cycle as a previous one was cleared, the IRQ is set public bool old_state; public bool state; public bool reload_block;