diff --git a/BizHawk.MultiClient/Input/ControllerBinding.cs b/BizHawk.MultiClient/Input/ControllerBinding.cs index 06792b05d3..09321a116a 100644 --- a/BizHawk.MultiClient/Input/ControllerBinding.cs +++ b/BizHawk.MultiClient/Input/ControllerBinding.cs @@ -317,8 +317,7 @@ namespace BizHawk.MultiClient } } else - { - Console.WriteLine(mnemonic); + { for (int i = 1; i < 6; i++) { if ((Global.MainForm.UserMovie.MultiTrack.CurrentPlayer == i) || Global.MainForm.UserMovie.MultiTrack.RecordAll) diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index b7825856d9..edcf62a9ee 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -1136,7 +1136,7 @@ namespace BizHawk.MultiClient Global.RenderPanel.MT = "Recording None"; } else - Global.RenderPanel.AddMessage("MultiTrack Disabled"); + Global.RenderPanel.AddMessage("MultiTrack Disabled"); Global.MainForm.UserMovie.MultiTrack.RecordAll = false; Global.MainForm.UserMovie.MultiTrack.CurrentPlayer = 0; Global.ClientControls.UnpressButton("Toggle MultiTrack"); @@ -1306,9 +1306,10 @@ namespace BizHawk.MultiClient Global.ActiveController.SetControllersAsMnemonic(UserMovie.GetInputFrame(Global.Emulator.Frame) + 1); } } - if (UserMovie.GetMovieMode() == MOVIEMODE.RECORD && Global.MainForm.UserMovie.MultiTrack.isActive) - { - Global.ActiveController.SetControllersAsMnemonic(UserMovie.GetInputFrame(Global.Emulator.Frame) + 1); + if (UserMovie.GetMovieMode() == MOVIEMODE.RECORD && UserMovie.MultiTrack.isActive) + { + Global.ActiveController.SetControllersAsMnemonic(UserMovie.GetInputFrame(Global.Emulator.Frame-1)); + //Console.WriteLine("Out: " + UserMovie.GetInputFrame(Global.Emulator.Frame)); } Global.Emulator.FrameAdvance(!throttle.skipnextframe); RamWatch1.UpdateValues(); @@ -1318,10 +1319,13 @@ namespace BizHawk.MultiClient NESPPU1.UpdateValues(); TAStudio1.UpdateValues(); - if (UserMovie.GetMovieMode() == MOVIEMODE.RECORD) - UserMovie.GetMnemonic(); - else if (InputLog.GetMovieMode() == MOVIEMODE.RECORD) - InputLog.GetMnemonic(); + if (UserMovie.GetMovieMode() == MOVIEMODE.RECORD) + { + UserMovie.GetMnemonic(); + //Console.WriteLine("In: " + UserMovie.GetInputFrame(Global.Emulator.Frame)); + } + else if (InputLog.GetMovieMode() == MOVIEMODE.RECORD) + InputLog.GetMnemonic(); } if (genSound) diff --git a/BizHawk.MultiClient/movie/Movie.cs b/BizHawk.MultiClient/movie/Movie.cs index be5cc84fd6..58b1dfe991 100644 --- a/BizHawk.MultiClient/movie/Movie.cs +++ b/BizHawk.MultiClient/movie/Movie.cs @@ -84,30 +84,30 @@ namespace BizHawk.MultiClient public void GetMnemonic() { - if (MultiTrack.isActive) - { - if (MovieMode == MOVIEMODE.RECORD) - { - - if (Global.Emulator.Frame < Log.Length()) - Log.AddFrameAt(Global.ActiveController.GetControllersAsMnemonic(), Global.Emulator.Frame - 1); - else - Log.AddFrame(Global.ActiveController.GetControllersAsMnemonic()); - } - } - else - if (MovieMode == MOVIEMODE.RECORD) - { - - if (Global.Emulator.Frame < Log.Length()) - { - Log.Truncate(Global.Emulator.Frame); - } - // if (Global.MainForm.TAStudio1.Engaged) - // Log.AddFrame(Global.MainForm.TAStudio1.GetMnemonic()); - // else - Log.AddFrame(Global.ActiveController.GetControllersAsMnemonic()); - } + if (MultiTrack.isActive) + { + if (MovieMode == MOVIEMODE.RECORD) + { + + if (Global.Emulator.Frame < Log.Length()) + Log.ReplaceFrameAt(Global.ActiveController.GetControllersAsMnemonic(),Global.Emulator.Frame); + else + Log.AddFrame(Global.ActiveController.GetControllersAsMnemonic()); + } + } + else + if (MovieMode == MOVIEMODE.RECORD) + { + + if (Global.Emulator.Frame < Log.Length()) + { + Log.Truncate(Global.Emulator.Frame); + } + // if (Global.MainForm.TAStudio1.Engaged) + // Log.AddFrame(Global.MainForm.TAStudio1.GetMnemonic()); + // else + Log.AddFrame(Global.ActiveController.GetControllersAsMnemonic()); + } } public string GetInputFrame(int frame) @@ -349,17 +349,37 @@ namespace BizHawk.MultiClient public void LoadLogFromSavestateText(TextReader reader) { //We are in record mode so replace the movie log with the one from the savestate - Log.Clear(); - while (true) - { - string line = reader.ReadLine(); - if (line == null) break; - if (line.Trim() == "") continue; - if (line == "[Input]") continue; - if (line == "[/Input]") break; - if (line[0] == '|') - Log.AddFrame(line); - } + if (!MultiTrack.isActive) + { + Log.Clear(); + while (true) + { + string line = reader.ReadLine(); + if (line == null) break; + if (line.Trim() == "") continue; + if (line == "[Input]") continue; + if (line == "[/Input]") break; + if (line[0] == '|') + Log.AddFrame(line); + } + } + else + { + int i = 0; + while (true) + { + string line = reader.ReadLine(); + if (line == null) break; + if (line.Trim() == "") continue; + if (line == "[Input]") continue; + if (line == "[/Input]") break; + if (line[0] == '|') + { + Log.ReplaceFrameAt(line, i); + i++; + } + } + } //TODO: we can truncate the movie down to the current frame now (in case the savestate has a larger input log) //However, VBA will load it all, then truncate on the next frame, do we want that? IncrementRerecordCount(); diff --git a/BizHawk.MultiClient/movie/MovieLog.cs b/BizHawk.MultiClient/movie/MovieLog.cs index 0614c9dbae..a17ae80ab5 100644 --- a/BizHawk.MultiClient/movie/MovieLog.cs +++ b/BizHawk.MultiClient/movie/MovieLog.cs @@ -39,7 +39,13 @@ namespace BizHawk.MultiClient { MovieRecords.Add(frame); } - + public void ReplaceFrameAt(string frame, int frameNum) + { + if (MovieRecords.Count > frameNum) + MovieRecords[frameNum] = frame; + else + MovieRecords.Insert(frameNum, frame); + } public void AddFrameAt(string frame, int frameNum) { MovieRecords.Insert(frameNum, frame);