diff --git a/Core/Debugger/BaseEventManager.cpp b/Core/Debugger/BaseEventManager.cpp index a15f60dc..0353391d 100644 --- a/Core/Debugger/BaseEventManager.cpp +++ b/Core/Debugger/BaseEventManager.cpp @@ -64,6 +64,9 @@ void BaseEventManager::GetEvents(DebugEventInfo* eventArray, uint32_t& maxEventC auto lock = _lock.AcquireSafe(); uint32_t eventCount = std::min(maxEventCount, (uint32_t)_sentEvents.size()); memcpy(eventArray, _sentEvents.data(), eventCount * sizeof(DebugEventInfo)); + for(uint32_t i = 0; i < eventCount; i++) { + eventArray[i].Color = GetEventConfig(eventArray[i]).Color; + } maxEventCount = eventCount; } diff --git a/Core/Debugger/BaseEventManager.h b/Core/Debugger/BaseEventManager.h index c01f5084..7138ee2b 100644 --- a/Core/Debugger/BaseEventManager.h +++ b/Core/Debugger/BaseEventManager.h @@ -26,6 +26,7 @@ struct DebugEventInfo uint32_t Flags; int32_t RegisterId = -1; MemoryOperationInfo TargetMemory; + uint32_t Color = 0; }; struct EventViewerCategoryCfg diff --git a/UI/Debugger/ViewModels/EventViewerListViewModel.cs b/UI/Debugger/ViewModels/EventViewerListViewModel.cs index c3d8d7c1..88d515c9 100644 --- a/UI/Debugger/ViewModels/EventViewerListViewModel.cs +++ b/UI/Debugger/ViewModels/EventViewerListViewModel.cs @@ -44,6 +44,7 @@ namespace Mesen.Debugger.ViewModels } private Dictionary> _comparers = new() { + { "Color", (a, b) => a.Color.CompareTo(b.Color) }, { "ProgramCounter", (a, b) => a.ProgramCounter.CompareTo(b.ProgramCounter) }, { "Scanline", (a, b) => a.Scanline.CompareTo(b.Scanline) }, { "Cycle", (a, b) => a.Cycle.CompareTo(b.Cycle) }, diff --git a/UI/Debugger/ViewModels/EventViewerViewModel.cs b/UI/Debugger/ViewModels/EventViewerViewModel.cs index 46db0b10..2b4d0b55 100644 --- a/UI/Debugger/ViewModels/EventViewerViewModel.cs +++ b/UI/Debugger/ViewModels/EventViewerViewModel.cs @@ -174,7 +174,7 @@ namespace Mesen.Debugger.ViewModels new ContextMenuAction() { ActionType = ActionType.ViewInDebugger, IsEnabled = () => SelectedEvent != null, - HintText = () => "PC - " + (SelectedEvent != null ? $"${SelectedEvent.Value.ProgramCounter:X4}" : ""), + HintText = () => SelectedEvent != null ? $"PC -${SelectedEvent.Value.ProgramCounter:X4}" : "", OnClick = () => { if(SelectedEvent != null) { DebuggerWindow.OpenWindowAtAddress(CpuType, (int)SelectedEvent.Value.ProgramCounter); @@ -184,7 +184,7 @@ namespace Mesen.Debugger.ViewModels new ContextMenuAction() { ActionType = ActionType.ToggleBreakpoint, IsEnabled = () => SelectedEvent != null, - HintText = () => "PC - " + (SelectedEvent != null ? $"${SelectedEvent.Value.ProgramCounter:X4}" : ""), + HintText = () => SelectedEvent != null ? $"PC - ${SelectedEvent.Value.ProgramCounter:X4}" : "", OnClick = () => { if(SelectedEvent != null) { int addr = (int)SelectedEvent.Value.Operation.Address; @@ -195,7 +195,7 @@ namespace Mesen.Debugger.ViewModels new ContextMenuAction() { ActionType = ActionType.ToggleBreakpoint, IsEnabled = () => SelectedEvent != null && SelectedEvent?.Type == DebugEventType.Register, - HintText = () => "Address - " + (SelectedEvent != null && SelectedEvent?.Type == DebugEventType.Register ? $"${SelectedEvent.Value.Operation.Address:X4}" : ""), + HintText = () => (SelectedEvent != null && SelectedEvent?.Type == DebugEventType.Register ? $"Address - ${SelectedEvent.Value.Operation.Address:X4}" : ""), OnClick = () => { if(SelectedEvent != null && SelectedEvent?.Type == DebugEventType.Register) { int addr = (int)SelectedEvent.Value.Operation.Address; @@ -458,16 +458,7 @@ namespace Mesen.Debugger.ViewModels public event PropertyChangedEventHandler? PropertyChanged; - private string _programCounter = ""; - public string ProgramCounter - { - get - { - UpdateFields(); - return _programCounter; - } - } - + public string ProgramCounter { get; set; } = ""; public string Scanline { get; set; } = ""; public string Cycle { get; set; } = ""; public string Type { get; set; } = ""; @@ -475,6 +466,16 @@ namespace Mesen.Debugger.ViewModels public string Value { get; set; } = ""; public string Details { get; set; } = ""; + private UInt32 _color = 0; + public UInt32 Color + { + get + { + UpdateFields(); + return _color; + } + } + public DebugEventInfo RawEvent => _events[_index]; public DebugEventViewModel(DebugEventInfo[] events, int index) @@ -494,12 +495,14 @@ namespace Mesen.Debugger.ViewModels PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Address")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Value")); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Details")); + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Color")); } private void UpdateFields() { DebugEventInfo evt = _events[_index]; - _programCounter = "$" + evt.ProgramCounter.ToString("X4"); + _color = evt.Color; + ProgramCounter = "$" + evt.ProgramCounter.ToString("X4"); Scanline = evt.Scanline.ToString(); Cycle = evt.Cycle.ToString(); string address = ""; diff --git a/UI/Debugger/Windows/EventViewerWindow.axaml b/UI/Debugger/Windows/EventViewerWindow.axaml index f714301b..a9ac2e13 100644 --- a/UI/Debugger/Windows/EventViewerWindow.axaml +++ b/UI/Debugger/Windows/EventViewerWindow.axaml @@ -9,6 +9,7 @@ xmlns:c="using:Mesen.Controls" xmlns:dc="using:Mesen.Debugger.Controls" xmlns:du="using:Mesen.Debugger.Utilities" + xmlns:u="using:Mesen.Utilities" xmlns:v="using:Mesen.Debugger.Views" xmlns:i="using:Mesen.Interop" xmlns:l="using:Mesen.Localization" @@ -27,6 +28,7 @@ + @@ -122,9 +124,24 @@ - + + + + + + diff --git a/UI/Interop/DebugApi.cs b/UI/Interop/DebugApi.cs index a4d7ed15..50fde206 100644 --- a/UI/Interop/DebugApi.cs +++ b/UI/Interop/DebugApi.cs @@ -713,6 +713,7 @@ namespace Mesen.Interop public EventFlags Flags; public Int32 RegisterId; public MemoryOperationInfo TargetMemory; + public UInt32 Color; }; [StructLayout(LayoutKind.Sequential)]