diff --git a/BizHawk.MultiClient/Gameboy/Debugger.cs b/BizHawk.MultiClient/Gameboy/Debugger.cs index 888e250386..1c0ef55db0 100644 --- a/BizHawk.MultiClient/Gameboy/Debugger.cs +++ b/BizHawk.MultiClient/Gameboy/Debugger.cs @@ -15,12 +15,16 @@ namespace BizHawk.Emulation.Consoles.Gameboy { public partial class Debugger : Form, Gameboy.IDebuggerAPI { - readonly Gameboy gb; - public Debugger(Gameboy gb) + Gameboy gb; + public Debugger() + { + InitializeComponent(); + } + + public void LoadCore(Gameboy gb) { this.gb = gb; gb.DebuggerAPI = this; - InitializeComponent(); Refresh(); } @@ -76,13 +80,15 @@ namespace BizHawk.Emulation.Consoles.Gameboy bool Running = false; void DoRun() { - Running = true; - gb.RunForever(); - Running = false; + Global.MainForm.UnpauseEmulator(); + //Running = true; + //gb.RunForever(); + //Running = false; } void DoBreak() { + Global.MainForm.PauseEmulator(); //adelikat: This is probably "rounding" the break to the nearest frame, but without it, break fails gb.DebugBreak = true; } @@ -400,5 +406,24 @@ namespace BizHawk.Emulation.Consoles.Gameboy autoloadToolStripMenuItem.Checked = Global.Config.AutoloadGBDebugger; } + public void UpdateValues() + { + if (!this.IsHandleCreated || this.IsDisposed) return; + Refresh(); + } + + public void Restart() + { + if (!this.IsHandleCreated || this.IsDisposed) return; + + if (Global.Emulator is Gameboy) + { + LoadCore(Global.Emulator as Gameboy); + } + else + { + this.Close(); + } + } } } diff --git a/BizHawk.MultiClient/MainForm.MenuItems.cs b/BizHawk.MultiClient/MainForm.MenuItems.cs index bb7c193b60..cbe90838ef 100644 --- a/BizHawk.MultiClient/MainForm.MenuItems.cs +++ b/BizHawk.MultiClient/MainForm.MenuItems.cs @@ -1065,7 +1065,7 @@ namespace BizHawk.MultiClient private void debuggerToolStripMenuItem1_Click(object sender, EventArgs e) { - Global.MainForm.OpenGameboyDebugger(); + Global.MainForm.LoadGBDebugger(); } private void tAStudioToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index dfc0703f0a..fc6097ce9f 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -70,6 +70,7 @@ namespace BizHawk.MultiClient public ToolBox ToolBox1 = new ToolBox(); public TI83KeyPad TI83KeyPad1 = new TI83KeyPad(); public TAStudio TAStudio1 = new TAStudio(); + public Debugger GBDebugger = new Debugger(); #if WINDOWS public LuaConsole LuaConsole1 = new LuaConsole(); #endif @@ -1924,6 +1925,7 @@ namespace BizHawk.MultiClient PCEBGViewer1.UpdateValues(); PCEBGViewer1.Generate(); // TODO: just a makeshift. PCE core should provide callbacks. TAStudio1.UpdateValues(); + GBDebugger.UpdateValues(); } private unsafe Image MakeScreenshotImage() @@ -2449,6 +2451,7 @@ namespace BizHawk.MultiClient PCEBGViewer1.Restart(); TI83KeyPad1.Restart(); Cheats1.Restart(); + GBDebugger.Restart(); ToolBox1.Restart(); #if WINDOWS LuaConsole1.Restart(); @@ -2780,12 +2783,17 @@ namespace BizHawk.MultiClient #endif } - public void OpenGameboyDebugger() + public void LoadGBDebugger() { if (Global.Emulator is Gameboy) { - Debugger gbDebugger = new Debugger(Global.Emulator as Gameboy); - gbDebugger.Show(); + if (!GBDebugger.IsHandleCreated || GBDebugger.IsDisposed) + { + GBDebugger.LoadCore(Global.Emulator as Gameboy); + GBDebugger.Show(); + } + else + GBDebugger.Focus(); } } diff --git a/BizHawk.MultiClient/tools/TAStudio.cs b/BizHawk.MultiClient/tools/TAStudio.cs index a2d4240c15..3c6e24ba1c 100644 --- a/BizHawk.MultiClient/tools/TAStudio.cs +++ b/BizHawk.MultiClient/tools/TAStudio.cs @@ -312,7 +312,6 @@ namespace BizHawk.MultiClient private void PauseButton_Click(object sender, EventArgs e) { - Global.MainForm.TogglePause(); } diff --git a/BizHawk.MultiClient/tools/ToolBox.cs b/BizHawk.MultiClient/tools/ToolBox.cs index 49060e6637..3abfd04544 100644 --- a/BizHawk.MultiClient/tools/ToolBox.cs +++ b/BizHawk.MultiClient/tools/ToolBox.cs @@ -133,7 +133,7 @@ namespace BizHawk.MultiClient private void toolStripButton6_Click(object sender, EventArgs e) { - Global.MainForm.OpenGameboyDebugger(); + Global.MainForm.LoadGBDebugger(); } } }