diff --git a/GUI.NET/Debugger/Controls/CodeViewerActions.cs b/GUI.NET/Debugger/Controls/CodeViewerActions.cs index 7b1c1d6c..49f8d9dd 100644 --- a/GUI.NET/Debugger/Controls/CodeViewerActions.cs +++ b/GUI.NET/Debugger/Controls/CodeViewerActions.cs @@ -289,17 +289,17 @@ namespace Mesen.GUI.Debugger.Controls public void ToggleBreakpoint(bool toggleEnabledFlag) { - int lineIndex = Viewer.CodeViewer.SelectedLine; - int relativeAddress = Viewer.CodeViewer.GetLineNumber(lineIndex); - if(relativeAddress < 0 && Viewer.CodeViewer.LineCount > lineIndex + 1) { + AddressTypeInfo info = Viewer.GetAddressInfo(Viewer.CodeViewer.SelectedLine); + if(info.Address >= 0) { + BreakpointManager.ToggleBreakpoint(-1, info, toggleEnabledFlag); + } else { //Current line has no address, try using the next line instead. //(Used when trying to set a breakpoint on a row containing only a label) - lineIndex++; - relativeAddress = Viewer.CodeViewer.GetLineNumber(lineIndex); + info = Viewer.GetAddressInfo(Viewer.CodeViewer.SelectedLine + 1); + if(info.Address >= 0) { + BreakpointManager.ToggleBreakpoint(-1, info, toggleEnabledFlag); + } } - - AddressTypeInfo info = Viewer.GetAddressInfo(lineIndex); - BreakpointManager.ToggleBreakpoint(relativeAddress, info, toggleEnabledFlag); } private void mnuShowByteCodeOnLeft_Click(object sender, EventArgs e) diff --git a/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs b/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs index d95d7a0e..ed447884 100644 --- a/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs +++ b/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs @@ -273,17 +273,7 @@ namespace Mesen.GUI.Debugger _tooltipManager.Close(); if(e.Button == MouseButtons.Left && e.Location.X < this.ctrlCodeViewer.CodeMargin / 4) { - int lineIndex = ctrlCodeViewer.GetLineIndexAtPosition(e.Y); - int relativeAddress = ctrlCodeViewer.GetLineNumber(lineIndex); - if(relativeAddress < 0 && ctrlCodeViewer.LineCount > lineIndex + 1) { - //Current line has no address, try using the next line instead. - //(Used when trying to set a breakpoint on a row containing only a label) - lineIndex++; - relativeAddress = ctrlCodeViewer.GetLineNumber(lineIndex); - } - - AddressTypeInfo info = GetAddressInfo(lineIndex); - BreakpointManager.ToggleBreakpoint(relativeAddress, info, false); + _codeViewerActions.ToggleBreakpoint(false); } } diff --git a/GUI.NET/Debugger/Controls/ctrlSourceViewer.cs b/GUI.NET/Debugger/Controls/ctrlSourceViewer.cs index 31b48fb1..3946e146 100644 --- a/GUI.NET/Debugger/Controls/ctrlSourceViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlSourceViewer.cs @@ -191,7 +191,7 @@ namespace Mesen.GUI.Debugger.Controls private void mnuToggleBreakpoint_Click(object sender, EventArgs e) { - ToggleBreakpoint(); + _codeViewerActions.ToggleBreakpoint(false); } public AddressTypeInfo GetAddressInfo(int lineIndex) @@ -237,21 +237,6 @@ namespace Mesen.GUI.Debugger.Controls } } - public void ToggleBreakpoint() - { - AddressTypeInfo info = GetAddressInfo(ctrlCodeViewer.SelectedLine); - if(info.Address >= 0) { - BreakpointManager.ToggleBreakpoint(-1, info, false); - } else { - //Current line has no address, try using the next line instead. - //(Used when trying to set a breakpoint on a row containing only a label) - info = GetAddressInfo(ctrlCodeViewer.SelectedLine + 1); - if(info.Address >= 0) { - BreakpointManager.ToggleBreakpoint(-1, info, false); - } - } - } - private void ctrlCodeViewer_MouseMove(object sender, MouseEventArgs e) { if(e.Location.X < this.ctrlCodeViewer.CodeMargin / 4) { @@ -266,7 +251,7 @@ namespace Mesen.GUI.Debugger.Controls private void ctrlCodeViewer_MouseDown(object sender, MouseEventArgs e) { if(e.Button == MouseButtons.Left && e.Location.X < this.ctrlCodeViewer.CodeMargin / 4) { - ToggleBreakpoint(); + _codeViewerActions.ToggleBreakpoint(false); } }