diff options
-rw-r--r-- | WPZX81/WPZX81/DisassemblerPage.xaml | 138 | ||||
-rw-r--r-- | WPZX81/WPZX81/DisassemblerPage.xaml.cs | 3 | ||||
-rw-r--r-- | WPZX81/WPZX81/ViewModels/BaseViewModel.cs (renamed from WPZX81/WPZX81/BaseViewModel.cs) | 2 | ||||
-rw-r--r-- | WPZX81/WPZX81/ViewModels/DisassemblerLine.cs (renamed from WPZX81/WPZX81/DisassemblerLine.cs) | 2 | ||||
-rw-r--r-- | WPZX81/WPZX81/ViewModels/DisassemblerViewModel.cs (renamed from WPZX81/WPZX81/DisassemblerViewModel.cs) | 43 | ||||
-rw-r--r-- | WPZX81/WPZX81/WPZX81.csproj | 10 | ||||
-rw-r--r-- | WPZX81/WPZX81/ZX81/Emulation.cs | 3 |
7 files changed, 123 insertions, 78 deletions
diff --git a/WPZX81/WPZX81/DisassemblerPage.xaml b/WPZX81/WPZX81/DisassemblerPage.xaml index 3c87af6..16d7e53 100644 --- a/WPZX81/WPZX81/DisassemblerPage.xaml +++ b/WPZX81/WPZX81/DisassemblerPage.xaml @@ -7,6 +7,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:res="clr-namespace:WPZX81.Resources"
+ xmlns:conv="clr-namespace:WPZX81.Converters"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
@@ -16,31 +17,49 @@ <phone:PhoneApplicationPage.Resources>
<res:Strings x:Key="Strings" />
+ <conv:ConvertFlagsToString x:Key="ConvertFlagsToString" />
+ <conv:ConvertIntToHex2 x:Key="ConvertIntToHex2" />
+ <conv:ConvertIntToHex4 x:Key="ConvertIntToHex4" />
+
<Style x:Name="StateInfo" TargetType="TextBlock">
<Setter Property="FontSize" Value="18" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="Foreground" Value="White" />
+ <Setter Property="HorizontalAlignment" Value="Center" />
</Style>
<Style x:Name="StateData" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Courier New" />
<Setter Property="FontSize" Value="18" />
<Setter Property="FontWeight" Value="Normal" />
- <Setter Property="Foreground" Value="White" />
+ <Setter Property="Foreground" Value="LightGray" />
+ <Setter Property="HorizontalAlignment" Value="Center" />
</Style>
<Style x:Name="DisassemMemory" TargetType="TextBlock">
<Setter Property="FontFamily" Value="Courier New" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="Foreground" Value="Yellow" />
+ <Setter Property="FontSize" Value="18" />
+ <Setter Property="HorizontalAlignment" Value="Left" />
</Style>
<Style x:Name="DisassemOpcode" TargetType="TextBlock">
- <Setter Property="FontFamily" Value="Courier New" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="Foreground" Value="White" />
+ <Setter Property="FontFamily" Value="Courier New" />
+ <Setter Property="FontSize" Value="18" />
+ <Setter Property="HorizontalAlignment" Value="Left" />
</Style>
<Style x:Name="DisassemHexdump" TargetType="TextBlock">
- <Setter Property="FontFamily" Value="Courier New" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="Foreground" Value="Red" />
+ <Setter Property="FontFamily" Value="Courier New" />
+ <Setter Property="FontSize" Value="18" />
+ <Setter Property="HorizontalAlignment" Value="Left" />
+ </Style>
+ <Style x:Name="ButtonText" TargetType="TextBlock">
+ <Setter Property="FontWeight" Value="Normal" />
+ <Setter Property="FontSize" Value="18" />
+ <Setter Property="HorizontalAlignment" Value="Center" />
+ <Setter Property="TextWrapping" Value="Wrap" />
</Style>
</phone:PhoneApplicationPage.Resources>
@@ -69,13 +88,9 @@ <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="1*" />
- <ColumnDefinition Width="1*" />
- </Grid.ColumnDefinitions>
<!-- Z80 State -->
- <Grid Grid.Row="0" Grid.ColumnSpan="2">
+ <Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
@@ -108,28 +123,24 @@ Grid.Row="0" Grid.Column="6" />
<TextBlock Style="{StaticResource StateData}"
- Text="{Binding A, Mode=OneWay}"
+ Text="{Binding A, Mode=OneWay, Converter={StaticResource ConvertIntToHex2}}"
Grid.Row="1" Grid.Column="0"/>
<TextBlock Style="{StaticResource StateData}"
- Text="{Binding Flags, Mode=OneWay}"
+ Text="{Binding Flags, Mode=OneWay, Converter={StaticResource ConvertFlagsToString}}"
Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"/>
<TextBlock Style="{StaticResource StateData}"
- Text="{Binding BC, Mode=OneWay}"
+ Text="{Binding BC, Mode=OneWay, Converter={StaticResource ConvertIntToHex4}}"
Grid.Row="1" Grid.Column="3"/>
<TextBlock Style="{StaticResource StateData}"
- Text="{Binding DE, Mode=OneWay}"
+ Text="{Binding DE, Mode=OneWay, Converter={StaticResource ConvertIntToHex4}}"
Grid.Row="1" Grid.Column="4"/>
<TextBlock Style="{StaticResource StateData}"
- Text="{Binding HL, Mode=OneWay}"
+ Text="{Binding HL, Mode=OneWay, Converter={StaticResource ConvertIntToHex4}}"
Grid.Row="1" Grid.Column="5"/>
<TextBlock Style="{StaticResource StateData}"
- Text="{Binding PC, Mode=OneWay}"
+ Text="{Binding PC, Mode=OneWay, Converter={StaticResource ConvertIntToHex4}}"
Grid.Row="1" Grid.Column="6"/>
- <TextBlock Style="{StaticResource StateInfo}" Text="IY"
- Grid.Row="0" Grid.Column="6" />
-
-
<TextBlock Style="{StaticResource StateInfo}" Text="IX"
Grid.Row="2" Grid.Column="0" />
<TextBlock Style="{StaticResource StateInfo}" Text="IY"
@@ -146,25 +157,25 @@ Grid.Row="2" Grid.Column="6" />
<TextBlock Style="{StaticResource StateData}"
- Text="{Binding IY, Mode=OneWay}"
+ Text="{Binding IY, Mode=OneWay, Converter={StaticResource ConvertIntToHex4}}"
Grid.Row="3" Grid.Column="0"/>
<TextBlock Style="{StaticResource StateData}"
- Text="{Binding IY, Mode=OneWay}"
+ Text="{Binding IY, Mode=OneWay, Converter={StaticResource ConvertIntToHex4}}"
Grid.Row="3" Grid.Column="1"/>
<TextBlock Style="{StaticResource StateData}"
- Text="{Binding SP, Mode=OneWay}"
+ Text="{Binding SP, Mode=OneWay, Converter={StaticResource ConvertIntToHex4}}"
Grid.Row="3" Grid.Column="2"/>
<TextBlock Style="{StaticResource StateData}"
- Text="{Binding AF_, Mode=OneWay}"
+ Text="{Binding AF_, Mode=OneWay, Converter={StaticResource ConvertIntToHex4}}"
Grid.Row="3" Grid.Column="3"/>
<TextBlock Style="{StaticResource StateData}"
- Text="{Binding BC_, Mode=OneWay}"
+ Text="{Binding BC_, Mode=OneWay, Converter={StaticResource ConvertIntToHex4}}"
Grid.Row="3" Grid.Column="4"/>
<TextBlock Style="{StaticResource StateData}"
- Text="{Binding DE_, Mode=OneWay}"
+ Text="{Binding DE_, Mode=OneWay, Converter={StaticResource ConvertIntToHex4}}"
Grid.Row="3" Grid.Column="5"/>
<TextBlock Style="{StaticResource StateData}"
- Text="{Binding HL_, Mode=OneWay}"
+ Text="{Binding HL_, Mode=OneWay, Converter={StaticResource ConvertIntToHex4}}"
Grid.Row="3" Grid.Column="6"/>
<TextBlock Style="{StaticResource StateInfo}" Text="IM"
@@ -177,17 +188,17 @@ Grid.Row="4" Grid.Column="3" />
<TextBlock Style="{StaticResource StateInfo}" Text="IFF2"
Grid.Row="4" Grid.Column="4" />
- <TextBlock Style="{StaticResource StateInfo}" Text="Executed Instructions"
+ <TextBlock Style="{StaticResource StateInfo}" Text="Opcodes"
Grid.Row="4" Grid.Column="5" Grid.ColumnSpan="2"/>
<TextBlock Style="{StaticResource StateData}"
- Text="{Binding IM, Mode=OneWay}"
+ Text="{Binding IM, Mode=OneWay, Converter={StaticResource ConvertIntToHex2}}"
Grid.Row="5" Grid.Column="0"/>
<TextBlock Style="{StaticResource StateData}"
- Text="{Binding I, Mode=OneWay}"
+ Text="{Binding I, Mode=OneWay, Converter={StaticResource ConvertIntToHex2}}"
Grid.Row="5" Grid.Column="1"/>
<TextBlock Style="{StaticResource StateData}"
- Text="{Binding R, Mode=OneWay}"
+ Text="{Binding R, Mode=OneWay, Converter={StaticResource ConvertIntToHex2}}"
Grid.Row="5" Grid.Column="2"/>
<TextBlock Style="{StaticResource StateData}"
Text="{Binding IFF1, Mode=OneWay}"
@@ -202,24 +213,61 @@ </Grid>
<!-- Disassembly -->
- <ListBox x:Name="AsmDisplay" Grid.ColumnSpan="2" Grid.Row="1"
+ <ListBox Grid.Row="1"
ItemsSource="{Binding Disassembly, Mode=OneWay}"
- VerticalAlignment="Top"
- FontFamily="Courier New"/>
+ VerticalAlignment="Top" BorderThickness="2"
+ BorderBrush="DarkBlue" >
+ <ListBox.ItemTemplate>
+ <DataTemplate>
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="100" />
+ <ColumnDefinition Width="200" />
+ <ColumnDefinition Width="*" />
+ </Grid.ColumnDefinitions>
+ <TextBlock Text="{Binding Path=Address}"
+ Grid.Column="0"
+ Style="{StaticResource DisassemMemory}" />
+ <TextBlock Text="{Binding Path=Opcode}"
+ Grid.Column="1"
+ Style="{StaticResource DisassemOpcode}" />
+ <TextBlock Text="{Binding Path=Hexdump}"
+ Grid.Column="2"
+ Style="{StaticResource DisassemHexdump}" />
+ </Grid>
+ </DataTemplate>
+ </ListBox.ItemTemplate>
+ </ListBox>
- <!-- Step -->
- <Button Height="100"
- Content="{Binding DisassemblerStepButtonText, Source={StaticResource Strings}}"
- Grid.Row="2" Grid.Column="0"
- FontSize="18"
- Click="StepClick" />
-
- <!-- Run Frame -->
- <Button Height="100"
- Content="{Binding DisassemblerRunFrameButtonText, Source={StaticResource Strings}}"
- Grid.Row="2" Grid.Column="1"
- FontSize="18"
- Click="RunClick" />
+ <Grid Grid.Row="2">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="1*" />
+ <ColumnDefinition Width="1*" />
+ <ColumnDefinition Width="1*" />
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="3*" />
+ <RowDefinition Height="1*" />
+ </Grid.RowDefinitions>
+ <!-- Step -->
+ <Button Grid.Column="0" Grid.RowSpan="2" Click="StepClick">
+ <TextBlock Text="{Binding DisassemblerStepButtonText, Source={StaticResource Strings}}"
+ Style="{StaticResource ButtonText}" />
+ </Button>
+
+ <Slider Minimum="1" Maximum="1000" Grid.Column="1" Grid.Row="0"
+ Value="{Binding Steps, Mode=TwoWay}"/>
+
+ <TextBlock Grid.Column="1" Grid.Row="1"
+ Text="{Binding Steps, Mode=OneWay}"
+ HorizontalAlignment="Center"/>
+
+ <!-- Run Frame -->
+ <Button Grid.Column="3" Grid.RowSpan="2" Click="RunClick">
+ <TextBlock Text="{Binding DisassemblerRunFrameButtonText, Source={StaticResource Strings}}"
+ Style="{StaticResource ButtonText}" />
+ </Button>
+ </Grid>
</Grid>
</Grid>
diff --git a/WPZX81/WPZX81/DisassemblerPage.xaml.cs b/WPZX81/WPZX81/DisassemblerPage.xaml.cs index f5b1aa5..63717bb 100644 --- a/WPZX81/WPZX81/DisassemblerPage.xaml.cs +++ b/WPZX81/WPZX81/DisassemblerPage.xaml.cs @@ -1,6 +1,6 @@ using System;
-using System.ComponentModel;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Windows;
@@ -11,6 +11,7 @@ using System.Windows.Media; using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
+using WPZX81.ViewModels;
namespace WPZX81
{
diff --git a/WPZX81/WPZX81/BaseViewModel.cs b/WPZX81/WPZX81/ViewModels/BaseViewModel.cs index ae729e6..6a96d0b 100644 --- a/WPZX81/WPZX81/BaseViewModel.cs +++ b/WPZX81/WPZX81/ViewModels/BaseViewModel.cs @@ -10,7 +10,7 @@ using System.Windows.Media; using System.Windows.Media.Animation;
using System.Windows.Shapes;
-namespace WPZX81
+namespace WPZX81.ViewModels
{
/// <summary>
/// Provides a base for view models.
diff --git a/WPZX81/WPZX81/DisassemblerLine.cs b/WPZX81/WPZX81/ViewModels/DisassemblerLine.cs index 6618fc1..f493b85 100644 --- a/WPZX81/WPZX81/DisassemblerLine.cs +++ b/WPZX81/WPZX81/ViewModels/DisassemblerLine.cs @@ -9,7 +9,7 @@ using System.Windows.Media; using System.Windows.Media.Animation;
using System.Windows.Shapes;
-namespace WPZX81
+namespace WPZX81.ViewModels
{
/// <summary>
/// Represents a line of disassembly.
diff --git a/WPZX81/WPZX81/DisassemblerViewModel.cs b/WPZX81/WPZX81/ViewModels/DisassemblerViewModel.cs index b0ff2f7..cbf5dbb 100644 --- a/WPZX81/WPZX81/DisassemblerViewModel.cs +++ b/WPZX81/WPZX81/ViewModels/DisassemblerViewModel.cs @@ -11,7 +11,7 @@ using System.Windows.Shapes; using Noddybox.Emulation.EightBit.Z80;
using System.Collections.Generic;
-namespace WPZX81
+namespace WPZX81.ViewModels
{
/// <summary>
/// Implements a view model for the diassembler page.
@@ -22,7 +22,7 @@ namespace WPZX81 private Z80Cpu z80;
private int a;
- private string flags;
+ private Z80Flags flags;
private int bc;
private int de;
private int hl;
@@ -40,6 +40,7 @@ namespace WPZX81 private string iff1;
private string iff2;
private uint executedInstructions;
+ private int steps;
#endregion
@@ -50,6 +51,7 @@ namespace WPZX81 Z80Cpu z80 = Shared.ZX81.Z80;
A = z80.Acummulator;
+ Flags = z80.StatusFlags;
BC = z80.BC_Register.reg;
DE = z80.DE_Register.reg;
HL = z80.HL_Register.reg;
@@ -64,26 +66,8 @@ namespace WPZX81 ExecutedInstructions = z80.ExecutedInstructions;
I = z80.InterruptVector;
R = z80.Refresh;
- IFF1 = z80.IFF1_Register ? "ON":"OFF";
- IFF2 = z80.IFF2_Register ? "ON":"OFF";
-
- char[] names = new char[8] {'C', 'N', 'P', '3', 'H', '5', 'Z', 'S'};
- char[] flags = new char[8];
- int f;
-
- for(f = 0; f < 8; f++)
- {
- if (((int)z80.StatusFlags & (1 << f)) == (1 << f))
- {
- flags[7-f] = names[7-f];
- }
- else
- {
- flags[7-f] = '-';
- }
- }
-
- Flags = new String(flags);
+ IFF1 = z80.IFF1_Register ? "On":"Off";
+ IFF2 = z80.IFF2_Register ? "On":"Off";
}
#endregion
@@ -96,7 +80,7 @@ namespace WPZX81 set {SetValue(ref a, value, "A");}
}
- public string Flags
+ public Z80Flags Flags
{
get {return flags;}
set {SetValue(ref flags, value, "Flags");}
@@ -222,6 +206,12 @@ namespace WPZX81 }
}
+ public int Steps
+ {
+ get {return steps;}
+ set {SetValue(ref steps, value, "Steps");}
+ }
+
#endregion
#region Public methods
@@ -231,7 +221,11 @@ namespace WPZX81 /// </summary>
public void Step()
{
- Shared.ZX81.Step();
+ for(int f = 0; f < steps; f++)
+ {
+ Shared.ZX81.Step();
+ }
+
Update();
}
@@ -250,6 +244,7 @@ namespace WPZX81 public DisassemblerViewModel()
{
+ Steps = 1;
Update();
}
diff --git a/WPZX81/WPZX81/WPZX81.csproj b/WPZX81/WPZX81/WPZX81.csproj index 9c8122c..40b1311 100644 --- a/WPZX81/WPZX81/WPZX81.csproj +++ b/WPZX81/WPZX81/WPZX81.csproj @@ -69,12 +69,12 @@ <Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
- <Compile Include="BaseViewModel.cs" />
- <Compile Include="DisassemblerLine.cs" />
+ <Compile Include="Converters\ConvertFlagsToString.cs" />
+ <Compile Include="Converters\ConvertIntToHex2.cs" />
+ <Compile Include="Converters\ConvertIntToHex4.cs" />
<Compile Include="DisassemblerPage.xaml.cs">
<DependentUpon>DisassemblerPage.xaml</DependentUpon>
</Compile>
- <Compile Include="DisassemblerViewModel.cs" />
<Compile Include="GamePage.xaml.cs">
<DependentUpon>GamePage.xaml</DependentUpon>
</Compile>
@@ -93,6 +93,9 @@ <DependentUpon>SettingsPage.xaml</DependentUpon>
</Compile>
<Compile Include="Shared.cs" />
+ <Compile Include="ViewModels\BaseViewModel.cs" />
+ <Compile Include="ViewModels\DisassemblerLine.cs" />
+ <Compile Include="ViewModels\DisassemblerViewModel.cs" />
<Compile Include="ZX81\Emulation.cs" />
</ItemGroup>
<ItemGroup>
@@ -162,6 +165,7 @@ <LastGenOutput>Strings.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
+ <ItemGroup />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
diff --git a/WPZX81/WPZX81/ZX81/Emulation.cs b/WPZX81/WPZX81/ZX81/Emulation.cs index d328e72..0f56e4b 100644 --- a/WPZX81/WPZX81/ZX81/Emulation.cs +++ b/WPZX81/WPZX81/ZX81/Emulation.cs @@ -345,8 +345,6 @@ namespace WPZX81.ZX81 {
Stopwatch s = Stopwatch.StartNew();
- Z80.ExecutedInstructions = 0;
-
if (fast)
{
clock.StartFrame();
@@ -380,7 +378,6 @@ namespace WPZX81.ZX81 if (clock.FrameDone)
{
clock.StartFrame();
- Z80.ExecutedInstructions = 0;
Z80.MaskableInterrupt(0);
if (Z80.StackPointer < 0x8000)
|