Ram Search - fix some problems with specific value, float is still broken but fixed points should now work

This commit is contained in:
adelikat 2013-09-28 20:20:43 +00:00
parent 06330c1c12
commit 15ad1d3234
4 changed files with 73 additions and 14 deletions

View File

@ -225,8 +225,56 @@ namespace BizHawk.MultiClient
UpdateUndoToolBarButtons();
}
private int? CompareToValue
{
get
{
if (PreviousValueRadio.Checked)
{
return null;
}
else if (SpecificValueRadio.Checked)
{
return SpecificValueBox.ToRawInt();
}
else if (SpecificAddressRadio.Checked)
{
return SpecificAddressBox.ToRawInt();
}
else if (NumberOfChangesRadio.Checked)
{
return NumberOfChangesBox.ToRawInt();
}
else if (DifferenceRadio.Checked)
{
return DifferenceBox.ToRawInt();
}
else
{
return null;
}
}
}
private int? DifferentByValue
{
get
{
if (DifferentByRadio.Checked)
{
return DifferentByBox.ToRawInt();
}
else
{
return null;
}
}
}
private void DoSearch()
{
Searches.CompareValue = CompareToValue;
Searches.DifferentBy = DifferentByValue;
int removed = Searches.DoSearch();
SetTotal();
WatchListView.ItemCount = Searches.Count;
@ -1176,7 +1224,7 @@ namespace BizHawk.MultiClient
private void CompareToValue_TextChanged(object sender, EventArgs e)
{
SetCompareValue((sender as INumberBox).ToInt());
SetCompareValue((sender as INumberBox).ToRawInt());
}
#endregion
@ -1234,7 +1282,7 @@ namespace BizHawk.MultiClient
{
if (!String.IsNullOrWhiteSpace(DifferentByBox.Text))
{
Searches.DifferentBy = DifferentByBox.ToInt();
Searches.DifferentBy = DifferentByBox.ToRawInt();
}
else
{

View File

@ -217,7 +217,7 @@ namespace BizHawk.MultiClient
default:
case Mode.New:
var domain = Global.Emulator.MemoryDomains.FirstOrDefault(d => d.Name == DomainDropDown.SelectedItem.ToString());
var address = AddressBox.ToInt();
var address = AddressBox.ToRawInt();
var notes = NotesBox.Text;
var type = Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString());
var bigendian = BigEndianCheckBox.Checked;
@ -285,7 +285,7 @@ namespace BizHawk.MultiClient
string tempNotes = _watchList[i].Notes;
_watchList[i] = Watch.GenerateWatch(
_watchList[i].Domain,
_watchList.Count == 1 ? AddressBox.ToInt() : _watchList[i].Address.Value,
_watchList.Count == 1 ? AddressBox.ToRawInt() : _watchList[i].Address.Value,
size,
_watchList[i].Type,
_watchList[i].Notes,

View File

@ -177,7 +177,7 @@ namespace BizHawk.MultiClient
{
if (e.KeyCode == Keys.Up)
{
int val = ToInt();
int val = ToRawInt();
val++;
switch (_type)
@ -195,7 +195,7 @@ namespace BizHawk.MultiClient
}
else if (e.KeyCode == Keys.Down)
{
int val = ToInt();
int val = ToRawInt();
val--;
switch (_type)
@ -225,7 +225,7 @@ namespace BizHawk.MultiClient
}
}
public int ToInt()
public int ToRawInt()
{
if (String.IsNullOrWhiteSpace(Text))
{
@ -236,11 +236,22 @@ namespace BizHawk.MultiClient
switch (_type)
{
default:
case Watch.DisplayType.Signed:
return int.Parse(Text);
case Watch.DisplayType.Unsigned:
return (int)uint.Parse(Text);
case Watch.DisplayType.Binary:
return Convert.ToInt32(Text, 2);
case Watch.DisplayType.Hex:
return int.Parse(Text, NumberStyles.HexNumber);
case Watch.DisplayType.FixedPoint_12_4:
return (int)(double.Parse(Text) * 16.0);
case Watch.DisplayType.FixedPoint_20_12:
return (int)(double.Parse(Text) * 4096.0);
case Watch.DisplayType.Float:
float val = float.Parse(Text);
byte[] bytes = BitConverter.GetBytes(val);
return BitConverter.ToInt32(bytes, 0);
}
}
}

View File

@ -6,7 +6,7 @@ namespace BizHawk
{
public interface INumberBox
{
int ToInt();
int ToRawInt();
}
public class HexTextBox : TextBox, INumberBox
@ -34,7 +34,7 @@ namespace BizHawk
{
if (InputValidate.IsValidHexNumber(Text))
{
int val = ToInt();
int val = ToRawInt();
val++;
string formatstr = "{0:X" + MaxLength.ToString() + "}";
Text = String.Format(formatstr, val);
@ -44,7 +44,7 @@ namespace BizHawk
{
if (InputValidate.IsValidHexNumber(Text))
{
int val = ToInt();
int val = ToRawInt();
val--;
string formatstr = "{0:X" + MaxLength.ToString() + "}";
Text = String.Format(formatstr, val);
@ -64,7 +64,7 @@ namespace BizHawk
}
}
public int ToInt()
public int ToRawInt()
{
if (String.IsNullOrWhiteSpace(Text))
{
@ -102,7 +102,7 @@ namespace BizHawk
{
if (InputValidate.IsValidUnsignedNumber(Text))
{
int val = ToInt();
int val = ToRawInt();
val++;
Text = val.ToString();
}
@ -111,7 +111,7 @@ namespace BizHawk
{
if (InputValidate.IsValidUnsignedNumber(Text))
{
int val = ToInt();
int val = ToRawInt();
val--;
Text = val.ToString();
}
@ -130,7 +130,7 @@ namespace BizHawk
}
}
public int ToInt()
public int ToRawInt()
{
if (String.IsNullOrWhiteSpace(Text))
{