Skip to content

Commit

Permalink
Discard apihawksurface in TAStudio LoadState when frame advancing after
Browse files Browse the repository at this point in the history
This fixes an issue where lua scripts could write to the screen twice when seeking to a frame in TAStudio as the screen was not cleared between the load and the following frame advance.

This fixes / expands 1a9176e.
  • Loading branch information
Morilli committed Jun 8, 2024
1 parent bcc0d83 commit f0bc8fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void GoToFrame(int frame, bool fromLua = false, bool fromRewinding = fals
var lastState = GetPriorStateForFramebuffer(frame);
if (lastState.Key > Emulator.Frame)
{
LoadState(lastState);
LoadState(lastState, true);
}

StartSeeking(frame);
Expand Down
8 changes: 6 additions & 2 deletions src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ private void StartAtNearestFrameAndEmulate(int frame, bool fromLua, bool fromRew
var closestState = GetPriorStateForFramebuffer(frame);
if (closestState.Value.Length > 0 && (frame < Emulator.Frame || closestState.Key > Emulator.Frame))
{
LoadState(closestState);
LoadState(closestState, true);
}
closestState.Value.Dispose();

Expand Down Expand Up @@ -980,7 +980,7 @@ private void StartAtNearestFrameAndEmulate(int frame, bool fromLua, bool fromRew
}
}

public void LoadState(KeyValuePair<int, Stream> state)
public void LoadState(KeyValuePair<int, Stream> state, bool discardApiHawkSurfaces = false)
{
StatableEmulator.LoadStateBinary(new BinaryReader(state.Value));

Expand All @@ -990,6 +990,10 @@ public void LoadState(KeyValuePair<int, Stream> state)
}

UpdateTools();
if (discardApiHawkSurfaces)
{
DisplayManager.DiscardApiHawkSurfaces();
}
}

public void AddBranchExternal() => BookMarkControl.AddBranchExternal();
Expand Down

0 comments on commit f0bc8fb

Please sign in to comment.