Progress on Hex Editor. 16 addresses are displayed in the dialog!!

This commit is contained in:
andres.delikat 2011-03-06 19:25:37 +00:00
parent 54b408f875
commit c8a6da7e67
3 changed files with 93 additions and 22 deletions

View File

@ -40,9 +40,10 @@
this.byteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.byteToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.byteToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.restoreWindowSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.goToAddressToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
@ -63,7 +64,8 @@
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.optionsToolStripMenuItem});
this.optionsToolStripMenuItem,
this.settingsToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(508, 24);
@ -104,9 +106,7 @@
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.memoryDomainsToolStripMenuItem,
this.dataSizeToolStripMenuItem,
this.toolStripSeparator2,
this.restoreWindowSizeToolStripMenuItem,
this.autoloadToolStripMenuItem});
this.goToAddressToolStripMenuItem});
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(56, 20);
this.optionsToolStripMenuItem.Text = "&Options";
@ -146,24 +146,34 @@
this.byteToolStripMenuItem2.Size = new System.Drawing.Size(152, 22);
this.byteToolStripMenuItem2.Text = "4 Byte";
//
// toolStripSeparator2
// settingsToolStripMenuItem
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(183, 6);
this.settingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.restoreWindowSizeToolStripMenuItem,
this.autoloadToolStripMenuItem});
this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem";
this.settingsToolStripMenuItem.Size = new System.Drawing.Size(58, 20);
this.settingsToolStripMenuItem.Text = "&Settings";
//
// restoreWindowSizeToolStripMenuItem
//
this.restoreWindowSizeToolStripMenuItem.Name = "restoreWindowSizeToolStripMenuItem";
this.restoreWindowSizeToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
this.restoreWindowSizeToolStripMenuItem.Text = "&Restore Window Size";
this.restoreWindowSizeToolStripMenuItem.Click += new System.EventHandler(this.restoreWindowSizeToolStripMenuItem_Click);
//
// autoloadToolStripMenuItem
//
this.autoloadToolStripMenuItem.Name = "autoloadToolStripMenuItem";
this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
this.autoloadToolStripMenuItem.Text = "Auto-load";
this.autoloadToolStripMenuItem.Click += new System.EventHandler(this.autoloadToolStripMenuItem_Click);
//
// goToAddressToolStripMenuItem
//
this.goToAddressToolStripMenuItem.Name = "goToAddressToolStripMenuItem";
this.goToAddressToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.G)));
this.goToAddressToolStripMenuItem.Size = new System.Drawing.Size(192, 22);
this.goToAddressToolStripMenuItem.Text = "Go to Address";
this.goToAddressToolStripMenuItem.Click += new System.EventHandler(this.goToAddressToolStripMenuItem_Click);
//
// HexEditor
//
@ -197,7 +207,8 @@
private System.Windows.Forms.ToolStripMenuItem byteToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem byteToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem byteToolStripMenuItem2;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem goToAddressToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem restoreWindowSizeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem;
}

View File

@ -12,7 +12,19 @@ namespace BizHawk.MultiClient
public partial class HexEditor : Form
{
//TODO:
//Everything
//Find text box - autohighlights matches, and shows total matches
//Implement Goto address
//Scroll bar
//Users can customize background, & text colors
//Context menu - Poke, Freeze/Unfreeze, Watch
//Tool strip
//Double click addres = send to ram watch
//Add to Ram Watch menu item, enabled conditionally on if any address is highlighted
//Text box showing currently highlighted address(es) & total
//Typing legit hex values = memory poke
//Show num addresses in group box title (show "address" if 1 address)
int defaultWidth;
int defaultHeight;
@ -44,6 +56,8 @@ namespace BizHawk.MultiClient
{
this.Size = new System.Drawing.Size(Global.Config.HexEditorWidth, Global.Config.HexEditorHeight);
}
SetMemoryDomainMenu();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
@ -53,17 +67,16 @@ namespace BizHawk.MultiClient
private void MemoryViewer_Paint(object sender, PaintEventArgs e)
{
// Create a local version of the graphics object for the PictureBox.
Graphics g = e.Graphics;
Font font = new Font("Arial", 10);
//TODO: big font for currently mouse over'ed value?
Brush regBrush = Brushes.Black;
// Draw a string on the PictureBox.
g.DrawString("This is a diagonal line drawn on the control",
new Font("Arial",10), System.Drawing.Brushes.Blue, new Point(30,30));
// Draw a line in the PictureBox.
g.DrawLine(System.Drawing.Pens.Red, this.Left, this.Top,
this.Right, this.Bottom);
string row = "";
for (int x = 0; x < 16; x++)
row += String.Format("{0:X2}", Domain.PeekByte(x)) + " "; //TODO: format based on data size
g.DrawString(row, font, regBrush, new Point(16, 16));
}
public void UpdateValues()
@ -74,7 +87,7 @@ namespace BizHawk.MultiClient
public void Restart()
{
//TODO
SetMemoryDomainMenu(); //Calls update routines
}
private void restoreWindowSizeToolStripMenuItem_Click(object sender, EventArgs e)
@ -91,5 +104,52 @@ namespace BizHawk.MultiClient
{
autoloadToolStripMenuItem.Checked = Global.Config.AutoLoadHexEditor;
}
private void SetMemoryDomain(int pos)
{
if (pos < Global.Emulator.MemoryDomains.Count) //Sanity check
{
Domain = Global.Emulator.MemoryDomains[pos];
}
UpdateDomainString();
}
private void UpdateDomainString()
{
string memoryDomain = Domain.ToString();
string systemID = Global.Emulator.SystemId;
MemoryViewer.Text = systemID + " " + memoryDomain;
}
private void SetMemoryDomainMenu()
{
memoryDomainsToolStripMenuItem.DropDownItems.Clear();
if (Global.Emulator.MemoryDomains.Count > 0)
{
for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
{
string str = Global.Emulator.MemoryDomains[x].ToString();
var item = new ToolStripMenuItem();
item.Text = str;
{
int z = x;
item.Click += (o, ev) => SetMemoryDomain(z);
}
if (x == 0)
{
//item.Checked = true; //TODO: figure out how to check/uncheck these in SetMemoryDomain
SetMemoryDomain(x);
}
memoryDomainsToolStripMenuItem.DropDownItems.Add(item);
}
}
else
memoryDomainsToolStripMenuItem.Enabled = false;
}
private void goToAddressToolStripMenuItem_Click(object sender, EventArgs e)
{
//TODO
}
}
}

View File

@ -31,7 +31,7 @@ namespace BizHawk.MultiClient
public enum SCompareTo { PREV, VALUE, ADDRESS, CHANGES };
public enum SOperator { LESS, GREATER, LESSEQUAL, GREATEREQUAL, EQUAL, NOTEQUAL, DIFFBY };
public enum SSigned { SIGNED, UNSIGNED, HEX };
//Reset window position item
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
int defaultHeight;