Tastudio - improve navigation performance by emulating a frame when possible rather than loading a state
This commit is contained in:
parent
2e7546c67a
commit
5c85a8ca66
|
@ -2567,11 +2567,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_throttle.Step(true, -1);
|
_throttle.Step(true, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: for Tastudio debugging, coudl be removed if unused, it is a bad idea for anything else to clal this
|
|
||||||
public void FrameAdvance()
|
public void FrameAdvance()
|
||||||
{
|
{
|
||||||
PressFrameAdvance = true;
|
PressFrameAdvance = true;
|
||||||
StepRunLoop_Core();
|
StepRunLoop_Core(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StepRunLoop_Core(bool force = false)
|
private void StepRunLoop_Core(bool force = false)
|
||||||
|
|
|
@ -290,14 +290,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_supressContextMenu = true;
|
_supressContextMenu = true;
|
||||||
if (e.Delta < 0)
|
if (e.Delta < 0)
|
||||||
{
|
{
|
||||||
GoToFrame(Global.Emulator.Frame + 1);
|
GoToNextFrame();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Global.Emulator.Frame > 0)
|
GoToPreviousFrame();
|
||||||
{
|
|
||||||
GoToFrame(Global.Emulator.Frame - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,46 +60,60 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
else // We are going foward
|
else // We are going foward
|
||||||
{
|
{
|
||||||
var goToFrame = frame == 0 ? 0 : frame - 1;
|
if (frame == Global.Emulator.Frame + 1) // Just emulate a frame we only have 1 to go!
|
||||||
if (CurrentTasMovie[goToFrame].HasState) // Can we go directly there?
|
|
||||||
{
|
{
|
||||||
CurrentTasMovie.SwitchToPlay();
|
GlobalWin.MainForm.FrameAdvance();
|
||||||
Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(CurrentTasMovie[goToFrame].State.ToArray())));
|
|
||||||
Global.Emulator.FrameAdvance(true);
|
|
||||||
GlobalWin.DisplayManager.NeedsToPaint = true;
|
|
||||||
|
|
||||||
SetVisibleIndex(frame);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StartAtNearestFrameAndEmulate(frame);
|
var goToFrame = frame == 0 ? 0 : frame - 1;
|
||||||
return;
|
if (CurrentTasMovie[goToFrame].HasState) // Can we go directly there?
|
||||||
|
{
|
||||||
|
CurrentTasMovie.SwitchToPlay();
|
||||||
|
Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(CurrentTasMovie[goToFrame].State.ToArray())));
|
||||||
|
Global.Emulator.FrameAdvance(true);
|
||||||
|
GlobalWin.DisplayManager.NeedsToPaint = true;
|
||||||
|
|
||||||
|
SetVisibleIndex(frame);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StartAtNearestFrameAndEmulate(frame);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // Emulate to a future frame
|
else // Emulate to a future frame
|
||||||
{
|
{
|
||||||
// TODO: get the last greenzone frame and go there
|
if (frame == Global.Emulator.Frame + 1) // We are at the end of the movie and advancing one frame, therefore we are recording, simply emulate a frame
|
||||||
CurrentTasMovie.SwitchToPlay();
|
|
||||||
|
|
||||||
// no reason to loadstate when we can emulate a frame instead
|
|
||||||
var shouldLoadstate = frame - Global.Emulator.Frame != 1;
|
|
||||||
|
|
||||||
if (CurrentTasMovie.TasStateManager.LastEmulatedFrame > 0 && shouldLoadstate)
|
|
||||||
{
|
{
|
||||||
LoadState(CurrentTasMovie[CurrentTasMovie.TasStateManager.LastEmulatedFrame].State.ToArray());
|
GlobalWin.MainForm.FrameAdvance();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (frame != Global.Emulator.Frame) // If we aren't already at our destination, seek
|
|
||||||
{
|
{
|
||||||
GlobalWin.MainForm.UnpauseEmulator();
|
// TODO: get the last greenzone frame and go there
|
||||||
if (Global.Config.TAStudioAutoPause && frame < CurrentTasMovie.InputLogLength)
|
CurrentTasMovie.SwitchToPlay();
|
||||||
|
|
||||||
|
// no reason to loadstate when we can emulate a frame instead
|
||||||
|
var shouldLoadstate = frame - Global.Emulator.Frame != 1;
|
||||||
|
|
||||||
|
if (CurrentTasMovie.TasStateManager.LastEmulatedFrame > 0 && shouldLoadstate)
|
||||||
{
|
{
|
||||||
GlobalWin.MainForm.PauseOnFrame = CurrentTasMovie.InputLogLength;
|
LoadState(CurrentTasMovie[CurrentTasMovie.TasStateManager.LastEmulatedFrame].State.ToArray());
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (frame != Global.Emulator.Frame) // If we aren't already at our destination, seek
|
||||||
{
|
{
|
||||||
GlobalWin.MainForm.PauseOnFrame = frame;
|
GlobalWin.MainForm.UnpauseEmulator();
|
||||||
|
if (Global.Config.TAStudioAutoPause && frame < CurrentTasMovie.InputLogLength)
|
||||||
|
{
|
||||||
|
GlobalWin.MainForm.PauseOnFrame = CurrentTasMovie.InputLogLength;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GlobalWin.MainForm.PauseOnFrame = frame;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue