summaryrefslogtreecommitdiff
path: root/native
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2012-03-09 23:01:13 +0000
committerIan C <ianc@noddybox.co.uk>2012-03-09 23:01:13 +0000
commit998b64d14c9d055562d8c1611813d40af4cb030b (patch)
treeecb3402a5c7302d86c5a364308b6d0b173e00e5c /native
parent31203bc854656ff92844364903de9abee9daea8b (diff)
Further bug fixes to Z80. Now starts the Spectrum ROM OK.
Diffstat (limited to 'native')
-rw-r--r--native/Noddybox.Emulation.EightBit.Z80.Test/Program.cs44
-rw-r--r--native/Noddybox.Emulation.EightBit.Z80.Test/TestMachine.cs19
-rw-r--r--native/Noddybox.Emulation/Noddybox.Emulation.csproj3
3 files changed, 52 insertions, 14 deletions
diff --git a/native/Noddybox.Emulation.EightBit.Z80.Test/Program.cs b/native/Noddybox.Emulation.EightBit.Z80.Test/Program.cs
index 43dab10..cad9031 100644
--- a/native/Noddybox.Emulation.EightBit.Z80.Test/Program.cs
+++ b/native/Noddybox.Emulation.EightBit.Z80.Test/Program.cs
@@ -20,6 +20,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
+using System.Diagnostics;
namespace Noddybox.Emulation.EightBit.Z80.Test
{
@@ -60,6 +61,26 @@ namespace Noddybox.Emulation.EightBit.Z80.Test
return q;
}
+ static bool Run(Queue<string> test, Queue<string> expected, bool stop)
+ {
+ bool ok = true;
+
+ if (test.Peek() != expected.Peek())
+ {
+ throw new Exception(String.Format("Test name {0}, expected name {1}", test.Peek(), expected.Peek()));
+ }
+
+ TestMachine m = new TestMachine();
+ expected.Dequeue();
+
+ if (!m.Run(test.Dequeue(), test, expected, stop))
+ {
+ ok = false;
+ }
+
+ return ok;
+ }
+
static void Main(string[] args)
{
try
@@ -74,17 +95,22 @@ namespace Noddybox.Emulation.EightBit.Z80.Test
if (t.Count > 0)
{
- if (t.Peek() != e.Peek())
- {
- throw new Exception(String.Format("Test name {0}, expected name {1}", t.Peek(), e.Peek()));
- }
-
- TestMachine m = new TestMachine();
- e.Dequeue();
+ Queue<string> t2 = new Queue<string>(t);
+ Queue<string> e2 = new Queue<string>(t);
- if (!m.Run(t.Dequeue(), t, e))
+ if (!Run(t, e, false))
{
- Console.ReadKey(true);
+ if (!Debugger.IsAttached)
+ {
+ if (Console.ReadKey(true).Key == ConsoleKey.Q)
+ {
+ return;
+ }
+ }
+ else
+ {
+ Run(t2, e2, true);
+ }
}
}
}
diff --git a/native/Noddybox.Emulation.EightBit.Z80.Test/TestMachine.cs b/native/Noddybox.Emulation.EightBit.Z80.Test/TestMachine.cs
index d21e810..8483050 100644
--- a/native/Noddybox.Emulation.EightBit.Z80.Test/TestMachine.cs
+++ b/native/Noddybox.Emulation.EightBit.Z80.Test/TestMachine.cs
@@ -35,8 +35,9 @@ namespace Noddybox.Emulation.EightBit.Z80.Test
{
Console.ForegroundColor = pen;
Console.BackgroundColor = paper;
- Console.WriteLine(format, p);
+ Console.Write(format, p);
Console.ResetColor();
+ Console.WriteLine();
}
private Queue<Register16> Decode(string i)
@@ -69,7 +70,10 @@ namespace Noddybox.Emulation.EightBit.Z80.Test
byte IDevice.Read(ushort device)
{
// Output(ConsoleColor.Green, ConsoleColor.DarkGray, "Reading 00 from device {1:X4}", device);
- return 0;
+
+ Register16 r = new Register16(device);
+
+ return r.high;
}
void IDevice.Write(ushort device, byte value)
@@ -77,9 +81,9 @@ namespace Noddybox.Emulation.EightBit.Z80.Test
// Output(ConsoleColor.Red, ConsoleColor.DarkGray, "Writing {0:X2} to device {1:X4}", value, device);
}
- public bool Run(string name, Queue<string> input, Queue<string> expected)
+ public bool Run(string name, Queue<string> input, Queue<string> expected, bool stop)
{
- Output(ConsoleColor.Black, ConsoleColor.White, "Running test {0}", name);
+ Output(ConsoleColor.Black, ConsoleColor.White, "Running test {0}{1}", name, stop ? " - STOPPING FOR DEBUG THIS PASS" : String.Empty);
Queue<Register16> line = Decode(input.Dequeue());
Register16 r = line.Dequeue();
@@ -132,11 +136,16 @@ namespace Noddybox.Emulation.EightBit.Z80.Test
{
string a, b, c;
start = disassembler.Disassemble(start, out a, out b, out c);
- Output(ConsoleColor.Yellow, ConsoleColor.Blue, "{0}: {1}", a, b);
+ Output(ConsoleColor.Yellow, ConsoleColor.Blue, "{0}: {1,-20} ; {2}", a, b, c);
}
}
}
+ if (stop)
+ {
+ Debugger.Break();
+ }
+
while (clock.Ticks < cyclesToRun)
{
z80.Step();
diff --git a/native/Noddybox.Emulation/Noddybox.Emulation.csproj b/native/Noddybox.Emulation/Noddybox.Emulation.csproj
index e1cd715..4776878 100644
--- a/native/Noddybox.Emulation/Noddybox.Emulation.csproj
+++ b/native/Noddybox.Emulation/Noddybox.Emulation.csproj
@@ -43,6 +43,9 @@
<Compile Include="..\..\src\Noddybox.Emulation\Clock.cs">
<Link>Clock.cs</Link>
</Compile>
+ <Compile Include="..\..\src\Noddybox.Emulation\ReadOnlyArray.cs">
+ <Link>ReadOnlyArray.cs</Link>
+ </Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />