public void ExecuteStep() { try { StepCounter++; PrintClear(); int pc1 = CPU.GetLongPC(); PrintPC(pc1); CPU.ExecuteNext(); int pc2 = pc1 + CPU.Opcode.Length; PrintStatus(pc1, pc2); int pc = CPU.GetLongPC(); if (breakpoints.ContainsKey(pc)) { CPU.DebugPause = true; timer1.Enabled = false; BPCombo.Text = breakpoints.GetHex(pc); } } catch (Exception ex) { Print(ex.Message); CPU.Halt(); } }
private void DebugPanel_Paint(object sender, PaintEventArgs e) { bool paint = false; int currentPC = system.CPU.GetLongPC(); //if ((kernel.CPU.DebugPause)) if (true && queue != null) { int queueLength = queue.Count; int painted = 0; int index = 0; // Draw the position box if (position.X > 0 && position.Y > 0) { int row = position.Y / ROW_HEIGHT; int col = 12; e.Graphics.FillRectangle(lightBlueBrush, col, row * ROW_HEIGHT, 7 * 6, 14); } bool offsetPrinted = false; foreach (DebugLine line in queue) { if (line != null) { if (line.PC == currentPC) { paint = true; TopLineIndex = index; if (!offsetPrinted) { if (index > 4) { TopLineIndex -= 5; for (int c = 5; c > 0; c--) { DebugLine q0 = queue[index - c]; if (q0.PC == IRQPC) { e.Graphics.FillRectangle(orangeBrush, 0, painted * ROW_HEIGHT, this.Width, ROW_HEIGHT); } if (breakpoints.ContainsKey(q0.PC)) { e.Graphics.FillRectangle(yellowBrush, 0, painted * ROW_HEIGHT, this.Width, ROW_HEIGHT); } // Check if the memory still matches the opcodes //if (!q0.CheckOpcodes(system.RAM)) if (!q0.CheckOpcodes()) { e.Graphics.FillRectangle(redBrush, 0, painted * ROW_HEIGHT, this.Width, ROW_HEIGHT); } if (!q0.isLabel) { e.Graphics.DrawString(q0.ToString(), HeaderTextbox.Font, debugBrush, 2, painted * ROW_HEIGHT); } else { e.Graphics.FillRectangle(debugBrush, 0, painted * ROW_HEIGHT, this.Width, ROW_HEIGHT); e.Graphics.DrawString(q0.ToString(), HeaderTextbox.Font, labelBrush, 2, painted * ROW_HEIGHT); } painted++; } } offsetPrinted = true; } e.Graphics.FillRectangle(line.PC == IRQPC ? orangeBrush : lightBlueBrush, 0, painted * ROW_HEIGHT, this.Width, ROW_HEIGHT); } if (painted > 26) { paint = false; break; } if (paint) { if (breakpoints.ContainsKey(line.PC)) { e.Graphics.FillRectangle(yellowBrush, 0, painted * ROW_HEIGHT, this.Width, ROW_HEIGHT); } if (line.PC == IRQPC) { e.Graphics.FillRectangle(orangeBrush, 0, painted * ROW_HEIGHT, this.Width, ROW_HEIGHT); } // Check if the memory still matches the opcodes //if (!line.CheckOpcodes(system.RAM)) if (!line.CheckOpcodes()) { e.Graphics.FillRectangle(redBrush, 0, painted * ROW_HEIGHT, this.Width, ROW_HEIGHT); } if (line.PC == currentPC || !line.isLabel) { e.Graphics.DrawString(line.ToString(), HeaderTextbox.Font, debugBrush, 2, painted * ROW_HEIGHT); } else { e.Graphics.FillRectangle(debugBrush, 0, painted * ROW_HEIGHT, this.Width, ROW_HEIGHT); e.Graphics.DrawString(line.ToString(), HeaderTextbox.Font, labelBrush, 2, painted * ROW_HEIGHT); } painted++; } } index++; } } else { e.Graphics.FillRectangle(lightBlueBrush, 0, 0, this.Width, this.Height); e.Graphics.DrawString("Running code real fast ... no time to write!", HeaderTextbox.Font, debugBrush, 8, DebugPanel.Height / 2); } }