Gameboy - make debugger useful by connecting it to the multiclient events

This commit is contained in:
adelikat 2012-05-19 13:33:45 +00:00
parent abba87738f
commit b08d338761
5 changed files with 44 additions and 12 deletions

View File

@ -15,12 +15,16 @@ namespace BizHawk.Emulation.Consoles.Gameboy
{ {
public partial class Debugger : Form, Gameboy.IDebuggerAPI public partial class Debugger : Form, Gameboy.IDebuggerAPI
{ {
readonly Gameboy gb; Gameboy gb;
public Debugger(Gameboy gb) public Debugger()
{
InitializeComponent();
}
public void LoadCore(Gameboy gb)
{ {
this.gb = gb; this.gb = gb;
gb.DebuggerAPI = this; gb.DebuggerAPI = this;
InitializeComponent();
Refresh(); Refresh();
} }
@ -76,13 +80,15 @@ namespace BizHawk.Emulation.Consoles.Gameboy
bool Running = false; bool Running = false;
void DoRun() void DoRun()
{ {
Running = true; Global.MainForm.UnpauseEmulator();
gb.RunForever(); //Running = true;
Running = false; //gb.RunForever();
//Running = false;
} }
void DoBreak() void DoBreak()
{ {
Global.MainForm.PauseEmulator(); //adelikat: This is probably "rounding" the break to the nearest frame, but without it, break fails
gb.DebugBreak = true; gb.DebugBreak = true;
} }
@ -400,5 +406,24 @@ namespace BizHawk.Emulation.Consoles.Gameboy
autoloadToolStripMenuItem.Checked = Global.Config.AutoloadGBDebugger; 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();
}
}
} }
} }

View File

@ -1065,7 +1065,7 @@ namespace BizHawk.MultiClient
private void debuggerToolStripMenuItem1_Click(object sender, EventArgs e) private void debuggerToolStripMenuItem1_Click(object sender, EventArgs e)
{ {
Global.MainForm.OpenGameboyDebugger(); Global.MainForm.LoadGBDebugger();
} }
private void tAStudioToolStripMenuItem_Click(object sender, EventArgs e) private void tAStudioToolStripMenuItem_Click(object sender, EventArgs e)

View File

@ -70,6 +70,7 @@ namespace BizHawk.MultiClient
public ToolBox ToolBox1 = new ToolBox(); public ToolBox ToolBox1 = new ToolBox();
public TI83KeyPad TI83KeyPad1 = new TI83KeyPad(); public TI83KeyPad TI83KeyPad1 = new TI83KeyPad();
public TAStudio TAStudio1 = new TAStudio(); public TAStudio TAStudio1 = new TAStudio();
public Debugger GBDebugger = new Debugger();
#if WINDOWS #if WINDOWS
public LuaConsole LuaConsole1 = new LuaConsole(); public LuaConsole LuaConsole1 = new LuaConsole();
#endif #endif
@ -1924,6 +1925,7 @@ namespace BizHawk.MultiClient
PCEBGViewer1.UpdateValues(); PCEBGViewer1.UpdateValues();
PCEBGViewer1.Generate(); // TODO: just a makeshift. PCE core should provide callbacks. PCEBGViewer1.Generate(); // TODO: just a makeshift. PCE core should provide callbacks.
TAStudio1.UpdateValues(); TAStudio1.UpdateValues();
GBDebugger.UpdateValues();
} }
private unsafe Image MakeScreenshotImage() private unsafe Image MakeScreenshotImage()
@ -2449,6 +2451,7 @@ namespace BizHawk.MultiClient
PCEBGViewer1.Restart(); PCEBGViewer1.Restart();
TI83KeyPad1.Restart(); TI83KeyPad1.Restart();
Cheats1.Restart(); Cheats1.Restart();
GBDebugger.Restart();
ToolBox1.Restart(); ToolBox1.Restart();
#if WINDOWS #if WINDOWS
LuaConsole1.Restart(); LuaConsole1.Restart();
@ -2780,12 +2783,17 @@ namespace BizHawk.MultiClient
#endif #endif
} }
public void OpenGameboyDebugger() public void LoadGBDebugger()
{ {
if (Global.Emulator is Gameboy) if (Global.Emulator is Gameboy)
{ {
Debugger gbDebugger = new Debugger(Global.Emulator as Gameboy); if (!GBDebugger.IsHandleCreated || GBDebugger.IsDisposed)
gbDebugger.Show(); {
GBDebugger.LoadCore(Global.Emulator as Gameboy);
GBDebugger.Show();
}
else
GBDebugger.Focus();
} }
} }

View File

@ -312,7 +312,6 @@ namespace BizHawk.MultiClient
private void PauseButton_Click(object sender, EventArgs e) private void PauseButton_Click(object sender, EventArgs e)
{ {
Global.MainForm.TogglePause(); Global.MainForm.TogglePause();
} }

View File

@ -133,7 +133,7 @@ namespace BizHawk.MultiClient
private void toolStripButton6_Click(object sender, EventArgs e) private void toolStripButton6_Click(object sender, EventArgs e)
{ {
Global.MainForm.OpenGameboyDebugger(); Global.MainForm.LoadGBDebugger();
} }
} }
} }