TasStateManager - capture every other frame for now

This commit is contained in:
adelikat 2014-08-27 20:43:45 +00:00
parent e65e9d8a22
commit bbc84471d8
1 changed files with 27 additions and 13 deletions

View File

@ -65,26 +65,40 @@ namespace BizHawk.Client.Common
/// <summary>
/// Requests that the current emulator state be captured
/// Unless force is true, the state may or may not be captured depending on the logic employed by "greenzone" management
/// </summary>
public void Capture()
public void Capture(bool force = false)
{
var frame = Global.Emulator.Frame;
var state = (byte[])Global.Emulator.SaveStateBinary().Clone();
if (States.ContainsKey(frame))
bool shouldCapture = false;
if (force)
{
States[frame] = state;
shouldCapture = force;
}
else
{
if (Used + state.Length >= Settings.Cap)
{
Used -= States.ElementAt(0).Value.Length;
States.RemoveAt(0);
}
shouldCapture = Global.Emulator.Frame % 2 > 0;
}
States.Add(frame, state);
Used += state.Length;
if (shouldCapture)
{
var frame = Global.Emulator.Frame;
var state = (byte[])Global.Emulator.SaveStateBinary().Clone();
if (States.ContainsKey(frame))
{
States[frame] = state;
}
else
{
if (Used + state.Length >= Settings.Cap)
{
Used -= States.ElementAt(0).Value.Length;
States.RemoveAt(0);
}
States.Add(frame, state);
Used += state.Length;
}
}
}