diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.Core.cs b/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.Core.cs index 5095bca8ed..2660a40796 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.Core.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.Core.cs @@ -92,6 +92,7 @@ namespace BizHawk public void HardReset() { + _lagcount = 0; cpu = new MOS6507(); //cpu.debug = true; cpu.ReadMemory = ReadMemory; @@ -111,8 +112,8 @@ namespace BizHawk public void FrameAdvance(bool render) { - Frame++; - + _frame++; + _islag = true; tia.frameComplete = false; while (tia.frameComplete == false) { @@ -133,6 +134,8 @@ namespace BizHawk } + if (_islag) + LagCount++; //if (render == false) return; } @@ -145,6 +148,7 @@ namespace BizHawk if (Controller["P1 Left"]) value &= 0xBF; if (Controller["P1 Right"]) value &= 0x7F; if (Controller["P1 Button"]) value &= 0xF7; + _islag = false; return value; } @@ -157,6 +161,7 @@ namespace BizHawk if (Controller["P2 Left"]) value &= 0xBF; if (Controller["P2 Right"]) value &= 0x7F; if (Controller["P2 Button"]) value &= 0xF7; + _islag = false; return value; } diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.cs b/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.cs index 2c8478e009..07f6357bd7 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.cs @@ -26,7 +26,7 @@ namespace BizHawk } public void ResetFrameCounter() { - Frame = 0; + _frame = 0; } public static readonly ControllerDefinition Atari2600ControllerDefinition = new ControllerDefinition @@ -44,14 +44,19 @@ namespace BizHawk { cpu.SyncState(ser); ser.Sync("ram", ref ram, false); + ser.Sync("Lag", ref _lagcount); + ser.Sync("Frame", ref _frame); } public ControllerDefinition ControllerDefinition { get { return Atari2600ControllerDefinition; } } public IController Controller { get; set; } - public int Frame { get; set; } - public int LagCount { get { return 0; } set { return; } } - public bool IsLagFrame { get { return false; } } + public int Frame { get { return _frame; } set { _frame = value; } } + public int LagCount { get { return _lagcount; } set { _lagcount = value; } } + public bool IsLagFrame { get { return _islag; } } + private bool _islag = true; + private int _lagcount = 0; + private int _frame = 0; public byte[] SaveRam { get { return new byte[0]; } } public bool DeterministicEmulation { get; set; }