Ejemplo n.º 1
0
        private void ColorCode()
        {
            int i;

            objectView.Nodes.Clear();
            TreeNode root = objectView.Nodes.Add("Spin");
            TreeNode node;

            node     = root.Nodes.Add(String.Format("System Frequency: {0}mhz", Chip.DirectReadLong(0)));
            node.Tag = (int)0;
            node     = root.Nodes.Add(String.Format("Clock Mode: {0:X2}", Chip.DirectReadByte(4)));
            node.Tag = (int)4;
            node     = root.Nodes.Add(String.Format("Check Sum: {0:X2}", Chip.DirectReadByte(5)));
            node.Tag = (int)5;
            node     = root.Nodes.Add(String.Format("Root Object: {0:X4}", Chip.DirectReadWord(6)));
            node.Tag = (int)6;
            node     = root.Nodes.Add(String.Format("Variable Base: {0:X4}", Chip.DirectReadWord(8)));
            node.Tag = (int)8;
            node     = root.Nodes.Add(String.Format("Local Frame: {0:X4}", Chip.DirectReadWord(10)));
            node.Tag = (int)10;
            node     = root.Nodes.Add(String.Format("Entry PC: {0:X4}", Chip.DirectReadWord(12)));
            node.Tag = (int)12;
            node     = root.Nodes.Add(String.Format("Starting Stack: {0:X4}", Chip.DirectReadWord(14)));
            node.Tag = (int)14;

            for (i = 0; i < 16; i++)
            {
                Colorize[i] = Brushes.White;
            }

            for (i = Chip.DirectReadWord(0x8); i < Chip.DirectReadWord(0xA); i++)
            {
                Colorize[i] = Brushes.LightYellow;
            }

            for (; i < 0x8000; i++)
            {
                Colorize[i] = Brushes.LightGray;
            }

            ColorObject(Chip.DirectReadWord(0x6), Chip.DirectReadWord(0x8), root);
        }
Ejemplo n.º 2
0
        private void ColorCode()
        {
            int i;

            objectView.Nodes.Clear();
            TreeNode root = objectView.Nodes.Add("Spin");
            TreeNode node;

            node     = root.Nodes.Add(String.Format("System Frequency: {0}mhz", Chip.DirectReadLong(0)));
            node.Tag = Tuple.Create(0, 4);
            node     = root.Nodes.Add(String.Format("Clock Mode: {0:X2}", Chip.DirectReadByte(4)));
            node.Tag = Tuple.Create(4, 5);
            node     = root.Nodes.Add(String.Format("Check Sum: {0:X2}", Chip.DirectReadByte(5)));
            node.Tag = Tuple.Create(5, 6);
            node     = root.Nodes.Add(String.Format("Root Object: {0:X4}", Chip.DirectReadWord(6)));
            node.Tag = Tuple.Create(6, 8);
            node     = root.Nodes.Add(String.Format("Variable Base: {0:X4}", Chip.DirectReadWord(8)));
            node.Tag = Tuple.Create(8, 10);
            node     = root.Nodes.Add(String.Format("Local Frame: {0:X4}", Chip.DirectReadWord(10)));
            node.Tag = Tuple.Create(10, 12);
            node     = root.Nodes.Add(String.Format("Entry PC: {0:X4}", Chip.DirectReadWord(12)));
            node.Tag = Tuple.Create(12, 14);
            node     = root.Nodes.Add(String.Format("Starting Stack: {0:X4}", Chip.DirectReadWord(14)));
            node.Tag = Tuple.Create(14, 16);

            for (i = 0; i < 16; i++)
            {
                colorMap[i] = 1;
            }

            for (i = Chip.DirectReadWord(0x8); i < Chip.DirectReadWord(0xA); i++)
            {
                colorMap[i] = 2;
            }

            for (; i < 0x8000; i++)
            {
                colorMap[i] = 3;
            }

            ColorObject(Chip.DirectReadWord(0x6), Chip.DirectReadWord(0x8), root);
        }
Ejemplo n.º 3
0
        private void Repaint(bool tick, InterpretedCog host)
        {
            Graphics g = Graphics.FromImage((Image)BackBuffer);
            Brush    brush;

            g.Clear(SystemColors.Control);

            String display;
            uint   topLine, bottomLine;

            topLine    = 5;
            bottomLine = (uint)((ClientRectangle.Height / MonoFont.Height) - 5);

            zeroFlagLabel.Text   = "";
            carryFlagLabel.Text  = "";
            OpcodeSize.Visible   = true;
            DisplayUnits.Visible = true;

            if (memoryViewButton.Checked)
            {
                for (uint i = (uint)positionScroll.Value, y = 0;
                     y < ClientRectangle.Height;
                     y += (uint)MonoFont.Height, i++)
                {
                    if ((i > 0xFFFF) || (i < 0))
                    {
                        continue;
                    }

                    uint mem = host[(int)i];

                    string binary = Convert.ToString((long)mem, 2);

                    while (binary.Length < 32)
                    {
                        binary = "0" + binary;
                    }

                    display = String.Format("{0:X4}:  {1:X8}   {2}   ",
                                            i, mem, binary);
                    if (displayAsHexadecimal)
                    {
                        display = display + String.Format("{0:X8}", mem);
                    }
                    else
                    {
                        display = display + String.Format("{0}", mem);
                    }

                    g.FillRectangle(SystemBrushes.Control, 0, y, assemblyPanel.Width, y + MonoFont.Height);

                    g.DrawString(
                        display,
                        (host.ProgramCursor == i) ? MonoFontBold : MonoFont,
                        SystemBrushes.ControlText, 0, y);
                }
            }
            else
            {
                uint y = 0;

                for (uint i = (uint)positionScroll.Value, line = 1; y < ClientRectangle.Height; y += (uint)MonoFont.Height, line++)
                {
                    if (i > 0xFFFF)
                    {
                        continue;
                    }

                    uint start = i;

                    Propeller.MemoryManager mem = new Propeller.MemoryManager(Chip, i);
                    string inst = InstructionDisassembler.InterpreterText(mem, displayAsHexadecimal, useShortOpcodes);
                    i                   = mem.Address;
                    display             = String.Format("{0:X4}: ", start);
                    InterpAddress[line] = start;

                    for (uint q = start; q < start + 4; q++)
                    {
                        if (q < i)
                        {
                            byte b = Chip.DirectReadByte(q);
                            display += String.Format(" {0:X2}", b);
                        }
                        else
                        {
                            display += "   ";
                        }
                    }


                    display += "  " + inst;

                    if (InterpAddress[line] == host.BreakPoint)
                    {
                        brush = System.Drawing.Brushes.Pink;
                    }
                    else if ((!followPCButton.Checked) || (line <= topLine) || (line >= bottomLine))
                    {
                        brush = SystemBrushes.Control;
                    }
                    else
                    {
                        brush = SystemBrushes.Window;
                    }
                    g.FillRectangle(brush, 0, y, assemblyPanel.Width, y + MonoFont.Height);

                    g.DrawString(
                        display,
                        (host.ProgramCursor == start) ? MonoFontBold : MonoFont,
                        SystemBrushes.ControlText, 0, y);
                }

                StringBrush = SystemBrushes.ControlText;
                StringY     = 0;
                StringX     = (uint)(assemblyPanel.Width - StackMargin);

                DrawString(g, String.Format("@Stk[0] = ${0:X4} {0}", host.Stack));
                DrawString(g, String.Format("@Obj[0] = ${0:X4} {0}", host.Object));
                DrawString(g, String.Format("@Loc[0] = ${0:X4} {0}", host.Local));
                DrawString(g, String.Format("@Var[0] = ${0:X4} {0}", host.Variable));
                g.DrawLine(Pens.Black, assemblyPanel.Width - StackMargin, StringY, assemblyPanel.Width, StringY);
                DrawString(g, String.Format("Caller& = ${0:X4} {0}", Chip.DirectReadWord(host.Local - 8)));
                DrawString(g, String.Format("          ${0:X4} {0}", Chip.DirectReadWord(host.Local - 6)));
                DrawString(g, String.Format("          ${0:X4} {0}", Chip.DirectReadWord(host.Local - 4)));
                DrawString(g, String.Format("Return& = ${0:X4}", Chip.DirectReadWord(host.Local - 2)));
                g.DrawLine(Pens.Black, assemblyPanel.Width - StackMargin, StringY, assemblyPanel.Width, StringY);

                for (uint i = host.Local; i < host.Stack && StringY < ClientRectangle.Height; i += 4)
                {
                    DrawString(g, String.Format("${0:X8}  {0}", (int)Chip.DirectReadLong(i)));
                }
            }
        }