TAStudio - store whether or not a frame was a lag frame along with the state for green zoning, show lag frames in red based on this flag rather than something recorded into the movie file, also fixed a bug I introduced in the last commit

This commit is contained in:
adelikat 2012-09-03 21:28:10 +00:00
parent ac91ed67a6
commit 80012d29c6
3 changed files with 54 additions and 18 deletions

View File

@ -441,6 +441,11 @@ namespace BizHawk.MultiClient
#region Public Misc Methods
public bool FrameLagged(int frame)
{
return Log.FrameLagged(frame);
}
public void CaptureState()
{
if (StateCapturing == true)

View File

@ -51,7 +51,14 @@ namespace BizHawk.MultiClient
{
get
{
return StateRecords.Count * StateRecords[0].State.Length;
if (StateRecords.Count > 0)
{
return StateCount * StateRecords[0].State.Length;
}
else
{
return 0;
}
}
}
@ -84,7 +91,7 @@ namespace BizHawk.MultiClient
if (Global.Emulator.Frame < StateFirstIndex)
{
StateRecords.Clear();
StateRecords.Add(new StateRecordStruct(Global.Emulator.Frame, state));
StateRecords.Add(new StateRecord(Global.Emulator.Frame, state));
}
if (Global.Emulator.Frame > StateLastIndex)
{
@ -93,7 +100,7 @@ namespace BizHawk.MultiClient
// Discard the oldest state to save space.
StateRecords.RemoveAt(0);
}
StateRecords.Add(new StateRecordStruct(Global.Emulator.Frame,state));
StateRecords.Add(new StateRecord(Global.Emulator.Frame,state));
}
}
@ -169,11 +176,11 @@ namespace BizHawk.MultiClient
}
}
public string GetFrame(int frameCount)
public string GetFrame(int frame)
{
if (frameCount >= 0 && frameCount < MovieRecords.Count)
if (frame >= 0 && frame < MovieRecords.Count)
{
return MovieRecords[frameCount];
return MovieRecords[frame];
}
else
{
@ -198,24 +205,38 @@ namespace BizHawk.MultiClient
}
}
public bool FrameLagged(int frame)
{
if (frame >= StateFirstIndex && frame <= StateLastIndex)
{
return StateRecords[frame].Lagged;
}
else
{
return false;
}
}
#endregion
#region private fields
private class StateRecordStruct
private class StateRecord
{
public StateRecordStruct(int index, byte[] state)
public StateRecord(int index, byte[] state)
{
this.Index = index;
this.State = state;
Index = index;
State = state;
Lagged = Global.Emulator.IsLagFrame;
}
public int Index;
public byte[] State;
public bool Lagged;
}
private List<string> MovieRecords = new List<string>();
private List<StateRecordStruct> StateRecords = new List<StateRecordStruct>();
private List<StateRecord> StateRecords = new List<StateRecord>();
//TODO: Make this size limit configurable by the user
private int MaxStateRecordSize = 1024 * 1024 * 1024; //To limit memory usage.

View File

@ -117,7 +117,9 @@ namespace BizHawk.MultiClient
//TODO: remove this hack with a nes controls pad
if (Global.Emulator.SystemId == "NES")
{
str.Append("0|");
}
for (int x = 0; x < Pads.Count; x++)
str.Append(Pads[x].GetMnemonic());
@ -126,15 +128,23 @@ namespace BizHawk.MultiClient
private void TASView_QueryItemBkColor(int index, int column, ref Color color)
{
if (0 == index && 0 == Global.MovieSession.Movie.StateFirstIndex)
if (index == 0 && Global.MovieSession.Movie.StateFirstIndex == 0)
{
color = Color.LightGreen; //special case for frame 0. Normally we need to go back an extra frame, but for frame 0 we can reload the rom.
if (index > Global.MovieSession.Movie.StateFirstIndex && index <= Global.MovieSession.Movie.StateLastIndex)
color = Color.LightGreen;
if ("" != Global.MovieSession.Movie.GetInput(index) &&
Global.COMMANDS[Global.MovieInputSourceAdapter.Type.Name].ContainsKey("Lag") &&
Global.MovieSession.Movie.GetInput(index)[1] == Global.COMMANDS[Global.MovieInputSourceAdapter.Type.Name]["Lag"][0])
}
else if (Global.MovieSession.Movie.FrameLagged(index))
{
color = Color.Pink;
if (index == Global.Emulator.Frame)
//TODO: remove references to this lag
//Global.COMMANDS[Global.MovieInputSourceAdapter.Type.Name].ContainsKey("Lag") &&
//Global.MovieSession.Movie.GetInput(index)[1] == Global.COMMANDS[Global.MovieInputSourceAdapter.Type.Name]["Lag"][0])
}
else if (index > Global.MovieSession.Movie.StateFirstIndex && index <= Global.MovieSession.Movie.StateLastIndex)
{
color = Color.LightGreen;
}
else if (index == Global.Emulator.Frame)
{
color = Color.LightBlue;
}