From b2f3bb3cbaedff8fee0a468e0bb6d1439fb3d40a Mon Sep 17 00:00:00 2001 From: feos Date: Thu, 5 Dec 2024 00:53:55 +0300 Subject: [PATCH] fix wrong pause in AutoAdjustInput() it has to rewind to remove a frame, which makes it pause on first removed frame when we hit restore, instead of going all the way to LastPositionFrame. I tried a ton of things to fix it, and they break one of the 3 scenarios of going from the edited frame, emulating through removed was-lag frames until LastPositionFrame, and pausing there: - autorestore - restore manually via middle-click or the || button - step frame by frame using wheel+RMB wheel+RMB steps used to unpause in wrong places because paused state was disabled when it fires, so we couldn't decide whether to unpause or not based on it at the end of AutoAdjustInput(). so I'm enabling """paused""" state inside TasView_MouseWheel(), much like < and > buttons do, except they can be held to force unpause, but here you can't let go of mouse wheel since it already only fires once anyway. I'm disabling this state once tastudio has reached its INTERIM seek frame, and based on it I now can decide to unpause after AutoAdjustInput(). AutoAdjustInput() still has a tiny problem of not advancing the first removed was-lag frame when you go step by step, because it can only go one direction at a time, and it goes up as explained above, but we need it to also go down. this can be forced if we allow tastudio to seek to the CURRENT frame by loading its state and reemulating it, but I don't know if this will cause issues, and nobody is stepping through autoadjusted frames anyway, since it's meant to happen quickly and on autorestore TODO: removing consecutive was-lag frames seems to remove them ALL!!! inb4 all this causes other wild bugs... --- src/BizHawk.Client.EmuHawk/MainForm.cs | 11 +++++++++-- .../tools/TAStudio/TAStudio.ListView.cs | 3 +++ src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs | 9 ++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index 78829b0aa8..721efba0ab 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -3105,8 +3105,15 @@ namespace BizHawk.Client.EmuHawk if (PauseOnFrame.Value == Emulator.Frame) { PauseEmulator(); - if (Tools.IsLoaded()) Tools.TAStudio.StopSeeking(); - else PauseOnFrame = null; + if (Tools.IsLoaded()) + { + Tools.TAStudio.StopSeeking(); + HoldFrameAdvance = false; + } + else + { + PauseOnFrame = null; + } } else if (Tools.IsLoaded() && Tools.TAStudio.LastPositionFrame == Emulator.Frame diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index 6e05848efc..ff490d1e0c 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -901,6 +901,9 @@ namespace BizHawk.Client.EmuHawk } else { + // needed for AutoAdjustInput() when it removes was-lag frames + MainForm.HoldFrameAdvance = true; + GoToFrame(Emulator.Frame - notch); } } diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 64fbff6637..36cd4f5d0e 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -1116,16 +1116,19 @@ namespace BizHawk.Client.EmuHawk CurrentTasMovie.ChangeLog.AddInputBind(Emulator.Frame - 1, true, $"Bind Input; Delete {Emulator.Frame - 1}"); bool wasRecording = CurrentTasMovie.ChangeLog.IsRecording; CurrentTasMovie.ChangeLog.IsRecording = false; - CurrentTasMovie.RemoveFrames(framesToRemove); foreach (int f in framesToRemove) { CurrentTasMovie.LagLog.RemoveHistoryAt(f + 1); // Removes from WasLag } - CurrentTasMovie.ChangeLog.IsRecording = wasRecording; + + CurrentTasMovie.LastPositionStable = true; GoToLastEmulatedFrameIfNecessary(Emulator.Frame - 1); - DoAutoRestore(); + if (!MainForm.HoldFrameAdvance) + { + MainForm.PauseOnFrame = LastPositionFrame; + } return true; }