Skip to content

Commit

Permalink
Debugger: Event Viewer - GB - Added more categories, improved layout
Browse files Browse the repository at this point in the history
  • Loading branch information
SourMesen committed Jan 28, 2024
1 parent dbae841 commit d16d92d
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 36 deletions.
20 changes: 13 additions & 7 deletions Core/Gameboy/Debugger/GbEventManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,28 @@ EventViewerCategoryCfg GbEventManager::GetEventConfig(DebugEventInfo& evt)
uint16_t reg = evt.Operation.Address & 0xFFFF;
bool isWrite = evt.Operation.Type == MemoryOperationType::Write || evt.Operation.Type == MemoryOperationType::DmaWrite;
if(reg >= 0xFE00 && reg <= 0xFE9F) {
return isWrite ? _config.PpuRegisterOamWrites : _config.PpuRegisterReads;
return isWrite ? _config.PpuRegisterOamWrites : _config.PpuRegisterOamReads;
} else if(reg >= 0xFF42 && reg <= 0xFF43) {
return isWrite ? _config.PpuRegisterBgScrollWrites : _config.PpuRegisterReads;
return isWrite ? _config.PpuRegisterBgScrollWrites : _config.PpuRegisterBgScrollReads;
} else if(reg >= 0x8000 && reg <= 0x9FFF) {
return isWrite ? _config.PpuRegisterVramWrites : _config.PpuRegisterReads;
return isWrite ? _config.PpuRegisterVramWrites : _config.PpuRegisterVramReads;
} else if((reg >= 0xFF47 && reg <= 0xFF49) || (reg >= 0xFF68 && reg <= 0xFF6B)) {
return isWrite ? _config.PpuRegisterCgramWrites : _config.PpuRegisterReads;
return isWrite ? _config.PpuRegisterCgramWrites : _config.PpuRegisterCgramReads;
} else if(reg >= 0xFF4A && reg <= 0xFF4B) {
return isWrite ? _config.PpuRegisterWindowWrites : _config.PpuRegisterReads;
return isWrite ? _config.PpuRegisterWindowWrites : _config.PpuRegisterWindowReads;
} else if(reg >= 0xFF40 && reg <= 0xFF70) {
return isWrite ? _config.PpuRegisterOtherWrites : _config.PpuRegisterReads;
return isWrite ? _config.PpuRegisterOtherWrites : _config.PpuRegisterOtherReads;
} else if(reg >= 0xFF10 && reg <= 0xFF3F) {
return isWrite ? _config.ApuRegisterWrites : _config.ApuRegisterReads;
} else if(reg == 0xFF00) {
return isWrite ? _config.InputWrites : _config.InputReads;
} else if(reg == 0xFF01 || reg == 0xFF02) {
return isWrite ? _config.SerialWrites : _config.SerialReads;
} else if(reg >= 0xFF03 && reg <= 0xFF07) {
return isWrite ? _config.TimerWrites : _config.TimerReads;
}

return isWrite ? _config.CpuRegisterWrites : _config.CpuRegisterReads;
return isWrite ? _config.OtherRegisterWrites : _config.OtherRegisterReads;
}
}

Expand Down
22 changes: 19 additions & 3 deletions Core/Gameboy/Debugger/GbEventManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,34 @@ struct GbEventViewerConfig : public BaseEventViewerConfig
EventViewerCategoryCfg Irq;
EventViewerCategoryCfg MarkedBreakpoints;

EventViewerCategoryCfg PpuRegisterReads;
EventViewerCategoryCfg PpuRegisterCgramWrites;
EventViewerCategoryCfg PpuRegisterVramWrites;
EventViewerCategoryCfg PpuRegisterOamWrites;
EventViewerCategoryCfg PpuRegisterBgScrollWrites;
EventViewerCategoryCfg PpuRegisterWindowWrites;
EventViewerCategoryCfg PpuRegisterOtherWrites;

EventViewerCategoryCfg PpuRegisterCgramReads;
EventViewerCategoryCfg PpuRegisterVramReads;
EventViewerCategoryCfg PpuRegisterOamReads;
EventViewerCategoryCfg PpuRegisterBgScrollReads;
EventViewerCategoryCfg PpuRegisterWindowReads;
EventViewerCategoryCfg PpuRegisterOtherReads;

EventViewerCategoryCfg ApuRegisterReads;
EventViewerCategoryCfg ApuRegisterWrites;
EventViewerCategoryCfg CpuRegisterReads;
EventViewerCategoryCfg CpuRegisterWrites;

EventViewerCategoryCfg SerialReads;
EventViewerCategoryCfg SerialWrites;

EventViewerCategoryCfg TimerReads;
EventViewerCategoryCfg TimerWrites;

EventViewerCategoryCfg InputReads;
EventViewerCategoryCfg InputWrites;

EventViewerCategoryCfg OtherRegisterReads;
EventViewerCategoryCfg OtherRegisterWrites;

bool ShowPreviousFrameEvents;
};
Expand Down
44 changes: 38 additions & 6 deletions UI/Config/Debugger/GbEventViewerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,25 @@ public class GbEventViewerConfig : ViewModelBase
[Reactive] public EventViewerCategoryCfg PpuRegisterBgScrollWrites { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0x4A, 0x7C, 0xD9));
[Reactive] public EventViewerCategoryCfg PpuRegisterWindowWrites { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0xE2, 0x51, 0xF7));
[Reactive] public EventViewerCategoryCfg PpuRegisterOtherWrites { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0xD1, 0xDD, 0x42));
[Reactive] public EventViewerCategoryCfg PpuRegisterReads { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0x00, 0x75, 0x97));

[Reactive] public EventViewerCategoryCfg CpuRegisterWrites { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0xFF, 0x5E, 0x5E));
[Reactive] public EventViewerCategoryCfg CpuRegisterReads { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0x18, 0x98, 0xE4));
[Reactive] public EventViewerCategoryCfg PpuRegisterCgramReads { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0x29, 0xC9, 0x29));
[Reactive] public EventViewerCategoryCfg PpuRegisterVramReads { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0xDA, 0xB4, 0x7A));
[Reactive] public EventViewerCategoryCfg PpuRegisterOamReads { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0x44, 0x53, 0xD7));
[Reactive] public EventViewerCategoryCfg PpuRegisterBgScrollReads { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0xD9, 0x4A, 0x7C));
[Reactive] public EventViewerCategoryCfg PpuRegisterWindowReads { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0xF7, 0xE2, 0x51));
[Reactive] public EventViewerCategoryCfg PpuRegisterOtherReads { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0x42, 0xD1, 0xDD));

[Reactive] public EventViewerCategoryCfg SerialWrites { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0x7A, 0x7C, 0x29));
[Reactive] public EventViewerCategoryCfg SerialReads { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0x18, 0x98, 0x29));

[Reactive] public EventViewerCategoryCfg InputWrites { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0xFF, 0x42, 0x44));
[Reactive] public EventViewerCategoryCfg InputReads { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0x18, 0x51, 0xE4));

[Reactive] public EventViewerCategoryCfg TimerWrites { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0x51, 0xFF, 0x44));
[Reactive] public EventViewerCategoryCfg TimerReads { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0x18, 0x98, 0xE4));

[Reactive] public EventViewerCategoryCfg OtherRegisterWrites { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0x98, 0x5E, 0xFF));
[Reactive] public EventViewerCategoryCfg OtherRegisterReads { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0xC9, 0x98, 0xE4));

[Reactive] public EventViewerCategoryCfg ApuRegisterWrites { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0x9F, 0x93, 0xC6));
[Reactive] public EventViewerCategoryCfg ApuRegisterReads { get; set; } = new EventViewerCategoryCfg(Color.FromRgb(0xF9, 0xFE, 0xAC));
Expand All @@ -36,12 +51,29 @@ public InteropGbEventViewerConfig ToInterop()
PpuRegisterBgScrollWrites = this.PpuRegisterBgScrollWrites,
PpuRegisterWindowWrites = this.PpuRegisterWindowWrites,
PpuRegisterOtherWrites = this.PpuRegisterOtherWrites,
PpuRegisterReads = this.PpuRegisterReads,

CpuRegisterWrites = this.CpuRegisterWrites,
CpuRegisterReads = this.CpuRegisterReads,
PpuRegisterCgramReads = this.PpuRegisterCgramReads,
PpuRegisterVramReads = this.PpuRegisterVramReads,
PpuRegisterOamReads = this.PpuRegisterOamReads,
PpuRegisterBgScrollReads = this.PpuRegisterBgScrollReads,
PpuRegisterWindowReads = this.PpuRegisterWindowReads,
PpuRegisterOtherReads = this.PpuRegisterOtherReads,

SerialWrites = this.SerialWrites,
SerialReads = this.SerialReads,

InputWrites = this.InputWrites,
InputReads = this.InputReads,

TimerWrites = this.TimerWrites,
TimerReads = this.TimerReads,

OtherRegisterWrites = this.OtherRegisterWrites,
OtherRegisterReads = this.OtherRegisterReads,

ApuRegisterWrites = this.ApuRegisterWrites,
ApuRegisterReads = this.ApuRegisterReads,

Irq = this.Irq,
MarkedBreakpoints = this.MarkedBreakpoints,
ShowPreviousFrameEvents = this.ShowPreviousFrameEvents
Expand Down
64 changes: 47 additions & 17 deletions UI/Debugger/Views/GbEventViewerConfigView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:cfg="using:Mesen.Config"
xmlns:c="using:Mesen.Controls"
xmlns:dc="using:Mesen.Debugger.Controls"
mc:Ignorable="d"
Design.Width="200"
Design.Height="500"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
x:DataType="cfg:GbEventViewerConfig"
Expand All @@ -16,24 +19,51 @@
</Design.DataContext>

<StackPanel>
<dc:EventViewerCategoryControl Text="VRAM" Config="{CompiledBinding PpuRegisterVramWrites}" />
<dc:EventViewerCategoryControl Text="CGRAM" Config="{CompiledBinding PpuRegisterCgramWrites}" />
<dc:EventViewerCategoryControl Text="OAM" Config="{CompiledBinding PpuRegisterOamWrites}" />
<dc:EventViewerCategoryControl Text="BG Scroll" Config="{CompiledBinding PpuRegisterBgScrollWrites}" />
<dc:EventViewerCategoryControl Text="Window" Config="{CompiledBinding PpuRegisterWindowWrites}" />
<dc:EventViewerCategoryControl Text="Others" Config="{CompiledBinding PpuRegisterOtherWrites}" />

<dc:EventViewerCategoryControl Text="Read (any)" Config="{CompiledBinding PpuRegisterReads}" />

<dc:EventViewerCategoryControl Text="APU Read" Config="{CompiledBinding ApuRegisterReads}" />
<dc:EventViewerCategoryControl Text="APU Write" Config="{CompiledBinding ApuRegisterWrites}" />

<dc:EventViewerCategoryControl Text="CPU Read" Config="{CompiledBinding CpuRegisterReads}" />
<dc:EventViewerCategoryControl Text="CPU Write" Config="{CompiledBinding CpuRegisterWrites}" />

<dc:EventViewerCategoryControl Text="IRQ" Config="{CompiledBinding Irq}" />
<Grid ColumnDefinitions="10, 1*, 10, 1*" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto">
<c:OptionSection Header="LCD writes" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="0" />
<c:OptionSection Header="LCD reads" Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="2" Margin="10 0 0 0" />
<StackPanel Grid.Column="1" Grid.Row="1">
<dc:EventViewerCategoryControl Text="VRAM" Config="{CompiledBinding PpuRegisterVramWrites}" />
<dc:EventViewerCategoryControl Text="OAM" Config="{CompiledBinding PpuRegisterOamWrites}" />
<dc:EventViewerCategoryControl Text="Palette" Config="{CompiledBinding PpuRegisterCgramWrites}" />
<dc:EventViewerCategoryControl Text="BG Scroll" Config="{CompiledBinding PpuRegisterBgScrollWrites}" />
<dc:EventViewerCategoryControl Text="Window" Config="{CompiledBinding PpuRegisterWindowWrites}" />
<dc:EventViewerCategoryControl Text="Others" Config="{CompiledBinding PpuRegisterOtherWrites}" />
</StackPanel>
<StackPanel Grid.Column="3" Grid.Row="1">
<dc:EventViewerCategoryControl Text="VRAM" Config="{CompiledBinding PpuRegisterVramReads}" />
<dc:EventViewerCategoryControl Text="OAM" Config="{CompiledBinding PpuRegisterOamReads}" />
<dc:EventViewerCategoryControl Text="Palette" Config="{CompiledBinding PpuRegisterCgramReads}" />
<dc:EventViewerCategoryControl Text="BG Scroll" Config="{CompiledBinding PpuRegisterBgScrollReads}" />
<dc:EventViewerCategoryControl Text="Window" Config="{CompiledBinding PpuRegisterWindowReads}" />
<dc:EventViewerCategoryControl Text="Others" Config="{CompiledBinding PpuRegisterOtherReads}" />
</StackPanel>
</Grid>

<dc:EventViewerCategoryControl Text="Marked Breakpoints" Config="{CompiledBinding MarkedBreakpoints}" />
<Grid ColumnDefinitions="10, 1*, 10, 1*" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto" Margin="0 15 0 0">
<c:OptionSection Header="Register writes" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="0" />
<c:OptionSection Header="Register reads" Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="2" Margin="10 0 0 0" />
<StackPanel Grid.Column="1" Grid.Row="1">
<dc:EventViewerCategoryControl Text="APU" Config="{CompiledBinding ApuRegisterWrites}" />
<dc:EventViewerCategoryControl Text="Input" Config="{CompiledBinding InputWrites}" />
<dc:EventViewerCategoryControl Text="Timer" Config="{CompiledBinding TimerWrites}" />
<dc:EventViewerCategoryControl Text="Serial" Config="{CompiledBinding SerialWrites}" />
<dc:EventViewerCategoryControl Text="Other" Config="{CompiledBinding OtherRegisterWrites}" />
</StackPanel>
<StackPanel Grid.Column="3" Grid.Row="1">
<dc:EventViewerCategoryControl Text="APU" Config="{CompiledBinding ApuRegisterReads}" />
<dc:EventViewerCategoryControl Text="Input" Config="{CompiledBinding InputReads}" />
<dc:EventViewerCategoryControl Text="Timer" Config="{CompiledBinding TimerReads}" />
<dc:EventViewerCategoryControl Text="Serial" Config="{CompiledBinding SerialReads}" />
<dc:EventViewerCategoryControl Text="Other" Config="{CompiledBinding OtherRegisterReads}" />
</StackPanel>
</Grid>

<c:OptionSection Header="Other events" />
<StackPanel>
<dc:EventViewerCategoryControl Text="IRQ" Config="{CompiledBinding Irq}" />
<dc:EventViewerCategoryControl Text="Marked Breakpoints" Config="{CompiledBinding MarkedBreakpoints}" />
</StackPanel>

<CheckBox Margin="0 10 0 0" IsChecked="{CompiledBinding ShowPreviousFrameEvents}" Content="Show previous frame events" />
</StackPanel>
Expand Down
22 changes: 19 additions & 3 deletions UI/Interop/DebugApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -812,18 +812,34 @@ public class InteropGbEventViewerConfig
public InteropEventViewerCategoryCfg Irq;
public InteropEventViewerCategoryCfg MarkedBreakpoints;

public InteropEventViewerCategoryCfg PpuRegisterReads;
public InteropEventViewerCategoryCfg PpuRegisterCgramWrites;
public InteropEventViewerCategoryCfg PpuRegisterVramWrites;
public InteropEventViewerCategoryCfg PpuRegisterOamWrites;
public InteropEventViewerCategoryCfg PpuRegisterBgScrollWrites;
public InteropEventViewerCategoryCfg PpuRegisterWindowWrites;
public InteropEventViewerCategoryCfg PpuRegisterOtherWrites;

public InteropEventViewerCategoryCfg PpuRegisterCgramReads;
public InteropEventViewerCategoryCfg PpuRegisterVramReads;
public InteropEventViewerCategoryCfg PpuRegisterOamReads;
public InteropEventViewerCategoryCfg PpuRegisterBgScrollReads;
public InteropEventViewerCategoryCfg PpuRegisterWindowReads;
public InteropEventViewerCategoryCfg PpuRegisterOtherReads;

public InteropEventViewerCategoryCfg ApuRegisterReads;
public InteropEventViewerCategoryCfg ApuRegisterWrites;
public InteropEventViewerCategoryCfg CpuRegisterReads;
public InteropEventViewerCategoryCfg CpuRegisterWrites;

public InteropEventViewerCategoryCfg SerialReads;
public InteropEventViewerCategoryCfg SerialWrites;

public InteropEventViewerCategoryCfg TimerReads;
public InteropEventViewerCategoryCfg TimerWrites;

public InteropEventViewerCategoryCfg InputReads;
public InteropEventViewerCategoryCfg InputWrites;

public InteropEventViewerCategoryCfg OtherRegisterReads;
public InteropEventViewerCategoryCfg OtherRegisterWrites;

[MarshalAs(UnmanagedType.I1)] public bool ShowPreviousFrameEvents;
}
Expand Down

0 comments on commit d16d92d

Please sign in to comment.