2011-03-06 15:03:17 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
2011-03-08 13:33:46 +00:00
|
|
|
|
using System.Globalization;
|
2011-08-07 19:30:01 +00:00
|
|
|
|
using System.IO;
|
2011-03-06 15:03:17 +00:00
|
|
|
|
|
|
|
|
|
namespace BizHawk.MultiClient
|
|
|
|
|
{
|
2011-06-19 23:39:25 +00:00
|
|
|
|
public partial class HexEditor : Form
|
|
|
|
|
{
|
|
|
|
|
//TODO:
|
2012-06-25 03:10:04 +00:00
|
|
|
|
//Increment/Decrement wrapping logic for 4 byte values is messed up
|
2012-09-03 00:49:59 +00:00
|
|
|
|
//2 & 4 byte text area clicking is off
|
2012-06-19 02:42:07 +00:00
|
|
|
|
|
2011-06-19 23:39:25 +00:00
|
|
|
|
int defaultWidth;
|
|
|
|
|
int defaultHeight;
|
|
|
|
|
List<ToolStripMenuItem> domainMenuItems = new List<ToolStripMenuItem>();
|
2011-08-22 02:48:12 +00:00
|
|
|
|
int RowsVisible = 0;
|
|
|
|
|
int NumDigits = 4;
|
2011-08-25 23:49:13 +00:00
|
|
|
|
string NumDigitsStr = "{0:X4} ";
|
2011-08-27 04:32:54 +00:00
|
|
|
|
string DigitFormatString = "{0:X2} ";
|
2011-08-25 01:49:22 +00:00
|
|
|
|
char[] nibbles = { 'G', 'G', 'G', 'G' , 'G', 'G', 'G', 'G'}; //G = off 0-9 & A-F are acceptable values
|
2011-08-22 02:48:12 +00:00
|
|
|
|
int addressHighlighted = -1;
|
2012-06-19 02:42:07 +00:00
|
|
|
|
List<int> SecondaryHighlightedAddresses = new List<int>();
|
2011-08-22 02:48:12 +00:00
|
|
|
|
int addressOver = -1;
|
|
|
|
|
int addrOffset = 0; //If addresses are > 4 digits, this offset is how much the columns are moved to the right
|
|
|
|
|
int maxRow = 0;
|
|
|
|
|
MemoryDomain Domain = new MemoryDomain("NULL", 1024, Endian.Little, addr => { return 0; }, (a, v) => { v = 0; });
|
|
|
|
|
string info = "";
|
|
|
|
|
int row = 0;
|
|
|
|
|
int addr = 0;
|
2011-08-23 22:22:24 +00:00
|
|
|
|
private int Pointedx = 0;
|
|
|
|
|
private int Pointedy = 0;
|
2011-08-22 02:48:12 +00:00
|
|
|
|
const int rowX = 1;
|
|
|
|
|
const int rowY = 4;
|
|
|
|
|
const int rowYoffset = 20;
|
2011-08-23 22:44:23 +00:00
|
|
|
|
const int fontHeight = 14;
|
2011-08-24 02:31:45 +00:00
|
|
|
|
const int fontWidth = 7; //Width of 1 digits
|
2012-06-23 18:45:01 +00:00
|
|
|
|
string FindStr = "";
|
2012-03-09 16:13:40 +00:00
|
|
|
|
bool loaded = false;
|
2012-06-10 16:34:35 +00:00
|
|
|
|
|
2012-09-02 19:22:51 +00:00
|
|
|
|
byte[] ROM;
|
|
|
|
|
MemoryDomain ROMDomain;
|
|
|
|
|
|
2012-06-10 16:34:35 +00:00
|
|
|
|
// Configurations
|
2012-03-09 16:13:40 +00:00
|
|
|
|
bool AutoLoad;
|
|
|
|
|
bool SaveWindowPosition;
|
|
|
|
|
int Wndx = -1;
|
|
|
|
|
int Wndy = -1;
|
2012-03-09 16:37:55 +00:00
|
|
|
|
int Width_ = -1;
|
|
|
|
|
int Height_ = -1;
|
2012-03-09 16:13:40 +00:00
|
|
|
|
bool BigEndian;
|
|
|
|
|
int DataSize;
|
|
|
|
|
|
2012-06-23 18:45:01 +00:00
|
|
|
|
HexFind HexFind1 = new HexFind();
|
|
|
|
|
|
2011-06-19 23:39:25 +00:00
|
|
|
|
public HexEditor()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2011-08-23 01:43:19 +00:00
|
|
|
|
AddressesLabel.BackColor = Color.Transparent;
|
2012-03-09 16:13:40 +00:00
|
|
|
|
LoadConfigSettings();
|
2011-08-22 02:48:12 +00:00
|
|
|
|
SetHeader();
|
2011-06-19 23:39:25 +00:00
|
|
|
|
Closing += (o, e) => SaveConfigSettings();
|
2012-06-13 02:18:34 +00:00
|
|
|
|
Header.Font = new Font("Courier New", 8);
|
|
|
|
|
AddressesLabel.Font = new Font("Courier New", 8);
|
2012-06-18 03:34:14 +00:00
|
|
|
|
AddressLabel.Font = new Font("Courier New", 8);
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-03-09 16:13:40 +00:00
|
|
|
|
private void LoadConfigSettings()
|
|
|
|
|
{
|
|
|
|
|
AutoLoad = Global.Config.AutoLoadHexEditor;
|
|
|
|
|
SaveWindowPosition = Global.Config.SaveWindowPosition;
|
|
|
|
|
Wndx = Global.Config.HexEditorWndx;
|
|
|
|
|
Wndy = Global.Config.HexEditorWndy;
|
2012-03-09 16:37:55 +00:00
|
|
|
|
Width_ = Global.Config.HexEditorWidth;
|
|
|
|
|
Height_ = Global.Config.HexEditorHeight;
|
2012-03-09 16:13:40 +00:00
|
|
|
|
BigEndian = Global.Config.HexEditorBigEndian;
|
|
|
|
|
DataSize = Global.Config.HexEditorDataSize;
|
2012-06-12 03:50:25 +00:00
|
|
|
|
//Colors
|
|
|
|
|
menuStrip1.BackColor = Global.Config.HexMenubarColor;
|
|
|
|
|
MemoryViewerBox.BackColor = Global.Config.HexBackgrndColor;
|
|
|
|
|
MemoryViewerBox.ForeColor = Global.Config.HexForegrndColor;
|
2012-06-13 02:44:19 +00:00
|
|
|
|
Header.BackColor = Global.Config.HexBackgrndColor;
|
|
|
|
|
Header.ForeColor = Global.Config.HexForegrndColor;
|
|
|
|
|
|
2012-03-09 16:13:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-19 23:39:25 +00:00
|
|
|
|
public void SaveConfigSettings()
|
|
|
|
|
{
|
2012-06-23 18:45:01 +00:00
|
|
|
|
if (HexFind1.IsHandleCreated || !HexFind1.IsDisposed)
|
|
|
|
|
{
|
|
|
|
|
HexFind1.Close();
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-09 16:13:40 +00:00
|
|
|
|
Global.Config.AutoLoadHexEditor = AutoLoad;
|
|
|
|
|
Global.Config.HexEditorSaveWindowPosition = SaveWindowPosition;
|
|
|
|
|
if (SaveWindowPosition)
|
2011-06-19 23:39:25 +00:00
|
|
|
|
{
|
2012-03-09 16:13:40 +00:00
|
|
|
|
Global.Config.HexEditorWndx = loaded ? this.Location.X : Wndx;
|
|
|
|
|
Global.Config.HexEditorWndy = loaded ? this.Location.Y : Wndy;
|
2012-03-09 16:37:55 +00:00
|
|
|
|
Global.Config.HexEditorWidth = loaded ? this.Right - this.Left : Width_;
|
|
|
|
|
Global.Config.HexEditorHeight = loaded ? this.Bottom - this.Top : Height_;
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
2012-03-09 16:13:40 +00:00
|
|
|
|
Global.Config.HexEditorBigEndian = BigEndian;
|
|
|
|
|
Global.Config.HexEditorDataSize = DataSize;
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HexEditor_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
2012-03-09 17:14:39 +00:00
|
|
|
|
defaultWidth = this.Size.Width; //Save these first so that the user can restore to its original size
|
|
|
|
|
defaultHeight = this.Size.Height;
|
2012-03-09 16:13:40 +00:00
|
|
|
|
if (SaveWindowPosition)
|
2011-06-19 23:39:25 +00:00
|
|
|
|
{
|
2012-03-09 16:13:40 +00:00
|
|
|
|
if (Wndx >= 0 && Wndy >= 0)
|
|
|
|
|
this.Location = new Point(Wndx, Wndy);
|
2011-06-19 23:39:25 +00:00
|
|
|
|
|
2012-03-09 16:37:55 +00:00
|
|
|
|
if (Width_ >= 0 && Height_ >= 0)
|
|
|
|
|
this.Size = new System.Drawing.Size(Width_, Height_);
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
SetMemoryDomainMenu();
|
2012-03-09 16:13:40 +00:00
|
|
|
|
SetDataSize(DataSize);
|
2011-08-25 02:23:12 +00:00
|
|
|
|
UpdateValues();
|
2012-03-09 16:13:40 +00:00
|
|
|
|
loaded = true;
|
2012-06-18 03:34:14 +00:00
|
|
|
|
AddressLabel.Text = GenerateAddressString();
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateValues()
|
|
|
|
|
{
|
|
|
|
|
if (!this.IsHandleCreated || this.IsDisposed) return;
|
2011-08-22 02:48:12 +00:00
|
|
|
|
|
2011-08-22 16:34:47 +00:00
|
|
|
|
AddressesLabel.Text = GenerateMemoryViewString();
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-18 03:34:14 +00:00
|
|
|
|
public string GenerateAddressString()
|
|
|
|
|
{
|
|
|
|
|
StringBuilder addrStr = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < RowsVisible; i++)
|
|
|
|
|
{
|
|
|
|
|
row = i + vScrollBar1.Value;
|
|
|
|
|
addr = (row << 4);
|
|
|
|
|
if (addr >= Domain.Size)
|
|
|
|
|
break;
|
|
|
|
|
addrStr.AppendFormat(NumDigitsStr, addr);
|
|
|
|
|
addrStr.Append('\n');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return addrStr.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-22 16:42:32 +00:00
|
|
|
|
public string GenerateMemoryViewString()
|
2011-08-22 02:48:12 +00:00
|
|
|
|
{
|
2012-06-18 03:34:14 +00:00
|
|
|
|
StringBuilder rowStr = new StringBuilder();
|
2011-08-24 02:48:52 +00:00
|
|
|
|
|
2011-08-27 04:32:54 +00:00
|
|
|
|
for (int i = 0; i < RowsVisible; i++)
|
|
|
|
|
{
|
|
|
|
|
row = i + vScrollBar1.Value;
|
2012-06-18 03:34:14 +00:00
|
|
|
|
addr = (row << 4);
|
2011-08-27 04:32:54 +00:00
|
|
|
|
if (addr >= Domain.Size)
|
|
|
|
|
break;
|
2012-06-18 03:39:21 +00:00
|
|
|
|
|
2012-03-09 16:13:40 +00:00
|
|
|
|
for (int j = 0; j < 16; j += DataSize)
|
2011-08-27 04:32:54 +00:00
|
|
|
|
{
|
|
|
|
|
if (addr + j < Domain.Size)
|
2012-09-02 22:45:06 +00:00
|
|
|
|
{
|
2011-08-27 04:32:54 +00:00
|
|
|
|
rowStr.AppendFormat(DigitFormatString, MakeValue(addr + j));
|
2012-09-02 22:45:06 +00:00
|
|
|
|
}
|
2011-08-27 04:32:54 +00:00
|
|
|
|
}
|
|
|
|
|
rowStr.Append(" | ");
|
|
|
|
|
for (int k = 0; k < 16; k++)
|
|
|
|
|
{
|
2012-09-02 22:45:06 +00:00
|
|
|
|
if (addr + k < Domain.Size)
|
|
|
|
|
{
|
|
|
|
|
rowStr.Append(Remap(Domain.PeekByte(addr + k)));
|
|
|
|
|
}
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
2011-08-27 04:32:54 +00:00
|
|
|
|
rowStr.AppendLine();
|
|
|
|
|
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
2011-08-27 04:32:54 +00:00
|
|
|
|
return rowStr.ToString();
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char Remap(byte val)
|
|
|
|
|
{
|
2011-08-27 14:49:13 +00:00
|
|
|
|
if (val < ' ') return '.';
|
|
|
|
|
else if (val >= 0x80) return '.';
|
|
|
|
|
else return (char)val;
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-24 02:31:45 +00:00
|
|
|
|
private int MakeValue(int addr)
|
2011-08-22 02:48:12 +00:00
|
|
|
|
{
|
2011-08-27 04:32:54 +00:00
|
|
|
|
|
2012-03-09 16:13:40 +00:00
|
|
|
|
switch (DataSize)
|
2011-08-22 02:48:12 +00:00
|
|
|
|
{
|
2011-08-27 04:32:54 +00:00
|
|
|
|
default:
|
|
|
|
|
case 1:
|
|
|
|
|
return Domain.PeekByte(addr);
|
|
|
|
|
case 2:
|
2012-03-09 16:13:40 +00:00
|
|
|
|
if (BigEndian)
|
2012-06-09 22:56:08 +00:00
|
|
|
|
{
|
|
|
|
|
int value = 0;
|
|
|
|
|
value |= Domain.PeekByte(addr) << 8;
|
|
|
|
|
value |= Domain.PeekByte(addr + 1);
|
|
|
|
|
return value;
|
|
|
|
|
}
|
2011-08-27 04:32:54 +00:00
|
|
|
|
else
|
2012-06-09 22:56:08 +00:00
|
|
|
|
{
|
|
|
|
|
int value = 0;
|
|
|
|
|
value |= Domain.PeekByte(addr);
|
|
|
|
|
value |= Domain.PeekByte(addr + 1) << 8;
|
|
|
|
|
return value;
|
|
|
|
|
}
|
2011-08-27 04:32:54 +00:00
|
|
|
|
case 4:
|
2012-03-09 16:13:40 +00:00
|
|
|
|
if (BigEndian)
|
2012-06-09 22:56:08 +00:00
|
|
|
|
{
|
|
|
|
|
int value = 0;
|
|
|
|
|
value |= Domain.PeekByte(addr) << 24;
|
|
|
|
|
value |= Domain.PeekByte(addr + 1) << 16;
|
|
|
|
|
value |= Domain.PeekByte(addr + 2) << 8;
|
|
|
|
|
value |= Domain.PeekByte(addr + 3) << 0;
|
|
|
|
|
return value;
|
|
|
|
|
}
|
2011-08-27 04:32:54 +00:00
|
|
|
|
else
|
2012-06-09 22:56:08 +00:00
|
|
|
|
{
|
|
|
|
|
int value = 0;
|
|
|
|
|
value |= Domain.PeekByte(addr) << 0;
|
|
|
|
|
value |= Domain.PeekByte(addr + 1) << 8;
|
|
|
|
|
value |= Domain.PeekByte(addr + 2) << 16;
|
|
|
|
|
value |= Domain.PeekByte(addr + 3) << 24;
|
|
|
|
|
return value;
|
|
|
|
|
}
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-19 23:39:25 +00:00
|
|
|
|
public void Restart()
|
|
|
|
|
{
|
|
|
|
|
if (!this.IsHandleCreated || this.IsDisposed) return;
|
|
|
|
|
SetMemoryDomainMenu(); //Calls update routines
|
2011-08-22 02:48:12 +00:00
|
|
|
|
ResetScrollBar();
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void restoreWindowSizeToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Size = new System.Drawing.Size(defaultWidth, defaultHeight);
|
2011-08-22 02:48:12 +00:00
|
|
|
|
SetUpScrollBar();
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void autoloadToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2012-03-09 16:13:40 +00:00
|
|
|
|
AutoLoad ^= true;
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
|
|
|
|
{
|
2012-03-09 16:13:40 +00:00
|
|
|
|
enToolStripMenuItem.Checked = BigEndian;
|
|
|
|
|
switch (DataSize)
|
2011-06-19 23:39:25 +00:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-09 01:50:39 +00:00
|
|
|
|
if (IsFrozen(GetHighlightedAddress()))
|
|
|
|
|
{
|
|
|
|
|
freezeAddressToolStripMenuItem.Image = MultiClient.Properties.Resources.Unfreeze;
|
|
|
|
|
freezeAddressToolStripMenuItem.Text = "Un&freeze Address";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
freezeAddressToolStripMenuItem.Image = MultiClient.Properties.Resources.Freeze;
|
|
|
|
|
freezeAddressToolStripMenuItem.Text = "&Freeze Address";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-08-22 02:48:12 +00:00
|
|
|
|
if (GetHighlightedAddress() >= 0)
|
2011-06-19 23:39:25 +00:00
|
|
|
|
{
|
|
|
|
|
addToRamWatchToolStripMenuItem1.Enabled = true;
|
|
|
|
|
freezeAddressToolStripMenuItem.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
addToRamWatchToolStripMenuItem1.Enabled = false;
|
|
|
|
|
freezeAddressToolStripMenuItem.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-22 02:48:12 +00:00
|
|
|
|
public void SetMemoryDomain(MemoryDomain d)
|
|
|
|
|
{
|
|
|
|
|
Domain = d;
|
2012-06-02 21:48:09 +00:00
|
|
|
|
if (d.Endian == Endian.Big)
|
|
|
|
|
BigEndian = true;
|
|
|
|
|
else
|
|
|
|
|
BigEndian = false;
|
2011-08-22 02:48:12 +00:00
|
|
|
|
maxRow = Domain.Size / 2;
|
|
|
|
|
SetUpScrollBar();
|
|
|
|
|
vScrollBar1.Value = 0;
|
|
|
|
|
Refresh();
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-02 22:45:06 +00:00
|
|
|
|
private bool CurrentROMIsArchive()
|
|
|
|
|
{
|
|
|
|
|
string path = Global.MainForm.CurrentlyOpenRom;
|
|
|
|
|
if (path == null)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (var file = new HawkFile())
|
|
|
|
|
{
|
|
|
|
|
file.Open(path);
|
|
|
|
|
|
|
|
|
|
if (!file.Exists)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (file.IsArchive)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private byte[] GetRomBytes()
|
|
|
|
|
{
|
|
|
|
|
byte[] bytes;
|
|
|
|
|
string path = Global.MainForm.CurrentlyOpenRom;
|
|
|
|
|
if (path == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (var file = new HawkFile())
|
|
|
|
|
{
|
|
|
|
|
file.Open(path);
|
|
|
|
|
|
|
|
|
|
if (!file.Exists)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (file.IsArchive)
|
|
|
|
|
{
|
|
|
|
|
var stream = file.GetStream();
|
|
|
|
|
return Util.ReadAllBytes(stream);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return File.ReadAllBytes(path);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new byte[0];
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-19 23:39:25 +00:00
|
|
|
|
private void SetMemoryDomain(int pos)
|
|
|
|
|
{
|
2012-09-02 19:22:51 +00:00
|
|
|
|
if (pos == 999)
|
|
|
|
|
{
|
2012-09-02 22:45:06 +00:00
|
|
|
|
ROM = GetRomBytes();
|
|
|
|
|
if (ROM == null)
|
|
|
|
|
{
|
|
|
|
|
ROM = new byte[1] { 0xFF };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ROMDomain = new MemoryDomain("ROM File", ROM.Length, Endian.Little,
|
2012-09-02 19:22:51 +00:00
|
|
|
|
addr => ROM[addr],
|
|
|
|
|
(addr, value) => ROM[addr] = value);
|
2012-09-02 22:45:06 +00:00
|
|
|
|
|
2012-09-02 19:22:51 +00:00
|
|
|
|
Domain = ROMDomain;
|
|
|
|
|
}
|
|
|
|
|
else if (pos < Global.Emulator.MemoryDomains.Count) //Sanity check
|
2011-06-19 23:39:25 +00:00
|
|
|
|
{
|
2011-08-22 02:48:12 +00:00
|
|
|
|
SetMemoryDomain(Global.Emulator.MemoryDomains[pos]);
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
2011-08-23 23:48:22 +00:00
|
|
|
|
UpdateGroupBoxTitle();
|
2011-08-22 02:48:12 +00:00
|
|
|
|
ResetScrollBar();
|
2012-09-02 19:22:51 +00:00
|
|
|
|
UpdateValues();
|
2011-09-17 16:39:43 +00:00
|
|
|
|
MemoryViewerBox.Refresh();
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-23 23:48:22 +00:00
|
|
|
|
private void UpdateGroupBoxTitle()
|
2011-06-19 23:39:25 +00:00
|
|
|
|
{
|
2011-08-22 02:48:12 +00:00
|
|
|
|
string memoryDomain = Domain.ToString();
|
2011-06-19 23:39:25 +00:00
|
|
|
|
string systemID = Global.Emulator.SystemId;
|
2012-03-09 16:13:40 +00:00
|
|
|
|
MemoryViewerBox.Text = systemID + " " + memoryDomain + " - " + (Domain.Size / DataSize).ToString() + " addresses";
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetMemoryDomainMenu()
|
|
|
|
|
{
|
|
|
|
|
memoryDomainsToolStripMenuItem.DropDownItems.Clear();
|
2012-09-02 19:22:51 +00:00
|
|
|
|
|
|
|
|
|
for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
|
2011-06-19 23:39:25 +00:00
|
|
|
|
{
|
2012-09-02 19:22:51 +00:00
|
|
|
|
string str = Global.Emulator.MemoryDomains[x].ToString();
|
|
|
|
|
var item = new ToolStripMenuItem();
|
|
|
|
|
item.Text = str;
|
2011-06-19 23:39:25 +00:00
|
|
|
|
{
|
2012-09-02 19:22:51 +00:00
|
|
|
|
int z = x;
|
|
|
|
|
item.Click += (o, ev) => SetMemoryDomain(z);
|
|
|
|
|
}
|
|
|
|
|
if (x == 0)
|
|
|
|
|
{
|
|
|
|
|
SetMemoryDomain(x);
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
2012-09-02 19:22:51 +00:00
|
|
|
|
memoryDomainsToolStripMenuItem.DropDownItems.Add(item);
|
|
|
|
|
domainMenuItems.Add(item);
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
2012-09-02 19:22:51 +00:00
|
|
|
|
|
|
|
|
|
//Add ROM File memory domain
|
|
|
|
|
var rom_item = new ToolStripMenuItem();
|
|
|
|
|
rom_item.Text = "ROM File";
|
|
|
|
|
rom_item.Click += (o, ev) => SetMemoryDomain(999); //999 will denote ROM file
|
|
|
|
|
memoryDomainsToolStripMenuItem.DropDownItems.Add(rom_item);
|
|
|
|
|
domainMenuItems.Add(rom_item);
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-24 02:48:52 +00:00
|
|
|
|
|
2011-06-19 23:39:25 +00:00
|
|
|
|
|
|
|
|
|
private void goToAddressToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-08-22 02:48:12 +00:00
|
|
|
|
GoToSpecifiedAddress();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int GetNumDigits(Int32 i)
|
|
|
|
|
{
|
2011-08-27 14:49:13 +00:00
|
|
|
|
if (i <= 0x10000) return 4;
|
|
|
|
|
if (i <= 0x1000000) return 6;
|
|
|
|
|
else return 8;
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void GoToSpecifiedAddress()
|
|
|
|
|
{
|
|
|
|
|
InputPrompt i = new InputPrompt();
|
|
|
|
|
i.Text = "Go to Address";
|
|
|
|
|
i.SetMessage("Enter a hexadecimal value");
|
|
|
|
|
Global.Sound.StopSound();
|
|
|
|
|
i.ShowDialog();
|
|
|
|
|
Global.Sound.StartSound();
|
|
|
|
|
|
|
|
|
|
if (i.UserOK)
|
|
|
|
|
{
|
|
|
|
|
if (InputValidate.IsValidHexNumber(i.UserText))
|
|
|
|
|
{
|
|
|
|
|
GoToAddress(int.Parse(i.UserText, NumberStyles.HexNumber));
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-06-18 03:34:14 +00:00
|
|
|
|
AddressLabel.Text = GenerateAddressString();
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ClearNibbles()
|
|
|
|
|
{
|
2011-08-25 01:49:22 +00:00
|
|
|
|
for (int x = 0; x < 8; x++)
|
2011-08-22 02:48:12 +00:00
|
|
|
|
nibbles[x] = 'G';
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-07 19:53:52 +00:00
|
|
|
|
public void GoToAddress(int address)
|
|
|
|
|
{
|
2011-08-22 02:48:12 +00:00
|
|
|
|
if (address < 0)
|
|
|
|
|
address = 0;
|
|
|
|
|
|
|
|
|
|
if (address >= Domain.Size)
|
|
|
|
|
address = Domain.Size - 1;
|
|
|
|
|
|
|
|
|
|
SetHighlighted(address);
|
|
|
|
|
ClearNibbles();
|
2011-08-23 22:22:24 +00:00
|
|
|
|
UpdateValues();
|
|
|
|
|
MemoryViewerBox.Refresh();
|
2012-06-18 03:34:14 +00:00
|
|
|
|
AddressLabel.Text = GenerateAddressString();
|
2011-08-07 19:53:52 +00:00
|
|
|
|
}
|
2011-06-19 23:39:25 +00:00
|
|
|
|
|
2011-08-22 02:48:12 +00:00
|
|
|
|
public void SetHighlighted(int addr)
|
|
|
|
|
{
|
|
|
|
|
if (addr < 0)
|
|
|
|
|
addr = 0;
|
|
|
|
|
if (addr >= Domain.Size)
|
|
|
|
|
addr = Domain.Size - 1;
|
|
|
|
|
|
|
|
|
|
if (!IsVisible(addr))
|
|
|
|
|
{
|
|
|
|
|
int v = (addr / 16) - RowsVisible + 1;
|
|
|
|
|
if (v < 0)
|
|
|
|
|
v = 0;
|
2011-08-22 16:42:32 +00:00
|
|
|
|
vScrollBar1.Value = v;
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
|
|
|
|
addressHighlighted = addr;
|
|
|
|
|
addressOver = addr;
|
2011-08-25 23:58:16 +00:00
|
|
|
|
ClearNibbles();
|
2011-08-25 23:49:13 +00:00
|
|
|
|
info = String.Format(NumDigitsStr, addressOver);
|
|
|
|
|
UpdateFormText();
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-25 23:49:13 +00:00
|
|
|
|
private void UpdateFormText()
|
|
|
|
|
{
|
|
|
|
|
if (addressHighlighted >= 0)
|
|
|
|
|
Text = "Hex Editor - Editing Address 0x" + String.Format(NumDigitsStr, addressHighlighted);
|
|
|
|
|
else
|
|
|
|
|
Text = "Hex Editor";
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-22 02:48:12 +00:00
|
|
|
|
public bool IsVisible(int addr)
|
|
|
|
|
{
|
2011-08-27 14:49:13 +00:00
|
|
|
|
int row = addr >> 4;
|
2011-08-22 02:48:12 +00:00
|
|
|
|
|
2011-08-27 14:49:13 +00:00
|
|
|
|
if (row >= vScrollBar1.Value && row < (RowsVisible + vScrollBar1.Value))
|
|
|
|
|
return true;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
2011-06-19 23:39:25 +00:00
|
|
|
|
|
|
|
|
|
private void HexEditor_Resize(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-08-22 16:34:47 +00:00
|
|
|
|
SetUpScrollBar();
|
2011-08-23 22:22:24 +00:00
|
|
|
|
UpdateValues();
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetHeader()
|
|
|
|
|
{
|
2012-03-09 16:13:40 +00:00
|
|
|
|
switch (DataSize)
|
2011-08-22 02:48:12 +00:00
|
|
|
|
{
|
|
|
|
|
case 1:
|
2012-06-13 02:18:34 +00:00
|
|
|
|
Header.Text = " 0 1 2 3 4 5 6 7 8 9 A B C D E F";
|
2011-08-22 02:48:12 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2012-06-13 02:18:34 +00:00
|
|
|
|
Header.Text = " 0 2 4 6 8 A C E";
|
2011-08-22 02:48:12 +00:00
|
|
|
|
break;
|
|
|
|
|
case 4:
|
2012-06-13 02:18:34 +00:00
|
|
|
|
Header.Text = " 0 4 8 C";
|
2011-08-22 02:48:12 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
NumDigits = GetNumDigits(Domain.Size);
|
2012-06-10 22:43:43 +00:00
|
|
|
|
NumDigitsStr = "{0:X" + NumDigits.ToString() + "} ";
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetDataSize(int size)
|
|
|
|
|
{
|
|
|
|
|
if (size == 1 || size == 2 || size == 4)
|
2012-03-09 16:13:40 +00:00
|
|
|
|
DataSize = size;
|
|
|
|
|
DigitFormatString = "{0:X" + (DataSize * 2).ToString() + "} ";
|
2011-08-22 02:48:12 +00:00
|
|
|
|
SetHeader();
|
2011-08-23 23:48:22 +00:00
|
|
|
|
UpdateGroupBoxTitle();
|
|
|
|
|
UpdateValues();
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void byteToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-08-22 02:48:12 +00:00
|
|
|
|
SetDataSize(1);
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void byteToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-08-22 02:48:12 +00:00
|
|
|
|
SetDataSize(2);
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void byteToolStripMenuItem2_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2011-08-22 02:48:12 +00:00
|
|
|
|
SetDataSize(4);
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void enToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2012-03-09 16:13:40 +00:00
|
|
|
|
BigEndian ^= true;
|
2011-08-25 00:55:46 +00:00
|
|
|
|
UpdateValues();
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-19 02:42:07 +00:00
|
|
|
|
private Watch MakeWatch(int address)
|
|
|
|
|
{
|
|
|
|
|
Watch w = new Watch();
|
2012-09-03 23:42:00 +00:00
|
|
|
|
w.Address = address;
|
|
|
|
|
w.BigEndian = BigEndian;
|
|
|
|
|
w.Signed = Watch.DISPTYPE.HEX;
|
2012-06-19 02:42:07 +00:00
|
|
|
|
|
|
|
|
|
switch (DataSize)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case 1:
|
2012-09-03 23:42:00 +00:00
|
|
|
|
w.Type = Watch.TYPE.BYTE;
|
2012-06-19 02:42:07 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2012-09-03 23:42:00 +00:00
|
|
|
|
w.Type = Watch.TYPE.WORD;
|
2012-06-19 02:42:07 +00:00
|
|
|
|
break;
|
|
|
|
|
case 4:
|
2012-09-03 23:42:00 +00:00
|
|
|
|
w.Type = Watch.TYPE.DWORD;
|
2012-06-19 02:42:07 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return w;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-19 23:39:25 +00:00
|
|
|
|
private void AddToRamWatch()
|
|
|
|
|
{
|
|
|
|
|
//Add to RAM Watch
|
2011-08-22 02:48:12 +00:00
|
|
|
|
int address = GetHighlightedAddress();
|
2011-06-19 23:39:25 +00:00
|
|
|
|
|
2012-06-19 02:42:07 +00:00
|
|
|
|
if (address >= 0 || SecondaryHighlightedAddresses.Count > 0)
|
|
|
|
|
{
|
2012-08-15 01:14:25 +00:00
|
|
|
|
Global.MainForm.LoadRamWatch(true);
|
2012-06-19 02:42:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (address >= 0)
|
|
|
|
|
{
|
|
|
|
|
Global.MainForm.RamWatch1.AddWatch(MakeWatch(address));
|
|
|
|
|
}
|
|
|
|
|
foreach (int addr in SecondaryHighlightedAddresses)
|
|
|
|
|
{
|
|
|
|
|
Global.MainForm.RamWatch1.AddWatch(MakeWatch(addr));
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MemoryViewer_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
AddToRamWatch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void pokeToolStripMenuItem_Click(object sender, EventArgs e)
|
2011-09-12 23:21:39 +00:00
|
|
|
|
{
|
|
|
|
|
PokeAddress();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PokeAddress()
|
2011-06-19 23:39:25 +00:00
|
|
|
|
{
|
2011-08-24 22:26:17 +00:00
|
|
|
|
int p = GetHighlightedAddress();
|
2011-06-19 23:39:25 +00:00
|
|
|
|
if (p >= 0)
|
|
|
|
|
{
|
2011-09-17 15:35:39 +00:00
|
|
|
|
Watch w = new Watch();
|
2012-09-03 23:42:00 +00:00
|
|
|
|
w.Address = p;
|
|
|
|
|
w.Value = MakeValue(p);
|
|
|
|
|
w.BigEndian = BigEndian;
|
|
|
|
|
w.Signed = Watch.DISPTYPE.HEX;
|
2011-06-19 23:39:25 +00:00
|
|
|
|
|
2012-03-09 16:13:40 +00:00
|
|
|
|
switch (DataSize)
|
2011-06-19 23:39:25 +00:00
|
|
|
|
{
|
2011-09-17 15:35:39 +00:00
|
|
|
|
default:
|
|
|
|
|
case 1:
|
2012-09-03 23:42:00 +00:00
|
|
|
|
w.Type = Watch.TYPE.BYTE;
|
2011-09-17 15:35:39 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2012-09-03 23:42:00 +00:00
|
|
|
|
w.Type = Watch.TYPE.WORD;
|
2011-09-17 15:35:39 +00:00
|
|
|
|
break;
|
|
|
|
|
case 4:
|
2012-09-03 23:42:00 +00:00
|
|
|
|
w.Type = Watch.TYPE.DWORD;
|
2011-09-17 15:35:39 +00:00
|
|
|
|
break;
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
2011-09-17 15:35:39 +00:00
|
|
|
|
|
|
|
|
|
RamPoke poke = new RamPoke();
|
|
|
|
|
poke.SetWatchObject(w, Domain);
|
|
|
|
|
poke.location = GetAddressCoordinates(p);
|
|
|
|
|
Global.Sound.StopSound();
|
|
|
|
|
poke.ShowDialog();
|
|
|
|
|
Global.Sound.StartSound();
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-22 02:48:12 +00:00
|
|
|
|
public int GetPointedAddress()
|
|
|
|
|
{
|
|
|
|
|
if (addressOver >= 0)
|
2012-09-03 00:49:59 +00:00
|
|
|
|
{
|
2011-08-22 02:48:12 +00:00
|
|
|
|
return addressOver;
|
2012-09-03 00:49:59 +00:00
|
|
|
|
}
|
2011-08-22 02:48:12 +00:00
|
|
|
|
else
|
2012-09-03 00:49:59 +00:00
|
|
|
|
{
|
2011-08-22 02:48:12 +00:00
|
|
|
|
return -1; //Negative = no address pointed
|
2012-09-03 00:49:59 +00:00
|
|
|
|
}
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PokeHighlighted(int value)
|
|
|
|
|
{
|
2011-08-24 22:26:17 +00:00
|
|
|
|
//TODO: 4 byte
|
2011-08-22 02:48:12 +00:00
|
|
|
|
if (addressHighlighted >= 0)
|
2011-08-24 22:26:17 +00:00
|
|
|
|
{
|
2012-03-09 16:13:40 +00:00
|
|
|
|
switch (DataSize)
|
2011-08-24 22:26:17 +00:00
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case 1:
|
|
|
|
|
Domain.PokeByte(addressHighlighted, (byte)value);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
PokeWord(addressHighlighted, (byte)(value % 256), (byte)value);
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-19 23:39:25 +00:00
|
|
|
|
private void addToRamWatchToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
AddToRamWatch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addToRamWatchToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
AddToRamWatch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveWindowsSettingsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2012-03-09 16:13:40 +00:00
|
|
|
|
SaveWindowPosition ^= true;
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void settingsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
|
|
|
|
{
|
2012-03-09 16:13:40 +00:00
|
|
|
|
autoloadToolStripMenuItem.Checked = AutoLoad;
|
|
|
|
|
saveWindowsSettingsToolStripMenuItem.Checked = SaveWindowPosition;
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void freezeToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2012-03-09 01:33:55 +00:00
|
|
|
|
ToggleFreeze();
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-22 02:48:12 +00:00
|
|
|
|
public int GetHighlightedAddress()
|
|
|
|
|
{
|
|
|
|
|
if (addressHighlighted >= 0)
|
|
|
|
|
return addressHighlighted;
|
|
|
|
|
else
|
|
|
|
|
return -1; //Negative = no address highlighted
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-09 01:24:46 +00:00
|
|
|
|
private bool IsFrozen(int address)
|
|
|
|
|
{
|
|
|
|
|
return Global.CheatList.IsActiveCheat(Domain, address);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ToggleFreeze()
|
|
|
|
|
{
|
|
|
|
|
int address = GetHighlightedAddress();
|
|
|
|
|
if (IsFrozen(address))
|
|
|
|
|
{
|
2012-06-19 02:42:07 +00:00
|
|
|
|
UnFreezeAddress(address);
|
2012-03-09 01:24:46 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-06-19 02:42:07 +00:00
|
|
|
|
FreezeAddress(GetHighlightedAddress());
|
|
|
|
|
}
|
|
|
|
|
foreach (int addr in SecondaryHighlightedAddresses)
|
|
|
|
|
{
|
|
|
|
|
if (IsFrozen(addr))
|
|
|
|
|
{
|
|
|
|
|
UnFreezeAddress(addr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FreezeAddress(addr);
|
|
|
|
|
}
|
2012-03-09 01:24:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-19 02:42:07 +00:00
|
|
|
|
private void UnFreezeAddress(int address)
|
2012-03-09 01:24:46 +00:00
|
|
|
|
{
|
|
|
|
|
if (address >= 0)
|
|
|
|
|
{
|
|
|
|
|
Cheat c = new Cheat();
|
|
|
|
|
c.address = address;
|
|
|
|
|
c.value = Domain.PeekByte(address);
|
|
|
|
|
c.domain = Domain;
|
|
|
|
|
Global.MainForm.Cheats1.RemoveCheat(c);
|
|
|
|
|
|
2012-03-09 16:13:40 +00:00
|
|
|
|
switch (DataSize)
|
2012-03-09 01:24:46 +00:00
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case 1:
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
Cheat c2 = new Cheat();
|
|
|
|
|
c2.address = address + 1;
|
|
|
|
|
c2.domain = Domain;
|
|
|
|
|
c2.value = Domain.PeekByte(address + 1);
|
|
|
|
|
c2.Enable();
|
|
|
|
|
Global.MainForm.Cheats1.RemoveCheat(c2);
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
Cheat c42 = new Cheat();
|
|
|
|
|
c42.address = address + 1;
|
|
|
|
|
c42.domain = Domain;
|
|
|
|
|
c42.value = Domain.PeekByte(address + 1);
|
|
|
|
|
c42.Enable();
|
|
|
|
|
Global.MainForm.Cheats1.RemoveCheat(c42);
|
|
|
|
|
Cheat c43 = new Cheat();
|
|
|
|
|
c43.address = address + 2;
|
|
|
|
|
c43.domain = Domain;
|
|
|
|
|
c43.value = Domain.PeekByte(address + 2);
|
|
|
|
|
c43.Enable();
|
|
|
|
|
Global.MainForm.Cheats1.RemoveCheat(c43);
|
|
|
|
|
Cheat c44 = new Cheat();
|
|
|
|
|
c44.address = address + 3;
|
|
|
|
|
c44.domain = Domain;
|
|
|
|
|
c44.value = Domain.PeekByte(address + 3);
|
|
|
|
|
c44.Enable();
|
|
|
|
|
Global.MainForm.Cheats1.RemoveCheat(c44);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MemoryViewerBox.Refresh();
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-19 02:42:07 +00:00
|
|
|
|
private void FreezeAddress(int address)
|
2011-06-19 23:39:25 +00:00
|
|
|
|
{
|
|
|
|
|
if (address >= 0)
|
|
|
|
|
{
|
|
|
|
|
Cheat c = new Cheat();
|
|
|
|
|
c.address = address;
|
2011-08-25 01:22:03 +00:00
|
|
|
|
c.value = Domain.PeekByte(address);
|
2011-08-22 02:48:12 +00:00
|
|
|
|
c.domain = Domain;
|
2011-08-25 01:22:03 +00:00
|
|
|
|
c.Enable();
|
|
|
|
|
Global.MainForm.Cheats1.AddCheat(c);
|
|
|
|
|
|
2012-03-09 16:13:40 +00:00
|
|
|
|
switch (DataSize)
|
2011-06-19 23:39:25 +00:00
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case 1:
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2011-08-25 01:22:03 +00:00
|
|
|
|
Cheat c2 = new Cheat();
|
|
|
|
|
c2.address = address + 1;
|
|
|
|
|
c2.domain = Domain;
|
|
|
|
|
c2.value = Domain.PeekByte(address + 1);
|
|
|
|
|
c2.Enable();
|
|
|
|
|
Global.MainForm.Cheats1.AddCheat(c2);
|
2011-06-19 23:39:25 +00:00
|
|
|
|
break;
|
|
|
|
|
case 4:
|
2011-08-25 01:22:03 +00:00
|
|
|
|
Cheat c42 = new Cheat();
|
|
|
|
|
c42.address = address + 1;
|
|
|
|
|
c42.domain = Domain;
|
|
|
|
|
c42.value = Domain.PeekByte(address + 1);
|
|
|
|
|
c42.Enable();
|
|
|
|
|
Global.MainForm.Cheats1.AddCheat(c42);
|
|
|
|
|
Cheat c43 = new Cheat();
|
|
|
|
|
c43.address = address + 2;
|
|
|
|
|
c43.domain = Domain;
|
|
|
|
|
c43.value = Domain.PeekByte(address + 2);
|
|
|
|
|
c43.Enable();
|
|
|
|
|
Global.MainForm.Cheats1.AddCheat(c43);
|
|
|
|
|
Cheat c44 = new Cheat();
|
|
|
|
|
c44.address = address + 3;
|
|
|
|
|
c44.domain = Domain;
|
|
|
|
|
c44.value = Domain.PeekByte(address + 3);
|
|
|
|
|
c44.Enable();
|
|
|
|
|
Global.MainForm.Cheats1.AddCheat(c44);
|
2011-06-19 23:39:25 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-08-25 02:08:05 +00:00
|
|
|
|
MemoryViewerBox.Refresh();
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void freezeAddressToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2012-03-09 01:50:39 +00:00
|
|
|
|
ToggleFreeze();
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CheckDomainMenuItems()
|
|
|
|
|
{
|
|
|
|
|
for (int x = 0; x < domainMenuItems.Count; x++)
|
|
|
|
|
{
|
2011-08-22 02:48:12 +00:00
|
|
|
|
if (Domain.Name == domainMenuItems[x].Text)
|
2012-09-02 19:22:51 +00:00
|
|
|
|
{
|
2011-06-19 23:39:25 +00:00
|
|
|
|
domainMenuItems[x].Checked = true;
|
2012-09-02 19:22:51 +00:00
|
|
|
|
}
|
2011-06-19 23:39:25 +00:00
|
|
|
|
else
|
2012-09-02 19:22:51 +00:00
|
|
|
|
{
|
2011-06-19 23:39:25 +00:00
|
|
|
|
domainMenuItems[x].Checked = false;
|
2012-09-02 19:22:51 +00:00
|
|
|
|
}
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void memoryDomainsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CheckDomainMenuItems();
|
|
|
|
|
}
|
2011-06-26 00:06:50 +00:00
|
|
|
|
|
|
|
|
|
private void dumpToFileToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2012-06-10 17:28:38 +00:00
|
|
|
|
SaveAsText();
|
2011-08-07 19:30:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 17:28:38 +00:00
|
|
|
|
private void SaveAsText()
|
2011-08-07 19:30:01 +00:00
|
|
|
|
{
|
|
|
|
|
var file = GetSaveFileFromUser();
|
|
|
|
|
if (file != null)
|
|
|
|
|
{
|
|
|
|
|
using (StreamWriter sw = new StreamWriter(file.FullName))
|
|
|
|
|
{
|
|
|
|
|
string str = "";
|
|
|
|
|
|
2011-08-22 02:48:12 +00:00
|
|
|
|
for (int x = 0; x < Domain.Size / 16; x++)
|
2011-08-07 19:30:01 +00:00
|
|
|
|
{
|
|
|
|
|
for (int y = 0; y < 16; y++)
|
|
|
|
|
{
|
2011-08-22 02:48:12 +00:00
|
|
|
|
str += String.Format("{0:X2} ", Domain.PeekByte((x * 16) + y));
|
2011-08-07 19:30:01 +00:00
|
|
|
|
}
|
|
|
|
|
str += "\r\n";
|
|
|
|
|
}
|
2011-06-26 00:06:50 +00:00
|
|
|
|
|
2011-08-07 19:30:01 +00:00
|
|
|
|
sw.WriteLine(str);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-26 00:06:50 +00:00
|
|
|
|
}
|
2011-08-07 19:30:01 +00:00
|
|
|
|
|
2012-06-10 17:28:38 +00:00
|
|
|
|
private void SaveAsBinary()
|
|
|
|
|
{
|
2012-09-02 23:12:00 +00:00
|
|
|
|
SaveFileBinary(GetBinarySaveFileFromUser());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SaveFileBinary(FileInfo file)
|
|
|
|
|
{
|
2012-06-10 17:28:38 +00:00
|
|
|
|
if (file != null)
|
|
|
|
|
{
|
2012-09-02 23:12:00 +00:00
|
|
|
|
using (BinaryWriter binWriter = new BinaryWriter(File.Open(file.FullName, FileMode.Create)))
|
2012-06-10 17:28:38 +00:00
|
|
|
|
{
|
|
|
|
|
byte[] dump = new byte[Domain.Size];
|
|
|
|
|
|
|
|
|
|
for (int x = 0; x < Domain.Size; x++)
|
|
|
|
|
{
|
|
|
|
|
binWriter.Write(Domain.PeekByte(x));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-07 19:30:01 +00:00
|
|
|
|
private FileInfo GetSaveFileFromUser()
|
|
|
|
|
{
|
|
|
|
|
var sfd = new SaveFileDialog();
|
2011-08-24 02:48:52 +00:00
|
|
|
|
|
2011-08-07 19:30:01 +00:00
|
|
|
|
if (!(Global.Emulator is NullEmulator))
|
2011-09-10 13:51:26 +00:00
|
|
|
|
sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
|
2011-08-07 19:30:01 +00:00
|
|
|
|
else
|
|
|
|
|
sfd.FileName = "MemoryDump";
|
|
|
|
|
|
2011-08-24 02:48:52 +00:00
|
|
|
|
|
|
|
|
|
sfd.InitialDirectory = PathManager.GetPlatformBase(Global.Emulator.SystemId);
|
|
|
|
|
|
2011-08-07 19:30:01 +00:00
|
|
|
|
sfd.Filter = "Text (*.txt)|*.txt|All Files|*.*";
|
|
|
|
|
sfd.RestoreDirectory = true;
|
|
|
|
|
Global.Sound.StopSound();
|
|
|
|
|
var result = sfd.ShowDialog();
|
|
|
|
|
Global.Sound.StartSound();
|
|
|
|
|
if (result != DialogResult.OK)
|
|
|
|
|
return null;
|
|
|
|
|
var file = new FileInfo(sfd.FileName);
|
|
|
|
|
return file;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-02 23:12:00 +00:00
|
|
|
|
private string GetSaveFileFilter()
|
|
|
|
|
{
|
|
|
|
|
if (Domain.Name == "ROM File")
|
|
|
|
|
{
|
|
|
|
|
string extension = Path.GetExtension(Global.MainForm.CurrentlyOpenRom);
|
|
|
|
|
|
|
|
|
|
return "Binary (*" + extension + ")|*" + extension + "|All Files|*.*";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "Binary (*.bin)|*.bin|All Files|*.*";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 17:28:38 +00:00
|
|
|
|
private FileInfo GetBinarySaveFileFromUser()
|
|
|
|
|
{
|
|
|
|
|
var sfd = new SaveFileDialog();
|
|
|
|
|
|
|
|
|
|
if (!(Global.Emulator is NullEmulator))
|
|
|
|
|
sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
|
|
|
|
|
else
|
|
|
|
|
sfd.FileName = "MemoryDump";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sfd.InitialDirectory = PathManager.GetPlatformBase(Global.Emulator.SystemId);
|
|
|
|
|
|
2012-09-02 23:12:00 +00:00
|
|
|
|
sfd.Filter = GetSaveFileFilter();
|
2012-06-10 17:28:38 +00:00
|
|
|
|
sfd.RestoreDirectory = true;
|
|
|
|
|
Global.Sound.StopSound();
|
|
|
|
|
var result = sfd.ShowDialog();
|
|
|
|
|
Global.Sound.StartSound();
|
|
|
|
|
if (result != DialogResult.OK)
|
|
|
|
|
return null;
|
|
|
|
|
var file = new FileInfo(sfd.FileName);
|
|
|
|
|
return file;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-22 02:48:12 +00:00
|
|
|
|
public void ResetScrollBar()
|
|
|
|
|
{
|
|
|
|
|
vScrollBar1.Value = 0;
|
|
|
|
|
SetUpScrollBar();
|
|
|
|
|
Refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetUpScrollBar()
|
|
|
|
|
{
|
2011-08-23 22:44:23 +00:00
|
|
|
|
RowsVisible = ((MemoryViewerBox.Height - (fontHeight * 2) - (fontHeight / 2)) / fontHeight);
|
2011-08-22 02:48:12 +00:00
|
|
|
|
int totalRows = Domain.Size / 16;
|
|
|
|
|
int MaxRows = (totalRows - RowsVisible) + 16;
|
|
|
|
|
|
|
|
|
|
if (MaxRows > 0)
|
|
|
|
|
{
|
|
|
|
|
vScrollBar1.Visible = true;
|
|
|
|
|
if (vScrollBar1.Value > MaxRows)
|
|
|
|
|
vScrollBar1.Value = MaxRows;
|
|
|
|
|
vScrollBar1.Maximum = MaxRows;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
vScrollBar1.Visible = false;
|
|
|
|
|
|
2012-06-18 03:34:14 +00:00
|
|
|
|
AddressLabel.Text = GenerateAddressString();
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.SetUpScrollBar();
|
|
|
|
|
UpdateValues();
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-19 02:42:07 +00:00
|
|
|
|
private int GetPointedAddress(int x, int y)
|
2011-08-22 02:48:12 +00:00
|
|
|
|
{
|
2012-09-03 00:49:59 +00:00
|
|
|
|
|
2012-06-19 02:42:07 +00:00
|
|
|
|
int address = -1;
|
2011-08-22 02:48:12 +00:00
|
|
|
|
//Scroll value determines the first row
|
|
|
|
|
int row = vScrollBar1.Value;
|
2012-06-16 23:11:43 +00:00
|
|
|
|
int rowoffset = y / fontHeight;
|
2011-08-23 22:22:24 +00:00
|
|
|
|
row += rowoffset;
|
2011-08-24 02:31:45 +00:00
|
|
|
|
int colWidth = 0;
|
2012-03-09 16:13:40 +00:00
|
|
|
|
switch (DataSize)
|
2011-08-24 02:31:45 +00:00
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case 1:
|
|
|
|
|
colWidth = 3;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
colWidth = 5;
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
colWidth = 9;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2012-06-18 03:34:14 +00:00
|
|
|
|
int column = (x /*- 43*/) / (fontWidth * colWidth);
|
2011-08-22 02:48:12 +00:00
|
|
|
|
|
2012-09-03 00:49:59 +00:00
|
|
|
|
//int last = (16 / DataSize);
|
|
|
|
|
//if (column >= last)
|
|
|
|
|
//{
|
|
|
|
|
int start = GetTextOffset() - addrOffset - 50; //This is ugly, needs cleanup but it works!
|
|
|
|
|
if (x > start)
|
|
|
|
|
{
|
|
|
|
|
column = (x - start) / (fontWidth / DataSize);
|
|
|
|
|
}
|
|
|
|
|
//}
|
|
|
|
|
|
2012-03-09 16:13:40 +00:00
|
|
|
|
if (row >= 0 && row <= maxRow && column >= 0 && column < (16 / DataSize))
|
2011-08-22 02:48:12 +00:00
|
|
|
|
{
|
2012-06-19 02:42:07 +00:00
|
|
|
|
address = row * 16 + (column * DataSize);
|
2011-08-27 14:49:13 +00:00
|
|
|
|
info = String.Format(NumDigitsStr, addressOver);
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-06-19 02:42:07 +00:00
|
|
|
|
address = -1;
|
2011-08-22 02:48:12 +00:00
|
|
|
|
info = "";
|
|
|
|
|
}
|
2012-06-19 02:42:07 +00:00
|
|
|
|
return address;
|
2011-08-22 02:48:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HexEditor_ResizeEnd(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SetUpScrollBar();
|
|
|
|
|
}
|
2011-08-23 01:43:19 +00:00
|
|
|
|
|
|
|
|
|
private void AddressesLabel_MouseMove(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2012-06-19 02:42:07 +00:00
|
|
|
|
addressOver = GetPointedAddress(e.X, e.Y);
|
2011-08-23 01:43:19 +00:00
|
|
|
|
Pointedx = e.X;
|
|
|
|
|
Pointedy = e.Y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddressesLabel_MouseClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2012-06-19 02:42:07 +00:00
|
|
|
|
int addressOver = GetPointedAddress(e.X, e.Y);
|
|
|
|
|
if (addressOver >= 0)
|
2011-08-23 01:43:19 +00:00
|
|
|
|
{
|
2012-06-19 02:42:07 +00:00
|
|
|
|
if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
|
|
|
|
|
{
|
|
|
|
|
if (addressOver == addressHighlighted)
|
|
|
|
|
{
|
|
|
|
|
ClearHighlighted();
|
|
|
|
|
}
|
|
|
|
|
else if (SecondaryHighlightedAddresses.Contains(addressOver))
|
|
|
|
|
{
|
|
|
|
|
SecondaryHighlightedAddresses.Remove(addressOver);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SecondaryHighlightedAddresses.Add(addressOver);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
|
|
|
|
|
{
|
2012-07-04 21:25:34 +00:00
|
|
|
|
if (addressOver >= 0)
|
2012-06-19 02:42:07 +00:00
|
|
|
|
{
|
|
|
|
|
SecondaryHighlightedAddresses.Clear();
|
|
|
|
|
if (addressOver < addressHighlighted)
|
|
|
|
|
{
|
|
|
|
|
for (int x = addressOver; x < addressHighlighted; x++)
|
|
|
|
|
{
|
|
|
|
|
SecondaryHighlightedAddresses.Add(x);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (addressOver > addressHighlighted)
|
|
|
|
|
{
|
|
|
|
|
for (int x = addressHighlighted + DataSize; x <= addressOver; x++)
|
|
|
|
|
{
|
|
|
|
|
SecondaryHighlightedAddresses.Add(x);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (addressOver == addressHighlighted)
|
|
|
|
|
{
|
|
|
|
|
ClearHighlighted();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SetHighlighted(addressOver);
|
|
|
|
|
SecondaryHighlightedAddresses.Clear();
|
2012-06-23 18:45:01 +00:00
|
|
|
|
FindStr = "";
|
2012-06-19 02:42:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MemoryViewerBox.Refresh();
|
2011-08-23 01:43:19 +00:00
|
|
|
|
}
|
2011-08-25 23:58:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ClearHighlighted()
|
|
|
|
|
{
|
|
|
|
|
addressHighlighted = -1;
|
|
|
|
|
UpdateFormText();
|
|
|
|
|
MemoryViewerBox.Refresh();
|
2011-08-23 01:43:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-23 22:22:24 +00:00
|
|
|
|
private Point GetAddressCoordinates(int address)
|
|
|
|
|
{
|
2012-06-18 03:39:21 +00:00
|
|
|
|
addrOffset = (NumDigits % 4) * 9;
|
2012-03-09 16:13:40 +00:00
|
|
|
|
switch (DataSize)
|
2011-08-24 02:31:45 +00:00
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case 1:
|
|
|
|
|
return new Point(((address % 16) * (fontWidth * 3)) + 50 + addrOffset, (((address / 16) - vScrollBar1.Value) * fontHeight) + 30);
|
|
|
|
|
case 2:
|
2012-03-09 16:13:40 +00:00
|
|
|
|
return new Point((((address % 16) / DataSize) * (fontWidth * 5)) + 50 + addrOffset, (((address / 16) - vScrollBar1.Value) * fontHeight) + 30);
|
2011-08-24 02:31:45 +00:00
|
|
|
|
case 4:
|
2012-03-09 16:13:40 +00:00
|
|
|
|
return new Point((((address % 16) / DataSize) * (fontWidth * 9)) + 50 + addrOffset, (((address / 16) - vScrollBar1.Value) * fontHeight) + 30);
|
2011-08-24 02:31:45 +00:00
|
|
|
|
}
|
2011-08-23 22:22:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 00:49:59 +00:00
|
|
|
|
private int GetTextOffset()
|
|
|
|
|
{
|
|
|
|
|
int start = 0;
|
|
|
|
|
switch (DataSize)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case 1:
|
|
|
|
|
start = (16 * (fontWidth * 3)) + (50 + addrOffset);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
start = ((16 / DataSize) * (fontWidth * 5)) + (50 + addrOffset);
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
start = ((16 / DataSize) * (fontWidth * 9)) + (50 + addrOffset);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
start += (fontWidth * 4);
|
|
|
|
|
return start;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int GetTextX(int address)
|
|
|
|
|
{
|
|
|
|
|
int start = GetTextOffset();
|
|
|
|
|
return start + ((address % 16) * fontWidth);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-23 01:43:19 +00:00
|
|
|
|
private void MemoryViewerBox_Paint(object sender, PaintEventArgs e)
|
|
|
|
|
{
|
2012-06-10 23:34:37 +00:00
|
|
|
|
|
2011-08-25 02:08:05 +00:00
|
|
|
|
for (int x = 0; x < Global.CheatList.Count; x++)
|
|
|
|
|
{
|
|
|
|
|
if (IsVisible(Global.CheatList.cheatList[x].address))
|
|
|
|
|
{
|
2011-09-17 16:39:43 +00:00
|
|
|
|
if (Domain.ToString() == Global.CheatList.cheatList[x].domain.ToString())
|
|
|
|
|
{
|
2012-03-09 16:13:40 +00:00
|
|
|
|
Rectangle rect = new Rectangle(GetAddressCoordinates(Global.CheatList.cheatList[x].address), new Size(15 * DataSize, fontHeight));
|
2011-09-17 16:39:43 +00:00
|
|
|
|
e.Graphics.DrawRectangle(new Pen(Brushes.Black), rect);
|
2012-06-10 23:34:37 +00:00
|
|
|
|
e.Graphics.FillRectangle(new SolidBrush(Global.Config.HexFreezeColor), rect);
|
2011-09-17 16:39:43 +00:00
|
|
|
|
}
|
2011-08-25 02:08:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-08-23 01:43:19 +00:00
|
|
|
|
if (addressHighlighted >= 0 && IsVisible(addressHighlighted))
|
|
|
|
|
{
|
2012-09-03 00:49:59 +00:00
|
|
|
|
Point point = GetAddressCoordinates(addressHighlighted);
|
|
|
|
|
int textX = GetTextX(addressHighlighted);
|
|
|
|
|
Point textpoint = new Point(textX, point.Y);
|
|
|
|
|
|
|
|
|
|
Rectangle rect = new Rectangle(point, new Size(15 * DataSize, fontHeight));
|
2011-08-24 02:31:45 +00:00
|
|
|
|
e.Graphics.DrawRectangle(new Pen(Brushes.Black), rect);
|
2012-09-03 00:49:59 +00:00
|
|
|
|
|
|
|
|
|
Rectangle textrect = new Rectangle(textpoint, new Size((8 * DataSize), fontHeight));
|
|
|
|
|
|
2011-08-25 02:08:05 +00:00
|
|
|
|
if (Global.CheatList.IsActiveCheat(Domain, addressHighlighted))
|
2012-09-03 00:49:59 +00:00
|
|
|
|
{
|
2012-06-10 23:34:37 +00:00
|
|
|
|
e.Graphics.FillRectangle(new SolidBrush(Global.Config.HexHighlightFreezeColor), rect);
|
2012-09-03 00:49:59 +00:00
|
|
|
|
e.Graphics.FillRectangle(new SolidBrush(Global.Config.HexHighlightFreezeColor), textrect);
|
|
|
|
|
}
|
2011-08-25 02:08:05 +00:00
|
|
|
|
else
|
2012-09-03 00:49:59 +00:00
|
|
|
|
{
|
2012-06-10 23:34:37 +00:00
|
|
|
|
e.Graphics.FillRectangle(new SolidBrush(Global.Config.HexHighlightColor), rect);
|
2012-09-03 00:49:59 +00:00
|
|
|
|
e.Graphics.FillRectangle(new SolidBrush(Global.Config.HexHighlightColor), textrect);
|
|
|
|
|
}
|
2011-08-23 01:43:19 +00:00
|
|
|
|
}
|
2012-06-19 02:42:07 +00:00
|
|
|
|
foreach (int address in SecondaryHighlightedAddresses)
|
|
|
|
|
{
|
2012-09-03 00:49:59 +00:00
|
|
|
|
Point point = GetAddressCoordinates(address);
|
|
|
|
|
int textX = GetTextX(address);
|
|
|
|
|
Point textpoint = new Point(textX, point.Y);
|
|
|
|
|
|
|
|
|
|
Rectangle rect = new Rectangle(point, new Size(15 * DataSize, fontHeight));
|
2012-06-19 02:42:07 +00:00
|
|
|
|
e.Graphics.DrawRectangle(new Pen(Brushes.Black), rect);
|
|
|
|
|
|
2012-09-03 00:49:59 +00:00
|
|
|
|
Rectangle textrect = new Rectangle(textpoint, new Size(8, fontHeight));
|
|
|
|
|
|
2012-06-19 02:42:07 +00:00
|
|
|
|
if (Global.CheatList.IsActiveCheat(Domain, address))
|
|
|
|
|
{
|
|
|
|
|
e.Graphics.FillRectangle(new SolidBrush(Global.Config.HexHighlightFreezeColor), rect);
|
2012-09-03 00:49:59 +00:00
|
|
|
|
e.Graphics.FillRectangle(new SolidBrush(Global.Config.HexHighlightFreezeColor), textrect);
|
2012-06-19 02:42:07 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-09-03 00:49:59 +00:00
|
|
|
|
e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(0x77FFD4D4)), rect);
|
|
|
|
|
e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(0x77FFD4D4)), textrect);
|
2012-06-19 02:42:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2011-08-25 02:23:12 +00:00
|
|
|
|
if (HasNibbles())
|
|
|
|
|
{
|
2012-06-25 03:21:54 +00:00
|
|
|
|
e.Graphics.DrawString(MakeNibbles(), new Font("Courier New", 8, FontStyle.Italic), Brushes.Black, new Point(158,4));
|
2011-08-25 02:23:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool HasNibbles()
|
|
|
|
|
{
|
2012-03-09 16:13:40 +00:00
|
|
|
|
for (int x = 0; x < (DataSize * 2); x++)
|
2011-08-25 02:23:12 +00:00
|
|
|
|
{
|
|
|
|
|
if (nibbles[x] != 'G')
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string MakeNibbles()
|
|
|
|
|
{
|
|
|
|
|
string str = "";
|
2012-03-09 16:13:40 +00:00
|
|
|
|
for (int x = 0; x < (DataSize * 2); x++)
|
2011-08-25 02:23:12 +00:00
|
|
|
|
{
|
|
|
|
|
if (nibbles[x] != 'G')
|
|
|
|
|
str += nibbles[x];
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return str;
|
2011-08-23 01:43:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddressesLabel_MouseLeave(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Pointedx = 0;
|
|
|
|
|
Pointedy = 0;
|
2011-08-24 02:31:45 +00:00
|
|
|
|
addressOver = -1;
|
2011-08-23 01:43:19 +00:00
|
|
|
|
MemoryViewerBox.Refresh();
|
|
|
|
|
}
|
2011-08-23 22:22:24 +00:00
|
|
|
|
|
|
|
|
|
private void HexEditor_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
2012-06-23 20:48:17 +00:00
|
|
|
|
int newHighlighted;
|
2011-08-23 22:22:24 +00:00
|
|
|
|
switch (e.KeyCode)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Up:
|
2012-06-23 20:48:17 +00:00
|
|
|
|
newHighlighted = addressHighlighted - 16;
|
|
|
|
|
if (e.Modifiers == Keys.Shift)
|
|
|
|
|
{
|
|
|
|
|
for (int i = newHighlighted + 1; i <= addressHighlighted; i++)
|
|
|
|
|
{
|
|
|
|
|
AddToSecondaryHighlights(i);
|
|
|
|
|
}
|
|
|
|
|
GoToAddress(newHighlighted);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SecondaryHighlightedAddresses.Clear();
|
|
|
|
|
GoToAddress(newHighlighted);
|
|
|
|
|
}
|
2011-08-23 22:22:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case Keys.Down:
|
2012-06-23 20:48:17 +00:00
|
|
|
|
newHighlighted = addressHighlighted + 16;
|
|
|
|
|
if (e.Modifiers == Keys.Shift)
|
|
|
|
|
{
|
|
|
|
|
for (int i = newHighlighted - 16; i < newHighlighted; i++)
|
|
|
|
|
{
|
|
|
|
|
AddToSecondaryHighlights(i);
|
|
|
|
|
}
|
|
|
|
|
GoToAddress(newHighlighted);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SecondaryHighlightedAddresses.Clear();
|
|
|
|
|
GoToAddress(newHighlighted);
|
|
|
|
|
}
|
2011-08-23 22:22:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case Keys.Left:
|
2012-06-23 20:48:17 +00:00
|
|
|
|
newHighlighted = addressHighlighted - (1 * DataSize);
|
|
|
|
|
if (e.Modifiers == Keys.Shift)
|
|
|
|
|
{
|
|
|
|
|
AddToSecondaryHighlights(addressHighlighted);
|
|
|
|
|
GoToAddress(newHighlighted);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SecondaryHighlightedAddresses.Clear();
|
|
|
|
|
GoToAddress(newHighlighted);
|
|
|
|
|
}
|
2011-08-23 22:22:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case Keys.Right:
|
2012-06-23 20:48:17 +00:00
|
|
|
|
newHighlighted = addressHighlighted + (1 * DataSize);
|
|
|
|
|
if (e.Modifiers == Keys.Shift)
|
|
|
|
|
{
|
|
|
|
|
AddToSecondaryHighlights(addressHighlighted);
|
|
|
|
|
GoToAddress(newHighlighted);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SecondaryHighlightedAddresses.Clear();
|
|
|
|
|
GoToAddress(newHighlighted);
|
|
|
|
|
}
|
2011-08-23 22:22:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case Keys.PageUp:
|
2012-06-23 20:48:17 +00:00
|
|
|
|
newHighlighted = addressHighlighted - (RowsVisible * 16);
|
|
|
|
|
if (e.Modifiers == Keys.Shift)
|
|
|
|
|
{
|
|
|
|
|
for (int i = newHighlighted + 1; i <= addressHighlighted; i++)
|
|
|
|
|
{
|
|
|
|
|
AddToSecondaryHighlights(i);
|
|
|
|
|
}
|
|
|
|
|
GoToAddress(newHighlighted);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SecondaryHighlightedAddresses.Clear();
|
|
|
|
|
GoToAddress(newHighlighted);
|
|
|
|
|
}
|
2011-08-23 22:22:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case Keys.PageDown:
|
2012-06-23 20:48:17 +00:00
|
|
|
|
newHighlighted = addressHighlighted + (RowsVisible * 16);
|
|
|
|
|
if (e.Modifiers == Keys.Shift)
|
|
|
|
|
{
|
|
|
|
|
for (int i = addressHighlighted + 1; i < newHighlighted; i++)
|
|
|
|
|
{
|
|
|
|
|
AddToSecondaryHighlights(i);
|
|
|
|
|
}
|
|
|
|
|
GoToAddress(newHighlighted);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SecondaryHighlightedAddresses.Clear();
|
|
|
|
|
GoToAddress(newHighlighted);
|
|
|
|
|
}
|
2011-08-23 22:22:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case Keys.Tab:
|
2012-06-23 20:48:17 +00:00
|
|
|
|
SecondaryHighlightedAddresses.Clear();
|
2011-08-23 22:22:24 +00:00
|
|
|
|
if (e.Modifiers == Keys.Shift)
|
|
|
|
|
GoToAddress(addressHighlighted - 8);
|
|
|
|
|
else
|
|
|
|
|
GoToAddress(addressHighlighted + 8);
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Home:
|
2012-06-23 21:09:20 +00:00
|
|
|
|
if (e.Modifiers == Keys.Shift)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 1; i <= addressHighlighted; i++)
|
|
|
|
|
{
|
|
|
|
|
AddToSecondaryHighlights(i);
|
|
|
|
|
}
|
|
|
|
|
GoToAddress(0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SecondaryHighlightedAddresses.Clear();
|
|
|
|
|
GoToAddress(0);
|
|
|
|
|
}
|
2011-08-23 22:22:24 +00:00
|
|
|
|
break;
|
|
|
|
|
case Keys.End:
|
2012-06-23 21:09:20 +00:00
|
|
|
|
newHighlighted = Domain.Size - (DataSize);
|
|
|
|
|
if (e.Modifiers == Keys.Shift)
|
|
|
|
|
{
|
|
|
|
|
for (int i = addressHighlighted; i < newHighlighted; i++)
|
|
|
|
|
{
|
|
|
|
|
AddToSecondaryHighlights(i);
|
|
|
|
|
}
|
|
|
|
|
GoToAddress(newHighlighted);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SecondaryHighlightedAddresses.Clear();
|
|
|
|
|
GoToAddress(newHighlighted);
|
|
|
|
|
}
|
2011-08-23 22:22:24 +00:00
|
|
|
|
break;
|
2012-03-08 18:33:57 +00:00
|
|
|
|
case Keys.Add:
|
|
|
|
|
IncrementAddress();
|
|
|
|
|
UpdateValues();
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Subtract:
|
|
|
|
|
DecrementAddress();
|
|
|
|
|
UpdateValues();
|
|
|
|
|
break;
|
2012-03-09 01:24:46 +00:00
|
|
|
|
case Keys.Space:
|
|
|
|
|
ToggleFreeze();
|
|
|
|
|
break;
|
2012-03-09 01:43:52 +00:00
|
|
|
|
case Keys.Delete:
|
|
|
|
|
if (e.Modifiers == Keys.Shift)
|
|
|
|
|
RemoveAllCheats();
|
|
|
|
|
else
|
2012-06-19 02:42:07 +00:00
|
|
|
|
UnFreezeAddress(GetHighlightedAddress());
|
2012-03-09 01:43:52 +00:00
|
|
|
|
break;
|
2012-03-10 02:31:34 +00:00
|
|
|
|
case Keys.W:
|
|
|
|
|
if (e.Modifiers == Keys.Control)
|
|
|
|
|
AddToRamWatch();
|
2012-03-09 01:43:52 +00:00
|
|
|
|
break;
|
2011-08-23 22:22:24 +00:00
|
|
|
|
}
|
2011-08-24 02:31:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-23 20:48:17 +00:00
|
|
|
|
private void AddToSecondaryHighlights(int address)
|
|
|
|
|
{
|
|
|
|
|
if (address >= 0 && address < Domain.Size)
|
|
|
|
|
{
|
|
|
|
|
SecondaryHighlightedAddresses.Add(address);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-24 02:31:45 +00:00
|
|
|
|
private void HexEditor_KeyUp(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!InputValidate.IsValidHexNumber(((char)e.KeyCode).ToString()))
|
|
|
|
|
{
|
|
|
|
|
if (e.Control && e.KeyCode == Keys.G)
|
|
|
|
|
GoToSpecifiedAddress();
|
2011-09-13 00:35:40 +00:00
|
|
|
|
if (e.Control && e.KeyCode == Keys.P)
|
|
|
|
|
PokeAddress();
|
2011-08-24 02:31:45 +00:00
|
|
|
|
e.Handled = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 16:34:35 +00:00
|
|
|
|
if (e.Control || e.Shift || e.Alt) //If user is pressing one of these, don't type into the hex editor
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-09 16:13:40 +00:00
|
|
|
|
switch (DataSize)
|
2011-08-24 02:48:52 +00:00
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case 1:
|
|
|
|
|
if (nibbles[0] == 'G')
|
|
|
|
|
{
|
|
|
|
|
nibbles[0] = (char)e.KeyCode;
|
|
|
|
|
info = nibbles[0].ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string temp = nibbles[0].ToString() + ((char)e.KeyCode).ToString();
|
|
|
|
|
byte x = byte.Parse(temp, NumberStyles.HexNumber);
|
|
|
|
|
Domain.PokeByte(addressHighlighted, x);
|
|
|
|
|
ClearNibbles();
|
|
|
|
|
SetHighlighted(addressHighlighted + 1);
|
|
|
|
|
UpdateValues();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
if (nibbles[0] == 'G')
|
|
|
|
|
{
|
|
|
|
|
nibbles[0] = (char)e.KeyCode;
|
|
|
|
|
info = nibbles[0].ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (nibbles[1] == 'G')
|
|
|
|
|
{
|
|
|
|
|
nibbles[1] = (char)e.KeyCode;
|
|
|
|
|
info = nibbles[1].ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (nibbles[2] == 'G')
|
|
|
|
|
{
|
|
|
|
|
nibbles[2] = (char)e.KeyCode;
|
|
|
|
|
info = nibbles[2].ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (nibbles[3] == 'G')
|
|
|
|
|
{
|
|
|
|
|
string temp = nibbles[0].ToString() + nibbles[1].ToString();
|
|
|
|
|
byte x1 = byte.Parse(temp, NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
|
|
string temp2 = nibbles[2].ToString() + ((char)e.KeyCode).ToString();
|
|
|
|
|
byte x2 = byte.Parse(temp2, NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
|
|
PokeWord(addressHighlighted, x1, x2);
|
|
|
|
|
ClearNibbles();
|
2011-08-25 02:23:12 +00:00
|
|
|
|
SetHighlighted(addressHighlighted + 2);
|
2011-08-24 02:48:52 +00:00
|
|
|
|
UpdateValues();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
2011-08-25 01:49:22 +00:00
|
|
|
|
if (nibbles[0] == 'G')
|
|
|
|
|
{
|
|
|
|
|
nibbles[0] = (char)e.KeyCode;
|
|
|
|
|
info = nibbles[0].ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (nibbles[1] == 'G')
|
|
|
|
|
{
|
|
|
|
|
nibbles[1] = (char)e.KeyCode;
|
|
|
|
|
info = nibbles[1].ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (nibbles[2] == 'G')
|
|
|
|
|
{
|
|
|
|
|
nibbles[2] = (char)e.KeyCode;
|
|
|
|
|
info = nibbles[2].ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (nibbles[3] == 'G')
|
|
|
|
|
{
|
|
|
|
|
nibbles[3] = (char)e.KeyCode;
|
|
|
|
|
info = nibbles[3].ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (nibbles[4] == 'G')
|
|
|
|
|
{
|
|
|
|
|
nibbles[4] = (char)e.KeyCode;
|
|
|
|
|
info = nibbles[4].ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (nibbles[5] == 'G')
|
|
|
|
|
{
|
|
|
|
|
nibbles[5] = (char)e.KeyCode;
|
|
|
|
|
info = nibbles[5].ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (nibbles[6] == 'G')
|
|
|
|
|
{
|
|
|
|
|
nibbles[6] = (char)e.KeyCode;
|
|
|
|
|
info = nibbles[6].ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (nibbles[7] == 'G')
|
|
|
|
|
{
|
|
|
|
|
string temp = nibbles[0].ToString() + nibbles[1].ToString();
|
|
|
|
|
byte x1 = byte.Parse(temp, NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
|
|
string temp2 = nibbles[2].ToString() + nibbles[3].ToString();
|
|
|
|
|
byte x2 = byte.Parse(temp2, NumberStyles.HexNumber);
|
2011-08-24 02:48:52 +00:00
|
|
|
|
|
2011-08-25 01:49:22 +00:00
|
|
|
|
string temp3 = nibbles[4].ToString() + nibbles[5].ToString();
|
|
|
|
|
byte x3 = byte.Parse(temp3, NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
|
|
string temp4 = nibbles[6].ToString() + ((char)e.KeyCode).ToString();
|
|
|
|
|
byte x4 = byte.Parse(temp4, NumberStyles.HexNumber);
|
|
|
|
|
|
|
|
|
|
PokeWord(addressHighlighted, x1, x2);
|
|
|
|
|
PokeWord(addressHighlighted + 2, x3, x4);
|
|
|
|
|
ClearNibbles();
|
|
|
|
|
SetHighlighted(addressHighlighted + 4);
|
|
|
|
|
UpdateValues();
|
|
|
|
|
}
|
2011-08-24 02:48:52 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2011-08-25 02:23:12 +00:00
|
|
|
|
MemoryViewerBox.Refresh();
|
2011-08-24 02:48:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PokeWord(int addr, byte _1, byte _2)
|
|
|
|
|
{
|
2012-03-09 16:13:40 +00:00
|
|
|
|
if (BigEndian)
|
2011-08-24 02:31:45 +00:00
|
|
|
|
{
|
2011-08-24 02:48:52 +00:00
|
|
|
|
Domain.PokeByte(addr, _2);
|
|
|
|
|
Domain.PokeByte(addr + 1, _1);
|
2011-08-24 02:31:45 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-08-24 02:48:52 +00:00
|
|
|
|
Domain.PokeByte(addr, _1);
|
|
|
|
|
Domain.PokeByte(addr + 1, _2);
|
2011-08-24 02:31:45 +00:00
|
|
|
|
}
|
2011-08-23 22:22:24 +00:00
|
|
|
|
}
|
2011-08-25 01:49:22 +00:00
|
|
|
|
|
|
|
|
|
private void RemoveAllCheats()
|
|
|
|
|
{
|
|
|
|
|
Global.MainForm.Cheats1.RemoveAllCheats();
|
|
|
|
|
MemoryViewerBox.Refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void unfreezeAllToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
RemoveAllCheats();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void unfreezeAllToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
RemoveAllCheats();
|
|
|
|
|
}
|
2011-08-26 00:20:42 +00:00
|
|
|
|
|
|
|
|
|
private void HexEditor_MouseWheel(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Delta > 0)
|
|
|
|
|
{
|
|
|
|
|
if (vScrollBar1.Value > vScrollBar1.Minimum)
|
|
|
|
|
{
|
|
|
|
|
vScrollBar1.Value--;
|
|
|
|
|
MemoryViewerBox.Refresh();
|
2012-06-19 01:33:32 +00:00
|
|
|
|
AddressLabel.Text = GenerateAddressString();
|
2011-08-26 00:20:42 +00:00
|
|
|
|
UpdateValues();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (e.Delta < 0)
|
|
|
|
|
{
|
|
|
|
|
if (vScrollBar1.Value < vScrollBar1.Maximum)
|
|
|
|
|
{
|
|
|
|
|
vScrollBar1.Value++;
|
|
|
|
|
MemoryViewerBox.Refresh();
|
2012-06-19 01:33:32 +00:00
|
|
|
|
AddressLabel.Text = GenerateAddressString();
|
2011-08-26 00:20:42 +00:00
|
|
|
|
UpdateValues();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2012-03-08 18:33:57 +00:00
|
|
|
|
|
|
|
|
|
private void IncrementAddress()
|
|
|
|
|
{
|
|
|
|
|
int address = GetHighlightedAddress();
|
|
|
|
|
byte value;
|
|
|
|
|
if (address >= 0)
|
|
|
|
|
{
|
2012-03-09 16:13:40 +00:00
|
|
|
|
switch (DataSize)
|
2012-03-08 18:33:57 +00:00
|
|
|
|
{
|
|
|
|
|
default:
|
2012-06-25 03:10:04 +00:00
|
|
|
|
case 1:
|
2012-03-08 18:33:57 +00:00
|
|
|
|
value = Domain.PeekByte(address);
|
2012-06-25 03:10:04 +00:00
|
|
|
|
HexPokeAddress(address, (byte)(value + 1));
|
2012-03-08 18:33:57 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2012-06-25 03:10:04 +00:00
|
|
|
|
if (BigEndian)
|
|
|
|
|
{
|
|
|
|
|
value = Domain.PeekByte(address + 1);
|
|
|
|
|
if (value == 0xFF) //Wrapping logic
|
|
|
|
|
{
|
|
|
|
|
HexPokeAddress(address, (byte)(value + 1));
|
|
|
|
|
HexPokeAddress(address + 1, (byte)(value + 1));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HexPokeAddress(address + 1, (byte)(value + 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
value = Domain.PeekByte(address);
|
|
|
|
|
if (value == 0xFF) //Wrapping logic
|
|
|
|
|
{
|
|
|
|
|
HexPokeAddress(address, (byte)(value + 1));
|
|
|
|
|
HexPokeAddress(address + 1, (byte)(value + 1));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HexPokeAddress(address, (byte)(value + 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-08 18:33:57 +00:00
|
|
|
|
break;
|
|
|
|
|
case 4:
|
2012-06-25 03:10:04 +00:00
|
|
|
|
if (BigEndian)
|
|
|
|
|
{
|
|
|
|
|
value = Domain.PeekByte(address + 3);
|
|
|
|
|
if (value == 0xFF) //Wrapping logic
|
|
|
|
|
{
|
|
|
|
|
HexPokeAddress(address + 3, (byte)(value + 1));
|
|
|
|
|
HexPokeAddress(address + 2, (byte)(value + 1));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HexPokeAddress(address + 2, (byte)(value + 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
value = Domain.PeekByte(address);
|
|
|
|
|
HexPokeAddress(address, (byte)(value + 1));
|
|
|
|
|
}
|
2012-03-08 18:33:57 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-25 03:10:04 +00:00
|
|
|
|
private void HexPokeAddress(int address, byte value)
|
|
|
|
|
{
|
|
|
|
|
if (Global.CheatList.IsActiveCheat(Domain, address))
|
|
|
|
|
{
|
|
|
|
|
UnFreezeAddress(address);
|
|
|
|
|
Domain.PokeByte(address, value);
|
|
|
|
|
FreezeAddress(address);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Domain.PokeByte(address, (byte)value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-08 18:33:57 +00:00
|
|
|
|
private void DecrementAddress()
|
|
|
|
|
{
|
|
|
|
|
int address = GetHighlightedAddress();
|
|
|
|
|
byte value;
|
|
|
|
|
if (address >= 0)
|
|
|
|
|
{
|
2012-03-09 16:13:40 +00:00
|
|
|
|
switch (DataSize)
|
2012-03-08 18:33:57 +00:00
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case 1:
|
|
|
|
|
value = Domain.PeekByte(address);
|
2012-06-25 03:10:04 +00:00
|
|
|
|
HexPokeAddress(address, (byte)(value - 1));
|
2012-03-08 18:33:57 +00:00
|
|
|
|
break;
|
2012-06-25 03:10:04 +00:00
|
|
|
|
case 2:
|
|
|
|
|
if (BigEndian)
|
|
|
|
|
{
|
|
|
|
|
value = Domain.PeekByte(address + 1);
|
|
|
|
|
if (value == 0) //Wrapping logic
|
|
|
|
|
{
|
|
|
|
|
HexPokeAddress(address, (byte)(value - 1));
|
|
|
|
|
HexPokeAddress(address + 1, (byte)(value - 1));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Domain.PokeByte(address + 1, (byte)(value - 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
value = Domain.PeekByte(address);
|
|
|
|
|
if (value == 0) //Wrapping logic
|
|
|
|
|
{
|
|
|
|
|
HexPokeAddress(address, (byte)(value - 1));
|
|
|
|
|
HexPokeAddress(address + 1, (byte)(value - 1));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HexPokeAddress(address, (byte)(value - 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-08 18:33:57 +00:00
|
|
|
|
break;
|
|
|
|
|
case 4:
|
2012-06-25 03:10:04 +00:00
|
|
|
|
if (BigEndian)
|
|
|
|
|
{
|
|
|
|
|
value = Domain.PeekByte(address + 3);
|
|
|
|
|
if (value == 0xFF) //Wrapping logic
|
|
|
|
|
{
|
|
|
|
|
HexPokeAddress(address + 3, (byte)(value - 1));
|
|
|
|
|
HexPokeAddress(address + 2, (byte)(value - 1));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HexPokeAddress(address + 3, (byte)(value - 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
value = Domain.PeekByte(address);
|
|
|
|
|
if (value == 0)
|
|
|
|
|
{
|
|
|
|
|
HexPokeAddress(address, (byte)(value - 1));
|
|
|
|
|
HexPokeAddress(address + 1, (byte)(value - 1));
|
|
|
|
|
int value2 = Domain.PeekByte(address + 1);
|
|
|
|
|
if (value2 == 0xFF)
|
|
|
|
|
{
|
|
|
|
|
Domain.PokeByte(address + 2, (byte)(value - 1));
|
|
|
|
|
int value3 = Domain.PeekByte(address + 1);
|
|
|
|
|
if (value3 == 0xFF)
|
|
|
|
|
{
|
|
|
|
|
HexPokeAddress(address + 3, (byte)(value - 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HexPokeAddress(address, (byte)(value - 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-08 18:33:57 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void incrementToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
IncrementAddress();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void decrementToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DecrementAddress();
|
|
|
|
|
}
|
2012-03-09 01:33:55 +00:00
|
|
|
|
|
|
|
|
|
private void ViewerContextMenuStrip_Opening(object sender, CancelEventArgs e)
|
|
|
|
|
{
|
2012-06-19 02:42:07 +00:00
|
|
|
|
if (addressHighlighted > 0 || SecondaryHighlightedAddresses.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
copyToolStripMenuItem1.Visible = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
copyToolStripMenuItem1.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IDataObject iData = Clipboard.GetDataObject();
|
|
|
|
|
|
|
|
|
|
if (iData.GetDataPresent(DataFormats.Text))
|
|
|
|
|
{
|
|
|
|
|
pasteToolStripMenuItem1.Visible = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pasteToolStripMenuItem1.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-09 01:33:55 +00:00
|
|
|
|
if (IsFrozen(GetHighlightedAddress()))
|
|
|
|
|
{
|
2012-06-02 18:49:06 +00:00
|
|
|
|
freezeToolStripMenuItem.Text = "Un&freeze";
|
|
|
|
|
freezeToolStripMenuItem.Image = MultiClient.Properties.Resources.Unfreeze;
|
2012-03-09 01:33:55 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-06-02 18:49:06 +00:00
|
|
|
|
freezeToolStripMenuItem.Text = "&Freeze";
|
|
|
|
|
freezeToolStripMenuItem.Image = MultiClient.Properties.Resources.Freeze;
|
2012-03-09 01:33:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-06-02 21:18:21 +00:00
|
|
|
|
|
|
|
|
|
private void gotoAddressToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
GoToSpecifiedAddress();
|
|
|
|
|
}
|
2012-06-09 22:04:09 +00:00
|
|
|
|
|
2012-06-19 02:42:07 +00:00
|
|
|
|
private string ValueString(int address)
|
2012-06-10 16:34:35 +00:00
|
|
|
|
{
|
2012-06-19 02:42:07 +00:00
|
|
|
|
if (address != -1)
|
2012-06-10 16:34:35 +00:00
|
|
|
|
{
|
2012-06-19 02:42:07 +00:00
|
|
|
|
return String.Format(DigitFormatString, (int)MakeValue(address)).Trim();
|
2012-06-10 16:34:35 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-23 18:45:01 +00:00
|
|
|
|
private void OpenFindBox()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
FindStr = GetFindValues();
|
|
|
|
|
if (!HexFind1.IsHandleCreated || HexFind1.IsDisposed)
|
|
|
|
|
{
|
|
|
|
|
HexFind1 = new HexFind();
|
|
|
|
|
Point p = PointToScreen(AddressesLabel.Location);
|
|
|
|
|
HexFind1.SetLocation(p);
|
|
|
|
|
HexFind1.SetInitialValue(FindStr);
|
|
|
|
|
HexFind1.Show();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HexFind1.SetInitialValue(FindStr);
|
|
|
|
|
HexFind1.Focus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string GetFindValues()
|
|
|
|
|
{
|
|
|
|
|
string values = "";
|
|
|
|
|
if (addressHighlighted > 0)
|
|
|
|
|
{
|
|
|
|
|
values += ValueString(GetHighlightedAddress());
|
|
|
|
|
foreach (int x in SecondaryHighlightedAddresses)
|
|
|
|
|
{
|
|
|
|
|
values += ValueString(x);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return values;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void FindNext(string value)
|
|
|
|
|
{
|
|
|
|
|
int found = 0;
|
|
|
|
|
|
|
|
|
|
string search = value.Replace(" ", "").ToUpper();
|
|
|
|
|
if (search.Length == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
int numByte = search.Length / 2;
|
|
|
|
|
|
|
|
|
|
int startByte = 0;
|
|
|
|
|
if (addressHighlighted == -1)
|
|
|
|
|
{
|
|
|
|
|
startByte = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (addressHighlighted >= (Domain.Size - 1 - numByte))
|
|
|
|
|
{
|
|
|
|
|
startByte = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
startByte = addressHighlighted + DataSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = startByte; i < (Domain.Size - numByte); i++)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder ramblock = new StringBuilder();
|
|
|
|
|
for (int j = 0; j < numByte; j++)
|
|
|
|
|
{
|
|
|
|
|
ramblock.Append(String.Format("{0:X2}", (int)Domain.PeekByte(i + j)));
|
|
|
|
|
}
|
|
|
|
|
string block = ramblock.ToString().ToUpper();
|
|
|
|
|
if (search == block)
|
|
|
|
|
{
|
|
|
|
|
found = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found > 0)
|
|
|
|
|
{
|
|
|
|
|
HighlightSecondaries(search, found);
|
|
|
|
|
GoToAddress(found);
|
|
|
|
|
FindStr = search;
|
2012-06-25 03:13:02 +00:00
|
|
|
|
MemoryViewerBox.Focus();
|
2012-06-23 18:45:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void FindPrev(string value)
|
|
|
|
|
{
|
|
|
|
|
int found = 0;
|
|
|
|
|
|
|
|
|
|
string search = value.Replace(" ", "").ToUpper();
|
|
|
|
|
if (search.Length == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
int numByte = search.Length / 2;
|
|
|
|
|
|
|
|
|
|
int startByte = 0;
|
|
|
|
|
if (addressHighlighted == -1)
|
|
|
|
|
{
|
|
|
|
|
startByte = Domain.Size - DataSize;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
startByte = addressHighlighted - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = startByte; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder ramblock = new StringBuilder();
|
|
|
|
|
for (int j = 0; j < numByte; j++)
|
|
|
|
|
{
|
|
|
|
|
ramblock.Append(String.Format("{0:X2}", (int)Domain.PeekByte(i + j)));
|
|
|
|
|
}
|
|
|
|
|
string block = ramblock.ToString().ToUpper();
|
|
|
|
|
if (search == block)
|
|
|
|
|
{
|
|
|
|
|
found = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found > 0)
|
|
|
|
|
{
|
|
|
|
|
HighlightSecondaries(search, found);
|
|
|
|
|
GoToAddress(found);
|
|
|
|
|
FindStr = search;
|
2012-06-25 03:13:02 +00:00
|
|
|
|
MemoryViewerBox.Focus();
|
2012-06-23 18:45:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HighlightSecondaries(string value, int found)
|
|
|
|
|
{
|
|
|
|
|
//This function assumes that the primary highlighted value has been set and sets the remaining characters in this string
|
|
|
|
|
SecondaryHighlightedAddresses.Clear();
|
|
|
|
|
|
|
|
|
|
int addrLength = DataSize * 2;
|
|
|
|
|
if (value.Length <= addrLength)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int numToHighlight = ((value.Length / addrLength)) - 1;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < numToHighlight; i++)
|
|
|
|
|
{
|
|
|
|
|
SecondaryHighlightedAddresses.Add(found + 1 + i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 16:34:35 +00:00
|
|
|
|
private void Find()
|
2012-06-09 22:04:09 +00:00
|
|
|
|
{
|
|
|
|
|
InputPrompt prompt = new InputPrompt();
|
|
|
|
|
prompt.SetMessage("Enter a set of hex values to search for");
|
|
|
|
|
prompt.SetCasing(CharacterCasing.Upper);
|
2012-08-17 03:04:35 +00:00
|
|
|
|
prompt.TextInputType = InputPrompt.InputType.HEX;
|
2012-06-09 22:45:24 +00:00
|
|
|
|
if (addressHighlighted > 0)
|
|
|
|
|
{
|
2012-06-19 23:44:36 +00:00
|
|
|
|
string values = ValueString(GetHighlightedAddress());
|
|
|
|
|
foreach (int x in SecondaryHighlightedAddresses)
|
|
|
|
|
{
|
|
|
|
|
values += ValueString(x);
|
|
|
|
|
}
|
|
|
|
|
prompt.SetInitialValue(values);
|
2012-06-09 22:45:24 +00:00
|
|
|
|
}
|
2012-06-09 22:04:09 +00:00
|
|
|
|
prompt.ShowDialog();
|
2012-06-09 22:45:24 +00:00
|
|
|
|
|
2012-06-10 16:34:35 +00:00
|
|
|
|
|
2012-06-09 22:04:09 +00:00
|
|
|
|
if (prompt.UserOK)
|
|
|
|
|
{
|
|
|
|
|
int found = 0;
|
|
|
|
|
|
|
|
|
|
string search = prompt.UserText.Replace(" ", "").ToUpper();
|
2012-06-09 22:45:24 +00:00
|
|
|
|
if (search.Length == 0)
|
|
|
|
|
return;
|
2012-06-09 22:04:09 +00:00
|
|
|
|
|
|
|
|
|
int numByte = search.Length / 2;
|
2012-06-10 16:34:35 +00:00
|
|
|
|
|
2012-06-09 22:45:24 +00:00
|
|
|
|
int startByte = 0;
|
|
|
|
|
if (addressHighlighted == -1)
|
|
|
|
|
{
|
|
|
|
|
startByte = 0;
|
|
|
|
|
}
|
|
|
|
|
else if (addressHighlighted >= (Domain.Size - 1 - numByte))
|
|
|
|
|
{
|
|
|
|
|
startByte = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
startByte = addressHighlighted + DataSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = startByte; i < (Domain.Size - numByte); i++)
|
2012-06-09 22:04:09 +00:00
|
|
|
|
{
|
|
|
|
|
StringBuilder ramblock = new StringBuilder();
|
|
|
|
|
for (int j = 0; j < numByte; j++)
|
|
|
|
|
{
|
|
|
|
|
ramblock.Append(String.Format("{0:X2}", (int)Domain.PeekByte(i + j)));
|
|
|
|
|
}
|
|
|
|
|
string block = ramblock.ToString().ToUpper();
|
|
|
|
|
if (search == block)
|
|
|
|
|
{
|
|
|
|
|
found = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (found > 0)
|
|
|
|
|
{
|
|
|
|
|
GoToAddress(found);
|
2012-06-10 16:34:35 +00:00
|
|
|
|
|
2012-06-09 22:04:09 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Could not find the values: " + search);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-06-10 16:34:35 +00:00
|
|
|
|
|
2012-06-19 02:42:07 +00:00
|
|
|
|
private void Copy()
|
2012-06-10 16:34:35 +00:00
|
|
|
|
{
|
2012-06-19 02:42:07 +00:00
|
|
|
|
string value = ValueString(GetHighlightedAddress());
|
|
|
|
|
foreach (int x in SecondaryHighlightedAddresses)
|
|
|
|
|
{
|
|
|
|
|
value += MakeValue(x);
|
|
|
|
|
}
|
2012-06-10 16:34:35 +00:00
|
|
|
|
if (!String.IsNullOrWhiteSpace(value))
|
|
|
|
|
{
|
|
|
|
|
Clipboard.SetDataObject(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-19 02:42:07 +00:00
|
|
|
|
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Copy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Paste()
|
2012-06-10 16:34:35 +00:00
|
|
|
|
{
|
|
|
|
|
IDataObject iData = Clipboard.GetDataObject();
|
|
|
|
|
|
|
|
|
|
if (iData.GetDataPresent(DataFormats.Text))
|
|
|
|
|
{
|
|
|
|
|
string clipboardRaw = (String)iData.GetData(DataFormats.Text);
|
|
|
|
|
string hex = InputValidate.DoHexString(clipboardRaw);
|
|
|
|
|
|
|
|
|
|
int numBytes = hex.Length / 2;
|
|
|
|
|
for (int i = 0; i < numBytes; i++)
|
|
|
|
|
{
|
|
|
|
|
int value = int.Parse(hex.Substring(i * 2, 2), NumberStyles.HexNumber);
|
|
|
|
|
int address = addressHighlighted + i;
|
|
|
|
|
Domain.PokeByte(address, (byte)value);
|
|
|
|
|
}
|
2012-06-19 02:42:07 +00:00
|
|
|
|
|
2012-06-10 16:34:35 +00:00
|
|
|
|
UpdateValues();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//Do nothing
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-19 02:42:07 +00:00
|
|
|
|
private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Paste();
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 16:34:35 +00:00
|
|
|
|
private void findToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2012-06-23 18:45:01 +00:00
|
|
|
|
OpenFindBox();
|
|
|
|
|
//Find();
|
2012-06-10 16:34:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-06-10 17:28:38 +00:00
|
|
|
|
private void saveAsBinaryToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SaveAsBinary();
|
|
|
|
|
}
|
2012-06-10 22:43:43 +00:00
|
|
|
|
|
|
|
|
|
private void setColorsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
HexColors_Form h = new HexColors_Form();
|
|
|
|
|
h.Show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setColorsToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
HexColors_Form h = new HexColors_Form();
|
2012-06-13 00:21:11 +00:00
|
|
|
|
Global.Sound.StopSound();
|
2012-06-10 22:54:41 +00:00
|
|
|
|
h.ShowDialog();
|
2012-06-13 00:21:11 +00:00
|
|
|
|
Global.Sound.StartSound();
|
2012-06-10 22:43:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void resetToDefaultToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.MemoryViewerBox.BackColor = Color.FromName("Control");
|
|
|
|
|
this.MemoryViewerBox.ForeColor = Color.FromName("ControlText");
|
|
|
|
|
this.menuStrip1.BackColor = Color.FromName("Control");
|
2012-06-13 02:44:19 +00:00
|
|
|
|
this.Header.BackColor = Color.FromName("Control");
|
|
|
|
|
this.Header.ForeColor = Color.FromName("ControlText");
|
2012-06-10 23:34:37 +00:00
|
|
|
|
Global.Config.HexMenubarColor = Color.FromName("Control");
|
2012-06-12 03:50:25 +00:00
|
|
|
|
Global.Config.HexForegrndColor = Color.FromName("ControlText");
|
|
|
|
|
Global.Config.HexBackgrndColor = Color.FromName("Control");
|
|
|
|
|
Global.Config.HexFreezeColor = Color.LightBlue;
|
|
|
|
|
Global.Config.HexHighlightColor = Color.Pink;
|
|
|
|
|
Global.Config.HexHighlightFreezeColor = Color.Violet;
|
2012-06-10 22:43:43 +00:00
|
|
|
|
}
|
2012-06-19 02:42:07 +00:00
|
|
|
|
|
|
|
|
|
private void copyToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Copy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void pasteToolStripMenuItem1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Paste();
|
|
|
|
|
}
|
2012-06-23 18:45:01 +00:00
|
|
|
|
|
|
|
|
|
private void findNextToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
FindNext(FindStr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void findPrevToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
FindPrev(FindStr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void editToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (String.IsNullOrWhiteSpace(FindStr))
|
|
|
|
|
{
|
|
|
|
|
findNextToolStripMenuItem.Enabled = false;
|
|
|
|
|
findPrevToolStripMenuItem.Enabled = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
findNextToolStripMenuItem.Enabled = true;
|
|
|
|
|
findPrevToolStripMenuItem.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-09-02 23:12:00 +00:00
|
|
|
|
|
|
|
|
|
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (CurrentROMIsArchive())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FileInfo file = new FileInfo(Global.MainForm.CurrentlyOpenRom);
|
|
|
|
|
SaveFileBinary(file);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fileToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Domain.Name == "ROM File")
|
|
|
|
|
{
|
|
|
|
|
if (!CurrentROMIsArchive())
|
|
|
|
|
{
|
|
|
|
|
saveToolStripMenuItem.Visible = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
saveToolStripMenuItem.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
saveAsBinaryToolStripMenuItem.Text = "Save as ROM...";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
saveAsBinaryToolStripMenuItem.Text = "Save as binary...";
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-06-19 23:39:25 +00:00
|
|
|
|
}
|
2012-06-25 03:10:04 +00:00
|
|
|
|
}
|