(guess) Delegate peeking to `IMiniWatch.Current` implementations
This commit is contained in:
parent
fdabc5ed13
commit
250dc16748
|
@ -261,7 +261,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
||||||
_watchList = _watchList.OrderBy(w => w.Address, reverse).ToArray();
|
_watchList = _watchList.OrderBy(w => w.Address, reverse).ToArray();
|
||||||
break;
|
break;
|
||||||
case WatchList.Value:
|
case WatchList.Value:
|
||||||
_watchList = _watchList.OrderBy(w => GetValue(w.Address), reverse).ToArray();
|
_watchList = _watchList.OrderBy(w => w.Current, reverse).ToArray();
|
||||||
break;
|
break;
|
||||||
case WatchList.Prev:
|
case WatchList.Prev:
|
||||||
_watchList = _watchList.OrderBy(w => w.Previous, reverse).ToArray();
|
_watchList = _watchList.OrderBy(w => w.Previous, reverse).ToArray();
|
||||||
|
@ -270,7 +270,7 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
||||||
_watchList = _watchList.OrderBy(w => w.ChangeCount, reverse).ToArray();
|
_watchList = _watchList.OrderBy(w => w.ChangeCount, reverse).ToArray();
|
||||||
break;
|
break;
|
||||||
case WatchList.Diff:
|
case WatchList.Diff:
|
||||||
_watchList = _watchList.OrderBy(w => GetValue(w.Address) - w.Previous, reverse).ToArray();
|
_watchList = _watchList.OrderBy(w => w.Current - w.Previous, reverse).ToArray();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,52 +319,52 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case ComparisonOperator.Equal:
|
case ComparisonOperator.Equal:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) == SignExtendAsNeeded(w.Previous));
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) == SignExtendAsNeeded(w.Previous));
|
||||||
case ComparisonOperator.NotEqual:
|
case ComparisonOperator.NotEqual:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) != SignExtendAsNeeded(w.Previous));
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) != SignExtendAsNeeded(w.Previous));
|
||||||
case ComparisonOperator.GreaterThan:
|
case ComparisonOperator.GreaterThan:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) > SignExtendAsNeeded(w.Previous));
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) > SignExtendAsNeeded(w.Previous));
|
||||||
case ComparisonOperator.GreaterThanEqual:
|
case ComparisonOperator.GreaterThanEqual:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) >= SignExtendAsNeeded(w.Previous));
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) >= SignExtendAsNeeded(w.Previous));
|
||||||
case ComparisonOperator.LessThan:
|
case ComparisonOperator.LessThan:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) < SignExtendAsNeeded(w.Previous));
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) < SignExtendAsNeeded(w.Previous));
|
||||||
case ComparisonOperator.LessThanEqual:
|
case ComparisonOperator.LessThanEqual:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) <= SignExtendAsNeeded(w.Previous));
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) <= SignExtendAsNeeded(w.Previous));
|
||||||
case ComparisonOperator.DifferentBy:
|
case ComparisonOperator.DifferentBy:
|
||||||
if (DifferentBy is not int differentBy) throw new InvalidOperationException();
|
if (DifferentBy is not int differentBy) throw new InvalidOperationException();
|
||||||
return watchList.Where(w =>
|
return watchList.Where(w =>
|
||||||
differentBy == Math.Abs(SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous)));
|
differentBy == Math.Abs(SignExtendAsNeeded(w.Current) - SignExtendAsNeeded(w.Previous)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (Operator)
|
switch (Operator)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case ComparisonOperator.Equal:
|
case ComparisonOperator.Equal:
|
||||||
return watchList.Where(w => ReinterpretAsF32(GetValue(w.Address)).HawkFloatEquality(ReinterpretAsF32(w.Previous)));
|
return watchList.Where(w => ReinterpretAsF32(w.Current).HawkFloatEquality(ReinterpretAsF32(w.Previous)));
|
||||||
case ComparisonOperator.NotEqual:
|
case ComparisonOperator.NotEqual:
|
||||||
return watchList.Where(w => !ReinterpretAsF32(GetValue(w.Address)).HawkFloatEquality(ReinterpretAsF32(w.Previous)));
|
return watchList.Where(w => !ReinterpretAsF32(w.Current).HawkFloatEquality(ReinterpretAsF32(w.Previous)));
|
||||||
case ComparisonOperator.GreaterThan:
|
case ComparisonOperator.GreaterThan:
|
||||||
return watchList.Where(w => ReinterpretAsF32(GetValue(w.Address)) > ReinterpretAsF32(w.Previous));
|
return watchList.Where(w => ReinterpretAsF32(w.Current) > ReinterpretAsF32(w.Previous));
|
||||||
case ComparisonOperator.GreaterThanEqual:
|
case ComparisonOperator.GreaterThanEqual:
|
||||||
return watchList.Where(w =>
|
return watchList.Where(w =>
|
||||||
{
|
{
|
||||||
var val = ReinterpretAsF32(GetValue(w.Address));
|
var val = ReinterpretAsF32(w.Current);
|
||||||
var prev = ReinterpretAsF32(w.Previous);
|
var prev = ReinterpretAsF32(w.Previous);
|
||||||
return val > prev || val.HawkFloatEquality(prev);
|
return val > prev || val.HawkFloatEquality(prev);
|
||||||
});
|
});
|
||||||
case ComparisonOperator.LessThan:
|
case ComparisonOperator.LessThan:
|
||||||
return watchList.Where(w => ReinterpretAsF32(GetValue(w.Address)) < ReinterpretAsF32(w.Previous));
|
return watchList.Where(w => ReinterpretAsF32(w.Current) < ReinterpretAsF32(w.Previous));
|
||||||
case ComparisonOperator.LessThanEqual:
|
case ComparisonOperator.LessThanEqual:
|
||||||
return watchList.Where(w =>
|
return watchList.Where(w =>
|
||||||
{
|
{
|
||||||
var val = ReinterpretAsF32(GetValue(w.Address));
|
var val = ReinterpretAsF32(w.Current);
|
||||||
var prev = ReinterpretAsF32(w.Previous);
|
var prev = ReinterpretAsF32(w.Previous);
|
||||||
return val < prev || val.HawkFloatEquality(prev);
|
return val < prev || val.HawkFloatEquality(prev);
|
||||||
});
|
});
|
||||||
case ComparisonOperator.DifferentBy:
|
case ComparisonOperator.DifferentBy:
|
||||||
if (DifferentBy is not int differentBy) throw new InvalidOperationException();
|
if (DifferentBy is not int differentBy) throw new InvalidOperationException();
|
||||||
var differentByF = ReinterpretAsF32(differentBy);
|
var differentByF = ReinterpretAsF32(differentBy);
|
||||||
return watchList.Where(w => Math.Abs(ReinterpretAsF32(GetValue(w.Address)) - ReinterpretAsF32(w.Previous))
|
return watchList.Where(w => Math.Abs(ReinterpretAsF32(w.Current) - ReinterpretAsF32(w.Previous))
|
||||||
.HawkFloatEquality(differentByF));
|
.HawkFloatEquality(differentByF));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,21 +378,21 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case ComparisonOperator.Equal:
|
case ComparisonOperator.Equal:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) == SignExtendAsNeeded(compareValue));
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) == SignExtendAsNeeded(compareValue));
|
||||||
case ComparisonOperator.NotEqual:
|
case ComparisonOperator.NotEqual:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) != SignExtendAsNeeded(compareValue));
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) != SignExtendAsNeeded(compareValue));
|
||||||
case ComparisonOperator.GreaterThan:
|
case ComparisonOperator.GreaterThan:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) > SignExtendAsNeeded(compareValue));
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) > SignExtendAsNeeded(compareValue));
|
||||||
case ComparisonOperator.GreaterThanEqual:
|
case ComparisonOperator.GreaterThanEqual:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) >= SignExtendAsNeeded(compareValue));
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) >= SignExtendAsNeeded(compareValue));
|
||||||
case ComparisonOperator.LessThan:
|
case ComparisonOperator.LessThan:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) < SignExtendAsNeeded(compareValue));
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) < SignExtendAsNeeded(compareValue));
|
||||||
case ComparisonOperator.LessThanEqual:
|
case ComparisonOperator.LessThanEqual:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) <= SignExtendAsNeeded(compareValue));
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) <= SignExtendAsNeeded(compareValue));
|
||||||
case ComparisonOperator.DifferentBy:
|
case ComparisonOperator.DifferentBy:
|
||||||
if (DifferentBy is not int differentBy) throw new InvalidOperationException();
|
if (DifferentBy is not int differentBy) throw new InvalidOperationException();
|
||||||
return watchList.Where(w =>
|
return watchList.Where(w =>
|
||||||
differentBy == Math.Abs(SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(compareValue)));
|
differentBy == Math.Abs(SignExtendAsNeeded(w.Current) - SignExtendAsNeeded(compareValue)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var compareValueF = ReinterpretAsF32(compareValue);
|
var compareValueF = ReinterpretAsF32(compareValue);
|
||||||
|
@ -400,29 +400,29 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case ComparisonOperator.Equal:
|
case ComparisonOperator.Equal:
|
||||||
return watchList.Where(w => ReinterpretAsF32(GetValue(w.Address)).HawkFloatEquality(compareValueF));
|
return watchList.Where(w => ReinterpretAsF32(w.Current).HawkFloatEquality(compareValueF));
|
||||||
case ComparisonOperator.NotEqual:
|
case ComparisonOperator.NotEqual:
|
||||||
return watchList.Where(w => !ReinterpretAsF32(GetValue(w.Address)).HawkFloatEquality(compareValueF));
|
return watchList.Where(w => !ReinterpretAsF32(w.Current).HawkFloatEquality(compareValueF));
|
||||||
case ComparisonOperator.GreaterThan:
|
case ComparisonOperator.GreaterThan:
|
||||||
return watchList.Where(w => ReinterpretAsF32(GetValue(w.Address)) > compareValueF);
|
return watchList.Where(w => ReinterpretAsF32(w.Current) > compareValueF);
|
||||||
case ComparisonOperator.GreaterThanEqual:
|
case ComparisonOperator.GreaterThanEqual:
|
||||||
return watchList.Where(w =>
|
return watchList.Where(w =>
|
||||||
{
|
{
|
||||||
var val = ReinterpretAsF32(GetValue(w.Address));
|
var val = ReinterpretAsF32(w.Current);
|
||||||
return val > compareValueF || val.HawkFloatEquality(compareValueF);
|
return val > compareValueF || val.HawkFloatEquality(compareValueF);
|
||||||
});
|
});
|
||||||
case ComparisonOperator.LessThan:
|
case ComparisonOperator.LessThan:
|
||||||
return watchList.Where(w => ReinterpretAsF32(GetValue(w.Address)) < compareValueF);
|
return watchList.Where(w => ReinterpretAsF32(w.Current) < compareValueF);
|
||||||
case ComparisonOperator.LessThanEqual:
|
case ComparisonOperator.LessThanEqual:
|
||||||
return watchList.Where(w =>
|
return watchList.Where(w =>
|
||||||
{
|
{
|
||||||
var val = ReinterpretAsF32(GetValue(w.Address));
|
var val = ReinterpretAsF32(w.Current);
|
||||||
return val < compareValueF || val.HawkFloatEquality(compareValueF);
|
return val < compareValueF || val.HawkFloatEquality(compareValueF);
|
||||||
});
|
});
|
||||||
case ComparisonOperator.DifferentBy:
|
case ComparisonOperator.DifferentBy:
|
||||||
if (DifferentBy is not int differentBy) throw new InvalidOperationException();
|
if (DifferentBy is not int differentBy) throw new InvalidOperationException();
|
||||||
var differentByF = ReinterpretAsF32(differentBy);
|
var differentByF = ReinterpretAsF32(differentBy);
|
||||||
return watchList.Where(w => Math.Abs(ReinterpretAsF32(GetValue(w.Address)) - compareValueF)
|
return watchList.Where(w => Math.Abs(ReinterpretAsF32(w.Current) - compareValueF)
|
||||||
.HawkFloatEquality(differentByF));
|
.HawkFloatEquality(differentByF));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -484,21 +484,21 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case ComparisonOperator.Equal:
|
case ComparisonOperator.Equal:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) == compareValue);
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) - SignExtendAsNeeded(w.Previous) == compareValue);
|
||||||
case ComparisonOperator.NotEqual:
|
case ComparisonOperator.NotEqual:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) != compareValue);
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) - SignExtendAsNeeded(w.Previous) != compareValue);
|
||||||
case ComparisonOperator.GreaterThan:
|
case ComparisonOperator.GreaterThan:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) > compareValue);
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) - SignExtendAsNeeded(w.Previous) > compareValue);
|
||||||
case ComparisonOperator.GreaterThanEqual:
|
case ComparisonOperator.GreaterThanEqual:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) >= compareValue);
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) - SignExtendAsNeeded(w.Previous) >= compareValue);
|
||||||
case ComparisonOperator.LessThan:
|
case ComparisonOperator.LessThan:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) < compareValue);
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) - SignExtendAsNeeded(w.Previous) < compareValue);
|
||||||
case ComparisonOperator.LessThanEqual:
|
case ComparisonOperator.LessThanEqual:
|
||||||
return watchList.Where(w => SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) <= compareValue);
|
return watchList.Where(w => SignExtendAsNeeded(w.Current) - SignExtendAsNeeded(w.Previous) <= compareValue);
|
||||||
case ComparisonOperator.DifferentBy:
|
case ComparisonOperator.DifferentBy:
|
||||||
if (DifferentBy is not int differentBy) throw new InvalidOperationException();
|
if (DifferentBy is not int differentBy) throw new InvalidOperationException();
|
||||||
return watchList.Where(w =>
|
return watchList.Where(w =>
|
||||||
differentBy == Math.Abs(SignExtendAsNeeded(GetValue(w.Address)) - SignExtendAsNeeded(w.Previous) - compareValue));
|
differentBy == Math.Abs(SignExtendAsNeeded(w.Current) - SignExtendAsNeeded(w.Previous) - compareValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var compareValueF = ReinterpretAsF32(compareValue);
|
var compareValueF = ReinterpretAsF32(compareValue);
|
||||||
|
@ -506,29 +506,29 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case ComparisonOperator.Equal:
|
case ComparisonOperator.Equal:
|
||||||
return watchList.Where(w => (ReinterpretAsF32(GetValue(w.Address)) - ReinterpretAsF32(w.Previous)).HawkFloatEquality(compareValueF));
|
return watchList.Where(w => (ReinterpretAsF32(w.Current) - ReinterpretAsF32(w.Previous)).HawkFloatEquality(compareValueF));
|
||||||
case ComparisonOperator.NotEqual:
|
case ComparisonOperator.NotEqual:
|
||||||
return watchList.Where(w => !(ReinterpretAsF32(GetValue(w.Address)) - ReinterpretAsF32(w.Previous)).HawkFloatEquality(compareValueF));
|
return watchList.Where(w => !(ReinterpretAsF32(w.Current) - ReinterpretAsF32(w.Previous)).HawkFloatEquality(compareValueF));
|
||||||
case ComparisonOperator.GreaterThan:
|
case ComparisonOperator.GreaterThan:
|
||||||
return watchList.Where(w => ReinterpretAsF32(GetValue(w.Address)) - ReinterpretAsF32(w.Previous) > compareValueF);
|
return watchList.Where(w => ReinterpretAsF32(w.Current) - ReinterpretAsF32(w.Previous) > compareValueF);
|
||||||
case ComparisonOperator.GreaterThanEqual:
|
case ComparisonOperator.GreaterThanEqual:
|
||||||
return watchList.Where(w =>
|
return watchList.Where(w =>
|
||||||
{
|
{
|
||||||
var diff = ReinterpretAsF32(GetValue(w.Address)) - ReinterpretAsF32(w.Previous);
|
var diff = ReinterpretAsF32(w.Current) - ReinterpretAsF32(w.Previous);
|
||||||
return diff > compareValueF || diff.HawkFloatEquality(compareValueF);
|
return diff > compareValueF || diff.HawkFloatEquality(compareValueF);
|
||||||
});
|
});
|
||||||
case ComparisonOperator.LessThan:
|
case ComparisonOperator.LessThan:
|
||||||
return watchList.Where(w => ReinterpretAsF32(GetValue(w.Address)) - ReinterpretAsF32(w.Previous) < compareValueF);
|
return watchList.Where(w => ReinterpretAsF32(w.Current) - ReinterpretAsF32(w.Previous) < compareValueF);
|
||||||
case ComparisonOperator.LessThanEqual:
|
case ComparisonOperator.LessThanEqual:
|
||||||
return watchList.Where(w =>
|
return watchList.Where(w =>
|
||||||
{
|
{
|
||||||
var diff = ReinterpretAsF32(GetValue(w.Address)) - ReinterpretAsF32(w.Previous);
|
var diff = ReinterpretAsF32(w.Current) - ReinterpretAsF32(w.Previous);
|
||||||
return diff < compareValueF || diff.HawkFloatEquality(compareValueF);
|
return diff < compareValueF || diff.HawkFloatEquality(compareValueF);
|
||||||
});
|
});
|
||||||
case ComparisonOperator.DifferentBy:
|
case ComparisonOperator.DifferentBy:
|
||||||
if (DifferentBy is not int differentBy) throw new InvalidOperationException();
|
if (DifferentBy is not int differentBy) throw new InvalidOperationException();
|
||||||
var differentByF = ReinterpretAsF32(differentBy);
|
var differentByF = ReinterpretAsF32(differentBy);
|
||||||
return watchList.Where(w => Math.Abs(ReinterpretAsF32(GetValue(w.Address)) - ReinterpretAsF32(w.Previous) - compareValueF)
|
return watchList.Where(w => Math.Abs(ReinterpretAsF32(w.Current) - ReinterpretAsF32(w.Previous) - compareValueF)
|
||||||
.HawkFloatEquality(differentByF));
|
.HawkFloatEquality(differentByF));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -549,18 +549,6 @@ namespace BizHawk.Client.Common.RamSearchEngine
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private long GetValue(long addr)
|
|
||||||
{
|
|
||||||
// do not return sign extended variables from here.
|
|
||||||
return _settings.Size switch
|
|
||||||
{
|
|
||||||
WatchSize.Byte => MiniByteWatch.GetByte(addr, Domain),
|
|
||||||
WatchSize.Word => MiniWordWatch.GetUshort(addr, Domain, _settings.BigEndian),
|
|
||||||
WatchSize.DWord => MiniDWordWatch.GetUint(addr, Domain, _settings.BigEndian),
|
|
||||||
_ => MiniByteWatch.GetByte(addr, Domain)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool CanDoCompareType(Compare compareType)
|
private bool CanDoCompareType(Compare compareType)
|
||||||
{
|
{
|
||||||
return _settings.Mode switch
|
return _settings.Mode switch
|
||||||
|
|
Loading…
Reference in New Issue