Debugger - add a crude Register box, dynamically reads the cores flags and registers and creates ui, is they are settable it creates textboxes (registers) and checkboxes (flags) with change events that set the core values. If register setting is not implemented, it creates labels instead. Plenty of details to refine about this process.

This commit is contained in:
adelikat 2014-12-06 01:14:58 +00:00
parent 748fab4dfb
commit 4b8f5b2962
6 changed files with 375 additions and 2 deletions

View File

@ -649,6 +649,12 @@
<DependentUpon>GenericDebugger.cs</DependentUpon>
<SubType>Form</SubType>
</Compile>
<Compile Include="tools\Debugger\RegisterBoxControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="tools\Debugger\RegisterBoxControl.Designer.cs">
<DependentUpon>RegisterBoxControl.cs</DependentUpon>
</Compile>
<Compile Include="tools\GBA\GBAGPUView.cs">
<SubType>Form</SubType>
</Compile>
@ -1224,6 +1230,9 @@
<EmbeddedResource Include="tools\Debugger\GenericDebugger.resx">
<DependentUpon>GenericDebugger.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="tools\Debugger\RegisterBoxControl.resx">
<DependentUpon>RegisterBoxControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="tools\GBA\GBAGPUView.resx">
<DependentUpon>GBAGPUView.cs</DependentUpon>
</EmbeddedResource>

View File

@ -42,8 +42,11 @@
this.TracerBox = new System.Windows.Forms.GroupBox();
this.TraceView = new BizHawk.Client.EmuHawk.VirtualListView();
this.Script = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.RegistersGroupBox = new System.Windows.Forms.GroupBox();
this.RegisterPanel = new BizHawk.Client.EmuHawk.RegisterBoxControl();
this.menuStrip1.SuspendLayout();
this.TracerBox.SuspendLayout();
this.RegistersGroupBox.SuspendLayout();
this.SuspendLayout();
//
// menuStrip1
@ -54,7 +57,7 @@
this.OptionsSubMenu});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(685, 24);
this.menuStrip1.Size = new System.Drawing.Size(746, 24);
this.menuStrip1.TabIndex = 1;
this.menuStrip1.Text = "menuStrip1";
//
@ -170,11 +173,37 @@
this.Script.Text = "Instructions";
this.Script.Width = 599;
//
// RegistersGroupBox
//
this.RegistersGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.RegistersGroupBox.Controls.Add(this.RegisterPanel);
this.RegistersGroupBox.Location = new System.Drawing.Point(425, 27);
this.RegistersGroupBox.Name = "RegistersGroupBox";
this.RegistersGroupBox.Size = new System.Drawing.Size(309, 234);
this.RegistersGroupBox.TabIndex = 8;
this.RegistersGroupBox.TabStop = false;
this.RegistersGroupBox.Text = "Registers";
//
// RegisterPanel
//
this.RegisterPanel.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.RegisterPanel.AutoScroll = true;
this.RegisterPanel.Core = null;
this.RegisterPanel.Location = new System.Drawing.Point(8, 19);
this.RegisterPanel.Name = "RegisterPanel";
this.RegisterPanel.ParentDebugger = null;
this.RegisterPanel.Size = new System.Drawing.Size(295, 209);
this.RegisterPanel.TabIndex = 0;
//
// GenericDebugger
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(685, 560);
this.ClientSize = new System.Drawing.Size(746, 560);
this.Controls.Add(this.RegistersGroupBox);
this.Controls.Add(this.TracerBox);
this.Controls.Add(this.menuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
@ -186,6 +215,7 @@
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.TracerBox.ResumeLayout(false);
this.RegistersGroupBox.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -206,5 +236,7 @@
private System.Windows.Forms.GroupBox TracerBox;
private VirtualListView TraceView;
public System.Windows.Forms.ColumnHeader Script;
private System.Windows.Forms.GroupBox RegistersGroupBox;
private RegisterBoxControl RegisterPanel;
}
}

View File

@ -58,12 +58,20 @@ namespace BizHawk.Client.EmuHawk
EngageDebugger();
}
public void DisableRegisterBox()
{
RegistersGroupBox.Enabled = false;
}
private void EngageDebugger()
{
try
{
Core.Tracer.Enabled = true;
TraceView.Columns[0].Text = Core.Tracer.Header;
RegisterPanel.Core = Core;
RegisterPanel.ParentDebugger = this;
RegisterPanel.GenerateUI();
}
catch (NotImplementedException)
{

View File

@ -0,0 +1,47 @@
namespace BizHawk.Client.EmuHawk
{
partial class RegisterBoxControl
{
/// <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 Component 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.SuspendLayout();
//
// RegisterBoxControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "RegisterBoxControl";
this.Size = new System.Drawing.Size(240, 217);
this.Load += new System.EventHandler(this.RegisterBoxControl_Load);
this.ResumeLayout(false);
}
#endregion
}
}

View File

@ -0,0 +1,157 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Common.NumberExtensions;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
public partial class RegisterBoxControl : UserControl
{
public IDebuggable Core { get; set; }
public GenericDebugger ParentDebugger { get; set; }
private bool _supressChangeEvents = false;
public RegisterBoxControl()
{
InitializeComponent();
AutoScroll = true;
}
private void RegisterBoxControl_Load(object sender, EventArgs e)
{
}
private bool CanGetCpuRegisters
{
get
{
try
{
var registers = Core.GetCpuFlagsAndRegisters();
return true;
}
catch (NotImplementedException)
{
return false;
}
}
}
private bool CanSetCpuRegisters
{
get
{
try
{
Core.SetCpuRegister("", 0);
return true;
}
catch (NotImplementedException)
{
return false;
}
catch (Exception)
{
return true;
}
}
}
public void GenerateUI()
{
var canget = CanGetCpuRegisters;
var canset = CanSetCpuRegisters;
if (!canget && !canset)
{
ParentDebugger.DisableRegisterBox();
this.Enabled = false;
}
var registers = Core.GetCpuFlagsAndRegisters();
int y = 0;
foreach (var register in registers)
{
this.Controls.Add(new Label
{
Text = register.Key + (canset ? ": " : ""),
Location = new Point(5, y + 2),
Width = 50
});
if (canset)
{
if (register.Key.Contains("Flag")) // TODO: this depends on naming conventions!
{
var c = new CheckBox
{
Name = register.Key,
Text = "",
Checked = register.Value == 1 ? true : false,
Location = new Point(55, y)
};
c.CheckedChanged += (o, e) =>
{
if (!_supressChangeEvents)
{
try
{
Core.SetCpuRegister(c.Name, c.Checked ? 1 : 0);
}
catch (InvalidOperationException) // TODO: This is hacky stuff because NES doesn't support setting flags! Need to know when a core supports this or not, and enable/disable the box accordingly
{
_supressChangeEvents = true;
c.Checked = !c.Checked;
_supressChangeEvents = false;
c.Enabled = false;
}
}
};
this.Controls.Add(c);
}
else
{
var t = new TextBox
{
Name = register.Key,
Text = register.Value.ToString(),
Width = 75,
Location = new Point(55, y),
};
t.TextChanged += (o, e) =>
{
Core.SetCpuRegister(t.Name, int.Parse(t.Text));
};
this.Controls.Add(t);
}
}
else
{
this.Controls.Add(new Label
{
Name = register.Key,
Text = register.Value.ToString(),
Width = 75,
Location = new Point(55, y)
});
}
y += 25;
}
}
}
}

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>