Ram Search - some nitpicky Oops refactoring and fix unsigned 4 byte comparisons
This commit is contained in:
parent
a1c322bc91
commit
0c850ef533
|
@ -13,11 +13,15 @@ namespace BizHawk.MultiClient
|
||||||
public enum ComparisonOperator { Equal, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual, NotEqual, DifferentBy };
|
public enum ComparisonOperator { Equal, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual, NotEqual, DifferentBy };
|
||||||
public enum Compare { Previous, SpecificValue, SpecificAddress, Changes, Difference }
|
public enum Compare { Previous, SpecificValue, SpecificAddress, Changes, Difference }
|
||||||
|
|
||||||
public Compare CompareTo = Compare.Previous;
|
|
||||||
public int? CompareValue = null;
|
|
||||||
public ComparisonOperator Operator = ComparisonOperator.Equal;
|
|
||||||
public int? DifferentBy = null;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private int? _differentBy = null;
|
||||||
|
|
||||||
|
|
||||||
|
private Compare _compareTo = Compare.Previous;
|
||||||
|
private long? _compareValue = null;
|
||||||
|
private ComparisonOperator _operator = ComparisonOperator.Equal;
|
||||||
|
|
||||||
private List<IMiniWatch> _watchList = new List<IMiniWatch>();
|
private List<IMiniWatch> _watchList = new List<IMiniWatch>();
|
||||||
private Settings _settings;
|
private Settings _settings;
|
||||||
|
@ -132,7 +136,7 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
int before = _watchList.Count;
|
int before = _watchList.Count;
|
||||||
|
|
||||||
switch (CompareTo)
|
switch (_compareTo)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case RamSearchEngine.Compare.Previous:
|
case RamSearchEngine.Compare.Previous:
|
||||||
|
@ -167,7 +171,7 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
public bool Preview(int address)
|
public bool Preview(int address)
|
||||||
{
|
{
|
||||||
switch (CompareTo)
|
switch (_compareTo)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case RamSearchEngine.Compare.Previous:
|
case RamSearchEngine.Compare.Previous:
|
||||||
|
@ -193,6 +197,30 @@ namespace BizHawk.MultiClient
|
||||||
get { return _settings.Domain; }
|
get { return _settings.Domain; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Compare CompareTo
|
||||||
|
{
|
||||||
|
get { return _compareTo; }
|
||||||
|
set { _compareTo = value; } //TODO: check to see if this value is valid based on mode
|
||||||
|
}
|
||||||
|
|
||||||
|
public long? CompareValue
|
||||||
|
{
|
||||||
|
get { return _compareValue; }
|
||||||
|
set { _compareValue = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public ComparisonOperator Operator
|
||||||
|
{
|
||||||
|
get { return _operator; }
|
||||||
|
set { _operator = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int? DifferentBy
|
||||||
|
{
|
||||||
|
get { return _differentBy; }
|
||||||
|
set { _differentBy = value; }
|
||||||
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (_settings.Mode == Settings.SearchMode.Detailed)
|
if (_settings.Mode == Settings.SearchMode.Detailed)
|
||||||
|
@ -415,7 +443,7 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
private IEnumerable<IMiniWatch> ComparePrevious(IEnumerable<IMiniWatch> watchList)
|
private IEnumerable<IMiniWatch> ComparePrevious(IEnumerable<IMiniWatch> watchList)
|
||||||
{
|
{
|
||||||
switch (Operator)
|
switch (_operator)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case ComparisonOperator.Equal:
|
case ComparisonOperator.Equal:
|
||||||
|
@ -431,9 +459,9 @@ namespace BizHawk.MultiClient
|
||||||
case ComparisonOperator.LessThanEqual:
|
case ComparisonOperator.LessThanEqual:
|
||||||
return watchList.Where(x => GetValue(x.Address) <= x.Previous);
|
return watchList.Where(x => GetValue(x.Address) <= x.Previous);
|
||||||
case ComparisonOperator.DifferentBy:
|
case ComparisonOperator.DifferentBy:
|
||||||
if (DifferentBy.HasValue)
|
if (_differentBy.HasValue)
|
||||||
{
|
{
|
||||||
return watchList.Where(x => (GetValue(x.Address) + DifferentBy.Value == x.Previous) || (GetValue(x.Address) - DifferentBy.Value == x.Previous));
|
return watchList.Where(x => (GetValue(x.Address) + _differentBy.Value == x.Previous) || (GetValue(x.Address) - _differentBy.Value == x.Previous));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -445,27 +473,27 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
private IEnumerable<IMiniWatch> CompareSpecificValue(IEnumerable<IMiniWatch> watchList)
|
private IEnumerable<IMiniWatch> CompareSpecificValue(IEnumerable<IMiniWatch> watchList)
|
||||||
{
|
{
|
||||||
if (CompareValue.HasValue)
|
if (_compareValue.HasValue)
|
||||||
{
|
{
|
||||||
switch (Operator)
|
switch (_operator)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case ComparisonOperator.Equal:
|
case ComparisonOperator.Equal:
|
||||||
return watchList.Where(x => GetValue(x.Address) == CompareValue.Value);
|
return watchList.Where(x => GetValue(x.Address) == _compareValue.Value);
|
||||||
case ComparisonOperator.NotEqual:
|
case ComparisonOperator.NotEqual:
|
||||||
return watchList.Where(x => GetValue(x.Address) != CompareValue.Value);
|
return watchList.Where(x => GetValue(x.Address) != _compareValue.Value);
|
||||||
case ComparisonOperator.GreaterThan:
|
case ComparisonOperator.GreaterThan:
|
||||||
return watchList.Where(x => GetValue(x.Address) > CompareValue.Value);
|
return watchList.Where(x => GetValue(x.Address) > _compareValue.Value);
|
||||||
case ComparisonOperator.GreaterThanEqual:
|
case ComparisonOperator.GreaterThanEqual:
|
||||||
return watchList.Where(x => GetValue(x.Address) >= CompareValue.Value);
|
return watchList.Where(x => GetValue(x.Address) >= _compareValue.Value);
|
||||||
case ComparisonOperator.LessThan:
|
case ComparisonOperator.LessThan:
|
||||||
return watchList.Where(x => GetValue(x.Address) < CompareValue.Value);
|
return watchList.Where(x => GetValue(x.Address) < _compareValue.Value);
|
||||||
case ComparisonOperator.LessThanEqual:
|
case ComparisonOperator.LessThanEqual:
|
||||||
return watchList.Where(x => GetValue(x.Address) <= CompareValue.Value);
|
return watchList.Where(x => GetValue(x.Address) <= _compareValue.Value);
|
||||||
case ComparisonOperator.DifferentBy:
|
case ComparisonOperator.DifferentBy:
|
||||||
if (DifferentBy.HasValue)
|
if (_differentBy.HasValue)
|
||||||
{
|
{
|
||||||
return watchList.Where(x => (GetValue(x.Address) + DifferentBy.Value == CompareValue.Value) || (GetValue(x.Address) - DifferentBy.Value == CompareValue.Value));
|
return watchList.Where(x => (GetValue(x.Address) + _differentBy.Value == _compareValue.Value) || (GetValue(x.Address) - _differentBy.Value == _compareValue.Value));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -481,27 +509,27 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
private IEnumerable<IMiniWatch> CompareSpecificAddress(IEnumerable<IMiniWatch> watchList)
|
private IEnumerable<IMiniWatch> CompareSpecificAddress(IEnumerable<IMiniWatch> watchList)
|
||||||
{
|
{
|
||||||
if (CompareValue.HasValue)
|
if (_compareValue.HasValue)
|
||||||
{
|
{
|
||||||
switch (Operator)
|
switch (_operator)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case ComparisonOperator.Equal:
|
case ComparisonOperator.Equal:
|
||||||
return watchList.Where(x => x.Address == CompareValue.Value);
|
return watchList.Where(x => x.Address == _compareValue.Value);
|
||||||
case ComparisonOperator.NotEqual:
|
case ComparisonOperator.NotEqual:
|
||||||
return watchList.Where(x => x.Address != CompareValue.Value);
|
return watchList.Where(x => x.Address != _compareValue.Value);
|
||||||
case ComparisonOperator.GreaterThan:
|
case ComparisonOperator.GreaterThan:
|
||||||
return watchList.Where(x => x.Address > CompareValue.Value);
|
return watchList.Where(x => x.Address > _compareValue.Value);
|
||||||
case ComparisonOperator.GreaterThanEqual:
|
case ComparisonOperator.GreaterThanEqual:
|
||||||
return watchList.Where(x => x.Address >= CompareValue.Value);
|
return watchList.Where(x => x.Address >= _compareValue.Value);
|
||||||
case ComparisonOperator.LessThan:
|
case ComparisonOperator.LessThan:
|
||||||
return watchList.Where(x => x.Address < CompareValue.Value);
|
return watchList.Where(x => x.Address < _compareValue.Value);
|
||||||
case ComparisonOperator.LessThanEqual:
|
case ComparisonOperator.LessThanEqual:
|
||||||
return watchList.Where(x => x.Address <= CompareValue.Value);
|
return watchList.Where(x => x.Address <= _compareValue.Value);
|
||||||
case ComparisonOperator.DifferentBy:
|
case ComparisonOperator.DifferentBy:
|
||||||
if (DifferentBy.HasValue)
|
if (_differentBy.HasValue)
|
||||||
{
|
{
|
||||||
return watchList.Where(x => (x.Address + DifferentBy.Value == CompareValue.Value) || (x.Address - DifferentBy.Value == CompareValue.Value));
|
return watchList.Where(x => (x.Address + _differentBy.Value == _compareValue.Value) || (x.Address - _differentBy.Value == _compareValue.Value));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -517,47 +545,47 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
private IEnumerable<IMiniWatch> CompareChanges(IEnumerable<IMiniWatch> watchList)
|
private IEnumerable<IMiniWatch> CompareChanges(IEnumerable<IMiniWatch> watchList)
|
||||||
{
|
{
|
||||||
if (_settings.Mode == Settings.SearchMode.Detailed && CompareValue.HasValue)
|
if (_settings.Mode == Settings.SearchMode.Detailed && _compareValue.HasValue)
|
||||||
{
|
{
|
||||||
switch (Operator)
|
switch (_operator)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case ComparisonOperator.Equal:
|
case ComparisonOperator.Equal:
|
||||||
return watchList
|
return watchList
|
||||||
.Cast<IMiniWatchDetails>()
|
.Cast<IMiniWatchDetails>()
|
||||||
.Where(x => x.ChangeCount == CompareValue.Value)
|
.Where(x => x.ChangeCount == _compareValue.Value)
|
||||||
.Cast<IMiniWatch>();
|
.Cast<IMiniWatch>();
|
||||||
case ComparisonOperator.NotEqual:
|
case ComparisonOperator.NotEqual:
|
||||||
return watchList
|
return watchList
|
||||||
.Cast<IMiniWatchDetails>()
|
.Cast<IMiniWatchDetails>()
|
||||||
.Where(x => x.ChangeCount != CompareValue.Value)
|
.Where(x => x.ChangeCount != _compareValue.Value)
|
||||||
.Cast<IMiniWatch>();
|
.Cast<IMiniWatch>();
|
||||||
case ComparisonOperator.GreaterThan:
|
case ComparisonOperator.GreaterThan:
|
||||||
return watchList
|
return watchList
|
||||||
.Cast<IMiniWatchDetails>()
|
.Cast<IMiniWatchDetails>()
|
||||||
.Where(x => x.ChangeCount > CompareValue.Value)
|
.Where(x => x.ChangeCount > _compareValue.Value)
|
||||||
.Cast<IMiniWatch>();
|
.Cast<IMiniWatch>();
|
||||||
case ComparisonOperator.GreaterThanEqual:
|
case ComparisonOperator.GreaterThanEqual:
|
||||||
return watchList
|
return watchList
|
||||||
.Cast<IMiniWatchDetails>()
|
.Cast<IMiniWatchDetails>()
|
||||||
.Where(x => x.ChangeCount >= CompareValue.Value)
|
.Where(x => x.ChangeCount >= _compareValue.Value)
|
||||||
.Cast<IMiniWatch>();
|
.Cast<IMiniWatch>();
|
||||||
case ComparisonOperator.LessThan:
|
case ComparisonOperator.LessThan:
|
||||||
return watchList
|
return watchList
|
||||||
.Cast<IMiniWatchDetails>()
|
.Cast<IMiniWatchDetails>()
|
||||||
.Where(x => x.ChangeCount < CompareValue.Value)
|
.Where(x => x.ChangeCount < _compareValue.Value)
|
||||||
.Cast<IMiniWatch>();
|
.Cast<IMiniWatch>();
|
||||||
case ComparisonOperator.LessThanEqual:
|
case ComparisonOperator.LessThanEqual:
|
||||||
return watchList
|
return watchList
|
||||||
.Cast<IMiniWatchDetails>()
|
.Cast<IMiniWatchDetails>()
|
||||||
.Where(x => x.ChangeCount <= CompareValue.Value)
|
.Where(x => x.ChangeCount <= _compareValue.Value)
|
||||||
.Cast<IMiniWatch>();
|
.Cast<IMiniWatch>();
|
||||||
case ComparisonOperator.DifferentBy:
|
case ComparisonOperator.DifferentBy:
|
||||||
if (DifferentBy.HasValue)
|
if (_differentBy.HasValue)
|
||||||
{
|
{
|
||||||
return watchList
|
return watchList
|
||||||
.Cast<IMiniWatchDetails>()
|
.Cast<IMiniWatchDetails>()
|
||||||
.Where(x => (x.ChangeCount + DifferentBy.Value == CompareValue.Value) || (x.ChangeCount - DifferentBy.Value == CompareValue.Value))
|
.Where(x => (x.ChangeCount + _differentBy.Value == _compareValue.Value) || (x.ChangeCount - _differentBy.Value == _compareValue.Value))
|
||||||
.Cast<IMiniWatch>();
|
.Cast<IMiniWatch>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -574,27 +602,27 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
private IEnumerable<IMiniWatch> CompareDifference(IEnumerable<IMiniWatch> watchList)
|
private IEnumerable<IMiniWatch> CompareDifference(IEnumerable<IMiniWatch> watchList)
|
||||||
{
|
{
|
||||||
if (CompareValue.HasValue)
|
if (_compareValue.HasValue)
|
||||||
{
|
{
|
||||||
switch (Operator)
|
switch (_operator)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case ComparisonOperator.Equal:
|
case ComparisonOperator.Equal:
|
||||||
return watchList.Where(x => (GetValue(x.Address) - x.Previous) == CompareValue.Value);
|
return watchList.Where(x => (GetValue(x.Address) - x.Previous) == _compareValue.Value);
|
||||||
case ComparisonOperator.NotEqual:
|
case ComparisonOperator.NotEqual:
|
||||||
return watchList.Where(x => (GetValue(x.Address) - x.Previous) != CompareValue.Value);
|
return watchList.Where(x => (GetValue(x.Address) - x.Previous) != _compareValue.Value);
|
||||||
case ComparisonOperator.GreaterThan:
|
case ComparisonOperator.GreaterThan:
|
||||||
return watchList.Where(x => (GetValue(x.Address) - x.Previous) > CompareValue.Value);
|
return watchList.Where(x => (GetValue(x.Address) - x.Previous) > _compareValue.Value);
|
||||||
case ComparisonOperator.GreaterThanEqual:
|
case ComparisonOperator.GreaterThanEqual:
|
||||||
return watchList.Where(x => (GetValue(x.Address) - x.Previous) >= CompareValue.Value);
|
return watchList.Where(x => (GetValue(x.Address) - x.Previous) >= _compareValue.Value);
|
||||||
case ComparisonOperator.LessThan:
|
case ComparisonOperator.LessThan:
|
||||||
return watchList.Where(x => (GetValue(x.Address) - x.Previous) < CompareValue.Value);
|
return watchList.Where(x => (GetValue(x.Address) - x.Previous) < _compareValue.Value);
|
||||||
case ComparisonOperator.LessThanEqual:
|
case ComparisonOperator.LessThanEqual:
|
||||||
return watchList.Where(x => (GetValue(x.Address) - x.Previous) <= CompareValue.Value);
|
return watchList.Where(x => (GetValue(x.Address) - x.Previous) <= _compareValue.Value);
|
||||||
case ComparisonOperator.DifferentBy:
|
case ComparisonOperator.DifferentBy:
|
||||||
if (DifferentBy.HasValue)
|
if (_differentBy.HasValue)
|
||||||
{
|
{
|
||||||
return watchList.Where(x => (GetValue(x.Address) - x.Previous + DifferentBy.Value == CompareValue) || (GetValue(x.Address) - x.Previous - DifferentBy.Value == x.Previous));
|
return watchList.Where(x => (GetValue(x.Address) - x.Previous + _differentBy.Value == _compareValue) || (GetValue(x.Address) - x.Previous - _differentBy.Value == x.Previous));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -612,7 +640,7 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
#region Private parts
|
#region Private parts
|
||||||
|
|
||||||
private int GetValue(int addr)
|
private long GetValue(int addr)
|
||||||
{
|
{
|
||||||
switch (_settings.Size)
|
switch (_settings.Size)
|
||||||
{
|
{
|
||||||
|
@ -645,7 +673,7 @@ namespace BizHawk.MultiClient
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return (int)theDWord; //TODO
|
return (uint)theDWord;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue