2013-12-01 20:55:52 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Client.Common
|
|
|
|
|
{
|
2013-12-02 04:24:45 +00:00
|
|
|
|
public class MovieRecord : IMovieRecord
|
2013-12-01 20:55:52 +00:00
|
|
|
|
{
|
2013-12-06 15:47:23 +00:00
|
|
|
|
private MnemonicsGenerator _mg;
|
|
|
|
|
private byte[] _state;
|
|
|
|
|
|
|
|
|
|
public string Input { get; private set; }
|
2013-12-01 20:55:52 +00:00
|
|
|
|
|
|
|
|
|
public bool Lagged { get; private set; }
|
|
|
|
|
public IEnumerable<byte> State
|
|
|
|
|
{
|
|
|
|
|
get { return _state; }
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-06 15:47:23 +00:00
|
|
|
|
public void SetInput(MnemonicsGenerator mg)
|
2013-12-01 20:55:52 +00:00
|
|
|
|
{
|
2013-12-06 15:47:23 +00:00
|
|
|
|
_mg = mg;
|
|
|
|
|
}
|
2013-12-01 20:55:52 +00:00
|
|
|
|
|
2013-12-06 15:47:23 +00:00
|
|
|
|
public void ClearInput()
|
|
|
|
|
{
|
|
|
|
|
_mg = new MnemonicsGenerator();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MovieRecord(MnemonicsGenerator mg, bool captureState)
|
|
|
|
|
{
|
|
|
|
|
_mg = mg;
|
|
|
|
|
if (captureState)
|
|
|
|
|
{
|
|
|
|
|
Lagged = Global.Emulator.IsLagFrame;
|
|
|
|
|
_state = Global.Emulator.SaveStateBinary();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool HasState
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return State.Count() > 0;
|
|
|
|
|
}
|
2013-12-01 20:55:52 +00:00
|
|
|
|
}
|
2013-12-02 04:24:45 +00:00
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
//TODO: consider the fileformat of binary and lagged data
|
|
|
|
|
return Input;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class MovieRecordList : List<MovieRecord>
|
|
|
|
|
{
|
2013-12-02 14:59:38 +00:00
|
|
|
|
public MovieRecordList()
|
|
|
|
|
: base()
|
|
|
|
|
{
|
|
|
|
|
|
2013-12-04 03:04:29 +00:00
|
|
|
|
}
|
2013-12-02 14:59:38 +00:00
|
|
|
|
|
2013-12-02 04:24:45 +00:00
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
var sb = new StringBuilder();
|
2013-12-02 14:59:38 +00:00
|
|
|
|
sb
|
|
|
|
|
.AppendLine("[Input]")
|
2013-12-04 03:04:29 +00:00
|
|
|
|
|
2013-12-04 00:31:50 +00:00
|
|
|
|
.Append("Frame ")
|
|
|
|
|
.Append(Global.Emulator.Frame)
|
2013-12-02 14:59:38 +00:00
|
|
|
|
.AppendLine();
|
|
|
|
|
|
2013-12-02 04:24:45 +00:00
|
|
|
|
foreach (var record in this)
|
|
|
|
|
{
|
|
|
|
|
sb.AppendLine(record.ToString());
|
|
|
|
|
}
|
2013-12-02 14:59:38 +00:00
|
|
|
|
sb.AppendLine("[/Input]");
|
2013-12-02 04:24:45 +00:00
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
2013-12-03 01:43:02 +00:00
|
|
|
|
|
|
|
|
|
public void Truncate(int index)
|
|
|
|
|
{
|
|
|
|
|
if (index < Count)
|
|
|
|
|
{
|
|
|
|
|
RemoveRange(index, Count - index);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-01 20:55:52 +00:00
|
|
|
|
}
|
|
|
|
|
}
|