tastudio: refactor restore logic again, fixes some more bugs

(_autoRestoreFrame completely replaced by LastPositionFrame)
This commit is contained in:
feos 2016-11-21 23:59:12 +03:00
parent 0e9e4cc034
commit f59ebfe126
4 changed files with 19 additions and 89 deletions

View File

@ -56,7 +56,6 @@ namespace BizHawk.Client.EmuHawk
} }
private bool _triggerAutoRestore; // If true, autorestore will be called on mouse up private bool _triggerAutoRestore; // If true, autorestore will be called on mouse up
private int? _autoRestoreFrame; // The frame auto-restore will restore to, if set
private bool? _autoRestorePaused = null; private bool? _autoRestorePaused = null;
private int? _seekStartFrame = null; private int? _seekStartFrame = null;
private bool _wasRecording = false; private bool _wasRecording = false;
@ -71,13 +70,6 @@ namespace BizHawk.Client.EmuHawk
{ {
if (Global.Emulator.Frame > CurrentTasMovie.LastValidFrame) if (Global.Emulator.Frame > CurrentTasMovie.LastValidFrame)
{ {
if (_autoRestorePaused == null)
{
_autoRestorePaused = Mainform.EmulatorPaused;
if (Mainform.IsSeeking) // If seeking, do not shorten seek.
_autoRestoreFrame = Mainform.PauseOnFrame;
}
GoToLastEmulatedFrameIfNecessary(CurrentTasMovie.LastValidFrame); GoToLastEmulatedFrameIfNecessary(CurrentTasMovie.LastValidFrame);
} }
} }
@ -105,7 +97,7 @@ namespace BizHawk.Client.EmuHawk
TastudioRecordMode(); TastudioRecordMode();
_wasRecording = false; _wasRecording = false;
} }
Mainform.PauseOnFrame = null;
if (CurrentTasMovie != null) if (CurrentTasMovie != null)
RefreshDialog(); RefreshDialog();
} }
@ -494,15 +486,6 @@ namespace BizHawk.Client.EmuHawk
{ {
bool wasPaused = Mainform.EmulatorPaused; bool wasPaused = Mainform.EmulatorPaused;
if (Emulator.Frame > frame || CurrentTasMovie.LastValidFrame > frame)
{
if (wasPaused && !Mainform.IsSeeking && !CurrentTasMovie.LastPositionStable)
{
LastPositionFrame = Emulator.Frame;
CurrentTasMovie.LastPositionStable = true; // until new frame is emulated
}
}
if (Global.MovieSession.MovieControllerAdapter.Type.BoolButtons.Contains(buttonName)) if (Global.MovieSession.MovieControllerAdapter.Type.BoolButtons.Contains(buttonName))
{ {
CurrentTasMovie.ChangeLog.BeginNewBatch("Paint Bool " + buttonName + " from frame " + frame); CurrentTasMovie.ChangeLog.BeginNewBatch("Paint Bool " + buttonName + " from frame " + frame);

View File

@ -415,14 +415,7 @@ namespace BizHawk.Client.EmuHawk
if (needsToRollback) if (needsToRollback)
{ {
GoToLastEmulatedFrameIfNecessary(TasView.FirstSelectedIndex.Value); GoToLastEmulatedFrameIfNecessary(TasView.FirstSelectedIndex.Value);
if (wasPaused) DoAutoRestore();
{
DoAutoRestore();
}
else
{
Mainform.UnpauseEmulator();
}
} }
else else
{ {
@ -462,14 +455,7 @@ namespace BizHawk.Client.EmuHawk
if (needsToRollback) if (needsToRollback)
{ {
GoToLastEmulatedFrameIfNecessary(TasView.FirstSelectedIndex.Value); GoToLastEmulatedFrameIfNecessary(TasView.FirstSelectedIndex.Value);
if (wasPaused) DoAutoRestore();
{
DoAutoRestore();
}
else
{
Mainform.UnpauseEmulator();
}
} }
else else
{ {
@ -511,14 +497,7 @@ namespace BizHawk.Client.EmuHawk
if (needsToRollback) if (needsToRollback)
{ {
GoToLastEmulatedFrameIfNecessary(rollBackFrame); GoToLastEmulatedFrameIfNecessary(rollBackFrame);
if (wasPaused) DoAutoRestore();
{
DoAutoRestore();
}
else
{
Mainform.UnpauseEmulator();
}
} }
else else
{ {
@ -545,14 +524,7 @@ namespace BizHawk.Client.EmuHawk
if (needsToRollback) if (needsToRollback)
{ {
GoToLastEmulatedFrameIfNecessary(rollBackFrame); GoToLastEmulatedFrameIfNecessary(rollBackFrame);
if (wasPaused) DoAutoRestore();
{
DoAutoRestore();
}
else
{
Mainform.UnpauseEmulator();
}
} }
else else
{ {
@ -580,14 +552,7 @@ namespace BizHawk.Client.EmuHawk
if (needsToRollback) if (needsToRollback)
{ {
GoToLastEmulatedFrameIfNecessary(rollBackFrame); GoToLastEmulatedFrameIfNecessary(rollBackFrame);
if (wasPaused) DoAutoRestore();
{
DoAutoRestore();
}
else
{
Mainform.UnpauseEmulator();
}
} }
else else
{ {
@ -614,14 +579,7 @@ namespace BizHawk.Client.EmuHawk
if (needsToRollback) if (needsToRollback)
{ {
GoToLastEmulatedFrameIfNecessary(insertionFrame); GoToLastEmulatedFrameIfNecessary(insertionFrame);
if (wasPaused) DoAutoRestore();
{
DoAutoRestore();
}
else
{
Mainform.UnpauseEmulator();
}
} }
else else
{ {
@ -641,14 +599,7 @@ namespace BizHawk.Client.EmuHawk
if (needsToRollback) if (needsToRollback)
{ {
GoToLastEmulatedFrameIfNecessary(insertionFrame); GoToLastEmulatedFrameIfNecessary(insertionFrame);
if (wasPaused) DoAutoRestore();
{
DoAutoRestore();
}
else
{
Mainform.UnpauseEmulator();
}
} }
else else
{ {
@ -672,14 +623,7 @@ namespace BizHawk.Client.EmuHawk
if (needsToRollback) if (needsToRollback)
{ {
GoToLastEmulatedFrameIfNecessary(insertionFrame); GoToLastEmulatedFrameIfNecessary(insertionFrame);
if (wasPaused) DoAutoRestore();
{
DoAutoRestore();
}
else
{
Mainform.UnpauseEmulator();
}
} }
else else
{ {

View File

@ -18,11 +18,14 @@ namespace BizHawk.Client.EmuHawk
if (frame <= Emulator.Frame) if (frame <= Emulator.Frame)
{ {
if ((Mainform.EmulatorPaused || !Mainform.IsSeeking) &&
!CurrentTasMovie.LastPositionStable)
{
LastPositionFrame = Emulator.Frame;
CurrentTasMovie.LastPositionStable = true; // until new frame is emulated
}
GoToFrame(frame); GoToFrame(frame);
} }
if (!_autoRestoreFrame.HasValue || _autoRestoreFrame.Value < restoreFrame)
_autoRestoreFrame = restoreFrame;
} }
} }

View File

@ -792,11 +792,11 @@ namespace BizHawk.Client.EmuHawk
private void DoAutoRestore() private void DoAutoRestore()
{ {
if (Settings.AutoRestoreLastPosition && _autoRestoreFrame.HasValue) if (Settings.AutoRestoreLastPosition && LastPositionFrame != -1)
{ {
if (_autoRestoreFrame > Emulator.Frame) // Don't unpause if we are already on the desired frame, else runaway seek if (LastPositionFrame > Emulator.Frame) // Don't unpause if we are already on the desired frame, else runaway seek
{ {
StartSeeking(_autoRestoreFrame); StartSeeking(LastPositionFrame);
} }
} }
else else
@ -808,7 +808,7 @@ namespace BizHawk.Client.EmuHawk
} }
_autoRestorePaused = null; _autoRestorePaused = null;
} }
_autoRestoreFrame = null; //_autoRestoreFrame = null;
} }
private void StartAtNearestFrameAndEmulate(int frame) private void StartAtNearestFrameAndEmulate(int frame)