Esempio n. 1
0
 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);
     }
 }
Esempio n. 2
0
 private static void Test(PrimaryOpCode op, OpCode expected)
 {
     using (var fixture = new DecodeFixture(1, 4, op))
     {
         fixture.Expected.OpCode(expected).Operands(Operand.A).UseAlternativeFlagAffection();
     }
 }
Esempio n. 3
0
 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);
     }
 }
Esempio n. 4
0
 public void DEC_ss(PrimaryOpCode op, Operand s)
 {
     using (var fixture = new DecodeFixture(1, 6, op))
     {
         fixture.Expected.OpCode(OpCode.Decrement16).Operands(s);
     }
 }
Esempio n. 5
0
 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);
     }
 }
Esempio n. 6
0
 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);
     }
 }
Esempio n. 7
0
 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);
     }
 }
Esempio n. 9
0
 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);
     }
 }
Esempio n. 10
0
 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);
     }
 }
Esempio n. 11
0
 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);
     }
 }
Esempio n. 12
0
        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);
            }
        }
Esempio n. 13
0
        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);
            }
        }
Esempio n. 14
0
        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);
            }
        }
Esempio n. 15
0
        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);
            }
        }
Esempio n. 16
0
        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);
            }
        }
Esempio n. 17
0
        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);
            }
        }
Esempio n. 18
0
        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);
            }
        }
Esempio n. 19
0
        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);
            }
        }
Esempio n. 20
0
        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]);
                }
            }
        }
Esempio n. 21
0
 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);
         }
     }
 }
Esempio n. 22
0
        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);
                }
            }
        }
Esempio n. 23
0
        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);
                }
            }
        }
Esempio n. 24
0
 public void OR_r(PrimaryOpCode op, Operand r) => Test(op, r, OpCode.Or);
Esempio n. 25
0
 public void AND_r(PrimaryOpCode op, Operand r) => Test(op, r, OpCode.And);
Esempio n. 26
0
 public void SBC_A_r(PrimaryOpCode op, Operand r) => Test(op, r, OpCode.SubtractWithCarry);
Esempio n. 27
0
 public void SUB_A_r(PrimaryOpCode op, Operand r) => Test(op, r, OpCode.Subtract);
Esempio n. 28
0
 public void ADC_A_r(PrimaryOpCode op, Operand r) => Test(op, r, OpCode.AddWithCarry);
Esempio n. 29
0
 public void DEC_r(PrimaryOpCode op, Operand r) => Test(op, r, OpCode.Decrement);
Esempio n. 30
0
 public void ADD_A_r(PrimaryOpCode op, Operand r) => Test(op, r, OpCode.Add);