diff --git a/BizHawk.MultiClient/BizHawk.MultiClient.csproj b/BizHawk.MultiClient/BizHawk.MultiClient.csproj
index 50c31db862..18ccad0702 100644
--- a/BizHawk.MultiClient/BizHawk.MultiClient.csproj
+++ b/BizHawk.MultiClient/BizHawk.MultiClient.csproj
@@ -370,6 +370,12 @@
Component
+
+ Form
+
+
+ GenGameGenie.cs
+
Component
@@ -568,6 +574,9 @@
NESSoundConfig.cs
+
+ GenGameGenie.cs
+
PCEBGViewer.cs
diff --git a/BizHawk.MultiClient/Config.cs b/BizHawk.MultiClient/Config.cs
index 8693b22e4e..d90d5a3996 100644
--- a/BizHawk.MultiClient/Config.cs
+++ b/BizHawk.MultiClient/Config.cs
@@ -586,6 +586,12 @@ namespace BizHawk.MultiClient
public int GBGGWndx = -1;
public int GBGGWndy = -1;
+ // GEN Game Genie Encoder/Decoder
+ public bool GENGGAutoload = false;
+ public bool GENGGSaveWindowPosition = true;
+ public int GENGGWndx = -1;
+ public int GENGGWndy = -1;
+
//Movie Settings
public RecentFiles RecentMovies = new RecentFiles(8);
public bool AutoLoadMostRecentMovie = false;
diff --git a/BizHawk.MultiClient/GBtools/GBGameGenie.Designer.cs b/BizHawk.MultiClient/GBtools/GBGameGenie.Designer.cs
index 3060c12bd0..10851c1049 100644
--- a/BizHawk.MultiClient/GBtools/GBGameGenie.Designer.cs
+++ b/BizHawk.MultiClient/GBtools/GBGameGenie.Designer.cs
@@ -28,15 +28,13 @@
///
private void InitializeComponent()
{
- this.GameGenieCode = new System.Windows.Forms.TextBox();
this.GameGenieCodeBox = new System.Windows.Forms.GroupBox();
+ this.GGCodeMaskBox = new System.Windows.Forms.MaskedTextBox();
this.label3 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
- this.CompareBox = new BizHawk.HexTextBox();
this.ValueBox = new BizHawk.HexTextBox();
this.AddressBox = new BizHawk.HexTextBox();
- this.AddCheat = new System.Windows.Forms.Button();
+ this.addcheatbt = new System.Windows.Forms.Button();
this.ButtonPanel = new System.Windows.Forms.Panel();
this.BF = new System.Windows.Forms.Button();
this.BD = new System.Windows.Forms.Button();
@@ -56,7 +54,6 @@
this.B0 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label6 = new System.Windows.Forms.Label();
- this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.ClearButton = new System.Windows.Forms.Button();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
@@ -65,83 +62,66 @@
this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.cheatname = new System.Windows.Forms.TextBox();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label5 = new System.Windows.Forms.Label();
+ this.CompareBox = new BizHawk.HexTextBox();
this.GameGenieCodeBox.SuspendLayout();
this.ButtonPanel.SuspendLayout();
this.groupBox1.SuspendLayout();
this.menuStrip1.SuspendLayout();
+ this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
- // GameGenieCode
- //
- this.GameGenieCode.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
- this.GameGenieCode.Location = new System.Drawing.Point(8, 23);
- this.GameGenieCode.Margin = new System.Windows.Forms.Padding(4);
- this.GameGenieCode.MaxLength = 9;
- this.GameGenieCode.Name = "GameGenieCode";
- this.GameGenieCode.Size = new System.Drawing.Size(113, 22);
- this.GameGenieCode.TabIndex = 20;
- this.GameGenieCode.TextChanged += new System.EventHandler(this.GameGenieCode_TextChanged);
- this.GameGenieCode.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GameGenieCode_KeyDown);
- this.GameGenieCode.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.GameGenieCode_KeyPress);
- //
// GameGenieCodeBox
//
- this.GameGenieCodeBox.Controls.Add(this.GameGenieCode);
+ this.GameGenieCodeBox.Controls.Add(this.GGCodeMaskBox);
this.GameGenieCodeBox.Location = new System.Drawing.Point(41, 127);
this.GameGenieCodeBox.Margin = new System.Windows.Forms.Padding(4);
this.GameGenieCodeBox.Name = "GameGenieCodeBox";
this.GameGenieCodeBox.Padding = new System.Windows.Forms.Padding(4);
- this.GameGenieCodeBox.Size = new System.Drawing.Size(153, 66);
+ this.GameGenieCodeBox.Size = new System.Drawing.Size(158, 66);
this.GameGenieCodeBox.TabIndex = 1;
this.GameGenieCodeBox.TabStop = false;
this.GameGenieCodeBox.Text = "Game Genie Code";
//
+ // GGCodeMaskBox
+ //
+ this.GGCodeMaskBox.Location = new System.Drawing.Point(33, 32);
+ this.GGCodeMaskBox.Mask = ">AAA-AAA-AAA";
+ this.GGCodeMaskBox.Name = "GGCodeMaskBox";
+ this.GGCodeMaskBox.Size = new System.Drawing.Size(99, 22);
+ this.GGCodeMaskBox.TabIndex = 10;
+ this.GGCodeMaskBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
+ this.GGCodeMaskBox.TextMaskFormat = System.Windows.Forms.MaskFormat.ExcludePromptAndLiterals;
+ this.GGCodeMaskBox.TextChanged += new System.EventHandler(this.GGCodeMaskBox_TextChanged);
+ this.GGCodeMaskBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.GGCodeMaskBox_KeyPress);
+ //
// label3
//
this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(11, 84);
+ this.label3.Location = new System.Drawing.Point(11, 80);
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(44, 17);
this.label3.TabIndex = 5;
this.label3.Text = "Value";
//
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(11, 52);
- this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(65, 17);
- this.label2.TabIndex = 4;
- this.label2.Text = "Compare";
- //
// label1
//
this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(11, 20);
+ this.label1.Location = new System.Drawing.Point(11, 24);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(60, 17);
this.label1.TabIndex = 3;
this.label1.Text = "Address";
//
- // CompareBox
- //
- this.CompareBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
- this.CompareBox.Location = new System.Drawing.Point(116, 48);
- this.CompareBox.Margin = new System.Windows.Forms.Padding(4);
- this.CompareBox.MaxLength = 2;
- this.CompareBox.Name = "CompareBox";
- this.CompareBox.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
- this.CompareBox.Size = new System.Drawing.Size(35, 22);
- this.CompareBox.TabIndex = 22;
- this.CompareBox.TextChanged += new System.EventHandler(this.CompareBox_TextChanged);
- //
// ValueBox
//
this.ValueBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
- this.ValueBox.Location = new System.Drawing.Point(116, 80);
+ this.ValueBox.Location = new System.Drawing.Point(140, 75);
this.ValueBox.Margin = new System.Windows.Forms.Padding(4);
this.ValueBox.MaxLength = 2;
this.ValueBox.Name = "ValueBox";
@@ -153,26 +133,27 @@
// AddressBox
//
this.AddressBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
- this.AddressBox.Location = new System.Drawing.Point(100, 16);
+ this.AddressBox.Location = new System.Drawing.Point(117, 20);
this.AddressBox.Margin = new System.Windows.Forms.Padding(4);
this.AddressBox.MaxLength = 4;
this.AddressBox.Name = "AddressBox";
this.AddressBox.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
- this.AddressBox.Size = new System.Drawing.Size(51, 22);
+ this.AddressBox.Size = new System.Drawing.Size(58, 22);
this.AddressBox.TabIndex = 21;
this.AddressBox.TextChanged += new System.EventHandler(this.AddressBox_TextChanged);
//
- // AddCheat
+ // addcheatbt
//
- this.AddCheat.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.AddCheat.Location = new System.Drawing.Point(269, 276);
- this.AddCheat.Margin = new System.Windows.Forms.Padding(4);
- this.AddCheat.Name = "AddCheat";
- this.AddCheat.Size = new System.Drawing.Size(92, 26);
- this.AddCheat.TabIndex = 33;
- this.AddCheat.Text = "&Add Cheat";
- this.AddCheat.UseVisualStyleBackColor = true;
- this.AddCheat.Click += new System.EventHandler(this.AddCheat_Click);
+ this.addcheatbt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.addcheatbt.Enabled = false;
+ this.addcheatbt.Location = new System.Drawing.Point(117, 201);
+ this.addcheatbt.Margin = new System.Windows.Forms.Padding(4);
+ this.addcheatbt.Name = "addcheatbt";
+ this.addcheatbt.Size = new System.Drawing.Size(82, 32);
+ this.addcheatbt.TabIndex = 33;
+ this.addcheatbt.Text = "&Add Cheat";
+ this.addcheatbt.UseVisualStyleBackColor = true;
+ this.addcheatbt.Click += new System.EventHandler(this.AddCheatClick);
//
// ButtonPanel
//
@@ -193,7 +174,7 @@
this.ButtonPanel.Controls.Add(this.B4);
this.ButtonPanel.Controls.Add(this.B2);
this.ButtonPanel.Controls.Add(this.B0);
- this.ButtonPanel.Location = new System.Drawing.Point(41, 37);
+ this.ButtonPanel.Location = new System.Drawing.Point(47, 37);
this.ButtonPanel.Margin = new System.Windows.Forms.Padding(4);
this.ButtonPanel.Name = "ButtonPanel";
this.ButtonPanel.Size = new System.Drawing.Size(319, 82);
@@ -378,47 +359,38 @@
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.groupBox1.Controls.Add(this.label6);
+ this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label5);
+ this.groupBox1.Controls.Add(this.CompareBox);
+ this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label1);
- this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.AddressBox);
this.groupBox1.Controls.Add(this.ValueBox);
- this.groupBox1.Controls.Add(this.CompareBox);
- this.groupBox1.Location = new System.Drawing.Point(41, 201);
+ this.groupBox1.Location = new System.Drawing.Point(207, 127);
this.groupBox1.Margin = new System.Windows.Forms.Padding(4);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(4);
- this.groupBox1.Size = new System.Drawing.Size(168, 114);
+ this.groupBox1.Size = new System.Drawing.Size(183, 101);
this.groupBox1.TabIndex = 5;
this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Decoded Value";
//
// label6
//
this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(92, 85);
+ this.label6.Location = new System.Drawing.Point(116, 80);
this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(22, 17);
this.label6.TabIndex = 9;
this.label6.Text = "0x";
//
- // label5
- //
- this.label5.AutoSize = true;
- this.label5.Location = new System.Drawing.Point(92, 52);
- this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(22, 17);
- this.label5.TabIndex = 8;
- this.label5.Text = "0x";
- //
// label4
//
this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(76, 20);
+ this.label4.Location = new System.Drawing.Point(76, 24);
this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(22, 17);
@@ -428,10 +400,9 @@
// ClearButton
//
this.ClearButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.ClearButton.Location = new System.Drawing.Point(288, 201);
- this.ClearButton.Margin = new System.Windows.Forms.Padding(4);
+ this.ClearButton.Location = new System.Drawing.Point(41, 201);
this.ClearButton.Name = "ClearButton";
- this.ClearButton.Size = new System.Drawing.Size(72, 28);
+ this.ClearButton.Size = new System.Drawing.Size(72, 32);
this.ClearButton.TabIndex = 32;
this.ClearButton.Text = "&Clear";
this.ClearButton.UseVisualStyleBackColor = true;
@@ -487,15 +458,65 @@
this.exitToolStripMenuItem.Text = "E&xit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
+ // groupBox2
+ //
+ this.groupBox2.Controls.Add(this.cheatname);
+ this.groupBox2.Location = new System.Drawing.Point(41, 242);
+ this.groupBox2.Name = "groupBox2";
+ this.groupBox2.Size = new System.Drawing.Size(349, 61);
+ this.groupBox2.TabIndex = 24;
+ this.groupBox2.TabStop = false;
+ this.groupBox2.Text = "Cheat Title (Uses GG code if left empty)";
+ //
+ // cheatname
+ //
+ this.cheatname.Location = new System.Drawing.Point(24, 28);
+ this.cheatname.Name = "cheatname";
+ this.cheatname.Size = new System.Drawing.Size(301, 22);
+ this.cheatname.TabIndex = 0;
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(116, 52);
+ this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(22, 17);
+ this.label2.TabIndex = 25;
+ this.label2.Text = "0x";
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Location = new System.Drawing.Point(11, 52);
+ this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(65, 17);
+ this.label5.TabIndex = 24;
+ this.label5.Text = "Compare";
+ //
+ // CompareBox
+ //
+ this.CompareBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
+ this.CompareBox.Location = new System.Drawing.Point(140, 47);
+ this.CompareBox.Margin = new System.Windows.Forms.Padding(4);
+ this.CompareBox.MaxLength = 2;
+ this.CompareBox.Name = "CompareBox";
+ this.CompareBox.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
+ this.CompareBox.Size = new System.Drawing.Size(35, 22);
+ this.CompareBox.TabIndex = 26;
+ this.CompareBox.TextChanged += new System.EventHandler(this.CompareBox_TextChanged);
+ //
// GBGameGenie
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(403, 315);
+ this.Controls.Add(this.groupBox2);
this.Controls.Add(this.ClearButton);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.ButtonPanel);
- this.Controls.Add(this.AddCheat);
+ this.Controls.Add(this.addcheatbt);
this.Controls.Add(this.GameGenieCodeBox);
this.Controls.Add(this.menuStrip1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
@@ -507,7 +528,6 @@
this.Name = "GBGameGenie";
this.ShowIcon = false;
this.Text = "Game Genie Encoder / Decoder";
- this.Load += new System.EventHandler(this.GBGameGenie_Load);
this.GameGenieCodeBox.ResumeLayout(false);
this.GameGenieCodeBox.PerformLayout();
this.ButtonPanel.ResumeLayout(false);
@@ -515,6 +535,8 @@
this.groupBox1.PerformLayout();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
+ this.groupBox2.ResumeLayout(false);
+ this.groupBox2.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@@ -522,15 +544,12 @@
#endregion
- private System.Windows.Forms.TextBox GameGenieCode;
- private System.Windows.Forms.GroupBox GameGenieCodeBox;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Label label1;
- private HexTextBox CompareBox;
+ private System.Windows.Forms.GroupBox GameGenieCodeBox;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label1;
private HexTextBox ValueBox;
private HexTextBox AddressBox;
- private System.Windows.Forms.Button AddCheat;
+ private System.Windows.Forms.Button addcheatbt;
private System.Windows.Forms.Panel ButtonPanel;
private System.Windows.Forms.Button B6;
private System.Windows.Forms.Button B4;
@@ -549,8 +568,7 @@
private System.Windows.Forms.Button B3;
private System.Windows.Forms.Button B1;
private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button ClearButton;
private System.Windows.Forms.MenuStrip menuStrip1;
@@ -558,6 +576,12 @@
private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
- private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
+ private System.Windows.Forms.MaskedTextBox GGCodeMaskBox;
+ private System.Windows.Forms.GroupBox groupBox2;
+ private System.Windows.Forms.TextBox cheatname;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label label5;
+ private HexTextBox CompareBox;
}
}
\ No newline at end of file
diff --git a/BizHawk.MultiClient/GBtools/GBGameGenie.cs b/BizHawk.MultiClient/GBtools/GBGameGenie.cs
index cb100e34af..b91d538723 100644
--- a/BizHawk.MultiClient/GBtools/GBGameGenie.cs
+++ b/BizHawk.MultiClient/GBtools/GBGameGenie.cs
@@ -3,19 +3,16 @@ using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Globalization;
+using System.Text.RegularExpressions;
namespace BizHawk.MultiClient
{
public partial class GBGameGenie : Form
{
- public int Address = -1;
- public int Value = -1;
- public int Compare = -1;
private readonly Dictionary GameGenieTable = new Dictionary();
- private bool Decoding = false;
- private bool Encoding = false;
+ private bool Processing = false;
- public GBGameGenie()
+ public GBGameGenie()
{
InitializeComponent();
Closing += (o, e) => SaveConfigSettings();
@@ -38,84 +35,53 @@ namespace BizHawk.MultiClient
GameGenieTable.Add('F', 15); //1111
}
- private void GBGameGenie_Load(object sender, EventArgs e)
+ public void GBGGDecode(string code, ref int val, ref int add, ref int cmp)
{
- AddCheat.Enabled = false;
- if (Global.Config.GBGGSaveWindowPosition && Global.Config.GBGGWndx >= 0 && Global.Config.GBGGWndy >= 0)
- Location = new Point(Global.Config.GBGGWndx, Global.Config.GBGGWndy);
- }
-
- private void SaveConfigSettings()
- {
- Global.Config.GBGGWndx = Location.X;
- Global.Config.GBGGWndy = 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;
- }
- }
-
- }
-
- public void GBDecodeGameGenieCode(string code)
- {
//No cypher on value
//Char # | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
//Bit # |3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|
//maps to| Value |A|B|C|D|E|F|G|H|I|J|K|L|XOR 0xF|a|b|c|c|NotUsed|e|f|g|h|
//proper | Value |XOR 0xF|A|B|C|D|E|F|G|H|I|J|K|L|g|h|a|b|Nothing|c|d|e|f|
-
- int x;
- byte[] val = { 0, 0 };
+ int x;
// Getting Value
if (code.Length > 0)
{
GameGenieTable.TryGetValue(code[0], out x);
- Value = x << 4;
+ val = x << 4;
}
if (code.Length > 1)
{
GameGenieTable.TryGetValue(code[1], out x);
- Value |= x;
+ val |= x;
}
//Address
if (code.Length > 2)
{
GameGenieTable.TryGetValue(code[2], out x);
- Address = (x << 8);
+ add = (x << 8);
}
else
- Address = -1;
+ add = -1;
if (code.Length > 3)
{
GameGenieTable.TryGetValue(code[3], out x);
- Address |= (x << 4);
+ add |= (x << 4);
}
if (code.Length > 4)
{
GameGenieTable.TryGetValue(code[4], out x);
- Address |= x;
+ add |= x;
}
if (code.Length > 5)
{
GameGenieTable.TryGetValue(code[5], out x);
- Address |= ((x ^ 0xF) <<12);
+ add |= ((x ^ 0xF) << 12);
}
// compare need to be full
if (code.Length > 8)
@@ -127,188 +93,29 @@ namespace BizHawk.MultiClient
GameGenieTable.TryGetValue(code[8], out x);
comp |= ((x & 0xC) >> 2);
comp |= ((x & 0x3) << 6);
- Compare = comp ^ 0xBA;
+ cmp = comp ^ 0xBA;
}
else
- Compare = -1;
+ cmp = -1;
- SetProperties();
- }
-
- private void SetProperties()
- {
- if (Address >= 0)
- AddressBox.Text = String.Format("{0:X4}", Address);
- else
- AddressBox.Text = "";
-
- if (Compare >= 0)
- CompareBox.Text = String.Format("{0:X2}", Compare);
- else
- CompareBox.Text = "";
-
- if (Value >= 0)
- ValueBox.Text = String.Format("{0:X2}", Value);
-
- }
-
- private void ClearProperties()
- {
- bool tempenc = Encoding;
- bool tempdec = Decoding;
- Encoding = true;
- Decoding = true;
- Address = -1;
- Value = -1;
- Compare = -1;
- AddressBox.Text = "";
- CompareBox.Text = "";
- ValueBox.Text = "";
- AddCheat.Enabled = false;
- Encoding = tempenc;
- Decoding = tempdec;
- }
-
- private void GameGenieCode_TextChanged(object sender, EventArgs e)
- {
-
- if (Encoding == false)
- {
- if (GameGenieCode.Text.Length > 0)
- {
- Decoding = true;
- GBDecodeGameGenieCode(GameGenieCode.Text);
- }
- else
- ClearProperties();
- }
- TryEnableAddCheat();
- Decoding = false;
- }
-
- private void Keypad_Click(object sender, EventArgs e)
- {
- if (GameGenieCode.Text.Length < 9)
- {
- string code = "";
- if (sender == B0) code = "0";
- if (sender == B1) code += "1";
- if (sender == B2) code += "2";
- if (sender == B3) code += "3";
- if (sender == B4) code += "4";
- if (sender == B5) code += "5";
- if (sender == B6) code += "6";
- if (sender == B7) code += "7";
- if (sender == B8) code += "8";
- if (sender == B9) code += "9";
- if (sender == BA) code += "A";
- if (sender == BB) code += "B";
- if (sender == BC) code += "C";
- if (sender == BD) code += "D";
- if (sender == BE) code += "E";
- if (sender == BF) code += "F";
-
- int x = GameGenieCode.SelectionStart;
- GameGenieCode.Text = GameGenieCode.Text.Insert(x, code);
- GameGenieCode.SelectionStart = x + 1;
- }
- }
-
- private void AddressBox_TextChanged(object sender, EventArgs e)
- {
- if (Decoding == false)
- {
- if (AddressBox.Text.Length > 0)
- {
- Address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
- if (ValueBox.Text.Length > 0)
- Value = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
- else
- Value = 0;
- if (CompareBox.Text.Length == 2)
- Compare = int.Parse(CompareBox.Text, NumberStyles.HexNumber);
- else
- Compare = 0;
- Encoding = true;
- GBEncodeGameGenie();
- Encoding = false;
- }
- }
-
- TryEnableAddCheat();
- }
-
- private void CompareBox_TextChanged(object sender, EventArgs e)
- {
- if (Decoding == false)
- {
- if (CompareBox.Text.Length == 2)
- Compare = int.Parse(CompareBox.Text, NumberStyles.HexNumber);
- if (AddressBox.Text.Length > 0)
- Address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
- else
- Address = 0x0000;
- if (ValueBox.Text.Length > 0)
- Value = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
- else
- Value = 0;
- Encoding = true;
- GBEncodeGameGenie();
- Encoding = false;
-
- }
- TryEnableAddCheat();
+ }
-
- }
-
- private void TryEnableAddCheat()
- {
- if (AddressBox.Text.Length == 4 && ValueBox.Text.Length == 2)
- AddCheat.Enabled = true;
- else
- AddCheat.Enabled = false;
- }
-
- private void ValueBox_TextChanged(object sender, EventArgs e)
- {
- if (Decoding == false)
- {
- if (ValueBox.Text.Length > 0)
- {
- if (AddressBox.Text.Length > 0)
- Address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
- else
- Address = 0x0000;
- if (CompareBox.Text.Length == 2)
- Compare = int.Parse(CompareBox.Text, NumberStyles.HexNumber);
- else
- Compare = 0;
- Value = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
- Encoding = true;
- GBEncodeGameGenie();
- Encoding = false;
- }
- }
- TryEnableAddCheat();
- }
-
- private void GBEncodeGameGenie()
+ private string GBGGEncode(int val, int add, int cmp)
{
char[] letters = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
- GameGenieCode.Text = "";
+ string code = "";
int[] num = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- num[0] = (Value & 0xF0) >> 4;
- num[1] = Value & 0x0F;
+ num[0] = (val & 0xF0) >> 4;
+ num[1] = val & 0x0F;
- num[2] = (Address & 0x0F00) >> 8;
- num[3] = (Address & 0x00F0) >> 4;
- num[4] = (Address & 0x000F);
- num[5] = (((Address & 0xF000) >> 12) ^ 0xF);
- if (CompareBox.Text.Length == 2)
+ num[2] = (add & 0x0F00) >> 8;
+ num[3] = (add & 0x00F0) >> 4;
+ num[4] = (add & 0x000F);
+ num[5] = (((add & 0xF000) >> 12) ^ 0xF);
+ if (cmp > -1)
{
-
- int xoredcomp = ((Compare &0xFF) ^ 0xBA);
+
+ int xoredcomp = ((cmp & 0xFF) ^ 0xBA);
num[6] = ((xoredcomp & 0x30) >> 2);
num[6] |= ((xoredcomp & 0x0C) >> 2);
// 8th char has no real use (its value is not reflected in the address:value:compare
@@ -316,45 +123,251 @@ namespace BizHawk.MultiClient
// to get back what the original code had (Might be more to it)
num[7] = num[6] ^ 8;
num[8] = ((xoredcomp & 0xC0) >> 6);
- num[8] |= ((xoredcomp &0x03) << 2);
+ num[8] |= ((xoredcomp & 0x03) << 2);
for (int x = 0; x < 9; x++)
- GameGenieCode.Text += letters[num[x]];
- }
+ code += letters[num[x]];
+ }
else
{
for (int x = 0; x < 6; x++)
- GameGenieCode.Text += letters[num[x]];
+ code += letters[num[x]];
}
+ return code;
+ }
+ private void GBGameGenie_Load(object sender, EventArgs e)
+ {
+ addcheatbt.Enabled = false;
+
+ if (Global.Config.GBGGSaveWindowPosition && Global.Config.GBGGWndx >= 0 && Global.Config.GBGGWndy >= 0)
+ Location = new Point(Global.Config.GBGGWndx, Global.Config.GBGGWndy);
+ }
+
+ private void SaveConfigSettings()
+ {
+ Global.Config.GBGGWndx = Location.X;
+ Global.Config.GBGGWndy = Location.Y;
+ }
+
+ private void GGCodeMaskBox_KeyPress(object sender, KeyPressEventArgs e)
+ {
+ // Find a better way to remove all NON HEX char, while still allowing copy/paste
+ //Right now its all done through removing em GGCodeMaskBox_TextChanged
+ }
+
+ private void GGCodeMaskBox_TextChanged(object sender, EventArgs e)
+ {
+
+ if (Processing == false)
+ {
+ Processing = true;
+ //insert REGEX Remove non HEXA char
+ if (Regex.IsMatch(GGCodeMaskBox.Text, @"[^a-fA-F0-9]"))
+ {
+ string temp = Regex.Replace(GGCodeMaskBox.Text, @"[^a-fA-F0-9]", string.Empty);
+ GGCodeMaskBox.Text = temp;
+ }
+
+ if (GGCodeMaskBox.Text.Length > 0)
+ {
+ int val = -1;
+ int add = -1;
+ int cmp = -1;
+ GBGGDecode(GGCodeMaskBox.Text, ref val, ref add, ref cmp);
+ if (add > -1)
+ AddressBox.Text = String.Format("{0:X4}", add);
+ if (val > -1)
+ ValueBox.Text = String.Format("{0:X2}", val);
+ if (cmp > -1)
+ CompareBox.Text = String.Format("{0:X2}", cmp);
+ else
+ CompareBox.Text = "";
+
+ addcheatbt.Enabled = true;
+ }
+ else
+ {
+ AddressBox.Text = "";
+ ValueBox.Text = "";
+ CompareBox.Text = "";
+ addcheatbt.Enabled = false;
+ }
+ Processing = false;
+ }
+ }
+
+ private void Keypad_Click(object sender, EventArgs e)
+ {
+ if (GGCodeMaskBox.Text.Length < 9)
+ {
+ string code = "";
+ if (sender == B0) code = "0";
+ if (sender == B1) code = "1";
+ if (sender == B2) code = "2";
+ if (sender == B3) code = "3";
+ if (sender == B4) code = "4";
+ if (sender == B5) code = "5";
+ if (sender == B6) code = "6";
+ if (sender == B7) code = "7";
+ if (sender == B8) code = "8";
+ if (sender == B9) code = "9";
+ if (sender == BA) code = "A";
+ if (sender == BB) code = "B";
+ if (sender == BC) code = "C";
+ if (sender == BD) code = "D";
+ if (sender == BE) code = "E";
+ if (sender == BF) code = "F";
+
+ GGCodeMaskBox.Text += code;
+ //int x = GGCodeMaskBox.SelectionStart;
+ //GGCodeMaskBox.Text = GGCodeMaskBox.Text.Insert(x, code);
+ //GGCodeMaskBox.SelectionStart = x + 1;
+ }
+ }
+
+ private void AddressBox_TextChanged(object sender, EventArgs e)
+ {
+ //remove invalid character when pasted
+ if (Processing == false)
+ {
+ Processing = true;
+ if (Regex.IsMatch(AddressBox.Text, @"[^a-fA-F0-9]"))
+ {
+ string temp = Regex.Replace(AddressBox.Text, @"[^a-fA-F0-9]", string.Empty);
+ AddressBox.Text = temp;
+ }
+ if ((AddressBox.Text.Length > 0) || (ValueBox.Text.Length > 0))
+ {
+ int val = 0;
+ int add = 0;
+ int cmp = -1;
+ if (ValueBox.Text.Length > 0)
+ val = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
+ if (AddressBox.Text.Length > 0)
+ add = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
+ if (CompareBox.Text.Length == 2)
+ cmp = int.Parse(CompareBox.Text, NumberStyles.HexNumber);
+
+ GGCodeMaskBox.Text = GBGGEncode(val, add, cmp);
+ addcheatbt.Enabled = true;
+ }
+ else
+ {
+ GGCodeMaskBox.Text = "";
+ addcheatbt.Enabled = false;
+ }
+ Processing = false;
+ }
+
+ }
+ private void ValueBox_TextChanged(object sender, EventArgs e)
+ {
+ if (Processing == false)
+ {
+ Processing = true;
+ //remove invalid character when pasted
+ if (Regex.IsMatch(ValueBox.Text, @"[^a-fA-F0-9]"))
+ {
+ string temp = Regex.Replace(ValueBox.Text, @"[^a-fA-F0-9]", string.Empty);
+ ValueBox.Text = temp;
+ }
+ if ((AddressBox.Text.Length > 0) || (ValueBox.Text.Length > 0))
+ {
+ int val = 0;
+ int add = 0;
+ int cmp = -1;
+ if (ValueBox.Text.Length > 0)
+ val = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
+ if (AddressBox.Text.Length > 0)
+ add = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
+ if (CompareBox.Text.Length == 2)
+ cmp = int.Parse(CompareBox.Text, NumberStyles.HexNumber);
+ GGCodeMaskBox.Text = GBGGEncode(val, add, cmp);
+ addcheatbt.Enabled = true;
+
+ }
+ else
+ {
+ GGCodeMaskBox.Text = "";
+ addcheatbt.Enabled = false;
+ }
+ Processing = false;
+ }
+
+ }
+
+ private void CompareBox_TextChanged(object sender, EventArgs e)
+ {
+ if (Processing == false)
+ {
+ Processing = true;
+ //remove invalid character when pasted
+ if (Regex.IsMatch(CompareBox.Text, @"[^a-fA-F0-9]"))
+ {
+ string temp = Regex.Replace(CompareBox.Text, @"[^a-fA-F0-9]", string.Empty);
+ CompareBox.Text = temp;
+ }
+ if ((CompareBox.Text.Length == 2) || (CompareBox.Text.Length == 0))
+ {
+ if ((AddressBox.Text.Length > 0) || (ValueBox.Text.Length > 0))
+ {
+ int val = 0;
+ int add = 0;
+ int cmp = -1;
+ if (ValueBox.Text.Length > 0)
+ val = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
+ if (AddressBox.Text.Length > 0)
+ add = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
+ if (CompareBox.Text.Length == 2)
+ cmp = int.Parse(CompareBox.Text, NumberStyles.HexNumber);
+ GGCodeMaskBox.Text = GBGGEncode(val, add, cmp);
+ addcheatbt.Enabled = true;
+
+ }
+ else
+ {
+ GGCodeMaskBox.Text = "";
+ addcheatbt.Enabled = false;
+ }
+ }
+ Processing = false;
+ }
}
private void ClearButton_Click(object sender, EventArgs e)
{
- ClearProperties();
- GameGenieCode.Text = "";
-
+ AddressBox.Text = "";
+ ValueBox.Text = "";
+ CompareBox.Text = "";
+ GGCodeMaskBox.Text = "";
+ addcheatbt.Enabled = false;
}
- private void AddCheat_Click(object sender, EventArgs e)
+ private void AddCheatClick(object sender, EventArgs e)
{
- AddCheatClick();
- }
- private void AddCheatClick()
- {
- Cheat c = new Cheat {name = GameGenieCode.Text};
+ Cheat c = new Cheat();
+ if (cheatname.Text.Length > 0)
+ c.name = cheatname.Text;
+ else
+ {
+ Processing = true;
+ GGCodeMaskBox.TextMaskFormat = MaskFormat.IncludeLiterals;
+ c.name = GGCodeMaskBox.Text;
+ GGCodeMaskBox.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
+ Processing = false;
+ }
if (String.IsNullOrWhiteSpace(AddressBox.Text))
- {
- return;
- }
- else if (String.IsNullOrWhiteSpace(ValueBox.Text))
- {
- return;
- }
- c.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
- c.value = byte.Parse(ValueBox.Text, NumberStyles.HexNumber);
+ c.address = 0;
+ else
+ c.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
+
+ if (String.IsNullOrWhiteSpace(ValueBox.Text))
+ c.value = 0;
+ else
+ c.value = (byte)((int.Parse(ValueBox.Text, NumberStyles.HexNumber) & 0xFF00) >> 8);
if (!String.IsNullOrWhiteSpace(CompareBox.Text))
{
@@ -371,15 +384,15 @@ namespace BizHawk.MultiClient
{
c.compare = null;
}
- c.Enable();
for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
+
if (Global.Emulator.MemoryDomains[x].ToString() == "System Bus")
{
- c.domain = Global.Emulator.MemoryDomains[x]; //Bus
+ c.domain = Global.Emulator.MemoryDomains[x];
+ c.Enable();
Global.MainForm.Cheats1.AddCheat(c);
break;
}
-
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
@@ -403,15 +416,6 @@ namespace BizHawk.MultiClient
saveWindowPositionToolStripMenuItem.Checked = Global.Config.GBGGSaveWindowPosition;
}
- private void GameGenieCode_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyData == Keys.Enter)
- {
- if (AddCheat.Enabled)
- {
- AddCheatClick();
- }
- }
- }
+
}
}
diff --git a/BizHawk.MultiClient/GENtools/GenGameGenie.Designer.cs b/BizHawk.MultiClient/GENtools/GenGameGenie.Designer.cs
new file mode 100644
index 0000000000..471fa639b3
--- /dev/null
+++ b/BizHawk.MultiClient/GENtools/GenGameGenie.Designer.cs
@@ -0,0 +1,304 @@
+namespace BizHawk.MultiClient
+{
+ partial class GenGameGenie
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.menuStrip1 = new System.Windows.Forms.MenuStrip();
+ this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
+ this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.GGCodeMaskBox = new System.Windows.Forms.MaskedTextBox();
+ this.addcheatbt = new System.Windows.Forms.Button();
+ this.GameGenieCodeBox = new System.Windows.Forms.GroupBox();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.ValueBox = new BizHawk.HexTextBox();
+ this.AddressBox = new BizHawk.HexTextBox();
+ this.label6 = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label1 = new System.Windows.Forms.Label();
+ this.ClearBT = new System.Windows.Forms.Button();
+ this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.cheatname = new System.Windows.Forms.TextBox();
+ this.menuStrip1.SuspendLayout();
+ this.GameGenieCodeBox.SuspendLayout();
+ this.groupBox1.SuspendLayout();
+ this.groupBox2.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // menuStrip1
+ //
+ 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.Padding = new System.Windows.Forms.Padding(8, 2, 0, 2);
+ this.menuStrip1.Size = new System.Drawing.Size(403, 28);
+ this.menuStrip1.TabIndex = 8;
+ this.menuStrip1.Text = "menuStrip1";
+ //
+ // optionsToolStripMenuItem
+ //
+ this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.autoloadToolStripMenuItem,
+ this.saveWindowPositionToolStripMenuItem,
+ this.toolStripSeparator1,
+ this.exitToolStripMenuItem});
+ this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
+ this.optionsToolStripMenuItem.Size = new System.Drawing.Size(73, 24);
+ this.optionsToolStripMenuItem.Text = "&Options";
+ //
+ // autoloadToolStripMenuItem
+ //
+ this.autoloadToolStripMenuItem.Name = "autoloadToolStripMenuItem";
+ this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(225, 24);
+ this.autoloadToolStripMenuItem.Text = "Auto-load";
+ this.autoloadToolStripMenuItem.Click += new System.EventHandler(this.autoloadToolStripMenuItem_Click);
+ //
+ // saveWindowPositionToolStripMenuItem
+ //
+ this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem";
+ this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(225, 24);
+ this.saveWindowPositionToolStripMenuItem.Text = "Save Window Position";
+ this.saveWindowPositionToolStripMenuItem.Click += new System.EventHandler(this.saveWindowPositionToolStripMenuItem_Click);
+ //
+ // toolStripSeparator1
+ //
+ this.toolStripSeparator1.Name = "toolStripSeparator1";
+ this.toolStripSeparator1.Size = new System.Drawing.Size(222, 6);
+ //
+ // exitToolStripMenuItem
+ //
+ 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(225, 24);
+ this.exitToolStripMenuItem.Text = "E&xit";
+ this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
+ //
+ // GGCodeMaskBox
+ //
+ this.GGCodeMaskBox.Location = new System.Drawing.Point(24, 37);
+ this.GGCodeMaskBox.Mask = ">AAAA-AAAA";
+ this.GGCodeMaskBox.Name = "GGCodeMaskBox";
+ this.GGCodeMaskBox.Size = new System.Drawing.Size(99, 22);
+ this.GGCodeMaskBox.TabIndex = 9;
+ this.GGCodeMaskBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
+ this.GGCodeMaskBox.TextMaskFormat = System.Windows.Forms.MaskFormat.ExcludePromptAndLiterals;
+ this.GGCodeMaskBox.TextChanged += new System.EventHandler(this.GGCodeMaskBox_TextChanged);
+ this.GGCodeMaskBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.GGCodeMaskBox_KeyPress);
+ //
+ // addcheatbt
+ //
+ this.addcheatbt.Enabled = false;
+ this.addcheatbt.Location = new System.Drawing.Point(208, 144);
+ this.addcheatbt.Name = "addcheatbt";
+ this.addcheatbt.Size = new System.Drawing.Size(96, 32);
+ this.addcheatbt.TabIndex = 10;
+ this.addcheatbt.Text = "&Add Cheat";
+ this.addcheatbt.UseVisualStyleBackColor = true;
+ this.addcheatbt.Click += new System.EventHandler(this.addcheatbt_Click);
+ //
+ // GameGenieCodeBox
+ //
+ this.GameGenieCodeBox.Controls.Add(this.GGCodeMaskBox);
+ this.GameGenieCodeBox.Location = new System.Drawing.Point(27, 43);
+ this.GameGenieCodeBox.Margin = new System.Windows.Forms.Padding(4);
+ this.GameGenieCodeBox.Name = "GameGenieCodeBox";
+ this.GameGenieCodeBox.Padding = new System.Windows.Forms.Padding(4);
+ this.GameGenieCodeBox.Size = new System.Drawing.Size(153, 85);
+ this.GameGenieCodeBox.TabIndex = 11;
+ this.GameGenieCodeBox.TabStop = false;
+ this.GameGenieCodeBox.Text = "Game Genie Code";
+ //
+ // groupBox1
+ //
+ this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.groupBox1.Controls.Add(this.ValueBox);
+ this.groupBox1.Controls.Add(this.AddressBox);
+ this.groupBox1.Controls.Add(this.label6);
+ this.groupBox1.Controls.Add(this.label4);
+ this.groupBox1.Controls.Add(this.label3);
+ this.groupBox1.Controls.Add(this.label1);
+ this.groupBox1.Location = new System.Drawing.Point(208, 43);
+ this.groupBox1.Margin = new System.Windows.Forms.Padding(4);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Padding = new System.Windows.Forms.Padding(4);
+ this.groupBox1.Size = new System.Drawing.Size(182, 85);
+ this.groupBox1.TabIndex = 12;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Decoded Value";
+ //
+ // ValueBox
+ //
+ this.ValueBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
+ this.ValueBox.Location = new System.Drawing.Point(122, 53);
+ this.ValueBox.Margin = new System.Windows.Forms.Padding(4);
+ this.ValueBox.MaxLength = 4;
+ this.ValueBox.Name = "ValueBox";
+ this.ValueBox.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
+ this.ValueBox.Size = new System.Drawing.Size(52, 22);
+ this.ValueBox.TabIndex = 23;
+ this.ValueBox.TextChanged += new System.EventHandler(this.ValueBox_TextChanged);
+ //
+ // AddressBox
+ //
+ this.AddressBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
+ this.AddressBox.Location = new System.Drawing.Point(95, 23);
+ this.AddressBox.Margin = new System.Windows.Forms.Padding(4);
+ this.AddressBox.MaxLength = 6;
+ this.AddressBox.Name = "AddressBox";
+ this.AddressBox.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
+ this.AddressBox.Size = new System.Drawing.Size(79, 22);
+ this.AddressBox.TabIndex = 22;
+ this.AddressBox.TextChanged += new System.EventHandler(this.AddressBox_TextChanged);
+ //
+ // label6
+ //
+ this.label6.AutoSize = true;
+ this.label6.Location = new System.Drawing.Point(92, 57);
+ this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(22, 17);
+ this.label6.TabIndex = 9;
+ this.label6.Text = "0x";
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(70, 28);
+ this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(22, 17);
+ this.label4.TabIndex = 7;
+ this.label4.Text = "0x";
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(11, 56);
+ this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(44, 17);
+ this.label3.TabIndex = 5;
+ this.label3.Text = "Value";
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(11, 28);
+ this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(60, 17);
+ this.label1.TabIndex = 3;
+ this.label1.Text = "Address";
+ //
+ // ClearBT
+ //
+ this.ClearBT.Location = new System.Drawing.Point(88, 144);
+ this.ClearBT.Name = "ClearBT";
+ this.ClearBT.Size = new System.Drawing.Size(92, 32);
+ this.ClearBT.TabIndex = 13;
+ this.ClearBT.Text = "&Clear";
+ this.ClearBT.UseVisualStyleBackColor = true;
+ this.ClearBT.Click += new System.EventHandler(this.ClearBT_Click);
+ //
+ // groupBox2
+ //
+ this.groupBox2.Controls.Add(this.cheatname);
+ this.groupBox2.Location = new System.Drawing.Point(27, 188);
+ this.groupBox2.Name = "groupBox2";
+ this.groupBox2.Size = new System.Drawing.Size(355, 61);
+ this.groupBox2.TabIndex = 14;
+ this.groupBox2.TabStop = false;
+ this.groupBox2.Text = "Cheat Title (Uses GG code if left empty)";
+ //
+ // cheatname
+ //
+ this.cheatname.Location = new System.Drawing.Point(24, 28);
+ this.cheatname.Name = "cheatname";
+ this.cheatname.Size = new System.Drawing.Size(301, 22);
+ this.cheatname.TabIndex = 0;
+ //
+ // GenGameGenie
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(403, 261);
+ this.Controls.Add(this.groupBox2);
+ this.Controls.Add(this.ClearBT);
+ this.Controls.Add(this.groupBox1);
+ this.Controls.Add(this.GameGenieCodeBox);
+ this.Controls.Add(this.addcheatbt);
+ this.Controls.Add(this.menuStrip1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
+ this.MainMenuStrip = this.menuStrip1;
+ this.Margin = new System.Windows.Forms.Padding(4);
+ this.MaximizeBox = false;
+ this.MaximumSize = new System.Drawing.Size(413, 354);
+ this.MinimumSize = new System.Drawing.Size(413, 300);
+ this.Name = "GenGameGenie";
+ this.ShowIcon = false;
+ this.Text = "Game Genie Encoder / Decoder";
+ this.menuStrip1.ResumeLayout(false);
+ this.menuStrip1.PerformLayout();
+ this.GameGenieCodeBox.ResumeLayout(false);
+ this.GameGenieCodeBox.PerformLayout();
+ this.groupBox1.ResumeLayout(false);
+ this.groupBox1.PerformLayout();
+ this.groupBox2.ResumeLayout(false);
+ this.groupBox2.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.MenuStrip menuStrip1;
+ private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem;
+ private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
+ private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
+ private System.Windows.Forms.MaskedTextBox GGCodeMaskBox;
+ private System.Windows.Forms.Button addcheatbt;
+ private System.Windows.Forms.GroupBox GameGenieCodeBox;
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.Label label6;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Button ClearBT;
+ private HexTextBox ValueBox;
+ private HexTextBox AddressBox;
+ private System.Windows.Forms.GroupBox groupBox2;
+ private System.Windows.Forms.TextBox cheatname;
+ }
+}
\ No newline at end of file
diff --git a/BizHawk.MultiClient/GENtools/GenGameGenie.cs b/BizHawk.MultiClient/GENtools/GenGameGenie.cs
new file mode 100644
index 0000000000..e46f4cd065
--- /dev/null
+++ b/BizHawk.MultiClient/GENtools/GenGameGenie.cs
@@ -0,0 +1,307 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Windows.Forms;
+using System.Globalization;
+using System.Text.RegularExpressions;
+
+namespace BizHawk.MultiClient
+{
+ public partial class GenGameGenie : Form
+ {
+ bool Processing = false;
+ private readonly Dictionary GameGenieTable = new Dictionary();
+
+ public GenGameGenie()
+ {
+ InitializeComponent();
+ Closing += (o, e) => SaveConfigSettings();
+
+ GameGenieTable.Add('A', 0);
+ GameGenieTable.Add('B', 1);
+ GameGenieTable.Add('C', 2);
+ GameGenieTable.Add('D', 3);
+ GameGenieTable.Add('E', 4);
+ GameGenieTable.Add('F', 5);
+ GameGenieTable.Add('G', 6);
+ GameGenieTable.Add('H', 7);
+ GameGenieTable.Add('J', 8);
+ GameGenieTable.Add('K', 9);
+ GameGenieTable.Add('L', 10);
+ GameGenieTable.Add('M', 11);
+ GameGenieTable.Add('N', 12);
+ GameGenieTable.Add('P', 13);
+ GameGenieTable.Add('R', 14);
+ GameGenieTable.Add('S', 15);
+ GameGenieTable.Add('T', 16);
+ GameGenieTable.Add('V', 17);
+ GameGenieTable.Add('W', 18);
+ GameGenieTable.Add('X', 19);
+ GameGenieTable.Add('Y', 20);
+ GameGenieTable.Add('Z', 21);
+ GameGenieTable.Add('0', 22);
+ GameGenieTable.Add('1', 23);
+ GameGenieTable.Add('2', 24);
+ GameGenieTable.Add('3', 25);
+ GameGenieTable.Add('4', 26);
+ GameGenieTable.Add('5', 27);
+ GameGenieTable.Add('6', 28);
+ GameGenieTable.Add('7', 29);
+ GameGenieTable.Add('8', 30);
+ GameGenieTable.Add('9', 31);
+ }
+
+
+ // code is code to be converted, val is pointer to value, add is pointer to address
+ private void GenGGDecode(string code, ref int val, ref int add)
+ {
+ long hexcode = 0;
+ long decoded = 0;
+ int y = 0;
+
+ //convert code to a long binary string
+ for (int x = 0; x < code.Length; x++)
+ {
+ hexcode <<= 5;
+ GameGenieTable.TryGetValue(code[x], out y);
+ hexcode |= y;
+ }
+
+ decoded = ((hexcode & 0xFF00000000) >> 32);
+ decoded |= (hexcode & 0x00FF000000);
+ decoded |= ((hexcode & 0x0000FF0000) << 16 );
+ decoded |= ((hexcode & 0x00000000700) << 5);
+ decoded |= ((hexcode & 0x000000F800) >> 3);
+ decoded |= ((hexcode & 0x00000000FF) << 16);
+
+ val = (int)(decoded & 0x000000FFFF);
+ add = (int)((decoded & 0xFFFFFF0000) >> 16);
+
+ }
+
+ private string GenGGEncode(int val, int add)
+ {
+ long encoded = 0;
+ string code = null;
+
+ encoded = ((long)(val & 0x00FF) << 32);
+ encoded |= ((val & 0xE000) >> 5);
+ encoded |= ((val & 0x1F00) << 3);
+ encoded |= (add & 0xFF0000);
+ encoded |= ((add & 0x00FF00) << 16);
+ encoded |= (add & 0x0000FF);
+
+ char[] letters = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
+ for (int x = 0; x < 8; x++)
+ {
+ int chr = 0;
+ chr = (int)(encoded & 0x1F);
+ code += letters[chr];
+ encoded >>= 5;
+ }
+ //reverse string, as its build backward
+ char[] array = code.ToCharArray();
+ Array.Reverse(array);
+ return (new string(array));
+ }
+
+ private void GGCodeMaskBox_KeyPress(object sender, KeyPressEventArgs e)
+ {
+ //ignore I O Q U
+ if ((e.KeyChar == 73) || (e.KeyChar == 79) || (e.KeyChar == 81) || (e.KeyChar == 85) ||
+ (e.KeyChar == 105) || (e.KeyChar == 111) || (e.KeyChar == 113) || (e.KeyChar == 117))
+ {
+ e.KeyChar = '\n' ;
+ }
+ }
+
+ private void GGCodeMaskBox_TextChanged(object sender, EventArgs e)
+ {
+ if (Processing == false)
+ {
+ Processing = true;
+ //remove Invalid I O Q P if pasted
+ GGCodeMaskBox.Text = GGCodeMaskBox.Text.Replace("I", string.Empty);
+ GGCodeMaskBox.Text = GGCodeMaskBox.Text.Replace("O", string.Empty);
+ GGCodeMaskBox.Text = GGCodeMaskBox.Text.Replace("Q", string.Empty);
+ GGCodeMaskBox.Text = GGCodeMaskBox.Text.Replace("U", string.Empty);
+
+
+ if (GGCodeMaskBox.Text.Length > 0)
+ {
+ int val = 0;
+ int add = 0;
+ GenGGDecode(GGCodeMaskBox.Text, ref val, ref add);
+ AddressBox.Text = String.Format("{0:X6}", add);
+ ValueBox.Text = String.Format("{0:X4}", val);
+ addcheatbt.Enabled = true;
+ }
+ else
+ {
+ AddressBox.Text = "";
+ ValueBox.Text = "";
+ addcheatbt.Enabled = false;
+ }
+ Processing = false;
+ }
+ }
+
+ private void ClearBT_Click(object sender, EventArgs e)
+ {
+ AddressBox.Text = "";
+ ValueBox.Text = "";
+ GGCodeMaskBox.Text = "";
+ addcheatbt.Enabled = false;
+ }
+
+ private void AddressBox_TextChanged(object sender, EventArgs e)
+ {
+ //remove invalid character when pasted
+ if (Processing == false)
+ {
+ Processing = true;
+ if (Regex.IsMatch(AddressBox.Text, @"[^a-fA-F0-9]"))
+ {
+ string temp = Regex.Replace(AddressBox.Text, @"[^a-fA-F0-9]", string.Empty);
+ AddressBox.Text = temp;
+ }
+ if ((AddressBox.Text.Length > 0) || (ValueBox.Text.Length > 0))
+ {
+ int val = 0;
+ int add = 0;
+ if (ValueBox.Text.Length > 0)
+ val = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
+ if (AddressBox.Text.Length > 0)
+ add = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
+ GGCodeMaskBox.Text = GenGGEncode(val, add);
+ addcheatbt.Enabled = true;
+ }
+ else
+ {
+ GGCodeMaskBox.Text = "";
+ addcheatbt.Enabled = false;
+ }
+ Processing = false;
+ }
+ }
+
+ private void ValueBox_TextChanged(object sender, EventArgs e)
+ {
+ if (Processing == false)
+ {
+ Processing = true;
+ //remove invalid character when pasted
+ if (Regex.IsMatch(ValueBox.Text, @"[^a-fA-F0-9]"))
+ {
+ string temp = Regex.Replace(ValueBox.Text, @"[^a-fA-F0-9]", string.Empty);
+ ValueBox.Text = temp;
+ }
+ if ((AddressBox.Text.Length > 0) || (ValueBox.Text.Length > 0))
+ {
+ int val = 0;
+ int add = 0;
+ if (ValueBox.Text.Length > 0)
+ val = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
+ if (AddressBox.Text.Length > 0)
+ add = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
+ GGCodeMaskBox.Text = GenGGEncode(val, add);
+ addcheatbt.Enabled = true;
+
+ }
+ else
+ {
+ GGCodeMaskBox.Text = "";
+ addcheatbt.Enabled = false;
+ }
+ Processing = false;
+ }
+ }
+
+ private void addcheatbt_Click(object sender, EventArgs e)
+ {
+ Cheat c = new Cheat();
+ Cheat d = new Cheat();
+ if (cheatname.Text.Length > 0)
+ {
+ c.name = cheatname.Text + " Part 1";
+ d.name = cheatname.Text + " Part 2";
+ }
+ else
+ {
+ Processing = true;
+ GGCodeMaskBox.TextMaskFormat = MaskFormat.IncludeLiterals;
+ c.name = GGCodeMaskBox.Text + " Part 1";
+ d.name = GGCodeMaskBox.Text + " Part 2";
+ GGCodeMaskBox.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
+ Processing = false;
+ }
+
+ if (String.IsNullOrWhiteSpace(AddressBox.Text))
+ {
+ c.address = 0;
+ d.address = 0+1;
+ }
+ else
+ {
+ c.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
+ d.address = c.address + 1;
+ }
+ if (String.IsNullOrWhiteSpace(ValueBox.Text))
+ {
+ c.value = 0;
+ d.value = 0;
+ }
+ else
+ {
+ c.value = (byte)((int.Parse(ValueBox.Text, NumberStyles.HexNumber) & 0xFF00) >> 8);
+ d.value = (byte)(int.Parse(ValueBox.Text, NumberStyles.HexNumber) & 0x00FF);
+ }
+ c.compare = null;
+ d.compare = null;
+ for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
+
+ if (Global.Emulator.MemoryDomains[x].ToString() == "Rom Data")
+ {
+ c.domain = Global.Emulator.MemoryDomains[x];
+ c.Enable();
+ Global.MainForm.Cheats1.AddCheat(c);
+ d.domain = Global.Emulator.MemoryDomains[x];
+ d.Enable();
+ Global.MainForm.Cheats1.AddCheat(d);
+ break;
+ }
+
+
+ }
+
+ private void autoloadToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ Global.Config.GENGGAutoload ^= true;
+ }
+
+ private void saveWindowPositionToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ Global.Config.GENGGSaveWindowPosition ^= true;
+ }
+
+ private void exitToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ Close();
+ }
+
+ private void GENGameGenie_Load(object sender, EventArgs e)
+ {
+
+ if (Global.Config.GENGGSaveWindowPosition && Global.Config.GENGGWndx >= 0 && Global.Config.GENGGWndy >= 0)
+ Location = new Point(Global.Config.GENGGWndx, Global.Config.GENGGWndy);
+ }
+
+ private void SaveConfigSettings()
+ {
+ Global.Config.GENGGWndx = Location.X;
+ Global.Config.GENGGWndy = Location.Y;
+ }
+
+ }
+}
+
diff --git a/BizHawk.MultiClient/GENtools/GenGameGenie.resx b/BizHawk.MultiClient/GENtools/GenGameGenie.resx
new file mode 100644
index 0000000000..25d918dd97
--- /dev/null
+++ b/BizHawk.MultiClient/GENtools/GenGameGenie.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs
index 233d8edf85..e4f947c406 100644
--- a/BizHawk.MultiClient/MainForm.cs
+++ b/BizHawk.MultiClient/MainForm.cs
@@ -3345,6 +3345,11 @@ namespace BizHawk.MultiClient
GBGameGenie gg = new GBGameGenie();
gg.Show();
}
+ else if (Global.Emulator is Genesis)
+ {
+ GenGameGenie gg = new GenGameGenie();
+ gg.Show();
+ }
}
public void LoadSNESGraphicsDebugger()
diff --git a/BizHawk.MultiClient/SNESTools/SNESGameGenie.Designer.cs b/BizHawk.MultiClient/SNESTools/SNESGameGenie.Designer.cs
index 0319683c77..54762b4e2d 100644
--- a/BizHawk.MultiClient/SNESTools/SNESGameGenie.Designer.cs
+++ b/BizHawk.MultiClient/SNESTools/SNESGameGenie.Designer.cs
@@ -28,13 +28,13 @@
///
private void InitializeComponent()
{
- this.GameGenieCode = new System.Windows.Forms.TextBox();
this.GameGenieCodeBox = new System.Windows.Forms.GroupBox();
+ this.GGCodeMaskBox = new System.Windows.Forms.MaskedTextBox();
this.label3 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.ValueBox = new BizHawk.HexTextBox();
this.AddressBox = new BizHawk.HexTextBox();
- this.AddCheat = new System.Windows.Forms.Button();
+ this.addcheatbt = new System.Windows.Forms.Button();
this.ButtonPanel = new System.Windows.Forms.Panel();
this.BF = new System.Windows.Forms.Button();
this.BD = new System.Windows.Forms.Button();
@@ -62,41 +62,43 @@
this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.cheatname = new System.Windows.Forms.TextBox();
this.GameGenieCodeBox.SuspendLayout();
this.ButtonPanel.SuspendLayout();
this.groupBox1.SuspendLayout();
this.menuStrip1.SuspendLayout();
+ this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
- // GameGenieCode
- //
- this.GameGenieCode.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
- this.GameGenieCode.Location = new System.Drawing.Point(8, 23);
- this.GameGenieCode.Margin = new System.Windows.Forms.Padding(4);
- this.GameGenieCode.MaxLength = 8;
- this.GameGenieCode.Name = "GameGenieCode";
- this.GameGenieCode.Size = new System.Drawing.Size(113, 22);
- this.GameGenieCode.TabIndex = 20;
- this.GameGenieCode.TextChanged += new System.EventHandler(this.GameGenieCode_TextChanged);
- this.GameGenieCode.KeyDown += new System.Windows.Forms.KeyEventHandler(this.GameGenieCode_KeyDown);
- this.GameGenieCode.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.GameGenieCode_KeyPress);
- //
// GameGenieCodeBox
//
- this.GameGenieCodeBox.Controls.Add(this.GameGenieCode);
+ this.GameGenieCodeBox.Controls.Add(this.GGCodeMaskBox);
this.GameGenieCodeBox.Location = new System.Drawing.Point(41, 127);
this.GameGenieCodeBox.Margin = new System.Windows.Forms.Padding(4);
this.GameGenieCodeBox.Name = "GameGenieCodeBox";
this.GameGenieCodeBox.Padding = new System.Windows.Forms.Padding(4);
- this.GameGenieCodeBox.Size = new System.Drawing.Size(153, 66);
+ this.GameGenieCodeBox.Size = new System.Drawing.Size(158, 66);
this.GameGenieCodeBox.TabIndex = 1;
this.GameGenieCodeBox.TabStop = false;
this.GameGenieCodeBox.Text = "Game Genie Code";
//
+ // GGCodeMaskBox
+ //
+ this.GGCodeMaskBox.Location = new System.Drawing.Point(33, 32);
+ this.GGCodeMaskBox.Mask = ">AAAA-AAAA";
+ this.GGCodeMaskBox.Name = "GGCodeMaskBox";
+ this.GGCodeMaskBox.Size = new System.Drawing.Size(99, 22);
+ this.GGCodeMaskBox.TabIndex = 10;
+ this.GGCodeMaskBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
+ this.GGCodeMaskBox.TextMaskFormat = System.Windows.Forms.MaskFormat.ExcludePromptAndLiterals;
+ this.GGCodeMaskBox.TextChanged += new System.EventHandler(this.GGCodeMaskBox_TextChanged);
+ this.GGCodeMaskBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.GGCodeMaskBox_KeyPress);
+ //
// label3
//
this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(11, 56);
+ this.label3.Location = new System.Drawing.Point(11, 67);
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(44, 17);
@@ -106,7 +108,7 @@
// label1
//
this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(11, 20);
+ this.label1.Location = new System.Drawing.Point(11, 27);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(60, 17);
@@ -116,7 +118,7 @@
// ValueBox
//
this.ValueBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
- this.ValueBox.Location = new System.Drawing.Point(140, 51);
+ this.ValueBox.Location = new System.Drawing.Point(140, 62);
this.ValueBox.Margin = new System.Windows.Forms.Padding(4);
this.ValueBox.MaxLength = 2;
this.ValueBox.Name = "ValueBox";
@@ -128,7 +130,7 @@
// AddressBox
//
this.AddressBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
- this.AddressBox.Location = new System.Drawing.Point(100, 16);
+ this.AddressBox.Location = new System.Drawing.Point(100, 23);
this.AddressBox.Margin = new System.Windows.Forms.Padding(4);
this.AddressBox.MaxLength = 6;
this.AddressBox.Name = "AddressBox";
@@ -137,17 +139,18 @@
this.AddressBox.TabIndex = 21;
this.AddressBox.TextChanged += new System.EventHandler(this.AddressBox_TextChanged);
//
- // AddCheat
+ // addcheatbt
//
- this.AddCheat.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.AddCheat.Location = new System.Drawing.Point(268, 276);
- this.AddCheat.Margin = new System.Windows.Forms.Padding(4);
- this.AddCheat.Name = "AddCheat";
- this.AddCheat.Size = new System.Drawing.Size(92, 26);
- this.AddCheat.TabIndex = 33;
- this.AddCheat.Text = "&Add Cheat";
- this.AddCheat.UseVisualStyleBackColor = true;
- this.AddCheat.Click += new System.EventHandler(this.AddCheat_Click);
+ this.addcheatbt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.addcheatbt.Enabled = false;
+ this.addcheatbt.Location = new System.Drawing.Point(117, 201);
+ this.addcheatbt.Margin = new System.Windows.Forms.Padding(4);
+ this.addcheatbt.Name = "addcheatbt";
+ this.addcheatbt.Size = new System.Drawing.Size(82, 32);
+ this.addcheatbt.TabIndex = 33;
+ this.addcheatbt.Text = "&Add Cheat";
+ this.addcheatbt.UseVisualStyleBackColor = true;
+ this.addcheatbt.Click += new System.EventHandler(this.AddCheat_Click);
//
// ButtonPanel
//
@@ -168,7 +171,7 @@
this.ButtonPanel.Controls.Add(this.B4);
this.ButtonPanel.Controls.Add(this.B2);
this.ButtonPanel.Controls.Add(this.B0);
- this.ButtonPanel.Location = new System.Drawing.Point(41, 37);
+ this.ButtonPanel.Location = new System.Drawing.Point(47, 37);
this.ButtonPanel.Margin = new System.Windows.Forms.Padding(4);
this.ButtonPanel.Name = "ButtonPanel";
this.ButtonPanel.Size = new System.Drawing.Size(319, 82);
@@ -359,18 +362,19 @@
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.AddressBox);
this.groupBox1.Controls.Add(this.ValueBox);
- this.groupBox1.Location = new System.Drawing.Point(41, 201);
+ this.groupBox1.Location = new System.Drawing.Point(207, 127);
this.groupBox1.Margin = new System.Windows.Forms.Padding(4);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Padding = new System.Windows.Forms.Padding(4);
this.groupBox1.Size = new System.Drawing.Size(183, 101);
this.groupBox1.TabIndex = 5;
this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Decoded Value";
//
// label6
//
this.label6.AutoSize = true;
- this.label6.Location = new System.Drawing.Point(116, 56);
+ this.label6.Location = new System.Drawing.Point(116, 67);
this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(22, 17);
@@ -380,7 +384,7 @@
// label4
//
this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(76, 20);
+ this.label4.Location = new System.Drawing.Point(76, 27);
this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(22, 17);
@@ -390,10 +394,9 @@
// ClearButton
//
this.ClearButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.ClearButton.Location = new System.Drawing.Point(288, 210);
- this.ClearButton.Margin = new System.Windows.Forms.Padding(4);
+ this.ClearButton.Location = new System.Drawing.Point(41, 201);
this.ClearButton.Name = "ClearButton";
- this.ClearButton.Size = new System.Drawing.Size(72, 28);
+ this.ClearButton.Size = new System.Drawing.Size(72, 32);
this.ClearButton.TabIndex = 32;
this.ClearButton.Text = "&Clear";
this.ClearButton.UseVisualStyleBackColor = true;
@@ -449,15 +452,33 @@
this.exitToolStripMenuItem.Text = "E&xit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
//
+ // groupBox2
+ //
+ this.groupBox2.Controls.Add(this.cheatname);
+ this.groupBox2.Location = new System.Drawing.Point(41, 242);
+ this.groupBox2.Name = "groupBox2";
+ this.groupBox2.Size = new System.Drawing.Size(349, 61);
+ this.groupBox2.TabIndex = 24;
+ this.groupBox2.TabStop = false;
+ this.groupBox2.Text = "Cheat Title (Uses GG code if left empty)";
+ //
+ // cheatname
+ //
+ this.cheatname.Location = new System.Drawing.Point(24, 28);
+ this.cheatname.Name = "cheatname";
+ this.cheatname.Size = new System.Drawing.Size(301, 22);
+ this.cheatname.TabIndex = 0;
+ //
// SNESGameGenie
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(403, 315);
+ this.Controls.Add(this.groupBox2);
this.Controls.Add(this.ClearButton);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.ButtonPanel);
- this.Controls.Add(this.AddCheat);
+ this.Controls.Add(this.addcheatbt);
this.Controls.Add(this.GameGenieCodeBox);
this.Controls.Add(this.menuStrip1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
@@ -476,6 +497,8 @@
this.groupBox1.PerformLayout();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
+ this.groupBox2.ResumeLayout(false);
+ this.groupBox2.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@@ -483,13 +506,12 @@
#endregion
- private System.Windows.Forms.TextBox GameGenieCode;
- private System.Windows.Forms.GroupBox GameGenieCodeBox;
+ private System.Windows.Forms.GroupBox GameGenieCodeBox;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label1;
private HexTextBox ValueBox;
private HexTextBox AddressBox;
- private System.Windows.Forms.Button AddCheat;
+ private System.Windows.Forms.Button addcheatbt;
private System.Windows.Forms.Panel ButtonPanel;
private System.Windows.Forms.Button B6;
private System.Windows.Forms.Button B4;
@@ -517,5 +539,8 @@
private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
+ private System.Windows.Forms.MaskedTextBox GGCodeMaskBox;
+ private System.Windows.Forms.GroupBox groupBox2;
+ private System.Windows.Forms.TextBox cheatname;
}
}
\ No newline at end of file
diff --git a/BizHawk.MultiClient/SNESTools/SNESGameGenie.cs b/BizHawk.MultiClient/SNESTools/SNESGameGenie.cs
index 3b7095c8d7..43c4d0fa53 100644
--- a/BizHawk.MultiClient/SNESTools/SNESGameGenie.cs
+++ b/BizHawk.MultiClient/SNESTools/SNESGameGenie.cs
@@ -3,19 +3,16 @@ using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Globalization;
+using System.Text.RegularExpressions;
namespace BizHawk.MultiClient
{
public partial class SNESGameGenie : Form
{
- public int Address = -1;
- public int Value = -1;
private readonly Dictionary GameGenieTable = new Dictionary();
- private bool Decoding = false;
- private bool Encoding = false;
-
+ private bool Processing = false;
- public SNESGameGenie()
+ public SNESGameGenie()
{
InitializeComponent();
Closing += (o, e) => SaveConfigSettings();
@@ -41,9 +38,101 @@ namespace BizHawk.MultiClient
GameGenieTable.Add('E', 15); //1111
}
+ public void SNESGGDecode(string code, ref int val, ref int add)
+ {
+
+ //Code: D F 4 7 0 9 1 5 6 B C 8 A 2 3 E
+ //Hex: 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ //XXYY-YYYY, where XX is the value, and YY-YYYY is the address.
+ //Char # | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
+ //Bit # |3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|
+ //maps to| Value |i|j|k|l|q|r|s|t|o|p|a|b|c|d|u|v|w|x|e|f|g|h|m|n|
+ //order | Value |a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|
+
+ int x;
+
+ // Getting Value
+ if (code.Length > 0)
+ {
+ GameGenieTable.TryGetValue(code[0], out x);
+ val = x << 4;
+ }
+
+ if (code.Length > 1)
+ {
+ GameGenieTable.TryGetValue(code[1], out x);
+ val |= x;
+ }
+ //Address
+ if (code.Length > 2)
+ {
+ GameGenieTable.TryGetValue(code[2], out x);
+ add = (x << 12);
+ }
+
+ if (code.Length > 3)
+ {
+ GameGenieTable.TryGetValue(code[3], out x);
+ add |= (x << 4);
+ }
+
+ if (code.Length > 4)
+ {
+ GameGenieTable.TryGetValue(code[4], out x);
+ add |= ((x & 0xC) << 6);
+ add |= ((x & 0x3) << 22);
+ }
+
+ if (code.Length > 5)
+ {
+ GameGenieTable.TryGetValue(code[5], out x);
+ add |= ((x & 0xC) << 18);
+ add |= ((x & 0x3) << 2);
+ }
+
+ if (code.Length > 6)
+ {
+ GameGenieTable.TryGetValue(code[6], out x);
+ add |= ((x & 0xC) >> 2);
+ add |= ((x & 0x3) << 18);
+ }
+
+ if (code.Length > 7)
+ {
+ GameGenieTable.TryGetValue(code[7], out x);
+ add |= ((x & 0xC) << 14);
+ add |= ((x & 0x3) << 10);
+ }
+
+ }
+
+ private string SNESGGEncode(int val, int add)
+ {
+ //Code: D F 4 7 0 9 1 5 6 B C 8 A 2 3 E
+ //Hex: 0 1 2 3 4 5 6 7 8 9 A B C D E F
+ //Char # | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
+ //Bit # |3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|
+ //maps to| Value |i|j|k|l|q|r|s|t|o|p|a|b|c|d|u|v|w|x|e|f|g|h|m|n|
+ //order | Value |a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|
+ char[] letters = { 'D', 'F', '4', '7', '0', '9', '1', '5', '6', 'B', 'C', '8', 'A', '2', '3', 'E' };
+ string code = "";
+ int[] num = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ num[0] = (val & 0xF0) >>4;
+ num[1] = val & 0x0F;
+
+ num[2] = (add & 0x00F000) >> 12; //ijkl
+ num[3] = (add & 0x0000F0) >> 4; //qrst
+ num[4] = ((add & 0x000300) >> 6) | ((add & 0xC00000) >> 22); //opab
+ num[5] = ((add & 0x300000) >> 18) | ((add & 0x00000C) >>2); //cduv
+ num[6] = ((add & 0x000003) << 2)| ((add & 0x0C0000) >> 18);//wxef
+ num[7] = ((add & 0x030000) >> 14) | ((add & 0x000C00) >> 10);//ghmn*/
+ for (int x = 0; x < 8; x++)
+ code += letters[num[x]];
+ return code;
+ }
private void SNESGameGenie_Load(object sender, EventArgs e)
{
- AddCheat.Enabled = false;
+ addcheatbt.Enabled = false;
if (Global.Config.SNESGGSaveWindowPosition && Global.Config.SNESGGWndx >= 0 && Global.Config.SNESGGWndy >= 0)
Location = new Point(Global.Config.SNESGGWndx, Global.Config.SNESGGWndy);
@@ -55,270 +144,185 @@ namespace BizHawk.MultiClient
Global.Config.SNESGGWndy = Location.Y;
}
- private void GameGenieCode_KeyPress(object sender, KeyPressEventArgs e)
+ private void GGCodeMaskBox_KeyPress(object sender, KeyPressEventArgs e)
+ {
+ // Find a better way to remove all NON HEX char, while still allowing copy/paste
+ //Right now its all done through removing em GGCodeMaskBox_TextChanged
+ }
+
+ private void GGCodeMaskBox_TextChanged(object sender, EventArgs e)
{
- //Make uppercase
- if (e.KeyChar >= 97 && e.KeyChar < 123)
- e.KeyChar -= (char)32;
-
- if (!(GameGenieTable.ContainsKey(e.KeyChar)))
+ if (Processing == false)
{
- if (e.KeyChar != (char)Keys.Back || e.KeyChar == '\b' || e.KeyChar == 22 || e.KeyChar == 1 || e.KeyChar == 3)
+ Processing = true;
+ //insert REGEX Remove non HEXA char
+ if (Regex.IsMatch(GGCodeMaskBox.Text, @"[^a-fA-F0-9]"))
{
- e.Handled = true;
+ string temp = Regex.Replace(GGCodeMaskBox.Text, @"[^a-fA-F0-9]", string.Empty);
+ GGCodeMaskBox.Text = temp;
}
- }
- }
-
- public void SNESDecodeGameGenieCode(string code)
- {
-
- //Code: D F 4 7 0 9 1 5 6 B C 8 A 2 3 E
- //Hex: 0 1 2 3 4 5 6 7 8 9 A B C D E F
- //XXYY-YYYY, where XX is the value, and YY-YYYY is the address.
- //Char # | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
- //Bit # |3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|
- //maps to| Value |i|j|k|l|q|r|s|t|o|p|a|b|c|d|u|v|w|x|e|f|g|h|m|n|
- //order | Value |a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|
- //Decoding = true;
-
- int x;
- byte[] val = { 0, 0};
-
- // Getting Value
- if (code.Length > 0)
- {
- GameGenieTable.TryGetValue(code[0], out x);
- Value = x << 4;
- }
-
- if (code.Length > 1)
- {
- GameGenieTable.TryGetValue(code[1], out x);
- Value |= x;
- }
- //Address
- if (code.Length > 2)
- {
- GameGenieTable.TryGetValue(code[2], out x);
- Address = (x << 12);
- }
-
- if (code.Length > 3)
- {
- GameGenieTable.TryGetValue(code[3], out x);
- Address |= (x << 4);
- }
-
- if (code.Length > 4)
- {
- GameGenieTable.TryGetValue(code[4], out x);
- Address |= ((x & 0xC) << 6);
- Address |= ((x & 0x3) << 22);
- }
-
- if (code.Length > 5)
- {
- GameGenieTable.TryGetValue(code[5], out x);
- Address |= ((x & 0xC) << 18);
- Address |= ((x & 0x3) << 2);
- }
-
- if (code.Length > 6)
- {
- GameGenieTable.TryGetValue(code[6], out x);
- Address |= ((x & 0xC) >> 2);
- Address |= ((x & 0x3) << 18);
- }
-
- if (code.Length > 7)
- {
- GameGenieTable.TryGetValue(code[7], out x);
- Address |= ((x & 0xC) << 14);
- Address |= ((x & 0x3) << 10);
- }
-
- SetProperties();
-
- }
-
- private void SetProperties()
- {
- if (Address >= 0)
- AddressBox.Text = String.Format("{0:X6}", Address);
- else
- AddressBox.Text = "";
-
- if (Value >= 0)
- ValueBox.Text = String.Format("{0:X2}", Value);
-
- }
-
- private void ClearProperties()
- {
- Address = -1;
- Value = -1;
- AddressBox.Text = "";
- ValueBox.Text = "";
- AddCheat.Enabled = false;
- //Decoding = false;
- }
-
- private void GameGenieCode_TextChanged(object sender, EventArgs e)
- {
-
- if (Encoding == false)
- {
- if (GameGenieCode.Text.Length > 0)
+ if (GGCodeMaskBox.Text.Length > 0)
{
- Decoding = true;
- SNESDecodeGameGenieCode(GameGenieCode.Text);
+ int val = 0;
+ int add = 0;
+ SNESGGDecode(GGCodeMaskBox.Text, ref val, ref add);
+ AddressBox.Text = String.Format("{0:X6}", add);
+ ValueBox.Text = String.Format("{0:X2}", val);
+ addcheatbt.Enabled = true;
}
else
- ClearProperties();
+ {
+ AddressBox.Text = "";
+ ValueBox.Text = "";
+ addcheatbt.Enabled = false;
+ }
+ Processing = false;
}
- TryEnableAddCheat();
- Decoding = false;
}
private void Keypad_Click(object sender, EventArgs e)
{
- if (GameGenieCode.Text.Length < 8)
+ if (GGCodeMaskBox.Text.Length < 8)
{
string code = "";
if (sender == B0) code = "0";
- if (sender == B1) code += "1";
- if (sender == B2) code += "2";
- if (sender == B3) code += "3";
- if (sender == B4) code += "4";
- if (sender == B5) code += "5";
- if (sender == B6) code += "6";
- if (sender == B7) code += "7";
- if (sender == B8) code += "8";
- if (sender == B9) code += "9";
- if (sender == BA) code += "A";
- if (sender == BB) code += "B";
- if (sender == BC) code += "C";
- if (sender == BD) code += "D";
- if (sender == BE) code += "E";
- if (sender == BF) code += "F";
+ if (sender == B1) code = "1";
+ if (sender == B2) code = "2";
+ if (sender == B3) code = "3";
+ if (sender == B4) code = "4";
+ if (sender == B5) code = "5";
+ if (sender == B6) code = "6";
+ if (sender == B7) code = "7";
+ if (sender == B8) code = "8";
+ if (sender == B9) code = "9";
+ if (sender == BA) code = "A";
+ if (sender == BB) code = "B";
+ if (sender == BC) code = "C";
+ if (sender == BD) code = "D";
+ if (sender == BE) code = "E";
+ if (sender == BF) code = "F";
- int x = GameGenieCode.SelectionStart;
- GameGenieCode.Text = GameGenieCode.Text.Insert(x, code);
- GameGenieCode.SelectionStart = x + 1;
+ GGCodeMaskBox.Text += code;
+ //int x = GGCodeMaskBox.SelectionStart;
+ //GGCodeMaskBox.Text = GGCodeMaskBox.Text.Insert(x, code);
+ //GGCodeMaskBox.SelectionStart = x + 1;
}
}
private void AddressBox_TextChanged(object sender, EventArgs e)
{
- if (Decoding == false)
+ //remove invalid character when pasted
+ if (Processing == false)
{
- if (AddressBox.Text.Length > 0 )
+ Processing = true;
+ if (Regex.IsMatch(AddressBox.Text, @"[^a-fA-F0-9]"))
{
- Address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
- if (ValueBox.Text.Length > 0)
- Value = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
- else
- Value = 0;
- Encoding = true;
- SNESEncodeGameGenie();
- Encoding = false;
+ string temp = Regex.Replace(AddressBox.Text, @"[^a-fA-F0-9]", string.Empty);
+ AddressBox.Text = temp;
}
+ if ((AddressBox.Text.Length > 0) || (ValueBox.Text.Length > 0))
+ {
+ int val = 0;
+ int add = 0;
+ if (ValueBox.Text.Length > 0)
+ val = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
+ if (AddressBox.Text.Length > 0)
+ add = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
+ GGCodeMaskBox.Text = SNESGGEncode(val, add);
+ addcheatbt.Enabled = true;
+ }
+ else
+ {
+ GGCodeMaskBox.Text = "";
+ addcheatbt.Enabled = false;
+ }
+ Processing = false;
}
- TryEnableAddCheat();
}
- private void TryEnableAddCheat()
- {
- if (AddressBox.Text.Length == 6 && ValueBox.Text.Length == 2)
- AddCheat.Enabled = true;
- else
- AddCheat.Enabled = false;
- }
private void ValueBox_TextChanged(object sender, EventArgs e)
{
- if (Decoding == false)
+ if (Processing == false)
{
- if (ValueBox.Text.Length > 0)
+ Processing = true;
+ //remove invalid character when pasted
+ if (Regex.IsMatch(ValueBox.Text, @"[^a-fA-F0-9]"))
{
- if (AddressBox.Text.Length > 0)
- Address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
- else
- Address = 0x000000;
- Value = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
- Encoding = true;
- SNESEncodeGameGenie();
- Encoding = false;
+ string temp = Regex.Replace(ValueBox.Text, @"[^a-fA-F0-9]", string.Empty);
+ ValueBox.Text = temp;
}
+ if ((AddressBox.Text.Length > 0) || (ValueBox.Text.Length > 0))
+ {
+ int val = 0;
+ int add = 0;
+ if (ValueBox.Text.Length > 0)
+ val = int.Parse(ValueBox.Text, NumberStyles.HexNumber);
+ if (AddressBox.Text.Length > 0)
+ add = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
+ GGCodeMaskBox.Text = SNESGGEncode(val, add);
+ addcheatbt.Enabled = true;
+
+ }
+ else
+ {
+ GGCodeMaskBox.Text = "";
+ addcheatbt.Enabled = false;
+ }
+ Processing = false;
}
- TryEnableAddCheat();
}
- private void SNESEncodeGameGenie()
- {
- //Code: D F 4 7 0 9 1 5 6 B C 8 A 2 3 E
- //Hex: 0 1 2 3 4 5 6 7 8 9 A B C D E F
- //Char # | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
- //Bit # |3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|3|2|1|0|
- //maps to| Value |i|j|k|l|q|r|s|t|o|p|a|b|c|d|u|v|w|x|e|f|g|h|m|n|
- //order | Value |a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|
- char[] letters = { 'D', 'F', '4', '7', '0', '9', '1', '5', '6', 'B', 'C', '8', 'A', '2', '3', 'E' };
- GameGenieCode.Text = "";
- int[] num = { 0, 0, 0, 0, 0, 0, 0, 0 };
- num[0] = (Value & 0xF0) >>4;
- num[1] = Value & 0x0F;
-
- num[2] = (Address & 0x00F000) >> 12; //ijkl
- num[3] = (Address & 0x0000F0) >> 4; //qrst
- num[4] = ((Address & 0x000300) >> 6) | ((Address & 0xC00000) >> 22); //opab
- num[5] = ((Address & 0x300000) >> 18) | ((Address & 0x00000C) >>2); //cduv
- num[6] = ((Address & 0x000003) << 2)| ((Address & 0x0C0000) >> 18);//wxef
- num[7] = ((Address & 0x030000) >> 14) | ((Address & 0x000C00) >> 10);//ghmn*/
- for (int x = 0; x < 8; x++)
- GameGenieCode.Text += letters[num[x]];
- }
+
private void ClearButton_Click(object sender, EventArgs e)
{
- ClearProperties();
- GameGenieCode.Text = "";
+ AddressBox.Text = "";
+ ValueBox.Text = "";
+ GGCodeMaskBox.Text = "";
+ addcheatbt.Enabled = false;
}
private void AddCheat_Click(object sender, EventArgs e)
{
- AddCheatClick();
- }
-
- private void AddCheatClick()
- {
- Cheat c = new Cheat {name = GameGenieCode.Text};
+ Cheat c = new Cheat();
+ if (cheatname.Text.Length > 0)
+ c.name = cheatname.Text;
+ else
+ {
+ Processing = true;
+ GGCodeMaskBox.TextMaskFormat = MaskFormat.IncludeLiterals;
+ c.name = GGCodeMaskBox.Text;
+ GGCodeMaskBox.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals;
+ Processing = false;
+ }
if (String.IsNullOrWhiteSpace(AddressBox.Text))
- {
- return;
- }
- else if (String.IsNullOrWhiteSpace(ValueBox.Text))
- {
- return;
- }
+ c.address = 0;
+ else
+ c.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
+
+ if (String.IsNullOrWhiteSpace(ValueBox.Text))
+ c.value = 0;
+ else
+ c.value = (byte)((int.Parse(ValueBox.Text, NumberStyles.HexNumber) & 0xFF00) >> 8);
- c.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
- c.value = byte.Parse(ValueBox.Text, NumberStyles.HexNumber);
c.compare = null;
- c.Enable();
for (int x = 0; x < Global.Emulator.MemoryDomains.Count; x++)
- if (Global.Emulator.MemoryDomains[x].ToString() == "BUS")
- {
- c.domain = Global.Emulator.MemoryDomains[x]; //Bus
- Global.MainForm.Cheats1.AddCheat(c);
- break;
- }
+
+ if (Global.Emulator.MemoryDomains[x].ToString() == "BUS")
+ {
+ c.domain = Global.Emulator.MemoryDomains[x];
+ c.Enable();
+ Global.MainForm.Cheats1.AddCheat(c);
+ break;
+ }
+
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
@@ -342,16 +346,9 @@ namespace BizHawk.MultiClient
saveWindowPositionToolStripMenuItem.Checked = Global.Config.SNESGGSaveWindowPosition;
}
- private void GameGenieCode_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyData == Keys.Enter)
- {
- if (AddCheat.Enabled)
- {
- AddCheatClick();
- }
- }
- }
+
+
+
}
diff --git a/BizHawk.MultiClient/tools/Cheats.cs b/BizHawk.MultiClient/tools/Cheats.cs
index 7257914700..c82d1d2bb2 100644
--- a/BizHawk.MultiClient/tools/Cheats.cs
+++ b/BizHawk.MultiClient/tools/Cheats.cs
@@ -7,7 +7,9 @@ using System.Windows.Forms;
using System.IO;
using System.Globalization;
+using BizHawk.Emulation.Consoles.Nintendo.SNES;
using BizHawk.Emulation.Consoles.Nintendo;
+using BizHawk.Emulation.Consoles.Sega;
namespace BizHawk.MultiClient
{
@@ -149,7 +151,7 @@ namespace BizHawk.MultiClient
private void ToggleGameGenieButtons()
{
- if (Global.Emulator is NES)
+ if ((Global.Emulator is NES) || (Global.Emulator is Genesis) || (Global.Emulator.SystemId == "GB") || (Global.Game.System == "GG") || (Global.Emulator is LibsnesCore))
{
toolStripButtonLoadGameGenie.Visible = true;
toolStripSeparator7.Visible = true;