diff --git a/BizHawk.MultiClient/tools/RamPoke.cs b/BizHawk.MultiClient/tools/RamPoke.cs index a4cce8f0d2..96b0f955b6 100644 --- a/BizHawk.MultiClient/tools/RamPoke.cs +++ b/BizHawk.MultiClient/tools/RamPoke.cs @@ -137,7 +137,16 @@ namespace BizHawk.MultiClient } break; case asigned.SIGNED: - //TODO + if (InputValidate.IsValidSignedNumber(ValueBox.Text)) + { + watch.value = int.Parse(ValueBox.Text); + } + else + { + MessageBox.Show("Invalid Address, must be a valid number number", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Error); + ValueBox.Focus(); + ValueBox.SelectAll(); + } break; case asigned.HEX: if (InputValidate.IsValidHexNumber(ValueBox.Text)) diff --git a/BizHawk.Util/InputValidate.cs b/BizHawk.Util/InputValidate.cs index 111fd4543b..ec68ef871f 100644 --- a/BizHawk.Util/InputValidate.cs +++ b/BizHawk.Util/InputValidate.cs @@ -27,6 +27,37 @@ namespace BizHawk return true; } + /// + /// Validates all chars are 0-9 or a dash as the first value + /// + /// + /// + public static bool IsValidSignedNumber(string Str) + { + char[] input = (Str.ToCharArray()); + ASCIIEncoding AE = new ASCIIEncoding(); + // Check each character in the new label to determine if it is a number. + for (int x = 0; x < input.Length; x++) + { + // Encode the character from the character array to its ASCII code. + byte[] bc = AE.GetBytes(input[x].ToString()); + + // Determine if the ASCII code is within the valid range of numerical values. + if (bc[0] > 58) + return false; + + if (bc[0] < 47) + { + if (bc[0] == 45 && x == 0) + continue; + else + return false; + } + + } + return true; + } + /// /// validates is a Hex number 0-9, A-F (must be capital letters) ///