Example #1
0
        private void assemblyPanel_MouseMove(object sender, MouseEventArgs e)
        {
            uint line;
            uint mem;

            if (!(Chip.GetCog(HostID) is NativeCog))
            {
                return;
            }
            NativeCog host = (NativeCog)Chip.GetCog(HostID);

            line = (uint)positionScroll.Value + (uint)(e.Y / MonoFont.Height);
            if (line > 0x1FF)
            {
                return;
            }

            //Update tooltip only if line has change to prevent flickering
            if (line != LastLine)
            {
                mem = host.ReadLong(line);
                toolTip1.SetToolTip(assemblyPanel, String.Format("${0:x3}= ${1:x8}, {1}\n${2:x3}= ${3:x8}, {3}",
                                                                 mem >> 9 & 0x1ff, host.ReadLong(mem >> 9 & 0x1ff),
                                                                 mem & 0x1ff, host.ReadLong(mem & 0x1ff))
                                    );
                LastLine = line;
            }
        }
Example #2
0
        /// @brief Repaint the Cog state and data.
        /// @param force
        public override void UpdateGui()
        {
            assemblyPanel.Invalidate();

            Cog host = Chip?.GetCog(HostID);

            if (host == null)
            {
                processorStateLabel.Text = "CPU State: Cog is stopped.";
                programCounterLabel.Text = "";
                zeroFlagLabel.Text       = "";
                carryFlagLabel.Text      = "";
                return;
            }

            positionScroll.Minimum = 0;

            if (host is InterpretedCog)
            {
                positionScroll.Maximum = PropellerCPU.TOTAL_MEMORY - 1;
            }
            else if (host is NativeCog)
            {
                positionScroll.Maximum = 0x200;
            }

            positionScroll.LargeChange = 10;
            positionScroll.SmallChange = 1;

            if (positionScroll.Maximum < positionScroll.Value)
            {
                positionScroll.Value = positionScroll.Maximum;
            }

            if (followPCButton.Checked)
            {
                uint topLine, bottomLine;
                topLine    = 5;
                bottomLine = (uint)((ClientRectangle.Height / MonoFont.Height) - 5);
                if (host is NativeCog)
                {
                    if (host.ProgramCursor < topLine)
                    {
                        positionScroll.Value = 0;
                    }
                    else if (host.ProgramCursor - positionScroll.Value >= bottomLine - 1)
                    {
                        positionScroll.Value = (int)host.ProgramCursor - (int)topLine;
                    }
                    else if (host.ProgramCursor - positionScroll.Value < topLine)
                    {
                        positionScroll.Value = (int)host.ProgramCursor - (int)topLine;
                    }
                }
                else
                {
                    positionScroll.Value = (int)host.ProgramCursor;
                }
            }

            if (host is NativeCog)
            {
                NativeCog nativeHost = (NativeCog)host;

                OpcodeSize.Visible   = false;
                DisplayUnits.Visible = false;
                zeroFlagLabel.Text   = "Zero: " + (nativeHost.ZeroFlag ? "True" : "False");
                carryFlagLabel.Text  = "Carry: " + (nativeHost.CarryFlag ? "True" : "False");
            }
            else if (host is InterpretedCog)
            {
                zeroFlagLabel.Text   = "";
                carryFlagLabel.Text  = "";
                OpcodeSize.Visible   = true;
                DisplayUnits.Visible = true;
            }

            programCounterLabel.Text = "PC: " + String.Format("{0:X8}", host.ProgramCursor);
            processorStateLabel.Text = "CPU State: " + host.CogState;
        }
Example #3
0
        private void Repaint(bool tick, NativeCog host)
        {
            Graphics g = Graphics.FromImage((Image)BackBuffer);

            g.Clear(SystemColors.Control);
            Brush brush;

            OpcodeSize.Visible   = false;
            DisplayUnits.Visible = false;
            zeroFlagLabel.Text   = "Zero: " + (host.ZeroFlag ? "True" : "False");
            carryFlagLabel.Text  = "Carry: " + (host.CarryFlag ? "True" : "False");

            String display;
            uint   topLine, bottomLine;

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

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

                uint mem = host[(int)i];

                if (memoryViewButton.Checked)
                {
                    string binary = Convert.ToString((long)mem, 2);

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

                    display = String.Format("{0:X4}:  {1:X8}   {2}   {1}",
                                            i,
                                            mem,
                                            binary);
                }
                else
                {
                    display = String.Format("{0:X3}:  {2:X8}   {1}",
                                            i,
                                            InstructionDisassembler.AssemblyText(mem),
                                            mem);
                }

                if ((uint)positionScroll.Value + line - 1 == 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 == i) ? MonoFontBold : MonoFont,
                    SystemBrushes.ControlText, 0, y);
            }
        }
Example #4
0
        private void PaintNative(Graphics g, NativeCog host)
        {
            g.Clear(SystemColors.Control);
            Brush brush;

            String display;
            uint   topLine, bottomLine;

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

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

                uint mem = host[(int)i];

                if (memoryViewButton.Checked)
                {
                    string binary = Convert.ToString((long)mem, 2);

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

                    display = String.Format("{0:X4}:  {1:X8}   {2}   {1}",
                                            i,
                                            mem,
                                            binary);
                }
                else
                {
                    display = String.Format("{0:X3}:  {2:X8}   {1}",
                                            i,
                                            InstructionDisassembler.AssemblyText(mem),
                                            mem);
                }

                if ((uint)positionScroll.Value + line - 1 == 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 == i) ? MonoFontBold : MonoFont,
                    SystemBrushes.ControlText, 0, y);
            }
        }