diff --git a/BizHawk.MultiClient/BizHawk.MultiClient.csproj b/BizHawk.MultiClient/BizHawk.MultiClient.csproj index 21a6678da9..91fa9ce25c 100644 --- a/BizHawk.MultiClient/BizHawk.MultiClient.csproj +++ b/BizHawk.MultiClient/BizHawk.MultiClient.csproj @@ -151,13 +151,18 @@ RecordMovie.cs + + Form + + + RamPoke.cs + Form InputPrompt.cs - Form @@ -218,6 +223,10 @@ RecordMovie.cs Designer + + RamPoke.cs + Designer + InputPrompt.cs Designer diff --git a/BizHawk.MultiClient/images/poke.ico b/BizHawk.MultiClient/images/poke.ico new file mode 100644 index 0000000000..68beaafa71 Binary files /dev/null and b/BizHawk.MultiClient/images/poke.ico differ diff --git a/BizHawk.MultiClient/tools/Poke.cs b/BizHawk.MultiClient/tools/Poke.cs deleted file mode 100644 index 7bb3ca97d5..0000000000 --- a/BizHawk.MultiClient/tools/Poke.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.MultiClient -{ - /// - /// This class prompts the user for an address & value and writes to memory - /// If supplied a Watch object it will use it to generate default values - /// - class Poke - { - Watch w = new Watch(); - - public bool PokeAddress(Watch watch) - { - w = watch; - return PokeWatch(); - } - - public bool PokeAddress() - { - return PokeWatch(); - } - - private bool PokeWatch() - { - InputPrompt i = new InputPrompt(); - i.Text = "Poke address"; - i.ShowDialog(); - //Prompt user - //Attempt to poke - //If use cancels or some failure, return false, else turn true - return true; - } - } -} diff --git a/BizHawk.MultiClient/tools/RamPoke.Designer.cs b/BizHawk.MultiClient/tools/RamPoke.Designer.cs new file mode 100644 index 0000000000..06ebf4c86d --- /dev/null +++ b/BizHawk.MultiClient/tools/RamPoke.Designer.cs @@ -0,0 +1,296 @@ +namespace BizHawk.MultiClient +{ + partial class RamPoke + { + /// + /// 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() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RamPoke)); + this.label1 = new System.Windows.Forms.Label(); + this.AddressBox = new System.Windows.Forms.TextBox(); + this.DataTypeGroupBox = new System.Windows.Forms.GroupBox(); + this.HexRadio = new System.Windows.Forms.RadioButton(); + this.UnsignedRadio = new System.Windows.Forms.RadioButton(); + this.SignedRadio = new System.Windows.Forms.RadioButton(); + this.DataSizeBox = new System.Windows.Forms.GroupBox(); + this.Byte4Radio = new System.Windows.Forms.RadioButton(); + this.Byte2Radio = new System.Windows.Forms.RadioButton(); + this.Byte1Radio = new System.Windows.Forms.RadioButton(); + this.EndianBox = new System.Windows.Forms.GroupBox(); + this.LittleEndianRadio = new System.Windows.Forms.RadioButton(); + this.BigEndianRadio = new System.Windows.Forms.RadioButton(); + this.OK = new System.Windows.Forms.Button(); + this.Cancel = new System.Windows.Forms.Button(); + this.OutputLabel = new System.Windows.Forms.Label(); + this.ValeLabel = new System.Windows.Forms.Label(); + this.ValueBox = new System.Windows.Forms.TextBox(); + this.DataTypeGroupBox.SuspendLayout(); + this.DataSizeBox.SuspendLayout(); + this.EndianBox.SuspendLayout(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(9, 33); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(48, 13); + this.label1.TabIndex = 0; + this.label1.Text = "Address:"; + // + // AddressBox + // + this.AddressBox.Location = new System.Drawing.Point(60, 30); + this.AddressBox.Name = "AddressBox"; + this.AddressBox.Size = new System.Drawing.Size(100, 20); + this.AddressBox.TabIndex = 2; + this.AddressBox.Text = "0000"; + // + // DataTypeGroupBox + // + this.DataTypeGroupBox.Controls.Add(this.HexRadio); + this.DataTypeGroupBox.Controls.Add(this.UnsignedRadio); + this.DataTypeGroupBox.Controls.Add(this.SignedRadio); + this.DataTypeGroupBox.Location = new System.Drawing.Point(12, 98); + this.DataTypeGroupBox.Name = "DataTypeGroupBox"; + this.DataTypeGroupBox.Size = new System.Drawing.Size(95, 79); + this.DataTypeGroupBox.TabIndex = 4; + this.DataTypeGroupBox.TabStop = false; + this.DataTypeGroupBox.Text = "Data Type"; + // + // HexRadio + // + this.HexRadio.AutoSize = true; + this.HexRadio.Location = new System.Drawing.Point(4, 51); + this.HexRadio.Name = "HexRadio"; + this.HexRadio.Size = new System.Drawing.Size(86, 17); + this.HexRadio.TabIndex = 2; + this.HexRadio.Text = "Hexadecimal"; + this.HexRadio.UseVisualStyleBackColor = true; + // + // UnsignedRadio + // + this.UnsignedRadio.AutoSize = true; + this.UnsignedRadio.Checked = true; + this.UnsignedRadio.Location = new System.Drawing.Point(4, 34); + this.UnsignedRadio.Name = "UnsignedRadio"; + this.UnsignedRadio.Size = new System.Drawing.Size(70, 17); + this.UnsignedRadio.TabIndex = 1; + this.UnsignedRadio.TabStop = true; + this.UnsignedRadio.Text = "Unsigned"; + this.UnsignedRadio.UseVisualStyleBackColor = true; + // + // SignedRadio + // + this.SignedRadio.AutoSize = true; + this.SignedRadio.Location = new System.Drawing.Point(4, 17); + this.SignedRadio.Name = "SignedRadio"; + this.SignedRadio.Size = new System.Drawing.Size(58, 17); + this.SignedRadio.TabIndex = 0; + this.SignedRadio.Text = "Signed"; + this.SignedRadio.UseVisualStyleBackColor = true; + // + // DataSizeBox + // + this.DataSizeBox.Controls.Add(this.Byte4Radio); + this.DataSizeBox.Controls.Add(this.Byte2Radio); + this.DataSizeBox.Controls.Add(this.Byte1Radio); + this.DataSizeBox.Location = new System.Drawing.Point(115, 98); + this.DataSizeBox.Name = "DataSizeBox"; + this.DataSizeBox.Size = new System.Drawing.Size(83, 79); + this.DataSizeBox.TabIndex = 5; + this.DataSizeBox.TabStop = false; + this.DataSizeBox.Text = "Data Size:"; + // + // Byte4Radio + // + this.Byte4Radio.AutoSize = true; + this.Byte4Radio.Location = new System.Drawing.Point(5, 51); + this.Byte4Radio.Name = "Byte4Radio"; + this.Byte4Radio.Size = new System.Drawing.Size(60, 17); + this.Byte4Radio.TabIndex = 2; + this.Byte4Radio.Text = "4 Bytes"; + this.Byte4Radio.UseVisualStyleBackColor = true; + // + // Byte2Radio + // + this.Byte2Radio.AutoSize = true; + this.Byte2Radio.Location = new System.Drawing.Point(5, 34); + this.Byte2Radio.Name = "Byte2Radio"; + this.Byte2Radio.Size = new System.Drawing.Size(60, 17); + this.Byte2Radio.TabIndex = 1; + this.Byte2Radio.Text = "2 Bytes"; + this.Byte2Radio.UseVisualStyleBackColor = true; + // + // Byte1Radio + // + this.Byte1Radio.AutoSize = true; + this.Byte1Radio.Checked = true; + this.Byte1Radio.Location = new System.Drawing.Point(5, 17); + this.Byte1Radio.Name = "Byte1Radio"; + this.Byte1Radio.Size = new System.Drawing.Size(55, 17); + this.Byte1Radio.TabIndex = 0; + this.Byte1Radio.TabStop = true; + this.Byte1Radio.Text = "1 Byte"; + this.Byte1Radio.UseVisualStyleBackColor = true; + // + // EndianBox + // + this.EndianBox.Controls.Add(this.LittleEndianRadio); + this.EndianBox.Controls.Add(this.BigEndianRadio); + this.EndianBox.Location = new System.Drawing.Point(12, 183); + this.EndianBox.Name = "EndianBox"; + this.EndianBox.Size = new System.Drawing.Size(117, 55); + this.EndianBox.TabIndex = 6; + this.EndianBox.TabStop = false; + this.EndianBox.Text = "Endian"; + // + // LittleEndianRadio + // + this.LittleEndianRadio.AutoSize = true; + this.LittleEndianRadio.Location = new System.Drawing.Point(4, 35); + this.LittleEndianRadio.Name = "LittleEndianRadio"; + this.LittleEndianRadio.Size = new System.Drawing.Size(83, 17); + this.LittleEndianRadio.TabIndex = 1; + this.LittleEndianRadio.Text = "Little Endian"; + this.LittleEndianRadio.UseVisualStyleBackColor = true; + // + // BigEndianRadio + // + this.BigEndianRadio.AutoSize = true; + this.BigEndianRadio.Checked = true; + this.BigEndianRadio.Location = new System.Drawing.Point(4, 18); + this.BigEndianRadio.Name = "BigEndianRadio"; + this.BigEndianRadio.Size = new System.Drawing.Size(76, 17); + this.BigEndianRadio.TabIndex = 0; + this.BigEndianRadio.TabStop = true; + this.BigEndianRadio.Text = "Big Endian"; + this.BigEndianRadio.UseVisualStyleBackColor = true; + // + // OK + // + this.OK.Location = new System.Drawing.Point(12, 253); + this.OK.Name = "OK"; + this.OK.Size = new System.Drawing.Size(75, 23); + this.OK.TabIndex = 7; + this.OK.Text = "&Poke"; + this.OK.UseVisualStyleBackColor = true; + this.OK.Click += new System.EventHandler(this.OK_Click); + // + // Cancel + // + this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.Cancel.Location = new System.Drawing.Point(123, 253); + this.Cancel.Name = "Cancel"; + this.Cancel.Size = new System.Drawing.Size(75, 23); + this.Cancel.TabIndex = 8; + this.Cancel.Text = "Close"; + this.Cancel.UseVisualStyleBackColor = true; + this.Cancel.Click += new System.EventHandler(this.Cancel_Click); + // + // OutputLabel + // + this.OutputLabel.AutoSize = true; + this.OutputLabel.Location = new System.Drawing.Point(12, 7); + this.OutputLabel.Name = "OutputLabel"; + this.OutputLabel.Size = new System.Drawing.Size(129, 13); + this.OutputLabel.TabIndex = 9; + this.OutputLabel.Text = "Enter an address to poke:"; + // + // ValeLabel + // + this.ValeLabel.AutoSize = true; + this.ValeLabel.Location = new System.Drawing.Point(9, 60); + this.ValeLabel.Name = "ValeLabel"; + this.ValeLabel.Size = new System.Drawing.Size(37, 13); + this.ValeLabel.TabIndex = 10; + this.ValeLabel.Text = "Value:"; + // + // ValueBox + // + this.ValueBox.Location = new System.Drawing.Point(60, 57); + this.ValueBox.Name = "ValueBox"; + this.ValueBox.Size = new System.Drawing.Size(100, 20); + this.ValueBox.TabIndex = 11; + this.ValueBox.Text = "0000"; + // + // RamPoke + // + this.AcceptButton = this.OK; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.Cancel; + this.ClientSize = new System.Drawing.Size(213, 292); + this.Controls.Add(this.ValueBox); + this.Controls.Add(this.ValeLabel); + this.Controls.Add(this.OutputLabel); + this.Controls.Add(this.Cancel); + this.Controls.Add(this.OK); + this.Controls.Add(this.EndianBox); + this.Controls.Add(this.DataSizeBox); + this.Controls.Add(this.DataTypeGroupBox); + this.Controls.Add(this.AddressBox); + this.Controls.Add(this.label1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "RamPoke"; + this.Text = "Ram Poke"; + this.Load += new System.EventHandler(this.RamPoke_Load); + this.DataTypeGroupBox.ResumeLayout(false); + this.DataTypeGroupBox.PerformLayout(); + this.DataSizeBox.ResumeLayout(false); + this.DataSizeBox.PerformLayout(); + this.EndianBox.ResumeLayout(false); + this.EndianBox.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox AddressBox; + private System.Windows.Forms.GroupBox DataTypeGroupBox; + private System.Windows.Forms.RadioButton SignedRadio; + private System.Windows.Forms.RadioButton UnsignedRadio; + private System.Windows.Forms.RadioButton HexRadio; + private System.Windows.Forms.GroupBox DataSizeBox; + private System.Windows.Forms.RadioButton Byte1Radio; + private System.Windows.Forms.RadioButton Byte2Radio; + private System.Windows.Forms.RadioButton Byte4Radio; + private System.Windows.Forms.GroupBox EndianBox; + private System.Windows.Forms.RadioButton BigEndianRadio; + private System.Windows.Forms.RadioButton LittleEndianRadio; + private System.Windows.Forms.Button OK; + private System.Windows.Forms.Button Cancel; + private System.Windows.Forms.Label OutputLabel; + private System.Windows.Forms.Label ValeLabel; + private System.Windows.Forms.TextBox ValueBox; + } +} \ No newline at end of file diff --git a/BizHawk.MultiClient/tools/RamPoke.cs b/BizHawk.MultiClient/tools/RamPoke.cs new file mode 100644 index 0000000000..ba953c355e --- /dev/null +++ b/BizHawk.MultiClient/tools/RamPoke.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.Globalization; + +namespace BizHawk.MultiClient +{ + public partial class RamPoke : Form + { + //TODO: + //If signed/unsigned/hex radios selected, auto-change the value box + //Checked signed/u/h value on RamPoke_Load and set value appopriately + public Watch watch = new Watch(); + public Point location = new Point(); + + public RamPoke() + { + InitializeComponent(); + } + + public void SetWatchObject(Watch w) + { + watch = w; + } + + private void RamPoke_Load(object sender, EventArgs e) + { + SetTypeRadio(watch.type); + SetSignedRadio(watch.signed); + if (watch.bigendian == true) + BigEndianRadio.Checked = true; + else + LittleEndianRadio.Checked = true; + AddressBox.Text = String.Format("{0:X}", watch.address); + ValueBox.Text = watch.value.ToString(); + if (location.X > 0 && location.Y > 0) + this.Location = location; + + } + + private void SetTypeRadio(atype a) + { + switch (a) + { + case atype.BYTE: + Byte1Radio.Checked = true; + break; + case atype.WORD: + Byte2Radio.Checked = true; + break; + case atype.DWORD: + Byte4Radio.Checked = true; + break; + default: + break; + } + } + + private void SetSignedRadio(asigned a) + { + switch (a) + { + case asigned.SIGNED: + SignedRadio.Checked = true; + break; + case asigned.UNSIGNED: + UnsignedRadio.Checked = true; + break; + case asigned.HEX: + HexRadio.Checked = true; + break; + default: + break; + } + } + + private void RamPokeLoaddddddd(object sender, EventArgs e) + { + /* + if (!customSetup) + { + Watch w = new Watch(); + SetTypeRadio(w.type); + SetSignedRadio(w.signed); + + if (w.bigendian == true) + BigEndianRadio.Checked = true; + else + LittleEndianRadio.Checked = true; + } + if (location.X > 0 && location.Y > 0) + this.Location = location; + * */ + } + + private void Cancel_Click(object sender, EventArgs e) + { + this.Close(); + } + + private void OK_Click(object sender, EventArgs e) + { + //Put user settings in the watch file + + //TODO, check the user address so this can be used as a generic dialog: + //watch.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber); + //TODO: validate input + + //TODO: check all the users choices here too + /* + if (SignedRadio.Checked) + watch.signed = asigned.SIGNED; + else if (UnsignedRadio.Checked) + watch.signed = asigned.UNSIGNED; + else if (HexRadio.Checked) + watch.signed = asigned.HEX; + + if (Byte1Radio.Checked) + watch.type = atype.BYTE; + else if (Byte2Radio.Checked) + watch.type = atype.WORD; + else if (Byte4Radio.Checked) + watch.type = atype.DWORD; + + if (BigEndianRadio.Checked) + watch.bigendian = true; + else if (LittleEndianRadio.Checked) + watch.bigendian = false; + */ + + watch.value = int.Parse(ValueBox.Text); + + //TODO: Try/Catch this? Seems destined for failures + Global.Emulator.MainMemory.PokeByte(watch.address, (byte)watch.value); + //TODO: format value based on watch.type + OutputLabel.Text = watch.value.ToString() + " written to " + String.Format("{0:X}", watch.address); + } + + } +} diff --git a/BizHawk.MultiClient/tools/RamPoke.resx b/BizHawk.MultiClient/tools/RamPoke.resx new file mode 100644 index 0000000000..96b4b0e227 --- /dev/null +++ b/BizHawk.MultiClient/tools/RamPoke.resx @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAABMLAAATCwAAAAAAAAAA + AAAAAAAAAAAAAAAAAADp6en/AAAA/wAAAAAAAAD/3Nzc/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAKioq/wAAAAAAAAAAAAAAAD4+Pv8AAAAAAAAAAAAAAAAA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AA/7e4tv/o6ef/AAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALy8vP8AAAD/AAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADo6Oj/AAAA/wAAAAAAAAAAAAAAAAAA + AAAAAAAA5P8AAO7/AADl/wAA+P8AAPj/AAD4/wAA/H8AAPx/AAD+fwAA/j8AAP8/AAD/HwAA/x8AAP+P + AAD/nwAA/58AAA== + + + \ No newline at end of file diff --git a/BizHawk.MultiClient/tools/RamWatch.cs b/BizHawk.MultiClient/tools/RamWatch.cs index 2d05691360..5513f98b0a 100644 --- a/BizHawk.MultiClient/tools/RamWatch.cs +++ b/BizHawk.MultiClient/tools/RamWatch.cs @@ -26,7 +26,8 @@ namespace BizHawk.MultiClient //Multiselect is enabled but only one row can be highlighted by the user //Make it clear that on edit/new/duplicate watch, address is hex //Validate address box as legit hex number - //Implement PokeAddress() + //When using ListView index, validate the user has selected one! + int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired int defaultHeight; List watchList = new List(); @@ -733,8 +734,10 @@ namespace BizHawk.MultiClient private void PokeAddress() { ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices; - Poke p = new Poke(); - p.PokeAddress(watchList[indexes[0]]); + RamPoke p = new RamPoke(); + p.SetWatchObject(watchList[indexes[0]]); + p.location = GetPromptPoint(); + p.ShowDialog(); } private void pokeAddressToolStripMenuItem_Click(object sender, EventArgs e)