diff --git a/src/BizHawk.Client.Common/tools/RamSearchEngine/RamSearchEngine.cs b/src/BizHawk.Client.Common/tools/RamSearchEngine/RamSearchEngine.cs index 2169959453..b46eb47c93 100644 --- a/src/BizHawk.Client.Common/tools/RamSearchEngine/RamSearchEngine.cs +++ b/src/BizHawk.Client.Common/tools/RamSearchEngine/RamSearchEngine.cs @@ -89,10 +89,12 @@ namespace BizHawk.Client.Common.RamSearchEngine _watchList[index].Previous, _settings.IsDetailed() ? _watchList[index].ChangeCount : 0); - public int DoSearch() + public int DoSearch(bool updatePrevious) { int before = _watchList.Length; + Update(updatePrevious); + using (Domain.EnterExit()) { _watchList = _compareTo switch @@ -169,12 +171,12 @@ namespace BizHawk.Client.Common.RamSearchEngine /// public int? DifferentBy { get; set; } - public void Update() + public void Update(bool updatePrevious) { using var @lock = _settings.Domain.EnterExit(); foreach (var watch in _watchList) { - watch.Update(_settings.PreviousType, _settings.Domain, _settings.BigEndian); + watch.Update(updatePrevious ? _settings.PreviousType : PreviousType.Original, _settings.Domain, _settings.BigEndian); } } @@ -182,20 +184,13 @@ namespace BizHawk.Client.Common.RamSearchEngine public void SetEndian(bool bigEndian) => _settings.BigEndian = bigEndian; - /// is and is - public void SetPreviousType(PreviousType type) - { - if (_settings.IsFastMode() && type == PreviousType.LastFrame) - { - throw new InvalidOperationException(); - } + public void SetPreviousType(PreviousType type) => _settings.PreviousType = type; - _settings.PreviousType = type; - } + public void SetMode(SearchMode mode) => _settings.Mode = mode; public void SetPreviousToCurrent() { - Array.ForEach(_watchList, w => w.SetPreviousToCurrent(_settings.Domain, _settings.BigEndian)); + Array.ForEach(_watchList, static w => w.SetPreviousToCurrent()); } public void ClearChangeCounts() @@ -450,7 +445,7 @@ namespace BizHawk.Client.Common.RamSearchEngine private IEnumerable CompareChanges(IEnumerable watchList) { - if (CompareValue is not long compareValue) throw new InvalidCastException(); //TODO typo for IOE? + if (CompareValue is not long compareValue) throw new InvalidOperationException(); switch (Operator) { default: diff --git a/src/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs b/src/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs index fcf05523e5..369e4828d9 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs @@ -270,8 +270,6 @@ namespace BizHawk.Client.EmuHawk { if (_searches.Count > 0) { - _searches.Update(); - if (_autoSearch) { if (InputPollableCore != null && Settings.AutoSearchTakeLagFramesIntoAccount && InputPollableCore.IsLagFrame) @@ -280,21 +278,24 @@ namespace BizHawk.Client.EmuHawk } else { - DoSearch(); + DoSearch(true); } } + else if (_settings.IsDetailed()) + { + _searches.Update(true); + } _forcePreviewClear = false; WatchListView.RowCount = _searches.Count; } } + // TODO: this seems to be missing some logic from FrameUpdate that probably should exist here private void MinimalUpdate() { if (_searches.Count > 0) { - _searches.Update(); - if (_autoSearch) { DoSearch(); @@ -521,14 +522,14 @@ namespace BizHawk.Client.EmuHawk } } - public void DoSearch() + public void DoSearch(bool updatePrevious = false) { _searches.CompareValue = CompareToValue; _searches.DifferentBy = DifferentByValue; _searches.Operator = Operator; _searches.CompareTo = Compare; - var removed = _searches.DoSearch(); + var removed = _searches.DoSearch(updatePrevious); UpdateList(); SetRemovedMessage(removed); ToggleSearchDependentToolBarItems(); @@ -587,7 +588,6 @@ namespace BizHawk.Client.EmuHawk && _settings.IsDetailed()) { _settings.Mode = SearchMode.Fast; - SetReboot(true); MessageLabel.Text = "Large domain, switching to fast mode"; } } @@ -753,6 +753,7 @@ namespace BizHawk.Client.EmuHawk private void SetToDetailedMode() { _settings.Mode = SearchMode.Detailed; + _searches.SetMode(SearchMode.Detailed); NumberOfChangesRadio.Enabled = true; NumberOfChangesBox.Enabled = true; DifferenceRadio.Enabled = true; @@ -763,7 +764,6 @@ namespace BizHawk.Client.EmuHawk ChangesMenuItem.Checked = true; ColumnToggleCallback(); - SetReboot(true); } private ToolStripMenuItem ChangesMenuItem @@ -782,6 +782,7 @@ namespace BizHawk.Client.EmuHawk private void SetToFastMode() { _settings.Mode = SearchMode.Fast; + _searches.SetMode(SearchMode.Fast); if (_settings.PreviousType == PreviousType.LastFrame || _settings.PreviousType == PreviousType.LastChange) { @@ -802,7 +803,6 @@ namespace BizHawk.Client.EmuHawk ChangesMenuItem.Checked = false; ColumnToggleCallback(); - SetReboot(true); } private void RemoveAddresses()