summaryrefslogtreecommitdiff
path: root/src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeED.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeED.cs')
-rw-r--r--src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeED.cs129
1 files changed, 127 insertions, 2 deletions
diff --git a/src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeED.cs b/src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeED.cs
index 5d8ec1e..d06ee3d 100644
--- a/src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeED.cs
+++ b/src/Noddybox.Emulation.EightBit.Z80/Z80CpuDecodeED.cs
@@ -1,4 +1,18 @@
-//
+// 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
+//
// Copyright (c) 2012 Ian Cowburn
//
using System;
@@ -8,11 +22,122 @@ namespace Noddybox.Emulation.EightBit.Z80
public partial class Z80Cpu
{
/// <summary>
- /// Decode and execute a ED-shifted opcode.
+ /// Decode and execute an ED-shifted opcode.
/// </summary>
/// <param name="opcode">The opcode.</param>
private void DecodeED(byte opcode)
{
+ ushort addr;
+ byte b;
+
+ switch(opcode)
+ {
+ case 0x40: // IN B,(C)
+ clock.Add(12);
+ BC.high = device.Read(BC.reg);
+ F = Z80Flags.Carry | PSZtable[BC.high] | H35table[BC.high];
+ break;
+
+ case 0x41: // OUT (C),B
+ clock.Add(12);
+ device.Write(BC.reg, BC.high);
+ break;
+
+ case 0x42: // SBC HL,BC
+ clock.Add(15);
+ SBC(ref HL.reg, BC.reg);
+ break;
+
+ case 0x43: // LD (nnnn),BC
+ clock.Add(20);
+ addr = FetchWord();
+ memory.Write(addr++, BC.low);
+ memory.Write(addr, BC.high);
+ break;
+
+ case 0x44: // NEG
+ clock.Add(8);
+ b = A;
+ A = 0;
+ SUB8(b);
+ break;
+
+ case 0x45: // RETN
+ clock.Add(14);
+ IFF1 = IFF2;
+ PC = POP();
+ break;
+
+ case 0x46: // IM 0
+ clock.Add(8);
+ IM = 0;
+ break;
+
+ case 0x47: // LD I,A
+ clock.Add(9);
+ I = A;
+ break;
+
+ case 0x48: // IN C,(C)
+ clock.Add(12);
+ BC.low = device.Read(BC.reg);
+ F = Z80Flags.Carry | PSZtable[BC.low] | H35table[BC.low];
+ break;
+
+ case 0x49: // OUT (C),C
+ clock.Add(12);
+ device.Write(BC.reg, BC.low);
+ break;
+
+ case 0x4a: // ADC HL, BC
+ clock.Add(15);
+ ADC16(ref HL.reg, BC.reg);
+ break;
+
+ case 0x4b: // LD BC,(nnnn)
+ clock.Add(20);
+ addr = FetchWord();
+ BC.low = memory.Read(addr++);
+ BC.high = memory.Read(addr);
+ break;
+
+ case 0x4c: // NEG
+ clock.Add(8);
+ b = A;
+ A = 0;
+ SUB8(b);
+ break;
+
+ case 0x4d: // RETI
+ clock.Add(14);
+ IFF1 = IFF2;
+ PC = POP();
+ break;
+
+ case 0x4e: // IM 0/1
+ clock.Add(8);
+ IM = 0;
+ break;
+
+ case 0x4f: // LD R,A
+ clock.Add(9);
+ R = A;
+ break;
+
+ case 0x50: // IN D,(C)
+ clock.Add(12);
+ DE.high = device.Read(BC.reg);
+ F = Z80Flags.Carry | PSZtable[DE.high] | H35table[DE.high];
+ break;
+
+ case 0x51: // OUT (C),D
+ clock.Add(12);
+ device.Write(BC.reg, DE.high);
+ break;
+
+ default:
+ break;
+ }
}
}
}