Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
        public void Clear()
        {
            if (_rewindThread != null)
            {
                _rewindThread.Dispose();
                _rewindThread = null;
            }

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

            _lastState = new byte[0];
        }
Ejemplo n.º 3
0
        public void Uninitialize()
        {
            if (_rewindThread != null)
            {
                _rewindThread.Dispose();
                _rewindThread = null;
            }

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

            Clear();

            RewindEnabled   = false;
            RewindFrequency = 0;
        }