Example #1
0
        public Byte exe_ins()
        {
            Byte opTime = 1;

            Opcodes.Opcode op = (Opcodes.Opcode)(Program.emulator.GetMemory().ReadFromMemory(reg_pc));

            // Logger.AppendLog(Logger.LOG_LEVEL.LOG_LEVEL_DEBUG, "[" + String.Format("{0:X4}", get_reg_pc()) + "]: " + String.Format("{0:X2}", op) + "PRE Execute");
            if (!Enum.IsDefined(typeof(Opcodes.Opcode), op))
            {
                Logger.AppendLog(Logger.LOG_LEVEL.LOG_LEVEL_WARNING, "UNKNOWN OPCODE OCCURED: " + String.Format("{0:X2}", op)
                                 + " At Address: " + String.Format("{0:X4}", reg_pc));

                set_reg_pc((UInt16)(get_reg_pc() + 1));
                return(opTime);
            }

            // Special Execute for CB Opcodes
            if (op == Opcodes.Opcode.OPCODE_INTERNAL_CB)
            {
                // Increase Program Counter to next location
                set_reg_pc((UInt16)(get_reg_pc() + 1));
                OpcodesCB.ExecuteOpcodeCB((OpcodesCB.OpcodeCB)(Program.emulator.GetMemory().ReadFromMemory(reg_pc)));
                // TODO: Implement Clocks for CB Opcodes
                return(opTime);
            }

            //Logger.AppendLog(Logger.LOG_LEVEL.LOG_LEVEL_DEBUG, "[" + String.Format("{0:X4}", get_reg_pc()) + "]: " + op.ToString() + " Executing");

            Opcodes.ExecuteOpcode(op);
            opTime = Opcodes.opcodeTimings.ContainsKey(op) ? Opcodes.opcodeTimings[op] : (byte)1;

            return(opTime);
        }