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(); }
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(); }
public TasStateManager(TasMovie movie) { _movie = movie; Settings = new TasStateManagerSettings(Global.Config.DefaultTasProjSettings); if (_movie.StartsFromSavestate) { SetState(0, _movie.BinarySavestate); } _decay = new StateManagerDecay(this); }
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(); }