diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/Breakpoint.cs b/BizHawk.Client.EmuHawk/tools/Debugger/Breakpoint.cs index fb6f6d171f..49b310e217 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/Breakpoint.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/Breakpoint.cs @@ -33,6 +33,22 @@ namespace BizHawk.Client.EmuHawk private bool _active; private readonly IDebuggable _core; + public Breakpoint(bool readOnly, IDebuggable core, Action callBack, uint address, MemoryCallbackType type, bool enabled = true) + { + _core = core; + + Callback = callBack; + Address = address; + Active = enabled; + Name = "Pause"; + ReadOnly = readOnly; + + if (enabled) + { + AddCallback(); + } + } + public Breakpoint(IDebuggable core, Action callBack, uint address, MemoryCallbackType type, bool enabled = true) { _core = core; diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/BreakpointControl.cs b/BizHawk.Client.EmuHawk/tools/Debugger/BreakpointControl.cs index de206196a3..b4c089938f 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/BreakpointControl.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/BreakpointControl.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text; using System.Windows.Forms; +using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Common; using BizHawk.Emulation.Common.IEmulatorExtensions; using BizHawk.Client.Common; @@ -65,11 +66,25 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger UpdateValues(); } + private void SeekCallback() + { + BreakpointCallback(); + + var seekBreakpoint = Breakpoints.FirstOrDefault(x => x.Name.StartsWith(SeekName)); + + if (seekBreakpoint != null) + { + Breakpoints.Remove(seekBreakpoint); + UpdateValues(); + } + } + public void UpdateValues() { - if (this.Enabled) + if (Enabled) { - + BreakpointView.ItemCount = Breakpoints.Count; + UpdateStatsLabel(); } } @@ -118,6 +133,16 @@ namespace BizHawk.Client.EmuHawk.tools.Debugger UpdateStatsLabel(); } + private const string SeekName = "Seek to PC "; + + public void AddSeekBreakpoint(uint pcVal, int pcBitSize) + { + Breakpoints.Add(new Breakpoint(true, Core, SeekCallback, pcVal, MemoryCallbackType.Execute) + { + Name = SeekName + pcVal.ToHexString(pcBitSize / 4) + }); + } + private IEnumerable SelectedIndices { get { return BreakpointView.SelectedIndices.Cast(); } diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Designer.cs b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Designer.cs index 0806ff49a2..9d7eeeb72c 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Designer.cs @@ -275,6 +275,7 @@ this.SeekToBtn.TabIndex = 13; this.SeekToBtn.Text = "Seek To:"; this.SeekToBtn.UseVisualStyleBackColor = true; + this.SeekToBtn.Click += new System.EventHandler(this.SeekToBtn_Click); // // SeekToBox // diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.cs b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.cs index d366224604..1251f8c9eb 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.cs @@ -263,5 +263,13 @@ namespace BizHawk.Client.EmuHawk _currentToolTipControl = null; } } + + private void SeekToBtn_Click(object sender, EventArgs e) + { + var pcVal = (uint)(SeekToBox.ToRawInt() ?? 0); + var pcBitSize = Debuggable.GetCpuFlagsAndRegisters()["PC"].BitSize; + BreakPointControl1.AddSeekBreakpoint(pcVal, pcBitSize); + BreakPointControl1.UpdateValues(); + } } }