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); } }
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))); } } }
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); } }