Exemplo n.º 1
0
        private void UpdateDataCode(int start, int end)
        {
            this.BeginLoadData();
            ushort i = (ushort)start;

            while (i < end)
            {
                m_cur = i;
                byte opcode = GameBoy.Ram.ReadByteAt(i);
                bool isCB   = false;
                if (opcode == 0xCB)
                {
                    isCB = true;
                    i   += 0x01;
                }
                Z80.Z80Instruction inst = GameBoy.Cpu.decoder.GetInstructionAt(i, isCB);
                if (inst != null)
                {
                    byte   length   = inst.GetLenght(i);
                    String bytecode = "";
                    for (byte j = 0; j < length; j++)
                    {
                        byte b = GameBoy.Ram.ReadByteAt((ushort)(i + j));
                        bytecode += String.Format("{0:x2} ", b);
                    }
                    object[] row = new object[(int)eRamTableColumn.eColumn_count];
                    row[(int)eRamTableColumn.eColumn_breakPoint]  = false;
                    row[(int)eRamTableColumn.eColumn_zone]        = m_name;
                    row[(int)eRamTableColumn.eColumn_adress]      = String.Format("{0:x4}", i);
                    row[(int)eRamTableColumn.eColumn_value]       = bytecode;
                    row[(int)eRamTableColumn.eColumn_instruction] = inst.ToString(i);
                    row[(int)eRamTableColumn.eColumn_length]      = length;
                    row[(int)eRamTableColumn.eColumn_valid]       = true;
                    row[(int)eRamTableColumn.eColumn_adressINT]   = i;

                    this.LoadDataRow(row, true);
                    ushort l = (ushort)(i + length);
                    ++i;
                    while (i < l)
                    {
                        object[] rowh = new object[(int)eRamTableColumn.eColumn_count];
                        rowh[(int)eRamTableColumn.eColumn_breakPoint]  = false;
                        rowh[(int)eRamTableColumn.eColumn_zone]        = m_name;
                        rowh[(int)eRamTableColumn.eColumn_adress]      = String.Format("{0:x4}", i);
                        rowh[(int)eRamTableColumn.eColumn_value]       = "**";
                        rowh[(int)eRamTableColumn.eColumn_instruction] = "db";
                        rowh[(int)eRamTableColumn.eColumn_length]      = length;
                        rowh[(int)eRamTableColumn.eColumn_valid]       = false;
                        rowh[(int)eRamTableColumn.eColumn_adressINT]   = i;
                        this.LoadDataRow(rowh, true);
                        ++i;
                    }
                }
                else
                {
                    ++i;
                }
            }
            this.EndLoadData();
        }
Exemplo n.º 2
0
        private void UpdateAdressCode(int adress)
        {
            ushort adr    = (ushort)adress;
            byte   opcode = GameBoy.Ram.ReadByteAt(adr);
            bool   isCB   = false;

            if (opcode == 0xCB)
            {
                isCB = true;
                ++adr;
            }
            Z80.Z80Instruction inst = GameBoy.Cpu.decoder.GetInstructionAt(adr, isCB);
            this.BeginLoadData();
            if (inst != null)
            {
                byte   length   = inst.GetLenght(adr);
                String bytecode = "";
                for (byte j = 0; j < length; j++)
                {
                    byte b = GameBoy.Ram.ReadByteAt((ushort)(adr + j));
                    bytecode += String.Format("{0:x2} ", b);
                }
                object[] row = new object[(int)eRamTableColumn.eColumn_count];
                row[(int)eRamTableColumn.eColumn_breakPoint]  = false;
                row[(int)eRamTableColumn.eColumn_zone]        = m_name;
                row[(int)eRamTableColumn.eColumn_adress]      = String.Format("{0:x4}", adr);
                row[(int)eRamTableColumn.eColumn_value]       = bytecode;
                row[(int)eRamTableColumn.eColumn_instruction] = inst.ToString(adr);
                row[(int)eRamTableColumn.eColumn_length]      = length;
                row[(int)eRamTableColumn.eColumn_valid]       = true;
                row[(int)eRamTableColumn.eColumn_adressINT]   = adr;

                this.LoadDataRow(row, true);
                ushort l = (ushort)(adr + length);
                ++adr;
                while (adr < l)
                {
                    object[] rowh = new object[(int)eRamTableColumn.eColumn_count];
                    rowh[(int)eRamTableColumn.eColumn_breakPoint]  = false;
                    rowh[(int)eRamTableColumn.eColumn_zone]        = m_name;
                    rowh[(int)eRamTableColumn.eColumn_adress]      = String.Format("{0:x4}", adr);
                    rowh[(int)eRamTableColumn.eColumn_value]       = "**";
                    rowh[(int)eRamTableColumn.eColumn_instruction] = "db";
                    rowh[(int)eRamTableColumn.eColumn_length]      = length;
                    rowh[(int)eRamTableColumn.eColumn_valid]       = false;
                    rowh[(int)eRamTableColumn.eColumn_adressINT]   = adr;
                    this.LoadDataRow(rowh, true);
                    ++adr;
                }
                this.EndLoadData();
            }
        }
Exemplo n.º 3
0
        public int DecodeInstruction(int adress, ref StringBuilder output)
        {
            const String myFormat = "  \t{0,-6}{1,-6}{2,-20}{3,-20}{4,-4}";
            String       bytecode = "";
            ushort       i        = (ushort)adress;
            int          outAdr   = 0;
            String       bp       = m_breakPoints[adress] ? "X" : "";
            byte         opcode   = GameBoy.Ram.ReadByteAt(i);
            bool         isCB     = false;

            if (opcode == 0xCB)
            {
                isCB = true;
            }
            if (isCB)
            {
                i += 0x01;
                outAdr++;
            }
            Z80.Z80Instruction inst = GameBoy.Cpu.decoder.GetInstructionAt(i, isCB);
            if (inst != null)
            {
                byte length = inst.GetLenght((ushort)i);
                for (byte j = 0; j < length; j++)
                {
                    byte b = GameBoy.Ram.ReadByteAt((ushort)(i + j));
                    if (isCB)
                    {
                        bytecode += "CB ";
                    }
                    bytecode += String.Format("{0:x2} ", b);
                }
                outAdr += length;
                string s = bp;
                s += String.Format(myFormat, GetLocation(adress), String.Format("{0:x4} ", (adress)).ToUpper(), bytecode.ToUpper(), inst.ToString(i), ";" + length);
                output.AppendLine(s);
            }
            else
            {
                byte b = GameBoy.Ram.ReadByteAt((ushort)(i));
                bytecode += String.Format("{0:x2} ", b);
                output.AppendLine(String.Format(myFormat, GetLocation(adress), String.Format("{0:x4} ", (adress)).ToUpper(), bytecode.ToUpper(), "-", ";1"));
                outAdr++;
            }
            return(outAdr);
        }