Atari - implement lag counter, refactor implementation of frame counter slightly, add frame and lag counters to savestates

This commit is contained in:
adelikat 2012-03-23 02:55:46 +00:00
parent 2e5ec4fdcb
commit bbf282e131
2 changed files with 16 additions and 6 deletions

View File

@ -92,6 +92,7 @@ namespace BizHawk
public void HardReset() public void HardReset()
{ {
_lagcount = 0;
cpu = new MOS6507(); cpu = new MOS6507();
//cpu.debug = true; //cpu.debug = true;
cpu.ReadMemory = ReadMemory; cpu.ReadMemory = ReadMemory;
@ -111,8 +112,8 @@ namespace BizHawk
public void FrameAdvance(bool render) public void FrameAdvance(bool render)
{ {
Frame++; _frame++;
_islag = true;
tia.frameComplete = false; tia.frameComplete = false;
while (tia.frameComplete == false) while (tia.frameComplete == false)
{ {
@ -133,6 +134,8 @@ namespace BizHawk
} }
if (_islag)
LagCount++;
//if (render == false) return; //if (render == false) return;
} }
@ -145,6 +148,7 @@ namespace BizHawk
if (Controller["P1 Left"]) value &= 0xBF; if (Controller["P1 Left"]) value &= 0xBF;
if (Controller["P1 Right"]) value &= 0x7F; if (Controller["P1 Right"]) value &= 0x7F;
if (Controller["P1 Button"]) value &= 0xF7; if (Controller["P1 Button"]) value &= 0xF7;
_islag = false;
return value; return value;
} }
@ -157,6 +161,7 @@ namespace BizHawk
if (Controller["P2 Left"]) value &= 0xBF; if (Controller["P2 Left"]) value &= 0xBF;
if (Controller["P2 Right"]) value &= 0x7F; if (Controller["P2 Right"]) value &= 0x7F;
if (Controller["P2 Button"]) value &= 0xF7; if (Controller["P2 Button"]) value &= 0xF7;
_islag = false;
return value; return value;
} }

View File

@ -26,7 +26,7 @@ namespace BizHawk
} }
public void ResetFrameCounter() public void ResetFrameCounter()
{ {
Frame = 0; _frame = 0;
} }
public static readonly ControllerDefinition Atari2600ControllerDefinition = new ControllerDefinition public static readonly ControllerDefinition Atari2600ControllerDefinition = new ControllerDefinition
@ -44,14 +44,19 @@ namespace BizHawk
{ {
cpu.SyncState(ser); cpu.SyncState(ser);
ser.Sync("ram", ref ram, false); ser.Sync("ram", ref ram, false);
ser.Sync("Lag", ref _lagcount);
ser.Sync("Frame", ref _frame);
} }
public ControllerDefinition ControllerDefinition { get { return Atari2600ControllerDefinition; } } public ControllerDefinition ControllerDefinition { get { return Atari2600ControllerDefinition; } }
public IController Controller { get; set; } public IController Controller { get; set; }
public int Frame { get; set; } public int Frame { get { return _frame; } set { _frame = value; } }
public int LagCount { get { return 0; } set { return; } } public int LagCount { get { return _lagcount; } set { _lagcount = value; } }
public bool IsLagFrame { get { return false; } } 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 byte[] SaveRam { get { return new byte[0]; } }
public bool DeterministicEmulation { get; set; } public bool DeterministicEmulation { get; set; }