Hex Editor - implement big/little endian toggling

This commit is contained in:
andres.delikat 2011-03-07 04:40:51 +00:00
parent 80d84888df
commit e913d5e0cb
3 changed files with 25 additions and 4 deletions

View File

@ -44,6 +44,7 @@
this.restoreWindowSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.MemoryViewer = new BizHawk.MultiClient.MemoryViewer();
this.enToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
@ -93,6 +94,7 @@
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.memoryDomainsToolStripMenuItem,
this.dataSizeToolStripMenuItem,
this.enToolStripMenuItem,
this.goToAddressToolStripMenuItem});
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(56, 20);
@ -178,6 +180,13 @@
this.MemoryViewer.TabStop = false;
this.MemoryViewer.Text = "RAM";
//
// enToolStripMenuItem
//
this.enToolStripMenuItem.Name = "enToolStripMenuItem";
this.enToolStripMenuItem.Size = new System.Drawing.Size(192, 22);
this.enToolStripMenuItem.Text = "Big Endian";
this.enToolStripMenuItem.Click += new System.EventHandler(this.enToolStripMenuItem_Click);
//
// HexEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -215,5 +224,6 @@
private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem restoreWindowSizeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem enToolStripMenuItem;
}
}

View File

@ -87,7 +87,7 @@ namespace BizHawk.MultiClient
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{
autoloadToolStripMenuItem.Checked = Global.Config.AutoLoadHexEditor;
enToolStripMenuItem.Checked = MemoryViewer.BigEndian;
switch (MemoryViewer.GetDataSize())
{
default:
@ -180,6 +180,11 @@ namespace BizHawk.MultiClient
MemoryViewer.SetDataSize(4);
}
private void enToolStripMenuItem_Click(object sender, EventArgs e)
{
MemoryViewer.BigEndian ^= true;
}
}
}

View File

@ -17,7 +17,7 @@ namespace BizHawk.MultiClient
Brush regBrush = Brushes.Black;
int RowsVisible = 0;
int DataSize = 1;
bool BigEndian = false;
public bool BigEndian = false;
string Header = "";
public MemoryViewer()
@ -62,8 +62,7 @@ namespace BizHawk.MultiClient
for (int i = 0; i < RowsVisible; i++)
{
row = i + vScrollBar1.Value;
rowStr = String.Format("{0:X4}", row * 16) + " "; //TODO: num digits based on size of domain
rowStr = String.Format("{0:X" + GetNumDigits(Domain.Size) + "}", row * 16) + " "; //TODO: fix offsets on vertical line & digits if > 4
switch (DataSize)
{
default:
@ -192,5 +191,12 @@ namespace BizHawk.MultiClient
{
return DataSize;
}
private int GetNumDigits(Int32 i)
{
if (i < 0x10000) return 4;
if (i < 0x1000000) return 6;
else return 8;
}
}
}