Skip to content

Commit e57b8f7

Browse files
committed
Fix #4591
1 parent 145f5be commit e57b8f7

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/BizHawk.Client.EmuHawk/MainForm.cs

Lines changed: 21 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,23 @@ private set
10881088
}
10891089
}
10901090

1091+
private bool _unpauseByFrameAdvance;
1092+
1093+
/// <summary>
1094+
/// Avoids using EmulatorPaused to handle frame advance, thus allowing Lua to unpause during a frame advance.
1095+
/// </summary>
1096+
private bool UnpauseByFrameAdvance
1097+
{
1098+
get => _unpauseByFrameAdvance;
1099+
set
1100+
{
1101+
if (_unpauseByFrameAdvance == value) return;
1102+
_unpauseByFrameAdvance = value;
1103+
1104+
OnPauseToggle(!value);
1105+
}
1106+
}
1107+
10911108
private void OnPauseToggle(bool newPauseState)
10921109
{
10931110
if (!newPauseState) // Unpausing
@@ -2935,21 +2952,22 @@ private void StepRunLoop_Core(bool force = false)
29352952
// handle the initial trigger of a frame advance
29362953
runFrame = true;
29372954
_frameAdvanceTimestamp = currentTimestamp;
2955+
// Pausing is inconsistent with the behavior of TAStudio while seeking, but it's always been this way so.
29382956
PauseEmulator();
29392957
}
29402958
else if (frameProgressTimeElapsed)
29412959
{
29422960
runFrame = true;
29432961
_runloopFrameProgress = true;
2944-
UnpauseEmulator();
2962+
UnpauseByFrameAdvance = true;
29452963
}
29462964
}
29472965
else
29482966
{
29492967
if (_runloopFrameAdvance)
29502968
{
29512969
// handle release of frame advance
2952-
PauseEmulator();
2970+
UnpauseByFrameAdvance = false;
29532971
}
29542972
_runloopFrameProgress = false;
29552973
}

0 commit comments

Comments
 (0)