From 148f6d4332232df0727a91ca1699930f9e257361 Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Tue, 15 May 2018 15:50:33 -0400 Subject: [PATCH] GBHawk: Timer work --- .../Consoles/Nintendo/GBHawk/Timer.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs index 4107a8da63..5f3fb8e9ce 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBHawk/Timer.cs @@ -93,10 +93,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk write_ignore = 4; TMA_coincidence = true; - } - else if (pending_reload == 1 && !reload_block) - { - // set interrupts if (Core.REG_FFFF.Bit(2)) { Core.cpu.FlagI = true; } Core.REG_FF0F |= 0x04; @@ -135,11 +131,20 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk timer_old = timer; timer++; - // if overflow, set the interrupt flag and reload the timer (4 clocks later) + // if overflow happens, set the interrupt flag and reload the timer (if applicable) if (timer < timer_old) { - pending_reload = 4; - reload_block = false; + if (timer_control.Bit(2)) + { + pending_reload = 4; + reload_block = false; + } + else + { + //TODO: Check if timer still gets reloaded if TAC diabled causes overflow + if (Core.REG_FFFF.Bit(2)) { Core.cpu.FlagI = true; } + Core.REG_FF0F |= 0x04; + } } }