예제 #1
0
        public void Attach(IEmulator emulator)
        {
            if (!_emulator.IsNull())
            {
                throw new InvalidOperationException("A core has already been attached!");
            }

            if (!emulator.HasSavestates())
            {
                throw new InvalidOperationException($"A core must be able to provide an {nameof(IStatable)} service");
            }

            _emulator = emulator;
            _core     = emulator.AsStatable();

            _decay = new StateManagerDecay(_movie, this);

            _expectedStateSizeInMb = _core.CloneSavestate().Length / (double)(1024 * 1024);
            if (_expectedStateSizeInMb.HawkFloatEquality(0))
            {
                throw new InvalidOperationException("Savestate size can not be zero!");
            }

            // don't erase states if they exist already (already loaded)
            if ((_states == null) || (_states.Capacity == 0))
            {
                _states = new SortedList <int, byte[]>(MaxStates);
            }

            UpdateStateFrequency();
        }
예제 #2
0
        public void Attach(IEmulator emulator)
        {
            // TODO: we aren't ready for this, attach is called when converting a bk2 to tasproj and again to officially load the emulator
            //if (!_emulator.IsNull())
            //{
            //	throw new InvalidOperationException("A core has already been attached!");
            //}

            if (!emulator.HasSavestates())
            {
                throw new InvalidOperationException($"A core must be able to provide an {nameof(IStatable)} service");
            }

            _emulator = emulator;
            _core     = emulator.AsStatable();

            _decay = new StateManagerDecay(_movie, this);

            _expectedStateSizeInMb = _core.CloneSavestate().Length / (double)(1024 * 1024);
            if (_expectedStateSizeInMb.HawkFloatEquality(0))
            {
                throw new InvalidOperationException("Savestate size can not be zero!");
            }

            _states = new SortedList <int, byte[]>(MaxStates);

            UpdateStateFrequency();
        }
예제 #3
0
        public TasStateManager(TasMovie movie)
        {
            _movie   = movie;
            Settings = new TasStateManagerSettings(Global.Config.DefaultTasProjSettings);

            if (_movie.StartsFromSavestate)
            {
                SetState(0, _movie.BinarySavestate);
            }

            _decay = new StateManagerDecay(this);
        }
예제 #4
0
        public TasStateManager(TasMovie movie)
        {
            _movie   = movie;
            Settings = new TasStateManagerSettings(Global.Config.DefaultTasProjSettings);

            if (_movie.StartsFromSavestate)
            {
                SetState(0, _movie.BinarySavestate);
            }

            _decay = new StateManagerDecay(_movie, this);

            _expectedStateSize = (ulong)Core.SaveStateBinary().Length;
            if (_expectedStateSize == 0)
            {
                throw new InvalidOperationException("Savestate size can not be zero!");
            }

            _states = new SortedList <int, byte[]>(MaxStates);

            UpdateStateFrequency();
        }