Exemple #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);
        }
Exemple #2
0
        private void lv_windowLoadData(UInt16 i_address)
        {
            lv_dissassembly.Clear();

            lv_dissassembly.Columns.Add("Address", 70);
            lv_dissassembly.Columns.Add("Opcode", 70);
            lv_dissassembly.Columns.Add("Instruction", 200);

            UInt16 lo_val = (i_address < 0x00FF) ? (UInt16)(0) : (UInt16)(i_address - 0xFF);
            UInt16 hi_val = ((UInt32)(i_address + 0x00FF) > 0xFFFF) ? (UInt16)(0xFFFF) : (UInt16)(i_address + 0xFF);

            for (UInt16 i = lo_val; i < hi_val;)
            {
                Byte   opcode  = Program.emulator.GetMemory().ReadFromMemory(i);
                String address = String.Format("{0:X4}", i);
                String value   = String.Format("{0:X2}", opcode);

                ListViewItem item = new ListViewItem(address);
                item.SubItems.Add(value);

                if ((Opcodes.Opcode)opcode == Opcodes.Opcode.OPCODE_INTERNAL_CB)
                {
                    opcode = Program.emulator.GetMemory().ReadFromMemory(++i);
                    item.SubItems.Add(OpcodesCB.GetOpcodeCB((OpcodesCB.OpcodeCB)opcode, ref i));
                }
                else
                {
                    item.SubItems.Add(Opcodes.GetOpcode((Opcodes.Opcode)opcode, ref i));
                }

                lv_dissassembly.Items.Add(item);
            }

            if (lv_dissassembly.Items.Count == 0)
            {
                return;
            }

            int          index    = GetItemIndexWithAddress(String.Format("{0:X4}", i_address));
            ListViewItem sel_item = lv_dissassembly.Items[index];

            sel_item.Selected = true;
            sel_item.Focused  = true;
            lv_dissassembly.Select();
            lv_dissassembly.EnsureVisible(index);
        }