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 RecordMovie( MainForm mainForm, Config config, GameInfo game, IEmulator core, IMovieSession movieSession) { _mainForm = mainForm; _config = config; _game = game; _emulator = core; _movieSession = movieSession; InitializeComponent(); if (!_emulator.HasSavestates()) { StartFromCombo.Items.Remove( StartFromCombo.Items .OfType <object>() .First(i => i.ToString() .ToLower() == "now")); } if (!_emulator.HasSaveRam()) { StartFromCombo.Items.Remove( StartFromCombo.Items .OfType <object>() .First(i => i.ToString() .ToLower() == "saveram")); } }
public void Update(IEmulator emulator, IMovie movie, string saveStatePrefix) { if (!emulator.HasSavestates()) { for (int i = 0; i < 10; i++) { _slots[i] = false; } return; } for (int i = 0; i < 10; i++) { if (movie is ITasMovie tasMovie) { _slots[i] = i < tasMovie.Branches.Count; } else { var file = new FileInfo($"{saveStatePrefix}.QuickSave{i}.State"); if (file.Directory != null && file.Directory.Exists == false) { file.Directory.Create(); } _slots[i] = file.Exists; } } }
public override void Attach(IEmulator emulator) { if (!emulator.HasSavestates()) { throw new InvalidOperationException($"A core must be able to provide an {nameof(IStatable)} service"); } if (!emulator.CanPollInput()) { throw new InvalidOperationException($"A core must be able to provide an {nameof(IInputPollable)} service"); } _inputPollable = emulator.AsInputPollable(); if (StartsFromSavestate) { TasStateManager.Engage(BinarySavestate); } else { var ms = new MemoryStream(); emulator.AsStatable().SaveStateBinary(new BinaryWriter(ms)); TasStateManager.Engage(ms.ToArray()); } base.Attach(emulator); foreach (var button in emulator.ControllerDefinition.BoolButtons) { _mnemonicCache[button] = Bk2MnemonicLookup.Lookup(button, emulator.SystemId); } }
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 RecordMovie( IMainFormForTools mainForm, Config config, GameInfo game, IEmulator core, IMovieSession movieSession, FirmwareManager firmwareManager) { _mainForm = mainForm; _config = config; _game = game; _emulator = core; _movieSession = movieSession; _firmwareManager = firmwareManager; InitializeComponent(); Icon = Properties.Resources.TAStudioIcon; BrowseBtn.Image = Properties.Resources.OpenFile; if (OSTailoredCode.IsUnixHost) { Load += (_, _) => { //HACK to make this usable on Linux. No clue why this Form in particular is so much worse, maybe the GroupBox? --yoshi groupBox1.Height -= 24; DefaultAuthorCheckBox.Location += new Size(0, 32); var s = new Size(0, 40); OK.Location += s; Cancel.Location += s; } } ; if (!_emulator.HasSavestates()) { StartFromCombo.Items.Remove( StartFromCombo.Items .OfType <object>() .First(i => i.ToString() .ToLower() == "now")); } if (!_emulator.HasSaveRam()) { StartFromCombo.Items.Remove( StartFromCombo.Items .OfType <object>() .First(i => i.ToString() .ToLower() == "saveram")); } }
public bool HasSlot(IEmulator emulator, IMovie movie, int slot, string savestatePrefix) { if (!emulator.HasSavestates()) { return(false); } if (!0.RangeTo(10).Contains(slot)) { return(false); } Update(emulator, movie, savestatePrefix); return(_slots[slot]); }
// TODO - Allow relative paths in record textbox public RecordMovie(IEmulator core) { InitializeComponent(); Emulator = core; if (!Emulator.HasSavestates()) { StartFromCombo.Items.Remove( StartFromCombo.Items .OfType <object>() .First(i => i.ToString() .ToLower() == "now")); } }
public override void Attach(IEmulator emulator) { if (!emulator.HasSavestates()) { throw new InvalidOperationException($"A core must be able to provide an {nameof(IStatable)} service"); } if (!emulator.CanPollInput()) { throw new InvalidOperationException($"A core must be able to provide an {nameof(IInputPollable)} service"); } _inputPollable = emulator.AsInputPollable(); TasStateManager.Attach(emulator); base.Attach(emulator); }
public SavestateFile(IEmulator emulator, IMovieSession movieSession, IDictionary <string, object> userBag) { if (!emulator.HasSavestates()) { throw new InvalidOperationException("The provided core must have savestates"); } _emulator = emulator; _statable = emulator.AsStatable(); if (emulator.HasVideoProvider()) { _videoProvider = emulator.AsVideoProvider(); } _movieSession = movieSession; _userBag = userBag; }
/// <summary> /// If the given movie contains a savestate it will be loaded if /// the given core has savestates, and a framebuffer populated /// if it is contained in the state and the given core supports it /// </summary> public static void ProcessSavestate(this IMovie movie, IEmulator emulator) { if (emulator.HasSavestates() && movie.StartsFromSavestate) { if (movie.TextSavestate != null) { emulator.AsStatable().LoadStateText(movie.TextSavestate); } else { emulator.AsStatable().LoadStateBinary(movie.BinarySavestate); } if (movie.SavestateFramebuffer != null && emulator.HasVideoProvider()) { emulator.AsVideoProvider().PopulateFromBuffer(movie.SavestateFramebuffer); } emulator.ResetCounters(); } }
public override void Attach(IEmulator emulator) { if (!emulator.HasSavestates()) { throw new InvalidOperationException($"A core must be able to provide an {nameof(IStatable)} service"); } if (!emulator.CanPollInput()) { throw new InvalidOperationException($"A core must be able to provide an {nameof(IInputPollable)} service"); } _inputPollable = emulator.AsInputPollable(); TasStateManager.Attach(emulator); base.Attach(emulator); foreach (var button in emulator.ControllerDefinition.BoolButtons) { _mnemonicCache[button] = Bk2MnemonicLookup.Lookup(button, emulator.SystemId); } }
public RecordMovie( IMainFormForTools mainForm, Config config, GameInfo game, IEmulator core, IMovieSession movieSession, FirmwareManager firmwareManager) { _mainForm = mainForm; _config = config; _game = game; _emulator = core; _movieSession = movieSession; _firmwareManager = firmwareManager; InitializeComponent(); Icon = Properties.Resources.TAStudio_MultiSize; BrowseBtn.Image = Properties.Resources.OpenFile; if (!_emulator.HasSavestates()) { StartFromCombo.Items.Remove( StartFromCombo.Items .OfType <object>() .First(i => i.ToString() .ToLower() == "now")); } if (!_emulator.HasSaveRam()) { StartFromCombo.Items.Remove( StartFromCombo.Items .OfType <object>() .First(i => i.ToString() .ToLower() == "saveram")); } }
private void Ok_Click(object sender, EventArgs e) { var path = MakePath(); if (!string.IsNullOrWhiteSpace(path)) { var test = new FileInfo(path); if (test.Exists) { var result = MessageBox.Show(path + " already exists, overwrite?", "Confirm overwrite", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (result == DialogResult.Cancel) { return; } } var movieToRecord = MovieService.Get(path); var fileInfo = new FileInfo(path); if (!fileInfo.Exists) { Directory.CreateDirectory(fileInfo.DirectoryName); } if (StartFromCombo.SelectedItem.ToString() == "Now" && Emulator.HasSavestates()) { var core = Emulator.AsStatable(); movieToRecord.StartsFromSavestate = true; movieToRecord.StartsFromSaveRam = false; if (core.BinarySaveStatesPreferred) { movieToRecord.BinarySavestate = (byte[])core.SaveStateBinary().Clone(); } else { using (var sw = new StringWriter()) { core.SaveStateText(sw); movieToRecord.TextSavestate = sw.ToString(); } } // TODO: do we want to support optionally not saving this? if (true) { // hack: some IMovies eat the framebuffer, so don't bother with them movieToRecord.SavestateFramebuffer = new int[0]; if (movieToRecord.SavestateFramebuffer != null && Emulator.HasVideoProvider()) { movieToRecord.SavestateFramebuffer = (int[])Emulator.AsVideoProvider().GetVideoBuffer().Clone(); } } } else if (StartFromCombo.SelectedItem.ToString() == "SaveRam" && Emulator.HasSaveRam()) { var core = Emulator.AsSaveRam(); movieToRecord.StartsFromSavestate = false; movieToRecord.StartsFromSaveRam = true; movieToRecord.SaveRam = core.CloneSaveRam(); } movieToRecord.PopulateWithDefaultHeaderValues(AuthorBox.Text); movieToRecord.Save(); GlobalWin.MainForm.StartNewMovie(movieToRecord, true); Global.Config.UseDefaultAuthor = DefaultAuthorCheckBox.Checked; if (DefaultAuthorCheckBox.Checked) { Global.Config.DefaultAuthor = AuthorBox.Text; } Close(); } else { MessageBox.Show("Please select a movie to record", "File selection error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Ok_Click(object sender, EventArgs e) { var path = MakePath(); if (!string.IsNullOrWhiteSpace(path)) { var test = new FileInfo(path); if (test.Exists) { var result = DialogController.ShowMessageBox2($"{path} already exists, overwrite?", "Confirm overwrite", EMsgBoxIcon.Warning, useOKCancel: true); if (!result) { return; } } var movieToRecord = _movieSession.Get(path); var fileInfo = new FileInfo(path); if (!fileInfo.Exists) { Directory.CreateDirectory(fileInfo.DirectoryName); } if (StartFromCombo.SelectedItem.ToString() == "Now" && _emulator.HasSavestates()) { var core = _emulator.AsStatable(); movieToRecord.StartsFromSavestate = true; if (_config.Savestates.Type == SaveStateType.Binary) { movieToRecord.BinarySavestate = core.CloneSavestate(); } else { using var sw = new StringWriter(); core.SaveStateText(sw); movieToRecord.TextSavestate = sw.ToString(); } // TODO: do we want to support optionally not saving this? movieToRecord.SavestateFramebuffer = Array.Empty <int>(); if (_emulator.HasVideoProvider()) { movieToRecord.SavestateFramebuffer = (int[])_emulator.AsVideoProvider().GetVideoBuffer().Clone(); } } else if (StartFromCombo.SelectedItem.ToString() == "SaveRam" && _emulator.HasSaveRam()) { var core = _emulator.AsSaveRam(); movieToRecord.StartsFromSaveRam = true; movieToRecord.SaveRam = core.CloneSaveRam(); } movieToRecord.PopulateWithDefaultHeaderValues( _emulator, _game, _firmwareManager, AuthorBox.Text ?? _config.DefaultAuthor); movieToRecord.Save(); _mainForm.StartNewMovie(movieToRecord, true); _config.UseDefaultAuthor = DefaultAuthorCheckBox.Checked; if (DefaultAuthorCheckBox.Checked) { _config.DefaultAuthor = AuthorBox.Text; } Close(); } else { DialogController.ShowMessageBox("Please select a movie to record", "File selection error", EMsgBoxIcon.Error); } }