Rewind: Re-order some methods (no code change).
This commit is contained in:
parent
3f776dbf6f
commit
eadea2481e
|
@ -57,26 +57,6 @@ namespace BizHawk.Client.Common
|
||||||
get { return Global.Config.RewindEnabledLarge || Global.Config.RewindEnabledMedium || Global.Config.RewindEnabledSmall; }
|
get { return Global.Config.RewindEnabledLarge || Global.Config.RewindEnabledMedium || Global.Config.RewindEnabledSmall; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Capture()
|
|
||||||
{
|
|
||||||
if (!IsRewindEnabledAtAll || !Global.Emulator.HasSavestates())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_rewindThread == null)
|
|
||||||
{
|
|
||||||
Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_rewindThread == null || Global.Emulator.Frame % _rewindFrequency != 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_rewindThread.Capture(Global.Emulator.AsStatable().SaveStateBinary());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
|
@ -121,46 +101,6 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Rewind(int frames)
|
|
||||||
{
|
|
||||||
if (!Global.Emulator.HasSavestates() || _rewindThread == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_rewindThread.Rewind(frames);
|
|
||||||
|
|
||||||
return _lastRewindLoadedState;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RewindInternal(int frames)
|
|
||||||
{
|
|
||||||
_lastRewindLoadedState = false;
|
|
||||||
|
|
||||||
for (int i = 0; i < frames; i++)
|
|
||||||
{
|
|
||||||
if (_rewindBuffer.Count <= 1 || (Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.InputLogLength == 0))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadPreviousState();
|
|
||||||
_lastRewindLoadedState = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CaptureInternal(byte[] coreSavestate)
|
|
||||||
{
|
|
||||||
if (_rewindDeltaEnable)
|
|
||||||
{
|
|
||||||
CaptureStateDelta(coreSavestate);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CaptureStateNonDelta(coreSavestate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
if (_rewindThread != null)
|
if (_rewindThread != null)
|
||||||
|
@ -254,6 +194,38 @@ namespace BizHawk.Client.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Capture()
|
||||||
|
{
|
||||||
|
if (!IsRewindEnabledAtAll || !Global.Emulator.HasSavestates())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_rewindThread == null)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_rewindThread == null || Global.Emulator.Frame % _rewindFrequency != 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_rewindThread.Capture(Global.Emulator.AsStatable().SaveStateBinary());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CaptureInternal(byte[] coreSavestate)
|
||||||
|
{
|
||||||
|
if (_rewindDeltaEnable)
|
||||||
|
{
|
||||||
|
CaptureStateDelta(coreSavestate);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CaptureStateNonDelta(coreSavestate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void CaptureStateNonDelta(byte[] state)
|
private void CaptureStateNonDelta(byte[] state)
|
||||||
{
|
{
|
||||||
long offset = _rewindBuffer.Enqueue(0, state.Length + 1);
|
long offset = _rewindBuffer.Enqueue(0, state.Length + 1);
|
||||||
|
@ -352,6 +324,34 @@ namespace BizHawk.Client.Common
|
||||||
UpdateLastState(currentState);
|
UpdateLastState(currentState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Rewind(int frames)
|
||||||
|
{
|
||||||
|
if (!Global.Emulator.HasSavestates() || _rewindThread == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_rewindThread.Rewind(frames);
|
||||||
|
|
||||||
|
return _lastRewindLoadedState;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RewindInternal(int frames)
|
||||||
|
{
|
||||||
|
_lastRewindLoadedState = false;
|
||||||
|
|
||||||
|
for (int i = 0; i < frames; i++)
|
||||||
|
{
|
||||||
|
if (_rewindBuffer.Count <= 1 || (Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.InputLogLength == 0))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadPreviousState();
|
||||||
|
_lastRewindLoadedState = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private MemoryStream GetPreviousStateMemoryStream()
|
private MemoryStream GetPreviousStateMemoryStream()
|
||||||
{
|
{
|
||||||
if (_rewindDeltaEnable)
|
if (_rewindDeltaEnable)
|
||||||
|
|
Loading…
Reference in New Issue