summaryrefslogtreecommitdiff
path: root/src
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 /src
parent31203bc854656ff92844364903de9abee9daea8b (diff)
Further bug fixes to Z80. Now starts the Spectrum ROM OK.
Diffstat (limited to 'src')
-rw-r--r--src/Noddybox.Emulation.EightBit.Z80.Disassembler/Z80Disassembler.cs22
-rw-r--r--src/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs40
-rw-r--r--src/Noddybox.Emulation.EightBit.Z80/Z80CpuBaseOpcodes.cs171
-rw-r--r--src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeByte.cs22
-rw-r--r--src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeED.cs29
-rw-r--r--src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeShiftedCB.cs888
-rw-r--r--src/Noddybox.Emulation/ReadOnlyArray.cs63
7 files changed, 600 insertions, 635 deletions
diff --git a/src/Noddybox.Emulation.EightBit.Z80.Disassembler/Z80Disassembler.cs b/src/Noddybox.Emulation.EightBit.Z80.Disassembler/Z80Disassembler.cs
index 438b962..91be791 100644
--- a/src/Noddybox.Emulation.EightBit.Z80.Disassembler/Z80Disassembler.cs
+++ b/src/Noddybox.Emulation.EightBit.Z80.Disassembler/Z80Disassembler.cs
@@ -633,16 +633,10 @@ namespace Noddybox.Emulation.EightBit.Z80.Disassembler
private void DIS_BIT_IX(byte op, ref ushort pc)
{
- int reg;
int bit;
- reg = (op % 8);
bit = (op - 0x40) / 8;
-
- if (reg == 6)
- Z80_Dis_Set("bit", Z80_Dis_Printf("%d,%s", bit, IX_RelStrCB(op, ref pc)));
- else
- Z80_Dis_Set("bit", Z80_Dis_Printf("%d,%s[%s]", bit, IX_RelStrCB(op, ref pc), z80_dis_reg8[reg]));
+ Z80_Dis_Set("bit", Z80_Dis_Printf("%d,%s", bit, IX_RelStrCB(op, ref pc)));
}
private void DIS_RES_IX(byte op, ref ushort pc)
@@ -1276,16 +1270,10 @@ namespace Noddybox.Emulation.EightBit.Z80.Disassembler
private void DIS_BIT_IY(byte op, ref ushort pc)
{
- int reg;
int bit;
- reg = (op % 8);
bit = (op - 0x40) / 8;
-
- if (reg == 6)
- Z80_Dis_Set("bit", Z80_Dis_Printf("%d,%s", bit, IY_RelStrCB(op, ref pc)));
- else
- Z80_Dis_Set("bit", Z80_Dis_Printf("%d,%s[%s]", bit, IY_RelStrCB(op, ref pc), z80_dis_reg8[reg]));
+ Z80_Dis_Set("bit", Z80_Dis_Printf("%d,%s", bit, IY_RelStrCB(op, ref pc)));
}
private void DIS_RES_IY(byte op, ref ushort pc)
@@ -2403,13 +2391,13 @@ namespace Noddybox.Emulation.EightBit.Z80.Disassembler
{
address = String.Format("{0:X4}", startAddress);
- byte op = Z80_Dis_FetchByte(ref startAddress);
-
Hex.Clear();
+ byte op = Z80_Dis_FetchByte(ref startAddress);
+
dis_opcode_z80[op](op, ref startAddress);
- opcode = String.Format("{0} {1}", Opcode, Argument);
+ opcode = String.Format("{0,-5} {1}", Opcode, Argument);
hexdump = Hex.ToString();
return startAddress;
diff --git a/src/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs b/src/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs
index 2da155e..74a8df1 100644
--- a/src/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs
+++ b/src/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs
@@ -15,6 +15,12 @@
//
// Copyright (c) 2012 Ian Cowburn
//
+// Some of the concepts and code in here are taken from FUSE, the open source UNIX
+// Spectrum emulator Copyright (c) 1999-2003 Philip Kendall.
+// See <http://fuse-emulator.sourceforge.net/>
+//
+// Any introduced bugs in that code are mine, and not the original authors.
+//
using System;
namespace Noddybox.Emulation.EightBit.Z80
@@ -45,6 +51,40 @@ namespace Noddybox.Emulation.EightBit.Z80
private Z80Flags[] Ztable = new Z80Flags[512];
private Z80Flags[] H35table = new Z80Flags[512];
+ // Whether a half carry occurred or not can be determined by looking at
+ // the 3rd bit of the two arguments and the result; these are hashed
+ // into this table in the form r12, where r is the 3rd bit of the
+ // result, 1 is the 3rd bit of the 1st argument and 2 is the
+ // third bit of the 2nd argument; the tables differ for add and subtract
+ // operations.
+ //
+ private readonly ReadOnlyArray<Z80Flags> halfcarry_add_table =
+ new ReadOnlyArray<Z80Flags>
+ (new Z80Flags[8]
+ {Z80Flags.None, Z80Flags.HalfCarry, Z80Flags.HalfCarry, Z80Flags.HalfCarry,
+ Z80Flags.None, Z80Flags.None, Z80Flags.None, Z80Flags.HalfCarry});
+
+ private readonly ReadOnlyArray<Z80Flags> halfcarry_sub_table =
+ new ReadOnlyArray<Z80Flags>
+ (new Z80Flags[8]
+ {Z80Flags.None, Z80Flags.None, Z80Flags.HalfCarry, Z80Flags.None,
+ Z80Flags.HalfCarry, Z80Flags.None, Z80Flags.HalfCarry, Z80Flags.HalfCarry});
+
+ // Similarly, overflow can be determined by looking at the 7th bits; again
+ // the hash into this table is r12
+ //
+ private readonly ReadOnlyArray<Z80Flags> overflow_add_table =
+ new ReadOnlyArray<Z80Flags>
+ (new Z80Flags[8]
+ {Z80Flags.None, Z80Flags.None, Z80Flags.None, Z80Flags.PV,
+ Z80Flags.PV, Z80Flags.None, Z80Flags.None, Z80Flags.None});
+
+ private readonly ReadOnlyArray<Z80Flags> overflow_sub_table =
+ new ReadOnlyArray<Z80Flags>
+ (new Z80Flags[8]
+ {Z80Flags.None, Z80Flags.PV, Z80Flags.None, Z80Flags.None,
+ Z80Flags.None, Z80Flags.None, Z80Flags.PV, Z80Flags.None});
+
// Machine accessors
//
private IMemory memory;
diff --git a/src/Noddybox.Emulation.EightBit.Z80/Z80CpuBaseOpcodes.cs b/src/Noddybox.Emulation.EightBit.Z80/Z80CpuBaseOpcodes.cs
index e0cc4e4..cc02e94 100644
--- a/src/Noddybox.Emulation.EightBit.Z80/Z80CpuBaseOpcodes.cs
+++ b/src/Noddybox.Emulation.EightBit.Z80/Z80CpuBaseOpcodes.cs
@@ -15,6 +15,12 @@
//
// Copyright (c) 2012 Ian Cowburn
//
+// Some of the concepts and code in here are taken from FUSE, the open source UNIX
+// Spectrum emulator Copyright (c) 1999-2003 Philip Kendall.
+// See <http://fuse-emulator.sourceforge.net/>
+//
+// Any introduced bugs in that code are mine, and not the original authors.
+//
using System;
namespace Noddybox.Emulation.EightBit.Z80
@@ -57,6 +63,7 @@ namespace Noddybox.Emulation.EightBit.Z80
{
if (shift == 0xdd || shift == 0xfd)
{
+ clock.Add(8);
byte b = memory.Read(PC++);
return (sbyte)b;
}
@@ -107,8 +114,9 @@ namespace Noddybox.Emulation.EightBit.Z80
/// <param name="val">The value.</param>
private void PUSH(ushort val)
{
- memory.Write(--SP, (byte)(val & 0xff));
- memory.Write(--SP, (byte)(Binary.ShiftRight(val, 8) & 0xff));
+ Register16 r = new Register16(val);
+ memory.Write(--SP, r.high);
+ memory.Write(--SP, r.low);
}
/// <summary>
@@ -117,9 +125,12 @@ namespace Noddybox.Emulation.EightBit.Z80
/// <returns></returns>
private ushort POP()
{
- SP = (ushort)((SP + 2) & 0xffff);
- return (ushort)(memory.Read((ushort)(SP-2)) |
- (memory.Read((ushort)(SP - 1)) >> 8));
+ Register16 r = new Register16(0);
+
+ r.low = memory.Read(SP++);
+ r.high = memory.Read(SP++);
+
+ return r.reg;
}
#endregion
@@ -133,18 +144,10 @@ namespace Noddybox.Emulation.EightBit.Z80
private void ADD8(byte b)
{
int w = A + b;
+ int lookup = ((A & 0x88) >> 3) | ((b & 0x88) >> 2) | ((w & 0x88) >> 1);
- 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;
- }
+ F = SZtable[w] | H35table[w & 0xff] |
+ halfcarry_add_table[lookup & 0x07] | overflow_add_table[lookup >> 4];
A = (byte)(w & 0xff);
}
@@ -156,18 +159,10 @@ namespace Noddybox.Emulation.EightBit.Z80
private void ADC8(byte b)
{
int w = A + b + (int)(F & Z80Flags.Carry);
+ int lookup = ((A & 0x88) >> 3) | ((b & 0x88) >> 2) | ((w & 0x88) >> 1);
- 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;
- }
+ F = SZtable[w] | H35table[w & 0xff] |
+ halfcarry_add_table[lookup & 0x07] | overflow_add_table[lookup >> 4];
A = (byte)(w & 0xff);
}
@@ -185,17 +180,10 @@ namespace Noddybox.Emulation.EightBit.Z80
w += 0x200;
}
- F = SZtable[w] | H35table[w & 0xff] | Z80Flags.Neg;
+ int lookup = ((A & 0x88) >> 3) | ((b & 0x88) >> 2) | ((w & 0x88) >> 1);
- if (((A ^ w ^ b) & (int)Z80Flags.HalfCarry) == (int)Z80Flags.HalfCarry)
- {
- F |= Z80Flags.HalfCarry;
- }
-
- if (((b ^ A) & (b ^ w) & 0x80) > 0)
- {
- F |= Z80Flags.PV;
- }
+ F = SZtable[w] | H35table[w] | Z80Flags.Neg |
+ halfcarry_sub_table[lookup & 0x07] | overflow_sub_table[lookup >> 4];
A = (byte)(w & 0xff);
}
@@ -213,17 +201,10 @@ namespace Noddybox.Emulation.EightBit.Z80
w += 0x200;
}
- F = SZtable[w] | H35table[w & 0xff] | Z80Flags.Neg;
+ int lookup = ((A & 0x88) >> 3) | ((b & 0x88) >> 2) | ((w & 0x88) >> 1);
- if (((A ^ w ^ b) & (int)Z80Flags.HalfCarry) == (int)Z80Flags.HalfCarry)
- {
- F |= Z80Flags.HalfCarry;
- }
-
- if (((b ^ A) & (b ^ w) & 0x80) > 0)
- {
- F |= Z80Flags.PV;
- }
+ F = SZtable[w] | H35table[b] | Z80Flags.Neg |
+ halfcarry_sub_table[lookup & 0x07] | overflow_sub_table[lookup >> 4];
}
/// <summary>
@@ -239,17 +220,10 @@ namespace Noddybox.Emulation.EightBit.Z80
w += 0x200;
}
- F = SZtable[w] | H35table[w & 0xff] | Z80Flags.Neg;
-
- if (((A ^ w ^ b) & (int)Z80Flags.HalfCarry) == (int)Z80Flags.HalfCarry)
- {
- F |= Z80Flags.HalfCarry;
- }
+ int lookup = ((A & 0x88) >> 3) | ((b & 0x88) >> 2) | ((w & 0x88) >> 1);
- if (((b ^ A) & (b ^ w) & 0x80) > 0)
- {
- F |= Z80Flags.PV;
- }
+ F = SZtable[w] | H35table[w & 0xff] | Z80Flags.Neg |
+ halfcarry_sub_table[lookup & 0x07] | overflow_sub_table[lookup >> 4];
A = (byte)(w & 0xff);
}
@@ -269,14 +243,13 @@ namespace Noddybox.Emulation.EightBit.Z80
F |= Z80Flags.Carry;
}
- if (((reg ^ w ^ b) & 0x1000) == 0x1000)
- {
- F |= Z80Flags.HalfCarry;
- }
+ int lookup = ((reg & 0x8800) >> 11) |
+ ((b & 0x8800) >> 10) |
+ ((w & 0x8800) >> 9);
reg = (ushort)(w & 0xffff);
- F |= H35table[reg >> 8];
+ F |= halfcarry_add_table[lookup & 0x07] | H35table[reg >> 8];
}
/// <summary>
@@ -304,19 +277,14 @@ namespace Noddybox.Emulation.EightBit.Z80
F |= Z80Flags.Carry;
}
- if (((b ^ reg ^ 0x8000) & ((reg ^ w) & 0x8000)) == 0x8000)
- {
- F |= Z80Flags.PV;
- }
-
- if ((reg ^ w ^ b) == 0x1000)
- {
- F |= Z80Flags.HalfCarry;
- }
+ int lookup = ((reg & 0x8800) >> 11) |
+ ((b & 0x8800) >> 10) |
+ ((w & 0x8800) >> 9);
reg = (ushort)(w & 0xffff);
- F |= H35table[reg >> 8];
+ F |= halfcarry_add_table[lookup & 0x07] | overflow_add_table[lookup >> 4] |
+ H35table[reg >> 8];
}
@@ -346,19 +314,14 @@ namespace Noddybox.Emulation.EightBit.Z80
F |= Z80Flags.Sign;
}
- if (((b ^ reg) & ((reg ^ w) & 0x8000)) == 0x8000)
- {
- F |= Z80Flags.PV;
- }
-
- if ((reg ^ w ^ b) == 0x1000)
- {
- F |= Z80Flags.HalfCarry;
- }
+ int lookup = ((reg & 0x8800) >> 11) |
+ ((b & 0x8800) >> 10) |
+ ((w & 0x8800) >> 9);
reg = (ushort)(w & 0xffff);
- F |= H35table[reg >> 8];
+ F |= halfcarry_sub_table[lookup & 0x07] | overflow_sub_table[lookup >> 4] |
+ H35table[reg >> 8];
}
/// <summary>
@@ -554,7 +517,7 @@ namespace Noddybox.Emulation.EightBit.Z80
private void SRL(ref byte reg)
{
byte carry = (byte)(reg & 1);
- reg = Binary.ShiftLeft(reg, 1);
+ reg = Binary.ShiftRight(reg, 1);
F = PSZtable[reg] | (Z80Flags)carry | H35table[reg];
}
@@ -565,7 +528,7 @@ namespace Noddybox.Emulation.EightBit.Z80
private void SRA(ref byte reg)
{
byte carry = (byte)(reg & 1);
- reg = (byte)(Binary.ShiftLeft(reg, 1) | (reg & 0x80));
+ reg = (byte)(Binary.ShiftRight(reg, 1) | (reg & 0x80));
F = PSZtable[reg] | (Z80Flags)carry | H35table[reg];
}
@@ -576,7 +539,7 @@ namespace Noddybox.Emulation.EightBit.Z80
private void SLL(ref byte reg)
{
byte carry = Binary.ShiftRight(reg, 7);
- reg = (byte)(Binary.ShiftRight(reg, 1) | 0x01);
+ reg = (byte)(Binary.ShiftLeft(reg, 1) | 0x01);
F = PSZtable[reg] | (Z80Flags)carry | H35table[reg];
}
@@ -587,7 +550,7 @@ namespace Noddybox.Emulation.EightBit.Z80
private void SLA(ref byte reg)
{
byte carry = Binary.ShiftRight(reg, 7);
- reg = Binary.ShiftRight(reg, 1);
+ reg = Binary.ShiftLeft(reg, 1);
F = PSZtable[reg] | (Z80Flags)carry | H35table[reg];
}
@@ -612,7 +575,7 @@ namespace Noddybox.Emulation.EightBit.Z80
void OR(byte val)
{
A |= val;
- F = PSZtable[A] | Z80Flags.HalfCarry | H35table[A];
+ F = PSZtable[A] | H35table[A];
}
/// <summary>
@@ -622,7 +585,7 @@ namespace Noddybox.Emulation.EightBit.Z80
void XOR(byte val)
{
A ^= val;
- F = PSZtable[A] | Z80Flags.HalfCarry | H35table[A];
+ F = PSZtable[A] | H35table[A];
}
/// <summary>
@@ -633,7 +596,7 @@ namespace Noddybox.Emulation.EightBit.Z80
void BIT(ref byte reg, int bit)
{
F &= Z80Flags.Carry;
- F |= Z80Flags.HalfCarry;
+ F |= Z80Flags.HalfCarry | H35table[reg];
if ((reg & (1 << bit)) != 0)
{
@@ -641,15 +604,29 @@ namespace Noddybox.Emulation.EightBit.Z80
{
F |= Z80Flags.Sign;
}
+ }
+ else
+ {
+ F |= Z80Flags.Zero | Z80Flags.PV;
+ }
+ }
- if (bit == 5 && (reg & (int)Z80Flags.Hidden5) != 0)
- {
- F |= Z80Flags.Hidden5;
- }
+ /// <summary>
+ /// Perform the BIT operation on an indexed location.
+ /// </summary>
+ /// <param name="reg">The register to operate on.</param>
+ /// <param name="bit">The bit to test.</param>
+ /// <param name="addr">The address being checked.</param>
+ void BIT(ref byte reg, int bit, ushort addr)
+ {
+ F &= Z80Flags.Carry;
+ F |= Z80Flags.HalfCarry | H35table[addr>>8];
- if (bit == 3 && (reg & (int)Z80Flags.Hidden3) != 0)
+ if ((reg & (1 << bit)) != 0)
+ {
+ if (bit == 7 && (reg & (int)Z80Flags.Sign) != 0)
{
- F |= Z80Flags.Hidden3;
+ F |= Z80Flags.Sign;
}
}
else
@@ -688,7 +665,7 @@ namespace Noddybox.Emulation.EightBit.Z80
private void CALL()
{
PUSH((ushort)(PC + 2));
- PC = (ushort)(memory.Read(PC) | memory.Read((ushort)(PC+1)) >> 8);
+ PC = FetchWord();
}
/// <summary>
@@ -696,7 +673,7 @@ namespace Noddybox.Emulation.EightBit.Z80
/// </summary>
private void JP()
{
- PC = (ushort)(memory.Read(PC) | memory.Read((ushort)(PC+1)) >> 8);
+ PC = FetchWord();
}
/// <summary>
diff --git a/src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeByte.cs b/src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeByte.cs
index 22a6c98..63ccc15 100644
--- a/src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeByte.cs
+++ b/src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeByte.cs
@@ -349,7 +349,14 @@ namespace Noddybox.Emulation.EightBit.Z80
break;
case 0x36: // LD (HL),n
- clock.Add(10);
+ if (shift == 0xdd || shift == 0xfd)
+ {
+ clock.Add(7);
+ }
+ else
+ {
+ clock.Add(10);
+ }
addr = (ushort)(hl.reg + Offset());
memory.Write(addr, memory.Read(PC++));
break;
@@ -1093,7 +1100,7 @@ namespace Noddybox.Emulation.EightBit.Z80
break;
case 0xc5: // PUSH BC
- clock.Add(10);
+ clock.Add(11);
PUSH(BC.reg);
break;
@@ -1112,7 +1119,7 @@ namespace Noddybox.Emulation.EightBit.Z80
case 0xc9: // RET
clock.Add(10);
- SP = POP();
+ PC = POP();
break;
case 0xca: // JP Z,nnnn
@@ -1120,8 +1127,6 @@ namespace Noddybox.Emulation.EightBit.Z80
break;
case 0xcb: // CB shift
- AddR(1);
-
// Check for IX/IY shift
//
if (shift != 0)
@@ -1139,6 +1144,7 @@ namespace Noddybox.Emulation.EightBit.Z80
}
else
{
+ AddR(1);
DecodeCB(memory.Read(PC++));
}
break;
@@ -1186,7 +1192,7 @@ namespace Noddybox.Emulation.EightBit.Z80
break;
case 0xd5: // PUSH DE
- clock.Add(10);
+ clock.Add(11);
PUSH(DE.reg);
break;
@@ -1266,7 +1272,7 @@ namespace Noddybox.Emulation.EightBit.Z80
break;
case 0xe5: // PUSH HL
- clock.Add(10);
+ clock.Add(11);
PUSH(hl.reg);
break;
@@ -1341,7 +1347,7 @@ namespace Noddybox.Emulation.EightBit.Z80
break;
case 0xf5: // PUSH AF
- clock.Add(10);
+ clock.Add(11);
PUSH((ushort)((A << 8) | (int)(F)));
break;
diff --git a/src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeED.cs b/src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeED.cs
index a6037f6..f9cc84e 100644
--- a/src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeED.cs
+++ b/src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeED.cs
@@ -36,7 +36,8 @@ namespace Noddybox.Emulation.EightBit.Z80
case 0x40: // IN B,(C)
clock.Add(12);
BC.high = device.Read(BC.reg);
- F = Z80Flags.Carry | PSZtable[BC.high] | H35table[BC.high];
+ F &= Z80Flags.Carry;
+ F |= PSZtable[BC.high] | H35table[BC.high];
break;
case 0x41: // OUT (C),B
@@ -82,7 +83,8 @@ namespace Noddybox.Emulation.EightBit.Z80
case 0x48: // IN C,(C)
clock.Add(12);
BC.low = device.Read(BC.reg);
- F = Z80Flags.Carry | PSZtable[BC.low] | H35table[BC.low];
+ F &= Z80Flags.Carry;
+ F |= PSZtable[BC.low] | H35table[BC.low];
break;
case 0x49: // OUT (C),C
@@ -128,7 +130,8 @@ namespace Noddybox.Emulation.EightBit.Z80
case 0x50: // IN D,(C)
clock.Add(12);
DE.high = device.Read(BC.reg);
- F = Z80Flags.Carry | PSZtable[DE.high] | H35table[DE.high];
+ F &= Z80Flags.Carry;
+ F |= PSZtable[DE.high] | H35table[DE.high];
break;
case 0x51: // OUT (C),D
@@ -169,12 +172,15 @@ namespace Noddybox.Emulation.EightBit.Z80
case 0x57: // LD A,I
clock.Add(9);
A = (byte)I;
+ F &= Z80Flags.Carry;
+ F |= H35table[A] | SZtable[A] | (IFF2 ? Z80Flags.PV : Z80Flags.None);
break;
case 0x58: // IN E,(C)
clock.Add(12);
DE.low = device.Read(BC.reg);
- F = Z80Flags.Carry | PSZtable[BC.low] | H35table[BC.low];
+ F &= Z80Flags.Carry;
+ F |= PSZtable[DE.low] | H35table[DE.low];
break;
case 0x59: // OUT (C),E
@@ -215,12 +221,15 @@ namespace Noddybox.Emulation.EightBit.Z80
case 0x5f: // LD A,R
clock.Add(9);
A = R;
+ F &= Z80Flags.Carry;
+ F |= H35table[A] | SZtable[A] | (IFF2 ? Z80Flags.PV : Z80Flags.None);
break;
case 0x60: // IN H,(C)
clock.Add(12);
HL.high = device.Read(BC.reg);
- F = Z80Flags.Carry | PSZtable[DE.high] | H35table[DE.high];
+ F &= Z80Flags.Carry;
+ F |= PSZtable[HL.high] | H35table[HL.high];
break;
case 0x61: // OUT (C),H
@@ -263,13 +272,15 @@ namespace Noddybox.Emulation.EightBit.Z80
b = memory.Read(HL.reg);
memory.Write(HL.reg, (byte)((b >> 4)|(A << 4)));
A = (byte)((A & 0xf0) | (b & 0x0f));
- F = Z80Flags.Carry | PSZtable[A] | H35table[A];
+ F &= Z80Flags.Carry;
+ F |= PSZtable[A] | H35table[A];
break;
case 0x68: // IN L,(C)
clock.Add(12);
HL.low = device.Read(BC.reg);
- F = Z80Flags.Carry | PSZtable[BC.low] | H35table[BC.low];
+ F &= Z80Flags.Carry;
+ F |= PSZtable[HL.low] | H35table[HL.low];
break;
case 0x69: // OUT (C),L
@@ -318,7 +329,8 @@ namespace Noddybox.Emulation.EightBit.Z80
case 0x70: // IN (C)
clock.Add(12);
b = device.Read(BC.reg);
- F = Z80Flags.Carry | PSZtable[b] | H35table[b];
+ F &= Z80Flags.Carry;
+ F |= PSZtable[b] | H35table[b];
break;
case 0x71: // OUT (C)
@@ -364,7 +376,6 @@ namespace Noddybox.Emulation.EightBit.Z80
case 0x78: // IN A,(C)
clock.Add(12);
A = device.Read(BC.reg);
- F = Z80Flags.Carry | PSZtable[BC.low] | H35table[BC.low];
break;
case 0x79: // OUT (C),A
diff --git a/src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeShiftedCB.cs b/src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeShiftedCB.cs
index 731e474..ee86817 100644
--- a/src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeShiftedCB.cs
+++ b/src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeShiftedCB.cs
@@ -37,7 +37,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RLC(ref result);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x01: // RLC (ix+d) -> C
@@ -45,7 +45,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RLC(ref result);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x02: // RLC (ix+d) -> D
@@ -53,7 +53,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RLC(ref result);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x03: // RLC (ix+d) -> E
@@ -61,7 +61,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RLC(ref result);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x04: // RLC (ix+d) -> H
@@ -69,7 +69,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RLC(ref result);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x05: // RLC (ix+d) -> L
@@ -77,14 +77,14 @@ namespace Noddybox.Emulation.EightBit.Z80
RLC(ref result);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x06: // RLC (ix+d)
result = memory.Read(addr);
RLC(ref result);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0x07: // RLC (ix+d) -> A
@@ -92,7 +92,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RLC(ref result);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x08: // RRC (ix+d) -> B
@@ -100,7 +100,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RRC(ref result);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x09: // RRC (ix+d) -> C
@@ -108,7 +108,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RRC(ref result);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x0a: // RRC (ix+d) -> D
@@ -116,7 +116,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RRC(ref result);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x0b: // RRC (ix+d) -> E
@@ -124,7 +124,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RRC(ref result);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x0c: // RRC (ix+d) -> H
@@ -132,7 +132,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RRC(ref result);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x0d: // RRC (ix+d) -> L
@@ -140,14 +140,14 @@ namespace Noddybox.Emulation.EightBit.Z80
RRC(ref result);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x0e: // RRC (ix+d)
result = memory.Read(addr);
RRC(ref result);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0x0f: // RRC (ix+d) -> A
@@ -155,7 +155,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RRC(ref result);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x10: // RL (ix+d) -> B
@@ -163,7 +163,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RL(ref result);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x11: // RL (ix+d) -> C
@@ -171,7 +171,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RL(ref result);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x12: // RL (ix+d) -> D
@@ -179,7 +179,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RL(ref result);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x13: // RL (ix+d) -> E
@@ -187,7 +187,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RL(ref result);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x14: // RL (ix+d) -> H
@@ -195,7 +195,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RL(ref result);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x15: // RL (ix+d) -> L
@@ -203,14 +203,14 @@ namespace Noddybox.Emulation.EightBit.Z80
RL(ref result);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x16: // RL (ix+d)
result = memory.Read(addr);
RL(ref result);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0x17: // RL (ix+d) -> A
@@ -218,7 +218,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RL(ref result);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x18: // RR (ix+d) -> B
@@ -226,7 +226,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RR(ref result);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x19: // RR (ix+d) -> C
@@ -234,7 +234,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RR(ref result);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x1a: // RR (ix+d) -> D
@@ -242,7 +242,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RR(ref result);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x1b: // RR (ix+d) -> E
@@ -250,7 +250,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RR(ref result);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x1c: // RR (ix+d) -> H
@@ -258,7 +258,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RR(ref result);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x1d: // RR (ix+d) -> L
@@ -266,14 +266,14 @@ namespace Noddybox.Emulation.EightBit.Z80
RR(ref result);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x1e: // RR (ix+d)
result = memory.Read(addr);
RR(ref result);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0x1f: // RR (ix+d) -> A
@@ -281,7 +281,7 @@ namespace Noddybox.Emulation.EightBit.Z80
RR(ref result);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x20: // SLA (ix+d) -> B
@@ -289,7 +289,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SLA(ref result);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x21: // SLA (ix+d) -> C
@@ -297,7 +297,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SLA(ref result);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x22: // SLA (ix+d) -> D
@@ -305,7 +305,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SLA(ref result);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x23: // SLA (ix+d) -> E
@@ -313,7 +313,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SLA(ref result);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x24: // SLA (ix+d) -> H
@@ -321,7 +321,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SLA(ref result);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x25: // SLA (ix+d) -> L
@@ -329,14 +329,14 @@ namespace Noddybox.Emulation.EightBit.Z80
SLA(ref result);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x26: // SLA (ix+d)
result = memory.Read(addr);
SLA(ref result);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0x27: // SLA (ix+d) -> A
@@ -344,7 +344,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SLA(ref result);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x28: // SRA (ix+d) -> B
@@ -352,7 +352,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SRA(ref result);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x29: // SRA (ix+d) -> C
@@ -360,7 +360,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SRA(ref result);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x2a: // SRA (ix+d) -> D
@@ -368,7 +368,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SRA(ref result);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x2b: // SRA (ix+d) -> E
@@ -376,7 +376,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SRA(ref result);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x2c: // SRA (ix+d) -> H
@@ -384,7 +384,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SRA(ref result);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x2d: // SRA (ix+d) -> L
@@ -392,14 +392,14 @@ namespace Noddybox.Emulation.EightBit.Z80
SRA(ref result);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x2e: // SRA (ix+d)
result = memory.Read(addr);
SRA(ref result);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0x2f: // SRA (ix+d) -> A
@@ -407,7 +407,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SRA(ref result);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x30: // SLL (ix+d) -> B
@@ -415,7 +415,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SLL(ref result);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x31: // SLL (ix+d) -> C
@@ -423,7 +423,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SLL(ref result);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x32: // SLL (ix+d) -> D
@@ -431,7 +431,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SLL(ref result);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x33: // SLL (ix+d) -> E
@@ -439,7 +439,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SLL(ref result);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x34: // SLL (ix+d) -> H
@@ -447,7 +447,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SLL(ref result);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x35: // SLL (ix+d) -> L
@@ -455,14 +455,14 @@ namespace Noddybox.Emulation.EightBit.Z80
SLL(ref result);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x36: // SLL (ix+d)
result = memory.Read(addr);
SLL(ref result);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0x37: // SLL (ix+d) -> A
@@ -470,7 +470,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SLL(ref result);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x38: // SRL (ix+d) -> B
@@ -478,7 +478,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SRL(ref result);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x39: // SRL (ix+d) -> C
@@ -486,7 +486,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SRL(ref result);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x3a: // SRL (ix+d) -> D
@@ -494,7 +494,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SRL(ref result);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x3b: // SRL (ix+d) -> E
@@ -502,7 +502,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SRL(ref result);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x3c: // SRL (ix+d) -> H
@@ -510,7 +510,7 @@ namespace Noddybox.Emulation.EightBit.Z80
SRL(ref result);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x3d: // SRL (ix+d) -> L
@@ -518,14 +518,14 @@ namespace Noddybox.Emulation.EightBit.Z80
SRL(ref result);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x3e: // SRL (ix+d)
result = memory.Read(addr);
SRL(ref result);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0x3f: // SRL (ix+d) -> A
@@ -533,511 +533,391 @@ namespace Noddybox.Emulation.EightBit.Z80
SRL(ref result);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
- case 0x40: // BIT 0,(ix+d) -> B
+ case 0x40: // BIT 0,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 0);
- memory.Write(addr, result);
- BC.high = result;
- clock.Add(20);
+ BIT(ref result, 0, addr);
+ clock.Add(8);
break;
- case 0x41: // BIT 0,(ix+d) -> C
+ case 0x41: // BIT 0,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 0);
- memory.Write(addr, result);
- BC.low = result;
- clock.Add(20);
+ BIT(ref result, 0, addr);
+ clock.Add(8);
break;
- case 0x42: // BIT 0,(ix+d) -> D
+ case 0x42: // BIT 0,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 0);
- memory.Write(addr, result);
- DE.high = result;
- clock.Add(20);
+ BIT(ref result, 0, addr);
+ clock.Add(8);
break;
- case 0x43: // BIT 0,(ix+d) -> E
+ case 0x43: // BIT 0,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 0);
- memory.Write(addr, result);
- DE.low = result;
- clock.Add(20);
+ BIT(ref result, 0, addr);
+ clock.Add(8);
break;
- case 0x44: // BIT 0,(ix+d) -> H
+ case 0x44: // BIT 0,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 0);
- memory.Write(addr, result);
- HL.high = result;
- clock.Add(20);
+ BIT(ref result, 0, addr);
+ clock.Add(8);
break;
- case 0x45: // BIT 0,(ix+d) -> L
+ case 0x45: // BIT 0,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 0);
- memory.Write(addr, result);
- HL.low = result;
- clock.Add(20);
+ BIT(ref result, 0, addr);
+ clock.Add(8);
break;
- case 0x46: // BIT 0,(ix+d)
+ case 0x46: // BIT 0,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 0);
- memory.Write(addr, result);
- clock.Add(20);
+ BIT(ref result, 0, addr);
+ clock.Add(8);
break;
- case 0x47: // BIT 0,(ix+d) -> A
+ case 0x47: // BIT 0,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 0);
- memory.Write(addr, result);
- A = result;
- clock.Add(20);
+ BIT(ref result, 0, addr);
+ clock.Add(8);
break;
- case 0x48: // BIT 1,(ix+d) -> B
+ case 0x48: // BIT 1,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 1);
- memory.Write(addr, result);
- BC.high = result;
- clock.Add(20);
+ BIT(ref result, 1, addr);
+ clock.Add(8);
break;
- case 0x49: // BIT 1,(ix+d) -> C
+ case 0x49: // BIT 1,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 1);
- memory.Write(addr, result);
- BC.low = result;
- clock.Add(20);
+ BIT(ref result, 1, addr);
+ clock.Add(8);
break;
- case 0x4a: // BIT 1,(ix+d) -> D
+ case 0x4a: // BIT 1,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 1);
- memory.Write(addr, result);
- DE.high = result;
- clock.Add(20);
+ BIT(ref result, 1, addr);
+ clock.Add(8);
break;
- case 0x4b: // BIT 1,(ix+d) -> E
+ case 0x4b: // BIT 1,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 1);
- memory.Write(addr, result);
- DE.low = result;
- clock.Add(20);
+ BIT(ref result, 1, addr);
+ clock.Add(8);
break;
- case 0x4c: // BIT 1,(ix+d) -> H
+ case 0x4c: // BIT 1,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 1);
- memory.Write(addr, result);
- HL.high = result;
- clock.Add(20);
+ BIT(ref result, 1, addr);
+ clock.Add(8);
break;
- case 0x4d: // BIT 1,(ix+d) -> L
+ case 0x4d: // BIT 1,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 1);
- memory.Write(addr, result);
- HL.low = result;
- clock.Add(20);
+ BIT(ref result, 1, addr);
+ clock.Add(8);
break;
- case 0x4e: // BIT 1,(ix+d)
+ case 0x4e: // BIT 1,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 1);
- memory.Write(addr, result);
- clock.Add(20);
+ BIT(ref result, 1, addr);
+ clock.Add(8);
break;
- case 0x4f: // BIT 1,(ix+d) -> A
+ case 0x4f: // BIT 1,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 1);
- memory.Write(addr, result);
- A = result;
- clock.Add(20);
+ BIT(ref result, 1, addr);
+ clock.Add(8);
break;
- case 0x50: // BIT 2,(ix+d) -> B
+ case 0x50: // BIT 2,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 2);
- memory.Write(addr, result);
- BC.high = result;
- clock.Add(20);
+ BIT(ref result, 2, addr);
+ clock.Add(8);
break;
- case 0x51: // BIT 2,(ix+d) -> C
+ case 0x51: // BIT 2,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 2);
- memory.Write(addr, result);
- BC.low = result;
- clock.Add(20);
+ BIT(ref result, 2, addr);
+ clock.Add(8);
break;
- case 0x52: // BIT 2,(ix+d) -> D
+ case 0x52: // BIT 2,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 2);
- memory.Write(addr, result);
- DE.high = result;
- clock.Add(20);
+ BIT(ref result, 2, addr);
+ clock.Add(8);
break;
- case 0x53: // BIT 2,(ix+d) -> E
+ case 0x53: // BIT 2,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 2);
- memory.Write(addr, result);
- DE.low = result;
- clock.Add(20);
+ BIT(ref result, 2, addr);
+ clock.Add(8);
break;
- case 0x54: // BIT 2,(ix+d) -> H
+ case 0x54: // BIT 2,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 2);
- memory.Write(addr, result);
- HL.high = result;
- clock.Add(20);
+ BIT(ref result, 2, addr);
+ clock.Add(8);
break;
- case 0x55: // BIT 2,(ix+d) -> L
+ case 0x55: // BIT 2,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 2);
- memory.Write(addr, result);
- HL.low = result;
- clock.Add(20);
+ BIT(ref result, 2, addr);
+ clock.Add(8);
break;
- case 0x56: // BIT 2,(ix+d)
+ case 0x56: // BIT 2,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 2);
- memory.Write(addr, result);
- clock.Add(20);
+ BIT(ref result, 2, addr);
+ clock.Add(8);
break;
- case 0x57: // BIT 2,(ix+d) -> A
+ case 0x57: // BIT 2,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 2);
- memory.Write(addr, result);
- A = result;
- clock.Add(20);
+ BIT(ref result, 2, addr);
+ clock.Add(8);
break;
- case 0x58: // BIT 3,(ix+d) -> B
+ case 0x58: // BIT 3,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 3);
- memory.Write(addr, result);
- BC.high = result;
- clock.Add(20);
+ BIT(ref result, 3, addr);
+ clock.Add(8);
break;
- case 0x59: // BIT 3,(ix+d) -> C
+ case 0x59: // BIT 3,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 3);
- memory.Write(addr, result);
- BC.low = result;
- clock.Add(20);
+ BIT(ref result, 3, addr);
+ clock.Add(8);
break;
- case 0x5a: // BIT 3,(ix+d) -> D
+ case 0x5a: // BIT 3,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 3);
- memory.Write(addr, result);
- DE.high = result;
- clock.Add(20);
+ BIT(ref result, 3, addr);
+ clock.Add(8);
break;
- case 0x5b: // BIT 3,(ix+d) -> E
+ case 0x5b: // BIT 3,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 3);
- memory.Write(addr, result);
- DE.low = result;
- clock.Add(20);
+ BIT(ref result, 3, addr);
+ clock.Add(8);
break;
- case 0x5c: // BIT 3,(ix+d) -> H
+ case 0x5c: // BIT 3,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 3);
- memory.Write(addr, result);
- HL.high = result;
- clock.Add(20);
+ BIT(ref result, 3, addr);
+ clock.Add(8);
break;
- case 0x5d: // BIT 3,(ix+d) -> L
+ case 0x5d: // BIT 3,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 3);
- memory.Write(addr, result);
- HL.low = result;
- clock.Add(20);
+ BIT(ref result, 3, addr);
+ clock.Add(8);
break;
- case 0x5e: // BIT 3,(ix+d)
+ case 0x5e: // BIT 3,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 3);
- memory.Write(addr, result);
- clock.Add(20);
+ BIT(ref result, 3, addr);
+ clock.Add(8);
break;
- case 0x5f: // BIT 3,(ix+d) -> A
+ case 0x5f: // BIT 3,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 3);
- memory.Write(addr, result);
- A = result;
- clock.Add(20);
+ BIT(ref result, 3, addr);
+ clock.Add(8);
break;
- case 0x60: // BIT 4,(ix+d) -> B
+ case 0x60: // BIT 4,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 4);
- memory.Write(addr, result);
- BC.high = result;
- clock.Add(20);
+ BIT(ref result, 4, addr);
+ clock.Add(8);
break;
- case 0x61: // BIT 4,(ix+d) -> C
+ case 0x61: // BIT 4,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 4);
- memory.Write(addr, result);
- BC.low = result;
- clock.Add(20);
+ BIT(ref result, 4, addr);
+ clock.Add(8);
break;
- case 0x62: // BIT 4,(ix+d) -> D
+ case 0x62: // BIT 4,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 4);
- memory.Write(addr, result);
- DE.high = result;
- clock.Add(20);
+ BIT(ref result, 4, addr);
+ clock.Add(8);
break;
- case 0x63: // BIT 4,(ix+d) -> E
+ case 0x63: // BIT 4,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 4);
- memory.Write(addr, result);
- DE.low = result;
- clock.Add(20);
+ BIT(ref result, 4, addr);
+ clock.Add(8);
break;
- case 0x64: // BIT 4,(ix+d) -> H
+ case 0x64: // BIT 4,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 4);
- memory.Write(addr, result);
- HL.high = result;
- clock.Add(20);
+ BIT(ref result, 4, addr);
+ clock.Add(8);
break;
- case 0x65: // BIT 4,(ix+d) -> L
+ case 0x65: // BIT 4,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 4);
- memory.Write(addr, result);
- HL.low = result;
- clock.Add(20);
+ BIT(ref result, 4, addr);
+ clock.Add(8);
break;
- case 0x66: // BIT 4,(ix+d)
+ case 0x66: // BIT 4,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 4);
- memory.Write(addr, result);
- clock.Add(20);
+ BIT(ref result, 4, addr);
+ clock.Add(8);
break;
- case 0x67: // BIT 4,(ix+d) -> A
+ case 0x67: // BIT 4,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 4);
- memory.Write(addr, result);
- A = result;
- clock.Add(20);
+ BIT(ref result, 4, addr);
+ clock.Add(8);
break;
- case 0x68: // BIT 5,(ix+d) -> B
+ case 0x68: // BIT 5,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 5);
- memory.Write(addr, result);
- BC.high = result;
- clock.Add(20);
+ BIT(ref result, 5, addr);
+ clock.Add(8);
break;
- case 0x69: // BIT 5,(ix+d) -> C
+ case 0x69: // BIT 5,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 5);
- memory.Write(addr, result);
- BC.low = result;
- clock.Add(20);
+ BIT(ref result, 5, addr);
+ clock.Add(8);
break;
- case 0x6a: // BIT 5,(ix+d) -> D
+ case 0x6a: // BIT 5,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 5);
- memory.Write(addr, result);
- DE.high = result;
- clock.Add(20);
+ BIT(ref result, 5, addr);
+ clock.Add(8);
break;
- case 0x6b: // BIT 5,(ix+d) -> E
+ case 0x6b: // BIT 5,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 5);
- memory.Write(addr, result);
- DE.low = result;
- clock.Add(20);
+ BIT(ref result, 5, addr);
+ clock.Add(8);
break;
- case 0x6c: // BIT 5,(ix+d) -> H
+ case 0x6c: // BIT 5,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 5);
- memory.Write(addr, result);
- HL.high = result;
- clock.Add(20);
+ BIT(ref result, 5, addr);
+ clock.Add(8);
break;
- case 0x6d: // BIT 5,(ix+d) -> L
+ case 0x6d: // BIT 5,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 5);
- memory.Write(addr, result);
- HL.low = result;
- clock.Add(20);
+ BIT(ref result, 5, addr);
+ clock.Add(8);
break;
- case 0x6e: // BIT 5,(ix+d)
+ case 0x6e: // BIT 5,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 5);
- memory.Write(addr, result);
- clock.Add(20);
+ BIT(ref result, 5, addr);
+ clock.Add(8);
break;
- case 0x6f: // BIT 5,(ix+d) -> A
+ case 0x6f: // BIT 5,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 5);
- memory.Write(addr, result);
- A = result;
- clock.Add(20);
+ BIT(ref result, 5, addr);
+ clock.Add(8);
break;
- case 0x70: // BIT 6,(ix+d) -> B
+ case 0x70: // BIT 6,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 6);
- memory.Write(addr, result);
- BC.high = result;
- clock.Add(20);
+ BIT(ref result, 6, addr);
+ clock.Add(8);
break;
- case 0x71: // BIT 6,(ix+d) -> C
+ case 0x71: // BIT 6,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 6);
- memory.Write(addr, result);
- BC.low = result;
- clock.Add(20);
+ BIT(ref result, 6, addr);
+ clock.Add(8);
break;
- case 0x72: // BIT 6,(ix+d) -> D
+ case 0x72: // BIT 6,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 6);
- memory.Write(addr, result);
- DE.high = result;
- clock.Add(20);
+ BIT(ref result, 6, addr);
+ clock.Add(8);
break;
- case 0x73: // BIT 6,(ix+d) -> E
+ case 0x73: // BIT 6,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 6);
- memory.Write(addr, result);
- DE.low = result;
- clock.Add(20);
+ BIT(ref result, 6, addr);
+ clock.Add(8);
break;
- case 0x74: // BIT 6,(ix+d) -> H
+ case 0x74: // BIT 6,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 6);
- memory.Write(addr, result);
- HL.high = result;
- clock.Add(20);
+ BIT(ref result, 6, addr);
+ clock.Add(8);
break;
- case 0x75: // BIT 6,(ix+d) -> L
+ case 0x75: // BIT 6,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 6);
- memory.Write(addr, result);
- HL.low = result;
- clock.Add(20);
+ BIT(ref result, 6, addr);
+ clock.Add(8);
break;
- case 0x76: // BIT 6,(ix+d)
+ case 0x76: // BIT 6,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 6);
- memory.Write(addr, result);
- clock.Add(20);
+ BIT(ref result, 6, addr);
+ clock.Add(8);
break;
- case 0x77: // BIT 6,(ix+d) -> A
+ case 0x77: // BIT 6,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 6);
- memory.Write(addr, result);
- A = result;
- clock.Add(20);
+ BIT(ref result, 6, addr);
+ clock.Add(8);
break;
- case 0x78: // BIT 7,(ix+d) -> B
+ case 0x78: // BIT 7,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 7);
- memory.Write(addr, result);
- BC.high = result;
- clock.Add(20);
+ BIT(ref result, 7, addr);
+ clock.Add(8);
break;
- case 0x79: // BIT 7,(ix+d) -> C
+ case 0x79: // BIT 7,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 7);
- memory.Write(addr, result);
- BC.low = result;
- clock.Add(20);
+ BIT(ref result, 7, addr);
+ clock.Add(8);
break;
- case 0x7a: // BIT 7,(ix+d) -> D
+ case 0x7a: // BIT 7,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 7);
- memory.Write(addr, result);
- DE.high = result;
- clock.Add(20);
+ BIT(ref result, 7, addr);
+ clock.Add(8);
break;
- case 0x7b: // BIT 7,(ix+d) -> E
+ case 0x7b: // BIT 7,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 7);
- memory.Write(addr, result);
- DE.low = result;
- clock.Add(20);
+ BIT(ref result, 7, addr);
+ clock.Add(8);
break;
- case 0x7c: // BIT 7,(ix+d) -> H
+ case 0x7c: // BIT 7,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 7);
- memory.Write(addr, result);
- HL.high = result;
- clock.Add(20);
+ BIT(ref result, 7, addr);
+ clock.Add(8);
break;
- case 0x7d: // BIT 7,(ix+d) -> L
+ case 0x7d: // BIT 7,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 7);
- memory.Write(addr, result);
- HL.low = result;
- clock.Add(20);
+ BIT(ref result, 7, addr);
+ clock.Add(8);
break;
- case 0x7e: // BIT 7,(ix+d)
+ case 0x7e: // BIT 7,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 7);
- memory.Write(addr, result);
- clock.Add(20);
+ BIT(ref result, 7, addr);
+ clock.Add(8);
break;
- case 0x7f: // BIT 7,(ix+d) -> A
+ case 0x7f: // BIT 7,(ix+d)
result = memory.Read(addr);
- BIT(ref result, 7);
- memory.Write(addr, result);
- A = result;
- clock.Add(20);
+ BIT(ref result, 7, addr);
+ clock.Add(8);
break;
case 0x80: // RES 0,(ix+d) -> B
@@ -1045,7 +925,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 0);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x81: // RES 0,(ix+d) -> C
@@ -1053,7 +933,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 0);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x82: // RES 0,(ix+d) -> D
@@ -1061,7 +941,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 0);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x83: // RES 0,(ix+d) -> E
@@ -1069,7 +949,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 0);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x84: // RES 0,(ix+d) -> H
@@ -1077,7 +957,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 0);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x85: // RES 0,(ix+d) -> L
@@ -1085,14 +965,14 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 0);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x86: // RES 0,(ix+d)
result = memory.Read(addr);
BIT_RES(ref result, 0);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0x87: // RES 0,(ix+d) -> A
@@ -1100,7 +980,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 0);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x88: // RES 1,(ix+d) -> B
@@ -1108,7 +988,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 1);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x89: // RES 1,(ix+d) -> C
@@ -1116,7 +996,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 1);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x8a: // RES 1,(ix+d) -> D
@@ -1124,7 +1004,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 1);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x8b: // RES 1,(ix+d) -> E
@@ -1132,7 +1012,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 1);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x8c: // RES 1,(ix+d) -> H
@@ -1140,7 +1020,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 1);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x8d: // RES 1,(ix+d) -> L
@@ -1148,14 +1028,14 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 1);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x8e: // RES 1,(ix+d)
result = memory.Read(addr);
BIT_RES(ref result, 1);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0x8f: // RES 1,(ix+d) -> A
@@ -1163,7 +1043,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 1);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x90: // RES 2,(ix+d) -> B
@@ -1171,7 +1051,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 2);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x91: // RES 2,(ix+d) -> C
@@ -1179,7 +1059,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 2);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x92: // RES 2,(ix+d) -> D
@@ -1187,7 +1067,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 2);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x93: // RES 2,(ix+d) -> E
@@ -1195,7 +1075,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 2);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x94: // RES 2,(ix+d) -> H
@@ -1203,7 +1083,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 2);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x95: // RES 2,(ix+d) -> L
@@ -1211,14 +1091,14 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 2);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x96: // RES 2,(ix+d)
result = memory.Read(addr);
BIT_RES(ref result, 2);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0x97: // RES 2,(ix+d) -> A
@@ -1226,7 +1106,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 2);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x98: // RES 3,(ix+d) -> B
@@ -1234,7 +1114,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 3);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x99: // RES 3,(ix+d) -> C
@@ -1242,7 +1122,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 3);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x9a: // RES 3,(ix+d) -> D
@@ -1250,7 +1130,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 3);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x9b: // RES 3,(ix+d) -> E
@@ -1258,7 +1138,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 3);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x9c: // RES 3,(ix+d) -> H
@@ -1266,7 +1146,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 3);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x9d: // RES 3,(ix+d) -> L
@@ -1274,14 +1154,14 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 3);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0x9e: // RES 3,(ix+d)
result = memory.Read(addr);
BIT_RES(ref result, 3);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0x9f: // RES 3,(ix+d) -> A
@@ -1289,7 +1169,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 3);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xa0: // RES 4,(ix+d) -> B
@@ -1297,7 +1177,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 4);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xa1: // RES 4,(ix+d) -> C
@@ -1305,7 +1185,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 4);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xa2: // RES 4,(ix+d) -> D
@@ -1313,7 +1193,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 4);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xa3: // RES 4,(ix+d) -> E
@@ -1321,7 +1201,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 4);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xa4: // RES 4,(ix+d) -> H
@@ -1329,7 +1209,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 4);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xa5: // RES 4,(ix+d) -> L
@@ -1337,14 +1217,14 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 4);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xa6: // RES 4,(ix+d)
result = memory.Read(addr);
BIT_RES(ref result, 4);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0xa7: // RES 4,(ix+d) -> A
@@ -1352,7 +1232,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 4);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xa8: // RES 5,(ix+d) -> B
@@ -1360,7 +1240,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 5);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xa9: // RES 5,(ix+d) -> C
@@ -1368,7 +1248,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 5);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xaa: // RES 5,(ix+d) -> D
@@ -1376,7 +1256,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 5);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xab: // RES 5,(ix+d) -> E
@@ -1384,7 +1264,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 5);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xac: // RES 5,(ix+d) -> H
@@ -1392,7 +1272,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 5);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xad: // RES 5,(ix+d) -> L
@@ -1400,14 +1280,14 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 5);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xae: // RES 5,(ix+d)
result = memory.Read(addr);
BIT_RES(ref result, 5);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0xaf: // RES 5,(ix+d) -> A
@@ -1415,7 +1295,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 5);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xb0: // RES 6,(ix+d) -> B
@@ -1423,7 +1303,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 6);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xb1: // RES 6,(ix+d) -> C
@@ -1431,7 +1311,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 6);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xb2: // RES 6,(ix+d) -> D
@@ -1439,7 +1319,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 6);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xb3: // RES 6,(ix+d) -> E
@@ -1447,7 +1327,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 6);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xb4: // RES 6,(ix+d) -> H
@@ -1455,7 +1335,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 6);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xb5: // RES 6,(ix+d) -> L
@@ -1463,14 +1343,14 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 6);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xb6: // RES 6,(ix+d)
result = memory.Read(addr);
BIT_RES(ref result, 6);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0xb7: // RES 6,(ix+d) -> A
@@ -1478,7 +1358,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 6);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xb8: // RES 7,(ix+d) -> B
@@ -1486,7 +1366,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 7);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xb9: // RES 7,(ix+d) -> C
@@ -1494,7 +1374,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 7);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xba: // RES 7,(ix+d) -> D
@@ -1502,7 +1382,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 7);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xbb: // RES 7,(ix+d) -> E
@@ -1510,7 +1390,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 7);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xbc: // RES 7,(ix+d) -> H
@@ -1518,7 +1398,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 7);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xbd: // RES 7,(ix+d) -> L
@@ -1526,14 +1406,14 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 7);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xbe: // RES 7,(ix+d)
result = memory.Read(addr);
BIT_RES(ref result, 7);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0xbf: // RES 7,(ix+d) -> A
@@ -1541,7 +1421,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_RES(ref result, 7);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xc0: // SET 0,(ix+d) -> B
@@ -1549,7 +1429,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 0);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xc1: // SET 0,(ix+d) -> C
@@ -1557,7 +1437,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 0);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xc2: // SET 0,(ix+d) -> D
@@ -1565,7 +1445,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 0);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xc3: // SET 0,(ix+d) -> E
@@ -1573,7 +1453,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 0);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xc4: // SET 0,(ix+d) -> H
@@ -1581,7 +1461,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 0);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xc5: // SET 0,(ix+d) -> L
@@ -1589,14 +1469,14 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 0);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xc6: // SET 0,(ix+d)
result = memory.Read(addr);
BIT_SET(ref result, 0);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0xc7: // SET 0,(ix+d) -> A
@@ -1604,7 +1484,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 0);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xc8: // SET 1,(ix+d) -> B
@@ -1612,7 +1492,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 1);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xc9: // SET 1,(ix+d) -> C
@@ -1620,7 +1500,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 1);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xca: // SET 1,(ix+d) -> D
@@ -1628,7 +1508,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 1);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xcb: // SET 1,(ix+d) -> E
@@ -1636,7 +1516,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 1);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xcc: // SET 1,(ix+d) -> H
@@ -1644,7 +1524,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 1);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xcd: // SET 1,(ix+d) -> L
@@ -1652,14 +1532,14 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 1);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xce: // SET 1,(ix+d)
result = memory.Read(addr);
BIT_SET(ref result, 1);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0xcf: // SET 1,(ix+d) -> A
@@ -1667,7 +1547,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 1);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xd0: // SET 2,(ix+d) -> B
@@ -1675,7 +1555,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 2);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xd1: // SET 2,(ix+d) -> C
@@ -1683,7 +1563,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 2);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xd2: // SET 2,(ix+d) -> D
@@ -1691,7 +1571,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 2);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xd3: // SET 2,(ix+d) -> E
@@ -1699,7 +1579,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 2);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xd4: // SET 2,(ix+d) -> H
@@ -1707,7 +1587,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 2);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xd5: // SET 2,(ix+d) -> L
@@ -1715,14 +1595,14 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 2);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xd6: // SET 2,(ix+d)
result = memory.Read(addr);
BIT_SET(ref result, 2);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0xd7: // SET 2,(ix+d) -> A
@@ -1730,7 +1610,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 2);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xd8: // SET 3,(ix+d) -> B
@@ -1738,7 +1618,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 3);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xd9: // SET 3,(ix+d) -> C
@@ -1746,7 +1626,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 3);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xda: // SET 3,(ix+d) -> D
@@ -1754,7 +1634,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 3);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xdb: // SET 3,(ix+d) -> E
@@ -1762,7 +1642,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 3);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xdc: // SET 3,(ix+d) -> H
@@ -1770,7 +1650,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 3);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xdd: // SET 3,(ix+d) -> L
@@ -1778,14 +1658,14 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 3);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xde: // SET 3,(ix+d)
result = memory.Read(addr);
BIT_SET(ref result, 3);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0xdf: // SET 3,(ix+d) -> A
@@ -1793,7 +1673,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 3);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xe0: // SET 4,(ix+d) -> B
@@ -1801,7 +1681,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 4);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xe1: // SET 4,(ix+d) -> C
@@ -1809,7 +1689,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 4);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xe2: // SET 4,(ix+d) -> D
@@ -1817,7 +1697,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 4);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xe3: // SET 4,(ix+d) -> E
@@ -1825,7 +1705,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 4);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xe4: // SET 4,(ix+d) -> H
@@ -1833,7 +1713,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 4);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xe5: // SET 4,(ix+d) -> L
@@ -1841,14 +1721,14 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 4);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xe6: // SET 4,(ix+d)
result = memory.Read(addr);
BIT_SET(ref result, 4);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0xe7: // SET 4,(ix+d) -> A
@@ -1856,7 +1736,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 4);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xe8: // SET 5,(ix+d) -> B
@@ -1864,7 +1744,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 5);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xe9: // SET 5,(ix+d) -> C
@@ -1872,7 +1752,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 5);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xea: // SET 5,(ix+d) -> D
@@ -1880,7 +1760,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 5);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xeb: // SET 5,(ix+d) -> E
@@ -1888,7 +1768,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 5);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xec: // SET 5,(ix+d) -> H
@@ -1896,7 +1776,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 5);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xed: // SET 5,(ix+d) -> L
@@ -1904,14 +1784,14 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 5);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xee: // SET 5,(ix+d)
result = memory.Read(addr);
BIT_SET(ref result, 5);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0xef: // SET 5,(ix+d) -> A
@@ -1919,7 +1799,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 5);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xf0: // SET 6,(ix+d) -> B
@@ -1927,7 +1807,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 6);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xf1: // SET 6,(ix+d) -> C
@@ -1935,7 +1815,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 6);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xf2: // SET 6,(ix+d) -> D
@@ -1943,7 +1823,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 6);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xf3: // SET 6,(ix+d) -> E
@@ -1951,7 +1831,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 6);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xf4: // SET 6,(ix+d) -> H
@@ -1959,7 +1839,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 6);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xf5: // SET 6,(ix+d) -> L
@@ -1967,14 +1847,14 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 6);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xf6: // SET 6,(ix+d)
result = memory.Read(addr);
BIT_SET(ref result, 6);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0xf7: // SET 6,(ix+d) -> A
@@ -1982,7 +1862,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 6);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xf8: // SET 7,(ix+d) -> B
@@ -1990,7 +1870,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 7);
memory.Write(addr, result);
BC.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xf9: // SET 7,(ix+d) -> C
@@ -1998,7 +1878,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 7);
memory.Write(addr, result);
BC.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xfa: // SET 7,(ix+d) -> D
@@ -2006,7 +1886,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 7);
memory.Write(addr, result);
DE.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xfb: // SET 7,(ix+d) -> E
@@ -2014,7 +1894,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 7);
memory.Write(addr, result);
DE.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xfc: // SET 7,(ix+d) -> H
@@ -2022,7 +1902,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 7);
memory.Write(addr, result);
HL.high = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xfd: // SET 7,(ix+d) -> L
@@ -2030,14 +1910,14 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 7);
memory.Write(addr, result);
HL.low = result;
- clock.Add(23);
+ clock.Add(11);
break;
case 0xfe: // SET 7,(ix+d)
result = memory.Read(addr);
BIT_SET(ref result, 7);
memory.Write(addr, result);
- clock.Add(23);
+ clock.Add(11);
break;
case 0xff: // SET 7,(ix+d) -> A
@@ -2045,7 +1925,7 @@ namespace Noddybox.Emulation.EightBit.Z80
BIT_SET(ref result, 7);
memory.Write(addr, result);
A = result;
- clock.Add(23);
+ clock.Add(11);
break;
}
}
diff --git a/src/Noddybox.Emulation/ReadOnlyArray.cs b/src/Noddybox.Emulation/ReadOnlyArray.cs
new file mode 100644
index 0000000..6cc9e49
--- /dev/null
+++ b/src/Noddybox.Emulation/ReadOnlyArray.cs
@@ -0,0 +1,63 @@
+// This file is part of the Noddybox.Emulation C# suite.
+//
+// Noddybox.Emulation is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Noddybox.Emulation is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Noddybox.Emulation. If not, see <http://www.gnu.org/licenses/>.
+//
+// Copyright (c) 2012 Ian Cowburn
+//
+using System;
+using System.Collections.Generic;
+
+namespace Noddybox.Emulation
+{
+ /// <summary>
+ /// Provides a basic read only array implementation.
+ /// </summary>
+ public class ReadOnlyArray<T>
+ {
+ #region Private fields
+
+ private T[] array;
+
+ #endregion
+
+ #region Public properties
+
+ public T this[int index]
+ {
+ get {return array[index];}
+ }
+
+ #endregion
+
+ #region Constructors
+
+ /// <summary>
+ /// Defines a read-only array.
+ /// </summary>
+ /// <param name="items">The items to initialise the array with.</param>
+ public ReadOnlyArray(IEnumerable<T> items)
+ {
+ List<T> l = new List<T>();
+
+ foreach (T i in items)
+ {
+ l.Add(i);
+ }
+
+ array = l.ToArray();
+ }
+
+ #endregion
+ }
+}