Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 8 additions & 19 deletions src/BizHawk.Client.EmuHawk/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,15 +1121,8 @@ private set

set
{
bool wasTurboSeeking = IsTurboSeeking;
_pauseOnFrame = value;
SetPauseStatusBarIcon();

if (wasTurboSeeking && value == null) // TODO: make an Event handler instead, but the logic here is that after turbo seeking, tools will want to do a real update when the emulator finally pauses
{
// Tools.UpdateToolsBefore(); // TODO: do we need this?
Tools.UpdateToolsAfter();
}
}
}

Expand Down Expand Up @@ -2932,6 +2925,7 @@ private void StepRunLoop_Core(bool force = false)
{
var isFastForwarding = IsFastForwarding;
var isFastForwardingOrRewinding = isFastForwarding || isRewinding || Config.Unthrottled;
bool atTurboSeekEnd = IsTurboSeeking && Emulator.Frame == PauseOnFrame.Value - 1;

if (isFastForwardingOrRewinding != _lastFastForwardingOrRewinding)
{
Expand All @@ -2949,7 +2943,7 @@ private void StepRunLoop_Core(bool force = false)
InputManager.ClickyVirtualPadController.FrameTick();
InputManager.ButtonOverrideAdapter.FrameTick();

if (IsTurboing)
if (IsTurboing && !atTurboSeekEnd)
{
Tools.FastUpdateBefore();
}
Expand Down Expand Up @@ -3019,7 +3013,6 @@ private void StepRunLoop_Core(bool force = false)
atten = 0;
}

bool atTurboSeekEnd = IsTurboSeeking && Emulator.Frame == PauseOnFrame.Value - 1;
bool render = !_throttle.skipNextFrame || _currAviWriter?.UsesVideo is true || atTurboSeekEnd;
bool newFrame = Emulator.FrameAdvance(InputManager.ControllerOutput, render, renderSound);

Expand Down Expand Up @@ -3048,17 +3041,13 @@ private void StepRunLoop_Core(bool force = false)

PressFrameAdvance = false;

// Update tools, but not if we're at the end of a turbo seek. In that case, updating will happen later when the seek is ended.
if (!atTurboSeekEnd)
if (IsTurboing && !atTurboSeekEnd)
{
if (IsTurboing)
{
Tools.FastUpdateAfter();
}
else
{
UpdateToolsAfter();
}
Tools.FastUpdateAfter();
}
else
{
UpdateToolsAfter();
}

if (newFrame)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public bool Rewind()
WheelSeek(rewindStep);
// we need a frame advance if a state was loaded (frame has changed)
// and also we are seeking (not already at the target frame)
return Emulator.Frame != frame && _seekingTo != -1;
return Emulator.Frame != frame && SeekingTo != -1;
}

public bool WantsToControlRestartMovie { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public partial class TAStudio : IToolForm

private void UpdateProgressBar()
{
if (_seekingTo != -1)
if (SeekingTo != -1)
{
int diff = Emulator.Frame - _seekStartFrame;
int unit = _seekingTo - _seekStartFrame;
int unit = SeekingTo - _seekStartFrame;
double progress = 0;

if (diff != 0 && unit != 0)
Expand Down Expand Up @@ -92,7 +92,7 @@ protected override void UpdateAfter()
CurrentTasMovie.TasSession.UpdateValues(Emulator.Frame, CurrentTasMovie.Branches.Current);
MaybeFollowCursor();

if (Settings.AutoPause && _seekingTo == -1)
if (Settings.AutoPause && SeekingTo == -1)
{
if (_doPause && CurrentTasMovie.IsAtEnd()) MainForm.PauseEmulator();
_doPause = !CurrentTasMovie.IsAtEnd();
Expand All @@ -109,7 +109,7 @@ protected override void UpdateAfter()

protected override void FastUpdateAfter()
{
if (_seekingTo != -1 && Emulator.Frame >= _seekingTo)
if (SeekingTo != -1 && Emulator.Frame >= SeekingTo)
{
bool smga = _shouldMoveGreenArrow;
StopSeeking();
Expand Down
23 changes: 11 additions & 12 deletions src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private void BeginAxisMouseEdit(int yPos)
public void StopSeeking(bool skipRecModeCheck = false)
{
_shouldMoveGreenArrow = true;
if (_seekingTo == -1) return;
if (SeekingTo == -1) return;

if (WasRecording && !skipRecModeCheck)
{
Expand All @@ -115,8 +115,7 @@ public void StopSeeking(bool skipRecModeCheck = false)
}

_seekingByEdit = false;
_seekingTo = -1;
MainForm.PauseOnFrame = null; // This being unset is how MainForm knows we are not seeking, and controls TurboSeek.
SeekingTo = -1;
if (_pauseAfterSeeking)
{
MainForm.PauseEmulator();
Expand Down Expand Up @@ -372,7 +371,7 @@ private void TasView_QueryItemIcon(InputRoll sender, int index, RollColumn colum

if (index == Emulator.Frame)
{
bitmap = index == _seekingTo
bitmap = index == SeekingTo
? sender.HorizontalOrientation ? ts_v_arrow_green_blue : ts_h_arrow_green_blue
: sender.HorizontalOrientation ? ts_v_arrow_blue : ts_h_arrow_blue;
}
Expand Down Expand Up @@ -457,11 +456,11 @@ private void TasView_QueryRowBkColor(InputRoll sender, int index, ref Color colo

var record = CurrentTasMovie[index];

if (_seekingTo == index)
if (SeekingTo == index)
{
color = Palette.CurrentFrame_InputLog;
}
else if (_seekingTo == -1 && Emulator.Frame == index)
else if (SeekingTo == -1 && Emulator.Frame == index)
{
color = Palette.CurrentFrame_InputLog;
}
Expand Down Expand Up @@ -771,7 +770,7 @@ private void TasView_MouseDown(object sender, MouseEventArgs e)
{
if (MainForm.EmulatorPaused)
{
if (_seekingTo != -1)
if (SeekingTo != -1)
{
MainForm.UnpauseEmulator(); // resume seek
return;
Expand Down Expand Up @@ -1066,7 +1065,7 @@ public bool FrameEdited(int frame)
{
if (_shouldMoveGreenArrow)
{
RestorePositionFrame = _seekingTo != -1 ? _seekingTo : Emulator.Frame;
RestorePositionFrame = SeekingTo != -1 ? SeekingTo : Emulator.Frame;
}

GoToFrame(frame);
Expand Down Expand Up @@ -1204,14 +1203,14 @@ private void TasView_MouseUp(object sender, MouseEventArgs e)

private void WheelSeek(int count)
{
if (_seekingTo != -1)
if (SeekingTo != -1)
{
_shouldMoveGreenArrow = true;
_seekingTo = Math.Max(_seekingTo - count, 0);
SeekingTo = Math.Max(SeekingTo - count, 0);

if (count > 0 && Emulator.Frame >= _seekingTo)
if (count > 0 && Emulator.Frame >= SeekingTo)
{
GoToFrame(_seekingTo);
GoToFrame(SeekingTo);
}

RefreshDialog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ private void RightClickMenu_Opened(object sender, EventArgs e)

StartFromNowSeparator.Visible = StartNewProjectFromNowMenuItem.Visible || StartANewProjectFromSaveRamMenuItem.Visible;
RemoveMarkersContextMenuItem.Enabled = CurrentTasMovie.Markers.Any(m => IsRowSelected(m.Frame)); // Disable the option to remove markers if no markers are selected (FCEUX does this).
CancelSeekContextMenuItem.Enabled = _seekingTo != -1;
CancelSeekContextMenuItem.Enabled = SeekingTo != -1;
BranchContextMenuItem.Visible = CurrentCell?.RowIndex == Emulator.Frame;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void GoToFrame(int frame, bool OnLeftMouseDown = false, bool skipLoadStat
// what is the significance of a seek to frame if we don't pause?
// Answer: We use this in order to temporarily disable recording mode when the user navigates to a frame. (to avoid recording between whatever is the most recent state and the user-specified frame)
// Other answer: turbo seek, navigating while unpaused
_pauseAfterSeeking = MainForm.EmulatorPaused || (_seekingTo != -1 && _pauseAfterSeeking);
_pauseAfterSeeking = MainForm.EmulatorPaused || (SeekingTo != -1 && _pauseAfterSeeking);
WasRecording = CurrentTasMovie.IsRecording() || WasRecording;
TastudioPlayMode();

Expand All @@ -37,11 +37,10 @@ public void GoToFrame(int frame, bool OnLeftMouseDown = false, bool skipLoadStat
_seekStartFrame = Emulator.Frame;
_seekingByEdit = false;

_seekingTo = frame;
MainForm.PauseOnFrame = int.MaxValue; // This being set is how MainForm knows we are seeking, and controls TurboSeek.
SeekingTo = frame;
MainForm.UnpauseEmulator();

if (_seekingTo - _seekStartFrame > 1)
if (SeekingTo - _seekStartFrame > 1)
{
MessageStatusLabel.Text = "Seeking...";
ProgressBar.Visible = true;
Expand Down Expand Up @@ -117,7 +116,7 @@ private void MaybeFollowCursor()

public int GetSeekFrame()
{
return _seekingTo == -1 ? Emulator.Frame : _seekingTo;
return SeekingTo == -1 ? Emulator.Frame : SeekingTo;
}
}
}
12 changes: 11 additions & 1 deletion src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,17 @@ public static Icon ToolIcon
private bool _shouldMoveGreenArrow;
private bool _seekingByEdit;

private int _seekingTo = -1;
private int SeekingTo
{
get => MainForm.PauseOnFrame ?? -1;
set
{
if (value == -1)
MainForm.PauseOnFrame = null;
else
MainForm.PauseOnFrame = value;
}
}

[ConfigPersist]
public TAStudioSettings Settings { get; set; } = new TAStudioSettings();
Expand Down
Loading