private static void TestReturn(PrimaryOpCode op, FlagTest flagTest, int machineCycles = 1, int throttlingStates = 5, bool gameboy = true) { using (var fixture = new DecodeFixture(machineCycles, throttlingStates, op).DoNotHalt().ThrowOnGameboy(!gameboy)) { fixture.Expected.OpCode(OpCode.Return).FlagTest(flagTest); } }
private static void Test(PrimaryOpCode op, OpCode expected) { using (var fixture = new DecodeFixture(1, 4, op)) { fixture.Expected.OpCode(expected).Operands(Operand.A).UseAlternativeFlagAffection(); } }
private static void TestStackOperation(PrimaryOpCode op, Operand qq, OpCode expected = OpCode.Push, int machineCycles = 3, int throttlineStates = 11) { using (var fixture = new DecodeFixture(machineCycles, throttlineStates, op)) { fixture.Expected.OpCode(expected).Operands(qq); } }
public void DEC_ss(PrimaryOpCode op, Operand s) { using (var fixture = new DecodeFixture(1, 6, op)) { fixture.Expected.OpCode(OpCode.Decrement16).Operands(s); } }
private static void TestZ80StackOperation(PrimaryOpCode op, Operand qq, OpCode expected = OpCode.Push, int machineCycles = 4, int throttlineStates = 15) { using (var fixture = new DecodeFixture(machineCycles, throttlineStates, qq.GetZ80IndexPrefix(), op).ThrowUnlessZ80()) { fixture.Expected.OpCode(expected).Operands(qq); } }
public void ADD_IXY_s(PrimaryOpCode op, Operand index, Operand s) { using (var fixture = new DecodeFixture(4, 15, index.GetZ80IndexPrefix(), op).ThrowUnlessZ80()) { fixture.Expected.OpCode(OpCode.Add16).Operands(index, s); } }
private static void IndexTest(PrimaryOpCode op, OpCode expected, int machineCycles = 2, int throttlingStates = 7) { using (var fixture = new DecodeFixture(machineCycles, throttlingStates, op)) { fixture.Expected.OpCode(expected).Operands(Operand.mHL); } }
private static void Test(PrimaryOpCode op, OpCode expected) { using (var fixture = new DecodeFixture(1, 4, op)) { fixture.Expected.OpCode(expected); } }
public void RST_nn(PrimaryOpCode op, ushort address) { using (var fixture = new DecodeFixture(3, 11, op).DoNotHalt()) { fixture.Expected.OpCode(OpCode.Reset).Operands(Operand.nn).WordLiteral(address); } }
public void ADD_HL_s(PrimaryOpCode op, Operand s) { using (var fixture = new DecodeFixture(3, 11, op)) { fixture.Expected.OpCode(OpCode.Add16).Operands(Operand.HL, s); } }
private static void Test(PrimaryOpCode op, Operand r, OpCode expected, int machineCycles = 1, int throttlingStates = 4) { using (var fixture = new DecodeFixture(machineCycles, throttlingStates, op)) { fixture.Expected.OpCode(expected).Operands(r); } }
private static void TestZ80Index(PrimaryOpCode prefix, PrimaryOpCode op, Operand o0, Operand o1) { var displacement = Rng.SByte(); using (var fixture = new DecodeFixture(5, 19, prefix, op, displacement).ThrowUnlessZ80()) { fixture.Expected.OpCode(OpCode.Load).Operands(o0, o1).Displacement(displacement); } }
private static void TestByteLiteral(PrimaryOpCode op, OpCode excepted = OpCode.Input) { var literal = Rng.Byte(); using (var fixture = new DecodeFixture(3, 11, op, literal).ThrowOnGameboy()) { fixture.Expected.OpCode(excepted).Operands(Operand.A, Operand.n).ByteLiteral(literal); } }
private static void LiteralTest(PrimaryOpCode op, OpCode expected, int machineCycles = 2, int throttlingStates = 7) { var literal = Rng.Byte(); using (var fixture = new DecodeFixture(machineCycles, throttlingStates, op, literal)) { fixture.Expected.OpCode(expected).Operands(Operand.n).ByteLiteral(literal); } }
private static void TestCall(PrimaryOpCode op, FlagTest flagTest, int machineCycles = 3, int throttlingStates = 10, bool gameboy = true) { var address = Rng.Word(); using (var fixture = new DecodeFixture(machineCycles, throttlingStates, op, address).DoNotHalt().ThrowOnGameboy(!gameboy)) { fixture.Expected.OpCode(OpCode.Call).FlagTest(flagTest).Operands(Operand.nn).WordLiteral(address); } }
private static void TestLiteralIndexed(PrimaryOpCode op, Operand o0, Operand o1) { var literal = Rng.Word(); using (var fixture = new DecodeFixture(4, 13, op, literal).NotOnGameboy()) { fixture.Expected.OpCode(OpCode.Load).Operands(o0, o1).WordLiteral(literal); } }
private static void Z80Index(PrimaryOpCode op, Operand index, OpCode expected, int machineCycles = 5, int throttlingStates = 19) { var displacement = Rng.SByte(); using (var fixture = new DecodeFixture(machineCycles, throttlingStates, index.GetZ80IndexPrefix(), op, displacement).ThrowUnlessZ80()) { fixture.Expected.OpCode(expected).Operands(index).Displacement(displacement); } }
public void LD_dd_nn(PrimaryOpCode op, Operand dd) { var literal = Rng.Word(); using (var fixture = new DecodeFixture(3, 10, op, literal)) { fixture.Expected.OpCode(OpCode.Load16).Operands(dd, Operand.nn).WordLiteral(literal); } }
private static void TestZ80Index(PrimaryOpCode prefix, PrimaryOpCode op, Operand o0, Operand o1, int maxhineCycles = 6, int throttlineStates = 20) { var literal = Rng.Word(); using (var fixture = new DecodeFixture(maxhineCycles, throttlineStates, prefix, op, literal).ThrowUnlessZ80()) { fixture.Expected.OpCode(OpCode.Load16).Operands(o0, o1).WordLiteral(literal); } }
private static void Test(PrimaryOpCode op, OpCode expected, params Operand[] operands) { using (var fixture = new DecodeFixture(1, 4, op).NotOnGameboy()) { fixture.Expected.OpCode(expected); if (operands.Length == 2) { fixture.Expected.Operands(operands[0], operands[1]); } } }
private static void Test(PrimaryOpCode op, Operand o0, Operand o1, int machineCycles = 1, int throttlingStates = 4) { using (var fixture = new DecodeFixture(machineCycles, throttlingStates, op)) { if (o0 == o1) { fixture.Expected.OpCode(OpCode.NoOperation); } else { fixture.Expected.OpCode(OpCode.Load).Operands(o0, o1); } } }
private static void Test(PrimaryOpCode op, FlagTest test = FlagTest.None, bool gameBoy = true) { var literal = Rng.Word(); using (var fixture = new DecodeFixture(3, 10, op, literal).DoNotHalt()) { if (!gameBoy) { fixture.NotOnGameboy(); } fixture.Expected.OpCode(OpCode.Jump).Operands(Operand.nn).WordLiteral(literal); if (test != FlagTest.None) { fixture.Expected.FlagTest(test); } } }
private static void TestRelative(PrimaryOpCode op, FlagTest test = FlagTest.None, bool gameBoy = true) { var literal = Rng.SByte(); var(machineCycles, throttlingStates) = test == FlagTest.None ? (3, 12) : (2, 7); using (var fixture = new DecodeFixture(machineCycles, throttlingStates, op, literal).DoNotHalt()) { if (!gameBoy) { fixture.NotOnGameboy(); } fixture.Expected.OpCode(OpCode.JumpRelative).Displacement(literal); if (test != FlagTest.None) { fixture.Expected.FlagTest(test); } } }
public void OR_r(PrimaryOpCode op, Operand r) => Test(op, r, OpCode.Or);
public void AND_r(PrimaryOpCode op, Operand r) => Test(op, r, OpCode.And);
public void SBC_A_r(PrimaryOpCode op, Operand r) => Test(op, r, OpCode.SubtractWithCarry);
public void SUB_A_r(PrimaryOpCode op, Operand r) => Test(op, r, OpCode.Subtract);
public void ADC_A_r(PrimaryOpCode op, Operand r) => Test(op, r, OpCode.AddWithCarry);
public void DEC_r(PrimaryOpCode op, Operand r) => Test(op, r, OpCode.Decrement);
public void ADD_A_r(PrimaryOpCode op, Operand r) => Test(op, r, OpCode.Add);