From d7ba739b3082de63022e41e2e1328ebcb4dc8eeb Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Mon, 28 Feb 2011 01:26:38 +0000 Subject: [PATCH] Some fix ups to input recording, and setting up the ability to test recording & playback --- BizHawk.Emulation/Consoles/PC Engine/Input.cs | 38 ++-- BizHawk.Emulation/Consoles/Sega/SMS/Input.cs | 1 - BizHawk.MultiClient/MainForm.Designer.cs | 30 ++-- BizHawk.MultiClient/MainForm.MenuItems.cs | 8 +- BizHawk.MultiClient/MainForm.cs | 22 ++- BizHawk.MultiClient/movie/Movie.cs | 4 +- BizHawk.MultiClient/output/log.tas | 170 ------------------ 7 files changed, 68 insertions(+), 205 deletions(-) delete mode 100644 BizHawk.MultiClient/output/log.tas diff --git a/BizHawk.Emulation/Consoles/PC Engine/Input.cs b/BizHawk.Emulation/Consoles/PC Engine/Input.cs index ed01895563..820bfb7794 100644 --- a/BizHawk.Emulation/Consoles/PC Engine/Input.cs +++ b/BizHawk.Emulation/Consoles/PC Engine/Input.cs @@ -14,30 +14,48 @@ public void SetControllersAsMnemonic(string mnemonic) { - return; //TODO + if (mnemonic.Length == 0) return; + + if (mnemonic[1] != '.') + Controller.ForceButton("Up"); + if (mnemonic[2] != '.') + Controller.ForceButton("Down"); + if (mnemonic[3] != '.') + Controller.ForceButton("Left"); + if (mnemonic[4] != '.') + Controller.ForceButton("Right"); + if (mnemonic[5] != '.') + Controller.ForceButton("I"); + if (mnemonic[6] != '.') + Controller.ForceButton("II"); + if (mnemonic[7] != '.') + Controller.ForceButton("Select"); + if (mnemonic[8] != '.') + Controller.ForceButton("Run"); } public string GetControllersAsMnemonic() { //TODO: Implement all controllers - string input = ""; + string input = "|"; + if (Controller.IsPressed("Up")) input += "U"; - else input += " "; + else input += "."; if (Controller.IsPressed("Down")) input += "D"; - else input += " "; + else input += "."; if (Controller.IsPressed("Left")) input += "L"; - else input += " "; + else input += "."; if (Controller.IsPressed("Right")) input += "R"; - else input += " "; + else input += "."; if (Controller.IsPressed("I")) input += "1"; - else input += " "; + else input += "."; if (Controller.IsPressed("II")) input += "2"; - else input += " "; + else input += "."; if (Controller.IsPressed("Select")) input += "S"; - else input += " "; + else input += "."; if (Controller.IsPressed("Run")) input += "R"; - else input += " "; + else input += "."; input += "|.|"; //TODO: Add commands like reset here diff --git a/BizHawk.Emulation/Consoles/Sega/SMS/Input.cs b/BizHawk.Emulation/Consoles/Sega/SMS/Input.cs index 2aa4bf02b5..9dfddb444d 100644 --- a/BizHawk.Emulation/Consoles/Sega/SMS/Input.cs +++ b/BizHawk.Emulation/Consoles/Sega/SMS/Input.cs @@ -46,7 +46,6 @@ if (mnemonic[15] != '.' && mnemonic[15] != '0') Controller.ForceButton("Reset"); - } diff --git a/BizHawk.MultiClient/MainForm.Designer.cs b/BizHawk.MultiClient/MainForm.Designer.cs index 7228f7a086..ccab41f659 100644 --- a/BizHawk.MultiClient/MainForm.Designer.cs +++ b/BizHawk.MultiClient/MainForm.Designer.cs @@ -157,6 +157,7 @@ this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.helpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.replayInputLogToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -613,7 +614,8 @@ this.recordMovieToolStripMenuItem, this.playMovieToolStripMenuItem, this.stopMovieToolStripMenuItem, - this.playFromBeginningToolStripMenuItem}); + this.playFromBeginningToolStripMenuItem, + this.replayInputLogToolStripMenuItem}); this.movieToolStripMenuItem.Name = "movieToolStripMenuItem"; this.movieToolStripMenuItem.Size = new System.Drawing.Size(177, 22); this.movieToolStripMenuItem.Text = "Movie"; @@ -870,26 +872,26 @@ // controllersToolStripMenuItem // this.controllersToolStripMenuItem.Name = "controllersToolStripMenuItem"; - this.controllersToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.controllersToolStripMenuItem.Size = new System.Drawing.Size(143, 22); this.controllersToolStripMenuItem.Text = "&Controllers"; this.controllersToolStripMenuItem.Click += new System.EventHandler(this.controllersToolStripMenuItem_Click); // // hotkeysToolStripMenuItem // this.hotkeysToolStripMenuItem.Name = "hotkeysToolStripMenuItem"; - this.hotkeysToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.hotkeysToolStripMenuItem.Size = new System.Drawing.Size(143, 22); this.hotkeysToolStripMenuItem.Text = "&Hotkeys"; this.hotkeysToolStripMenuItem.Click += new System.EventHandler(this.hotkeysToolStripMenuItem_Click); // // toolStripSeparator9 // this.toolStripSeparator9.Name = "toolStripSeparator9"; - this.toolStripSeparator9.Size = new System.Drawing.Size(149, 6); + this.toolStripSeparator9.Size = new System.Drawing.Size(140, 6); // // soundToolStripMenuItem // this.soundToolStripMenuItem.Name = "soundToolStripMenuItem"; - this.soundToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.soundToolStripMenuItem.Size = new System.Drawing.Size(143, 22); this.soundToolStripMenuItem.Text = "&Sound"; this.soundToolStripMenuItem.Click += new System.EventHandler(this.soundToolStripMenuItem_Click); // @@ -900,7 +902,7 @@ this.saveWindowPositionToolStripMenuItem, this.startPausedToolStripMenuItem}); this.gUIToolStripMenuItem.Name = "gUIToolStripMenuItem"; - this.gUIToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.gUIToolStripMenuItem.Size = new System.Drawing.Size(143, 22); this.gUIToolStripMenuItem.Text = "GUI"; this.gUIToolStripMenuItem.DropDownOpened += new System.EventHandler(this.gUIToolStripMenuItem_DropDownOpened); // @@ -949,7 +951,7 @@ this.miSpeed150, this.miSpeed200}); this.frameSkipToolStripMenuItem.Name = "frameSkipToolStripMenuItem"; - this.frameSkipToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.frameSkipToolStripMenuItem.Size = new System.Drawing.Size(143, 22); this.frameSkipToolStripMenuItem.Text = "Speed/Skip"; this.frameSkipToolStripMenuItem.DropDownOpened += new System.EventHandler(this.frameSkipToolStripMenuItem_DropDownOpened); // @@ -1092,19 +1094,19 @@ // toolStripSeparator10 // this.toolStripSeparator10.Name = "toolStripSeparator10"; - this.toolStripSeparator10.Size = new System.Drawing.Size(149, 6); + this.toolStripSeparator10.Size = new System.Drawing.Size(140, 6); // // saveConfigToolStripMenuItem // this.saveConfigToolStripMenuItem.Name = "saveConfigToolStripMenuItem"; - this.saveConfigToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.saveConfigToolStripMenuItem.Size = new System.Drawing.Size(143, 22); this.saveConfigToolStripMenuItem.Text = "Save Config"; this.saveConfigToolStripMenuItem.Click += new System.EventHandler(this.saveConfigToolStripMenuItem_Click); // // loadConfigToolStripMenuItem // this.loadConfigToolStripMenuItem.Name = "loadConfigToolStripMenuItem"; - this.loadConfigToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.loadConfigToolStripMenuItem.Size = new System.Drawing.Size(143, 22); this.loadConfigToolStripMenuItem.Text = "Load Config"; // // toolsToolStripMenuItem @@ -1186,6 +1188,13 @@ this.aboutToolStripMenuItem.Text = "&About"; this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click); // + // replayInputLogToolStripMenuItem + // + this.replayInputLogToolStripMenuItem.Name = "replayInputLogToolStripMenuItem"; + this.replayInputLogToolStripMenuItem.Size = new System.Drawing.Size(179, 22); + this.replayInputLogToolStripMenuItem.Text = "Replay Input Log"; + this.replayInputLogToolStripMenuItem.Click += new System.EventHandler(this.replayInputLogToolStripMenuItem_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1336,6 +1345,7 @@ private System.Windows.Forms.ToolStripSeparator toolStripSeparator10; private System.Windows.Forms.ToolStripMenuItem saveConfigToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem loadConfigToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem replayInputLogToolStripMenuItem; } } diff --git a/BizHawk.MultiClient/MainForm.MenuItems.cs b/BizHawk.MultiClient/MainForm.MenuItems.cs index b61d07c0cf..33e39c6b64 100644 --- a/BizHawk.MultiClient/MainForm.MenuItems.cs +++ b/BizHawk.MultiClient/MainForm.MenuItems.cs @@ -124,12 +124,8 @@ namespace BizHawk.MultiClient private void playMovieToolStripMenuItem_Click(object sender, EventArgs e) { - //PlayMovie p = new PlayMovie(); - //p.ShowDialog(); - - //Hacky testing - //InputLog.LoadMovie(); - //InputLog.WriteMovie(); + PlayMovie p = new PlayMovie(); + p.ShowDialog(); } private void stopMovieToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index 249abce675..93f227f475 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -21,7 +21,7 @@ namespace BizHawk.MultiClient private string CurrentlyOpenRom; //TODO: adelikat: can this be the official file extension? - Movie InputLog = new Movie("log.tas"); //This movie is always recording while user is playing + Movie InputLog = new Movie("log.tas", MOVIEMODE.RECORD); //This movie is always recording while user is playing //the currently selected savestate slot private int SaveSlot = 0; @@ -79,6 +79,7 @@ namespace BizHawk.MultiClient Closing += (o, e) => { CloseGame(); + InputLog.StopMovie(); SaveConfig(); }; @@ -128,9 +129,6 @@ namespace BizHawk.MultiClient if (Global.Config.StartPaused) PauseEmulator(); - - InputLog.LoadMovie(); //TODO: Debug - InputLog.StartPlayback(); //TODO: Debug } void SetSpeedPercent(int value) @@ -427,8 +425,14 @@ namespace BizHawk.MultiClient { new BizHawk.Emulation.Consoles.Gameboy.Debugger(Global.Emulator as Gameboy).Show(); } - - //InputLog.StartNewRecording(); //TODO: Uncomment and check for a user movie selected? + + if (InputLog.GetMovieMode() == MOVIEMODE.RECORD) + InputLog.StartNewRecording(); //TODO: Uncomment and check for a user movie selected? + else if (InputLog.GetMovieMode() == MOVIEMODE.PLAY) + { + InputLog.LoadMovie(); //TODO: Debug + InputLog.StartPlayback(); //TODO: Debug + } //setup the throttle based on platform's specifications //(one day later for some systems we will need to modify it at runtime as the display mode changes) @@ -1087,5 +1091,11 @@ namespace BizHawk.MultiClient RamSearch1.SaveConfigSettings(); ConfigService.Save("config.ini", Global.Config); } + + private void replayInputLogToolStripMenuItem_Click(object sender, EventArgs e) + { + InputLog.StartPlayback(); + LoadRom(CurrentlyOpenRom); + } } } \ No newline at end of file diff --git a/BizHawk.MultiClient/movie/Movie.cs b/BizHawk.MultiClient/movie/Movie.cs index 32f6e462bf..e7a219391b 100644 --- a/BizHawk.MultiClient/movie/Movie.cs +++ b/BizHawk.MultiClient/movie/Movie.cs @@ -17,10 +17,10 @@ namespace BizHawk.MultiClient private MOVIEMODE MovieMode = new MOVIEMODE(); - public Movie(string filename) + public Movie(string filename, MOVIEMODE m) { Filename = filename; //TODO: Validate that file is writable - MovieMode = MOVIEMODE.PLAY; + MovieMode = m; } public void StopMovie() diff --git a/BizHawk.MultiClient/output/log.tas b/BizHawk.MultiClient/output/log.tas deleted file mode 100644 index 836fd06f7c..0000000000 --- a/BizHawk.MultiClient/output/log.tas +++ /dev/null @@ -1,170 +0,0 @@ -EmulationVersion v1.0.0 -MovieVersion v1.0.0 -Platform -GameName -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|...R.........|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|..L..........|0| -|..L..........|0| -|..L..........|0| -|..L..........|0| -|..L..........|0| -|..L..........|0| -|..L..........|0| -|.D...........|0| -|.D...........|0| -|.D...........|0| -|.D...........|0| -|.D...........|0| -|..L..........|0| -|..L..........|0| -|..L..........|0| -|..L..........|0| -|..L..........|0| -|..L..........|0| -|..L..........|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|....12.......|0| -|U...12.......|0| -|U...12.......|0| -|U...12.......|0| -|U...12.......|0| -|U...12.......|0| -|.............|0| -|.D...........|0| -|.D...........|0| -|.D...........|0| -|..L..........|0| -|..L..........|0| -|...R.........|0| -|...R.........|0| -|U............|0| -|U............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -|.............|0| -