Atari 2600 Debuger - Add breakpoints

This commit is contained in:
adelikat 2014-05-26 18:23:58 +00:00
parent 60a754c1fa
commit 363b3bdd3b
6 changed files with 562 additions and 13 deletions

View File

@ -553,6 +553,12 @@
<DependentUpon>RomStatusPicker.cs</DependentUpon>
</Compile>
<Compile Include="Throttle.cs" />
<Compile Include="tools\Atari2600\AddBreakpointDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="tools\Atari2600\AddBreakpointDialog.Designer.cs">
<DependentUpon>AddBreakpointDialog.cs</DependentUpon>
</Compile>
<Compile Include="tools\Atari2600\Atari2600Debugger.cs">
<SubType>Form</SubType>
</Compile>
@ -1128,6 +1134,9 @@
<EmbeddedResource Include="RomStatusPicker.resx">
<DependentUpon>RomStatusPicker.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="tools\Atari2600\AddBreakpointDialog.resx">
<DependentUpon>AddBreakpointDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="tools\Atari2600\Atari2600Debugger.resx">
<DependentUpon>Atari2600Debugger.cs</DependentUpon>
</EmbeddedResource>

View File

@ -0,0 +1,147 @@
namespace BizHawk.Client.EmuHawk
{
partial class AddBreakpointDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.AddButton = new System.Windows.Forms.Button();
this.BreakpointTypeGroupbox = new System.Windows.Forms.GroupBox();
this.ExecuteRadio = new System.Windows.Forms.RadioButton();
this.WriteRadio = new System.Windows.Forms.RadioButton();
this.ReadRadio = new System.Windows.Forms.RadioButton();
this.AddressBox = new BizHawk.Client.EmuHawk.HexTextBox();
this.label1 = new System.Windows.Forms.Label();
this.BreakpointTypeGroupbox.SuspendLayout();
this.SuspendLayout();
//
// AddButton
//
this.AddButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.AddButton.Location = new System.Drawing.Point(152, 92);
this.AddButton.Name = "AddButton";
this.AddButton.Size = new System.Drawing.Size(60, 23);
this.AddButton.TabIndex = 100;
this.AddButton.Text = "&Add";
this.AddButton.UseVisualStyleBackColor = true;
this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
//
// BreakpointTypeGroupbox
//
this.BreakpointTypeGroupbox.Controls.Add(this.ExecuteRadio);
this.BreakpointTypeGroupbox.Controls.Add(this.WriteRadio);
this.BreakpointTypeGroupbox.Controls.Add(this.ReadRadio);
this.BreakpointTypeGroupbox.Location = new System.Drawing.Point(15, 31);
this.BreakpointTypeGroupbox.Name = "BreakpointTypeGroupbox";
this.BreakpointTypeGroupbox.Size = new System.Drawing.Size(196, 52);
this.BreakpointTypeGroupbox.TabIndex = 1;
this.BreakpointTypeGroupbox.TabStop = false;
//
// ExecuteRadio
//
this.ExecuteRadio.AutoSize = true;
this.ExecuteRadio.Location = new System.Drawing.Point(119, 19);
this.ExecuteRadio.Name = "ExecuteRadio";
this.ExecuteRadio.Size = new System.Drawing.Size(64, 17);
this.ExecuteRadio.TabIndex = 12;
this.ExecuteRadio.Text = "Execute";
this.ExecuteRadio.UseVisualStyleBackColor = true;
//
// WriteRadio
//
this.WriteRadio.AutoSize = true;
this.WriteRadio.Location = new System.Drawing.Point(63, 19);
this.WriteRadio.Name = "WriteRadio";
this.WriteRadio.Size = new System.Drawing.Size(50, 17);
this.WriteRadio.TabIndex = 11;
this.WriteRadio.Text = "Write";
this.WriteRadio.UseVisualStyleBackColor = true;
//
// ReadRadio
//
this.ReadRadio.AutoSize = true;
this.ReadRadio.Checked = true;
this.ReadRadio.Location = new System.Drawing.Point(6, 19);
this.ReadRadio.Name = "ReadRadio";
this.ReadRadio.Size = new System.Drawing.Size(51, 17);
this.ReadRadio.TabIndex = 10;
this.ReadRadio.TabStop = true;
this.ReadRadio.Text = "Read";
this.ReadRadio.UseVisualStyleBackColor = true;
//
// AddressBox
//
this.AddressBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
this.AddressBox.Location = new System.Drawing.Point(77, 5);
this.AddressBox.Name = "AddressBox";
this.AddressBox.Nullable = false;
this.AddressBox.Size = new System.Drawing.Size(135, 20);
this.AddressBox.TabIndex = 1;
this.AddressBox.Text = "0";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(59, 13);
this.label1.TabIndex = 3;
this.label1.Text = "Address 0x";
//
// AddBreakpointDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(224, 123);
this.Controls.Add(this.label1);
this.Controls.Add(this.AddressBox);
this.Controls.Add(this.BreakpointTypeGroupbox);
this.Controls.Add(this.AddButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "AddBreakpointDialog";
this.ShowIcon = false;
this.Text = "Add Breakpoint";
this.Load += new System.EventHandler(this.AddBreakpointDialog_Load);
this.BreakpointTypeGroupbox.ResumeLayout(false);
this.BreakpointTypeGroupbox.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button AddButton;
private System.Windows.Forms.GroupBox BreakpointTypeGroupbox;
private System.Windows.Forms.RadioButton ExecuteRadio;
private System.Windows.Forms.RadioButton WriteRadio;
private System.Windows.Forms.RadioButton ReadRadio;
private HexTextBox AddressBox;
private System.Windows.Forms.Label label1;
}
}

View File

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BizHawk.Client.EmuHawk
{
public partial class AddBreakpointDialog : Form
{
public AddBreakpointDialog()
{
InitializeComponent();
}
public BreakpointType BreakType
{
get
{
if (ReadRadio.Checked)
{
return BreakpointType.Read;
}
if (WriteRadio.Checked)
{
return BreakpointType.Write;
}
if (ExecuteRadio.Checked)
{
return BreakpointType.Execute;
}
return BreakpointType.Read;
}
}
public uint Address
{
get { return (uint)AddressBox.ToRawInt().Value; }
}
private void AddButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
Close();
}
private void AddBreakpointDialog_Load(object sender, EventArgs e)
{
}
}
public enum BreakpointType { Read, Write, Execute }
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -80,12 +80,18 @@
this.TracerBox = new System.Windows.Forms.GroupBox();
this.StepOverButton = new System.Windows.Forms.Button();
this.StepOutButton = new System.Windows.Forms.Button();
this.BreakpointGroupBox = new System.Windows.Forms.GroupBox();
this.AddBreakpointButton = new System.Windows.Forms.Button();
this.BreakpointView = new BizHawk.Client.EmuHawk.VirtualListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.TraceView = new BizHawk.Client.EmuHawk.VirtualListView();
this.Script = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.DebuggerMenu.SuspendLayout();
this.RegistersBox.SuspendLayout();
this.CoreInfoBox.SuspendLayout();
this.TracerBox.SuspendLayout();
this.BreakpointGroupBox.SuspendLayout();
this.SuspendLayout();
//
// DebuggerMenu
@ -95,7 +101,7 @@
this.OptionsSubMenu});
this.DebuggerMenu.Location = new System.Drawing.Point(0, 0);
this.DebuggerMenu.Name = "DebuggerMenu";
this.DebuggerMenu.Size = new System.Drawing.Size(732, 24);
this.DebuggerMenu.Size = new System.Drawing.Size(653, 24);
this.DebuggerMenu.TabIndex = 0;
this.DebuggerMenu.Text = "menuStrip1";
//
@ -172,7 +178,7 @@
// StepBtn
//
this.StepBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.StepBtn.Location = new System.Drawing.Point(645, 27);
this.StepBtn.Location = new System.Drawing.Point(566, 27);
this.StepBtn.Name = "StepBtn";
this.StepBtn.Size = new System.Drawing.Size(75, 23);
this.StepBtn.TabIndex = 1;
@ -183,7 +189,7 @@
// ScanlineAdvanceBtn
//
this.ScanlineAdvanceBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.ScanlineAdvanceBtn.Location = new System.Drawing.Point(645, 117);
this.ScanlineAdvanceBtn.Location = new System.Drawing.Point(566, 117);
this.ScanlineAdvanceBtn.Name = "ScanlineAdvanceBtn";
this.ScanlineAdvanceBtn.Size = new System.Drawing.Size(75, 23);
this.ScanlineAdvanceBtn.TabIndex = 2;
@ -194,7 +200,7 @@
// FrameAdvButton
//
this.FrameAdvButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.FrameAdvButton.Location = new System.Drawing.Point(645, 144);
this.FrameAdvButton.Location = new System.Drawing.Point(566, 144);
this.FrameAdvButton.Name = "FrameAdvButton";
this.FrameAdvButton.Size = new System.Drawing.Size(75, 23);
this.FrameAdvButton.TabIndex = 3;
@ -558,13 +564,12 @@
//
// TracerBox
//
this.TracerBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.TracerBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.TracerBox.Controls.Add(this.TraceView);
this.TracerBox.Location = new System.Drawing.Point(12, 188);
this.TracerBox.Name = "TracerBox";
this.TracerBox.Size = new System.Drawing.Size(511, 444);
this.TracerBox.Size = new System.Drawing.Size(407, 444);
this.TracerBox.TabIndex = 6;
this.TracerBox.TabStop = false;
this.TracerBox.Text = "Trace log";
@ -572,7 +577,7 @@
// StepOverButton
//
this.StepOverButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.StepOverButton.Location = new System.Drawing.Point(645, 56);
this.StepOverButton.Location = new System.Drawing.Point(566, 56);
this.StepOverButton.Name = "StepOverButton";
this.StepOverButton.Size = new System.Drawing.Size(75, 23);
this.StepOverButton.TabIndex = 7;
@ -582,13 +587,72 @@
// StepOutButton
//
this.StepOutButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.StepOutButton.Location = new System.Drawing.Point(645, 82);
this.StepOutButton.Location = new System.Drawing.Point(566, 82);
this.StepOutButton.Name = "StepOutButton";
this.StepOutButton.Size = new System.Drawing.Size(75, 23);
this.StepOutButton.TabIndex = 8;
this.StepOutButton.Text = "Step O&ut";
this.StepOutButton.UseVisualStyleBackColor = true;
//
// BreakpointGroupBox
//
this.BreakpointGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.BreakpointGroupBox.Controls.Add(this.AddBreakpointButton);
this.BreakpointGroupBox.Controls.Add(this.BreakpointView);
this.BreakpointGroupBox.Location = new System.Drawing.Point(435, 188);
this.BreakpointGroupBox.Name = "BreakpointGroupBox";
this.BreakpointGroupBox.Size = new System.Drawing.Size(206, 444);
this.BreakpointGroupBox.TabIndex = 7;
this.BreakpointGroupBox.TabStop = false;
this.BreakpointGroupBox.Text = "Breakpoints";
//
// AddBreakpointButton
//
this.AddBreakpointButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.AddBreakpointButton.Location = new System.Drawing.Point(8, 409);
this.AddBreakpointButton.Name = "AddBreakpointButton";
this.AddBreakpointButton.Size = new System.Drawing.Size(75, 23);
this.AddBreakpointButton.TabIndex = 5;
this.AddBreakpointButton.Text = "&Add";
this.AddBreakpointButton.UseVisualStyleBackColor = true;
this.AddBreakpointButton.Click += new System.EventHandler(this.AddBreakpointButton_Click);
//
// BreakpointView
//
this.BreakpointView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.BreakpointView.BlazingFast = false;
this.BreakpointView.CheckBoxes = true;
this.BreakpointView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2});
this.BreakpointView.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.BreakpointView.FullRowSelect = true;
this.BreakpointView.GridLines = true;
this.BreakpointView.HideSelection = false;
this.BreakpointView.ItemCount = 0;
this.BreakpointView.Location = new System.Drawing.Point(8, 18);
this.BreakpointView.Name = "BreakpointView";
this.BreakpointView.SelectAllInProgress = false;
this.BreakpointView.selectedItem = -1;
this.BreakpointView.Size = new System.Drawing.Size(192, 384);
this.BreakpointView.TabIndex = 4;
this.BreakpointView.TabStop = false;
this.BreakpointView.UseCompatibleStateImageBehavior = false;
this.BreakpointView.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "Address";
this.columnHeader1.Width = 85;
//
// columnHeader2
//
this.columnHeader2.Text = "Type";
this.columnHeader2.Width = 103;
//
// TraceView
//
this.TraceView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -607,7 +671,7 @@
this.TraceView.Name = "TraceView";
this.TraceView.SelectAllInProgress = false;
this.TraceView.selectedItem = -1;
this.TraceView.Size = new System.Drawing.Size(497, 414);
this.TraceView.Size = new System.Drawing.Size(393, 414);
this.TraceView.TabIndex = 4;
this.TraceView.TabStop = false;
this.TraceView.UseCompatibleStateImageBehavior = false;
@ -622,7 +686,8 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(732, 702);
this.ClientSize = new System.Drawing.Size(653, 702);
this.Controls.Add(this.BreakpointGroupBox);
this.Controls.Add(this.StepOutButton);
this.Controls.Add(this.StepOverButton);
this.Controls.Add(this.TracerBox);
@ -645,6 +710,7 @@
this.CoreInfoBox.ResumeLayout(false);
this.CoreInfoBox.PerformLayout();
this.TracerBox.ResumeLayout(false);
this.BreakpointGroupBox.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -705,5 +771,10 @@
private System.Windows.Forms.ToolStripMenuItem RestoreDefaultsMenuItem;
private System.Windows.Forms.Button StepOverButton;
private System.Windows.Forms.Button StepOutButton;
private System.Windows.Forms.GroupBox BreakpointGroupBox;
private VirtualListView BreakpointView;
public System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.Button AddBreakpointButton;
private System.Windows.Forms.ColumnHeader columnHeader2;
}
}

View File

@ -22,10 +22,13 @@ namespace BizHawk.Client.EmuHawk
// Step
// Advance 1 scanline?
// Settable registers, also implement in lua
// Breakpoints
// Breakpoints - Double click toggle, Delete to remove
// Save breakpoints to file?
private Atari2600 _core = Global.Emulator as Atari2600;
private readonly List<string> _instructions = new List<string>();
private readonly AtariBreakpointList Breakpoints = new AtariBreakpointList();
private int _defaultWidth;
private int _defaultHeight;
@ -89,9 +92,14 @@ namespace BizHawk.Client.EmuHawk
TraceView.QueryItemText += TraceView_QueryItemText;
TraceView.VirtualMode = true;
BreakpointView.QueryItemText += BreakPointView_QueryItemText;
BreakpointView.VirtualMode = true;
TopMost = Global.Config.Atari2600DebuggerSettings.TopMost;
Closing += (o, e) => Shutdown();
Breakpoints.Callback = BreakpointCallback;
}
private void Atari2600Debugger_Load(object sender, EventArgs e)
@ -200,6 +208,40 @@ namespace BizHawk.Client.EmuHawk
text = index < _instructions.Count ? _instructions[index] : string.Empty;
}
private void BreakPointView_QueryItemText(int index, int column, out string text)
{
text = string.Empty;
switch(column)
{
case 0:
text = string.Format("{0:X4}", Breakpoints[index].Address);
break;
case 1:
text = Breakpoints[index].Type.ToString();
break;
}
}
private void BreakPointView_QueryItemBkColor(int index, int column, ref Color color)
{
if (index >= BreakpointView.ItemCount)
{
return;
}
if (column == 0)
{
if (Breakpoints[index].Active)
{
color = Color.LightCyan;
}
else
{
color = BackColor;
}
}
}
#region Events
private void ExitMenuItem_Click(object sender, EventArgs e)
@ -275,5 +317,103 @@ namespace BizHawk.Client.EmuHawk
RefreshFloatingWindowControl();
base.OnShown(e);
}
// TODO: these can be generic to any debugger
#region Breakpoint Classes
public class AtariBreakpointList : List<AtariBreakpoint>
{
public Action Callback { get; set; }
public void Add(uint address, BreakpointType type)
{
Add(new AtariBreakpoint(Callback, address, type));
}
}
public class AtariBreakpoint
{
private bool _active;
public AtariBreakpoint(Action callBack, uint address, BreakpointType type, bool enabled = true)
{
Callback = callBack;
Address = address;
Active = enabled;
if (enabled)
{
AddCallback();
}
}
public Action Callback { get; set; }
public uint Address { get; set; }
public BreakpointType Type { get; set; }
public bool Active
{
get
{
return _active;
}
set
{
if (!value)
{
RemoveCallback();
}
if (!_active && value) // If inactive and changing to active
{
AddCallback();
}
_active = value;
}
}
private void AddCallback()
{
switch (Type)
{
case BreakpointType.Read:
Global.CoreComm.MemoryCallbackSystem.AddRead(Callback, Address);
break;
case BreakpointType.Write:
Global.CoreComm.MemoryCallbackSystem.AddWrite(Callback, Address);
break;
case BreakpointType.Execute:
Global.CoreComm.MemoryCallbackSystem.AddExecute(Callback, Address);
break;
}
}
private void RemoveCallback()
{
Global.CoreComm.MemoryCallbackSystem.Remove(Callback);
}
}
private void AddBreakpointButton_Click(object sender, EventArgs e)
{
var b = new AddBreakpointDialog();
if (b.ShowDialog() == DialogResult.OK)
{
Breakpoints.Add(b.Address, b.BreakType);
}
BreakpointView.ItemCount = Breakpoints.Count;
}
private void BreakpointCallback()
{
GlobalWin.MainForm.PauseEmulator();
UpdateValues();
}
#endregion
}
}