From e1d1095c3e671c6565e9b2f2174f39de05303201 Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 3 Dec 2013 15:59:46 +0000 Subject: [PATCH] Movie stuff --- BizHawk.Client.Common/movie/IMovie.cs | 29 +++++++++++++++---- BizHawk.Client.Common/movie/Movie.cs | 8 +++--- BizHawk.Client.Common/movie/MovieSession.cs | 3 +- BizHawk.Client.Common/movie/TasMovie.cs | 31 +++++++++++++++++---- 4 files changed, 55 insertions(+), 16 deletions(-) diff --git a/BizHawk.Client.Common/movie/IMovie.cs b/BizHawk.Client.Common/movie/IMovie.cs index a65a9901a2..5f79959aad 100644 --- a/BizHawk.Client.Common/movie/IMovie.cs +++ b/BizHawk.Client.Common/movie/IMovie.cs @@ -83,22 +83,41 @@ namespace BizHawk.Client.Common #region Editing API + /// + /// Repalces the given frame's input with an empty frame + /// + /// void ClearFrame(int frame); + + /// + /// Adds the given input to the movie + /// Note: this edits the input log without the normal movie recording logic applied + /// + /// void AppendFrame(MnemonicsGenerator mg); + + /// + /// Replaces the input at the given frame with the given input + /// Note: this edits the input log without the normal movie recording logic applied + /// + void PokeFrame(int frame, MnemonicsGenerator mg); + + /// + /// Records the given input into the given frame, + /// This is subject to normal movie recording logic + /// + void RecordFrame(int frame, MnemonicsGenerator mg); + void Truncate(int frame); + string GetInput(int frame); #endregion #region Dubious, should reconsider - void CommitFrame(int frameNum, MnemonicsGenerator mg); // Why pass in frameNum? Calling api - void PokeFrame(int frameNum, MnemonicsGenerator mg); // Why does this exist as something different than Commit Frame? LoadStateResult CheckTimeLines(TextReader reader, bool onlyGuid, bool ignoreGuidMismatch, out string errorMessage); // No need to return a status, no reason to have hacky flags, no need to pass a textreader - void ExtractInputLog(TextReader reader, bool isMultitracking); // how about the movie know if it is multi-tracking rather than having to pass it in - string GetInput(int frame); // Should be a property of a Record object - #endregion } } diff --git a/BizHawk.Client.Common/movie/Movie.cs b/BizHawk.Client.Common/movie/Movie.cs index 6fd7c5d791..df6401d6e3 100644 --- a/BizHawk.Client.Common/movie/Movie.cs +++ b/BizHawk.Client.Common/movie/Movie.cs @@ -366,13 +366,13 @@ namespace BizHawk.Client.Common #region Public Misc Methods - public void PokeFrame(int frameNum, MnemonicsGenerator mg) + public void PokeFrame(int frame, MnemonicsGenerator mg) { _changes = true; - _log.SetFrameAt(frameNum, mg.GetControllersAsMnemonic()); + _log.SetFrameAt(frame, mg.GetControllersAsMnemonic()); } - public void CommitFrame(int frameNum, MnemonicsGenerator mg) + public void RecordFrame(int frame, MnemonicsGenerator mg) { // Note: Truncation here instead of loadstate will make VBA style loadstates // (Where an entire movie is loaded then truncated on the next frame @@ -386,7 +386,7 @@ namespace BizHawk.Client.Common } _changes = true; - _log.SetFrameAt(frameNum, mg.GetControllersAsMnemonic()); + _log.SetFrameAt(frame, mg.GetControllersAsMnemonic()); } public string GetInputLog() diff --git a/BizHawk.Client.Common/movie/MovieSession.cs b/BizHawk.Client.Common/movie/MovieSession.cs index 8934f8b08b..2f12631d60 100644 --- a/BizHawk.Client.Common/movie/MovieSession.cs +++ b/BizHawk.Client.Common/movie/MovieSession.cs @@ -141,7 +141,6 @@ namespace BizHawk.Client.Common else if (Movie.IsPlaying) { - LatchInputFromLog(); //Movie may go into finished mode as a result from latching @@ -184,7 +183,7 @@ namespace BizHawk.Client.Common //this has been wired to Global.MovieOutputHardpoint in RewireInputChain var mg = new MnemonicsGenerator(); mg.SetSource(Global.MovieOutputHardpoint); - Movie.CommitFrame(Global.Emulator.Frame, mg); + Movie.RecordFrame(Global.Emulator.Frame, mg); } } diff --git a/BizHawk.Client.Common/movie/TasMovie.cs b/BizHawk.Client.Common/movie/TasMovie.cs index 4d70f70910..6b1b12ee7f 100644 --- a/BizHawk.Client.Common/movie/TasMovie.cs +++ b/BizHawk.Client.Common/movie/TasMovie.cs @@ -169,25 +169,46 @@ namespace BizHawk.Client.Common public void ClearFrame(int frame) { - throw new NotImplementedException(); + if (frame < _records.Count) + { + Changes = true; + _records[frame].Input = MnemonicsGenerator.GetEmptyMnemonic; + } } public void AppendFrame(MnemonicsGenerator mg) { + Changes = true; _records.Add(new MovieRecord() { Input = mg.GetControllersAsMnemonic(), }); } - public void CommitFrame(int frameNum, MnemonicsGenerator mg) + public void RecordFrame(int frame, MnemonicsGenerator mg) { - throw new NotImplementedException(); + if (_mode == Moviemode.Record) + { + Changes = true; + if (Global.Config.VBAStyleMovieLoadState) + { + if (Global.Emulator.Frame < _records.Count) + { + _records.Truncate(Global.Emulator.Frame); + } + } + + PokeFrame(frame, mg); + } } - public void PokeFrame(int frameNum, MnemonicsGenerator mg) + public void PokeFrame(int frame, MnemonicsGenerator mg) { - throw new NotImplementedException(); + if (frame < _records.Count) + { + Changes = true; + _records[frame].Input = mg.GetControllersAsMnemonic(); + } } public LoadStateResult CheckTimeLines(System.IO.TextReader reader, bool onlyGuid, bool ignoreGuidMismatch, out string errorMessage)