From 9816a04a4fbcc5f89718a4ec750afd2e34c047a1 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Tue, 22 Feb 2011 17:27:38 +0000 Subject: [PATCH] Ram Search - Implemented previous search based on the previous value being since last search. Also fixed preview feature, it was previewing the opposite result. --- BizHawk.MultiClient/tools/RamSearch.cs | 48 +++++++++++++++++++------- BizHawk.MultiClient/tools/Watch.cs | 13 +++++++ 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/BizHawk.MultiClient/tools/RamSearch.cs b/BizHawk.MultiClient/tools/RamSearch.cs index 49a2e65a47..4cdd9c4708 100644 --- a/BizHawk.MultiClient/tools/RamSearch.cs +++ b/BizHawk.MultiClient/tools/RamSearch.cs @@ -17,6 +17,7 @@ namespace BizHawk.MultiClient public partial class RamSearch : Form { //TODO: + //DoSearch() - if already previewed, don't generate the list again, perhaps a bool? //Window position gets saved but doesn't load properly //Implement definitions of Previous value //Multiple memory domains @@ -24,7 +25,10 @@ namespace BizHawk.MultiClient //Option to always remove Ram Watch list from search list //Truncate from file in File menu (and toolstrip?) //When a new ROM is loaded - run Start new Search (or just clear list?) - //Save Dialog - user cancelling crashes, same for Ram Search + //Save Dialog - user cancelling crashes, same for Ram Watch? + //Weddedlist & undoList are getting references instead of copies, somehow still works but there has to be some failures as a result, fix + //Add previous as original value option + //Add button to set copy current values to prev string systemID = "NULL"; List searchList = new List(); @@ -329,10 +333,20 @@ namespace BizHawk.MultiClient } } + MakePreviousList(); + OutputLabel.Text = "New search started"; DisplaySearchList(); } + private void MakePreviousList() + { + prevList = new List(); + + for (int x = 0; x < searchList.Count; x++) + prevList.Add(new Watch(searchList[x])); + } + private void DisplaySearchList() { SearchListView.ItemCount = searchList.Count; @@ -431,17 +445,12 @@ namespace BizHawk.MultiClient private void SearchListView_QueryItemBkColor(int index, int column, ref Color color) { - //if (index % 2 == 0) color = Color.White; else color = Color.Pink; - - - if (weededList.Contains(searchList[index])) { - color = Color.Pink; + color = Color.White; } else - color = Color.White; - //TODO: make background pink on items that would be removed if search button were clicked + color = Color.Pink; } private void SearchListView_QueryItemText(int index, int column, out string text) @@ -459,16 +468,26 @@ namespace BizHawk.MultiClient text = ((sbyte)searchList[index].value).ToString(); else if (searchList[index].signed == asigned.HEX) text = searchList[index].value.ToString("X"); - } if (column == 2) { if (searchList[index].signed == asigned.UNSIGNED) - text = searchList[index].prev.ToString(); + { + if (Global.Config.RamSearchPreviousAs == 2) //If prev frame + text = searchList[index].prev.ToString(); + else + text = prevList[index].value.ToString(); + //text = "urmom"; + + } else if (searchList[index].signed == asigned.SIGNED) + { text = ((sbyte)searchList[index].prev).ToString(); + } else if (searchList[index].signed == asigned.HEX) + { text = searchList[index].prev.ToString("X"); + } } if (column == 3) { @@ -518,19 +537,19 @@ namespace BizHawk.MultiClient if (GenerateWeedOutList()) { DisplaySearchList(); - OutputLabel.Text = MakeAddressString(weededList.Count) + "would be removed"; + OutputLabel.Text = MakeAddressString(searchList.Count - weededList.Count) + " would be removed"; } } } private void DoSearch() { - //TODO: if already previewed, don't generate the list again, perhaps a bool? if (GenerateWeedOutList()) { SaveUndo(); OutputLabel.Text = MakeAddressString(searchList.Count - weededList.Count) + " removed"; ReplaceSearchListWithWeedOutList(); + MakePreviousList(); DisplaySearchList(); } else @@ -599,7 +618,10 @@ namespace BizHawk.MultiClient private int GetPreviousValue(int pos) { - return searchList[pos].prev; //TODO: return value based on user choice + if (Global.Config.RamSearchPreviousAs == 2) //If Previous frame + return searchList[pos].prev; //TODO: return value based on user choice + else + return prevList[pos].value; } private bool DoPreviousValue() diff --git a/BizHawk.MultiClient/tools/Watch.cs b/BizHawk.MultiClient/tools/Watch.cs index d2732beb0a..d232c0b774 100644 --- a/BizHawk.MultiClient/tools/Watch.cs +++ b/BizHawk.MultiClient/tools/Watch.cs @@ -24,6 +24,19 @@ namespace BizHawk.MultiClient changecount = 0; prev = 0; } + + public Watch(Watch w) + { + address = w.address; + value = w.value; + type = w.type; + signed = w.signed; + bigendian = w.bigendian; + notes = w.notes; + changecount = w.changecount; + prev = w.prev; + } + public Watch(int Address, int Value, atype Type, asigned Signed, bool BigEndian, string Notes) { address = Address;