Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        public ADD16(Gameboy parent, byte opcode) : base(parent)
        {
            source = OpcodeUtils.BitsToRegister16((opcode & 0b110000) >> 4);

            Disassembly = "add hl, " + OpcodeUtils.Register16ToString(source);
            Cycles      = 8;
        }
Esempio n. 3
0
        public INC16(Gameboy parent, byte opcode) : base(parent)
        {
            target = OpcodeUtils.BitsToRegister16((opcode & 0b1110000) >> 4);

            Cycles      = 8;
            Disassembly = "inc " + OpcodeUtils.Register16ToString(target);
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        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");
        }
Esempio n. 9
0
        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";
        }
Esempio n. 10
0
        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");
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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");
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
        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");
        }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
        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));
        }
Esempio n. 18
0
        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));
        }