From b68aaefd7ea159436c5a8f18d1be2b8bfe3053e7 Mon Sep 17 00:00:00 2001 From: Sour Date: Sat, 8 Feb 2020 22:30:54 -0500 Subject: [PATCH] Debugger: Added "mark selection as" shortcuts in debugger & memory tools --- Core/CodeDataLogger.cpp | 21 ++- Core/CodeDataLogger.h | 2 + Core/DebugTypes.h | 3 +- Core/Debugger.cpp | 7 + Core/Debugger.h | 1 + Core/Disassembler.cpp | 2 +- InteropDLL/DebugApiWrapper.cpp | 3 +- UI/Debugger/Code/CpuLineStyleProvider.cs | 7 +- UI/Debugger/CodeLineData.cs | 3 +- UI/Debugger/Config/DebuggerShortcutsConfig.cs | 31 ++-- .../Controls/ctrlDisassemblyView.Designer.cs | 79 ++++++++--- UI/Debugger/Controls/ctrlDisassemblyView.cs | 115 ++++++++++++--- UI/Debugger/DebugWindowManager.cs | 11 ++ .../MemoryTools/ctrlHexViewer.Designer.cs | 134 ++++++++++++------ UI/Debugger/MemoryTools/ctrlHexViewer.cs | 48 +++++++ UI/Debugger/Profiler/frmProfiler.cs | 1 - UI/Debugger/frmDbgPreferences.cs | 6 +- UI/Debugger/frmDebugger.Designer.cs | 24 ++-- UI/Debugger/frmDebugger.cs | 7 +- UI/Forms/frmMain.cs | 6 +- UI/Interop/DebugApi.cs | 1 + 21 files changed, 369 insertions(+), 143 deletions(-) diff --git a/Core/CodeDataLogger.cpp b/Core/CodeDataLogger.cpp index d8a8fa7..b52557b 100644 --- a/Core/CodeDataLogger.cpp +++ b/Core/CodeDataLogger.cpp @@ -46,16 +46,19 @@ bool CodeDataLogger::LoadCdlFile(string cdlFilepath) void CodeDataLogger::CalculateStats() { - _codeSize = 0; - _dataSize = 0; + uint32_t codeSize = 0; + uint32_t dataSize = 0; for(int i = 0, len = _prgSize; i < len; i++) { if(IsCode(i)) { - _codeSize++; + codeSize++; } else if(IsData(i)) { - _dataSize++; + dataSize++; } } + + _codeSize = codeSize; + _dataSize = dataSize; } bool CodeDataLogger::SaveCdlFile(string cdlFilepath) @@ -126,7 +129,6 @@ void CodeDataLogger::SetCdlData(uint8_t *cdlData, uint32_t length) { if(length <= _prgSize) { memcpy(_cdlData, cdlData, length); - CalculateStats(); } } @@ -140,4 +142,11 @@ void CodeDataLogger::GetCdlData(uint32_t offset, uint32_t length, SnesMemoryType cdlData[i] = (info.Type == SnesMemoryType::PrgRom && info.Address >= 0) ? _cdlData[info.Address] : 0; } } -} \ No newline at end of file +} + +void CodeDataLogger::MarkBytesAs(uint32_t start, uint32_t end, uint8_t flags) +{ + for(uint32_t i = start; i <= end; i++) { + _cdlData[i] = (_cdlData[i] & 0xFC) | (int)flags; + } +} diff --git a/Core/CodeDataLogger.h b/Core/CodeDataLogger.h index 8256864..82a0eb7 100644 --- a/Core/CodeDataLogger.h +++ b/Core/CodeDataLogger.h @@ -36,4 +36,6 @@ public: void SetCdlData(uint8_t *cdlData, uint32_t length); void GetCdlData(uint32_t offset, uint32_t length, SnesMemoryType memoryType, uint8_t *cdlData); + + void MarkBytesAs(uint32_t start, uint32_t end, uint8_t flags); }; \ No newline at end of file diff --git a/Core/DebugTypes.h b/Core/DebugTypes.h index a8cf4e5..c82aed8 100644 --- a/Core/DebugTypes.h +++ b/Core/DebugTypes.h @@ -153,7 +153,8 @@ namespace LineFlags SubStart = 0x80, Label = 0x100, Comment = 0x200, - ShowAsData = 0x400 + ShowAsData = 0x400, + UnexecutedCode = 0x800 }; } diff --git a/Core/Debugger.cpp b/Core/Debugger.cpp index 80924f0..5662772 100644 --- a/Core/Debugger.cpp +++ b/Core/Debugger.cpp @@ -483,6 +483,13 @@ void Debugger::SetCdlData(uint8_t *cdlData, uint32_t length) RefreshCodeCache(); } +void Debugger::MarkBytesAs(uint32_t start, uint32_t end, uint8_t flags) +{ + DebugBreakHelper helper(this); + _codeDataLogger->MarkBytesAs(start, end, flags); + RefreshCodeCache(); +} + void Debugger::RefreshCodeCache() { _disassembler->ResetPrgCache(); diff --git a/Core/Debugger.h b/Core/Debugger.h index 74976af..3f4b23d 100644 --- a/Core/Debugger.h +++ b/Core/Debugger.h @@ -119,6 +119,7 @@ public: AddressInfo GetRelativeAddress(AddressInfo absAddress); void SetCdlData(uint8_t * cdlData, uint32_t length); + void MarkBytesAs(uint32_t start, uint32_t end, uint8_t flags); void RefreshCodeCache(); void SetBreakpoints(Breakpoint breakpoints[], uint32_t length); diff --git a/Core/Disassembler.cpp b/Core/Disassembler.cpp index 55dc2cb..22d7752 100644 --- a/Core/Disassembler.cpp +++ b/Core/Disassembler.cpp @@ -467,7 +467,7 @@ bool Disassembler::GetLineData(CpuType type, uint32_t lineIndex, CodeLineData &d if(!disInfo.IsInitialized()) { disInfo = DisassemblyInfo(src.Data + result.Address.Address, state.PS, CpuType::Cpu); } else { - data.Flags |= LineFlags::VerifiedCode; + data.Flags |= _cdl->IsCode(data.AbsoluteAddress) ? LineFlags::VerifiedCode : LineFlags::UnexecutedCode; } data.OpSize = disInfo.GetOpSize(); diff --git a/InteropDLL/DebugApiWrapper.cpp b/InteropDLL/DebugApiWrapper.cpp index b2a9f03..48c5644 100644 --- a/InteropDLL/DebugApiWrapper.cpp +++ b/InteropDLL/DebugApiWrapper.cpp @@ -82,7 +82,8 @@ extern "C" DllExport void __stdcall GetMemoryAccessCounts(uint32_t offset, uint32_t length, SnesMemoryType memoryType, MemoryOperationType operationType, uint32_t* counts) { GetDebugger()->GetMemoryAccessCounter()->GetAccessCounts(offset, length, memoryType, operationType, counts); } DllExport void __stdcall GetCdlData(uint32_t offset, uint32_t length, SnesMemoryType memoryType, uint8_t* cdlData) { GetDebugger()->GetCodeDataLogger()->GetCdlData(offset, length, memoryType, cdlData); } - DllExport void __stdcall SetCdlData(uint8_t *cdlData, uint32_t length) { GetDebugger()->SetCdlData(cdlData, length); } + DllExport void __stdcall SetCdlData(uint8_t* cdlData, uint32_t length) { GetDebugger()->SetCdlData(cdlData, length); } + DllExport void __stdcall MarkBytesAs(uint32_t start, uint32_t end, uint8_t flags) { GetDebugger()->MarkBytesAs(start, end, flags); } DllExport void __stdcall GetTilemap(GetTilemapOptions options, PpuState state, uint8_t *vram, uint8_t *cgram, uint32_t *buffer) { GetDebugger()->GetPpuTools()->GetTilemap(options, state, vram, cgram, buffer); } DllExport void __stdcall GetTileView(GetTileViewOptions options, uint8_t *source, uint32_t srcSize, uint8_t *cgram, uint32_t *buffer) { GetDebugger()->GetPpuTools()->GetTileView(options, source, srcSize, cgram, buffer); } diff --git a/UI/Debugger/Code/CpuLineStyleProvider.cs b/UI/Debugger/Code/CpuLineStyleProvider.cs index ce6203d..64c7af6 100644 --- a/UI/Debugger/Code/CpuLineStyleProvider.cs +++ b/UI/Debugger/Code/CpuLineStyleProvider.cs @@ -41,11 +41,6 @@ namespace Mesen.GUI.Debugger.Code ConfigureActiveStatement(props); } - //TODO - /* else if(_code._code.UnexecutedAddresses.Contains(lineNumber)) { - props.LineBgColor = info.CodeUnexecutedCodeColor; - }*/ - if(lineData.Flags.HasFlag(LineFlags.PrgRom)) { props.AddressColor = Color.Gray; } else if(lineData.Flags.HasFlag(LineFlags.WorkRam)) { @@ -56,6 +51,8 @@ namespace Mesen.GUI.Debugger.Code if(lineData.Flags.HasFlag(LineFlags.VerifiedData)) { props.LineBgColor = cfg.CodeVerifiedDataColor; + } else if(lineData.Flags.HasFlag(LineFlags.UnexecutedCode)) { + props.LineBgColor = cfg.CodeUnexecutedCodeColor; } else if(!lineData.Flags.HasFlag(LineFlags.VerifiedCode)) { props.LineBgColor = cfg.CodeUnidentifiedDataColor; } diff --git a/UI/Debugger/CodeLineData.cs b/UI/Debugger/CodeLineData.cs index b9fe3d1..9f8040c 100644 --- a/UI/Debugger/CodeLineData.cs +++ b/UI/Debugger/CodeLineData.cs @@ -146,6 +146,7 @@ namespace Mesen.GUI.Debugger SubStart = 0x80, Label = 0x100, Comment = 0x200, - ShowAsData = 0x400 + ShowAsData = 0x400, + UnexecutedCode = 0x800 } } diff --git a/UI/Debugger/Config/DebuggerShortcutsConfig.cs b/UI/Debugger/Config/DebuggerShortcutsConfig.cs index ac2336b..75ba0fc 100644 --- a/UI/Debugger/Config/DebuggerShortcutsConfig.cs +++ b/UI/Debugger/Config/DebuggerShortcutsConfig.cs @@ -312,26 +312,21 @@ namespace Mesen.GUI.Config } Keys keys = (XmlKeys)typeof(DebuggerShortcutsConfig).GetField(fieldName).GetValue(ConfigManager.Config.Debug.Shortcuts); - if((keys != Keys.None && !ToolStripManager.IsValidShortcut(keys)) || Program.IsMono) { - //Support normally invalid shortcut keys as a shortcut - item.ShortcutKeys = Keys.None; - item.ShortcutKeyDisplayString = GetShortcutDisplay(keys); - Form parentForm = parent.FindForm(); - if(parentForm is BaseForm) { - ProcessCmdKeyHandler onProcessCmdKeyHandler = (Keys keyData, ref bool processed) => { - if(!processed && item.Enabled && parent.ContainsFocus && keyData == keys) { - item.PerformClick(); - processed = true; - } - }; + item.ShortcutKeys = Keys.None; + item.ShortcutKeyDisplayString = GetShortcutDisplay(keys); - ((ShortcutInfo)item.Tag).KeyHandler = onProcessCmdKeyHandler; - (parentForm as BaseForm).OnProcessCmdKey += onProcessCmdKeyHandler; - } - } else { - item.ShortcutKeys = keys; - item.ShortcutKeyDisplayString = GetShortcutDisplay(keys); + Form parentForm = parent.FindForm(); + if(parentForm is BaseForm) { + ProcessCmdKeyHandler onProcessCmdKeyHandler = (Keys keyData, ref bool processed) => { + if(!processed && item.Enabled && parent.ContainsFocus && keyData == keys) { + item.PerformClick(); + processed = true; + } + }; + + ((ShortcutInfo)item.Tag).KeyHandler = onProcessCmdKeyHandler; + (parentForm as BaseForm).OnProcessCmdKey += onProcessCmdKeyHandler; } } } diff --git a/UI/Debugger/Controls/ctrlDisassemblyView.Designer.cs b/UI/Debugger/Controls/ctrlDisassemblyView.Designer.cs index 3b2ae3a..9d442a5 100644 --- a/UI/Debugger/Controls/ctrlDisassemblyView.Designer.cs +++ b/UI/Debugger/Controls/ctrlDisassemblyView.Designer.cs @@ -30,8 +30,12 @@ this.components = new System.ComponentModel.Container(); this.ctrlCode = new Mesen.GUI.Debugger.Controls.ctrlScrollableTextbox(); this.ctxMenu = new System.Windows.Forms.ContextMenuStrip(this.components); + this.mnuMarkSelectionAs = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuMarkAsCode = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuMarkAsData = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuMarkAsUnidentifiedData = new System.Windows.Forms.ToolStripMenuItem(); + this.sepMarkSelectionAs = new System.Windows.Forms.ToolStripSeparator(); this.mnuToggleBreakpoint = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); this.mnuAddToWatch = new System.Windows.Forms.ToolStripMenuItem(); this.mnuEditLabel = new System.Windows.Forms.ToolStripMenuItem(); this.mnuEditInMemoryTools = new System.Windows.Forms.ToolStripMenuItem(); @@ -76,8 +80,9 @@ // ctxMenu // this.ctxMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuMarkSelectionAs, + this.sepMarkSelectionAs, this.mnuToggleBreakpoint, - this.toolStripMenuItem1, this.mnuAddToWatch, this.mnuEditLabel, this.mnuEditInMemoryTools, @@ -87,28 +92,58 @@ this.sepSwitchView, this.mnuSwitchView}); this.ctxMenu.Name = "ctxMenu"; - this.ctxMenu.Size = new System.Drawing.Size(227, 198); + this.ctxMenu.Size = new System.Drawing.Size(227, 220); this.ctxMenu.Closing += new System.Windows.Forms.ToolStripDropDownClosingEventHandler(this.ctxMenu_Closing); this.ctxMenu.Opening += new System.ComponentModel.CancelEventHandler(this.ctxMenu_Opening); // + // mnuMarkSelectionAs + // + this.mnuMarkSelectionAs.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuMarkAsCode, + this.mnuMarkAsData, + this.mnuMarkAsUnidentifiedData}); + this.mnuMarkSelectionAs.Name = "mnuMarkSelectionAs"; + this.mnuMarkSelectionAs.Size = new System.Drawing.Size(226, 22); + this.mnuMarkSelectionAs.Text = "Mark selection as..."; + // + // mnuMarkAsCode + // + this.mnuMarkAsCode.Image = global::Mesen.GUI.Properties.Resources.Accept; + this.mnuMarkAsCode.Name = "mnuMarkAsCode"; + this.mnuMarkAsCode.Size = new System.Drawing.Size(199, 22); + this.mnuMarkAsCode.Text = "Verified Code"; + // + // mnuMarkAsData + // + this.mnuMarkAsData.Image = global::Mesen.GUI.Properties.Resources.CheatCode; + this.mnuMarkAsData.Name = "mnuMarkAsData"; + this.mnuMarkAsData.Size = new System.Drawing.Size(199, 22); + this.mnuMarkAsData.Text = "Verified Data"; + // + // mnuMarkAsUnidentifiedData + // + this.mnuMarkAsUnidentifiedData.Image = global::Mesen.GUI.Properties.Resources.Help; + this.mnuMarkAsUnidentifiedData.Name = "mnuMarkAsUnidentifiedData"; + this.mnuMarkAsUnidentifiedData.Size = new System.Drawing.Size(199, 22); + this.mnuMarkAsUnidentifiedData.Text = "Unidentified Code/Data"; + // + // sepMarkSelectionAs + // + this.sepMarkSelectionAs.Name = "sepMarkSelectionAs"; + this.sepMarkSelectionAs.Size = new System.Drawing.Size(223, 6); + // // mnuToggleBreakpoint // this.mnuToggleBreakpoint.Image = global::Mesen.GUI.Properties.Resources.Breakpoint; this.mnuToggleBreakpoint.Name = "mnuToggleBreakpoint"; - this.mnuToggleBreakpoint.Size = new System.Drawing.Size(206, 22); + this.mnuToggleBreakpoint.Size = new System.Drawing.Size(226, 22); this.mnuToggleBreakpoint.Text = "Toggle Breakpoint"; - this.mnuToggleBreakpoint.Click += new System.EventHandler(this.mnuToggleBreakpoint_Click); - // - // toolStripMenuItem1 - // - this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(203, 6); // // mnuAddToWatch // this.mnuAddToWatch.Image = global::Mesen.GUI.Properties.Resources.Add; this.mnuAddToWatch.Name = "mnuAddToWatch"; - this.mnuAddToWatch.Size = new System.Drawing.Size(206, 22); + this.mnuAddToWatch.Size = new System.Drawing.Size(226, 22); this.mnuAddToWatch.Text = "Add to Watch"; this.mnuAddToWatch.Click += new System.EventHandler(this.mnuAddToWatch_Click); // @@ -116,22 +151,20 @@ // this.mnuEditLabel.Image = global::Mesen.GUI.Properties.Resources.EditLabel; this.mnuEditLabel.Name = "mnuEditLabel"; - this.mnuEditLabel.Size = new System.Drawing.Size(206, 22); + this.mnuEditLabel.Size = new System.Drawing.Size(226, 22); this.mnuEditLabel.Text = "Edit Label"; - this.mnuEditLabel.Click += new System.EventHandler(this.mnuEditLabel_Click); // // mnuEditInMemoryTools // this.mnuEditInMemoryTools.Image = global::Mesen.GUI.Properties.Resources.CheatCode; this.mnuEditInMemoryTools.Name = "mnuEditInMemoryTools"; - this.mnuEditInMemoryTools.Size = new System.Drawing.Size(206, 22); + this.mnuEditInMemoryTools.Size = new System.Drawing.Size(226, 22); this.mnuEditInMemoryTools.Text = "Edit in Memory Tools"; - this.mnuEditInMemoryTools.Click += new System.EventHandler(this.mnuEditInMemoryTools_Click); // // toolStripMenuItem2 // this.toolStripMenuItem2.Name = "toolStripMenuItem2"; - this.toolStripMenuItem2.Size = new System.Drawing.Size(203, 6); + this.toolStripMenuItem2.Size = new System.Drawing.Size(223, 6); // // mnuGoToLocation // @@ -146,20 +179,20 @@ this.mnuFindOccurrences.Enabled = false; this.mnuFindOccurrences.Image = global::Mesen.GUI.Properties.Resources.Find; this.mnuFindOccurrences.Name = "mnuFindOccurrences"; - this.mnuFindOccurrences.Size = new System.Drawing.Size(206, 22); + this.mnuFindOccurrences.Size = new System.Drawing.Size(226, 22); this.mnuFindOccurrences.Text = "Find Occurrences"; this.mnuFindOccurrences.Visible = false; // // sepSwitchView // this.sepSwitchView.Name = "sepSwitchView"; - this.sepSwitchView.Size = new System.Drawing.Size(203, 6); + this.sepSwitchView.Size = new System.Drawing.Size(223, 6); // // mnuSwitchView // this.mnuSwitchView.Image = global::Mesen.GUI.Properties.Resources.SwitchView; this.mnuSwitchView.Name = "mnuSwitchView"; - this.mnuSwitchView.Size = new System.Drawing.Size(206, 22); + this.mnuSwitchView.Size = new System.Drawing.Size(226, 22); this.mnuSwitchView.Text = "Switch to Source View"; // // cboSourceFile @@ -222,7 +255,7 @@ private System.Windows.Forms.ToolStripMenuItem mnuAddToWatch; private System.Windows.Forms.ToolStripMenuItem mnuToggleBreakpoint; private System.Windows.Forms.ToolStripMenuItem mnuEditLabel; - private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1; + private System.Windows.Forms.ToolStripSeparator sepMarkSelectionAs; private System.Windows.Forms.ToolStripMenuItem mnuEditInMemoryTools; private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2; private System.Windows.Forms.ToolStripMenuItem mnuGoToLocation; @@ -232,5 +265,9 @@ private System.Windows.Forms.ToolStripMenuItem mnuSwitchView; private System.Windows.Forms.TableLayoutPanel tlpMain; private System.Windows.Forms.Label lblSourceFile; - } + private System.Windows.Forms.ToolStripMenuItem mnuMarkSelectionAs; + private System.Windows.Forms.ToolStripMenuItem mnuMarkAsCode; + private System.Windows.Forms.ToolStripMenuItem mnuMarkAsData; + private System.Windows.Forms.ToolStripMenuItem mnuMarkAsUnidentifiedData; + } } diff --git a/UI/Debugger/Controls/ctrlDisassemblyView.cs b/UI/Debugger/Controls/ctrlDisassemblyView.cs index 81c946e..36d2475 100644 --- a/UI/Debugger/Controls/ctrlDisassemblyView.cs +++ b/UI/Debugger/Controls/ctrlDisassemblyView.cs @@ -31,13 +31,17 @@ namespace Mesen.GUI.Debugger.Controls return; } - InitShortcuts(); - DebugWorkspaceManager.SymbolProviderChanged += DebugWorkspaceManager_SymbolProviderChanged; BreakpointManager.BreakpointsChanged += BreakpointManager_BreakpointsChanged; LabelManager.OnLabelUpdated += OnLabelUpdated; } + protected override void OnHandleCreated(EventArgs e) + { + base.OnHandleCreated(e); + InitShortcuts(); + } + protected override void OnHandleDestroyed(EventArgs e) { base.OnHandleDestroyed(e); @@ -46,6 +50,12 @@ namespace Mesen.GUI.Debugger.Controls BreakpointManager.BreakpointsChanged -= BreakpointManager_BreakpointsChanged; } + protected override bool ProcessCmdKey(ref Message msg, Keys keyData) + { + UpdateContextMenu(); + return base.ProcessCmdKey(ref msg, keyData); + } + private void DebugWorkspaceManager_SymbolProviderChanged(ISymbolProvider symbolProvider) { _symbolProvider = symbolProvider; @@ -126,16 +136,70 @@ namespace Mesen.GUI.Debugger.Controls private void InitShortcuts() { mnuToggleBreakpoint.InitShortcut(this, nameof(DebuggerShortcutsConfig.CodeWindow_ToggleBreakpoint)); + mnuToggleBreakpoint.Click += (s, e) => ToggleBreakpoint(); mnuEditLabel.InitShortcut(this, nameof(DebuggerShortcutsConfig.CodeWindow_EditLabel)); + mnuEditLabel.Click += (s, e) => EditLabel(GetActionTarget()); + mnuEditInMemoryTools.InitShortcut(this, nameof(DebuggerShortcutsConfig.CodeWindow_EditInMemoryViewer)); + mnuEditInMemoryTools.Click += (s, e) => EditInMemoryTools(GetActionTarget()); + mnuAddToWatch.InitShortcut(this, nameof(DebuggerShortcutsConfig.LabelList_AddToWatch)); + mnuMarkAsCode.InitShortcut(this, nameof(DebuggerShortcutsConfig.MarkAsCode)); + mnuMarkAsCode.Click += (s, e) => MarkSelectionAs(CdlFlags.Code); + mnuMarkAsData.InitShortcut(this, nameof(DebuggerShortcutsConfig.MarkAsData)); + mnuMarkAsData.Click += (s, e) => MarkSelectionAs(CdlFlags.Data); + mnuMarkAsUnidentifiedData.InitShortcut(this, nameof(DebuggerShortcutsConfig.MarkAsUnidentified)); + mnuMarkAsUnidentifiedData.Click += (s, e) => MarkSelectionAs(CdlFlags.None); + mnuSwitchView.InitShortcut(this, nameof(DebuggerShortcutsConfig.CodeWindow_SwitchView)); mnuSwitchView.Click += (s, e) => { ToggleView(); }; } + private void MarkSelectionAs(CdlFlags type) + { + SelectedAddressRange range = GetSelectedAddressRange(); + if(!_inSourceView && range != null && range.Start.Type == SnesMemoryType.PrgRom && range.End.Type == SnesMemoryType.PrgRom) { + DebugApi.MarkBytesAs((UInt32)range.Start.Address, (UInt32)range.End.Address, type); + DebugWindowManager.OpenDebugger(CpuType.Cpu)?.RefreshDisassembly(); + } + } + + class SelectedAddressRange + { + public AddressInfo Start; + public AddressInfo End; + public string Display; + } + + private SelectedAddressRange GetSelectedAddressRange() + { + int firstLineOfSelection = ctrlCode.SelectionStart; + + while(_manager.Provider.GetLineAddress(firstLineOfSelection) < 0) { + firstLineOfSelection++; + } + int firstLineAfterSelection = ctrlCode.SelectionStart + ctrlCode.SelectionLength + 1; + while(_manager.Provider.GetLineAddress(firstLineAfterSelection) < 0) { + firstLineAfterSelection++; + } + + int start = _manager.Provider.GetLineAddress(firstLineOfSelection); + int end = _manager.Provider.GetLineAddress(firstLineAfterSelection) - 1; + + if(start >= 0 && end >= 0) { + return new SelectedAddressRange() { + Start = DebugApi.GetAbsoluteAddress(new AddressInfo() { Address = start, Type = _manager.RelativeMemoryType }), + End = DebugApi.GetAbsoluteAddress(new AddressInfo() { Address = end, Type = _manager.RelativeMemoryType }), + Display = $"${start.ToString("X4")} - ${end.ToString("X4")}" + }; + } + + return null; + } + public void ToggleView() { _inSourceView = !_inSourceView; @@ -200,7 +264,7 @@ namespace Mesen.GUI.Debugger.Controls ctrlCode.ScrollToAddress((int)address); } - public void UpdateCode() + public void UpdateCode(bool refreshDisassembly = false) { int centerLineIndex = ctrlCode.GetLineIndexAtPosition(0) + ctrlCode.GetNumberVisibleLines() / 2; int centerLineAddress; @@ -212,6 +276,12 @@ namespace Mesen.GUI.Debugger.Controls scrollOffset++; } while(centerLineAddress < 0 && centerLineIndex > 0); + if(refreshDisassembly) { + DebugApi.RefreshDisassembly(CpuType.Cpu); + DebugApi.RefreshDisassembly(CpuType.Spc); + DebugApi.RefreshDisassembly(CpuType.Sa1); + } + _manager.RefreshCode(_inSourceView ? _symbolProvider : null, _inSourceView ? cboSourceFile.SelectedItem as SourceFileInfo : null); ctrlCode.DataProvider = _manager.Provider; @@ -354,21 +424,6 @@ namespace Mesen.GUI.Debugger.Controls return _manager.GetLocationInfo(word, lineIndex); } - private void mnuToggleBreakpoint_Click(object sender, EventArgs e) - { - ToggleBreakpoint(); - } - - private void mnuEditLabel_Click(object sender, EventArgs e) - { - EditLabel(GetActionTarget()); - } - - private void mnuEditInMemoryTools_Click(object sender, EventArgs e) - { - EditInMemoryTools(GetActionTarget()); - } - private void mnuGoToLocation_Click(object sender, EventArgs e) { GoToLocation(GetActionTarget()); @@ -450,17 +505,17 @@ namespace Mesen.GUI.Debugger.Controls ctrlCode.SetMessage(msg); } - private void ctxMenu_Opening(object sender, CancelEventArgs e) + private void UpdateContextMenu() { LocationInfo location = GetActionTarget(); bool active = location.Address >= 0 || location.Label != null || location.Symbol != null; - + string suffix = location.Symbol?.Name ?? location.Label?.Label; if(string.IsNullOrWhiteSpace(suffix)) { suffix = (location.Address >= 0 ? ("$" + location.Address.ToString("X6")) : ""); } - string labelName = ""; + string labelName = ""; if(suffix.Length > 0) { labelName = " (" + suffix + ")"; if(location.ArrayIndex.HasValue) { @@ -471,7 +526,7 @@ namespace Mesen.GUI.Debugger.Controls suffix = ""; labelName = ""; } - + bool enableGoToLocation = (location.Address != _manager.Provider.GetLineAddress(ctrlCode.SelectedLine)); mnuAddToWatch.Text = "Add to Watch" + suffix; @@ -479,12 +534,28 @@ namespace Mesen.GUI.Debugger.Controls mnuEditLabel.Text = "Edit Label" + labelName; mnuGoToLocation.Text = "Go to Location" + (enableGoToLocation ? suffix : ""); + SelectedAddressRange range = GetSelectedAddressRange(); + if(range != null && range.Start.Type == SnesMemoryType.PrgRom && range.End.Type == SnesMemoryType.PrgRom) { + mnuMarkSelectionAs.Enabled = true; + mnuMarkSelectionAs.Text = "Mark selection as... (" + range.Display + ")"; + } else { + mnuMarkSelectionAs.Enabled = false; + mnuMarkSelectionAs.Text = "Mark selection as..."; + } + mnuMarkSelectionAs.Visible = !_inSourceView; + sepMarkSelectionAs.Visible = !_inSourceView; + mnuAddToWatch.Enabled = active; mnuEditInMemoryTools.Enabled = active; mnuEditLabel.Enabled = active && location.Symbol == null; mnuGoToLocation.Enabled = active && enableGoToLocation; } + private void ctxMenu_Opening(object sender, CancelEventArgs e) + { + UpdateContextMenu(); + } + private void ctxMenu_Closing(object sender, ToolStripDropDownClosingEventArgs e) { mnuAddToWatch.Enabled = true; diff --git a/UI/Debugger/DebugWindowManager.cs b/UI/Debugger/DebugWindowManager.cs index 266ec10..6092ffc 100644 --- a/UI/Debugger/DebugWindowManager.cs +++ b/UI/Debugger/DebugWindowManager.cs @@ -90,6 +90,17 @@ namespace Mesen.GUI.Debugger throw new Exception("Invalid CPU type"); } + public static frmDebugger GetDebugger(CpuType type) + { + switch(type) { + case CpuType.Cpu: return (frmDebugger)GetExistingSingleInstanceWindow(DebugWindow.Debugger); + case CpuType.Spc: return (frmDebugger)GetExistingSingleInstanceWindow(DebugWindow.SpcDebugger); + case CpuType.Sa1: return (frmDebugger)GetExistingSingleInstanceWindow(DebugWindow.Sa1Debugger); + case CpuType.Gsu: return (frmDebugger)GetExistingSingleInstanceWindow(DebugWindow.GsuDebugger); + } + throw new Exception("Invalid CPU type"); + } + public static frmMemoryTools GetMemoryViewer() { return _openedWindows.ToList().Find((form) => form.GetType() == typeof(frmMemoryTools)) as frmMemoryTools; diff --git a/UI/Debugger/MemoryTools/ctrlHexViewer.Designer.cs b/UI/Debugger/MemoryTools/ctrlHexViewer.Designer.cs index 338f94c..0b54b40 100644 --- a/UI/Debugger/MemoryTools/ctrlHexViewer.Designer.cs +++ b/UI/Debugger/MemoryTools/ctrlHexViewer.Designer.cs @@ -46,14 +46,19 @@ this.statusStrip = new System.Windows.Forms.StatusStrip(); this.lblLocation = new System.Windows.Forms.ToolStripStatusLabel(); this.ctxMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); + this.mnuAddToWatch = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuEditBreakpoint = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuEditLabel = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); this.mnuCopy = new System.Windows.Forms.ToolStripMenuItem(); this.mnuPaste = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripSeparator(); this.mnuSelectAll = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator(); - this.mnuAddToWatch = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuEditBreakpoint = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuEditLabel = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuMarkSelectionAs = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuMarkAsCode = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuMarkAsData = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuMarkAsUnidentifiedData = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator(); this.tlpMain.SuspendLayout(); this.flowLayoutPanel1.SuspendLayout(); this.panelSearch.SuspendLayout(); @@ -300,6 +305,8 @@ // ctxMenuStrip // this.ctxMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuMarkSelectionAs, + this.toolStripMenuItem2, this.mnuAddToWatch, this.mnuEditBreakpoint, this.mnuEditLabel, @@ -309,48 +316,14 @@ this.toolStripMenuItem5, this.mnuSelectAll}); this.ctxMenuStrip.Name = "ctxMenuStrip"; - this.ctxMenuStrip.Size = new System.Drawing.Size(155, 170); + this.ctxMenuStrip.Size = new System.Drawing.Size(181, 198); this.ctxMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.ctxMenuStrip_Opening); // - // mnuCopy - // - this.mnuCopy.Image = global::Mesen.GUI.Properties.Resources.Copy; - this.mnuCopy.Name = "mnuCopy"; - this.mnuCopy.Size = new System.Drawing.Size(154, 22); - this.mnuCopy.Text = "Copy"; - this.mnuCopy.Click += new System.EventHandler(this.mnuCopy_Click); - // - // mnuPaste - // - this.mnuPaste.Image = global::Mesen.GUI.Properties.Resources.Paste; - this.mnuPaste.Name = "mnuPaste"; - this.mnuPaste.Size = new System.Drawing.Size(154, 22); - this.mnuPaste.Text = "Paste"; - this.mnuPaste.Click += new System.EventHandler(this.mnuPaste_Click); - // - // toolStripMenuItem5 - // - this.toolStripMenuItem5.Name = "toolStripMenuItem5"; - this.toolStripMenuItem5.Size = new System.Drawing.Size(151, 6); - // - // mnuSelectAll - // - this.mnuSelectAll.Image = global::Mesen.GUI.Properties.Resources.SelectAll; - this.mnuSelectAll.Name = "mnuSelectAll"; - this.mnuSelectAll.Size = new System.Drawing.Size(154, 22); - this.mnuSelectAll.Text = "Select All"; - this.mnuSelectAll.Click += new System.EventHandler(this.mnuSelectAll_Click); - // - // toolStripMenuItem1 - // - this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(151, 6); - // // mnuAddToWatch // this.mnuAddToWatch.Image = global::Mesen.GUI.Properties.Resources.Add; this.mnuAddToWatch.Name = "mnuAddToWatch"; - this.mnuAddToWatch.Size = new System.Drawing.Size(154, 22); + this.mnuAddToWatch.Size = new System.Drawing.Size(180, 22); this.mnuAddToWatch.Text = "Add to Watch"; this.mnuAddToWatch.Click += new System.EventHandler(this.mnuAddToWatch_Click); // @@ -358,7 +331,7 @@ // this.mnuEditBreakpoint.Image = global::Mesen.GUI.Properties.Resources.BreakpointEnableDisable; this.mnuEditBreakpoint.Name = "mnuEditBreakpoint"; - this.mnuEditBreakpoint.Size = new System.Drawing.Size(154, 22); + this.mnuEditBreakpoint.Size = new System.Drawing.Size(180, 22); this.mnuEditBreakpoint.Text = "Edit Breakpoint"; this.mnuEditBreakpoint.Click += new System.EventHandler(this.mnuEditBreakpoint_Click); // @@ -366,10 +339,80 @@ // this.mnuEditLabel.Image = global::Mesen.GUI.Properties.Resources.EditLabel; this.mnuEditLabel.Name = "mnuEditLabel"; - this.mnuEditLabel.Size = new System.Drawing.Size(154, 22); + this.mnuEditLabel.Size = new System.Drawing.Size(180, 22); this.mnuEditLabel.Text = "Edit Label"; this.mnuEditLabel.Click += new System.EventHandler(this.mnuEditLabel_Click); // + // toolStripMenuItem1 + // + this.toolStripMenuItem1.Name = "toolStripMenuItem1"; + this.toolStripMenuItem1.Size = new System.Drawing.Size(177, 6); + // + // mnuCopy + // + this.mnuCopy.Image = global::Mesen.GUI.Properties.Resources.Copy; + this.mnuCopy.Name = "mnuCopy"; + this.mnuCopy.Size = new System.Drawing.Size(180, 22); + this.mnuCopy.Text = "Copy"; + this.mnuCopy.Click += new System.EventHandler(this.mnuCopy_Click); + // + // mnuPaste + // + this.mnuPaste.Image = global::Mesen.GUI.Properties.Resources.Paste; + this.mnuPaste.Name = "mnuPaste"; + this.mnuPaste.Size = new System.Drawing.Size(180, 22); + this.mnuPaste.Text = "Paste"; + this.mnuPaste.Click += new System.EventHandler(this.mnuPaste_Click); + // + // toolStripMenuItem5 + // + this.toolStripMenuItem5.Name = "toolStripMenuItem5"; + this.toolStripMenuItem5.Size = new System.Drawing.Size(177, 6); + // + // mnuSelectAll + // + this.mnuSelectAll.Image = global::Mesen.GUI.Properties.Resources.SelectAll; + this.mnuSelectAll.Name = "mnuSelectAll"; + this.mnuSelectAll.Size = new System.Drawing.Size(180, 22); + this.mnuSelectAll.Text = "Select All"; + this.mnuSelectAll.Click += new System.EventHandler(this.mnuSelectAll_Click); + // + // mnuMarkSelectionAs + // + this.mnuMarkSelectionAs.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuMarkAsCode, + this.mnuMarkAsData, + this.mnuMarkAsUnidentifiedData}); + this.mnuMarkSelectionAs.Name = "mnuMarkSelectionAs"; + this.mnuMarkSelectionAs.Size = new System.Drawing.Size(180, 22); + this.mnuMarkSelectionAs.Text = "Mark selection as..."; + // + // mnuMarkAsCode + // + this.mnuMarkAsCode.Image = global::Mesen.GUI.Properties.Resources.Accept; + this.mnuMarkAsCode.Name = "mnuMarkAsCode"; + this.mnuMarkAsCode.Size = new System.Drawing.Size(199, 22); + this.mnuMarkAsCode.Text = "Verified Code"; + // + // mnuMarkAsData + // + this.mnuMarkAsData.Image = global::Mesen.GUI.Properties.Resources.CheatCode; + this.mnuMarkAsData.Name = "mnuMarkAsData"; + this.mnuMarkAsData.Size = new System.Drawing.Size(199, 22); + this.mnuMarkAsData.Text = "Verified Data"; + // + // mnuMarkAsUnidentifiedData + // + this.mnuMarkAsUnidentifiedData.Image = global::Mesen.GUI.Properties.Resources.Help; + this.mnuMarkAsUnidentifiedData.Name = "mnuMarkAsUnidentifiedData"; + this.mnuMarkAsUnidentifiedData.Size = new System.Drawing.Size(199, 22); + this.mnuMarkAsUnidentifiedData.Text = "Unidentified Code/Data"; + // + // toolStripMenuItem2 + // + this.toolStripMenuItem2.Name = "toolStripMenuItem2"; + this.toolStripMenuItem2.Size = new System.Drawing.Size(177, 6); + // // ctrlHexViewer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -427,5 +470,10 @@ private System.Windows.Forms.ToolStripMenuItem mnuEditBreakpoint; private System.Windows.Forms.ToolStripMenuItem mnuEditLabel; private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1; - } + private System.Windows.Forms.ToolStripMenuItem mnuMarkSelectionAs; + private System.Windows.Forms.ToolStripMenuItem mnuMarkAsCode; + private System.Windows.Forms.ToolStripMenuItem mnuMarkAsData; + private System.Windows.Forms.ToolStripMenuItem mnuMarkAsUnidentifiedData; + private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2; + } } diff --git a/UI/Debugger/MemoryTools/ctrlHexViewer.cs b/UI/Debugger/MemoryTools/ctrlHexViewer.cs index 772ec49..b15ecce 100644 --- a/UI/Debugger/MemoryTools/ctrlHexViewer.cs +++ b/UI/Debugger/MemoryTools/ctrlHexViewer.cs @@ -54,6 +54,13 @@ namespace Mesen.GUI.Debugger.Controls mnuAddToWatch.InitShortcut(this, nameof(DebuggerShortcutsConfig.MemoryViewer_AddToWatch)); mnuEditBreakpoint.InitShortcut(this, nameof(DebuggerShortcutsConfig.MemoryViewer_EditBreakpoint)); mnuEditLabel.InitShortcut(this, nameof(DebuggerShortcutsConfig.MemoryViewer_EditLabel)); + + mnuMarkAsCode.InitShortcut(this, nameof(DebuggerShortcutsConfig.MarkAsCode)); + mnuMarkAsCode.Click += (s, e) => MarkSelectionAs(CdlFlags.Code); + mnuMarkAsData.InitShortcut(this, nameof(DebuggerShortcutsConfig.MarkAsData)); + mnuMarkAsData.Click += (s, e) => MarkSelectionAs(CdlFlags.Data); + mnuMarkAsUnidentifiedData.InitShortcut(this, nameof(DebuggerShortcutsConfig.MarkAsUnidentified)); + mnuMarkAsUnidentifiedData.Click += (s, e) => MarkSelectionAs(CdlFlags.None); } public new void Focus() @@ -504,9 +511,50 @@ namespace Mesen.GUI.Debugger.Controls mnuAddToWatch.Enabled = false; } + if(_memoryType == SnesMemoryType.CpuMemory) { + AddressInfo start = DebugApi.GetAbsoluteAddress(new AddressInfo() { Address = (int)startAddress, Type = _memoryType }); + AddressInfo end = DebugApi.GetAbsoluteAddress(new AddressInfo() { Address = (int)endAddress, Type = _memoryType }); + + if(start.Address >= 0 && end.Address >= 0 && start.Address <= end.Address && start.Type == SnesMemoryType.PrgRom && end.Type == SnesMemoryType.PrgRom) { + mnuMarkSelectionAs.Text = "Mark selection as... (" + addressRange + ")"; + mnuMarkSelectionAs.Enabled = true; + } else { + mnuMarkSelectionAs.Text = "Mark selection as..."; + mnuMarkSelectionAs.Enabled = false; + } + } else if(_memoryType == SnesMemoryType.PrgRom) { + mnuMarkSelectionAs.Text = "Mark selection as... (" + addressRange + ")"; + mnuMarkSelectionAs.Enabled = true; + } else { + mnuMarkSelectionAs.Text = "Mark selection as..."; + mnuMarkSelectionAs.Enabled = false; + } + mnuEditBreakpoint.Enabled = true; } + private void MarkSelectionAs(CdlFlags type) + { + if(_memoryType != SnesMemoryType.CpuMemory && _memoryType != SnesMemoryType.PrgRom) { + return; + } + + int start = SelectionStartAddress; + int end = SelectionEndAddress; + + if(_memoryType == SnesMemoryType.CpuMemory) { + start = DebugApi.GetAbsoluteAddress(new AddressInfo() { Address = start, Type = _memoryType }).Address; + end = DebugApi.GetAbsoluteAddress(new AddressInfo() { Address = end, Type = _memoryType }).Address; + } + + if(start >= 0 && end >= 0 && start <= end) { + DebugApi.MarkBytesAs((UInt32)start, (UInt32)end, type); + DebugWindowManager.GetDebugger(_memoryType.ToCpuType())?.RefreshDisassembly(); + } + + RefreshData(_memoryType); + } + private void mnuAddToWatch_Click(object sender, EventArgs e) { if(_memoryType.SupportsWatch()) { diff --git a/UI/Debugger/Profiler/frmProfiler.cs b/UI/Debugger/Profiler/frmProfiler.cs index 56a90a2..141f13f 100644 --- a/UI/Debugger/Profiler/frmProfiler.cs +++ b/UI/Debugger/Profiler/frmProfiler.cs @@ -19,7 +19,6 @@ namespace Mesen.GUI.Debugger private WindowRefreshManager _refreshManager; private NotificationListener _notifListener; private TabPage _selectedTab; - private int _frameCount = 0; public ctrlScanlineCycleSelect ScanlineCycleSelect => null; diff --git a/UI/Debugger/frmDbgPreferences.cs b/UI/Debugger/frmDbgPreferences.cs index 9b8c27a..e9b7aff 100644 --- a/UI/Debugger/frmDbgPreferences.cs +++ b/UI/Debugger/frmDbgPreferences.cs @@ -36,9 +36,9 @@ namespace Mesen.GUI.Debugger GetMember(nameof(DebuggerShortcutsConfig.Paste)), GetMember(nameof(DebuggerShortcutsConfig.SelectAll)), GetMember(nameof(DebuggerShortcutsConfig.Refresh)), - //GetMember(nameof(DebuggerShortcutsConfig.MarkAsCode)), - //GetMember(nameof(DebuggerShortcutsConfig.MarkAsData)), - //GetMember(nameof(DebuggerShortcutsConfig.MarkAsUnidentified)), + GetMember(nameof(DebuggerShortcutsConfig.MarkAsCode)), + GetMember(nameof(DebuggerShortcutsConfig.MarkAsData)), + GetMember(nameof(DebuggerShortcutsConfig.MarkAsUnidentified)), //GetMember(nameof(DebuggerShortcutsConfig.GoToAll)), GetMember(nameof(DebuggerShortcutsConfig.CodeWindow_EditInMemoryViewer)), GetMember(nameof(DebuggerShortcutsConfig.MemoryViewer_ViewInDisassembly)), diff --git a/UI/Debugger/frmDebugger.Designer.cs b/UI/Debugger/frmDebugger.Designer.cs index e476d6b..71514a1 100644 --- a/UI/Debugger/frmDebugger.Designer.cs +++ b/UI/Debugger/frmDebugger.Designer.cs @@ -536,26 +536,26 @@ this.mnuShowUnident}); this.mnuUnidentifiedData.Image = global::Mesen.GUI.Properties.Resources.UnidentifiedData; this.mnuUnidentifiedData.Name = "mnuUnidentifiedData"; - this.mnuUnidentifiedData.Size = new System.Drawing.Size(227, 22); + this.mnuUnidentifiedData.Size = new System.Drawing.Size(217, 22); this.mnuUnidentifiedData.Text = "Unidentified Code/Data"; this.mnuUnidentifiedData.DropDownOpening += new System.EventHandler(this.mnuUnidentifiedData_DropDownOpening); // // mnuHideUnident // this.mnuHideUnident.Name = "mnuHideUnident"; - this.mnuHideUnident.Size = new System.Drawing.Size(170, 22); + this.mnuHideUnident.Size = new System.Drawing.Size(180, 22); this.mnuHideUnident.Text = "Hide"; // // mnuDisassembleUnident // this.mnuDisassembleUnident.Name = "mnuDisassembleUnident"; - this.mnuDisassembleUnident.Size = new System.Drawing.Size(170, 22); + this.mnuDisassembleUnident.Size = new System.Drawing.Size(180, 22); this.mnuDisassembleUnident.Text = "Show disassembly"; // // mnuShowUnident // this.mnuShowUnident.Name = "mnuShowUnident"; - this.mnuShowUnident.Size = new System.Drawing.Size(170, 22); + this.mnuShowUnident.Size = new System.Drawing.Size(180, 22); this.mnuShowUnident.Text = "Show as data"; // // mnuVerifiedData @@ -566,52 +566,52 @@ this.mnuShowData}); this.mnuVerifiedData.Image = global::Mesen.GUI.Properties.Resources.VerifiedData; this.mnuVerifiedData.Name = "mnuVerifiedData"; - this.mnuVerifiedData.Size = new System.Drawing.Size(227, 22); + this.mnuVerifiedData.Size = new System.Drawing.Size(217, 22); this.mnuVerifiedData.Text = "Verified Data"; this.mnuVerifiedData.DropDownOpening += new System.EventHandler(this.mnuVerifiedData_DropDownOpening); // // mnuHideData // this.mnuHideData.Name = "mnuHideData"; - this.mnuHideData.Size = new System.Drawing.Size(170, 22); + this.mnuHideData.Size = new System.Drawing.Size(180, 22); this.mnuHideData.Text = "Hide"; // // mnuDisassembleData // this.mnuDisassembleData.Name = "mnuDisassembleData"; - this.mnuDisassembleData.Size = new System.Drawing.Size(170, 22); + this.mnuDisassembleData.Size = new System.Drawing.Size(180, 22); this.mnuDisassembleData.Text = "Show disassembly"; // // mnuShowData // this.mnuShowData.Name = "mnuShowData"; - this.mnuShowData.Size = new System.Drawing.Size(170, 22); + this.mnuShowData.Size = new System.Drawing.Size(180, 22); this.mnuShowData.Text = "Show as data"; // // toolStripMenuItem6 // this.toolStripMenuItem6.Name = "toolStripMenuItem6"; - this.toolStripMenuItem6.Size = new System.Drawing.Size(224, 6); + this.toolStripMenuItem6.Size = new System.Drawing.Size(214, 6); // // mnuShowByteCode // this.mnuShowByteCode.CheckOnClick = true; this.mnuShowByteCode.Name = "mnuShowByteCode"; - this.mnuShowByteCode.Size = new System.Drawing.Size(227, 22); + this.mnuShowByteCode.Size = new System.Drawing.Size(217, 22); this.mnuShowByteCode.Text = "Show byte code"; // // mnuUseLowerCaseDisassembly // this.mnuUseLowerCaseDisassembly.CheckOnClick = true; this.mnuUseLowerCaseDisassembly.Name = "mnuUseLowerCaseDisassembly"; - this.mnuUseLowerCaseDisassembly.Size = new System.Drawing.Size(227, 22); + this.mnuUseLowerCaseDisassembly.Size = new System.Drawing.Size(217, 22); this.mnuUseLowerCaseDisassembly.Text = "Show in lower case"; // // mnuUseAltSpcOpNames // this.mnuUseAltSpcOpNames.CheckOnClick = true; this.mnuUseAltSpcOpNames.Name = "mnuUseAltSpcOpNames"; - this.mnuUseAltSpcOpNames.Size = new System.Drawing.Size(227, 22); + this.mnuUseAltSpcOpNames.Size = new System.Drawing.Size(217, 22); this.mnuUseAltSpcOpNames.Text = "Use alternative mnemonics"; // // mnuBreakOptions diff --git a/UI/Debugger/frmDebugger.cs b/UI/Debugger/frmDebugger.cs index 55fd0c2..e95b4eb 100644 --- a/UI/Debugger/frmDebugger.cs +++ b/UI/Debugger/frmDebugger.cs @@ -248,12 +248,9 @@ namespace Mesen.GUI.Debugger ConfigManager.Config.Debug.Debugger.ApplyConfig(); } - private void RefreshDisassembly() + public void RefreshDisassembly() { - DebugApi.RefreshDisassembly(CpuType.Cpu); - DebugApi.RefreshDisassembly(CpuType.Spc); - DebugApi.RefreshDisassembly(CpuType.Sa1); - ctrlDisassemblyView.UpdateCode(); + ctrlDisassemblyView.UpdateCode(true); } private void mnuBreakOptions_DropDownOpening(object sender, EventArgs e) diff --git a/UI/Forms/frmMain.cs b/UI/Forms/frmMain.cs index b595ea5..c491bad 100644 --- a/UI/Forms/frmMain.cs +++ b/UI/Forms/frmMain.cs @@ -245,10 +245,10 @@ namespace Mesen.GUI.Forms private void BindShortcuts() { - Func notClient = () => { return true; }; //TODO + Func notClient = () => { return !NetplayApi.IsConnected(); }; Func running = () => { return EmuRunner.IsRunning(); }; - Func runningNotClient = () => { return EmuRunner.IsRunning(); }; //TODO - Func runningNotClientNotMovie = () => { return EmuRunner.IsRunning(); }; //TODO + Func runningNotClient = () => { return EmuRunner.IsRunning() && !NetplayApi.IsConnected(); }; + Func runningNotClientNotMovie = () => { return EmuRunner.IsRunning() && !NetplayApi.IsConnected() && !RecordApi.MoviePlaying(); }; _shortcuts.BindShortcut(mnuOpen, EmulatorShortcut.OpenFile); _shortcuts.BindShortcut(mnuExit, EmulatorShortcut.Exit); diff --git a/UI/Interop/DebugApi.cs b/UI/Interop/DebugApi.cs index ba79e2f..b73b48a 100644 --- a/UI/Interop/DebugApi.cs +++ b/UI/Interop/DebugApi.cs @@ -168,6 +168,7 @@ namespace Mesen.GUI } [DllImport(DllPath)] public static extern void SetCdlData([In]byte[] cdlData, Int32 length); + [DllImport(DllPath)] public static extern void MarkBytesAs(UInt32 start, UInt32 end, CdlFlags type); } public enum SnesMemoryType