Hex Editor - implement viewing in 1 or 2 byte (todo: 4 byte)
This commit is contained in:
parent
5ae14bc55d
commit
80d84888df
|
@ -118,20 +118,23 @@
|
||||||
// byteToolStripMenuItem
|
// byteToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.byteToolStripMenuItem.Name = "byteToolStripMenuItem";
|
this.byteToolStripMenuItem.Name = "byteToolStripMenuItem";
|
||||||
this.byteToolStripMenuItem.Size = new System.Drawing.Size(116, 22);
|
this.byteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
|
||||||
this.byteToolStripMenuItem.Text = "1 Byte";
|
this.byteToolStripMenuItem.Text = "1 Byte";
|
||||||
|
this.byteToolStripMenuItem.Click += new System.EventHandler(this.byteToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// byteToolStripMenuItem1
|
// byteToolStripMenuItem1
|
||||||
//
|
//
|
||||||
this.byteToolStripMenuItem1.Name = "byteToolStripMenuItem1";
|
this.byteToolStripMenuItem1.Name = "byteToolStripMenuItem1";
|
||||||
this.byteToolStripMenuItem1.Size = new System.Drawing.Size(116, 22);
|
this.byteToolStripMenuItem1.Size = new System.Drawing.Size(152, 22);
|
||||||
this.byteToolStripMenuItem1.Text = "2 Byte";
|
this.byteToolStripMenuItem1.Text = "2 Byte";
|
||||||
|
this.byteToolStripMenuItem1.Click += new System.EventHandler(this.byteToolStripMenuItem1_Click);
|
||||||
//
|
//
|
||||||
// byteToolStripMenuItem2
|
// byteToolStripMenuItem2
|
||||||
//
|
//
|
||||||
this.byteToolStripMenuItem2.Name = "byteToolStripMenuItem2";
|
this.byteToolStripMenuItem2.Name = "byteToolStripMenuItem2";
|
||||||
this.byteToolStripMenuItem2.Size = new System.Drawing.Size(116, 22);
|
this.byteToolStripMenuItem2.Size = new System.Drawing.Size(152, 22);
|
||||||
this.byteToolStripMenuItem2.Text = "4 Byte";
|
this.byteToolStripMenuItem2.Text = "4 Byte";
|
||||||
|
this.byteToolStripMenuItem2.Click += new System.EventHandler(this.byteToolStripMenuItem2_Click);
|
||||||
//
|
//
|
||||||
// goToAddressToolStripMenuItem
|
// goToAddressToolStripMenuItem
|
||||||
//
|
//
|
||||||
|
|
|
@ -87,6 +87,26 @@ namespace BizHawk.MultiClient
|
||||||
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
autoloadToolStripMenuItem.Checked = Global.Config.AutoLoadHexEditor;
|
autoloadToolStripMenuItem.Checked = Global.Config.AutoLoadHexEditor;
|
||||||
|
|
||||||
|
switch (MemoryViewer.GetDataSize())
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case 1:
|
||||||
|
byteToolStripMenuItem.Checked = true;
|
||||||
|
byteToolStripMenuItem1.Checked = false;
|
||||||
|
byteToolStripMenuItem2.Checked = false;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
byteToolStripMenuItem.Checked = false;
|
||||||
|
byteToolStripMenuItem1.Checked = true;
|
||||||
|
byteToolStripMenuItem2.Checked = false;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
byteToolStripMenuItem.Checked = false;
|
||||||
|
byteToolStripMenuItem1.Checked = false;
|
||||||
|
byteToolStripMenuItem2.Checked = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetMemoryDomain(int pos)
|
private void SetMemoryDomain(int pos)
|
||||||
|
@ -145,6 +165,21 @@ namespace BizHawk.MultiClient
|
||||||
MemoryViewer.Refresh();
|
MemoryViewer.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void byteToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
MemoryViewer.SetDataSize(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void byteToolStripMenuItem1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
MemoryViewer.SetDataSize(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void byteToolStripMenuItem2_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
MemoryViewer.SetDataSize(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
public class MemoryViewer : GroupBox
|
public class MemoryViewer : GroupBox
|
||||||
{
|
{
|
||||||
//data size variable, and adjust drawing based on it, and a method for parent to set it
|
//TODO: 4 byte
|
||||||
|
|
||||||
public VScrollBar vScrollBar1;
|
public VScrollBar vScrollBar1;
|
||||||
MemoryDomain Domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { });
|
MemoryDomain Domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { });
|
||||||
|
@ -17,6 +17,7 @@ namespace BizHawk.MultiClient
|
||||||
Brush regBrush = Brushes.Black;
|
Brush regBrush = Brushes.Black;
|
||||||
int RowsVisible = 0;
|
int RowsVisible = 0;
|
||||||
int DataSize = 1;
|
int DataSize = 1;
|
||||||
|
bool BigEndian = false;
|
||||||
string Header = "";
|
string Header = "";
|
||||||
|
|
||||||
public MemoryViewer()
|
public MemoryViewer()
|
||||||
|
@ -67,15 +68,22 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case 1:
|
case 1:
|
||||||
Header = " 0 1 2 3 4 5 6 7 8 9 A B C D E F"; //TODO: not constant, must deal with bite size
|
Header = " 0 1 2 3 4 5 6 7 8 9 A B C D E F";
|
||||||
for (int j = 0; j < 16; j++)
|
for (int j = 0; j < 16; j++)
|
||||||
{
|
{
|
||||||
addr = (row * 16) + j;
|
addr = (row * 16) + j;
|
||||||
if (addr < Domain.Size)
|
if (addr < Domain.Size)
|
||||||
rowStr += String.Format("{0:X2}", Domain.PeekByte(addr)) + " "; //TODO: format based on data size
|
rowStr += String.Format("{0:X2}", Domain.PeekByte(addr)) + " ";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
Header = " 0 2 4 6 8 A C E";
|
||||||
|
for (int j = 0; j < 16; j+=2)
|
||||||
|
{
|
||||||
|
addr = (row * 16) + j;
|
||||||
|
if (addr < Domain.Size)
|
||||||
|
rowStr += String.Format("{0:X4}", MakeValue(addr, DataSize, BigEndian)) + " ";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
break;
|
break;
|
||||||
|
@ -89,6 +97,42 @@ namespace BizHawk.MultiClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int MakeValue(int addr, int size, bool Bigendian)
|
||||||
|
{
|
||||||
|
int x = 0;
|
||||||
|
if (size == 1 || size == 2 || size == 4)
|
||||||
|
{
|
||||||
|
switch (size)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
x = Domain.PeekByte(addr);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (Bigendian)
|
||||||
|
{
|
||||||
|
x = Domain.PeekByte(addr) + (Domain.PeekByte(addr + 1) * 255);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = (Domain.PeekByte(addr) * 255) + Domain.PeekByte(addr + 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
if (Bigendian)
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 0; //fail
|
||||||
|
}
|
||||||
|
|
||||||
public void ResetScrollBar()
|
public void ResetScrollBar()
|
||||||
{
|
{
|
||||||
vScrollBar1.Value = 0;
|
vScrollBar1.Value = 0;
|
||||||
|
@ -137,5 +181,16 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
Display(e.Graphics);
|
Display(e.Graphics);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetDataSize(int size)
|
||||||
|
{
|
||||||
|
if (size == 1 || size == 2 || size == 4)
|
||||||
|
DataSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetDataSize()
|
||||||
|
{
|
||||||
|
return DataSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue