improve rewind in tastudio by leaving editmode intact but taking care not to clobber frames. take special pains to ensure that (reverse) frame progress vs smooth rewind semantics stay as expected.
This commit is contained in:
parent
885a57d91e
commit
f458648fad
|
@ -1370,6 +1370,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private bool _runloopFrameProgress;
|
||||
private long _frameAdvanceTimestamp;
|
||||
private long _frameRewindTimestamp;
|
||||
private bool _frameRewindWasPaused;
|
||||
private bool _runloopFrameadvance;
|
||||
private bool _lastFastForwardingOrRewinding;
|
||||
private bool _inResizeLoop;
|
||||
|
@ -4121,13 +4122,25 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
isRewinding = true;
|
||||
_frameRewindTimestamp = currentTimestamp;
|
||||
_frameRewindWasPaused = EmulatorPaused;
|
||||
}
|
||||
else
|
||||
{
|
||||
double timestampDeltaMs = (double)(currentTimestamp - _frameRewindTimestamp) / Stopwatch.Frequency * 1000.0;
|
||||
isRewinding = timestampDeltaMs >= Global.Config.FrameProgressDelayMs;
|
||||
|
||||
//clear this flag once we get out of the progress stage
|
||||
if (isRewinding)
|
||||
_frameRewindWasPaused = false;
|
||||
|
||||
//if we're freely running, there's no need for reverse frame progress semantics (that may be debateable though)
|
||||
if (!EmulatorPaused) isRewinding = true;
|
||||
|
||||
if (_frameRewindWasPaused)
|
||||
if (IsSeeking) isRewinding = false;
|
||||
}
|
||||
|
||||
|
||||
if (isRewinding)
|
||||
{
|
||||
runFrame = true; // TODO: the master should be deciding this!
|
||||
|
|
|
@ -94,6 +94,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
StopSeeking(); //late breaking memo: dont know whether this is needed
|
||||
GoToPreviousFrame();
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -59,6 +59,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private bool? _autoRestorePaused = null;
|
||||
private int? _seekStartFrame = null;
|
||||
private bool _wasRecording = false;
|
||||
private bool _shouldUnpauseFromRewind = false;
|
||||
|
||||
private Emulation.Common.ControllerDefinition controllerType
|
||||
{ get { return Global.MovieSession.MovieControllerAdapter.Definition; } }
|
||||
|
@ -105,6 +106,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
_wasRecording = false;
|
||||
}
|
||||
Mainform.PauseOnFrame = null;
|
||||
if (_shouldUnpauseFromRewind)
|
||||
{
|
||||
Mainform.UnpauseEmulator();
|
||||
_shouldUnpauseFromRewind = false;
|
||||
}
|
||||
if (CurrentTasMovie != null)
|
||||
RefreshDialog();
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
// SuuperW: I changed this to public so that it could be used by MarkerControl.cs
|
||||
public void GoToFrame(int frame, bool fromLua = false)
|
||||
public void GoToFrame(int frame, bool fromLua = false, bool fromRewinding = false)
|
||||
{
|
||||
// If seeking to a frame before or at the end of the movie, use StartAtNearestFrameAndEmulate
|
||||
// Otherwise, load the latest state (if not already there) and seek while recording.
|
||||
|
@ -38,7 +38,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (frame <= CurrentTasMovie.InputLogLength)
|
||||
{
|
||||
// Get as close as we can then emulate there
|
||||
StartAtNearestFrameAndEmulate(frame, fromLua);
|
||||
StartAtNearestFrameAndEmulate(frame, fromLua, fromRewinding);
|
||||
|
||||
MaybeFollowCursor();
|
||||
}
|
||||
|
|
|
@ -807,11 +807,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
//_autoRestoreFrame = null;
|
||||
}
|
||||
|
||||
private void StartAtNearestFrameAndEmulate(int frame, bool fromLua)
|
||||
private void StartAtNearestFrameAndEmulate(int frame, bool fromLua, bool fromRewinding)
|
||||
{
|
||||
if (frame == Emulator.Frame)
|
||||
return;
|
||||
|
||||
_shouldUnpauseFromRewind = fromRewinding && !Mainform.EmulatorPaused;
|
||||
_wasRecording = CurrentTasMovie.IsRecording || _wasRecording;
|
||||
TastudioPlayMode();
|
||||
KeyValuePair<int, byte[]> closestState = CurrentTasMovie.TasStateManager.GetStateClosestToFrame(frame);
|
||||
|
@ -845,17 +846,18 @@ namespace BizHawk.Client.EmuHawk
|
|||
//now the next section won't happen since we're at the right spot
|
||||
}
|
||||
|
||||
// frame == Emualtor.Frame when frame == 0
|
||||
// frame == Emulator.Frame when frame == 0
|
||||
if (frame > Emulator.Frame)
|
||||
{
|
||||
if (Mainform.EmulatorPaused || Mainform.IsSeeking) // make seek frame keep up with emulation on fast scrolls
|
||||
if (Mainform.EmulatorPaused || Mainform.IsSeeking || fromRewinding) // make seek frame keep up with emulation on fast scrolls
|
||||
{
|
||||
StartSeeking(frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
//GUI users hand need to be protected from clobbering their video when skipping around
|
||||
//so we don't re-enable recording
|
||||
//GUI users may want to be protected from clobbering their video when skipping around...
|
||||
//well, users who are rewinding arent. (that gets done through the seeking system in the call above)
|
||||
//users who are clicking around.. I dont know.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue