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