Skip to content

Commit

Permalink
Debugger: SNES - Add Color/Plot info in GSU debugger status view (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
meat-loaf committed Jun 16, 2023
1 parent b90ffc7 commit 6b6dff8
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 2 deletions.
33 changes: 31 additions & 2 deletions UI/Debugger/StatusViews/GsuStatusView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
</StackPanel>
</WrapPanel>

<WrapPanel>
<WrapPanel Margin="0 5">
<StackPanel Orientation="Horizontal">
<TextBlock>PBR:</TextBlock>
<c:MesenNumericTextBox Value="{CompiledBinding RegPbr}" Hex="True" Max="0xFF" />
Expand All @@ -129,7 +129,12 @@
<c:MesenNumericTextBox Value="{CompiledBinding RamBank}" Hex="True" Max="0xFF" />
</StackPanel>
</WrapPanel>

<WrapPanel>
<StackPanel Orientation="Horizontal">
<TextBlock>RAM ADDR:</TextBlock>
<c:MesenNumericTextBox Value="{CompiledBinding RamAddrCache}" Hex="True" Max="0xFFFF" />
</StackPanel>
</WrapPanel>
<Rectangle Stroke="{StaticResource MesenGrayBorderColor}" StrokeThickness="1" Margin="5 5 5 2" />

<WrapPanel Margin="0 2 0 0" DockPanel.Dock="Top">
Expand Down Expand Up @@ -164,6 +169,30 @@
</StackPanel>
</WrapPanel>
</WrapPanel>
<Rectangle Stroke="{StaticResource MesenGrayBorderColor}" StrokeThickness="1" Margin="5 5 5 2" />
<WrapPanel Margin="0 2 0 0" DockPanel.Dock="Top">
<StackPanel Orientation="Horizontal">
<TextBlock>COLOR:</TextBlock>
<c:MesenNumericTextBox Value="{CompiledBinding RegColor}" Hex="True" Max="0xFF" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock>POR:</TextBlock>
<c:MesenNumericTextBox Value="{CompiledBinding RegPor}" Hex="True" Max="0xFF" IsEnabled="False" />
</StackPanel>
<WrapPanel>
<StackPanel>
<CheckBox IsChecked="{CompiledBinding FlagPlotTransparent}" Content="Plot Transparent" />
<CheckBox IsChecked="{CompiledBinding FlagPlotDither}" Content="Plot Dither" />
</StackPanel>
<StackPanel>
<CheckBox IsChecked="{CompiledBinding FlagColorHighNibble}" Content="Color Src High" />
<CheckBox IsChecked="{CompiledBinding FlagColorFreezeHigh}" Content="Color Freeze High" />
</StackPanel>
<StackPanel>
<CheckBox IsChecked="{CompiledBinding FlagObjMode}" Content="Obj Mode" />
</StackPanel>
</WrapPanel>
</WrapPanel>
</StackPanel>
</DockPanel>
</ScrollViewer>
Expand Down
39 changes: 39 additions & 0 deletions UI/Debugger/StatusViews/GsuStatusViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ public class GsuStatusViewModel : BaseConsoleStatusViewModel
[Reactive] public UInt16 Reg15 { get; set; }

[Reactive] public UInt16 RegSfr { get; set; }
[Reactive] public UInt16 RamAddrCache { get; set; }

[Reactive] public byte RegSrc { get; set; }
[Reactive] public byte RegDst { get; set; }
[Reactive] public byte RegColor { get; set; }
[Reactive] public byte RegPor { get; set;}

[Reactive] public byte RegPbr { get; set; }
[Reactive] public byte RomBank { get; set; }
Expand All @@ -50,11 +53,20 @@ public class GsuStatusViewModel : BaseConsoleStatusViewModel
[Reactive] public bool FlagImmHigh { get; set; }
[Reactive] public bool FlagPrefix { get; set; }

[Reactive] public bool FlagPlotTransparent { get; set; }
[Reactive] public bool FlagPlotDither { get; set; }
[Reactive] public bool FlagColorHighNibble { get; set; }
[Reactive] public bool FlagColorFreezeHigh { get; set; }
[Reactive] public bool FlagObjMode { get; set; }

public GsuStatusViewModel()
{
this.WhenAnyValue(x => x.FlagZero, x => x.FlagCarry, x => x.FlagSign, x => x.FlagOverflow).Subscribe(x => UpdateSfrValue());
this.WhenAnyValue(x => x.FlagAlt1, x => x.FlagAlt2, x => x.FlagIrq, x => x.FlagRomReadPending).Subscribe(x => UpdateSfrValue());
this.WhenAnyValue(x => x.FlagRunning, x => x.FlagImmLow, x => x.FlagImmHigh, x => x.FlagPrefix).Subscribe(x => UpdateSfrValue());

this.WhenAnyValue(x => x.FlagPlotTransparent, x => x.FlagPlotDither, x => x.FlagColorHighNibble).Subscribe(x => UpdatePorValue());
this.WhenAnyValue(x => x.FlagColorFreezeHigh, x => x.FlagObjMode).Subscribe(x => UpdatePorValue());
}

private void UpdateSfrValue()
Expand All @@ -75,6 +87,17 @@ private void UpdateSfrValue()
);
}

private void UpdatePorValue()
{
RegPor = (byte)(
(FlagPlotTransparent ? 0x01 : 0) |
(FlagPlotDither ? 0x02 : 0) |
(FlagColorHighNibble ? 0x04 : 0) |
(FlagColorFreezeHigh ? 0x08 : 0) |
(FlagObjMode ? 0x10 : 0)
);
}

protected override void InternalUpdateUiState()
{
GsuState cpu = DebugApi.GetCpuState<GsuState>(CpuType.Gsu);
Expand All @@ -100,9 +123,11 @@ protected override void InternalUpdateUiState()

RegSrc = cpu.SrcReg;
RegDst = cpu.DestReg;
RegColor = cpu.ColorReg;
RegPbr = cpu.ProgramBank;
RomBank = cpu.RomBank;
RamBank = cpu.RamBank;
RamAddrCache = cpu.RamAddress;

FlagCarry = cpu.SFR.Carry;
FlagZero = cpu.SFR.Zero;
Expand All @@ -116,6 +141,12 @@ protected override void InternalUpdateUiState()
FlagImmHigh = cpu.SFR.ImmHigh;
FlagPrefix = cpu.SFR.Prefix;
FlagIrq = cpu.SFR.Irq;

FlagPlotTransparent = cpu.PlotTransparent;
FlagPlotDither = cpu.PlotDither;
FlagColorHighNibble = cpu.ColorHighNibble;
FlagColorFreezeHigh = cpu.ColorFreezeHigh;
FlagObjMode = cpu.ObjMode;
}

protected override void InternalUpdateConsoleState()
Expand All @@ -141,9 +172,11 @@ protected override void InternalUpdateConsoleState()

cpu.SrcReg = RegSrc;
cpu.DestReg = RegDst;
cpu.ColorReg = RegColor;
cpu.ProgramBank = RegPbr;
cpu.RomBank = RomBank;
cpu.RamBank = RamBank;
cpu.RamAddress = RamAddrCache;

cpu.SFR.Carry = FlagCarry;
cpu.SFR.Zero = FlagZero;
Expand All @@ -158,6 +191,12 @@ protected override void InternalUpdateConsoleState()
cpu.SFR.Prefix = FlagPrefix;
cpu.SFR.Irq = FlagIrq;

cpu.PlotTransparent = FlagPlotTransparent;
cpu.PlotDither = FlagPlotDither;
cpu.ColorHighNibble = FlagColorHighNibble;
cpu.ColorFreezeHigh = FlagColorFreezeHigh;
cpu.ObjMode = FlagObjMode;

DebugApi.SetCpuState(cpu, CpuType.Gsu);
}
}
Expand Down

0 comments on commit 6b6dff8

Please sign in to comment.