diff --git a/BizHawk.Client.Common/BizHawk.Client.Common.csproj b/BizHawk.Client.Common/BizHawk.Client.Common.csproj index 10e8a7369e..213c227427 100644 --- a/BizHawk.Client.Common/BizHawk.Client.Common.csproj +++ b/BizHawk.Client.Common/BizHawk.Client.Common.csproj @@ -149,6 +149,9 @@ + + + diff --git a/BizHawk.Client.EmuHawk/rewind/RewindThreader.cs b/BizHawk.Client.Common/rewind/RewindThreader.cs similarity index 93% rename from BizHawk.Client.EmuHawk/rewind/RewindThreader.cs rename to BizHawk.Client.Common/rewind/RewindThreader.cs index edfeb2c0ac..62ec0d1741 100644 --- a/BizHawk.Client.EmuHawk/rewind/RewindThreader.cs +++ b/BizHawk.Client.Common/rewind/RewindThreader.cs @@ -2,7 +2,7 @@ using System.Threading; using System.Collections.Concurrent; -namespace BizHawk.Client.EmuHawk +namespace BizHawk.Client.Common { public class RewindThreader : IDisposable { @@ -16,8 +16,6 @@ namespace BizHawk.Client.EmuHawk private readonly ConcurrentQueue Jobs = new ConcurrentQueue(); private EventWaitHandle _ewh, _ewh2; private Thread _thread; - - // TODO: this is bad design! private Rewinder _rewinder; public RewindThreader(Rewinder rewinder, bool isThreaded) diff --git a/BizHawk.Client.EmuHawk/rewind/Rewinder.cs b/BizHawk.Client.Common/rewind/Rewinder.cs similarity index 91% rename from BizHawk.Client.EmuHawk/rewind/Rewinder.cs rename to BizHawk.Client.Common/rewind/Rewinder.cs index 084512735b..e46e1fe7b7 100644 --- a/BizHawk.Client.EmuHawk/rewind/Rewinder.cs +++ b/BizHawk.Client.Common/rewind/Rewinder.cs @@ -1,15 +1,13 @@ using System; using System.IO; -using BizHawk.Client.Common; - -namespace BizHawk.Client.EmuHawk +namespace BizHawk.Client.Common { public class Rewinder { public bool RewindActive = true; - private StreamBlobDatabase RewindBuffer; + private StreamBlobDatabase RewindBuffer; private RewindThreader RewindThread; private byte[] LastState; private bool RewindImpossible; @@ -18,6 +16,8 @@ namespace BizHawk.Client.EmuHawk private byte[] RewindFellationBuf; private byte[] TempBuf = new byte[0]; + public Action MessageCallback; + // TODO: make RewindBuf never be null public float FullnessRatio { @@ -109,11 +109,17 @@ namespace BizHawk.Client.EmuHawk long cap = Global.Config.Rewind_BufferSize * (long)1024 * (long)1024; if (RewindBuffer != null) + { RewindBuffer.Dispose(); + } + RewindBuffer = new StreamBlobDatabase(Global.Config.Rewind_OnDisk, cap, BufferManage); if (RewindThread != null) + { RewindThread.Dispose(); + } + RewindThread = new RewindThreader(this, Global.Config.Rewind_IsThreaded); } } @@ -175,16 +181,24 @@ namespace BizHawk.Client.EmuHawk LastState = null; } + private void DoMessage(string message) + { + if (MessageCallback != null) + { + MessageCallback(message); + } + } + private void SetRewindParams(bool enabled, int frequency) { if (RewindActive != enabled) { - GlobalWin.OSD.AddMessage("Rewind " + (enabled ? "Enabled" : "Disabled")); + DoMessage("Rewind " + (enabled ? "Enabled" : "Disabled")); } if (RewindFrequency != frequency && enabled) { - GlobalWin.OSD.AddMessage("Rewind frequency set to " + frequency); + DoMessage("Rewind frequency set to " + frequency); } RewindActive = enabled; diff --git a/BizHawk.Client.EmuHawk/rewind/StreamBlobDatabase.cs b/BizHawk.Client.Common/rewind/StreamBlobDatabase.cs similarity index 95% rename from BizHawk.Client.EmuHawk/rewind/StreamBlobDatabase.cs rename to BizHawk.Client.Common/rewind/StreamBlobDatabase.cs index c083a9e29c..df3f1b642a 100644 --- a/BizHawk.Client.EmuHawk/rewind/StreamBlobDatabase.cs +++ b/BizHawk.Client.Common/rewind/StreamBlobDatabase.cs @@ -4,9 +4,7 @@ using System.Threading; using System.Collections.Generic; using System.Collections.Concurrent; -using BizHawk.Client.Common; - -namespace BizHawk.Client.EmuHawk +namespace BizHawk.Client.Common { /// /// Manages a ring buffer of storage which can continually chow its own tail to keep growing forward. diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj index 1716601466..7838e95e03 100644 --- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -432,9 +432,6 @@ - - - Form diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 653b16c2cd..ce9534af9d 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -47,7 +47,11 @@ namespace BizHawk.Client.EmuHawk public MainForm(string[] args) { GlobalWin.MainForm = this; - GlobalWin.Rewinder = new Rewinder(); + GlobalWin.Rewinder = new Rewinder() + { + MessageCallback = GlobalWin.OSD.AddMessage + }; + Global.ControllerInputCoalescer = new ControllerInputCoalescer(); Global.FirmwareManager = new FirmwareManager(); Global.MovieSession = new MovieSession