From cdbc35e49f637eb2dcf930f57292ba54728832f0 Mon Sep 17 00:00:00 2001 From: Sour Date: Sat, 3 Mar 2018 15:40:11 -0500 Subject: [PATCH] Debugger: Added ability to customize the default labels on a per-mapper basis --- Core/BaseMapper.cpp | 5 ++ Core/BaseMapper.h | 1 + Core/Console.cpp | 9 +++ Core/Console.h | 1 + GUI.NET/Debugger/DebugWorkspaceManager.cs | 5 +- GUI.NET/Debugger/LabelManager.cs | 95 +++++++++++++++-------- GUI.NET/Debugger/frmDebugger.Designer.cs | 62 ++++++++------- GUI.NET/Debugger/frmDebugger.cs | 11 +++ GUI.NET/InteropEmu.cs | 4 + InteropDLL/ConsoleWrapper.cpp | 4 + 10 files changed, 137 insertions(+), 60 deletions(-) diff --git a/Core/BaseMapper.cpp b/Core/BaseMapper.cpp index bff1b1be..8aa233f1 100644 --- a/Core/BaseMapper.cpp +++ b/Core/BaseMapper.cpp @@ -725,6 +725,11 @@ RomFormat BaseMapper::GetRomFormat() return _romFormat; } +uint16_t BaseMapper::GetMapperId() +{ + return _mapperID; +} + HashInfo BaseMapper::GetHashInfo() { return _hashInfo; diff --git a/Core/BaseMapper.h b/Core/BaseMapper.h index d306ea61..db2064d5 100644 --- a/Core/BaseMapper.h +++ b/Core/BaseMapper.h @@ -175,6 +175,7 @@ public: HashInfo GetHashInfo(); string GetRomName(); RomFormat GetRomFormat(); + uint16_t GetMapperId(); __forceinline uint8_t ReadRAM(uint16_t addr) override; uint8_t DebugReadRAM(uint16_t addr); diff --git a/Core/Console.cpp b/Core/Console.cpp index 78c89f76..84c05943 100644 --- a/Core/Console.cpp +++ b/Core/Console.cpp @@ -304,6 +304,15 @@ RomFormat Console::GetRomFormat() } } +uint16_t Console::GetMapperId() +{ + if(Instance->_mapper) { + return Instance->_mapper->GetMapperId(); + } else { + return 0; + } +} + bool Console::IsChrRam() { if(Instance->_mapper) { diff --git a/Core/Console.h b/Core/Console.h index 9bff4be1..336d87bf 100644 --- a/Core/Console.h +++ b/Core/Console.h @@ -124,6 +124,7 @@ class Console static VirtualFile GetPatchFile(); static bool IsChrRam(); static RomFormat GetRomFormat(); + static uint16_t GetMapperId(); static HashInfo GetHashInfo(); static NesModel GetModel(); diff --git a/GUI.NET/Debugger/DebugWorkspaceManager.cs b/GUI.NET/Debugger/DebugWorkspaceManager.cs index 5c1ae144..2ada6c0a 100644 --- a/GUI.NET/Debugger/DebugWorkspaceManager.cs +++ b/GUI.NET/Debugger/DebugWorkspaceManager.cs @@ -43,6 +43,9 @@ namespace Mesen.GUI.Debugger _workspace.Breakpoints = new List(); _workspace.Labels = new List(); _workspace.WatchValues = new List(); + LabelManager.ResetLabels(); + WatchManager.WatchEntries = _workspace.WatchValues; + BreakpointManager.SetBreakpoints(_workspace.Breakpoints); _workspace.Save(); Clear(); } @@ -63,7 +66,7 @@ namespace Mesen.GUI.Debugger if(_workspace.Labels.Count == 0) { LabelManager.ResetLabels(); if(!ConfigManager.Config.DebugInfo.DisableDefaultLabels) { - LabelManager.SetDefaultLabels(InteropEmu.FdsGetSideCount() > 0); + LabelManager.SetDefaultLabels(InteropEmu.GetRomInfo().MapperId); } } else { LabelManager.ResetLabels(); diff --git a/GUI.NET/Debugger/LabelManager.cs b/GUI.NET/Debugger/LabelManager.cs index f65dee76..eeda2383 100644 --- a/GUI.NET/Debugger/LabelManager.cs +++ b/GUI.NET/Debugger/LabelManager.cs @@ -1,5 +1,7 @@ -using System; +using Mesen.GUI.Config; +using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -127,48 +129,75 @@ namespace Mesen.GUI.Debugger } } - public static void SetDefaultLabels(bool forFDS) + private const int FdsMapperID = 65535; + private const int NsfMapperID = 65534; + + public static void SetDefaultLabels(int mapperId) { - LabelManager.SetLabel(0x2000, AddressType.Register, "PpuControl_2000", $"7 bit 0{Environment.NewLine}---- ----{Environment.NewLine}VPHB SINN{Environment.NewLine}|||| ||||{Environment.NewLine}|||| ||++- Base nametable address{Environment.NewLine}|||| || (0 = $2000; 1 = $2400; 2 = $2800; 3 = $2C00){Environment.NewLine}|||| |+--- VRAM address increment per CPU read/write of PPUDATA{Environment.NewLine}|||| | (0: add 1, going across; 1: add 32, going down){Environment.NewLine}|||| +---- Sprite pattern table address for 8x8 sprites{Environment.NewLine}|||| (0: $0000; 1: $1000; ignored in 8x16 mode){Environment.NewLine}|||+------ Background pattern table address (0: $0000; 1: $1000){Environment.NewLine}||+------- Sprite size (0: 8x8; 1: 8x16){Environment.NewLine}|+-------- PPU master/slave select{Environment.NewLine}| (0: read backdrop from EXT pins; 1: output color on EXT pins){Environment.NewLine}+--------- Generate an NMI at the start of the{Environment.NewLine} vertical blanking interval (0: off; 1: on)", false); - LabelManager.SetLabel(0x2001, AddressType.Register, "PpuMask_2001", $"7 bit 0{Environment.NewLine}---- ----{Environment.NewLine}BGRs bMmG{Environment.NewLine}|||| ||||{Environment.NewLine}|||| |||+- Display type: (0: color, 1: grayscale){Environment.NewLine}|||| ||+-- 1: Show background in leftmost 8 pixels of screen, 0: Hide{Environment.NewLine}|||| |+--- 1: Show sprites in leftmost 8 pixels of screen, 0: Hide{Environment.NewLine}|||| +---- 1: Show background{Environment.NewLine}|||+------ 1: Show sprites{Environment.NewLine}||+------- Emphasize red{Environment.NewLine}|+-------- Emphasize green{Environment.NewLine}+--------- Emphasize blue", false); - LabelManager.SetLabel(0x2002, AddressType.Register, "PpuStatus_2002", $"7 bit 0{Environment.NewLine}---- ----{Environment.NewLine}VSO. ....{Environment.NewLine}|||| ||||{Environment.NewLine}|||+-++++- Least significant bits previously written into a PPU register{Environment.NewLine}||| (due to register not being updated for this address){Environment.NewLine}||+------- Sprite overflow. The intent was for this flag to be set{Environment.NewLine}|| whenever more than eight sprites appear on a scanline, but a{Environment.NewLine}|| hardware bug causes the actual behavior to be more complicated{Environment.NewLine}|| and generate false positives as well as false negatives; see{Environment.NewLine}|| PPU sprite evaluation. This flag is set during sprite{Environment.NewLine}|| evaluation and cleared at dot 1 (the second dot) of the{Environment.NewLine}|| pre-render line.{Environment.NewLine}|+-------- Sprite 0 Hit. Set when a nonzero pixel of sprite 0 overlaps{Environment.NewLine}| a nonzero background pixel; cleared at dot 1 of the pre-render{Environment.NewLine}| line. Used for raster timing.{Environment.NewLine}+--------- Vertical blank has started (0: not in vblank; 1: in vblank).{Environment.NewLine} Set at dot 1 of line 241 (the line *after* the post-render{Environment.NewLine} line, false); cleared after reading $2002 and at dot 1 of the{Environment.NewLine} pre-render line.", false); - LabelManager.SetLabel(0x2003, AddressType.Register, "OamAddr_2003", "Set OAM address - Write only", false); - LabelManager.SetLabel(0x2004, AddressType.Register, "OamData_2004", "Read/Write OAM data", false); - LabelManager.SetLabel(0x2005, AddressType.Register, "PpuScroll_2005", "Set PPU scroll, write twice - Write only", false); - LabelManager.SetLabel(0x2006, AddressType.Register, "PpuAddr_2006", "Set PPU address, write twice - Write only", false); - LabelManager.SetLabel(0x2007, AddressType.Register, "PpuData_2007", "Read/Write VRAM", false); + bool disableBuiltInWorkspace = false; + bool disableBuiltInMapperWorkspace = false; + string prefix = "DefaultLabels."; + string defaultWorkspaceMlbFile = Path.Combine(ConfigManager.DebuggerFolder, prefix + "Global.mlb"); + if(File.Exists(defaultWorkspaceMlbFile)) { + MesenLabelFile.Import(defaultWorkspaceMlbFile, true); + disableBuiltInWorkspace = true; + } - LabelManager.SetLabel(0x4000, AddressType.Register, "Sq1Duty_4000", $"DDLC VVVV{Environment.NewLine}Duty (D), envelope loop / length counter halt (L), constant volume (C), volume/envelope (V)", false); - LabelManager.SetLabel(0x4001, AddressType.Register, "Sq1Sweep_4001", $"EPPP NSSS{Environment.NewLine}Sweep unit: enabled (E), period (P), negate (N), shift (S)", false); - LabelManager.SetLabel(0x4002, AddressType.Register, "Sq1Timer_4002", $"TTTT TTTT{Environment.NewLine}Timer low (T)", false); - LabelManager.SetLabel(0x4003, AddressType.Register, "Sq1Length_4003", $"LLLL LTTT{Environment.NewLine}Length counter load (L), timer high (T)", false); + string mapperName = mapperId.ToString(); + if(mapperId == FdsMapperID) { + mapperName = "FDS"; + } else if(mapperId == NsfMapperID) { + mapperName = "NSF"; + } - LabelManager.SetLabel(0x4004, AddressType.Register, "Sq1Duty_4004", $"DDLC VVVV{Environment.NewLine}Duty (D), envelope loop / length counter halt (L), constant volume (C), volume/envelope (V)", false); - LabelManager.SetLabel(0x4005, AddressType.Register, "Sq1Sweep_4005", $"EPPP NSSS{Environment.NewLine}Sweep unit: enabled (E), period (P), negate (N), shift (S)", false); - LabelManager.SetLabel(0x4006, AddressType.Register, "Sq1Timer_4006", $"TTTT TTTT{Environment.NewLine}Timer low (T)", false); - LabelManager.SetLabel(0x4007, AddressType.Register, "Sq1Length_4007", $"LLLL LTTT{Environment.NewLine}Length counter load (L), timer high (T)", false); + string defaultWorkspaceMapperMlbFile = Path.Combine(ConfigManager.DebuggerFolder, prefix + mapperName + ".mlb"); + if(File.Exists(defaultWorkspaceMapperMlbFile)) { + MesenLabelFile.Import(defaultWorkspaceMapperMlbFile, true); + disableBuiltInMapperWorkspace = true; + } - LabelManager.SetLabel(0x4008, AddressType.Register, "TrgLinear_4008", $"CRRR RRRR{Environment.NewLine}Length counter halt / linear counter control (C), linear counter load (R)", false); - LabelManager.SetLabel(0x400A, AddressType.Register, "TrgTimer_400A", $"TTTT TTTT{Environment.NewLine}Timer low (T)", false); - LabelManager.SetLabel(0x400B, AddressType.Register, "TrgLength_400B", $"LLLL LTTT{Environment.NewLine}Length counter load (L), timer high (T)", false); + if(!disableBuiltInWorkspace) { + LabelManager.SetLabel(0x2000, AddressType.Register, "PpuControl_2000", $"7 bit 0{Environment.NewLine}---- ----{Environment.NewLine}VPHB SINN{Environment.NewLine}|||| ||||{Environment.NewLine}|||| ||++- Base nametable address{Environment.NewLine}|||| || (0 = $2000; 1 = $2400; 2 = $2800; 3 = $2C00){Environment.NewLine}|||| |+--- VRAM address increment per CPU read/write of PPUDATA{Environment.NewLine}|||| | (0: add 1, going across; 1: add 32, going down){Environment.NewLine}|||| +---- Sprite pattern table address for 8x8 sprites{Environment.NewLine}|||| (0: $0000; 1: $1000; ignored in 8x16 mode){Environment.NewLine}|||+------ Background pattern table address (0: $0000; 1: $1000){Environment.NewLine}||+------- Sprite size (0: 8x8; 1: 8x16){Environment.NewLine}|+-------- PPU master/slave select{Environment.NewLine}| (0: read backdrop from EXT pins; 1: output color on EXT pins){Environment.NewLine}+--------- Generate an NMI at the start of the{Environment.NewLine} vertical blanking interval (0: off; 1: on)", false); + LabelManager.SetLabel(0x2001, AddressType.Register, "PpuMask_2001", $"7 bit 0{Environment.NewLine}---- ----{Environment.NewLine}BGRs bMmG{Environment.NewLine}|||| ||||{Environment.NewLine}|||| |||+- Display type: (0: color, 1: grayscale){Environment.NewLine}|||| ||+-- 1: Show background in leftmost 8 pixels of screen, 0: Hide{Environment.NewLine}|||| |+--- 1: Show sprites in leftmost 8 pixels of screen, 0: Hide{Environment.NewLine}|||| +---- 1: Show background{Environment.NewLine}|||+------ 1: Show sprites{Environment.NewLine}||+------- Emphasize red{Environment.NewLine}|+-------- Emphasize green{Environment.NewLine}+--------- Emphasize blue", false); + LabelManager.SetLabel(0x2002, AddressType.Register, "PpuStatus_2002", $"7 bit 0{Environment.NewLine}---- ----{Environment.NewLine}VSO. ....{Environment.NewLine}|||| ||||{Environment.NewLine}|||+-++++- Least significant bits previously written into a PPU register{Environment.NewLine}||| (due to register not being updated for this address){Environment.NewLine}||+------- Sprite overflow. The intent was for this flag to be set{Environment.NewLine}|| whenever more than eight sprites appear on a scanline, but a{Environment.NewLine}|| hardware bug causes the actual behavior to be more complicated{Environment.NewLine}|| and generate false positives as well as false negatives; see{Environment.NewLine}|| PPU sprite evaluation. This flag is set during sprite{Environment.NewLine}|| evaluation and cleared at dot 1 (the second dot) of the{Environment.NewLine}|| pre-render line.{Environment.NewLine}|+-------- Sprite 0 Hit. Set when a nonzero pixel of sprite 0 overlaps{Environment.NewLine}| a nonzero background pixel; cleared at dot 1 of the pre-render{Environment.NewLine}| line. Used for raster timing.{Environment.NewLine}+--------- Vertical blank has started (0: not in vblank; 1: in vblank).{Environment.NewLine} Set at dot 1 of line 241 (the line *after* the post-render{Environment.NewLine} line, false); cleared after reading $2002 and at dot 1 of the{Environment.NewLine} pre-render line.", false); + LabelManager.SetLabel(0x2003, AddressType.Register, "OamAddr_2003", "Set OAM address - Write only", false); + LabelManager.SetLabel(0x2004, AddressType.Register, "OamData_2004", "Read/Write OAM data", false); + LabelManager.SetLabel(0x2005, AddressType.Register, "PpuScroll_2005", "Set PPU scroll, write twice - Write only", false); + LabelManager.SetLabel(0x2006, AddressType.Register, "PpuAddr_2006", "Set PPU address, write twice - Write only", false); + LabelManager.SetLabel(0x2007, AddressType.Register, "PpuData_2007", "Read/Write VRAM", false); - LabelManager.SetLabel(0x400C, AddressType.Register, "NoiseVolume_400C", $"--LC VVVV{Environment.NewLine}Envelope loop / length counter halt (L), constant volume (C), volume/envelope (V)", false); - LabelManager.SetLabel(0x400E, AddressType.Register, "NoisePeriod_400E", $"L--- PPPP{Environment.NewLine}Loop noise (L), noise period (P)", false); - LabelManager.SetLabel(0x400F, AddressType.Register, "NoiseLength_400F", $"LLLL L---{Environment.NewLine}Length counter load (L)", false); + LabelManager.SetLabel(0x4000, AddressType.Register, "Sq0Duty_4000", $"DDLC VVVV{Environment.NewLine}Duty (D), envelope loop / length counter halt (L), constant volume (C), volume/envelope (V)", false); + LabelManager.SetLabel(0x4001, AddressType.Register, "Sq0Sweep_4001", $"EPPP NSSS{Environment.NewLine}Sweep unit: enabled (E), period (P), negate (N), shift (S)", false); + LabelManager.SetLabel(0x4002, AddressType.Register, "Sq0Timer_4002", $"TTTT TTTT{Environment.NewLine}Timer low (T)", false); + LabelManager.SetLabel(0x4003, AddressType.Register, "Sq0Length_4003", $"LLLL LTTT{Environment.NewLine}Length counter load (L), timer high (T)", false); - LabelManager.SetLabel(0x4010, AddressType.Register, "DmcFreq_4010", $"IL-- RRRR{Environment.NewLine}IRQ enable (I), loop (L), frequency (R)", false); - LabelManager.SetLabel(0x4011, AddressType.Register, "DmcCounter_4011", $"-DDD DDDD{Environment.NewLine}Load counter (D)", false); - LabelManager.SetLabel(0x4012, AddressType.Register, "DmcAddress_4012", $"AAAA AAAA{Environment.NewLine}Sample address (A)", false); - LabelManager.SetLabel(0x4013, AddressType.Register, "DmcLength_4013", $"LLLL LLLL{Environment.NewLine}Sample length (L)", false); + LabelManager.SetLabel(0x4004, AddressType.Register, "Sq1Duty_4004", $"DDLC VVVV{Environment.NewLine}Duty (D), envelope loop / length counter halt (L), constant volume (C), volume/envelope (V)", false); + LabelManager.SetLabel(0x4005, AddressType.Register, "Sq1Sweep_4005", $"EPPP NSSS{Environment.NewLine}Sweep unit: enabled (E), period (P), negate (N), shift (S)", false); + LabelManager.SetLabel(0x4006, AddressType.Register, "Sq1Timer_4006", $"TTTT TTTT{Environment.NewLine}Timer low (T)", false); + LabelManager.SetLabel(0x4007, AddressType.Register, "Sq1Length_4007", $"LLLL LTTT{Environment.NewLine}Length counter load (L), timer high (T)", false); - LabelManager.SetLabel(0x4014, AddressType.Register, "SpriteDma_4014", "Writing $XX will upload 256 bytes of data from CPU page $XX00-$XXFF to the internal PPU OAM.", false); + LabelManager.SetLabel(0x4008, AddressType.Register, "TrgLinear_4008", $"CRRR RRRR{Environment.NewLine}Length counter halt / linear counter control (C), linear counter load (R)", false); + LabelManager.SetLabel(0x400A, AddressType.Register, "TrgTimer_400A", $"TTTT TTTT{Environment.NewLine}Timer low (T)", false); + LabelManager.SetLabel(0x400B, AddressType.Register, "TrgLength_400B", $"LLLL LTTT{Environment.NewLine}Length counter load (L), timer high (T)", false); - LabelManager.SetLabel(0x4015, AddressType.Register, "ApuStatus_4015", $"Read:{Environment.NewLine}IF-D NT21{Environment.NewLine}DMC interrupt (I), frame interrupt (F), DMC active (D), length counter > 0 (N/T/2/1){Environment.NewLine+Environment.NewLine}Write:{Environment.NewLine}---D NT21{Environment.NewLine}Enable DMC (D), noise (N), triangle (T), and pulse channels (2/1)", false); + LabelManager.SetLabel(0x400C, AddressType.Register, "NoiseVolume_400C", $"--LC VVVV{Environment.NewLine}Envelope loop / length counter halt (L), constant volume (C), volume/envelope (V)", false); + LabelManager.SetLabel(0x400E, AddressType.Register, "NoisePeriod_400E", $"L--- PPPP{Environment.NewLine}Loop noise (L), noise period (P)", false); + LabelManager.SetLabel(0x400F, AddressType.Register, "NoiseLength_400F", $"LLLL L---{Environment.NewLine}Length counter load (L)", false); - LabelManager.SetLabel(0x4016, AddressType.Register, "Ctrl1_4016", $"Read (NES - input):{Environment.NewLine}---4 3210{Environment.NewLine}Read data from controller port #1.{Environment.NewLine}{Environment.NewLine}Write:{Environment.NewLine}---- ---A{Environment.NewLine}Output data (strobe) to both controllers.", false); - LabelManager.SetLabel(0x4017, AddressType.Register, "Ctrl2_FrameCtr_4017", $"Read (NES - input):{Environment.NewLine}---4 3210{Environment.NewLine}Read data from controller port #2.{Environment.NewLine}{Environment.NewLine}Write (Frame counter): MI-- ----{Environment.NewLine}Mode (M, 0 = 4-step, 1 = 5-step), IRQ inhibit flag (I)", false); + LabelManager.SetLabel(0x4010, AddressType.Register, "DmcFreq_4010", $"IL-- RRRR{Environment.NewLine}IRQ enable (I), loop (L), frequency (R)", false); + LabelManager.SetLabel(0x4011, AddressType.Register, "DmcCounter_4011", $"-DDD DDDD{Environment.NewLine}Load counter (D)", false); + LabelManager.SetLabel(0x4012, AddressType.Register, "DmcAddress_4012", $"AAAA AAAA{Environment.NewLine}Sample address (A)", false); + LabelManager.SetLabel(0x4013, AddressType.Register, "DmcLength_4013", $"LLLL LLLL{Environment.NewLine}Sample length (L)", false); - if(forFDS) { + LabelManager.SetLabel(0x4014, AddressType.Register, "SpriteDma_4014", "Writing $XX will upload 256 bytes of data from CPU page $XX00-$XXFF to the internal PPU OAM.", false); + + LabelManager.SetLabel(0x4015, AddressType.Register, "ApuStatus_4015", $"Read:{Environment.NewLine}IF-D NT21{Environment.NewLine}DMC interrupt (I), frame interrupt (F), DMC active (D), length counter > 0 (N/T/2/1){Environment.NewLine + Environment.NewLine}Write:{Environment.NewLine}---D NT21{Environment.NewLine}Enable DMC (D), noise (N), triangle (T), and pulse channels (2/1)", false); + + LabelManager.SetLabel(0x4016, AddressType.Register, "Ctrl1_4016", $"Read (NES - input):{Environment.NewLine}---4 3210{Environment.NewLine}Read data from controller port #1.{Environment.NewLine}{Environment.NewLine}Write:{Environment.NewLine}---- ---A{Environment.NewLine}Output data (strobe) to both controllers.", false); + LabelManager.SetLabel(0x4017, AddressType.Register, "Ctrl2_FrameCtr_4017", $"Read (NES - input):{Environment.NewLine}---4 3210{Environment.NewLine}Read data from controller port #2.{Environment.NewLine}{Environment.NewLine}Write (Frame counter): MI-- ----{Environment.NewLine}Mode (M, 0 = 4-step, 1 = 5-step), IRQ inhibit flag (I)", false); + } + + if(!disableBuiltInMapperWorkspace && mapperId == FdsMapperID) { LabelManager.SetLabel(0x01F8, AddressType.PrgRom, "LoadFiles", "Input: Pointer to Disk ID, Pointer to File List" + Environment.NewLine + "Output: A = error #, Y = # of files loaded" + Environment.NewLine + "Desc: Loads files specified by DiskID into memory from disk. Load addresses are decided by the file's header.", false); LabelManager.SetLabel(0x0237, AddressType.PrgRom, "AppendFile", "Input: Pointer to Disk ID, Pointer to File Header" + Environment.NewLine + "Output: A = error #" + Environment.NewLine + "Desc: Appends the file data given by DiskID to the disk. This means that the file is tacked onto the end of the disk, and the disk file count is incremented. The file is then read back to verify the write. If an error occurs during verification, the disk's file count is decremented (logically hiding the written file).", false); LabelManager.SetLabel(0x0239, AddressType.PrgRom, "WriteFile", "Input: Pointer to Disk ID, Pointer to File Header, A = file #" + Environment.NewLine + "Output: A = error #" + Environment.NewLine + "Desc: Same as \"Append File\", but instead of writing the file to the end of the disk, A specifies the sequential position on the disk to write the file (0 is the first). This also has the effect of setting the disk's file count to the A value, therefore logically hiding any other files that may reside after the written one.", false); diff --git a/GUI.NET/Debugger/frmDebugger.Designer.cs b/GUI.NET/Debugger/frmDebugger.Designer.cs index 896745ff..dc0fd90f 100644 --- a/GUI.NET/Debugger/frmDebugger.Designer.cs +++ b/GUI.NET/Debugger/frmDebugger.Designer.cs @@ -143,6 +143,7 @@ namespace Mesen.GUI.Debugger this.mnuShowCodePreview = new System.Windows.Forms.ToolStripMenuItem(); this.mnuShowOpCodeTooltips = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripSeparator(); + this.mnuHidePauseIcon = new System.Windows.Forms.ToolStripMenuItem(); this.mnuPpuPartialDraw = new System.Windows.Forms.ToolStripMenuItem(); this.mnuPpuShowPreviousFrame = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem19 = new System.Windows.Forms.ToolStripSeparator(); @@ -179,7 +180,7 @@ namespace Mesen.GUI.Debugger this.ctrlPpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping(); this.ctrlCpuMemoryMapping = new Mesen.GUI.Debugger.Controls.ctrlMemoryMapping(); this.tsToolbar = new Mesen.GUI.Controls.ctrlMesenToolStrip(); - this.mnuHidePauseIcon = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuResetLabels = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); this.splitContainer.Panel1.SuspendLayout(); this.splitContainer.Panel2.SuspendLayout(); @@ -225,7 +226,7 @@ namespace Mesen.GUI.Debugger this.splitContainer.Panel2.Controls.Add(this.tableLayoutPanel10); this.splitContainer.Panel2MinSize = 100; this.splitContainer.Size = new System.Drawing.Size(1172, 573); - this.splitContainer.SplitterDistance = 410; + this.splitContainer.SplitterDistance = 407; this.splitContainer.SplitterWidth = 7; this.splitContainer.TabIndex = 1; this.splitContainer.TabStop = false; @@ -248,7 +249,7 @@ namespace Mesen.GUI.Debugger // this.ctrlSplitContainerTop.Panel2.Controls.Add(this.tlpFunctionLabelLists); this.ctrlSplitContainerTop.Panel2MinSize = 150; - this.ctrlSplitContainerTop.Size = new System.Drawing.Size(1172, 410); + this.ctrlSplitContainerTop.Size = new System.Drawing.Size(1172, 407); this.ctrlSplitContainerTop.SplitterDistance = 750; this.ctrlSplitContainerTop.SplitterWidth = 7; this.ctrlSplitContainerTop.TabIndex = 3; @@ -270,7 +271,7 @@ namespace Mesen.GUI.Debugger this.tlpTop.Name = "tlpTop"; this.tlpTop.RowCount = 1; this.tlpTop.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tlpTop.Size = new System.Drawing.Size(750, 410); + this.tlpTop.Size = new System.Drawing.Size(750, 407); this.tlpTop.TabIndex = 2; // // ctrlDebuggerCode @@ -282,7 +283,7 @@ namespace Mesen.GUI.Debugger this.ctrlDebuggerCode.Name = "ctrlDebuggerCode"; this.ctrlDebuggerCode.ShowMemoryValues = false; this.ctrlDebuggerCode.ShowScrollbars = true; - this.ctrlDebuggerCode.Size = new System.Drawing.Size(286, 404); + this.ctrlDebuggerCode.Size = new System.Drawing.Size(286, 401); this.ctrlDebuggerCode.TabIndex = 2; this.ctrlDebuggerCode.TextZoom = 100; this.ctrlDebuggerCode.OnEditCode += new Mesen.GUI.Debugger.ctrlDebuggerCode.AssemblerEventHandler(this.ctrlDebuggerCode_OnEditCode); @@ -296,7 +297,7 @@ namespace Mesen.GUI.Debugger this.ctrlConsoleStatus.Location = new System.Drawing.Point(292, 0); this.ctrlConsoleStatus.Margin = new System.Windows.Forms.Padding(0); this.ctrlConsoleStatus.Name = "ctrlConsoleStatus"; - this.ctrlConsoleStatus.Size = new System.Drawing.Size(458, 410); + this.ctrlConsoleStatus.Size = new System.Drawing.Size(458, 407); this.ctrlConsoleStatus.TabIndex = 3; this.ctrlConsoleStatus.OnGotoLocation += new System.EventHandler(this.ctrlConsoleStatus_OnGotoLocation); // @@ -309,7 +310,7 @@ namespace Mesen.GUI.Debugger this.ctrlDebuggerCodeSplit.Name = "ctrlDebuggerCodeSplit"; this.ctrlDebuggerCodeSplit.ShowMemoryValues = false; this.ctrlDebuggerCodeSplit.ShowScrollbars = true; - this.ctrlDebuggerCodeSplit.Size = new System.Drawing.Size(1, 404); + this.ctrlDebuggerCodeSplit.Size = new System.Drawing.Size(1, 401); this.ctrlDebuggerCodeSplit.TabIndex = 4; this.ctrlDebuggerCodeSplit.TextZoom = 100; this.ctrlDebuggerCodeSplit.Visible = false; @@ -331,16 +332,16 @@ namespace Mesen.GUI.Debugger this.tlpFunctionLabelLists.RowCount = 2; this.tlpFunctionLabelLists.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tlpFunctionLabelLists.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tlpFunctionLabelLists.Size = new System.Drawing.Size(415, 410); + this.tlpFunctionLabelLists.Size = new System.Drawing.Size(415, 407); this.tlpFunctionLabelLists.TabIndex = 5; // // grpLabels // this.grpLabels.Controls.Add(this.ctrlLabelList); this.grpLabels.Dock = System.Windows.Forms.DockStyle.Fill; - this.grpLabels.Location = new System.Drawing.Point(3, 208); + this.grpLabels.Location = new System.Drawing.Point(3, 206); this.grpLabels.Name = "grpLabels"; - this.grpLabels.Size = new System.Drawing.Size(409, 199); + this.grpLabels.Size = new System.Drawing.Size(409, 198); this.grpLabels.TabIndex = 6; this.grpLabels.TabStop = false; this.grpLabels.Text = "Labels"; @@ -350,7 +351,7 @@ namespace Mesen.GUI.Debugger this.ctrlLabelList.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlLabelList.Location = new System.Drawing.Point(3, 16); this.ctrlLabelList.Name = "ctrlLabelList"; - this.ctrlLabelList.Size = new System.Drawing.Size(403, 180); + this.ctrlLabelList.Size = new System.Drawing.Size(403, 179); this.ctrlLabelList.TabIndex = 0; this.ctrlLabelList.OnFindOccurrence += new System.EventHandler(this.ctrlLabelList_OnFindOccurrence); this.ctrlLabelList.OnLabelSelected += new System.EventHandler(this.ctrlLabelList_OnLabelSelected); @@ -361,7 +362,7 @@ namespace Mesen.GUI.Debugger this.grpFunctions.Dock = System.Windows.Forms.DockStyle.Fill; this.grpFunctions.Location = new System.Drawing.Point(3, 3); this.grpFunctions.Name = "grpFunctions"; - this.grpFunctions.Size = new System.Drawing.Size(409, 199); + this.grpFunctions.Size = new System.Drawing.Size(409, 197); this.grpFunctions.TabIndex = 5; this.grpFunctions.TabStop = false; this.grpFunctions.Text = "Functions"; @@ -371,7 +372,7 @@ namespace Mesen.GUI.Debugger this.ctrlFunctionList.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlFunctionList.Location = new System.Drawing.Point(3, 16); this.ctrlFunctionList.Name = "ctrlFunctionList"; - this.ctrlFunctionList.Size = new System.Drawing.Size(403, 180); + this.ctrlFunctionList.Size = new System.Drawing.Size(403, 178); this.ctrlFunctionList.TabIndex = 0; this.ctrlFunctionList.OnFindOccurrence += new System.EventHandler(this.ctrlFunctionList_OnFindOccurrence); this.ctrlFunctionList.OnFunctionSelected += new System.EventHandler(this.ctrlFunctionList_OnFunctionSelected); @@ -402,7 +403,7 @@ namespace Mesen.GUI.Debugger this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel10.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel10.Size = new System.Drawing.Size(1172, 156); + this.tableLayoutPanel10.Size = new System.Drawing.Size(1172, 159); this.tableLayoutPanel10.TabIndex = 0; // // grpWatch @@ -411,7 +412,7 @@ namespace Mesen.GUI.Debugger this.grpWatch.Dock = System.Windows.Forms.DockStyle.Fill; this.grpWatch.Location = new System.Drawing.Point(3, 3); this.grpWatch.Name = "grpWatch"; - this.grpWatch.Size = new System.Drawing.Size(384, 150); + this.grpWatch.Size = new System.Drawing.Size(384, 153); this.grpWatch.TabIndex = 2; this.grpWatch.TabStop = false; this.grpWatch.Text = "Watch"; @@ -421,7 +422,7 @@ namespace Mesen.GUI.Debugger this.ctrlWatch.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlWatch.Location = new System.Drawing.Point(3, 16); this.ctrlWatch.Name = "ctrlWatch"; - this.ctrlWatch.Size = new System.Drawing.Size(378, 131); + this.ctrlWatch.Size = new System.Drawing.Size(378, 134); this.ctrlWatch.TabIndex = 0; // // grpBreakpoints @@ -430,7 +431,7 @@ namespace Mesen.GUI.Debugger this.grpBreakpoints.Dock = System.Windows.Forms.DockStyle.Fill; this.grpBreakpoints.Location = new System.Drawing.Point(393, 3); this.grpBreakpoints.Name = "grpBreakpoints"; - this.grpBreakpoints.Size = new System.Drawing.Size(384, 150); + this.grpBreakpoints.Size = new System.Drawing.Size(384, 153); this.grpBreakpoints.TabIndex = 3; this.grpBreakpoints.TabStop = false; this.grpBreakpoints.Text = "Breakpoints"; @@ -440,7 +441,7 @@ namespace Mesen.GUI.Debugger this.ctrlBreakpoints.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlBreakpoints.Location = new System.Drawing.Point(3, 16); this.ctrlBreakpoints.Name = "ctrlBreakpoints"; - this.ctrlBreakpoints.Size = new System.Drawing.Size(378, 131); + this.ctrlBreakpoints.Size = new System.Drawing.Size(378, 134); this.ctrlBreakpoints.TabIndex = 0; this.ctrlBreakpoints.BreakpointNavigation += new System.EventHandler(this.ctrlBreakpoints_BreakpointNavigation); // @@ -450,7 +451,7 @@ namespace Mesen.GUI.Debugger this.grpCallstack.Dock = System.Windows.Forms.DockStyle.Fill; this.grpCallstack.Location = new System.Drawing.Point(783, 3); this.grpCallstack.Name = "grpCallstack"; - this.grpCallstack.Size = new System.Drawing.Size(386, 150); + this.grpCallstack.Size = new System.Drawing.Size(386, 153); this.grpCallstack.TabIndex = 4; this.grpCallstack.TabStop = false; this.grpCallstack.Text = "Call Stack"; @@ -460,7 +461,7 @@ namespace Mesen.GUI.Debugger this.ctrlCallstack.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlCallstack.Location = new System.Drawing.Point(3, 16); this.ctrlCallstack.Name = "ctrlCallstack"; - this.ctrlCallstack.Size = new System.Drawing.Size(380, 131); + this.ctrlCallstack.Size = new System.Drawing.Size(380, 134); this.ctrlCallstack.TabIndex = 0; this.ctrlCallstack.FunctionSelected += new System.EventHandler(this.ctrlCallstack_FunctionSelected); // @@ -538,6 +539,7 @@ namespace Mesen.GUI.Debugger this.mnuExportLabels, this.toolStripMenuItem16, this.mnuResetWorkspace, + this.mnuResetLabels, this.toolStripMenuItem10, this.mnuAutoLoadDbgFiles, this.mnuAutoLoadCdlFiles, @@ -1268,6 +1270,14 @@ namespace Mesen.GUI.Debugger this.toolStripMenuItem6.Name = "toolStripMenuItem6"; this.toolStripMenuItem6.Size = new System.Drawing.Size(263, 6); // + // mnuHidePauseIcon + // + this.mnuHidePauseIcon.CheckOnClick = true; + this.mnuHidePauseIcon.Name = "mnuHidePauseIcon"; + this.mnuHidePauseIcon.Size = new System.Drawing.Size(266, 22); + this.mnuHidePauseIcon.Text = "Hide Pause Icon"; + this.mnuHidePauseIcon.Click += new System.EventHandler(this.mnuHidePauseIcon_Click); + // // mnuPpuPartialDraw // this.mnuPpuPartialDraw.CheckOnClick = true; @@ -1568,13 +1578,12 @@ namespace Mesen.GUI.Debugger this.tsToolbar.Text = "toolStrip1"; this.tsToolbar.Visible = false; // - // mnuHidePauseIcon + // mnuResetLabels // - this.mnuHidePauseIcon.CheckOnClick = true; - this.mnuHidePauseIcon.Name = "mnuHidePauseIcon"; - this.mnuHidePauseIcon.Size = new System.Drawing.Size(266, 22); - this.mnuHidePauseIcon.Text = "Hide Pause Icon"; - this.mnuHidePauseIcon.Click += new System.EventHandler(this.mnuHidePauseIcon_Click); + this.mnuResetLabels.Name = "mnuResetLabels"; + this.mnuResetLabels.Size = new System.Drawing.Size(207, 22); + this.mnuResetLabels.Text = "Reset Labels"; + this.mnuResetLabels.Click += new System.EventHandler(this.mnuResetLabels_Click); // // frmDebugger // @@ -1769,5 +1778,6 @@ namespace Mesen.GUI.Debugger private System.Windows.Forms.ToolStripSeparator toolStripMenuItem23; private System.Windows.Forms.ToolStripMenuItem mnuGoToProgramCount; private System.Windows.Forms.ToolStripMenuItem mnuHidePauseIcon; + private System.Windows.Forms.ToolStripMenuItem mnuResetLabels; } } \ No newline at end of file diff --git a/GUI.NET/Debugger/frmDebugger.cs b/GUI.NET/Debugger/frmDebugger.cs index fb7fd61b..870b9da0 100644 --- a/GUI.NET/Debugger/frmDebugger.cs +++ b/GUI.NET/Debugger/frmDebugger.cs @@ -934,7 +934,18 @@ namespace Mesen.GUI.Debugger { if(MessageBox.Show("This operation will empty the watch window, remove all breakpoints, and reset labels to their default state." + Environment.NewLine + "Are you sure?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { DebugWorkspaceManager.ResetWorkspace(); + UpdateWorkspace(); + UpdateDebugger(false); + } + } + + private void mnuResetLabels_Click(object sender, EventArgs e) + { + if(MessageBox.Show("This operation will reset labels to their default state." + Environment.NewLine + "Are you sure?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { LabelManager.ResetLabels(); + if(!ConfigManager.Config.DebugInfo.DisableDefaultLabels) { + LabelManager.SetDefaultLabels(InteropEmu.GetRomInfo().MapperId); + } UpdateWorkspace(); UpdateDebugger(false); } diff --git a/GUI.NET/InteropEmu.cs b/GUI.NET/InteropEmu.cs index a36a96f0..bcb899f0 100644 --- a/GUI.NET/InteropEmu.cs +++ b/GUI.NET/InteropEmu.cs @@ -1551,6 +1551,8 @@ namespace Mesen.GUI [MarshalAs(UnmanagedType.I1)] public bool IsChrRam; + + public UInt16 MapperId; } public enum RomFormat @@ -1569,6 +1571,7 @@ namespace Mesen.GUI public UInt32 PrgCrc32; public RomFormat Format; public bool IsChrRam; + public UInt16 MapperId; public RomInfo(InteropRomInfo romInfo) { @@ -1577,6 +1580,7 @@ namespace Mesen.GUI this.PrgCrc32 = romInfo.PrgCrc32; this.Format = romInfo.Format; this.IsChrRam = romInfo.IsChrRam; + this.MapperId = romInfo.MapperId; } public string GetRomName() diff --git a/InteropDLL/ConsoleWrapper.cpp b/InteropDLL/ConsoleWrapper.cpp index ed437364..63c6f8a4 100644 --- a/InteropDLL/ConsoleWrapper.cpp +++ b/InteropDLL/ConsoleWrapper.cpp @@ -75,6 +75,7 @@ namespace InteropEmu { uint32_t PrgCrc32; RomFormat Format; bool IsChrRam; + uint16_t MapperId; }; extern "C" { @@ -230,6 +231,7 @@ namespace InteropEmu { romInfo.PrgCrc32 = Console::GetHashInfo().PrgCrc32Hash; romInfo.Format = Console::GetRomFormat(); romInfo.IsChrRam = Console::IsChrRam(); + romInfo.MapperId = Console::GetMapperId(); } else { RomLoader romLoader(true); if(romLoader.LoadFile(romPath)) { @@ -241,6 +243,7 @@ namespace InteropEmu { romInfo.PrgCrc32 = romData.PrgCrc32; romInfo.Format = RomFormat::Unknown; romInfo.IsChrRam = romData.ChrRom.size() == 0; + romInfo.MapperId = 0; } else { _returnString = ""; romInfo.RomName = _returnString.c_str(); @@ -248,6 +251,7 @@ namespace InteropEmu { romInfo.PrgCrc32 = 0; romInfo.Format = RomFormat::Unknown; romInfo.IsChrRam = false; + romInfo.MapperId = 0; } } }