From 67a9f86c78f33a4f35dce38d415270189cf2a212 Mon Sep 17 00:00:00 2001 From: brandman211 Date: Thu, 7 Jun 2012 23:17:22 +0000 Subject: [PATCH] -Fixed GetSpecificValue(), which means that signed searching works now. -Upon changing data type, the contents of the specific value box converts accordingly. --- BizHawk.MultiClient/tools/RamSearch.cs | 56 ++++++++++++++------------ BizHawk.MultiClient/tools/Watch.cs | 4 +- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/BizHawk.MultiClient/tools/RamSearch.cs b/BizHawk.MultiClient/tools/RamSearch.cs index 6e976f6cfc..ab652c5e5f 100644 --- a/BizHawk.MultiClient/tools/RamSearch.cs +++ b/BizHawk.MultiClient/tools/RamSearch.cs @@ -616,31 +616,10 @@ namespace BizHawk.MultiClient } if (column == 2) { - if (searchList[index].signed == asigned.UNSIGNED) - { - if (Global.Config.RamSearchPreviousAs == 2) //If prev frame - text = searchList[index].prev.ToString(); - else - text = prevList[index].value.ToString(); - } - else if (searchList[index].signed == asigned.SIGNED) - { - if (Global.Config.RamSearchPreviousAs == 2) //If prev frame - text = ((sbyte)searchList[index].prev).ToString(); - else - text = ((sbyte)prevList[index].value).ToString(); - } - else if (searchList[index].signed == asigned.HEX) - { - if (Global.Config.RamSearchPreviousAs == 2) //If prev frame - { - text = searchList[index].PrevToString(); - } - else - { - text = prevList[index].ValueToString(); - } - } + if (Global.Config.RamSearchPreviousAs == 2) //If prev frame + text = searchList[index].PrevToString(); + else + text = prevList[index].ValueToString(); } if (column == 3) { @@ -914,7 +893,20 @@ namespace BizHawk.MultiClient case asigned.SIGNED: i = InputValidate.IsValidSignedNumber(SpecificValueBox.Text); if (!i) return -99999999; - return (int)Int64.Parse(SpecificValueBox.Text); + int real = (int)Int64.Parse(SpecificValueBox.Text); + switch (GetDataSize()) + { + case atype.BYTE: + real = (int)(byte)real; + break; + case atype.WORD: + real = (int)(ushort)real; + break; + case atype.DWORD: + real = (int)(uint)real; + break; + } + return real; case asigned.HEX: i = InputValidate.IsValidHexNumber(SpecificValueBox.Text); if (!i) return -99999999; @@ -1100,6 +1092,10 @@ namespace BizHawk.MultiClient private void signedToolStripMenuItem_Click(object sender, EventArgs e) { + Watch specificValue = new Watch(); + specificValue.value = GetSpecificValue(); + specificValue.signed = asigned.SIGNED; + SpecificValueBox.Text = specificValue.ValueToString(); unsignedToolStripMenuItem.Checked = false; signedToolStripMenuItem.Checked = true; hexadecimalToolStripMenuItem.Checked = false; @@ -1110,6 +1106,10 @@ namespace BizHawk.MultiClient private void unsignedToolStripMenuItem_Click(object sender, EventArgs e) { + Watch specificValue = new Watch(); + specificValue.value = GetSpecificValue(); + specificValue.signed = asigned.UNSIGNED; + SpecificValueBox.Text = specificValue.ValueToString(); unsignedToolStripMenuItem.Checked = true; signedToolStripMenuItem.Checked = false; hexadecimalToolStripMenuItem.Checked = false; @@ -1120,6 +1120,10 @@ namespace BizHawk.MultiClient private void hexadecimalToolStripMenuItem_Click(object sender, EventArgs e) { + Watch specificValue = new Watch(); + specificValue.value = GetSpecificValue(); + specificValue.signed = asigned.HEX; + SpecificValueBox.Text = specificValue.ValueToString(); unsignedToolStripMenuItem.Checked = false; signedToolStripMenuItem.Checked = false; hexadecimalToolStripMenuItem.Checked = true; diff --git a/BizHawk.MultiClient/tools/Watch.cs b/BizHawk.MultiClient/tools/Watch.cs index ec2aa73872..82882eb759 100644 --- a/BizHawk.MultiClient/tools/Watch.cs +++ b/BizHawk.MultiClient/tools/Watch.cs @@ -280,7 +280,7 @@ namespace BizHawk.MultiClient default: case asigned.UNSIGNED: switch (type) - { + { default: case atype.BYTE: return ((byte)value).ToString(); @@ -288,7 +288,7 @@ namespace BizHawk.MultiClient return ((ushort)value).ToString(); case atype.DWORD: return ((uint)value).ToString(); - } + } } } }