From 7939f73f8251210a1f9de66a37e81ad9cbb3b437 Mon Sep 17 00:00:00 2001 From: Souryo Date: Sun, 27 Nov 2016 20:59:33 -0500 Subject: [PATCH] Debugger: Display byte & word values in tooltip --- GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs | 10 ++++++---- GUI.NET/Debugger/frmCodeTooltip.cs | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs b/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs index 4ed1b850..68942f34 100644 --- a/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs +++ b/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs @@ -234,11 +234,12 @@ namespace Mesen.GUI.Debugger if(word.StartsWith("$")) { try { UInt32 address = UInt32.Parse(word.Substring(1), System.Globalization.NumberStyles.AllowHexSpecifier); - Byte memoryValue = InteropEmu.DebugGetMemoryValue(address); + byte byteValue = InteropEmu.DebugGetMemoryValue(address); + UInt16 wordValue = (UInt16)(byteValue | (InteropEmu.DebugGetMemoryValue(address+1) << 8)); var values = new Dictionary() { { "Address", "$" + address.ToString("X4") }, - { "Value", "$" + memoryValue.ToString("X2") }, + { "Value", $"${byteValue.ToString("X2")} (byte){Environment.NewLine}${wordValue.ToString("X4")} (word)" } }; ShowTooltip(word, values); @@ -248,11 +249,12 @@ namespace Mesen.GUI.Debugger if(label != null) { Int32 relativeAddress = InteropEmu.DebugGetRelativeAddress(label.Address, label.AddressType); - Int32 memoryValue = relativeAddress >= 0 ? InteropEmu.DebugGetMemoryValue((UInt32)relativeAddress) : -1; + byte byteValue = relativeAddress >= 0 ? InteropEmu.DebugGetMemoryValue((UInt32)relativeAddress) : (byte)0; + UInt16 wordValue = relativeAddress >= 0 ? (UInt16)(byteValue | (InteropEmu.DebugGetMemoryValue((UInt32)relativeAddress+1) << 8)) : (UInt16)0; var values = new Dictionary() { { "Label", label.Label }, { "Address", "$" + InteropEmu.DebugGetRelativeAddress(label.Address, label.AddressType).ToString("X4") }, - { "Value", (memoryValue >= 0 ? ("$" + memoryValue.ToString("X2")) : "n/a") }, + { "Value", (relativeAddress >= 0 ? $"${byteValue.ToString("X2")} (byte){Environment.NewLine}${wordValue.ToString("X4")} (word)" : "n/a") }, }; if(!string.IsNullOrWhiteSpace(label.Comment)) { diff --git a/GUI.NET/Debugger/frmCodeTooltip.cs b/GUI.NET/Debugger/frmCodeTooltip.cs index fec3f2b6..82c9ce39 100644 --- a/GUI.NET/Debugger/frmCodeTooltip.cs +++ b/GUI.NET/Debugger/frmCodeTooltip.cs @@ -33,7 +33,7 @@ namespace Mesen.GUI.Debugger foreach(KeyValuePair kvp in _values) { tlpMain.RowStyles.Insert(1, new RowStyle()); Label lbl = new Label(); - lbl.Margin = new Padding(2); + lbl.Margin = new Padding(2, 3, 2, 2); lbl.Text = kvp.Key + ":"; lbl.Font = new Font(lbl.Font, FontStyle.Bold); lbl.AutoSize = true;