Exemple #1
0
        private bool REG(ushort instruction)
        {
            byte subcommand = ParserFunctions.GetSubCommand(instruction);
            var  command    = RegisterCommands[subcommand];

            var regX = ParserFunctions.GetX(instruction);
            var regY = ParserFunctions.GetY(instruction);

            command(regX, regY);
            return(false);
        }
Exemple #2
0
        private bool SNEV(ushort instruction)
        {
            var regX = ParserFunctions.GetX(instruction);
            var regY = ParserFunctions.GetY(instruction);

            var regValueX = Register[regX];
            var regValueY = Register[regY];

            if (regValueX != regValueY)
            {
                InstructionPointer += 2;
            }

            return(true);
        }
Exemple #3
0
        private bool SEV(ushort instruction)
        {
            byte x         = ParserFunctions.GetX(instruction);
            byte regValueX = Register[x];

            byte y         = ParserFunctions.GetY(instruction);
            byte regValueY = Register[y];

            if (regValueX == regValueY)
            {
                InstructionPointer += 2;
            }

            return(false);
        }
Exemple #4
0
        private bool DRW(ushort instruction)
        {
            var Vx    = ParserFunctions.GetX(instruction);
            var Vy    = ParserFunctions.GetY(instruction);
            var x     = Register[Vx];
            var y     = Register[Vy];
            var count = ParserFunctions.GetSubCommand(instruction);

            byte[] sprite = new byte[count];
            for (ushort i = 0; i < count; i++)
            {
                sprite[i] = memory.GetValue((ushort)(AddressRegister + i));
            }
            var collision = SetSprite(x, y, sprite, count);

            Register[0xF] = (byte)collision;
            // Draw screen
            display.Print();

            return(false);
        }