From 5b7d61223891e7ea9625fec4565c8db2f3276208 Mon Sep 17 00:00:00 2001 From: adelikat Date: Mon, 25 May 2020 17:59:09 -0500 Subject: [PATCH] SaveStateManager - simplify video buffer loading and don't use Global.Emulator --- src/BizHawk.Client.Common/SavestateManager.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/BizHawk.Client.Common/SavestateManager.cs b/src/BizHawk.Client.Common/SavestateManager.cs index 11926bc50a..a0beb7b35e 100644 --- a/src/BizHawk.Client.Common/SavestateManager.cs +++ b/src/BizHawk.Client.Common/SavestateManager.cs @@ -132,7 +132,10 @@ namespace BizHawk.Client.Common } } - bl.GetLump(BinaryStateLump.Framebuffer, false, PopulateFramebuffer); + if (emulator.HasVideoProvider()) + { + bl.GetLump(BinaryStateLump.Framebuffer, false, br => PopulateFramebuffer(br, emulator.AsVideoProvider())); + } string userData = ""; bl.GetLump(BinaryStateLump.UserData, false, delegate(TextReader tr) @@ -171,23 +174,18 @@ namespace BizHawk.Client.Common return false; } - private static void PopulateFramebuffer(BinaryReader br) + private static void PopulateFramebuffer(BinaryReader br, IVideoProvider videoProvider) { - if (!Global.Emulator.HasVideoProvider()) - { - return; - } - try { using (new SimpleTime("Load Framebuffer")) { - QuickBmpFile.Load(Global.Emulator.AsVideoProvider(), br.BaseStream); + QuickBmpFile.Load(videoProvider, br.BaseStream); } } catch { - var buff = Global.Emulator.AsVideoProvider().GetVideoBuffer(); + var buff = videoProvider.GetVideoBuffer(); try { for (int i = 0; i < buff.Length; i++)