BK2 - support loop offset

This commit is contained in:
adelikat 2014-06-14 18:52:00 +00:00
parent fed401164f
commit edacc9b8c8
4 changed files with 30 additions and 5 deletions

View File

@ -18,6 +18,7 @@ namespace BizHawk.Client.Common
public const string PAL = "PAL";
public const string BOARDNAME = "BoardName";
public const string SYNCSETTINGS = "SyncSettings";
public const string LOOPOFFSET = "LoopOffset";
// Core Setting
public const string CORE = "Core";

View File

@ -160,6 +160,32 @@ namespace BizHawk.Client.Common
set { Header[HeaderKeys.FIRMWARESHA1] = value; }
}
private int? LoopOffset
{
get
{
var offsetStr = Header[HeaderKeys.LOOPOFFSET];
if (!string.IsNullOrWhiteSpace(offsetStr))
{
return int.Parse(offsetStr);
}
return null;
}
set
{
if (value.HasValue)
{
Header[HeaderKeys.LOOPOFFSET] = value.ToString();
}
else
{
Header.Remove(HeaderKeys.LOOPOFFSET);
}
}
}
private string CommentsString()
{
StringBuilder sb = new StringBuilder();

View File

@ -160,7 +160,6 @@ namespace BizHawk.Client.Common
bs.PutLump(BinaryStateLump.Input, (tw) => tw.WriteLine(RawInputLog()));
if (StartsFromSavestate)
{
bs.PutLump(BinaryStateLump.CorestateText, (tw) => tw.WriteLine(SavestateBinaryBase64Blob));

View File

@ -14,7 +14,6 @@ namespace BizHawk.Client.Common
// Movies 2.0 TODO: save and load loopOffset, put in header object
private readonly PlatformFrameRates _frameRates = new PlatformFrameRates();
private bool _makeBackup = true;
private int? _loopOffset;
public Bk2Movie(string filename, bool startsFromSavestate = false)
: this(startsFromSavestate)
@ -45,7 +44,7 @@ namespace BizHawk.Client.Common
{
get
{
if (_loopOffset.HasValue)
if (LoopOffset.HasValue)
{
return double.PositiveInfinity;
}
@ -125,7 +124,7 @@ namespace BizHawk.Client.Common
int getframe;
if (_loopOffset.HasValue)
if (LoopOffset.HasValue)
{
if (frame < _log.Length)
{
@ -133,7 +132,7 @@ namespace BizHawk.Client.Common
}
else
{
getframe = ((frame - _loopOffset.Value) % (_log.Length - _loopOffset.Value)) + _loopOffset.Value;
getframe = ((frame - LoopOffset.Value) % (_log.Length - LoopOffset.Value)) + LoopOffset.Value;
}
}
else