diff --git a/BizHawk.MultiClient/tools/HexEditor.cs b/BizHawk.MultiClient/tools/HexEditor.cs index 33abeed830..7a7a8d2b81 100644 --- a/BizHawk.MultiClient/tools/HexEditor.cs +++ b/BizHawk.MultiClient/tools/HexEditor.cs @@ -170,14 +170,7 @@ namespace BizHawk.MultiClient memoryDomainsToolStripMenuItem.Enabled = false; } - public void GoToAddress(int address) - { - if (address < MemoryViewer.GetSize()) - { - MemoryViewer.SetHighlighted(address); - MemoryViewer.Refresh(); - } - } + private void goToAddressToolStripMenuItem_Click(object sender, EventArgs e) { @@ -195,6 +188,10 @@ namespace BizHawk.MultiClient } } + public void GoToAddress(int address) + { + MemoryViewer.GoToAddress(address); + } private void HexEditor_Resize(object sender, EventArgs e) diff --git a/BizHawk.MultiClient/tools/MemoryViewer.cs b/BizHawk.MultiClient/tools/MemoryViewer.cs index 6580959811..c93a569957 100644 --- a/BizHawk.MultiClient/tools/MemoryViewer.cs +++ b/BizHawk.MultiClient/tools/MemoryViewer.cs @@ -74,26 +74,22 @@ namespace BizHawk.MultiClient { if (keyData == Keys.Up) { - addressHighlighted -= 16; - this.Refresh(); + GoToAddress(addressHighlighted - 16); } else if (keyData == Keys.Down) { - addressHighlighted += 16; - this.Refresh(); + GoToAddress(addressHighlighted + 16); } else if (keyData == Keys.Left) { - addressHighlighted -= 1; - this.Refresh(); + GoToAddress(addressHighlighted - 1); } else if (keyData == Keys.Right) { - addressHighlighted += 1; - this.Refresh(); + GoToAddress(addressHighlighted + 1); } else if (keyData == Keys.Tab) @@ -102,6 +98,26 @@ namespace BizHawk.MultiClient this.Refresh(); } + else if (keyData == Keys.PageDown) + { + GoToAddress(addressHighlighted + (RowsVisible * 16)); + } + + else if (keyData == Keys.PageUp) + { + GoToAddress(addressHighlighted - (RowsVisible * 16)); + } + + else if (keyData == Keys.Home) + { + GoToAddress(0); + } + + else if (keyData == Keys.End) + { + GoToAddress(GetSize() - 1); + } + return true; } @@ -139,14 +155,20 @@ namespace BizHawk.MultiClient public void SetHighlighted(int addr) { - if (addr < Domain.Size) + if (addr < 0) + addr = 0; + if (addr >= Domain.Size) + addr = Domain.Size - 1; + + if (!IsVisible(addr)) { - if (!IsVisible(addr)) - { - vScrollBar1.Value = (addr >> 4) - RowsVisible + 1; - } - addressHighlighted = addr; + int v = (addr / 16) - RowsVisible + 1; + if (v < 0) + v = 0; + vScrollBar1.Value = v; } + addressHighlighted = addr; + addressOver = addr; } int row = 0; @@ -468,5 +490,17 @@ namespace BizHawk.MultiClient { return Domain; } + + public void GoToAddress(int address) + { + if (address < 0) + address = 0; + + if (address >= GetSize()) + address = GetSize() - 1; + + SetHighlighted(address); + Refresh(); + } } }