Esempio n. 1
0
        private void DispatchCb()
        {
            byte op      = mmu.rb(Registers.PC++);
            var  regId   = op & 0x7;
            byte r8Value = Registers.GetRegById(regId);

            switch (op)
            {
            //RLC
            case <= 0x7:
                Registers.SetRegById(regId, ControlUnit.RLC(r8Value));
                break;

            //RRC
            case <= 0xf:
                Registers.SetRegById(regId, ControlUnit.RRC(r8Value));
                break;

            //RL
            case <= 0x17:
                Registers.SetRegById(regId, ControlUnit.RL(r8Value));
                break;

            //RR
            case <= 0x1f:
                Registers.SetRegById(regId, ControlUnit.RR(r8Value));
                break;

            //SLA
            case <= 0x27:
                Registers.SetRegById(regId, ControlUnit.SLA(r8Value));
                break;

            //SRA
            case <= 0x2f:
                Registers.SetRegById(regId, ControlUnit.SRA(r8Value));
                break;

            //SWAP
            case <= 0x37:
                Registers.SetRegById(regId, ControlUnit.SWAP(r8Value));
                break;

            //SRL
            case <= 0x3f:
                Registers.SetRegById(regId, ControlUnit.SRL(r8Value));
                break;

            //BIT
            case <= 0x7f:
                ControlUnit.Bit(((op >> 3) & 0x7), r8Value);
                break;

            //RES
            case <= 0xbf:
                Registers.SetRegById(regId, ControlUnit.RES(((op >> 3) & 0x7), r8Value));
                break;

            //SET
            case <= 0xff:
                Registers.SetRegById(regId, ControlUnit.SET(((op >> 3) & 0x7), r8Value));
                break;

            default:
                throw new NotImplementedException($"The op code {op:X2} has not been implemented yet.");
            }
            clock.Tick(12);
        }