Hex Editor - several fps speed up - only draw left column of addresses when needed instead of every frame

This commit is contained in:
adelikat 2012-06-18 03:34:14 +00:00
parent b40d0eb199
commit b4c10f2e15
2 changed files with 46 additions and 9 deletions

View File

@ -78,6 +78,7 @@
this.vScrollBar1 = new System.Windows.Forms.VScrollBar();
this.AddressesLabel = new System.Windows.Forms.Label();
this.Header = new System.Windows.Forms.Label();
this.AddressLabel = new System.Windows.Forms.Label();
this.menuStrip1.SuspendLayout();
this.ViewerContextMenuStrip.SuspendLayout();
this.MemoryViewerBox.SuspendLayout();
@ -446,6 +447,7 @@
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.MemoryViewerBox.ContextMenuStrip = this.ViewerContextMenuStrip;
this.MemoryViewerBox.Controls.Add(this.AddressLabel);
this.MemoryViewerBox.Controls.Add(this.vScrollBar1);
this.MemoryViewerBox.Controls.Add(this.AddressesLabel);
this.MemoryViewerBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
@ -473,7 +475,7 @@
//
this.AddressesLabel.AutoSize = true;
this.AddressesLabel.ContextMenuStrip = this.ViewerContextMenuStrip;
this.AddressesLabel.Location = new System.Drawing.Point(6, 30);
this.AddressesLabel.Location = new System.Drawing.Point(48, 30);
this.AddressesLabel.Name = "AddressesLabel";
this.AddressesLabel.Size = new System.Drawing.Size(31, 13);
this.AddressesLabel.TabIndex = 0;
@ -492,6 +494,16 @@
this.Header.TabIndex = 2;
this.Header.Text = "label1";
//
// AddressLabel
//
this.AddressLabel.AutoSize = true;
this.AddressLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.AddressLabel.Location = new System.Drawing.Point(3, 30);
this.AddressLabel.Name = "AddressLabel";
this.AddressLabel.Size = new System.Drawing.Size(25, 13);
this.AddressLabel.TabIndex = 2;
this.AddressLabel.Text = " ";
//
// HexEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -571,5 +583,6 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator8;
private System.Windows.Forms.ToolStripMenuItem resetToDefaultToolStripMenuItem1;
public System.Windows.Forms.Label Header;
private System.Windows.Forms.Label AddressLabel;
}
}

View File

@ -14,8 +14,9 @@ namespace BizHawk.MultiClient
public partial class HexEditor : Form
{
//TODO:
//Find text box - autohighlights matches, and shows total matches
//Users can customize background, & text colors
//Find Prev, Find Next
//Multi-select
//Open Up ROM in memory domains, set up logic for saving the rom
//Tool strip
//Increment/Decrement wrapping logic for 2 and 4 byte values
int defaultWidth;
@ -63,6 +64,7 @@ namespace BizHawk.MultiClient
Closing += (o, e) => SaveConfigSettings();
Header.Font = new Font("Courier New", 8);
AddressesLabel.Font = new Font("Courier New", 8);
AddressLabel.Font = new Font("Courier New", 8);
}
private void LoadConfigSettings()
@ -115,6 +117,7 @@ namespace BizHawk.MultiClient
SetDataSize(DataSize);
UpdateValues();
loaded = true;
AddressLabel.Text = GenerateAddressString();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
@ -129,18 +132,35 @@ namespace BizHawk.MultiClient
AddressesLabel.Text = GenerateMemoryViewString();
}
public string GenerateMemoryViewString()
public string GenerateAddressString()
{
StringBuilder rowStr = new StringBuilder("");
addrOffset = (NumDigits % 4) * 9;
StringBuilder addrStr = new StringBuilder();
for (int i = 0; i < RowsVisible; i++)
{
row = i + vScrollBar1.Value;
addr = (row * 16);
addr = (row << 4);
if (addr >= Domain.Size)
break;
rowStr.AppendFormat(NumDigitsStr, addr);
addrStr.AppendFormat(NumDigitsStr, addr);
addrStr.Append('\n');
}
return addrStr.ToString();
}
public string GenerateMemoryViewString()
{
StringBuilder rowStr = new StringBuilder();
addrOffset = (NumDigits % 4) * 9; //TODO: I dont think this has any purpose here anymore, if this needs to be calculated, it could be done outside the frame loop
for (int i = 0; i < RowsVisible; i++)
{
row = i + vScrollBar1.Value;
addr = (row << 4);
if (addr >= Domain.Size)
break;
//rowStr.AppendFormat(NumDigitsStr, addr);
for (int j = 0; j < 16; j += DataSize)
{
@ -362,6 +382,7 @@ namespace BizHawk.MultiClient
GoToAddress(int.Parse(i.UserText, NumberStyles.HexNumber));
}
}
AddressLabel.Text = GenerateAddressString();
}
private void ClearNibbles()
@ -382,6 +403,7 @@ namespace BizHawk.MultiClient
ClearNibbles();
UpdateValues();
MemoryViewerBox.Refresh();
AddressLabel.Text = GenerateAddressString();
}
public void SetHighlighted(int addr)
@ -867,6 +889,7 @@ namespace BizHawk.MultiClient
else
vScrollBar1.Visible = false;
AddressLabel.Text = GenerateAddressString();
}
private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
@ -895,7 +918,7 @@ namespace BizHawk.MultiClient
colWidth = 9;
break;
}
int column = (x - 43) / (fontWidth * colWidth);
int column = (x /*- 43*/) / (fontWidth * colWidth);
if (row >= 0 && row <= maxRow && column >= 0 && column < (16 / DataSize))
{
@ -907,6 +930,7 @@ namespace BizHawk.MultiClient
addressOver = -1;
info = "";
}
AddressLabel.Text = GenerateAddressString();
}
private void HexEditor_ResizeEnd(object sender, EventArgs e)