From 7df8ed1f27bf9331b13505d57bb5d92eeb0ea280 Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Sat, 13 Jul 2019 18:33:54 -0400 Subject: [PATCH] A2600: Add HMCLR delay --- .../Consoles/Atari/2600/Tia/TIA.cs | 27 ++++++++++++++----- .../Consoles/Atari/2600/Tia/Tia.SyncState.cs | 2 ++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/TIA.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/TIA.cs index d7b2901d1e..225139911a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/TIA.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/TIA.cs @@ -104,6 +104,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 private int _hmbDelay; private byte _hmbVal; + private int _hmClrDelay; + private int _prg0Delay; private int _prg1Delay; private byte _prg0Val; @@ -387,6 +389,21 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } } + if (_hmClrDelay > 0) + { + _hmClrDelay++; + if (_hmClrDelay == 5) + { + _hmClrDelay = 0; + + _player0.HM = 0; + _player0.Missile.Hm = 0; + _player1.HM = 0; + _player1.Missile.Hm = 0; + _ball.HM = 0; + } + } + // Reset the RDY flag when we reach hblank if (_hsyncCnt <= 0) { @@ -799,7 +816,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 _hmove.BallLatch = true; _hmove.BallCnt = 0; - _hmove.LateHBlankReset = true; + if (_hsyncCnt < 67) { _hmove.LateHBlankReset = true; } } } @@ -1357,11 +1374,9 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 } else if (maskedAddr == 0x2B) // HMCLR { - _player0.HM = 0; - _player0.Missile.Hm = 0; - _player1.HM = 0; - _player1.Missile.Hm = 0; - _ball.HM = 0; + _hmClrDelay = 1; + + } else if (maskedAddr == 0x2C) // CXCLR { diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.SyncState.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.SyncState.cs index 252f74e644..8881944917 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.SyncState.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Tia/Tia.SyncState.cs @@ -51,6 +51,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 ser.Sync("hmb_delay", ref _hmbDelay); ser.Sync("hmb_val", ref _hmbVal); + ser.Sync("_hmClrDelay", ref _hmClrDelay); + ser.Sync("PRG0_delay", ref _prg0Delay); ser.Sync("PRG1_delay", ref _prg1Delay); ser.Sync("PRG0_val", ref _prg0Val);