Skip to content

Commit 1d73806

Browse files
committed
Fix #4591
1 parent eb2f7d5 commit 1d73806

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/BizHawk.Client.EmuHawk/MainForm.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ protected override void Dispose(bool disposing)
10761076
private bool _emulatorPaused;
10771077
public bool EmulatorPaused
10781078
{
1079-
get => _emulatorPaused;
1079+
get => _emulatorPaused && !_unpauseByFrameAdvance;
10801080

10811081
private set
10821082
{
@@ -1088,6 +1088,22 @@ private set
10881088
}
10891089
}
10901090

1091+
private bool _unpauseByFrameAdvance;
1092+
/// <summary>
1093+
/// Avoids using EmulatorPaused to handle frame advance, thus allowing Lua to unpause during a frame advance.
1094+
/// </summary>
1095+
private bool UnpauseByFrameAdvance
1096+
{
1097+
get => _unpauseByFrameAdvance;
1098+
set
1099+
{
1100+
if (_unpauseByFrameAdvance == value) return;
1101+
_unpauseByFrameAdvance = value;
1102+
1103+
OnPauseToggle(!value);
1104+
}
1105+
}
1106+
10911107
private void OnPauseToggle(bool newPauseState)
10921108
{
10931109
if (!newPauseState) // Unpausing
@@ -2936,21 +2952,22 @@ private void StepRunLoop_Core(bool force = false)
29362952
// handle the initial trigger of a frame advance
29372953
runFrame = true;
29382954
_frameAdvanceTimestamp = currentTimestamp;
2955+
// Pausing is inconsistent with the behavior of TAStudio while seeking, but it's always been this way so.
29392956
PauseEmulator();
29402957
}
29412958
else if (frameProgressTimeElapsed)
29422959
{
29432960
runFrame = true;
29442961
_runloopFrameProgress = true;
2945-
UnpauseEmulator();
2962+
UnpauseByFrameAdvance = true;
29462963
}
29472964
}
29482965
else
29492966
{
29502967
if (_runloopFrameAdvance)
29512968
{
29522969
// handle release of frame advance
2953-
PauseEmulator();
2970+
UnpauseByFrameAdvance = false;
29542971
}
29552972
_runloopFrameProgress = false;
29562973
}

0 commit comments

Comments
 (0)