add TargetFrameLength to rewind settings

This commit is contained in:
adelikat 2020-06-19 15:58:18 -05:00
parent 4978fe4b92
commit da59add3f6
3 changed files with 24 additions and 8 deletions

View File

@ -2,9 +2,26 @@
{
public interface IRewindSettings
{
public bool UseCompression { get; }
/// <summary>
/// Gets a value indicating whether or not to enable rewinding
/// </summary>
public bool Enabled { get; }
/// <summary>
/// Gets a value indicating whether or not to compress savestates before storing them
/// </summary>
public bool UseCompression { get; }
/// <summary>
/// Max amount of buffer space to use in MB
/// </summary>
public int BufferSize { get; }
/// <summary>
/// Desired frame length (number of emulated frames you can go back before running out of buffer)
/// </summary>
public int TargetFrameLength { get; }
}
public class RewindConfig : IRewindSettings
@ -12,5 +29,6 @@
public bool UseCompression { get; set; }
public bool Enabled { get; set; } = true;
public int BufferSize { get; set; } = 512; // in mb
public int TargetFrameLength { get; set; } = 600;
}
}

View File

@ -19,22 +19,20 @@ namespace BizHawk.Client.Common
maintain a separate rewinder alongside this one that is customized for those cores.
*/
/// <param name="targetSize">size of rewinder backing store in bytes</param>
/// <param name="targetFrameLength">desired frame length (number of emulated frames you can go back before running out of buffer)</param>
public Zwinder(int targetFrameLength, IBinaryStateable stateSource, IRewindSettings settings)
public Zwinder(IBinaryStateable stateSource, IRewindSettings settings)
{
long targetSize = settings.BufferSize * 1024 * 1024;
if (targetSize < 65536)
throw new ArgumentOutOfRangeException(nameof(targetSize));
if (targetFrameLength < 1)
throw new ArgumentOutOfRangeException(nameof(targetFrameLength));
if (settings.TargetFrameLength < 1)
throw new ArgumentOutOfRangeException(nameof(settings.TargetFrameLength));
Size = 1L << (int)Math.Floor(Math.Log(targetSize, 2));
_sizeMask = Size - 1;
_buffer = new byte[Size];
Active = true;
_stateSource = stateSource;
_targetFrameLength = targetFrameLength;
_targetFrameLength = settings.TargetFrameLength;
_states = new StateInfo[STATEMASK + 1];
_kompress = settings.UseCompression;
}

View File

@ -866,7 +866,7 @@ namespace BizHawk.Client.EmuHawk
{
Rewinder?.Dispose();
Rewinder = Emulator.HasSavestates() && Config.Rewind.Enabled
? new Zwinder(600, Emulator.AsStatable(), Config.Rewind)
? new Zwinder(Emulator.AsStatable(), Config.Rewind)
: null;
}