Move rewind code to client.common
This commit is contained in:
parent
edb5560da7
commit
b5d3f68126
|
@ -149,6 +149,9 @@
|
|||
<Compile Include="Properties\svnrev.cs" />
|
||||
<Compile Include="RecentFiles.cs" />
|
||||
<Compile Include="helpers\StringHelpers.cs" />
|
||||
<Compile Include="rewind\Rewinder.cs" />
|
||||
<Compile Include="rewind\RewindThreader.cs" />
|
||||
<Compile Include="rewind\StreamBlobDatabase.cs" />
|
||||
<Compile Include="RomGame.cs" />
|
||||
<Compile Include="RomLoader.cs" />
|
||||
<Compile Include="SaveSlotManager.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<Job> Jobs = new ConcurrentQueue<Job>();
|
||||
private EventWaitHandle _ewh, _ewh2;
|
||||
private Thread _thread;
|
||||
|
||||
// TODO: this is bad design!
|
||||
private Rewinder _rewinder;
|
||||
|
||||
public RewindThreader(Rewinder rewinder, bool isThreaded)
|
|
@ -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<string> 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;
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Manages a ring buffer of storage which can continually chow its own tail to keep growing forward.
|
|
@ -432,9 +432,6 @@
|
|||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="rewind\Rewinder.cs" />
|
||||
<Compile Include="rewind\RewindThreader.cs" />
|
||||
<Compile Include="rewind\StreamBlobDatabase.cs" />
|
||||
<Compile Include="ScanlineSlider.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue