public void SetFlagsForPrimaryOpcode(PrimaryOpcode opcode, byte initialValue, byte newValue)
        {
            AffectedFlags affectedFlags;

            affectedFlags = opcodeFlags.GetAffectedFlagsByPrimaryOpcode(opcode);
            UpdateFlags(affectedFlags, initialValue, newValue);
        }
Beispiel #2
0
 public AffectedFlags GetAffectedFlagsByPrimaryOpcode(PrimaryOpcode opcode)
 {
     return(primaryOpcodeAffectedFlags[opcode]);
 }
 public DataCacheInstruction(int address, PrimaryOpcode primary, SecondaryOpcode secondary, int rA, int rB)
     : base(address)
 {
     ByteCode = ((int)primary << 26 | rA << 16 | rB << 11 | (int)secondary << 1);
 }
Beispiel #4
0
        private int ProcessPrimaryOpcode(PrimaryOpcode opcode)
        {
            branchTaken = false;

            switch (opcode)
            {
            case PrimaryOpcode.NOP:
                break;

            case PrimaryOpcode.STOP:
                break;

            case PrimaryOpcode.HALT:
                break;

            case PrimaryOpcode.PREFIX_CB:
                break;

            case PrimaryOpcode.DI: DisableInterrupts(); break;

            case PrimaryOpcode.EI: EnableInterrupts(); break;

            case PrimaryOpcode.PUSH_BC: Push(Register16Bit.BC); break;

            case PrimaryOpcode.PUSH_DE: Push(Register16Bit.DE); break;

            case PrimaryOpcode.PUSH_HL: Push(Register16Bit.HL); break;

            case PrimaryOpcode.PUSH_AF: Push(Register16Bit.AF); break;

            case PrimaryOpcode.POP_BC: Pop(Register16Bit.BC); break;

            case PrimaryOpcode.POP_DE: Pop(Register16Bit.DE); break;

            case PrimaryOpcode.POP_HL: Pop(Register16Bit.HL); break;

            case PrimaryOpcode.POP_AF: Pop(Register16Bit.AF); break;

            case PrimaryOpcode.LD_BC_u16: LoadIntoRegister(Register16Bit.BC, ReadNextWordFromMemory()); break;

            case PrimaryOpcode.LD_DE_u16: LoadIntoRegister(Register16Bit.DE, ReadNextWordFromMemory()); break;

            case PrimaryOpcode.LD_HL_u16: LoadIntoRegister(Register16Bit.HL, ReadNextWordFromMemory()); break;

            case PrimaryOpcode.LD_SP_u16: LoadIntoRegister(Register16Bit.SP, ReadNextWordFromMemory()); break;

            case PrimaryOpcode.LD_HL_SPplusi8: LoadIntoRegister(Register16Bit.HL, registers.SP + ReadNextSignedByteFromMemory()); break;

            case PrimaryOpcode.LD_mu16_SP: LoadIntoMemory(ReadNextWordFromMemory(), registers.SP); break;

            case PrimaryOpcode.LD_SP_HL: LoadIntoRegister(Register16Bit.SP, registers.HL); break;

            case PrimaryOpcode.LD_B_u8: LoadIntoRegister(Register8Bit.B, ReadNextByteFromMemory()); break;

            case PrimaryOpcode.LD_C_u8: LoadIntoRegister(Register8Bit.C, ReadNextByteFromMemory()); break;

            case PrimaryOpcode.LD_D_u8: LoadIntoRegister(Register8Bit.D, ReadNextByteFromMemory()); break;

            case PrimaryOpcode.LD_E_u8: LoadIntoRegister(Register8Bit.E, ReadNextByteFromMemory()); break;

            case PrimaryOpcode.LD_H_u8: LoadIntoRegister(Register8Bit.H, ReadNextByteFromMemory()); break;

            case PrimaryOpcode.LD_L_u8: LoadIntoRegister(Register8Bit.L, ReadNextByteFromMemory()); break;

            case PrimaryOpcode.LD_A_u8: LoadIntoRegister(Register8Bit.A, ReadNextByteFromMemory()); break;

            case PrimaryOpcode.LD_mBC_A: LoadIntoMemory(registers.BC, registers.A); break;

            case PrimaryOpcode.LD_mDE_A: LoadIntoMemory(registers.DE, registers.A); break;

            case PrimaryOpcode.LD_mHL_u8: LoadIntoMemory(registers.HL, ReadNextByteFromMemory()); break;

            case PrimaryOpcode.LD_mHLplus_A: LoadIntoMemory(registers.HL + 1, registers.A); break;

            case PrimaryOpcode.LD_mHLminus_A: LoadIntoMemory(registers.HL - 1, registers.A); break;

            case PrimaryOpcode.LD_A_mBC: LoadIntoRegister(Register8Bit.A, ReadByte(registers.BC)); break;

            case PrimaryOpcode.LD_A_mDE: LoadIntoRegister(Register8Bit.A, ReadByte(registers.DE)); break;

            case PrimaryOpcode.LD_A_mHLplus: LoadIntoRegister(Register8Bit.A, ReadByte(registers.HL + 1)); break;

            case PrimaryOpcode.LD_A_mHLminus: LoadIntoRegister(Register8Bit.A, ReadByte(registers.HL - 1)); break;

            case PrimaryOpcode.LD_B_B: LoadIntoRegister(Register8Bit.B, registers.B); break;

            case PrimaryOpcode.LD_B_C: LoadIntoRegister(Register8Bit.B, registers.C); break;

            case PrimaryOpcode.LD_B_D: LoadIntoRegister(Register8Bit.B, registers.D); break;

            case PrimaryOpcode.LD_B_E: LoadIntoRegister(Register8Bit.B, registers.E); break;

            case PrimaryOpcode.LD_B_H: LoadIntoRegister(Register8Bit.B, registers.H); break;

            case PrimaryOpcode.LD_B_L: LoadIntoRegister(Register8Bit.B, registers.L); break;

            case PrimaryOpcode.LD_B_A: LoadIntoRegister(Register8Bit.B, registers.A); break;

            case PrimaryOpcode.LD_C_B: LoadIntoRegister(Register8Bit.C, registers.B); break;

            case PrimaryOpcode.LD_C_C: LoadIntoRegister(Register8Bit.C, registers.C); break;

            case PrimaryOpcode.LD_C_D: LoadIntoRegister(Register8Bit.C, registers.D); break;

            case PrimaryOpcode.LD_C_E: LoadIntoRegister(Register8Bit.C, registers.E); break;

            case PrimaryOpcode.LD_C_H: LoadIntoRegister(Register8Bit.C, registers.H); break;

            case PrimaryOpcode.LD_C_L: LoadIntoRegister(Register8Bit.C, registers.L); break;

            case PrimaryOpcode.LD_C_A: LoadIntoRegister(Register8Bit.C, registers.A); break;

            case PrimaryOpcode.LD_D_B: LoadIntoRegister(Register8Bit.D, registers.B); break;

            case PrimaryOpcode.LD_D_C: LoadIntoRegister(Register8Bit.D, registers.C); break;

            case PrimaryOpcode.LD_D_D: LoadIntoRegister(Register8Bit.D, registers.D); break;

            case PrimaryOpcode.LD_D_E: LoadIntoRegister(Register8Bit.D, registers.E); break;

            case PrimaryOpcode.LD_D_H: LoadIntoRegister(Register8Bit.D, registers.H); break;

            case PrimaryOpcode.LD_D_L: LoadIntoRegister(Register8Bit.D, registers.L); break;

            case PrimaryOpcode.LD_D_A: LoadIntoRegister(Register8Bit.D, registers.A); break;

            case PrimaryOpcode.LD_E_B: LoadIntoRegister(Register8Bit.E, registers.B); break;

            case PrimaryOpcode.LD_E_C: LoadIntoRegister(Register8Bit.E, registers.C); break;

            case PrimaryOpcode.LD_E_D: LoadIntoRegister(Register8Bit.E, registers.D); break;

            case PrimaryOpcode.LD_E_E: LoadIntoRegister(Register8Bit.E, registers.E); break;

            case PrimaryOpcode.LD_E_H: LoadIntoRegister(Register8Bit.E, registers.H); break;

            case PrimaryOpcode.LD_E_L: LoadIntoRegister(Register8Bit.E, registers.L); break;

            case PrimaryOpcode.LD_E_A: LoadIntoRegister(Register8Bit.E, registers.A); break;

            case PrimaryOpcode.LD_H_B: LoadIntoRegister(Register8Bit.H, registers.B); break;

            case PrimaryOpcode.LD_H_C: LoadIntoRegister(Register8Bit.H, registers.C); break;

            case PrimaryOpcode.LD_H_D: LoadIntoRegister(Register8Bit.H, registers.D); break;

            case PrimaryOpcode.LD_H_E: LoadIntoRegister(Register8Bit.H, registers.E); break;

            case PrimaryOpcode.LD_H_H: LoadIntoRegister(Register8Bit.H, registers.H); break;

            case PrimaryOpcode.LD_H_L: LoadIntoRegister(Register8Bit.H, registers.L); break;

            case PrimaryOpcode.LD_H_A: LoadIntoRegister(Register8Bit.H, registers.A); break;

            case PrimaryOpcode.LD_L_B: LoadIntoRegister(Register8Bit.L, registers.B); break;

            case PrimaryOpcode.LD_L_C: LoadIntoRegister(Register8Bit.L, registers.C); break;

            case PrimaryOpcode.LD_L_D: LoadIntoRegister(Register8Bit.L, registers.D); break;

            case PrimaryOpcode.LD_L_E: LoadIntoRegister(Register8Bit.L, registers.E); break;

            case PrimaryOpcode.LD_L_H: LoadIntoRegister(Register8Bit.L, registers.H); break;

            case PrimaryOpcode.LD_L_L: LoadIntoRegister(Register8Bit.L, registers.L); break;

            case PrimaryOpcode.LD_L_A: LoadIntoRegister(Register8Bit.L, registers.A); break;

            case PrimaryOpcode.LD_A_B: LoadIntoRegister(Register8Bit.A, registers.B); break;

            case PrimaryOpcode.LD_A_C: LoadIntoRegister(Register8Bit.A, registers.C); break;

            case PrimaryOpcode.LD_A_D: LoadIntoRegister(Register8Bit.A, registers.D); break;

            case PrimaryOpcode.LD_A_E: LoadIntoRegister(Register8Bit.A, registers.E); break;

            case PrimaryOpcode.LD_A_H: LoadIntoRegister(Register8Bit.A, registers.H); break;

            case PrimaryOpcode.LD_A_L: LoadIntoRegister(Register8Bit.A, registers.L); break;

            case PrimaryOpcode.LD_A_A: LoadIntoRegister(Register8Bit.A, registers.A); break;

            case PrimaryOpcode.LD_B_mHL: LoadIntoRegister(Register8Bit.B, ReatByteAtHL()); break;

            case PrimaryOpcode.LD_C_mHL: LoadIntoRegister(Register8Bit.C, ReatByteAtHL()); break;

            case PrimaryOpcode.LD_D_mHL: LoadIntoRegister(Register8Bit.D, ReatByteAtHL()); break;

            case PrimaryOpcode.LD_E_mHL: LoadIntoRegister(Register8Bit.E, ReatByteAtHL()); break;

            case PrimaryOpcode.LD_H_mHL: LoadIntoRegister(Register8Bit.H, ReatByteAtHL()); break;

            case PrimaryOpcode.LD_L_mHL: LoadIntoRegister(Register8Bit.L, ReatByteAtHL()); break;

            case PrimaryOpcode.LD_A_mHL: LoadIntoRegister(Register8Bit.A, ReatByteAtHL()); break;

            case PrimaryOpcode.LD_mHL_B: LoadIntoMemory(registers.HL, registers.B); break;

            case PrimaryOpcode.LD_mHL_C: LoadIntoMemory(registers.HL, registers.C); break;

            case PrimaryOpcode.LD_mHL_D: LoadIntoMemory(registers.HL, registers.D); break;

            case PrimaryOpcode.LD_mHL_E: LoadIntoMemory(registers.HL, registers.E); break;

            case PrimaryOpcode.LD_mHL_H: LoadIntoMemory(registers.HL, registers.H); break;

            case PrimaryOpcode.LD_mHL_L: LoadIntoMemory(registers.HL, registers.L); break;

            case PrimaryOpcode.LD_mHL_A: LoadIntoMemory(registers.HL, registers.A); break;

            case PrimaryOpcode.LD_mFF00plusu8_A: LoadIntoMemory(0xFF00 + ReadNextByteFromMemory(), registers.A); break;

            case PrimaryOpcode.LD_mFF00plusC_A: LoadIntoMemory(0xFF00 + registers.C, registers.A); break;

            case PrimaryOpcode.LD_mu16_A: LoadIntoMemory(ReadNextWordFromMemory(), registers.A); break;

            case PrimaryOpcode.LD_A_mFF00plusu8: LoadIntoRegister(Register8Bit.A, ReadByte(0xFF00 + ReadNextByteFromMemory())); break;

            case PrimaryOpcode.LD_A_mFF00plusC: LoadIntoRegister(Register8Bit.A, ReadByte(0xFF00 + registers.C)); break;

            case PrimaryOpcode.LD_A_mu16: LoadIntoRegister(Register8Bit.A, ReadByte(ReadNextWordFromMemory())); break;

            case PrimaryOpcode.INC_BC: IncrementRegister(Register16Bit.BC); break;

            case PrimaryOpcode.INC_DE: IncrementRegister(Register16Bit.DE); break;

            case PrimaryOpcode.INC_HL: IncrementRegister(Register16Bit.HL); break;

            case PrimaryOpcode.INC_SP: IncrementRegister(Register16Bit.SP); break;

            case PrimaryOpcode.INC_B: IncrementRegister(Register8Bit.B); break;

            case PrimaryOpcode.INC_C: IncrementRegister(Register8Bit.C); break;

            case PrimaryOpcode.INC_D: IncrementRegister(Register8Bit.D); break;

            case PrimaryOpcode.INC_E: IncrementRegister(Register8Bit.E); break;

            case PrimaryOpcode.INC_H: IncrementRegister(Register8Bit.H); break;

            case PrimaryOpcode.INC_L: IncrementRegister(Register8Bit.L); break;

            case PrimaryOpcode.INC_A: IncrementRegister(Register8Bit.A); break;

            case PrimaryOpcode.INC_mHL: IncrementMemoryValue(registers.HL); break;

            case PrimaryOpcode.DEC_BC: DecrementRegister(Register16Bit.BC); break;

            case PrimaryOpcode.DEC_DE: DecrementRegister(Register16Bit.DE); break;

            case PrimaryOpcode.DEC_HL: DecrementRegister(Register16Bit.HL); break;

            case PrimaryOpcode.DEC_SP: DecrementRegister(Register16Bit.SP); break;

            case PrimaryOpcode.DEC_B: DecrementRegister(Register8Bit.B); break;

            case PrimaryOpcode.DEC_C: DecrementRegister(Register8Bit.C); break;

            case PrimaryOpcode.DEC_D: DecrementRegister(Register8Bit.D); break;

            case PrimaryOpcode.DEC_E: DecrementRegister(Register8Bit.E); break;

            case PrimaryOpcode.DEC_H: DecrementRegister(Register8Bit.H); break;

            case PrimaryOpcode.DEC_L: DecrementRegister(Register8Bit.L); break;

            case PrimaryOpcode.DEC_A: DecrementRegister(Register8Bit.A); break;

            case PrimaryOpcode.DEC_mHL: DecrementMemoryValue(registers.HL); break;

            case PrimaryOpcode.ADD_HL_BC: AddValueToRegister(Register16Bit.HL, registers.BC); break;

            case PrimaryOpcode.ADD_HL_DE: AddValueToRegister(Register16Bit.HL, registers.DE); break;

            case PrimaryOpcode.ADD_HL_HL: AddValueToRegister(Register16Bit.HL, registers.HL); break;

            case PrimaryOpcode.ADD_HL_SP: AddValueToRegister(Register16Bit.HL, registers.SP); break;

            case PrimaryOpcode.ADD_SP_i8: AddValueToRegister(Register16Bit.SP, ReadNextSignedByteFromMemory()); break;

            case PrimaryOpcode.ADD_A_B: AddValueToA(registers.B); break;

            case PrimaryOpcode.ADD_A_C: AddValueToA(registers.C); break;

            case PrimaryOpcode.ADD_A_D: AddValueToA(registers.D); break;

            case PrimaryOpcode.ADD_A_E: AddValueToA(registers.E); break;

            case PrimaryOpcode.ADD_A_H: AddValueToA(registers.H); break;

            case PrimaryOpcode.ADD_A_L: AddValueToA(registers.L); break;

            case PrimaryOpcode.ADD_A_A: AddValueToA(registers.A); break;

            case PrimaryOpcode.ADD_A_mHL: AddValueToA(ReatByteAtHL()); break;

            case PrimaryOpcode.ADD_A_u8: AddValueToA(ReadNextByteFromMemory()); break;

            case PrimaryOpcode.ADC_A_B: AddValueToAWithCarry(registers.B); break;

            case PrimaryOpcode.ADC_A_C: AddValueToAWithCarry(registers.C); break;

            case PrimaryOpcode.ADC_A_D: AddValueToAWithCarry(registers.D); break;

            case PrimaryOpcode.ADC_A_E: AddValueToAWithCarry(registers.E); break;

            case PrimaryOpcode.ADC_A_H: AddValueToAWithCarry(registers.H); break;

            case PrimaryOpcode.ADC_A_L: AddValueToAWithCarry(registers.L); break;

            case PrimaryOpcode.ADC_A_A: AddValueToAWithCarry(registers.A); break;

            case PrimaryOpcode.ADC_A_mHL: AddValueToAWithCarry(ReatByteAtHL()); break;

            case PrimaryOpcode.ADC_A_u8: AddValueToAWithCarry(ReadNextByteFromMemory()); break;

            case PrimaryOpcode.SUB_A_B: SubtractValueFromA(registers.B); break;

            case PrimaryOpcode.SUB_A_C: SubtractValueFromA(registers.C); break;

            case PrimaryOpcode.SUB_A_D: SubtractValueFromA(registers.D); break;

            case PrimaryOpcode.SUB_A_E: SubtractValueFromA(registers.E); break;

            case PrimaryOpcode.SUB_A_H: SubtractValueFromA(registers.H); break;

            case PrimaryOpcode.SUB_A_L: SubtractValueFromA(registers.L); break;

            case PrimaryOpcode.SUB_A_A: SubtractValueFromA(registers.A); break;

            case PrimaryOpcode.SUB_A_mHL: SubtractValueFromA(ReatByteAtHL()); break;

            case PrimaryOpcode.SUB_A_u8: SubtractValueFromA(ReadNextByteFromMemory()); break;

            case PrimaryOpcode.SBC_A_B: SubtractValueFromAWithCarry(registers.B); break;

            case PrimaryOpcode.SBC_A_C: SubtractValueFromAWithCarry(registers.C); break;

            case PrimaryOpcode.SBC_A_D: SubtractValueFromAWithCarry(registers.D); break;

            case PrimaryOpcode.SBC_A_E: SubtractValueFromAWithCarry(registers.E); break;

            case PrimaryOpcode.SBC_A_H: SubtractValueFromAWithCarry(registers.H); break;

            case PrimaryOpcode.SBC_A_L: SubtractValueFromAWithCarry(registers.L); break;

            case PrimaryOpcode.SBC_A_A: SubtractValueFromAWithCarry(registers.A); break;

            case PrimaryOpcode.SBC_A_mHL: SubtractValueFromAWithCarry(ReatByteAtHL()); break;

            case PrimaryOpcode.SBC_A_u8: SubtractValueFromAWithCarry(ReadNextByteFromMemory()); break;

            case PrimaryOpcode.AND_A_B: AndValueWithA(registers.B); break;

            case PrimaryOpcode.AND_A_C: AndValueWithA(registers.C); break;

            case PrimaryOpcode.AND_A_D: AndValueWithA(registers.D); break;

            case PrimaryOpcode.AND_A_E: AndValueWithA(registers.E); break;

            case PrimaryOpcode.AND_A_H: AndValueWithA(registers.H); break;

            case PrimaryOpcode.AND_A_L: AndValueWithA(registers.L); break;

            case PrimaryOpcode.AND_A_A: AndValueWithA(registers.L); break;

            case PrimaryOpcode.AND_A_mHL: AndValueWithA(ReatByteAtHL()); break;

            case PrimaryOpcode.AND_A_u8: AndValueWithA(ReadNextByteFromMemory()); break;

            case PrimaryOpcode.XOR_A_B: XorValueWithA(registers.B); break;

            case PrimaryOpcode.XOR_A_C: XorValueWithA(registers.C); break;

            case PrimaryOpcode.XOR_A_D: XorValueWithA(registers.D); break;

            case PrimaryOpcode.XOR_A_E: XorValueWithA(registers.E); break;

            case PrimaryOpcode.XOR_A_H: XorValueWithA(registers.H); break;

            case PrimaryOpcode.XOR_A_L: XorValueWithA(registers.L); break;

            case PrimaryOpcode.XOR_A_A: XorValueWithA(registers.A); break;

            case PrimaryOpcode.XOR_A_mHL: XorValueWithA(ReatByteAtHL()); break;

            case PrimaryOpcode.XOR_A_u8: XorValueWithA(ReadNextByteFromMemory()); break;

            case PrimaryOpcode.OR_A_B: OrValueWithA(registers.B); break;

            case PrimaryOpcode.OR_A_C: OrValueWithA(registers.C); break;

            case PrimaryOpcode.OR_A_D: OrValueWithA(registers.D); break;

            case PrimaryOpcode.OR_A_E: OrValueWithA(registers.E); break;

            case PrimaryOpcode.OR_A_H: OrValueWithA(registers.H); break;

            case PrimaryOpcode.OR_A_L: OrValueWithA(registers.L); break;

            case PrimaryOpcode.OR_A_A: OrValueWithA(registers.A); break;

            case PrimaryOpcode.OR_A_mHL: OrValueWithA(ReatByteAtHL()); break;

            case PrimaryOpcode.OR_A_u8: OrValueWithA(ReadNextByteFromMemory()); break;

            case PrimaryOpcode.CP_A_B: CompareValueWithA(registers.B); break;

            case PrimaryOpcode.CP_A_C: CompareValueWithA(registers.C); break;

            case PrimaryOpcode.CP_A_D: CompareValueWithA(registers.D); break;

            case PrimaryOpcode.CP_A_E: CompareValueWithA(registers.E); break;

            case PrimaryOpcode.CP_A_H: CompareValueWithA(registers.H); break;

            case PrimaryOpcode.CP_A_L: CompareValueWithA(registers.L); break;

            case PrimaryOpcode.CP_A_A: CompareValueWithA(registers.A); break;

            case PrimaryOpcode.CP_A_mHL: CompareValueWithA(ReatByteAtHL()); break;

            case PrimaryOpcode.CP_A_u8: CompareValueWithA(ReadNextByteFromMemory()); break;

            case PrimaryOpcode.RLCA: RotateLeftWithCarry(Register8Bit.A); break;

            case PrimaryOpcode.RRCA: RotateRightWithCarry(Register8Bit.A); break;

            case PrimaryOpcode.RLA: RotateLeft(Register8Bit.A); break;

            case PrimaryOpcode.RRA: RotateRight(Register8Bit.A); break;

            case PrimaryOpcode.JR_i8: JumpRelative(ReadNextSignedByteFromMemory()); break;

            case PrimaryOpcode.JR_NZ_i8: JumpRelative(ReadNextSignedByteFromMemory(), !flags.ZeroFlag); break;

            case PrimaryOpcode.JR_Z_i8: JumpRelative(ReadNextSignedByteFromMemory(), flags.ZeroFlag); break;

            case PrimaryOpcode.JR_NC_i8: JumpRelative(ReadNextSignedByteFromMemory(), !flags.CarryFlag); break;

            case PrimaryOpcode.JR_C_i8: JumpRelative(ReadNextSignedByteFromMemory(), flags.CarryFlag); break;

            case PrimaryOpcode.JP_u16: Jump(ReadNextWordFromMemory()); break;

            case PrimaryOpcode.JP_NZ_u16: Jump(ReadNextWordFromMemory(), !flags.ZeroFlag); break;

            case PrimaryOpcode.JP_Z_u16: Jump(ReadNextWordFromMemory(), flags.ZeroFlag); break;

            case PrimaryOpcode.JP_NC_u16: Jump(ReadNextWordFromMemory(), !flags.CarryFlag); break;

            case PrimaryOpcode.JP_C_u16: Jump(ReadNextWordFromMemory(), flags.CarryFlag); break;

            case PrimaryOpcode.JP_HL: Jump(registers.HL); break;

            case PrimaryOpcode.CALL_u16: Call(ReadNextWordFromMemory()); break;

            case PrimaryOpcode.CALL_NZ_u16: Call(ReadNextWordFromMemory(), !flags.ZeroFlag); break;

            case PrimaryOpcode.CALL_Z_u16: Call(ReadNextWordFromMemory(), flags.ZeroFlag); break;

            case PrimaryOpcode.CALL_NC_u16: Call(ReadNextWordFromMemory(), !flags.CarryFlag); break;

            case PrimaryOpcode.CALL_C_u16: Call(ReadNextWordFromMemory(), flags.CarryFlag); break;

            case PrimaryOpcode.RET: Return(); break;

            case PrimaryOpcode.RET_NZ: Return(!flags.ZeroFlag); break;

            case PrimaryOpcode.RET_Z: Return(flags.ZeroFlag); break;

            case PrimaryOpcode.RET_NC: Return(!flags.CarryFlag); break;

            case PrimaryOpcode.RET_C: Return(flags.CarryFlag); break;

            case PrimaryOpcode.RETI: ReturnFromInterrupt(); break;

            case PrimaryOpcode.RST_00h: Restart(0x00); break;

            case PrimaryOpcode.RST_08h: Restart(0x08); break;

            case PrimaryOpcode.RST_10h: Restart(0x10); break;

            case PrimaryOpcode.RST_18h: Restart(0x18); break;

            case PrimaryOpcode.RST_20h: Restart(0x20); break;

            case PrimaryOpcode.RST_28h: Restart(0x28); break;

            case PrimaryOpcode.RST_30h: Restart(0x30); break;

            case PrimaryOpcode.RST_38h: Restart(0x38); break;

            case PrimaryOpcode.DAA: DecimalAdjustAccumulator(); break;

            case PrimaryOpcode.CPL: InvertA(); break;

            case PrimaryOpcode.SCF: SetCarryFlag(true); break;

            case PrimaryOpcode.CCF: SetCarryFlag(!flags.CarryFlag); break;
            }

            return(opcodeCycles.GetNumCyclesByPrimaryOpcode(opcode, branchTaken));
        }
 public void SetFlagsForPrimaryOpcode(PrimaryOpcode opcode, ushort initialValue, ushort newValue)
 {
     SetFlagsForPrimaryOpcode(opcode, (byte)(initialValue >> 8), (byte)(newValue >> 8));
 }