コード例 #1
0
        public void Initialize(IStatable statableCore, RewindConfig rewindConfig)
        {
            Uninitialize();

            _statableCore = statableCore;

            int stateSize = _statableCore.CloneSavestate().Length;

            if (stateSize >= rewindConfig.LargeStateSize)
            {
                RewindEnabled   = rewindConfig.EnabledLarge;
                RewindFrequency = rewindConfig.FrequencyLarge;
            }
            else if (stateSize >= rewindConfig.MediumStateSize)
            {
                RewindEnabled   = rewindConfig.EnabledMedium;
                RewindFrequency = rewindConfig.FrequencyMedium;
            }
            else
            {
                RewindEnabled   = rewindConfig.EnabledSmall;
                RewindFrequency = rewindConfig.FrequencySmall;
            }

            _rewindDeltaEnable = rewindConfig.UseDelta;

            if (RewindActive)
            {
                var capacity = rewindConfig.BufferSize * 1024L * 1024L;
                _rewindBuffer = new StreamBlobDatabase(rewindConfig.OnDisk, capacity, BufferManage);
                _rewindThread = new RewindThreader(CaptureInternal, RewindInternal, rewindConfig.IsThreaded);
            }
        }
コード例 #2
0
ファイル: Rewinder.cs プロジェクト: metalloidSmashes/BizHawk
        public void DoRewindSettings()
        {
            if (Global.Emulator.HasSavestates())
            {
                // This is the first frame. Capture the state, and put it in LastState for future deltas to be compared against.
                _lastState = (byte[])Global.Emulator.AsStatable().SaveStateBinary().Clone();

                int state_size;
                if (_lastState.Length >= Global.Config.Rewind_LargeStateSize)
                {
                    SetRewindParams(Global.Config.RewindEnabledLarge, Global.Config.RewindFrequencyLarge);
                    state_size = 3;
                }
                else if (_lastState.Length >= Global.Config.Rewind_MediumStateSize)
                {
                    SetRewindParams(Global.Config.RewindEnabledMedium, Global.Config.RewindFrequencyMedium);
                    state_size = 2;
                }
                else
                {
                    SetRewindParams(Global.Config.RewindEnabledSmall, Global.Config.RewindFrequencySmall);
                    state_size = 1;
                }

                var rewind_enabled = false;
                if (state_size == 1)
                {
                    rewind_enabled = Global.Config.RewindEnabledSmall;
                }
                else if (state_size == 2)
                {
                    rewind_enabled = Global.Config.RewindEnabledMedium;
                }
                else if (state_size == 3)
                {
                    rewind_enabled = Global.Config.RewindEnabledLarge;
                }

                _rewindDeltaEnable = Global.Config.Rewind_UseDelta;

                if (rewind_enabled)
                {
                    var capacity = Global.Config.Rewind_BufferSize * (long)1024 * 1024;

                    if (_rewindBuffer != null)
                    {
                        _rewindBuffer.Dispose();
                    }

                    _rewindBuffer = new StreamBlobDatabase(Global.Config.Rewind_OnDisk, capacity, BufferManage);

                    if (_rewindThread != null)
                    {
                        _rewindThread.Dispose();
                    }

                    _rewindThread = new RewindThreader(this, Global.Config.Rewind_IsThreaded);
                }
            }
        }
コード例 #3
0
ファイル: Rewinder.cs プロジェクト: hayate891/BizHawk
        public void Clear()
        {
            if (_rewindThread != null)
            {
                _rewindThread.Dispose();
                _rewindThread = null;
            }

            if (_rewindBuffer != null)
            {
                _rewindBuffer.Dispose();
                _rewindBuffer = null;
            }

            _lastState = new byte[0];
        }
コード例 #4
0
        public void Uninitialize()
        {
            if (_rewindThread != null)
            {
                _rewindThread.Dispose();
                _rewindThread = null;
            }

            if (_rewindBuffer != null)
            {
                _rewindBuffer.Dispose();
                _rewindBuffer = null;
            }

            Clear();

            RewindEnabled   = false;
            RewindFrequency = 0;
        }
コード例 #5
0
        public void Initialize()
        {
            Uninitialize();

            if (Global.Emulator.HasSavestates())
            {
                int stateSize = Global.Emulator.AsStatable().SaveStateBinary().Length;

                if (stateSize >= Global.Config.Rewind_LargeStateSize)
                {
                    RewindEnabled   = Global.Config.RewindEnabledLarge;
                    RewindFrequency = Global.Config.RewindFrequencyLarge;
                }
                else if (stateSize >= Global.Config.Rewind_MediumStateSize)
                {
                    RewindEnabled   = Global.Config.RewindEnabledMedium;
                    RewindFrequency = Global.Config.RewindFrequencyMedium;
                }
                else
                {
                    RewindEnabled   = Global.Config.RewindEnabledSmall;
                    RewindFrequency = Global.Config.RewindFrequencySmall;
                }
            }

            DoMessage(RewindEnabled ?
                      $"Rewind enabled, frequency: {RewindFrequency}" :
                      "Rewind disabled");

            _rewindDeltaEnable = Global.Config.Rewind_UseDelta;

            if (RewindActive)
            {
                var capacity = Global.Config.Rewind_BufferSize * (long)1024 * 1024;

                _rewindBuffer = new StreamBlobDatabase(Global.Config.Rewind_OnDisk, capacity, BufferManage);

                _rewindThread = new RewindThreader(CaptureInternal, RewindInternal, Global.Config.Rewind_IsThreaded);
            }
        }
コード例 #6
0
ファイル: Rewinder.cs プロジェクト: hayate891/BizHawk
        public void Initialize()
        {
            Clear();

            if (Global.Emulator.HasSavestates())
            {
                int stateSize = Global.Emulator.AsStatable().SaveStateBinary().Length;

                if (stateSize >= Global.Config.Rewind_LargeStateSize)
                {
                    SetRewindParams(Global.Config.RewindEnabledLarge, Global.Config.RewindFrequencyLarge);
                }
                else if (stateSize >= Global.Config.Rewind_MediumStateSize)
                {
                    SetRewindParams(Global.Config.RewindEnabledMedium, Global.Config.RewindFrequencyMedium);
                }
                else
                {
                    SetRewindParams(Global.Config.RewindEnabledSmall, Global.Config.RewindFrequencySmall);
                }
            }
            else
            {
                SetRewindParams(false, 1);
            }

            _rewindDeltaEnable = Global.Config.Rewind_UseDelta;

            if (RewindActive)
            {
                var capacity = Global.Config.Rewind_BufferSize * (long)1024 * 1024;

                _rewindBuffer = new StreamBlobDatabase(Global.Config.Rewind_OnDisk, capacity, BufferManage);

                _rewindThread = new RewindThreader(CaptureInternal, RewindInternal, Global.Config.Rewind_IsThreaded);
            }
        }
コード例 #7
0
ファイル: Rewinder.cs プロジェクト: henke37/BizHawk
		public void DoRewindSettings()
		{
			if (_rewindThread != null)
			{
				_rewindThread.Dispose();
				_rewindThread = null;
			}

			if (Global.Emulator.HasSavestates())
			{
				// This is the first frame. Capture the state, and put it in LastState for future deltas to be compared against.
				_lastState = (byte[])Global.Emulator.AsStatable().SaveStateBinary().Clone();

				int state_size;
				if (_lastState.Length >= Global.Config.Rewind_LargeStateSize)
				{
					SetRewindParams(Global.Config.RewindEnabledLarge, Global.Config.RewindFrequencyLarge);
					state_size = 3;
				}
				else if (_lastState.Length >= Global.Config.Rewind_MediumStateSize)
				{
					SetRewindParams(Global.Config.RewindEnabledMedium, Global.Config.RewindFrequencyMedium);
					state_size = 2;
				}
				else
				{
					SetRewindParams(Global.Config.RewindEnabledSmall, Global.Config.RewindFrequencySmall);
					state_size = 1;
				}

				var rewind_enabled = false;
				if (state_size == 1)
				{
					rewind_enabled = Global.Config.RewindEnabledSmall;
				}
				else if (state_size == 2)
				{
					rewind_enabled = Global.Config.RewindEnabledMedium;
				}
				else if (state_size == 3)
				{
					rewind_enabled = Global.Config.RewindEnabledLarge;
				}

				_rewindDeltaEnable = Global.Config.Rewind_UseDelta;

				if (rewind_enabled)
				{
					var capacity = Global.Config.Rewind_BufferSize * (long)1024 * 1024;

					if (_rewindBuffer != null)
					{
						_rewindBuffer.Dispose();
					}

					_rewindBuffer = new StreamBlobDatabase(Global.Config.Rewind_OnDisk, capacity, BufferManage);

					_rewindThread = new RewindThreader(this, Global.Config.Rewind_IsThreaded);
				}
			}
		}