From 6d95ee97a3fc1dd032f3363db0b3265be58a1d9f Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 17 Jul 2014 21:43:41 +0000 Subject: [PATCH] TAStudio - some tinkering with the GoToFrame() method logic, still more logic to be done here --- .../tools/TAStudio/TAStudio.IToolForm.cs | 6 ++ .../tools/TAStudio/TAStudio.cs | 65 +++++++++++++++---- 2 files changed, 57 insertions(+), 14 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs index aa089b8613..83addb602a 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs @@ -23,6 +23,12 @@ namespace BizHawk.Client.EmuHawk { TasView.ensureVisible(Global.Emulator.Frame); } + + if (StopFrame.HasValue && Global.Emulator.Frame == StopFrame.Value) + { + GlobalWin.MainForm.PauseEmulator(); + StopFrame = null; + } } public void Restart() diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 09f204df03..4bfe048371 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -25,6 +25,8 @@ namespace BizHawk.Client.EmuHawk private bool _originalRewindStatus; // The client rewind status before TAStudio was engaged (used to restore when disengaged) private MovieEndAction _originalEndAction; // The movie end behavior selected by the user (that is overridden by TAStudio) + private int? StopFrame = null; // This is the frame Tastudio + private Dictionary GenerateColumnNames() { var lg = Global.MovieSession.LogGeneratorInstance(); @@ -292,25 +294,60 @@ namespace BizHawk.Client.EmuHawk // If near a greenzone item, load and emulate // Do capturing and recording as needed - var goToFrame = frame == 0 ? 0 : frame - 1; - - if (_tas[goToFrame].HasState) // Go back 1 frame and emulate + if (frame < _tas.InputLogLength) { - _tas.SwitchToPlay(); - Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(_tas[goToFrame].State.ToArray()))); - - if (goToFrame > 0) // We can't emulate up to frame 0! + if (frame < Global.Emulator.Frame) // We are rewinding { - Global.Emulator.FrameAdvance(true); - } + var goToFrame = frame == 0 ? 0 : frame - 1; - GlobalWin.DisplayManager.NeedsToPaint = true; - TasView.ensureVisible(frame); - RefreshDialog(); + if (_tas[goToFrame].HasState) // Go back 1 frame and emulate + { + _tas.SwitchToPlay(); + Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(_tas[goToFrame].State.ToArray()))); + + if (goToFrame > 0) // We can't emulate up to frame 0! + { + Global.Emulator.FrameAdvance(true); + } + + GlobalWin.DisplayManager.NeedsToPaint = true; + TasView.ensureVisible(frame); + RefreshDialog(); + } + else + { + _tas.SwitchToPlay(); + Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(_tas[_tas.LastEmulatedFrame].State.ToArray()))); + GlobalWin.MainForm.UnpauseEmulator(); + StopFrame = frame; + // TODO: if turbo seek, ramp up the speed + } + } + else // We are going foward + { + var goToFrame = frame - 1; + if (_tas[goToFrame].HasState) // Can we go directly there? + { + _tas.SwitchToPlay(); + Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(_tas[goToFrame].State.ToArray()))); + Global.Emulator.FrameAdvance(true); + GlobalWin.DisplayManager.NeedsToPaint = true; + TasView.ensureVisible(frame); + RefreshDialog(); + } + else // TODO: this assume that there are no "gaps", instead of last emulated frame, we should do last frame from X + { + _tas.SwitchToPlay(); + Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(_tas[_tas.LastEmulatedFrame].State.ToArray()))); + GlobalWin.MainForm.UnpauseEmulator(); + StopFrame = frame; + // TODO: if turbo seek, ramp up the speed + } + } } - else + else // Emulate to a future frame { - // Find the earliest frame before this state + // TODO } }