From a937b96b20e61cd0770119da3327c15575779793 Mon Sep 17 00:00:00 2001 From: Ian C Date: Tue, 28 Feb 2012 23:22:49 +0000 Subject: Added ability to set/get the state of Z80 registers. --- src/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs | 163 +++++++++++++++++++++++++- 1 file changed, 160 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs b/src/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs index f937ea9..676a1b1 100644 --- a/src/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs +++ b/src/Noddybox.Emulation.EightBit.Z80/Z80Cpu.cs @@ -72,14 +72,14 @@ namespace Noddybox.Emulation.EightBit.Z80 // Auxilliary registers and flags // - private ushort I; + private byte I; private byte R; private bool IFF1; private bool IFF2; private bool raise; private bool nmi; private byte devbyte; - private int IM; + private byte IM; private bool HALT; private int shift; @@ -126,7 +126,7 @@ namespace Noddybox.Emulation.EightBit.Z80 case 2: PUSH(PC); - PC = (ushort)((I << 8) + devbyte); + PC = (ushort)(((ushort)I << 8) + devbyte); break; default: @@ -287,6 +287,163 @@ namespace Noddybox.Emulation.EightBit.Z80 #endregion + #region Public members + + /// + /// Set/get the current state of the accumulator. + /// + public byte Acummulator + { + get {return A;} + set {A = value;} + } + + /// + /// Set/get the current state of the flag register. + /// + public Z80Flags StatusFlags + { + get {return F;} + set {F = value;} + } + + /// + /// The current state of the BC register pair. + /// + public Register16 BC_Register + { + get { return BC; } + set { BC = value; } + } + + /// + /// The current state of the DE register pair. + /// + public Register16 DE_Register + { + get { return DE; } + set { DE = value; } + } + + /// + /// The current state of the HL register pair. + /// + public Register16 HL_Register + { + get { return HL; } + set { HL = value; } + } + + /// + /// The current state of the stack pointer. + /// + public ushort StackPointer + { + get { return SP; } + set { SP = value; } + } + + /// + /// The current state of the program counter. + /// + public ushort ProgramCounter + { + get { return PC; } + set { PC = value; } + } + + /// + /// The alternate AF' register. + /// + public Register16 AF_Alternate + { + get { return AF_; } + set { AF_ = value; } + } + + /// + /// The alternate BC' register. + /// + public Register16 BC_Alternate + { + get { return BC_; } + set { BC_ = value; } + } + + /// + /// The alternate DE' register. + /// + public Register16 DE_Alternate + { + get { return DE_; } + set { DE_ = value; } + } + + /// + /// The alternate HL' register. + /// + public Register16 HL_Alternate + { + get { return HL_; } + set { HL_ = value; } + } + + /// + /// The state of the HALT line. + /// + public bool HaltLine + { + get { return HALT; } + set { HALT = value; } + } + + /// + /// The state of the IFF1 register. + /// + public bool IFF1_Regsiter + { + get { return IFF1; } + set { IFF1 = value; } + } + + /// + /// The state of the IFF2 register. + /// + public bool IFF2_Regsiter + { + get { return IFF2; } + set { IFF2 = value; } + } + + /// + /// The state of the IM register. + /// + public byte IM_Register + { + get { return IM; } + set { IM = value; } + } + + /// + /// The state of the RAM refresh register. + /// + public byte Refresh + { + get { return R; } + set { R = value; } + } + + /// + /// The state of the interrupt vector register. + /// + public byte InterruptVector + { + get { return I; } + set { I = value; } + } + + #endregion + #region Events /// -- cgit v1.2.3