Fix bugs in things that use HexTextBox, and some bugs that made the Encoder part of NES GameGenie Encoder/Decoder not work
This commit is contained in:
parent
ea2df2e91b
commit
a11019ee6c
|
@ -15,7 +15,7 @@ namespace BizHawk
|
|||
|
||||
public class HexTextBox : TextBox, INumberBox
|
||||
{
|
||||
private string _addressFormatStr = "{0:X4}";
|
||||
private string _addressFormatStr = String.Empty;
|
||||
private int? _maxSize = null;
|
||||
private bool _nullable = true;
|
||||
|
||||
|
@ -75,7 +75,7 @@ namespace BizHawk
|
|||
{
|
||||
if (e.KeyCode == Keys.Up)
|
||||
{
|
||||
if (InputValidate.IsValidHexNumber(Text))
|
||||
if (InputValidate.IsValidHexNumber(Text) && !String.IsNullOrEmpty(_addressFormatStr))
|
||||
{
|
||||
uint val = (uint)ToRawInt();
|
||||
|
||||
|
@ -93,7 +93,7 @@ namespace BizHawk
|
|||
}
|
||||
else if (e.KeyCode == Keys.Down)
|
||||
{
|
||||
if (InputValidate.IsValidHexNumber(Text))
|
||||
if (InputValidate.IsValidHexNumber(Text) && !String.IsNullOrEmpty(_addressFormatStr))
|
||||
{
|
||||
uint val = (uint)ToRawInt();
|
||||
if (val == 0)
|
||||
|
@ -120,6 +120,8 @@ namespace BizHawk
|
|||
{
|
||||
ResetText();
|
||||
}
|
||||
|
||||
base.OnTextChanged(e);
|
||||
}
|
||||
|
||||
public int ToRawInt()
|
||||
|
|
|
@ -60,16 +60,16 @@
|
|||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.Encoding = new System.Windows.Forms.CheckBox();
|
||||
this.ClearButton = new System.Windows.Forms.Button();
|
||||
this.menuStrip1 = new MenuStripEx();
|
||||
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.MenuStrip = new MenuStripEx();
|
||||
this.OptionsSubMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.AutoloadMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.SaveWindowPositionMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ExitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.GameGenieCodeBox.SuspendLayout();
|
||||
this.ButtonPanel.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.MenuStrip.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// GameGenieCode
|
||||
|
@ -78,7 +78,7 @@
|
|||
this.GameGenieCode.Location = new System.Drawing.Point(6, 19);
|
||||
this.GameGenieCode.MaxLength = 8;
|
||||
this.GameGenieCode.Name = "GameGenieCode";
|
||||
this.GameGenieCode.Size = new System.Drawing.Size(86, 20);
|
||||
this.GameGenieCode.Size = new System.Drawing.Size(102, 20);
|
||||
this.GameGenieCode.TabIndex = 20;
|
||||
this.GameGenieCode.TextChanged += new System.EventHandler(this.GameGenieCode_TextChanged);
|
||||
this.GameGenieCode.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GameGenieCode_KeyDown);
|
||||
|
@ -89,7 +89,7 @@
|
|||
this.GameGenieCodeBox.Controls.Add(this.GameGenieCode);
|
||||
this.GameGenieCodeBox.Location = new System.Drawing.Point(31, 103);
|
||||
this.GameGenieCodeBox.Name = "GameGenieCodeBox";
|
||||
this.GameGenieCodeBox.Size = new System.Drawing.Size(115, 54);
|
||||
this.GameGenieCodeBox.Size = new System.Drawing.Size(119, 54);
|
||||
this.GameGenieCodeBox.TabIndex = 1;
|
||||
this.GameGenieCodeBox.TabStop = false;
|
||||
this.GameGenieCodeBox.Text = "Game Genie Code";
|
||||
|
@ -123,37 +123,40 @@
|
|||
//
|
||||
// CompareBox
|
||||
//
|
||||
this.CompareBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.CompareBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
|
||||
this.CompareBox.Location = new System.Drawing.Point(87, 39);
|
||||
this.CompareBox.Location = new System.Drawing.Point(88, 39);
|
||||
this.CompareBox.MaxLength = 2;
|
||||
this.CompareBox.Name = "CompareBox";
|
||||
this.CompareBox.Nullable = true;
|
||||
this.CompareBox.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
|
||||
this.CompareBox.Size = new System.Drawing.Size(27, 20);
|
||||
this.CompareBox.Size = new System.Drawing.Size(20, 20);
|
||||
this.CompareBox.TabIndex = 22;
|
||||
this.CompareBox.TextChanged += new System.EventHandler(this.CompareBox_TextChanged);
|
||||
//
|
||||
// ValueBox
|
||||
//
|
||||
this.ValueBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ValueBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
|
||||
this.ValueBox.Location = new System.Drawing.Point(87, 65);
|
||||
this.ValueBox.Location = new System.Drawing.Point(88, 65);
|
||||
this.ValueBox.MaxLength = 2;
|
||||
this.ValueBox.Name = "ValueBox";
|
||||
this.ValueBox.Nullable = true;
|
||||
this.ValueBox.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
|
||||
this.ValueBox.Size = new System.Drawing.Size(27, 20);
|
||||
this.ValueBox.Size = new System.Drawing.Size(20, 20);
|
||||
this.ValueBox.TabIndex = 23;
|
||||
this.ValueBox.TextChanged += new System.EventHandler(this.ValueBox_TextChanged);
|
||||
//
|
||||
// AddressBox
|
||||
//
|
||||
this.AddressBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.AddressBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
|
||||
this.AddressBox.Location = new System.Drawing.Point(75, 13);
|
||||
this.AddressBox.Location = new System.Drawing.Point(76, 13);
|
||||
this.AddressBox.MaxLength = 4;
|
||||
this.AddressBox.Name = "AddressBox";
|
||||
this.AddressBox.Nullable = true;
|
||||
this.AddressBox.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
|
||||
this.AddressBox.Size = new System.Drawing.Size(39, 20);
|
||||
this.AddressBox.Size = new System.Drawing.Size(32, 20);
|
||||
this.AddressBox.TabIndex = 21;
|
||||
this.AddressBox.TextChanged += new System.EventHandler(this.AddressBox_TextChanged);
|
||||
//
|
||||
|
@ -366,14 +369,15 @@
|
|||
this.groupBox1.Controls.Add(this.CompareBox);
|
||||
this.groupBox1.Location = new System.Drawing.Point(31, 158);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(126, 93);
|
||||
this.groupBox1.Size = new System.Drawing.Size(119, 93);
|
||||
this.groupBox1.TabIndex = 5;
|
||||
this.groupBox1.TabStop = false;
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.Location = new System.Drawing.Point(69, 69);
|
||||
this.label6.Location = new System.Drawing.Point(70, 69);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(18, 13);
|
||||
this.label6.TabIndex = 9;
|
||||
|
@ -381,8 +385,9 @@
|
|||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(69, 42);
|
||||
this.label5.Location = new System.Drawing.Point(70, 42);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(18, 13);
|
||||
this.label5.TabIndex = 8;
|
||||
|
@ -390,8 +395,9 @@
|
|||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(57, 16);
|
||||
this.label4.Location = new System.Drawing.Point(58, 16);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(18, 13);
|
||||
this.label4.TabIndex = 7;
|
||||
|
@ -420,55 +426,55 @@
|
|||
this.ClearButton.UseVisualStyleBackColor = true;
|
||||
this.ClearButton.Click += new System.EventHandler(this.ClearButton_Click);
|
||||
//
|
||||
// menuStrip1
|
||||
// MenuStrip
|
||||
//
|
||||
this.menuStrip1.ClickThrough = true;
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.optionsToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(292, 24);
|
||||
this.menuStrip1.TabIndex = 8;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
this.MenuStrip.ClickThrough = true;
|
||||
this.MenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.OptionsSubMenu});
|
||||
this.MenuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.MenuStrip.Name = "MenuStrip";
|
||||
this.MenuStrip.Size = new System.Drawing.Size(292, 24);
|
||||
this.MenuStrip.TabIndex = 8;
|
||||
this.MenuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// optionsToolStripMenuItem
|
||||
// OptionsSubMenu
|
||||
//
|
||||
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.autoloadToolStripMenuItem,
|
||||
this.saveWindowPositionToolStripMenuItem,
|
||||
this.OptionsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.AutoloadMenuItem,
|
||||
this.SaveWindowPositionMenuItem,
|
||||
this.toolStripSeparator1,
|
||||
this.exitToolStripMenuItem});
|
||||
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
|
||||
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
|
||||
this.optionsToolStripMenuItem.Text = "&Options";
|
||||
this.optionsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.optionsToolStripMenuItem_DropDownOpened);
|
||||
this.ExitMenuItem});
|
||||
this.OptionsSubMenu.Name = "OptionsSubMenu";
|
||||
this.OptionsSubMenu.Size = new System.Drawing.Size(61, 20);
|
||||
this.OptionsSubMenu.Text = "&Options";
|
||||
this.OptionsSubMenu.DropDownOpened += new System.EventHandler(this.OptionsSubMenu_DropDownOpened);
|
||||
//
|
||||
// autoloadToolStripMenuItem
|
||||
// AutoloadMenuItem
|
||||
//
|
||||
this.autoloadToolStripMenuItem.Name = "autoloadToolStripMenuItem";
|
||||
this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(191, 22);
|
||||
this.autoloadToolStripMenuItem.Text = "Auto-load";
|
||||
this.autoloadToolStripMenuItem.Click += new System.EventHandler(this.autoloadToolStripMenuItem_Click);
|
||||
this.AutoloadMenuItem.Name = "AutoloadMenuItem";
|
||||
this.AutoloadMenuItem.Size = new System.Drawing.Size(191, 22);
|
||||
this.AutoloadMenuItem.Text = "Auto-load";
|
||||
this.AutoloadMenuItem.Click += new System.EventHandler(this.AutoloadMenuItem_Click);
|
||||
//
|
||||
// saveWindowPositionToolStripMenuItem
|
||||
// SaveWindowPositionMenuItem
|
||||
//
|
||||
this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem";
|
||||
this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(191, 22);
|
||||
this.saveWindowPositionToolStripMenuItem.Text = "Save Window Position";
|
||||
this.saveWindowPositionToolStripMenuItem.Click += new System.EventHandler(this.saveWindowPositionToolStripMenuItem_Click);
|
||||
this.SaveWindowPositionMenuItem.Name = "SaveWindowPositionMenuItem";
|
||||
this.SaveWindowPositionMenuItem.Size = new System.Drawing.Size(191, 22);
|
||||
this.SaveWindowPositionMenuItem.Text = "Save Window Position";
|
||||
this.SaveWindowPositionMenuItem.Click += new System.EventHandler(this.SaveWindowPositionMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(188, 6);
|
||||
//
|
||||
// exitToolStripMenuItem
|
||||
// ExitMenuItem
|
||||
//
|
||||
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
|
||||
this.exitToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4)));
|
||||
this.exitToolStripMenuItem.Size = new System.Drawing.Size(191, 22);
|
||||
this.exitToolStripMenuItem.Text = "E&xit";
|
||||
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
||||
this.ExitMenuItem.Name = "ExitMenuItem";
|
||||
this.ExitMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4)));
|
||||
this.ExitMenuItem.Size = new System.Drawing.Size(191, 22);
|
||||
this.ExitMenuItem.Text = "E&xit";
|
||||
this.ExitMenuItem.Click += new System.EventHandler(this.ExitMenuItem_Click);
|
||||
//
|
||||
// NESGameGenie
|
||||
//
|
||||
|
@ -481,9 +487,9 @@
|
|||
this.Controls.Add(this.ButtonPanel);
|
||||
this.Controls.Add(this.AddCheat);
|
||||
this.Controls.Add(this.GameGenieCodeBox);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.Controls.Add(this.MenuStrip);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.MainMenuStrip = this.MenuStrip;
|
||||
this.MaximizeBox = false;
|
||||
this.MaximumSize = new System.Drawing.Size(312, 302);
|
||||
this.MinimumSize = new System.Drawing.Size(312, 295);
|
||||
|
@ -496,8 +502,8 @@
|
|||
this.ButtonPanel.ResumeLayout(false);
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.MenuStrip.ResumeLayout(false);
|
||||
this.MenuStrip.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
@ -537,11 +543,11 @@
|
|||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Button ClearButton;
|
||||
private MenuStripEx menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem;
|
||||
private MenuStripEx MenuStrip;
|
||||
private System.Windows.Forms.ToolStripMenuItem OptionsSubMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem AutoloadMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem SaveWindowPositionMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem ExitMenuItem;
|
||||
}
|
||||
}
|
|
@ -14,7 +14,25 @@ namespace BizHawk.MultiClient
|
|||
private int? _address = null;
|
||||
private int? _value = null;
|
||||
private int? _compare = null;
|
||||
private readonly Dictionary<char, int> GameGenieTable = new Dictionary<char, int>();
|
||||
private readonly Dictionary<char, int> GameGenieTable = new Dictionary<char, int>
|
||||
{
|
||||
{ 'A', 0 }, //0000
|
||||
{ 'P', 1 }, //0001
|
||||
{ 'Z', 2 }, //0010
|
||||
{ 'L', 3 }, //0011
|
||||
{ 'G', 4 }, //0100
|
||||
{ 'I', 5 }, //0101
|
||||
{ 'T', 6 }, //0110
|
||||
{ 'Y', 7 }, //0111
|
||||
{ 'E', 8 }, //1000
|
||||
{ 'O', 9 }, //1001
|
||||
{ 'X', 10}, //1010
|
||||
{ 'U', 11}, //1011
|
||||
{ 'K', 12}, //1100
|
||||
{ 'S', 13}, //1101
|
||||
{ 'V', 14}, //1110
|
||||
{ 'N', 15}, //1111
|
||||
};
|
||||
|
||||
public int? Address { get { return _address; } }
|
||||
public int? Value { get { return _value; } }
|
||||
|
@ -23,24 +41,14 @@ namespace BizHawk.MultiClient
|
|||
public NESGameGenie()
|
||||
{
|
||||
InitializeComponent();
|
||||
Closing += (o, e) => SaveConfigSettings();
|
||||
|
||||
GameGenieTable.Add('A', 0); //0000
|
||||
GameGenieTable.Add('P', 1); //0001
|
||||
GameGenieTable.Add('Z', 2); //0010
|
||||
GameGenieTable.Add('L', 3); //0011
|
||||
GameGenieTable.Add('G', 4); //0100
|
||||
GameGenieTable.Add('I', 5); //0101
|
||||
GameGenieTable.Add('T', 6); //0110
|
||||
GameGenieTable.Add('Y', 7); //0111
|
||||
GameGenieTable.Add('E', 8); //1000
|
||||
GameGenieTable.Add('O', 9); //1001
|
||||
GameGenieTable.Add('X', 10); //1010
|
||||
GameGenieTable.Add('U', 11); //1011
|
||||
GameGenieTable.Add('K', 12); //1100
|
||||
GameGenieTable.Add('S', 13); //1101
|
||||
GameGenieTable.Add('V', 14); //1110
|
||||
GameGenieTable.Add('N', 15); //1111
|
||||
Closing += (o, e) =>
|
||||
{
|
||||
Global.Config.NESGGWndx = Location.X;
|
||||
Global.Config.NESGGWndy = Location.Y;
|
||||
};
|
||||
AddressBox.SetHexProperties(0x10000);
|
||||
ValueBox.SetHexProperties(0x100);
|
||||
CompareBox.SetHexProperties(0x100);
|
||||
}
|
||||
|
||||
private void NESGameGenie_Load(object sender, EventArgs e)
|
||||
|
@ -53,31 +61,6 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
}
|
||||
|
||||
private void SaveConfigSettings()
|
||||
{
|
||||
Global.Config.NESGGWndx = Location.X;
|
||||
Global.Config.NESGGWndy = Location.Y;
|
||||
}
|
||||
|
||||
private void GameGenieCode_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
//Make uppercase
|
||||
if (e.KeyChar >= 97 && e.KeyChar < 123)
|
||||
e.KeyChar -= (char)32;
|
||||
|
||||
if (!(GameGenieTable.ContainsKey(e.KeyChar)))
|
||||
{
|
||||
if (e.KeyChar != (char)Keys.Back || e.KeyChar == '\b' || e.KeyChar == 22 || e.KeyChar == 1 || e.KeyChar == 3)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Encoding.Checked = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void DecodeGameGenieCode(string code)
|
||||
{
|
||||
//char 3 bit 3 denotes the code length.
|
||||
|
@ -201,15 +184,164 @@ namespace BizHawk.MultiClient
|
|||
AddCheat.Enabled = false;
|
||||
}
|
||||
|
||||
private void GameGenieCode_TextChanged(object sender, EventArgs e)
|
||||
private void TryEnableAddCheat()
|
||||
{
|
||||
if (Encoding.Checked == false)
|
||||
AddCheat.Enabled = !String.IsNullOrWhiteSpace(AddressBox.Text)
|
||||
&& !String.IsNullOrWhiteSpace(ValueBox.Text)
|
||||
&& !String.IsNullOrWhiteSpace(GameGenieCode.Text);
|
||||
}
|
||||
|
||||
private void EncodeGameGenie()
|
||||
{
|
||||
_address = AddressBox.ToRawInt();
|
||||
_value = ValueBox.ToRawInt();
|
||||
_compare = CompareBox.ToRawInt();
|
||||
|
||||
char[] letters = { 'A', 'P', 'Z', 'L', 'G', 'I', 'T', 'Y', 'E', 'O', 'X', 'U', 'K', 'S', 'V', 'N' };
|
||||
if (_address >= 0x8000)
|
||||
_address -= 0x8000;
|
||||
GameGenieCode.Text = String.Empty;
|
||||
byte[] num = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
num[0] = (byte)((_value & 7) + ((_value >> 4) & 8));
|
||||
num[1] = (byte)(((_value >> 4) & 7) + ((_address >> 4) & 8));
|
||||
num[2] = (byte)(((_address >> 4) & 7));
|
||||
num[3] = (byte)((_address >> 12) + (_address & 8));
|
||||
num[4] = (byte)((_address & 7) + ((_address >> 8) & 8));
|
||||
num[5] = (byte)(((_address >> 8) & 7));
|
||||
|
||||
if (_compare < 0 || CompareBox.Text.Length == 0)
|
||||
{
|
||||
if (GameGenieCode.Text.Length == 6 || GameGenieCode.Text.Length == 8)
|
||||
DecodeGameGenieCode(GameGenieCode.Text);
|
||||
else
|
||||
ClearProperties();
|
||||
num[5] += (byte)(_value & 8);
|
||||
for (int x = 0; x < 6; x++)
|
||||
GameGenieCode.Text += letters[num[x]];
|
||||
}
|
||||
else
|
||||
{
|
||||
num[2] += 8;
|
||||
num[5] += (byte)(_compare & 8);
|
||||
num[6] = (byte)((_compare & 7) + ((_compare >> 4) & 8));
|
||||
num[7] = (byte)(((_compare >> 4) & 7) + (_value & 8));
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
GameGenieCode.Text += letters[num[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddCheatClick()
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(AddressBox.Text) && !String.IsNullOrWhiteSpace(ValueBox.Text))
|
||||
{
|
||||
Watch watch = Watch.GenerateWatch(
|
||||
Global.Emulator.MemoryDomains[1], /*System Bus*/
|
||||
AddressBox.ToRawInt(),
|
||||
Watch.WatchSize.Byte,
|
||||
Watch.DisplayType.Hex,
|
||||
GameGenieCode.Text,
|
||||
false);
|
||||
|
||||
int? compare = null;
|
||||
if (!String.IsNullOrWhiteSpace(CompareBox.Text))
|
||||
{
|
||||
compare = CompareBox.ToRawInt();
|
||||
}
|
||||
|
||||
Global.CheatList.Add(new Cheat(
|
||||
watch,
|
||||
ValueBox.ToRawInt(),
|
||||
compare,
|
||||
enabled: true));
|
||||
|
||||
GlobalWinF.MainForm.Cheats_UpdateValues();
|
||||
}
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
#region File Menu
|
||||
|
||||
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
AutoloadMenuItem.Checked = Global.Config.NESGGAutoload;
|
||||
SaveWindowPositionMenuItem.Checked = Global.Config.NESGGSaveWindowPosition;
|
||||
}
|
||||
|
||||
private void AutoloadMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.NESGGAutoload ^= true;
|
||||
}
|
||||
|
||||
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.NESGGSaveWindowPosition ^= true;
|
||||
}
|
||||
|
||||
private void ExitMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Control Events
|
||||
|
||||
private void GameGenieCode_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
//Make uppercase
|
||||
if (e.KeyChar >= 97 && e.KeyChar < 123)
|
||||
e.KeyChar -= (char)32;
|
||||
|
||||
if (!(GameGenieTable.ContainsKey(e.KeyChar)))
|
||||
{
|
||||
if (e.KeyChar != (char)Keys.Back || e.KeyChar == '\b' || e.KeyChar == 22 || e.KeyChar == 1 || e.KeyChar == 3)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Encoding.Checked = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
ClearProperties();
|
||||
GameGenieCode.Text = String.Empty;
|
||||
Encoding.Checked = false;
|
||||
}
|
||||
|
||||
private void AddCheat_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddCheatClick();
|
||||
}
|
||||
|
||||
private void GameGenieCode_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyData == Keys.Enter)
|
||||
{
|
||||
if (AddCheat.Enabled)
|
||||
{
|
||||
AddCheatClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ValueBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Encoding.Checked && !String.IsNullOrWhiteSpace(ValueBox.Text))
|
||||
{
|
||||
int val = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
|
||||
if (val > 0 && val < 0x100)
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(AddressBox.Text))
|
||||
{
|
||||
_value = val;
|
||||
EncodeGameGenie();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TryEnableAddCheat();
|
||||
}
|
||||
|
||||
|
@ -217,7 +349,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
if (GameGenieCode.Text.Length < 8)
|
||||
{
|
||||
string code = "";
|
||||
string code = String.Empty;
|
||||
if (sender == A) code = "A";
|
||||
if (sender == P) code += "P";
|
||||
if (sender == Z) code += "Z";
|
||||
|
@ -246,10 +378,9 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
if (Encoding.Checked && AddressBox.Text.Length > 0)
|
||||
{
|
||||
int a = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
|
||||
if (ValueBox.Text.Length > 0)
|
||||
int _address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
|
||||
if (!String.IsNullOrEmpty(ValueBox.Text))
|
||||
{
|
||||
_address = a;
|
||||
EncodeGameGenie();
|
||||
}
|
||||
}
|
||||
|
@ -281,139 +412,24 @@ namespace BizHawk.MultiClient
|
|||
TryEnableAddCheat();
|
||||
}
|
||||
|
||||
private void TryEnableAddCheat()
|
||||
private void GameGenieCode_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (AddressBox.Text.Length > 0 && ValueBox.Text.Length > 0 && GameGenieCode.Text.Length > 0)
|
||||
AddCheat.Enabled = true;
|
||||
else
|
||||
AddCheat.Enabled = false;
|
||||
}
|
||||
|
||||
private void ValueBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Encoding.Checked && ValueBox.Text.Length > 0)
|
||||
if (Encoding.Checked == false)
|
||||
{
|
||||
int v = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
|
||||
if (v > 0 && v < 0x100)
|
||||
if (GameGenieCode.Text.Length == 6 || GameGenieCode.Text.Length == 8)
|
||||
{
|
||||
if (AddressBox.Text.Length > 0)
|
||||
{
|
||||
_value = v;
|
||||
EncodeGameGenie();
|
||||
}
|
||||
DecodeGameGenieCode(GameGenieCode.Text);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearProperties();
|
||||
}
|
||||
}
|
||||
|
||||
TryEnableAddCheat();
|
||||
}
|
||||
|
||||
private void EncodeGameGenie()
|
||||
{
|
||||
char[] letters = { 'A', 'P', 'Z', 'L', 'G', 'I', 'T', 'Y', 'E', 'O', 'X', 'U', 'K', 'S', 'V', 'N' };
|
||||
if (_address >= 0x8000)
|
||||
_address -= 0x8000;
|
||||
GameGenieCode.Text = "";
|
||||
byte[] num = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
num[0] = (byte)((_value & 7) + ((_value >> 4) & 8));
|
||||
num[1] = (byte)(((_value >> 4) & 7) + ((_address >> 4) & 8));
|
||||
num[2] = (byte)(((_address >> 4) & 7));
|
||||
num[3] = (byte)((_address >> 12) + (_address & 8));
|
||||
num[4] = (byte)((_address & 7) + ((_address >> 8) & 8));
|
||||
num[5] = (byte)(((_address >> 8) & 7));
|
||||
#endregion
|
||||
|
||||
if (_compare < 0 || CompareBox.Text.Length == 0)
|
||||
{
|
||||
num[5] += (byte)(_value & 8);
|
||||
for (int x = 0; x < 6; x++)
|
||||
GameGenieCode.Text += letters[num[x]];
|
||||
}
|
||||
else
|
||||
{
|
||||
num[2] += 8;
|
||||
num[5] += (byte)(_compare & 8);
|
||||
num[6] = (byte)((_compare & 7) + ((_compare >> 4) & 8));
|
||||
num[7] = (byte)(((_compare >> 4) & 7) + (_value & 8));
|
||||
for (int x = 0; x < 8; x++)
|
||||
GameGenieCode.Text += letters[num[x]];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ClearButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
ClearProperties();
|
||||
GameGenieCode.Text = "";
|
||||
Encoding.Checked = false;
|
||||
}
|
||||
|
||||
private void AddCheat_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddCheatClick();
|
||||
}
|
||||
|
||||
private void AddCheatClick()
|
||||
{
|
||||
if (Global.Emulator is NES)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(AddressBox.Text) || (String.IsNullOrWhiteSpace(ValueBox.Text)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Watch watch = Watch.GenerateWatch(
|
||||
Global.Emulator.MemoryDomains[1], /*System Bus*/
|
||||
AddressBox.ToRawInt(),
|
||||
Watch.WatchSize.Byte,
|
||||
Watch.DisplayType.Hex,
|
||||
GameGenieCode.Text,
|
||||
false);
|
||||
|
||||
int? compare = null;
|
||||
if (!String.IsNullOrWhiteSpace(CompareBox.Text))
|
||||
{
|
||||
compare = CompareBox.ToRawInt();
|
||||
}
|
||||
|
||||
Global.CheatList.Add(new Cheat(
|
||||
watch,
|
||||
ValueBox.ToRawInt(),
|
||||
compare,
|
||||
enabled: true));
|
||||
|
||||
GlobalWinF.MainForm.Cheats_UpdateValues();
|
||||
}
|
||||
}
|
||||
|
||||
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void saveWindowPositionToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.NESGGSaveWindowPosition ^= true;
|
||||
}
|
||||
|
||||
private void autoloadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Config.NESGGAutoload ^= true;
|
||||
}
|
||||
|
||||
private void optionsToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
autoloadToolStripMenuItem.Checked = Global.Config.NESGGAutoload;
|
||||
saveWindowPositionToolStripMenuItem.Checked = Global.Config.NESGGSaveWindowPosition;
|
||||
}
|
||||
|
||||
private void GameGenieCode_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyData == Keys.Enter)
|
||||
{
|
||||
if (AddCheat.Enabled)
|
||||
{
|
||||
AddCheatClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@
|
|||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<metadata name="MenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
Loading…
Reference in New Issue