diff --git a/BizHawk.Client.Common/movie/MovieSession.cs b/BizHawk.Client.Common/movie/MovieSession.cs
index 2e0476c770..a4e2140ed2 100644
--- a/BizHawk.Client.Common/movie/MovieSession.cs
+++ b/BizHawk.Client.Common/movie/MovieSession.cs
@@ -288,6 +288,9 @@ namespace BizHawk.Client.Common
QueuedMovie = null;
MultiTrack.Restart(Global.Emulator.ControllerDefinition.PlayerCount);
+ Movie.ProcessSavestate(Global.Emulator);
+ Movie.ProcessSram(Global.Emulator);
+
if (recordMode)
{
Movie.StartNewRecording();
diff --git a/BizHawk.Client.Common/movie/interfaces/IMovie.cs b/BizHawk.Client.Common/movie/interfaces/IMovie.cs
index 00f34eb65f..6ca0e4fa3f 100644
--- a/BizHawk.Client.Common/movie/interfaces/IMovie.cs
+++ b/BizHawk.Client.Common/movie/interfaces/IMovie.cs
@@ -252,5 +252,45 @@ namespace BizHawk.Client.Common
public static bool IsRecording(this IMovie movie) => movie?.Mode == MovieMode.Record;
public static bool IsFinished(this IMovie movie) => movie.Mode == MovieMode.Finished;
public static bool IsPlayingOrRecording(this IMovie movie) => movie?.Mode == MovieMode.Play || movie?.Mode == MovieMode.Record;
+
+
+ ///
+ /// If the given movie contains a savestate it will be loaded if
+ /// the given core has savestates, and a framebuffer populated
+ /// if it is contained in the state and the given core supports it
+ ///
+ public static void ProcessSavestate(this IMovie movie, IEmulator emulator)
+ {
+ if (emulator.HasSavestates() && movie.StartsFromSavestate)
+ {
+ if (movie.TextSavestate != null)
+ {
+ emulator.AsStatable().LoadStateText(movie.TextSavestate);
+ }
+ else
+ {
+ emulator.AsStatable().LoadStateBinary(movie.BinarySavestate);
+ }
+
+ if (movie.SavestateFramebuffer != null && emulator.HasVideoProvider())
+ {
+ emulator.AsVideoProvider().PopulateFromBuffer(movie.SavestateFramebuffer);
+ }
+
+ emulator.ResetCounters();
+ }
+ }
+
+ ///
+ /// Sets the given save ram if the movie contains save ram
+ /// and the core supports save ram
+ ///
+ public static void ProcessSram(this IMovie movie, IEmulator emulator)
+ {
+ if (movie.StartsFromSaveRam && emulator.HasSaveRam())
+ {
+ emulator.AsSaveRam().StoreSaveRam(movie.SaveRam);
+ }
+ }
}
}
diff --git a/BizHawk.Client.EmuHawk/MainForm.Movie.cs b/BizHawk.Client.EmuHawk/MainForm.Movie.cs
index 4c83128c9b..a4a0eea5c3 100644
--- a/BizHawk.Client.EmuHawk/MainForm.Movie.cs
+++ b/BizHawk.Client.EmuHawk/MainForm.Movie.cs
@@ -1,5 +1,4 @@
-using System.IO;
-using System.Windows.Forms;
+using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
@@ -25,29 +24,6 @@ namespace BizHawk.Client.EmuHawk
Config.RecentMovies.Add(movie.Filename);
- if (Emulator.HasSavestates() && movie.StartsFromSavestate)
- {
- if (movie.TextSavestate != null)
- {
- Emulator.AsStatable().LoadStateText(new StringReader(movie.TextSavestate));
- }
- else
- {
- Emulator.AsStatable().LoadStateBinary(movie.BinarySavestate);
- }
-
- if (movie.SavestateFramebuffer != null && Emulator.HasVideoProvider())
- {
- Emulator.AsVideoProvider().PopulateFromBuffer(movie.SavestateFramebuffer);
- }
-
- Emulator.ResetCounters();
- }
- else if (Emulator.HasSaveRam() && movie.StartsFromSaveRam)
- {
- Emulator.AsSaveRam().StoreSaveRam(movie.SaveRam);
- }
-
MovieSession.RunQueuedMovie(record);
SetMainformMovieInfo();
diff --git a/BizHawk.Emulation.Common/Interfaces/Services/IStatable.cs b/BizHawk.Emulation.Common/Interfaces/Services/IStatable.cs
index bc9720e0fb..180344c915 100644
--- a/BizHawk.Emulation.Common/Interfaces/Services/IStatable.cs
+++ b/BizHawk.Emulation.Common/Interfaces/Services/IStatable.cs
@@ -73,6 +73,11 @@ namespace BizHawk.Emulation.Common
}
}
+ public static void LoadStateText(this IStatable core, string textState)
+ {
+ core.LoadStateText(new StringReader(textState));
+ }
+
///
/// Loads a state directly from a byte array
///