summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2011-12-29 00:17:13 +0000
committerIan C <ianc@noddybox.co.uk>2011-12-29 00:17:13 +0000
commitf96332b0913a8a365db73a1af3443c0e225a23d8 (patch)
treed530b3eb68f9a5619c0c7c8a15878759b343f025
parent2e3102879b2d3059f4ce0efc1a0ecd4bc3142a99 (diff)
Development check-in.
-rw-r--r--Noddybox.Emulation.EightBit.Z80/Noddybox.Emulation.EightBit.Z80.csproj1
-rw-r--r--Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs179
-rw-r--r--Noddybox.Emulation.EightBit.Z80/Z80CpuBaseOpcodes.cs333
-rw-r--r--Noddybox.Emulation.EightBit/Binary.cs63
-rw-r--r--Noddybox.Emulation.EightBit/ICpu.cs5
-rw-r--r--Noddybox.Emulation.EightBit/IDevice.cs5
-rw-r--r--Noddybox.Emulation.EightBit/IMemory.cs16
-rw-r--r--Noddybox.Emulation.EightBit/IRegister16.cs5
-rw-r--r--Noddybox.Emulation.EightBit/Noddybox.Emulation.EightBit.csproj1
-rw-r--r--Noddybox.Emulation.EightBit/Register16BigEndian.cs5
-rw-r--r--Noddybox.Emulation.EightBit/Register16Factory.cs5
-rw-r--r--Noddybox.Emulation.EightBit/Register16LittleEndian.cs5
-rw-r--r--Noddybox.Emulation.suobin37376 -> 40448 bytes
-rw-r--r--Noddybox.Emulation/Clock.cs5
14 files changed, 553 insertions, 75 deletions
diff --git a/Noddybox.Emulation.EightBit.Z80/Noddybox.Emulation.EightBit.Z80.csproj b/Noddybox.Emulation.EightBit.Z80/Noddybox.Emulation.EightBit.Z80.csproj
index 60cb7ff..03c8010 100644
--- a/Noddybox.Emulation.EightBit.Z80/Noddybox.Emulation.EightBit.Z80.csproj
+++ b/Noddybox.Emulation.EightBit.Z80/Noddybox.Emulation.EightBit.Z80.csproj
@@ -51,6 +51,7 @@
<ItemGroup>
<Compile Include="Z80Cpu.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Z80CpuBaseOpcodes.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Noddybox.Emulation.EightBit\Noddybox.Emulation.EightBit.csproj">
diff --git a/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs b/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs
index d967bb9..1583ae0 100644
--- a/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs
+++ b/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs
@@ -1,4 +1,7 @@
-using System;
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
@@ -22,13 +25,13 @@ namespace Noddybox.Emulation.EightBit.Z80
private enum Z80Flags
{
None = 0x00,
- Carry = 0x01,
- Neg = 0x02,
- PV = 0x04,
- Hidden3 = 0x08,
- HalfCarry = 0x10,
- Hidden5 = 0x20,
- Zero = 0x40,
+ Carry = 0x01,
+ Neg = 0x02,
+ PV = 0x04,
+ Hidden3 = 0x08,
+ HalfCarry = 0x10,
+ Hidden5 = 0x20,
+ Zero = 0x40,
Sign = 0x80
};
@@ -38,11 +41,12 @@ namespace Noddybox.Emulation.EightBit.Z80
// Lookup tables
//
- private Z80Flags[] PSZtable = new Z80Flags[512];
- private Z80Flags[] SZtable = new Z80Flags[512];
- private Z80Flags[] Ptable = new Z80Flags[512];
- private Z80Flags[] Stable = new Z80Flags[512];
+ private Z80Flags[] PSZtable = new Z80Flags[512];
+ private Z80Flags[] SZtable = new Z80Flags[512];
+ private Z80Flags[] Ptable = new Z80Flags[512];
+ private Z80Flags[] Stable = new Z80Flags[512];
private Z80Flags[] Ztable = new Z80Flags[512];
+ private Z80Flags[] H35table = new Z80Flags[256];
// Machine accessors
//
@@ -53,17 +57,14 @@ namespace Noddybox.Emulation.EightBit.Z80
// Main registers
//
private byte A;
- private byte F;
- private byte R;
- private byte IFF1;
- private byte IFF2;
+ private Z80Flags F;
private IRegister16 BC = Register16Factory.Create();
private IRegister16 DE = Register16Factory.Create();
private IRegister16 HL = Register16Factory.Create();
private IRegister16 IX = Register16Factory.Create();
private IRegister16 IY = Register16Factory.Create();
- private IRegister16 SP = Register16Factory.Create();
- private IRegister16 PC = Register16Factory.Create();
+ private ushort SP;
+ private ushort PC;
// Alternate registers
//
@@ -72,6 +73,15 @@ namespace Noddybox.Emulation.EightBit.Z80
private IRegister16 DE_ = Register16Factory.Create();
private IRegister16 HL_ = Register16Factory.Create();
+ // Auxilliary registers and flags
+ //
+ private byte I;
+ private byte R;
+ private bool IFF1;
+ private bool IFF2;
+ private int IM;
+ private bool HALT;
+
#endregion
#region ICpu Members
@@ -87,7 +97,29 @@ namespace Noddybox.Emulation.EightBit.Z80
public void Reset()
{
- // TODO: Initial register settings.
+ PC = 0;
+ A = 0xff;
+ F = (Z80Flags)0xff;
+
+ BC.Value = 0xffff;
+ DE.Value = 0xffff;
+ HL.Value = 0xffff;
+ AF_.Value = 0xffff;
+ BC_.Value = 0xffff;
+ DE_.Value = 0xffff;
+ HL_.Value = 0xffff;
+
+ IX.Value = 0xffff;
+ IY.Value = 0xffff;
+
+ SP = 0xffff;
+
+ IFF1 = false;
+ IFF2 = false;
+ IM = 0;
+ I = 0;
+ R = 0;
+ HALT = false;
}
public void Step()
@@ -97,16 +129,23 @@ namespace Noddybox.Emulation.EightBit.Z80
public void Run()
{
- // TODO: Run for a frame
+ while(!clock.FrameDone)
+ {
+ Step();
+ }
}
public void MaskableInterrupt(byte value)
{
+ clock.Add(2);
+
// TODO: INT
}
public void NonMaskableInterrupt(byte value)
{
+ clock.Add(2);
+
// TODO: NMI
}
@@ -118,48 +157,64 @@ namespace Noddybox.Emulation.EightBit.Z80
{
// Setup lookup tables
//
- for(int f = 0; f < 256; f++)
- {
- Z80Flags p = Z80Flags.None;
- Z80Flags z = Z80Flags.None;
- Z80Flags s = Z80Flags.None;
- int parity = 0;
-
- for(int b=0; b < 8; b++)
- {
- if ((f & (1<<b)) == (1<<b))
- {
- parity++;
- }
- }
-
- if ((parity & 1) == 1)
- {
- p = Z80Flags.PV;
- }
-
- if (f == 0)
- {
- z = Z80Flags.Zero;
- }
-
- if ((f & 0x80) == 0x80)
- {
- s = Z80Flags.Sign;
- }
-
- Ptable[f] = p;
- Stable[f] = s;
- Ztable[f] = z;
- SZtable[f] =z|s;
- PSZtable[f] = z|s|p;
-
- Ptable[f+256] = Ptable[f]|Z80Flags.Carry;
- Stable[f+256] = Stable[f]|Z80Flags.Carry;
- Ztable[f+256] = Ztable[f]|Z80Flags.Carry;
- SZtable[f+256] = SZtable[f]|Z80Flags.Carry;
- PSZtable[f+256] = PSZtable[f]|Z80Flags.Carry;
- }
+ for(int f = 0; f < 256; f++)
+ {
+ Z80Flags p = Z80Flags.None;
+ Z80Flags z = Z80Flags.None;
+ Z80Flags s = Z80Flags.None;
+ Z80Flags h3 = Z80Flags.None;
+ Z80Flags h5 = Z80Flags.None;
+
+ int parity = 0;
+
+ for(int b=0; b < 8; b++)
+ {
+ if ((f & (1<<b)) == (1<<b))
+ {
+ parity++;
+ }
+ }
+
+ if ((parity & 1) == 1)
+ {
+ p = Z80Flags.PV;
+ }
+
+ if (f == 0)
+ {
+ z = Z80Flags.Zero;
+ }
+
+ if ((f & 0x80) == 0x80)
+ {
+ s = Z80Flags.Sign;
+ }
+
+ if ((f & (int)Z80Flags.Hidden3) == (int)Z80Flags.Hidden3)
+ {
+ h3 = Z80Flags.Hidden3;
+ }
+
+ if ((f & (int)Z80Flags.Hidden5) == (int)Z80Flags.Hidden5)
+ {
+ h5 = Z80Flags.Hidden5;
+ }
+
+ Ptable[f] = p;
+ Stable[f] = s;
+ Ztable[f] = z;
+ SZtable[f] =z | s;
+ PSZtable[f] = z | s | p;
+ H35table[f] = h3 | h5;
+
+ Ptable[f+256] = Ptable[f] | Z80Flags.Carry;
+ Stable[f+256] = Stable[f] | Z80Flags.Carry;
+ Ztable[f+256] = Ztable[f] | Z80Flags.Carry;
+ SZtable[f+256] = SZtable[f] | Z80Flags.Carry;
+ PSZtable[f+256] = PSZtable[f] | Z80Flags.Carry;
+ }
+
+ Reset();
}
#endregion
diff --git a/Noddybox.Emulation.EightBit.Z80/Z80CpuBaseOpcodes.cs b/Noddybox.Emulation.EightBit.Z80/Z80CpuBaseOpcodes.cs
new file mode 100644
index 0000000..c42c163
--- /dev/null
+++ b/Noddybox.Emulation.EightBit.Z80/Z80CpuBaseOpcodes.cs
@@ -0,0 +1,333 @@
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+
+namespace Noddybox.Emulation.EightBit.Z80
+{
+ public partial class Z80Cpu
+ {
+ #region Stack commands
+
+ /// <summary>
+ /// Push a value on the stack.
+ /// </summary>
+ /// <param name="val">The value.</param>
+ private void Push(ushort val)
+ {
+ unchecked
+ {
+ memory.Write(--SP, val & 0xff);
+ memory.Write(--SP, Binary.ShiftRight(val, 8) & 0xff);
+ }
+ }
+
+ /// <summary>
+ /// Pop a value from the stack.
+ /// </summary>
+ /// <returns></returns>
+ private ushort Pop()
+ {
+ SP = (ushort)((SP + 2) & 0xffff);
+ return (ushort)(memory.Read(SP-2) | (memory.Read(SP - 1) >> 8));
+ }
+
+ #endregion
+
+ #region ALU arithmetic and comparison
+
+ /// <summary>
+ /// Add an 8-bit value to the accumulator without carry.
+ /// </summary>
+ /// <param name="b">The vakue.</param>
+ private void Add8(byte b)
+ {
+ int w = A + b;
+
+ F = SZtable[w] | H35table[w & 0xff];
+
+ if (((A ^ w ^ b) & (int)Z80Flags.HalfCarry) == (int)Z80Flags.HalfCarry)
+ {
+ F |= Z80Flags.HalfCarry;
+ }
+
+ if (((b ^ A) & (b ^ w) & 0x80) > 0)
+ {
+ F |= Z80Flags.PV;
+ }
+
+ A = (byte)(w & 0xff);
+ }
+
+ /// <summary>
+ /// Add an 8-bit value to the accumulator with carry.
+ /// </summary>
+ /// <param name="b">The vakue.</param>
+ private void Adc8(byte b)
+ {
+ int w = A + b + (int)(F & Z80Flags.Carry);
+
+ F = SZtable[w] | H35table[w & 0xff];
+
+ if (((A ^ w ^ b) & (int)Z80Flags.HalfCarry) == (int)Z80Flags.HalfCarry)
+ {
+ F |= Z80Flags.HalfCarry;
+ }
+
+ if (((b ^ A) & (b ^ w) & 0x80) > 0)
+ {
+ F |= Z80Flags.PV;
+ }
+
+ A = (byte)(w & 0xff);
+ }
+
+ /// <summary>
+ /// Subtract an 8-bit value from the accumulator without carry.
+ /// </summary>
+ /// <param name="b">The vakue.</param>
+ private void Sub8(byte b)
+ {
+ int w = A - b;
+
+ if (w < 0)
+ {
+ w += 0x200;
+ }
+
+ F = SZtable[w] | H35table[w & 0xff] | Z80Flags.Neg;
+
+ if (((A ^ w ^ b) & (int)Z80Flags.HalfCarry) == (int)Z80Flags.HalfCarry)
+ {
+ F |= Z80Flags.HalfCarry;
+ }
+
+ if (((b ^ A) & (b ^ w) & 0x80) > 0)
+ {
+ F |= Z80Flags.PV;
+ }
+
+ A = (byte)(w & 0xff);
+ }
+
+ /// <summary>
+ /// Compare an 8-bit value with the accumulator.
+ /// </summary>
+ /// <param name="b">The vakue.</param>
+ private void Cmp8(byte b)
+ {
+ int w = A - b;
+
+ if (w < 0)
+ {
+ w += 0x200;
+ }
+
+ F = SZtable[w] | H35table[w & 0xff] | Z80Flags.Neg;
+
+ if (((A ^ w ^ b) & (int)Z80Flags.HalfCarry) == (int)Z80Flags.HalfCarry)
+ {
+ F |= Z80Flags.HalfCarry;
+ }
+
+ if (((b ^ A) & (b ^ w) & 0x80) > 0)
+ {
+ F |= Z80Flags.PV;
+ }
+ }
+
+ /// <summary>
+ /// Subtract an 8-bit value from the accumulator with carry.
+ /// </summary>
+ /// <param name="b">The vakue.</param>
+ private void Sbc8(byte b)
+ {
+ int w = A - b - (int)(F & Z80Flags.Carry);
+
+ if (w < 0)
+ {
+ w += 0x200;
+ }
+
+ F = SZtable[w] | H35table[w & 0xff] | Z80Flags.Neg;
+
+ if (((A ^ w ^ b) & (int)Z80Flags.HalfCarry) == (int)Z80Flags.HalfCarry)
+ {
+ F |= Z80Flags.HalfCarry;
+ }
+
+ if (((b ^ A) & (b ^ w) & 0x80) > 0)
+ {
+ F |= Z80Flags.PV;
+ }
+
+ A = (byte)(w & 0xff);
+ }
+
+ /// <summary>
+ /// Add a 16-bit value to a register without carry.
+ /// </summary>
+ /// <param name="b">The vakue.</param>
+ private void Add16(ref ushort reg, ushort b)
+ {
+ int w = reg + b;
+
+ F &= Z80Flags.Sign | Z80Flags.Zero | Z80Flags.PV;
+
+ if (w > 0xffff)
+ {
+ F |= Z80Flags.Carry;
+ }
+
+ if ((reg ^ w ^ b) == 0x1000)
+ {
+ F |= Z80Flags.HalfCarry;
+ }
+
+ reg = (ushort)(w & 0xffff);
+
+ F |= H35table[reg >> 8];
+ }
+
+ /// <summary>
+ /// Add a 16-bit value to a register with carry.
+ /// </summary>
+ /// <param name="b">The vakue.</param>
+ private void Adc16(ref ushort reg, ushort b)
+ {
+ int w = reg + b + (int)(F & Z80Flags.Carry);
+
+ F = Z80Flags.None;
+
+ if ((w & 0xffff) == 0)
+ {
+ F |= Z80Flags.Zero;
+ }
+
+ if ((w & 0x8000) == 0x8000)
+ {
+ F |= Z80Flags.Sign;
+ }
+
+ if (w > 0xffff)
+ {
+ F |= Z80Flags.Carry;
+ }
+
+ if (((b ^ reg ^ 0x8000) & ((reg ^ w) & 0x8000)) == 0x8000)
+ {
+ F |= Z80Flags.PV;
+ }
+
+ if ((reg ^ w ^ b) == 0x1000)
+ {
+ F |= Z80Flags.HalfCarry;
+ }
+
+ reg = (ushort)(w & 0xffff);
+
+ F |= H35table[reg >> 8];
+ }
+
+
+ /// <summary>
+ /// Subtract a 16-bit value from a register with carry.
+ /// </summary>
+ /// <param name="b">The vakue.</param>
+ private void Sbc16(ref ushort reg, ushort b)
+ {
+ int w = reg - b - (int)(F & Z80Flags.Carry);
+
+ F = Z80Flags.Neg;
+
+ if (w < 0)
+ {
+ w += 0x10000;
+ F |= Z80Flags.Carry;
+ }
+
+ if ((w & 0xffff) == 0)
+ {
+ F |= Z80Flags.Zero;
+ }
+
+ if ((w & 0x8000) == 0x8000)
+ {
+ F |= Z80Flags.Sign;
+ }
+
+ if (((b ^ reg) & ((reg ^ w) & 0x8000)) == 0x8000)
+ {
+ F |= Z80Flags.PV;
+ }
+
+ if ((reg ^ w ^ b) == 0x1000)
+ {
+ F |= Z80Flags.HalfCarry;
+ }
+
+ reg = (ushort)(w & 0xffff);
+
+ F |= H35table[reg >> 8];
+ }
+
+ /// <summary>
+ /// Increment an 8-bit register.
+ /// </summary>
+ /// <param name="reg">The register to increment.</param>
+ void Inc8(ref byte reg)
+ {
+ unchecked
+ {
+ reg++;
+ }
+
+ F = Z80Flags.Carry;
+
+ if (reg == 0x80)
+ {
+ F |= Z80Flags.PV;
+ }
+
+ if ((reg & 0x0f) == 0x00)
+ {
+ F |= Z80Flags.HalfCarry;
+ }
+ }
+
+ /// <summary>
+ /// Decrement an 8-bit register.
+ /// </summary>
+ /// <param name="reg">The register to decrement.</param>
+ void Dec8(ref byte reg)
+ {
+ unchecked
+ {
+ reg--;
+ }
+
+ F = Z80Flags.Carry | Z80Flags.Neg;
+
+ if (reg == 0x7f)
+ {
+ F |= Z80Flags.PV;
+ }
+
+ if ((reg & 0x0f) == 0x0f)
+ {
+ F |= Z80Flags.HalfCarry;
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/Noddybox.Emulation.EightBit/Binary.cs b/Noddybox.Emulation.EightBit/Binary.cs
new file mode 100644
index 0000000..0b1928b
--- /dev/null
+++ b/Noddybox.Emulation.EightBit/Binary.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Net;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Documents;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Shapes;
+
+namespace Noddybox.Emulation.EightBit
+{
+ /// <summary>
+ /// Provides helpers for shifting smaller values around without casts all over the shop.
+ /// </summary>
+ public static class Binary
+ {
+ /// <summary>
+ /// Shift 8-bits to the left.
+ /// </summary>
+ /// <param name="b">The byte.</param>
+ /// <param name="shift">How many bits to shift.</param>
+ /// <returns>The shifted value.</returns>
+ public static byte ShiftLeft(byte b, int shift)
+ {
+ return (byte)((b << shift) & 0xff);
+ }
+
+ /// <summary>
+ /// Shift 8-bits to the right.
+ /// </summary>
+ /// <param name="b">The byte.</param>
+ /// <param name="shift">How many bits to shift.</param>
+ /// <returns>The shifted value.</returns>
+ public static byte ShiftRight(byte b, int shift)
+ {
+ return (byte)((b >> shift) & 0xff);
+ }
+
+ /// <summary>
+ /// Shift 16-bits to the left.
+ /// </summary>
+ /// <param name="w">The word.</param>
+ /// <param name="shift">How many bits to shift.</param>
+ /// <returns>The shifted value.</returns>
+ public static ushort ShiftLeft(ushort w, int shift)
+ {
+ return (ushort)((w << shift) & 0xffff);
+ }
+
+ /// <summary>
+ /// Shift 16-bits to the right.
+ /// </summary>
+ /// <param name="w">The word.</param>
+ /// <param name="shift">How many bits to shift.</param>
+ /// <returns>The shifted value.</returns>
+ public static ushort ShiftRight(ushort w, int shift)
+ {
+ return (ushort)((w >> shift) & 0xffff);
+ }
+ }
+}
diff --git a/Noddybox.Emulation.EightBit/ICpu.cs b/Noddybox.Emulation.EightBit/ICpu.cs
index 139933d..dc2f811 100644
--- a/Noddybox.Emulation.EightBit/ICpu.cs
+++ b/Noddybox.Emulation.EightBit/ICpu.cs
@@ -1,4 +1,7 @@
-using System;
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
diff --git a/Noddybox.Emulation.EightBit/IDevice.cs b/Noddybox.Emulation.EightBit/IDevice.cs
index 00ef38d..b8d234a 100644
--- a/Noddybox.Emulation.EightBit/IDevice.cs
+++ b/Noddybox.Emulation.EightBit/IDevice.cs
@@ -1,4 +1,7 @@
-using System;
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
diff --git a/Noddybox.Emulation.EightBit/IMemory.cs b/Noddybox.Emulation.EightBit/IMemory.cs
index 2c842a5..ee41500 100644
--- a/Noddybox.Emulation.EightBit/IMemory.cs
+++ b/Noddybox.Emulation.EightBit/IMemory.cs
@@ -1,4 +1,7 @@
-using System;
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
@@ -12,7 +15,8 @@ using System.Windows.Shapes;
namespace Noddybox.Emulation.EightBit
{
/// <summary>
- /// Defines an interface for memory.
+ /// Defines an interface for memory. Note that ints are used rather than smaller unsigned types due to the pain of
+ /// doing boolean operations on anything else in C# without copious casting.
/// </summary>
public interface IMemory
{
@@ -20,14 +24,14 @@ namespace Noddybox.Emulation.EightBit
/// Reads a byte at a given address.
/// </summary>
/// <param name="address">The address to read.</param>
- /// <returns>The value at that address.</returns>
- byte Read(ushort address);
+ /// <returns>The value at that address in the lower 8-bits.</returns>
+ int Read(int address);
/// <summary>
/// Writes a byte at a given address.
/// </summary>
/// <param name="address">The address to write to.</param>
- /// <param name="value">The value to write.</param>
- void Write(ushort address, byte value);
+ /// <param name="value">The value to write. Only the lower 8-bits are taken.</param>
+ void Write(int address, int value);
}
}
diff --git a/Noddybox.Emulation.EightBit/IRegister16.cs b/Noddybox.Emulation.EightBit/IRegister16.cs
index e3bfc69..4356756 100644
--- a/Noddybox.Emulation.EightBit/IRegister16.cs
+++ b/Noddybox.Emulation.EightBit/IRegister16.cs
@@ -1,4 +1,7 @@
-using System;
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
diff --git a/Noddybox.Emulation.EightBit/Noddybox.Emulation.EightBit.csproj b/Noddybox.Emulation.EightBit/Noddybox.Emulation.EightBit.csproj
index c7d5924..801adae 100644
--- a/Noddybox.Emulation.EightBit/Noddybox.Emulation.EightBit.csproj
+++ b/Noddybox.Emulation.EightBit/Noddybox.Emulation.EightBit.csproj
@@ -49,6 +49,7 @@
<Reference Include="mscorlib.extensions" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Binary.cs" />
<Compile Include="ICpu.cs" />
<Compile Include="IDevice.cs" />
<Compile Include="IMemory.cs" />
diff --git a/Noddybox.Emulation.EightBit/Register16BigEndian.cs b/Noddybox.Emulation.EightBit/Register16BigEndian.cs
index 8378543..e7a3780 100644
--- a/Noddybox.Emulation.EightBit/Register16BigEndian.cs
+++ b/Noddybox.Emulation.EightBit/Register16BigEndian.cs
@@ -1,4 +1,7 @@
-using System;
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
diff --git a/Noddybox.Emulation.EightBit/Register16Factory.cs b/Noddybox.Emulation.EightBit/Register16Factory.cs
index fd31fe4..249e668 100644
--- a/Noddybox.Emulation.EightBit/Register16Factory.cs
+++ b/Noddybox.Emulation.EightBit/Register16Factory.cs
@@ -1,4 +1,7 @@
-using System;
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
diff --git a/Noddybox.Emulation.EightBit/Register16LittleEndian.cs b/Noddybox.Emulation.EightBit/Register16LittleEndian.cs
index a2cf8a8..ccecdaf 100644
--- a/Noddybox.Emulation.EightBit/Register16LittleEndian.cs
+++ b/Noddybox.Emulation.EightBit/Register16LittleEndian.cs
@@ -1,4 +1,7 @@
-using System;
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
diff --git a/Noddybox.Emulation.suo b/Noddybox.Emulation.suo
index 8cd6ad5..a6b0b10 100644
--- a/Noddybox.Emulation.suo
+++ b/Noddybox.Emulation.suo
Binary files differ
diff --git a/Noddybox.Emulation/Clock.cs b/Noddybox.Emulation/Clock.cs
index 55a0e7b..0b733cb 100644
--- a/Noddybox.Emulation/Clock.cs
+++ b/Noddybox.Emulation/Clock.cs
@@ -1,4 +1,7 @@
-using System;
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;