From 7a79ba9eb1e7cbee6386d8c8e019fdc4738228a4 Mon Sep 17 00:00:00 2001 From: Ian C <ianc@noddybox.co.uk> Date: Mon, 5 Mar 2012 23:55:51 +0000 Subject: None compiling safe-keeping commit. Started on Z80 disassembler. --- ...ybox.Emulation.EightBit.Z80.Disassembler.csproj | 66 ++++++++++++++++++++++ .../Properties/AssemblyInfo.cs | 36 ++++++++++++ .../Noddybox.Emulation.EightBit.Z80.Test.csproj | 4 ++ native/Noddybox.Emulation.EightBit.Z80.Test/README | 2 +- .../TestMachine.cs | 21 ++++++- .../Noddybox.Emulation.EightBit.csproj | 3 + 6 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 native/Noddybox.Emulation.EightBit.Z80.Disassembler/Noddybox.Emulation.EightBit.Z80.Disassembler.csproj create mode 100644 native/Noddybox.Emulation.EightBit.Z80.Disassembler/Properties/AssemblyInfo.cs (limited to 'native') diff --git a/native/Noddybox.Emulation.EightBit.Z80.Disassembler/Noddybox.Emulation.EightBit.Z80.Disassembler.csproj b/native/Noddybox.Emulation.EightBit.Z80.Disassembler/Noddybox.Emulation.EightBit.Z80.Disassembler.csproj new file mode 100644 index 0000000..c31f7ea --- /dev/null +++ b/native/Noddybox.Emulation.EightBit.Z80.Disassembler/Noddybox.Emulation.EightBit.Z80.Disassembler.csproj @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.30703</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{80CF1B2D-CCC3-4830-801F-2CCA9C1EDA1C}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Noddybox.Emulation.EightBit.Z80.Disassembler</RootNamespace> + <AssemblyName>Noddybox.Emulation.EightBit.Z80.Disassembler</AssemblyName> + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="..\..\src\Noddybox.Emulation.EightBit.Z80.Disassembler\Z80Disassembler.cs"> + <Link>Z80Disassembler.cs</Link> + </Compile> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\Noddybox.Emulation.EightBit\Noddybox.Emulation.EightBit.csproj"> + <Project>{C40AC553-8D22-4C04-8F2F-58D9A0EBD119}</Project> + <Name>Noddybox.Emulation.EightBit</Name> + </ProjectReference> + <ProjectReference Include="..\Noddybox.Emulation\Noddybox.Emulation.csproj"> + <Project>{1817A6AA-8E7A-424D-9741-934CD00A5D30}</Project> + <Name>Noddybox.Emulation</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file diff --git a/native/Noddybox.Emulation.EightBit.Z80.Disassembler/Properties/AssemblyInfo.cs b/native/Noddybox.Emulation.EightBit.Z80.Disassembler/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d6f3800 --- /dev/null +++ b/native/Noddybox.Emulation.EightBit.Z80.Disassembler/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Noddybox.Emulation.EightBit.Z80.Disassembler")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Noddybox.Emulation.EightBit.Z80.Disassembler")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c6fa059b-9603-4598-83dc-0e2cd55df466")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/native/Noddybox.Emulation.EightBit.Z80.Test/Noddybox.Emulation.EightBit.Z80.Test.csproj b/native/Noddybox.Emulation.EightBit.Z80.Test/Noddybox.Emulation.EightBit.Z80.Test.csproj index a162641..fe563c6 100644 --- a/native/Noddybox.Emulation.EightBit.Z80.Test/Noddybox.Emulation.EightBit.Z80.Test.csproj +++ b/native/Noddybox.Emulation.EightBit.Z80.Test/Noddybox.Emulation.EightBit.Z80.Test.csproj @@ -48,6 +48,10 @@ <Compile Include="TestMachine.cs" /> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\Noddybox.Emulation.EightBit.Z80.Disassembler\Noddybox.Emulation.EightBit.Z80.Disassembler.csproj"> + <Project>{80CF1B2D-CCC3-4830-801F-2CCA9C1EDA1C}</Project> + <Name>Noddybox.Emulation.EightBit.Z80.Disassembler</Name> + </ProjectReference> <ProjectReference Include="..\Noddybox.Emulation.EightBit.Z80\Noddybox.Emulation.EightBit.Z80.csproj"> <Project>{1E0BEBC1-AB7A-4844-AC1E-B1A0239B63CF}</Project> <Name>Noddybox.Emulation.EightBit.Z80</Name> diff --git a/native/Noddybox.Emulation.EightBit.Z80.Test/README b/native/Noddybox.Emulation.EightBit.Z80.Test/README index d260441..bd0321f 100644 --- a/native/Noddybox.Emulation.EightBit.Z80.Test/README +++ b/native/Noddybox.Emulation.EightBit.Z80.Test/README @@ -3,7 +3,7 @@ THESE TESTS ARE BASED ON THE TESTS FROM THE FUSE EMULATOR http://fuse-emulator.sourceforge.net/ -ANY MISTAKES ARE MINE +ANY MISTAKES IN USING IT ARE MINE ************************************* diff --git a/native/Noddybox.Emulation.EightBit.Z80.Test/TestMachine.cs b/native/Noddybox.Emulation.EightBit.Z80.Test/TestMachine.cs index b5d7810..a876826 100644 --- a/native/Noddybox.Emulation.EightBit.Z80.Test/TestMachine.cs +++ b/native/Noddybox.Emulation.EightBit.Z80.Test/TestMachine.cs @@ -19,6 +19,8 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Diagnostics; +using Noddybox.Emulation.EightBit.Z80.Disassembler; namespace Noddybox.Emulation.EightBit.Z80.Test { @@ -26,6 +28,7 @@ namespace Noddybox.Emulation.EightBit.Z80.Test { private readonly byte[] mem = new byte[0x10000]; private readonly Z80Cpu z80 = new Z80Cpu(); + private readonly Z80Disassembler disassembler = new Z80Disassembler(); private readonly Clock clock = new Clock(uint.MaxValue, uint.MaxValue); private void Output(ConsoleColor pen, ConsoleColor paper, string format, params object[] p) @@ -115,16 +118,30 @@ namespace Noddybox.Emulation.EightBit.Z80.Test if (line.Count > 1) { + ushort start; ushort addr = line.Dequeue().reg; + start = addr; foreach (Register16 b in line) { mem[addr++] = b.low; } + + while(start < addr) + { + string a, b, c; + start = disassembler.Disassemble(start, out a, out b, out c); + Output(ConsoleColor.Yellow, ConsoleColor.Blue, "{0}: {1} ; {2}", a, b, c); + } } } - while(clock.Ticks < cyclesToRun) + if (Debugger.IsAttached && name == "09") + { + Debugger.Break(); + } + + while (clock.Ticks < cyclesToRun) { z80.Step(); } @@ -318,6 +335,8 @@ namespace Noddybox.Emulation.EightBit.Z80.Test public TestMachine() { z80.Initialise(this, this, clock); + z80.Reset(); + disassembler.Initialise(this); } } } diff --git a/native/Noddybox.Emulation.EightBit/Noddybox.Emulation.EightBit.csproj b/native/Noddybox.Emulation.EightBit/Noddybox.Emulation.EightBit.csproj index 2d81cf6..5b385fc 100644 --- a/native/Noddybox.Emulation.EightBit/Noddybox.Emulation.EightBit.csproj +++ b/native/Noddybox.Emulation.EightBit/Noddybox.Emulation.EightBit.csproj @@ -49,6 +49,9 @@ <Compile Include="..\..\src\Noddybox.Emulation.EightBit\IDevice.cs"> <Link>IDevice.cs</Link> </Compile> + <Compile Include="..\..\src\Noddybox.Emulation.EightBit\IDisassembler.cs"> + <Link>IDisassembler.cs</Link> + </Compile> <Compile Include="..\..\src\Noddybox.Emulation.EightBit\IMemory.cs"> <Link>IMemory.cs</Link> </Compile> -- cgit v1.2.3