From e1841c869776b42d0778826f695eb767b6f47879 Mon Sep 17 00:00:00 2001 From: SirRickster <dbardaji@yahoo.es> Date: Thu, 9 Nov 2023 17:33:01 +0100 Subject: [PATCH 1/4] Add preliminary Flags dock to interface --- .../Flags/Controls/ZXFlagsView.axaml | 21 +++++++++++++++ .../Flags/Controls/ZXFlagsView.axaml.cs | 26 +++++++++++++++++++ ZXBStudio/MainWindow.axaml | 21 ++++++++++++--- ZXBStudio/MainWindow.axaml.cs | 5 ++++ ZXBStudio/ZXBasicStudio.csproj | 9 +++---- 5 files changed, 72 insertions(+), 10 deletions(-) create mode 100644 ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml create mode 100644 ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml.cs diff --git a/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml b/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml new file mode 100644 index 0000000..78ddfe5 --- /dev/null +++ b/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml @@ -0,0 +1,21 @@ +<UserControl xmlns="https://github.com/avaloniaui" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" + x:Class="ZXBasicStudio.DebuggingTools.Flags.Controls.ZXFlagsView"> + <Grid ColumnDefinitions="*,*" RowDefinitions="*,*"> + <Border BorderThickness="0,0,1,0" BorderBrush="#000" Background="#303030"> + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">Total</TextBlock> + </Border> + <Border Grid.Column="1" BorderThickness="1,0,0,0" BorderBrush="#000" Background="#303030"> + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">Step</TextBlock> + </Border> + <Border Grid.Row="1" Background="#606060" BorderThickness="0,0,1,0" BorderBrush="#000"> + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Row="2" Name="flag1">--</TextBlock> + </Border> + <Border Grid.Row="1" Grid.Column="1" Background="#606060" BorderThickness="1,0,0,0" BorderBrush="#000"> + <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Row="2" Grid.Column="1" Name="flag2">--</TextBlock> + </Border> + </Grid> +</UserControl> diff --git a/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml.cs b/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml.cs new file mode 100644 index 0000000..1ccf35d --- /dev/null +++ b/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml.cs @@ -0,0 +1,26 @@ +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace ZXBasicStudio.DebuggingTools.Flags.Controls +{ + public partial class ZXFlagsView : UserControl + { + + public ZXFlagsView() + { + InitializeComponent(); + } + + public void Update() + { + flag1.Text = "HH"; + flag2.Text = "HH"; + } + + public void Clear() + { + flag1.Text = "**"; + flag2.Text = "**"; + } + } +} diff --git a/ZXBStudio/MainWindow.axaml b/ZXBStudio/MainWindow.axaml index fa2545d..95fcd56 100644 --- a/ZXBStudio/MainWindow.axaml +++ b/ZXBStudio/MainWindow.axaml @@ -9,6 +9,7 @@ xmlns:zxdtr="using:ZXBasicStudio.DebuggingTools.Registers.Controls" xmlns:zxdtm="using:ZXBasicStudio.DebuggingTools.Memory.Controls" xmlns:zxdtt="using:ZXBasicStudio.DebuggingTools.TStates.Controls" + xmlns:zxdfl="using:ZXBasicStudio.DebuggingTools.Flags.Controls" xmlns:wnd="using:ZXBasicStudio.Classes" xmlns:svg="using:Avalonia.Svg.Skia" mc:Ignorable="d" d:DesignWidth="1024" d:DesignHeight="600" @@ -189,25 +190,37 @@ <TabControl Grid.Column="2" Grid.Row="2" Name="tcEditors" ItemsSource="{Binding EditItems}" /> <zxd:ZXCollapseButton CollapseDirection="Right" GridColumn="4" Grid.Column="3" Grid.Row="2"></zxd:ZXCollapseButton> <GridSplitter Classes="vertical" Grid.Column="3" Grid.Row="2" Grid.RowSpan="3" ResizeDirection="Columns"></GridSplitter> - <zxd:ZXDockingContainer Grid.Column="4" Grid.Row="2" RowDefinitions="*,4,0.3*,4,*" Grid.RowSpan="3" Name="dockRight"> - <zxd:ZXDockingControl Title="Variables" Name="varsDock"> + + <zxd:ZXDockingContainer Grid.Column="4" Grid.Row="2" RowDefinitions="*,4,0.3*,4,.3*,4,*" Grid.RowSpan="4" Name="dockRight"> + + <zxd:ZXDockingControl Grid.Row="0" Title="Variables" Name="varsDock"> <zxd:ZXDockingControl.DockedControl> <zxdtv:ZXVariablesView Name="varsView"></zxdtv:ZXVariablesView> </zxd:ZXDockingControl.DockedControl> </zxd:ZXDockingControl> + <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"></GridSplitter> - <zxd:ZXDockingControl Title="T-States" Grid.Row="2" Name="tstatesDock"> + <zxd:ZXDockingControl Grid.Row="2" Title="T-States" Name="tstatesDock"> <zxd:ZXDockingControl.DockedControl> <zxdtt:ZXTStatesView Name="statesView"></zxdtt:ZXTStatesView> </zxd:ZXDockingControl.DockedControl> </zxd:ZXDockingControl> + <GridSplitter Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"></GridSplitter> - <zxd:ZXDockingControl Title="Registers" Grid.Row="4" Name="regsDock"> + <zxd:ZXDockingControl Grid.Row="4" Title="Z80 Flags" Name="flagsDock"> + <zxd:ZXDockingControl.DockedControl> + <zxdfl:ZXFlagsView Name="flagsView"></zxdfl:ZXFlagsView> + </zxd:ZXDockingControl.DockedControl> + </zxd:ZXDockingControl> + + <GridSplitter Grid.Row="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"></GridSplitter> + <zxd:ZXDockingControl Grid.Row="6" Title="Registers" Name="regsDock"> <zxd:ZXDockingControl.DockedControl> <zxdtr:ZXRegistersView Name="regView" AllowEdit="{Binding EmulatorInfo.CanStep}"></zxdtr:ZXRegistersView> </zxd:ZXDockingControl.DockedControl> </zxd:ZXDockingControl> </zxd:ZXDockingContainer> + <GridSplitter Classes="horizontal" Grid.Column="2" Grid.ColumnSpan="1" Grid.Row="3" ResizeDirection="Rows"></GridSplitter> <zxd:ZXTabDockingContainer Name="dockBottom" Grid.Column="2" Grid.ColumnSpan="1" Grid.Row="4" TabsPosition="Bottom"> <zxd:ZXTabDockingContainer.DockedControls> diff --git a/ZXBStudio/MainWindow.axaml.cs b/ZXBStudio/MainWindow.axaml.cs index 86a2858..bfce33d 100644 --- a/ZXBStudio/MainWindow.axaml.cs +++ b/ZXBStudio/MainWindow.axaml.cs @@ -1050,6 +1050,7 @@ private void StopEmulator(object? sender, Avalonia.Interactivity.RoutedEventArgs UnblockEditors(); varsView.EndEdit(); statesView.Clear(); + flagsView.Clear(); } private async void PauseEmulator(object? sender, Avalonia.Interactivity.RoutedEventArgs e) { @@ -1067,6 +1068,7 @@ private async void PauseEmulator(object? sender, Avalonia.Interactivity.RoutedEv regView.Update(); varsView.BeginEdit(); statesView.Update(emu.TStates); + flagsView.Update(); } } private void ResumeEmulator(object? sender, Avalonia.Interactivity.RoutedEventArgs e) @@ -1179,6 +1181,7 @@ private async void AssemblerStepEmulator(object? sender, Avalonia.Interactivity. regView.Update(); varsView.BeginEdit(); statesView.Update(emu.TStates); + flagsView.Update(); } private void Emu_ProgramReady(object? sender, EventArgs e) { @@ -1235,6 +1238,7 @@ private void Emu_Breakpoint(object? sender, BreakpointEventArgs e) varsView.BeginEdit(); regView.Update(); statesView.Update(emu.TStates); + flagsView.Update(); outLog.Writer.WriteLine($"Breakpoint: file {Path.GetFileName(line.File)}, line {line.LineNumber + 1}, address {line.Address}"); }); @@ -2170,6 +2174,7 @@ void Cleanup() varsView.EndEdit(); statesView.Clear(); + flagsView.Clear(); currentBp = null; emu.UpdateBreakpoints(null); EmulatorInfo.IsRunning = false; diff --git a/ZXBStudio/ZXBasicStudio.csproj b/ZXBStudio/ZXBasicStudio.csproj index fc373ea..908d45c 100644 --- a/ZXBStudio/ZXBasicStudio.csproj +++ b/ZXBStudio/ZXBasicStudio.csproj @@ -15,12 +15,6 @@ <AssemblyVersion>1.0.*</AssemblyVersion> <Deterministic>False</Deterministic> </PropertyGroup> - <ItemGroup> - <AvaloniaXaml Remove="LanguageDefinitions\**" /> - <Compile Remove="LanguageDefinitions\**" /> - <EmbeddedResource Remove="LanguageDefinitions\**" /> - <None Remove="LanguageDefinitions\**" /> - </ItemGroup> <ItemGroup> <AvaloniaXaml Remove="Controls\ZXLocalVariablesView.axaml" /> <AvaloniaXaml Remove="Controls\ZXVariableView.axaml" /> @@ -573,6 +567,9 @@ <Compile Update="Emulator\Controls\ZXKeyView.axaml.cs"> <DependentUpon>ZXKeyView.axaml</DependentUpon> </Compile> + <Compile Update="DebuggingTools\Flags\Controls\ZXFlagsView.axaml.cs"> + <DependentUpon>ZXFlagsView.axaml</DependentUpon> + </Compile> <Compile Update="DebuggingTools\Registers\Controls\ZXRegisterView.axaml.cs"> <DependentUpon>ZXRegisterView.axaml</DependentUpon> </Compile> From 938012a8c07249ce4b35028c24d28e4bb38c4bae Mon Sep 17 00:00:00 2001 From: SirRickster <dbardaji@yahoo.es> Date: Thu, 9 Nov 2023 17:37:14 +0100 Subject: [PATCH 2/4] Stylizing Flags dock --- .../Flags/Controls/ZXFlagsView.axaml | 58 ++++++++++++++----- .../Flags/Controls/ZXFlagsView.axaml.cs | 6 +- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml b/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml index 78ddfe5..80b93b4 100644 --- a/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml +++ b/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml @@ -4,18 +4,48 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="ZXBasicStudio.DebuggingTools.Flags.Controls.ZXFlagsView"> - <Grid ColumnDefinitions="*,*" RowDefinitions="*,*"> - <Border BorderThickness="0,0,1,0" BorderBrush="#000" Background="#303030"> - <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">Total</TextBlock> - </Border> - <Border Grid.Column="1" BorderThickness="1,0,0,0" BorderBrush="#000" Background="#303030"> - <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">Step</TextBlock> - </Border> - <Border Grid.Row="1" Background="#606060" BorderThickness="0,0,1,0" BorderBrush="#000"> - <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Row="2" Name="flag1">--</TextBlock> - </Border> - <Border Grid.Row="1" Grid.Column="1" Background="#606060" BorderThickness="1,0,0,0" BorderBrush="#000"> - <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Row="2" Grid.Column="1" Name="flag2">--</TextBlock> - </Border> - </Grid> + <Panel Background="#FF606060"> + <Grid ColumnDefinitions="*,*,*,*,*,*,*,*" RowDefinitions="*,*" DataContext="{Binding ZXFlagsView, Mode=TwoWay}"> + <TextBlock Grid.Row="0" Grid.Column="0" ToolTip.Tip="S - Sign flag: Set if the 2-complement value is negative (copy of MSB)">S</TextBlock> + <TextBlock Grid.Row="0" Grid.Column="1" ToolTip.Tip="Z - Zero flag: Set if the value is zero">Z</TextBlock> + <TextBlock Grid.Row="0" Grid.Column="2" ToolTip.Tip="F5 - undocumented: Copy of bit 5">-</TextBlock> + <TextBlock Grid.Row="0" Grid.Column="3" ToolTip.Tip="H - Half Carry: Carry from bit 3 to bit 4">H</TextBlock> + <TextBlock Grid.Row="0" Grid.Column="4" ToolTip.Tip="F3 - undocumented: Copy of bit 3">-</TextBlock> + <TextBlock Grid.Row="0" Grid.Column="5" ToolTip.Tip="P/V - Parity or Overflow: Parity set if even number of bits set. Overflow set if the 2-complement result does not fit in the register">V</TextBlock> + <TextBlock Grid.Row="0" Grid.Column="6" ToolTip.Tip="N - Subtract: Set if the last operation was a subtraction">N</TextBlock> + <TextBlock Grid.Row="0" Grid.Column="7" ToolTip.Tip="C - Carry: Set if the result did not fit in the register">C</TextBlock> + <Border Grid.Column="0" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" + HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> + <TextBlock Text="{Binding Bit7Value,Mode=TwoWay}" Name="Bit7"/> + </Border> + <Border Grid.Column="1" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" + HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> + <TextBlock Text="{Binding Bit6Value,Mode=TwoWay}" Name="Bit6" /> + </Border> + <Border Grid.Column="2" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" + HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> + <TextBlock Text="{Binding Bit5Value}" Name="Bit5" /> + </Border> + <Border Grid.Column="3" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" + HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> + <TextBlock Text="{Binding bit4Value}" Name="Bit4" /> + </Border> + <Border Grid.Column="4" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" + HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> + <TextBlock Text="{Binding bit3Value}" Name="Bit3" /> + </Border> + <Border Grid.Column="5" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" + HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> + <TextBlock Text="{Binding bit2Value}" Name="Bit2" /> + </Border> + <Border Grid.Column="6" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" + HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> + <TextBlock Text="{Binding bit1Value}" Name="Bit1" /> + </Border> + <Border Grid.Column="7" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" + HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> + <TextBlock Text="{Binding bit0Value}" Name="Bit0" /> + </Border> + </Grid> + </Panel> </UserControl> diff --git a/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml.cs b/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml.cs index 1ccf35d..4eed2cc 100644 --- a/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml.cs +++ b/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml.cs @@ -13,14 +13,12 @@ public ZXFlagsView() public void Update() { - flag1.Text = "HH"; - flag2.Text = "HH"; + } public void Clear() { - flag1.Text = "**"; - flag2.Text = "**"; + } } } From c898865018fd43aa997e72955dd0a07e0d923fd4 Mon Sep 17 00:00:00 2001 From: SirRickster <dbardaji@yahoo.es> Date: Thu, 9 Nov 2023 21:11:45 +0100 Subject: [PATCH 3/4] Add Flags Dock --- .../Flags/Controls/ZXFlagsView.axaml | 93 ++++++++++--------- .../Flags/Controls/ZXFlagsView.axaml.cs | 38 +++++++- ZXBStudio/MainWindow.axaml | 2 +- ZXBStudio/MainWindow.axaml.cs | 7 +- 4 files changed, 87 insertions(+), 53 deletions(-) diff --git a/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml b/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml index 80b93b4..50a2d39 100644 --- a/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml +++ b/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml @@ -4,48 +4,53 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="ZXBasicStudio.DebuggingTools.Flags.Controls.ZXFlagsView"> - <Panel Background="#FF606060"> - <Grid ColumnDefinitions="*,*,*,*,*,*,*,*" RowDefinitions="*,*" DataContext="{Binding ZXFlagsView, Mode=TwoWay}"> - <TextBlock Grid.Row="0" Grid.Column="0" ToolTip.Tip="S - Sign flag: Set if the 2-complement value is negative (copy of MSB)">S</TextBlock> - <TextBlock Grid.Row="0" Grid.Column="1" ToolTip.Tip="Z - Zero flag: Set if the value is zero">Z</TextBlock> - <TextBlock Grid.Row="0" Grid.Column="2" ToolTip.Tip="F5 - undocumented: Copy of bit 5">-</TextBlock> - <TextBlock Grid.Row="0" Grid.Column="3" ToolTip.Tip="H - Half Carry: Carry from bit 3 to bit 4">H</TextBlock> - <TextBlock Grid.Row="0" Grid.Column="4" ToolTip.Tip="F3 - undocumented: Copy of bit 3">-</TextBlock> - <TextBlock Grid.Row="0" Grid.Column="5" ToolTip.Tip="P/V - Parity or Overflow: Parity set if even number of bits set. Overflow set if the 2-complement result does not fit in the register">V</TextBlock> - <TextBlock Grid.Row="0" Grid.Column="6" ToolTip.Tip="N - Subtract: Set if the last operation was a subtraction">N</TextBlock> - <TextBlock Grid.Row="0" Grid.Column="7" ToolTip.Tip="C - Carry: Set if the result did not fit in the register">C</TextBlock> - <Border Grid.Column="0" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" - HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> - <TextBlock Text="{Binding Bit7Value,Mode=TwoWay}" Name="Bit7"/> - </Border> - <Border Grid.Column="1" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" - HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> - <TextBlock Text="{Binding Bit6Value,Mode=TwoWay}" Name="Bit6" /> - </Border> - <Border Grid.Column="2" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" - HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> - <TextBlock Text="{Binding Bit5Value}" Name="Bit5" /> - </Border> - <Border Grid.Column="3" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" - HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> - <TextBlock Text="{Binding bit4Value}" Name="Bit4" /> - </Border> - <Border Grid.Column="4" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" - HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> - <TextBlock Text="{Binding bit3Value}" Name="Bit3" /> - </Border> - <Border Grid.Column="5" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" - HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> - <TextBlock Text="{Binding bit2Value}" Name="Bit2" /> - </Border> - <Border Grid.Column="6" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" - HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> - <TextBlock Text="{Binding bit1Value}" Name="Bit1" /> - </Border> - <Border Grid.Column="7" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" - HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> - <TextBlock Text="{Binding bit0Value}" Name="Bit0" /> - </Border> + <UserControl.Styles> + </UserControl.Styles> + <Grid Grid.Row="1" RowDefinitions="50" VerticalAlignment="Stretch"> + <Panel Background="#FF606060"> + <Grid ColumnDefinitions="*,*,*,*,*,*,*,*" RowDefinitions="25,25" Name="gridFlags"> + <TextBlock Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="S - Sign flag: Set if the 2-complement value is negative (copy of MSB)">S</TextBlock> + <TextBlock Grid.Row="0" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="Z - Zero flag: Set if the value is zero">Z</TextBlock> + <TextBlock Grid.Row="0" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="F5 - undocumented: Copy of bit 5">-</TextBlock> + <TextBlock Grid.Row="0" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="H - Half Carry: Carry from bit 3 to bit 4">H</TextBlock> + <TextBlock Grid.Row="0" Grid.Column="4" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="F3 - undocumented: Copy of bit 3">-</TextBlock> + <TextBlock Grid.Row="0" Grid.Column="5" + HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="P/V - Parity or Overflow: Parity set if even number of bits set. Overflow set if the 2-complement result does not fit in the register"> + V + </TextBlock> + <TextBlock Grid.Row="0" Grid.Column="6" + HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="N - Subtract: Set if the last operation was a subtraction"> + N + </TextBlock> + <TextBlock Grid.Row="0" Grid.Column="7" + HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="C - Carry: Set if the result did not fit in the register"> + C + </TextBlock> + <Border Grid.Column="0" Grid.Row="1" BorderBrush="Black" BorderThickness="0,1,0,0"> + <TextBlock Name="Bit7" HorizontalAlignment="Center" VerticalAlignment="Center"/> + </Border> + <Border Grid.Column="1" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0"> + <TextBlock Name="Bit6" HorizontalAlignment="Center" VerticalAlignment="Center"/> + </Border> + <Border Grid.Column="2" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0"> + <TextBlock Name="Bit5" HorizontalAlignment="Center" VerticalAlignment="Center"/> + </Border> + <Border Grid.Column="3" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0"> + <TextBlock Name="Bit4" HorizontalAlignment="Center" VerticalAlignment="Center"/> + </Border> + <Border Grid.Column="4" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0"> + <TextBlock Name="Bit3" HorizontalAlignment="Center" VerticalAlignment="Center"/> + </Border> + <Border Grid.Column="5" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0"> + <TextBlock Name="Bit2" HorizontalAlignment="Center" VerticalAlignment="Center"/> + </Border> + <Border Grid.Column="6" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0"> + <TextBlock Name="Bit1" HorizontalAlignment="Center" VerticalAlignment="Center"/> + </Border> + <Border Grid.Column="7" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0"> + <TextBlock Name="Bit0" HorizontalAlignment="Center" VerticalAlignment="Center"/> + </Border> + </Grid> + </Panel> </Grid> - </Panel> -</UserControl> +</UserControl> \ No newline at end of file diff --git a/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml.cs b/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml.cs index 4eed2cc..39e5c10 100644 --- a/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml.cs +++ b/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml.cs @@ -1,5 +1,6 @@ +using System; +using System.Linq; using Avalonia.Controls; -using Avalonia.Markup.Xaml; namespace ZXBasicStudio.DebuggingTools.Flags.Controls { @@ -10,15 +11,42 @@ public ZXFlagsView() { InitializeComponent(); } - - public void Update() + + public void Update(byte value) { - + var bits = GetBinaryFromByte(value); + Bit7.Text = bits[7].ToString(); + Bit6.Text = bits[6].ToString(); + Bit5.Text = bits[5].ToString(); + Bit4.Text = bits[4].ToString(); + Bit3.Text = bits[3].ToString(); + Bit2.Text = bits[2].ToString(); + Bit1.Text = bits[1].ToString(); + Bit0.Text = bits[0].ToString(); } + + private static int[] GetBinaryFromByte(byte value) + { + string s = Convert.ToString(value, 2); + int[] bits = s.PadLeft(8, '0') + .Select(c => int.Parse(c.ToString())) + .ToArray(); + Array.Reverse(bits); + return bits; + } + public void Clear() { - + Bit7.Text = "-"; + Bit6.Text = "-"; + Bit5.Text = "-"; + Bit4.Text = "-"; + Bit3.Text = "-"; + Bit2.Text = "-"; + Bit1.Text = "-"; + Bit0.Text = "-"; + } } } diff --git a/ZXBStudio/MainWindow.axaml b/ZXBStudio/MainWindow.axaml index 95fcd56..997287f 100644 --- a/ZXBStudio/MainWindow.axaml +++ b/ZXBStudio/MainWindow.axaml @@ -191,7 +191,7 @@ <zxd:ZXCollapseButton CollapseDirection="Right" GridColumn="4" Grid.Column="3" Grid.Row="2"></zxd:ZXCollapseButton> <GridSplitter Classes="vertical" Grid.Column="3" Grid.Row="2" Grid.RowSpan="3" ResizeDirection="Columns"></GridSplitter> - <zxd:ZXDockingContainer Grid.Column="4" Grid.Row="2" RowDefinitions="*,4,0.3*,4,.3*,4,*" Grid.RowSpan="4" Name="dockRight"> + <zxd:ZXDockingContainer Grid.Column="4" Grid.Row="2" RowDefinitions="*,4,0.3*,4,0.3*,4,*" Grid.RowSpan="4" Name="dockRight"> <zxd:ZXDockingControl Grid.Row="0" Title="Variables" Name="varsDock"> <zxd:ZXDockingControl.DockedControl> diff --git a/ZXBStudio/MainWindow.axaml.cs b/ZXBStudio/MainWindow.axaml.cs index bfce33d..ff137dc 100644 --- a/ZXBStudio/MainWindow.axaml.cs +++ b/ZXBStudio/MainWindow.axaml.cs @@ -39,6 +39,7 @@ using System.Threading.Tasks; using ZXBasicStudio.BuildSystem; using ZXBasicStudio.Classes; +using ZXBasicStudio.Common; using ZXBasicStudio.Common.ZXSinclairBasic; using ZXBasicStudio.Controls; using ZXBasicStudio.Controls.DockSystem; @@ -1066,9 +1067,9 @@ private async void PauseEmulator(object? sender, Avalonia.Interactivity.RoutedEv ClearBreakLines(); currentBp = await ShowBreakLines(emu.Registers.PC, true); regView.Update(); + flagsView.Update(emu.Registers.F); varsView.BeginEdit(); statesView.Update(emu.TStates); - flagsView.Update(); } } private void ResumeEmulator(object? sender, Avalonia.Interactivity.RoutedEventArgs e) @@ -1179,9 +1180,9 @@ private async void AssemblerStepEmulator(object? sender, Avalonia.Interactivity. } regView.Update(); + flagsView.Update(emu.Registers.F); varsView.BeginEdit(); statesView.Update(emu.TStates); - flagsView.Update(); } private void Emu_ProgramReady(object? sender, EventArgs e) { @@ -1237,8 +1238,8 @@ private void Emu_Breakpoint(object? sender, BreakpointEventArgs e) currentBp = e.Breakpoint; varsView.BeginEdit(); regView.Update(); + flagsView.Update(emu.Registers.F); statesView.Update(emu.TStates); - flagsView.Update(); outLog.Writer.WriteLine($"Breakpoint: file {Path.GetFileName(line.File)}, line {line.LineNumber + 1}, address {line.Address}"); }); From 505836f92ab81c2425b4b26cc1af09f93d3a1e1b Mon Sep 17 00:00:00 2001 From: SirRickster <dbardaji@yahoo.es> Date: Thu, 9 Nov 2023 21:11:45 +0100 Subject: [PATCH 4/4] Add Flags Dock --- .../Flags/Controls/ZXFlagsView.axaml | 93 ++++++++++--------- .../Flags/Controls/ZXFlagsView.axaml.cs | 38 +++++++- ZXBStudio/MainWindow.axaml | 2 +- ZXBStudio/MainWindow.axaml.cs | 7 +- ZXBStudio/ZXBasicStudio.csproj | 10 ++ 5 files changed, 97 insertions(+), 53 deletions(-) diff --git a/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml b/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml index 80b93b4..50a2d39 100644 --- a/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml +++ b/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml @@ -4,48 +4,53 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="ZXBasicStudio.DebuggingTools.Flags.Controls.ZXFlagsView"> - <Panel Background="#FF606060"> - <Grid ColumnDefinitions="*,*,*,*,*,*,*,*" RowDefinitions="*,*" DataContext="{Binding ZXFlagsView, Mode=TwoWay}"> - <TextBlock Grid.Row="0" Grid.Column="0" ToolTip.Tip="S - Sign flag: Set if the 2-complement value is negative (copy of MSB)">S</TextBlock> - <TextBlock Grid.Row="0" Grid.Column="1" ToolTip.Tip="Z - Zero flag: Set if the value is zero">Z</TextBlock> - <TextBlock Grid.Row="0" Grid.Column="2" ToolTip.Tip="F5 - undocumented: Copy of bit 5">-</TextBlock> - <TextBlock Grid.Row="0" Grid.Column="3" ToolTip.Tip="H - Half Carry: Carry from bit 3 to bit 4">H</TextBlock> - <TextBlock Grid.Row="0" Grid.Column="4" ToolTip.Tip="F3 - undocumented: Copy of bit 3">-</TextBlock> - <TextBlock Grid.Row="0" Grid.Column="5" ToolTip.Tip="P/V - Parity or Overflow: Parity set if even number of bits set. Overflow set if the 2-complement result does not fit in the register">V</TextBlock> - <TextBlock Grid.Row="0" Grid.Column="6" ToolTip.Tip="N - Subtract: Set if the last operation was a subtraction">N</TextBlock> - <TextBlock Grid.Row="0" Grid.Column="7" ToolTip.Tip="C - Carry: Set if the result did not fit in the register">C</TextBlock> - <Border Grid.Column="0" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" - HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> - <TextBlock Text="{Binding Bit7Value,Mode=TwoWay}" Name="Bit7"/> - </Border> - <Border Grid.Column="1" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" - HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> - <TextBlock Text="{Binding Bit6Value,Mode=TwoWay}" Name="Bit6" /> - </Border> - <Border Grid.Column="2" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" - HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> - <TextBlock Text="{Binding Bit5Value}" Name="Bit5" /> - </Border> - <Border Grid.Column="3" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" - HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> - <TextBlock Text="{Binding bit4Value}" Name="Bit4" /> - </Border> - <Border Grid.Column="4" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" - HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> - <TextBlock Text="{Binding bit3Value}" Name="Bit3" /> - </Border> - <Border Grid.Column="5" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" - HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> - <TextBlock Text="{Binding bit2Value}" Name="Bit2" /> - </Border> - <Border Grid.Column="6" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" - HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> - <TextBlock Text="{Binding bit1Value}" Name="Bit1" /> - </Border> - <Border Grid.Column="7" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0" - HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> - <TextBlock Text="{Binding bit0Value}" Name="Bit0" /> - </Border> + <UserControl.Styles> + </UserControl.Styles> + <Grid Grid.Row="1" RowDefinitions="50" VerticalAlignment="Stretch"> + <Panel Background="#FF606060"> + <Grid ColumnDefinitions="*,*,*,*,*,*,*,*" RowDefinitions="25,25" Name="gridFlags"> + <TextBlock Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="S - Sign flag: Set if the 2-complement value is negative (copy of MSB)">S</TextBlock> + <TextBlock Grid.Row="0" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="Z - Zero flag: Set if the value is zero">Z</TextBlock> + <TextBlock Grid.Row="0" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="F5 - undocumented: Copy of bit 5">-</TextBlock> + <TextBlock Grid.Row="0" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="H - Half Carry: Carry from bit 3 to bit 4">H</TextBlock> + <TextBlock Grid.Row="0" Grid.Column="4" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="F3 - undocumented: Copy of bit 3">-</TextBlock> + <TextBlock Grid.Row="0" Grid.Column="5" + HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="P/V - Parity or Overflow: Parity set if even number of bits set. Overflow set if the 2-complement result does not fit in the register"> + V + </TextBlock> + <TextBlock Grid.Row="0" Grid.Column="6" + HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="N - Subtract: Set if the last operation was a subtraction"> + N + </TextBlock> + <TextBlock Grid.Row="0" Grid.Column="7" + HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="C - Carry: Set if the result did not fit in the register"> + C + </TextBlock> + <Border Grid.Column="0" Grid.Row="1" BorderBrush="Black" BorderThickness="0,1,0,0"> + <TextBlock Name="Bit7" HorizontalAlignment="Center" VerticalAlignment="Center"/> + </Border> + <Border Grid.Column="1" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0"> + <TextBlock Name="Bit6" HorizontalAlignment="Center" VerticalAlignment="Center"/> + </Border> + <Border Grid.Column="2" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0"> + <TextBlock Name="Bit5" HorizontalAlignment="Center" VerticalAlignment="Center"/> + </Border> + <Border Grid.Column="3" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0"> + <TextBlock Name="Bit4" HorizontalAlignment="Center" VerticalAlignment="Center"/> + </Border> + <Border Grid.Column="4" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0"> + <TextBlock Name="Bit3" HorizontalAlignment="Center" VerticalAlignment="Center"/> + </Border> + <Border Grid.Column="5" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0"> + <TextBlock Name="Bit2" HorizontalAlignment="Center" VerticalAlignment="Center"/> + </Border> + <Border Grid.Column="6" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0"> + <TextBlock Name="Bit1" HorizontalAlignment="Center" VerticalAlignment="Center"/> + </Border> + <Border Grid.Column="7" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0"> + <TextBlock Name="Bit0" HorizontalAlignment="Center" VerticalAlignment="Center"/> + </Border> + </Grid> + </Panel> </Grid> - </Panel> -</UserControl> +</UserControl> \ No newline at end of file diff --git a/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml.cs b/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml.cs index 4eed2cc..39e5c10 100644 --- a/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml.cs +++ b/ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml.cs @@ -1,5 +1,6 @@ +using System; +using System.Linq; using Avalonia.Controls; -using Avalonia.Markup.Xaml; namespace ZXBasicStudio.DebuggingTools.Flags.Controls { @@ -10,15 +11,42 @@ public ZXFlagsView() { InitializeComponent(); } - - public void Update() + + public void Update(byte value) { - + var bits = GetBinaryFromByte(value); + Bit7.Text = bits[7].ToString(); + Bit6.Text = bits[6].ToString(); + Bit5.Text = bits[5].ToString(); + Bit4.Text = bits[4].ToString(); + Bit3.Text = bits[3].ToString(); + Bit2.Text = bits[2].ToString(); + Bit1.Text = bits[1].ToString(); + Bit0.Text = bits[0].ToString(); } + + private static int[] GetBinaryFromByte(byte value) + { + string s = Convert.ToString(value, 2); + int[] bits = s.PadLeft(8, '0') + .Select(c => int.Parse(c.ToString())) + .ToArray(); + Array.Reverse(bits); + return bits; + } + public void Clear() { - + Bit7.Text = "-"; + Bit6.Text = "-"; + Bit5.Text = "-"; + Bit4.Text = "-"; + Bit3.Text = "-"; + Bit2.Text = "-"; + Bit1.Text = "-"; + Bit0.Text = "-"; + } } } diff --git a/ZXBStudio/MainWindow.axaml b/ZXBStudio/MainWindow.axaml index 95fcd56..997287f 100644 --- a/ZXBStudio/MainWindow.axaml +++ b/ZXBStudio/MainWindow.axaml @@ -191,7 +191,7 @@ <zxd:ZXCollapseButton CollapseDirection="Right" GridColumn="4" Grid.Column="3" Grid.Row="2"></zxd:ZXCollapseButton> <GridSplitter Classes="vertical" Grid.Column="3" Grid.Row="2" Grid.RowSpan="3" ResizeDirection="Columns"></GridSplitter> - <zxd:ZXDockingContainer Grid.Column="4" Grid.Row="2" RowDefinitions="*,4,0.3*,4,.3*,4,*" Grid.RowSpan="4" Name="dockRight"> + <zxd:ZXDockingContainer Grid.Column="4" Grid.Row="2" RowDefinitions="*,4,0.3*,4,0.3*,4,*" Grid.RowSpan="4" Name="dockRight"> <zxd:ZXDockingControl Grid.Row="0" Title="Variables" Name="varsDock"> <zxd:ZXDockingControl.DockedControl> diff --git a/ZXBStudio/MainWindow.axaml.cs b/ZXBStudio/MainWindow.axaml.cs index bfce33d..ff137dc 100644 --- a/ZXBStudio/MainWindow.axaml.cs +++ b/ZXBStudio/MainWindow.axaml.cs @@ -39,6 +39,7 @@ using System.Threading.Tasks; using ZXBasicStudio.BuildSystem; using ZXBasicStudio.Classes; +using ZXBasicStudio.Common; using ZXBasicStudio.Common.ZXSinclairBasic; using ZXBasicStudio.Controls; using ZXBasicStudio.Controls.DockSystem; @@ -1066,9 +1067,9 @@ private async void PauseEmulator(object? sender, Avalonia.Interactivity.RoutedEv ClearBreakLines(); currentBp = await ShowBreakLines(emu.Registers.PC, true); regView.Update(); + flagsView.Update(emu.Registers.F); varsView.BeginEdit(); statesView.Update(emu.TStates); - flagsView.Update(); } } private void ResumeEmulator(object? sender, Avalonia.Interactivity.RoutedEventArgs e) @@ -1179,9 +1180,9 @@ private async void AssemblerStepEmulator(object? sender, Avalonia.Interactivity. } regView.Update(); + flagsView.Update(emu.Registers.F); varsView.BeginEdit(); statesView.Update(emu.TStates); - flagsView.Update(); } private void Emu_ProgramReady(object? sender, EventArgs e) { @@ -1237,8 +1238,8 @@ private void Emu_Breakpoint(object? sender, BreakpointEventArgs e) currentBp = e.Breakpoint; varsView.BeginEdit(); regView.Update(); + flagsView.Update(emu.Registers.F); statesView.Update(emu.TStates); - flagsView.Update(); outLog.Writer.WriteLine($"Breakpoint: file {Path.GetFileName(line.File)}, line {line.LineNumber + 1}, address {line.Address}"); }); diff --git a/ZXBStudio/ZXBasicStudio.csproj b/ZXBStudio/ZXBasicStudio.csproj index 908d45c..1b4f089 100644 --- a/ZXBStudio/ZXBasicStudio.csproj +++ b/ZXBStudio/ZXBasicStudio.csproj @@ -15,6 +15,16 @@ <AssemblyVersion>1.0.*</AssemblyVersion> <Deterministic>False</Deterministic> </PropertyGroup> + <ItemGroup> + <AvaloniaXaml Remove="LanguageDefinitions\**" /> + <Compile Remove="LanguageDefinitions\**" /> + <EmbeddedResource Remove="LanguageDefinitions\**" /> + <None Remove="LanguageDefinitions\**" /> + <Compile Update="DebuggingTools\Flags\Controls\ZXFlagsView.axaml.cs"> + <DependentUpon>ZXFlagsView.axaml</DependentUpon> + <SubType>Code</SubType> + </Compile> + </ItemGroup> <ItemGroup> <AvaloniaXaml Remove="Controls\ZXLocalVariablesView.axaml" /> <AvaloniaXaml Remove="Controls\ZXVariableView.axaml" />