From e6d6dc7e5141dbc98b1be757bd09e8c3e21e5016 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 30 Aug 2014 00:40:53 +0000 Subject: [PATCH] Tastudio - more go to frame stuff --- BizHawk.Client.Common/movie/tasproj/TasMovie.cs | 8 ++++++++ .../movie/tasproj/TasStateManager.cs | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs index 2f42512292..0b1b74c95c 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.cs @@ -298,6 +298,14 @@ namespace BizHawk.Client.Common } } + /// + /// For the given frame, returns a savestate that is that frame or before it, as close as possible to it + /// + public byte[] GetStateClosestToFrame(int frame) + { + return StateManager.GetStateClosestToFrame(frame); + } + /// /// Captures the current frame into the greenzone /// diff --git a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs index fbba8a0e87..da982a4d0d 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasStateManager.cs @@ -74,6 +74,14 @@ namespace BizHawk.Client.Common { shouldCapture = force; } + else if (Global.Emulator.Frame == 0) // For now, long term, TasMovie should have a .StartState property, and a tasproj file for the start state in non-savestate anchored movies + { + shouldCapture = true; + } + else if (_movie.Markers.IsMarker(Global.Emulator.Frame)) + { + shouldCapture = true; // Markers shoudl always get priority + } else { shouldCapture = Global.Emulator.Frame % 2 > 0; @@ -157,6 +165,10 @@ namespace BizHawk.Client.Common } } + public byte[] GetStateClosestToFrame(int frame) + { + return States.LastOrDefault(state => state.Key < frame).Value; + } // Map: // 4 bytes - total savestate count