Hex Editor - fix 6 digit domains (note that 8 digit will still fail should we have any)

This commit is contained in:
adelikat 2012-09-11 00:17:54 +00:00
parent 95cb43329b
commit eaa212fef7
2 changed files with 33 additions and 27 deletions

View File

@ -32,8 +32,9 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HexEditor));
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dumpToFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveAsBinaryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dumpToFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -83,7 +84,6 @@
this.vScrollBar1 = new System.Windows.Forms.VScrollBar();
this.AddressesLabel = new System.Windows.Forms.Label();
this.Header = new System.Windows.Forms.Label();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.ViewerContextMenuStrip.SuspendLayout();
this.MemoryViewerBox.SuspendLayout();
@ -115,12 +115,14 @@
this.fileToolStripMenuItem.Text = "&File";
this.fileToolStripMenuItem.DropDownOpened += new System.EventHandler(this.fileToolStripMenuItem_DropDownOpened);
//
// dumpToFileToolStripMenuItem
// saveToolStripMenuItem
//
this.dumpToFileToolStripMenuItem.Name = "dumpToFileToolStripMenuItem";
this.dumpToFileToolStripMenuItem.Size = new System.Drawing.Size(229, 22);
this.dumpToFileToolStripMenuItem.Text = "Save as text...";
this.dumpToFileToolStripMenuItem.Click += new System.EventHandler(this.dumpToFileToolStripMenuItem_Click);
this.saveToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.SaveAs;
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.saveToolStripMenuItem.Size = new System.Drawing.Size(229, 22);
this.saveToolStripMenuItem.Text = "Save";
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
//
// saveAsBinaryToolStripMenuItem
//
@ -131,6 +133,13 @@
this.saveAsBinaryToolStripMenuItem.Text = "Save as binary...";
this.saveAsBinaryToolStripMenuItem.Click += new System.EventHandler(this.saveAsBinaryToolStripMenuItem_Click);
//
// dumpToFileToolStripMenuItem
//
this.dumpToFileToolStripMenuItem.Name = "dumpToFileToolStripMenuItem";
this.dumpToFileToolStripMenuItem.Size = new System.Drawing.Size(229, 22);
this.dumpToFileToolStripMenuItem.Text = "Save as text...";
this.dumpToFileToolStripMenuItem.Click += new System.EventHandler(this.dumpToFileToolStripMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
@ -532,7 +541,7 @@
//
this.AddressesLabel.AutoSize = true;
this.AddressesLabel.ContextMenuStrip = this.ViewerContextMenuStrip;
this.AddressesLabel.Location = new System.Drawing.Point(48, 30);
this.AddressesLabel.Location = new System.Drawing.Point(55, 30);
this.AddressesLabel.Name = "AddressesLabel";
this.AddressesLabel.Size = new System.Drawing.Size(31, 13);
this.AddressesLabel.TabIndex = 0;
@ -551,15 +560,6 @@
this.Header.TabIndex = 2;
this.Header.Text = "label1";
//
// saveToolStripMenuItem
//
this.saveToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.SaveAs;
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
this.saveToolStripMenuItem.Size = new System.Drawing.Size(229, 22);
this.saveToolStripMenuItem.Text = "Save";
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
//
// HexEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

View File

@ -22,8 +22,8 @@ namespace BizHawk.MultiClient
List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>();
int RowsVisible = 0;
int NumDigits = 4;
string NumDigitsStr = "{0:X4} ";
string DigitFormatString = "{0:X2} ";
string NumDigitsStr = "{0:X4}";
string DigitFormatString = "{0:X2}";
char[] nibbles = { 'G', 'G', 'G', 'G' , 'G', 'G', 'G', 'G'}; //G = off 0-9 & A-F are acceptable values
int addressHighlighted = -1;
List<int> SecondaryHighlightedAddresses = new List<int>();
@ -150,8 +150,14 @@ namespace BizHawk.MultiClient
addr = (row << 4);
if (addr >= Domain.Size)
break;
addrStr.AppendFormat(NumDigitsStr, addr);
if (NumDigits == 4)
{
addrStr.Append(" "); //Hack to line things up better between 4 and 6
}
addrStr.Append(String.Format("{0:X" + NumDigits + "}", addr));
addrStr.Append('\n');
}
return addrStr.ToString();
@ -1061,7 +1067,7 @@ namespace BizHawk.MultiClient
}
int column = (x /*- 43*/) / (fontWidth * colWidth);
int start = GetTextOffset() - - 50;
int start = GetTextOffset() - 50;
if (x > start)
{
column = (x - start) / (fontWidth / DataSize);
@ -1161,11 +1167,11 @@ namespace BizHawk.MultiClient
{
default:
case 1:
return new Point(((address % 16) * (fontWidth * 3)) + 50, (((address / 16) - vScrollBar1.Value) * fontHeight) + 30);
return new Point(((address % 16) * (fontWidth * 3)) + 57, (((address / 16) - vScrollBar1.Value) * fontHeight) + 30);
case 2:
return new Point((((address % 16) / DataSize) * (fontWidth * 5)) + 50, (((address / 16) - vScrollBar1.Value) * fontHeight) + 30);
return new Point((((address % 16) / DataSize) * (fontWidth * 5)) + 57, (((address / 16) - vScrollBar1.Value) * fontHeight) + 30);
case 4:
return new Point((((address % 16) / DataSize) * (fontWidth * 9)) + 50, (((address / 16) - vScrollBar1.Value) * fontHeight) + 30);
return new Point((((address % 16) / DataSize) * (fontWidth * 9)) + 57, (((address / 16) - vScrollBar1.Value) * fontHeight) + 30);
}
}
@ -1176,13 +1182,13 @@ namespace BizHawk.MultiClient
{
default:
case 1:
start = (16 * (fontWidth * 3)) + 50;
start = (16 * (fontWidth * 3)) + 57;
break;
case 2:
start = ((16 / DataSize) * (fontWidth * 5)) + 50;
start = ((16 / DataSize) * (fontWidth * 5)) + 57;
break;
case 4:
start = ((16 / DataSize) * (fontWidth * 9)) + 50;
start = ((16 / DataSize) * (fontWidth * 9)) + 57;
break;
}
start += (fontWidth * 4);