public SBC(Gameboy parent, byte opcode) : base(parent) { source = OpcodeUtils.BitsToRegister(opcode & 0b111); Cycles = source == Register.M ? 8 : 4; Disassembly = "sbc " + (source == Register.M ? "[hl]" : OpcodeUtils.RegisterToString(source)); }
public ADD16(Gameboy parent, byte opcode) : base(parent) { source = OpcodeUtils.BitsToRegister16((opcode & 0b110000) >> 4); Disassembly = "add hl, " + OpcodeUtils.Register16ToString(source); Cycles = 8; }
public INC16(Gameboy parent, byte opcode) : base(parent) { target = OpcodeUtils.BitsToRegister16((opcode & 0b1110000) >> 4); Cycles = 8; Disassembly = "inc " + OpcodeUtils.Register16ToString(target); }
public DEC(Gameboy parent, byte opcode) : base(parent) { target = OpcodeUtils.BitsToRegister((opcode & 0b111000) >> 3); Cycles = target == Register.M ? 12 : 4; TickAccurate = target == Register.M; Disassembly = "dec " + (target == Register.M ? "[hl]" : OpcodeUtils.RegisterToString(target)); }
public CRET(Gameboy parent, byte opcode) : base(parent) { cFlagSet = (opcode & 0b1000) > 0; cFlag = (opcode & 0b10000) > 0 ? Flag.Carry : Flag.Zero; Cycles = 20; Disassembly = "ret " + (cFlagSet ? "" : "n") + OpcodeUtils.FlagToString(cFlag); }
public SWAP(Gameboy parent, byte opcode) : base(parent) { target = OpcodeUtils.BitsToRegister(opcode & 0b111); Length = 2; Cycles = (target == Register.M) ? 16 : 8; TickAccurate = target == Register.M; Disassembly = "swap " + (target == Register.M ? "[hl]" : OpcodeUtils.RegisterToString(target)); }
public PSL(Gameboy parent, byte opcode) : base(parent) { target = OpcodeUtils.BitsToRegister(opcode & 0b111); Length = 2; Cycles = target == Register.M ? 16 : 8; TickAccurate = target == Register.M; Disassembly = "srl " + OpcodeUtils.RegisterToString(target); }
public CJR(Gameboy parent, byte opcode) : base(parent) { cFlagSet = (opcode & 0b1000) > 0; cFlag = (opcode & 0b10000) > 0 ? Flag.Carry : Flag.Zero; Length = 2; Cycles = 12; Disassembly = "jr " + (cFlagSet ? "" : "n") + OpcodeUtils.FlagToString(cFlag) + ", $" + (parent.PC + (sbyte)parent.Memory[parent.PC + 1] + 2).ToString("X4"); }
public LDA(Gameboy parent, byte opcode) : base(parent) { load = (opcode & 0b1000) > 0; regpair = (opcode & 0b10000) > 0 ? Register16.DE : Register16.BC; Cycles = 8; TickAccurate = true; Disassembly = load ? "ld a, [" + OpcodeUtils.Register16ToString(regpair) + "]" : "ld [" + OpcodeUtils.Register16ToString(regpair) + "], a"; }
public CCALL(Gameboy parent, byte opcode) : base(parent) { cFlagSet = (opcode & 0b1000) > 0; cFlag = (opcode & 0b10000) > 0 ? Flag.Carry : Flag.Zero; Length = 3; Cycles = 24; Disassembly = "call " + (cFlagSet ? "" : "n") + OpcodeUtils.FlagToString(cFlag) + ", $" + (parent.Memory[parent.PC + 1] + (parent.Memory[parent.PC + 2] << 8)).ToString("X1"); }
public PSA(Gameboy parent, byte opcode) : base(parent) { left = (opcode & 0b1000) == 0; target = OpcodeUtils.BitsToRegister(opcode & 0b111); Length = 2; Cycles = target == Register.M ? 16 : 8; TickAccurate = target == Register.M; Disassembly = (left ? "sla" : "sra") + " " + OpcodeUtils.RegisterToString(target); }
public LDI(Gameboy parent, byte opcode) : base(parent) { target = OpcodeUtils.BitsToRegister((opcode & 0b111000) >> 3); Cycles = target == Register.M ? 12 : 8; Length = 2; TickAccurate = true; actionTick = target == Register.M ? 7 : 3; Disassembly = "ld " + (target == Register.M ? "[hl]" : OpcodeUtils.RegisterToString(target)) + ", $" + parent.Memory[parent.PC + 1].ToString("X2"); }
public POP(Gameboy parent, byte opcode) : base(parent) { target = OpcodeUtils.BitsToRegister16((opcode & 0b110000) >> 4); if (target == Register16.SP) { target = Register16.AF; } Cycles = 12; Disassembly = "pop " + OpcodeUtils.Register16ToString(target); }
public PRT(Gameboy parent, byte opcode) : base(parent) { left = (opcode & 0b1000) == 0; useCarry = (opcode & 0b10000) > 0; target = OpcodeUtils.BitsToRegister(opcode & 0b111); Length = 2; Cycles = (target == Register.M) ? 16 : 8; TickAccurate = target == Register.M; Disassembly = (left ? "rl" : "rr") + (useCarry ? "c" : "") + " " + OpcodeUtils.RegisterToString(target); }
public LD16(Gameboy parent, byte opcode) : base(parent) { target = OpcodeUtils.BitsToRegister16((opcode & 0b110000) >> 4); targetLow = target == Register16.BC ? Register.C : target == Register16.DE ? Register.E : Register.L; targetHigh = target == Register16.BC ? Register.B : target == Register16.DE ? Register.D : Register.H; Cycles = 12; Length = 3; TickAccurate = true; Disassembly = "ld " + OpcodeUtils.Register16ToString(target) + ", $" + (parent.Memory[parent.PC + 1] + (parent.Memory[parent.PC + 2] << 8)).ToString("X2"); }
public PUSH(Gameboy parent, byte opcode) : base(parent) { source = OpcodeUtils.BitsToRegister16((opcode & 0b110000) >> 4); if (source == Register16.SP) { source = Register16.AF; } Cycles = 16; Disassembly = "push " + OpcodeUtils.Register16ToString(source); }
public LD(Gameboy parent, byte opcode) : base(parent) { source = OpcodeUtils.BitsToRegister(opcode & 0b111); target = OpcodeUtils.BitsToRegister((opcode & 0b111000) >> 3); Cycles = source == Register.M || target == Register.M ? 8 : 4; if (target == Register.M || source == Register.M) { TickAccurate = true; } Disassembly = "ld " + (target == Register.M ? "[hl]" : OpcodeUtils.RegisterToString(target)) + ", " + (source == Register.M ? "[hl]" : OpcodeUtils.RegisterToString(source)); }
public BIT(Gameboy parent, byte opcode) : base(parent) { target = OpcodeUtils.BitsToRegister(opcode & 0b111); bit = (byte)((opcode & 0b111000) >> 3); Cycles = target == Register.M ? 12 : 8; Length = 2; TickAccurate = true; actionTick = 4; Disassembly = "bit $" + bit.ToString("X2") + ", " + (target == Register.M ? "[hl]" : OpcodeUtils.RegisterToString(target)); }