From 1f454af2c343403ed6252abb5cdede3bfc90d977 Mon Sep 17 00:00:00 2001 From: adelikat Date: Mon, 3 Sep 2012 23:42:00 +0000 Subject: [PATCH] Refactoring of Watch object and related tools, add domain into Watch object. No functionality changes in this commit --- BizHawk.MultiClient/tools/HexEditor.cs | 26 +- BizHawk.MultiClient/tools/RamPoke.cs | 160 ++-- BizHawk.MultiClient/tools/RamSearch.cs | 712 +++++++++--------- BizHawk.MultiClient/tools/RamWatch.cs | 216 +++--- BizHawk.MultiClient/tools/RamWatchNewWatch.cs | 68 +- BizHawk.MultiClient/tools/Watch.cs | 628 ++++++++------- BizHawk.MultiClient/tools/WatchCommon.cs | 22 +- 7 files changed, 1003 insertions(+), 829 deletions(-) diff --git a/BizHawk.MultiClient/tools/HexEditor.cs b/BizHawk.MultiClient/tools/HexEditor.cs index 249182d414..05d776cf2c 100644 --- a/BizHawk.MultiClient/tools/HexEditor.cs +++ b/BizHawk.MultiClient/tools/HexEditor.cs @@ -593,21 +593,21 @@ namespace BizHawk.MultiClient private Watch MakeWatch(int address) { Watch w = new Watch(); - w.address = address; - w.bigendian = BigEndian; - w.signed = asigned.HEX; + w.Address = address; + w.BigEndian = BigEndian; + w.Signed = Watch.DISPTYPE.HEX; switch (DataSize) { default: case 1: - w.type = atype.BYTE; + w.Type = Watch.TYPE.BYTE; break; case 2: - w.type = atype.WORD; + w.Type = Watch.TYPE.WORD; break; case 4: - w.type = atype.DWORD; + w.Type = Watch.TYPE.DWORD; break; } return w; @@ -649,22 +649,22 @@ namespace BizHawk.MultiClient if (p >= 0) { Watch w = new Watch(); - w.address = p; - w.value = MakeValue(p); - w.bigendian = BigEndian; - w.signed = asigned.HEX; + w.Address = p; + w.Value = MakeValue(p); + w.BigEndian = BigEndian; + w.Signed = Watch.DISPTYPE.HEX; switch (DataSize) { default: case 1: - w.type = atype.BYTE; + w.Type = Watch.TYPE.BYTE; break; case 2: - w.type = atype.WORD; + w.Type = Watch.TYPE.WORD; break; case 4: - w.type = atype.DWORD; + w.Type = Watch.TYPE.DWORD; break; } diff --git a/BizHawk.MultiClient/tools/RamPoke.cs b/BizHawk.MultiClient/tools/RamPoke.cs index 3aee4f6fe2..bf741897cd 100644 --- a/BizHawk.MultiClient/tools/RamPoke.cs +++ b/BizHawk.MultiClient/tools/RamPoke.cs @@ -32,19 +32,27 @@ namespace BizHawk.MultiClient private void RamPoke_Load(object sender, EventArgs e) { - if (watch.address == 0) + if (watch.Address == 0) PopulateMemoryDomainComboBox(); - SetTypeRadio(watch.type); - SetSignedRadio(watch.signed); - if (watch.signed == asigned.HEX) + SetTypeRadio(watch.Type); + SetSignedRadio(watch.Signed); + if (watch.Signed == Watch.DISPTYPE.HEX) + { ValueHexLabel.Text = "0x"; + } else + { ValueHexLabel.Text = ""; + } - if (watch.bigendian == true) + if (watch.BigEndian == true) + { BigEndianRadio.Checked = true; + } else + { LittleEndianRadio.Checked = true; + } SetValueBox(); SetAddressBox(); @@ -63,15 +71,15 @@ namespace BizHawk.MultiClient { if (HexRadio.Checked) ValueBox.Text = String.Format("{0:X" + - GetValueNumDigits() + "}", watch.value); + GetValueNumDigits() + "}", watch.Value); else - ValueBox.Text = watch.value.ToString(); + ValueBox.Text = watch.Value.ToString(); } private void SetAddressBox() { AddressBox.Text = String.Format("{0:X" + - GetNumDigits(watch.address) + "}", watch.address); + GetNumDigits(watch.Address) + "}", watch.Address); } private void UpdateTitleText() @@ -79,17 +87,17 @@ namespace BizHawk.MultiClient Text = "Ram Poke - " + domain.ToString(); } - private void SetTypeRadio(atype a) + private void SetTypeRadio(Watch.TYPE a) { switch (a) { - case atype.BYTE: + case Watch.TYPE.BYTE: Byte1Radio.Checked = true; break; - case atype.WORD: + case Watch.TYPE.WORD: Byte2Radio.Checked = true; break; - case atype.DWORD: + case Watch.TYPE.DWORD: Byte4Radio.Checked = true; break; default: @@ -97,17 +105,17 @@ namespace BizHawk.MultiClient } } - private void SetSignedRadio(asigned a) + private void SetSignedRadio(Watch.DISPTYPE a) { switch (a) { - case asigned.SIGNED: + case Watch.DISPTYPE.SIGNED: SignedRadio.Checked = true; break; - case asigned.UNSIGNED: + case Watch.DISPTYPE.UNSIGNED: UnsignedRadio.Checked = true; break; - case asigned.HEX: + case Watch.DISPTYPE.HEX: HexRadio.Checked = true; break; default: @@ -125,7 +133,7 @@ namespace BizHawk.MultiClient //Put user settings in the watch file if (InputValidate.IsValidHexNumber(AddressBox.Text)) - watch.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber); + watch.Address = int.Parse(AddressBox.Text, NumberStyles.HexNumber); else { MessageBox.Show("Invalid Address, must be a valid hex number", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -135,25 +143,41 @@ namespace BizHawk.MultiClient } if (SignedRadio.Checked) - watch.signed = asigned.SIGNED; + { + watch.Signed = Watch.DISPTYPE.SIGNED; + } else if (UnsignedRadio.Checked) - watch.signed = asigned.UNSIGNED; + { + watch.Signed = Watch.DISPTYPE.UNSIGNED; + } else if (HexRadio.Checked) - watch.signed = asigned.HEX; + { + watch.Signed = Watch.DISPTYPE.HEX; + } if (Byte1Radio.Checked) - watch.type = atype.BYTE; + { + watch.Type = Watch.TYPE.BYTE; + } else if (Byte2Radio.Checked) - watch.type = atype.WORD; + { + watch.Type = Watch.TYPE.WORD; + } else if (Byte4Radio.Checked) - watch.type = atype.DWORD; + { + watch.Type = Watch.TYPE.DWORD; + } if (BigEndianRadio.Checked) - watch.bigendian = true; + { + watch.BigEndian = true; + } else if (LittleEndianRadio.Checked) - watch.bigendian = false; + { + watch.BigEndian = false; + } - int x = GetSpecificValue(); + int x = GetSpecificValue(); //TODO: use a nullable int instead of this crap if (x == -99999999) { MessageBox.Show("Missing or invalid value", "Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -162,17 +186,19 @@ namespace BizHawk.MultiClient return; } else - watch.value = int.Parse(ValueBox.Text); + { + watch.Value = int.Parse(ValueBox.Text); + } watch.PokeAddress(domain); string value; if (HexRadio.Checked) - value = "0x" + String.Format("{0:X" + GetValueNumDigits() + "}", watch.value); + value = "0x" + String.Format("{0:X" + GetValueNumDigits() + "}", watch.Value); else - value = watch.value.ToString(); + value = watch.Value.ToString(); string address = String.Format("{0:X" + GetNumDigits(domain.Size).ToString() - + "}", watch.address); + + "}", watch.Address); OutputLabel.Text = value + " written to " + address; @@ -202,16 +228,24 @@ namespace BizHawk.MultiClient } } - private asigned GetDataType() + private Watch.DISPTYPE GetDataType() { if (SignedRadio.Checked) - return asigned.SIGNED; + { + return Watch.DISPTYPE.SIGNED; + } if (UnsignedRadio.Checked) - return asigned.UNSIGNED; + { + return Watch.DISPTYPE.UNSIGNED; + } if (HexRadio.Checked) - return asigned.HEX; - - return asigned.UNSIGNED; //Just in case + { + return Watch.DISPTYPE.HEX; + } + else + { + return Watch.DISPTYPE.UNSIGNED; //Just in case + } } private void AddressBox_KeyPress(object sender, KeyPressEventArgs e) @@ -228,48 +262,62 @@ namespace BizHawk.MultiClient switch (GetDataType()) { - case asigned.UNSIGNED: + case Watch.DISPTYPE.UNSIGNED: if (!InputValidate.IsValidUnsignedNumber(e.KeyChar)) + { e.Handled = true; + } break; - case asigned.SIGNED: + case Watch.DISPTYPE.SIGNED: if (!InputValidate.IsValidSignedNumber(e.KeyChar)) + { e.Handled = true; + } break; - case asigned.HEX: + case Watch.DISPTYPE.HEX: if (!InputValidate.IsValidHexNumber(e.KeyChar)) + { e.Handled = true; + } break; } } - private atype GetDataSize() + private Watch.TYPE GetDataSize() { if (Byte1Radio.Checked) - return atype.BYTE; - if (Byte2Radio.Checked) - return atype.WORD; - if (Byte4Radio.Checked) - return atype.DWORD; - - return atype.BYTE; + { + return Watch.TYPE.BYTE; + } + else if (Byte2Radio.Checked) + { + return Watch.TYPE.WORD; + } + else if (Byte4Radio.Checked) + { + return Watch.TYPE.DWORD; + } + else + { + return Watch.TYPE.BYTE; + } } - private int GetSpecificValue() + private int GetSpecificValue() //TODO: don't use -99999999 use nullable int instead { if (ValueBox.Text == "" || ValueBox.Text == "-") return 0; bool i = false; switch (GetDataType()) { - case asigned.UNSIGNED: + case Watch.DISPTYPE.UNSIGNED: i = InputValidate.IsValidUnsignedNumber(ValueBox.Text); if (!i) return -99999999; return (int)Int64.Parse(ValueBox.Text); //Note: 64 to be safe - case asigned.SIGNED: + case Watch.DISPTYPE.SIGNED: i = InputValidate.IsValidSignedNumber(ValueBox.Text); if (!i) return -99999999; return (int)Int64.Parse(ValueBox.Text); - case asigned.HEX: + case Watch.DISPTYPE.HEX: i = InputValidate.IsValidHexNumber(ValueBox.Text); if (!i) return -99999999; return (int)Int64.Parse(ValueBox.Text, NumberStyles.HexNumber); @@ -300,15 +348,15 @@ namespace BizHawk.MultiClient switch (GetDataSize()) { default: - case atype.BYTE: + case Watch.TYPE.BYTE: if (HexRadio.Checked) return 2; else if (UnsignedRadio.Checked) return 3; else return 4; - case atype.WORD: + case Watch.TYPE.WORD: if (HexRadio.Checked) return 4; else if (UnsignedRadio.Checked) return 5; else return 6; - case atype.DWORD: + case Watch.TYPE.DWORD: if (HexRadio.Checked) return 8; else if (UnsignedRadio.Checked) return 10; else return 11; @@ -343,8 +391,8 @@ namespace BizHawk.MultiClient domain = Global.Emulator.MemoryDomains[DomainComboBox.SelectedIndex]; UpdateTitleText(); int x = GetNumDigits(domain.Size); - watch.address = 0; - watch.value = 0; + watch.Address = 0; + watch.Value = 0; SetAddressBox(); SetValueBox(); AddressBox.MaxLength = GetNumDigits(domain.Size); diff --git a/BizHawk.MultiClient/tools/RamSearch.cs b/BizHawk.MultiClient/tools/RamSearch.cs index 097035f2ba..bb2c5194c5 100644 --- a/BizHawk.MultiClient/tools/RamSearch.cs +++ b/BizHawk.MultiClient/tools/RamSearch.cs @@ -21,7 +21,7 @@ namespace BizHawk.MultiClient public partial class RamSearch : Form { string systemID = "NULL"; - List searchList = new List(); + List Searches = new List(); List undoList = new List(); List redoList = new List(); private bool IsAWeededList = false; //For deciding whether the weeded list is relevant (0 size could mean all were removed in a legit preview @@ -71,7 +71,7 @@ namespace BizHawk.MultiClient { if (!this.IsHandleCreated || this.IsDisposed) return; - if (searchList.Count > 8) + if (Searches.Count > 8) { SearchListView.BlazingFast = true; } @@ -79,9 +79,9 @@ namespace BizHawk.MultiClient sortReverse = false; sortedCol = ""; - for (int x = searchList.Count - 1; x >= 0; x--) + for (int x = Searches.Count - 1; x >= 0; x--) { - searchList[x].PeekAddress(Domain); + Searches[x].PeekAddress(Domain); } if (AutoSearchCheckBox.Checked) { @@ -199,7 +199,7 @@ namespace BizHawk.MultiClient private void SetTotal() { - int x = searchList.Count; + int x = Searches.Count; string str; if (x == 1) str = " address"; @@ -213,7 +213,7 @@ namespace BizHawk.MultiClient var file = GetFileFromUser(); if (file != null) { - LoadSearchFile(file.FullName, false, false, searchList); + LoadSearchFile(file.FullName, false, false, Searches); DisplaySearchList(); } } @@ -313,7 +313,7 @@ namespace BizHawk.MultiClient Global.MainForm.LoadRamWatch(true); for (int x = 0; x < indexes.Count; x++) { - Global.MainForm.RamWatch1.AddWatch(searchList[indexes[x]]); + Global.MainForm.RamWatch1.AddWatch(Searches[indexes[x]]); } } } @@ -343,28 +343,44 @@ namespace BizHawk.MultiClient StartNewSearch(); } - private asigned GetDataType() + private Watch.DISPTYPE GetDataType() { if (unsignedToolStripMenuItem.Checked) - return asigned.UNSIGNED; - if (signedToolStripMenuItem.Checked) - return asigned.SIGNED; - if (hexadecimalToolStripMenuItem.Checked) - return asigned.HEX; - - return asigned.UNSIGNED; //Just in case + { + return Watch.DISPTYPE.UNSIGNED; + } + else if (signedToolStripMenuItem.Checked) + { + return Watch.DISPTYPE.SIGNED; + } + else if (hexadecimalToolStripMenuItem.Checked) + { + return Watch.DISPTYPE.HEX; + } + else + { + return Watch.DISPTYPE.UNSIGNED; //Just in case + } } - private atype GetDataSize() + private Watch.TYPE GetDataSize() { if (byteToolStripMenuItem.Checked) - return atype.BYTE; - if (bytesToolStripMenuItem.Checked) - return atype.WORD; - if (dWordToolStripMenuItem1.Checked) - return atype.DWORD; - - return atype.BYTE; + { + return Watch.TYPE.BYTE; + } + else if (bytesToolStripMenuItem.Checked) + { + return Watch.TYPE.WORD; + } + else if (dWordToolStripMenuItem1.Checked) + { + return Watch.TYPE.DWORD; + } + else + { + return Watch.TYPE.BYTE; + } } private bool GetBigEndian() @@ -381,7 +397,7 @@ namespace BizHawk.MultiClient ClearRedo(); //weededList.Clear(); IsAWeededList = false; - searchList.Clear(); + Searches.Clear(); SetPlatformAndMemoryDomainLabel(); int count = 0; int divisor = 1; @@ -390,10 +406,10 @@ namespace BizHawk.MultiClient { switch (GetDataSize()) { - case atype.WORD: + case Watch.TYPE.WORD: divisor = 2; break; - case atype.DWORD: + case Watch.TYPE.DWORD: divisor = 4; break; } @@ -401,30 +417,30 @@ namespace BizHawk.MultiClient for (int x = 0; x <= ((Domain.Size / divisor) - 1); x++) { - searchList.Add(new Watch()); - searchList[x].address = count; - searchList[x].type = GetDataSize(); - searchList[x].bigendian = GetBigEndian(); - searchList[x].signed = GetDataType(); - searchList[x].PeekAddress(Domain); - searchList[x].prev = searchList[x].value; - searchList[x].original = searchList[x].value; - searchList[x].lastchange = searchList[x].value; - searchList[x].lastsearch = searchList[x].value; - searchList[x].changecount = 0; + Searches.Add(new Watch()); + Searches[x].Address = count; + Searches[x].Type = GetDataSize(); + Searches[x].BigEndian = GetBigEndian(); + Searches[x].Signed = GetDataType(); + Searches[x].PeekAddress(Domain); + Searches[x].Prev = Searches[x].Value; + Searches[x].Original = Searches[x].Value; + Searches[x].LastChange = Searches[x].Value; + Searches[x].LastSearch = Searches[x].Value; + Searches[x].Changecount = 0; if (includeMisalignedToolStripMenuItem.Checked) count++; else { switch (GetDataSize()) { - case atype.BYTE: + case Watch.TYPE.BYTE: count++; break; - case atype.WORD: + case Watch.TYPE.WORD: count += 2; break; - case atype.DWORD: + case Watch.TYPE.DWORD: count += 4; break; } @@ -442,7 +458,7 @@ namespace BizHawk.MultiClient private void DisplaySearchList() { - SearchListView.ItemCount = searchList.Count; + SearchListView.ItemCount = Searches.Count; SetTotal(); } @@ -475,9 +491,9 @@ namespace BizHawk.MultiClient Global.Sound.StartSound(); int x = indexes[0]; - Watch bob = searchList[indexes[0]]; + Watch bob = Searches[indexes[0]]; if (indexes.Count > 0) - p.SetWatchObject(searchList[indexes[0]], Domain); + p.SetWatchObject(Searches[indexes[0]], Domain); p.location = GetPromptPoint(); p.ShowDialog(); UpdateValues(); @@ -507,7 +523,7 @@ namespace BizHawk.MultiClient MessageLabel.Text = MakeAddressString(indexes.Count) + " removed"; for (int x = 0; x < indexes.Count; x++) { - searchList.Remove(searchList[indexes[x] - x]); + Searches.Remove(Searches[indexes[x] - x]); } indexes.Clear(); DisplaySearchList(); @@ -526,7 +542,7 @@ namespace BizHawk.MultiClient private void SaveUndo() { undoList.Clear(); - undoList.AddRange(searchList); + undoList.AddRange(Searches); UndotoolStripButton.Enabled = true; } @@ -534,9 +550,9 @@ namespace BizHawk.MultiClient { if (undoList.Count > 0) { - MessageLabel.Text = MakeAddressString(undoList.Count - searchList.Count) + " restored"; - redoList = new List(searchList); - searchList = new List(undoList); + MessageLabel.Text = MakeAddressString(undoList.Count - Searches.Count) + " restored"; + redoList = new List(Searches); + Searches = new List(undoList); ClearUndo(); RedotoolStripButton2.Enabled = true; DisplaySearchList(); @@ -559,9 +575,9 @@ namespace BizHawk.MultiClient { if (redoList.Count > 0) { - MessageLabel.Text = MakeAddressString(searchList.Count - redoList.Count) + " removed"; - undoList = new List(searchList); - searchList = new List(redoList); + MessageLabel.Text = MakeAddressString(Searches.Count - redoList.Count) + " removed"; + undoList = new List(Searches); + Searches = new List(redoList); ClearRedo(); UndotoolStripButton.Enabled = true; DisplaySearchList(); @@ -579,10 +595,10 @@ namespace BizHawk.MultiClient { if (IsAWeededList && column == 0) { - if (searchList[index].deleted) + if (Searches[index].Deleted) { if (color == Color.Pink) return; - if (Global.CheatList.IsActiveCheat(Domain, searchList[index].address)) + if (Global.CheatList.IsActiveCheat(Domain, Searches[index].Address)) { if (color == Color.Purple) { @@ -605,7 +621,7 @@ namespace BizHawk.MultiClient } } } - else if (Global.CheatList.IsActiveCheat(Domain, searchList[index].address)) + else if (Global.CheatList.IsActiveCheat(Domain, Searches[index].Address)) { if (color == Color.LightCyan) { @@ -634,34 +650,34 @@ namespace BizHawk.MultiClient { if (column == 0) { - text = searchList[index].address.ToString(addressFormatStr); + text = Searches[index].Address.ToString(addressFormatStr); } else if (column == 1) { - text = searchList[index].ValueToString(); + text = Searches[index].ValueString; } else if (column == 2) { switch (Global.Config.RamSearchPreviousAs) { case 0: - text = searchList[index].LastSearchToString(); + text = Searches[index].LastSearchString; break; case 1: - text = searchList[index].OriginalToString(); + text = Searches[index].OriginalString; break; default: case 2: - text = searchList[index].PrevToString(); + text = Searches[index].PrevString; break; case 3: - text = searchList[index].LastChangeToString(); + text = Searches[index].LastChangeString; break; } } else if (column == 3) { - text = searchList[index].changecount.ToString(); + text = Searches[index].Changecount.ToString(); } else { @@ -672,9 +688,9 @@ namespace BizHawk.MultiClient private void ClearChangeCounts() { SaveUndo(); - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - searchList[x].changecount = 0; + Searches[x].Changecount = 0; } DisplaySearchList(); MessageLabel.Text = "Change counts cleared"; @@ -700,7 +716,7 @@ namespace BizHawk.MultiClient private void TrimWeededList() { - searchList = searchList.Where(x => x.deleted == false).ToList(); + Searches = Searches.Where(x => x.Deleted == false).ToList(); } private void DoSearch() @@ -708,7 +724,7 @@ namespace BizHawk.MultiClient if (GenerateWeedOutList()) { SaveUndo(); - MessageLabel.Text = MakeAddressString(searchList.Where(x => x.deleted == true).Count()) + " removed"; + MessageLabel.Text = MakeAddressString(Searches.Where(x => x.Deleted == true).Count()) + " removed"; TrimWeededList(); UpdateLastSearch(); DisplaySearchList(); @@ -784,14 +800,14 @@ namespace BizHawk.MultiClient switch (Global.Config.RamSearchPreviousAs) { case 0: - return searchList[pos].lastsearch; + return Searches[pos].LastSearch; case 1: - return searchList[pos].original; + return Searches[pos].Original; default: case 2: - return searchList[pos].prev; + return Searches[pos].Prev; case 3: - return searchList[pos].lastchange; + return Searches[pos].LastChange; } } @@ -800,169 +816,169 @@ namespace BizHawk.MultiClient switch (GetOperator()) { case SOperator.LESS: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { int previous = GetPreviousValue(x); - if (searchList[x].signed == asigned.SIGNED) + if (Searches[x].Signed == Watch.DISPTYPE.SIGNED) { - if (searchList[x].SignedVal(searchList[x].value) < searchList[x].SignedVal(previous)) + if (Searches[x].SignedVal(Searches[x].Value) < Searches[x].SignedVal(previous)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } else { - if (searchList[x].UnsignedVal(searchList[x].value) < searchList[x].UnsignedVal(previous)) + if (Searches[x].UnsignedVal(Searches[x].Value) < Searches[x].UnsignedVal(previous)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } } break; case SOperator.GREATER: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { int previous = GetPreviousValue(x); - if (searchList[x].signed == asigned.SIGNED) + if (Searches[x].Signed == Watch.DISPTYPE.SIGNED) { - if (searchList[x].SignedVal(searchList[x].value) > searchList[x].SignedVal(previous)) + if (Searches[x].SignedVal(Searches[x].Value) > Searches[x].SignedVal(previous)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } else { - if (searchList[x].UnsignedVal(searchList[x].value) > searchList[x].UnsignedVal(previous)) + if (Searches[x].UnsignedVal(Searches[x].Value) > Searches[x].UnsignedVal(previous)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = false; + Searches[x].Deleted = false; } } } break; case SOperator.LESSEQUAL: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { int previous = GetPreviousValue(x); - if (searchList[x].signed == asigned.SIGNED) + if (Searches[x].Signed == Watch.DISPTYPE.SIGNED) { - if (searchList[x].SignedVal(searchList[x].value) <= searchList[x].SignedVal(previous)) + if (Searches[x].SignedVal(Searches[x].Value) <= Searches[x].SignedVal(previous)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } else { - if (searchList[x].UnsignedVal(searchList[x].value) <= searchList[x].UnsignedVal(previous)) + if (Searches[x].UnsignedVal(Searches[x].Value) <= Searches[x].UnsignedVal(previous)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } } break; case SOperator.GREATEREQUAL: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { int previous = GetPreviousValue(x); - if (searchList[x].signed == asigned.SIGNED) + if (Searches[x].Signed == Watch.DISPTYPE.SIGNED) { - if (searchList[x].SignedVal(searchList[x].value) >= searchList[x].SignedVal(previous)) + if (Searches[x].SignedVal(Searches[x].Value) >= Searches[x].SignedVal(previous)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } else { - if (searchList[x].UnsignedVal(searchList[x].value) >= searchList[x].UnsignedVal(previous)) + if (Searches[x].UnsignedVal(Searches[x].Value) >= Searches[x].UnsignedVal(previous)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } } break; case SOperator.EQUAL: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { int previous = GetPreviousValue(x); - if (searchList[x].signed == asigned.SIGNED) + if (Searches[x].Signed == Watch.DISPTYPE.SIGNED) { - if (searchList[x].SignedVal(searchList[x].value) == searchList[x].SignedVal(previous)) + if (Searches[x].SignedVal(Searches[x].Value) == Searches[x].SignedVal(previous)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } else { - if (searchList[x].UnsignedVal(searchList[x].value) == searchList[x].UnsignedVal(previous)) + if (Searches[x].UnsignedVal(Searches[x].Value) == Searches[x].UnsignedVal(previous)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } } break; case SOperator.NOTEQUAL: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { int previous = GetPreviousValue(x); - if (searchList[x].signed == asigned.SIGNED) + if (Searches[x].Signed == Watch.DISPTYPE.SIGNED) { - if (searchList[x].SignedVal(searchList[x].value) != searchList[x].SignedVal(previous)) + if (Searches[x].SignedVal(Searches[x].Value) != Searches[x].SignedVal(previous)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } else { - if (searchList[x].UnsignedVal(searchList[x].value) != searchList[x].UnsignedVal(previous)) + if (Searches[x].UnsignedVal(Searches[x].Value) != Searches[x].UnsignedVal(previous)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } } @@ -970,29 +986,29 @@ namespace BizHawk.MultiClient case SOperator.DIFFBY: int diff = GetDifferentBy(); if (diff < 0) return false; - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { int previous = GetPreviousValue(x); - if (searchList[x].signed == asigned.SIGNED) + if (Searches[x].Signed == Watch.DISPTYPE.SIGNED) { - if (searchList[x].SignedVal(searchList[x].value) == searchList[x].SignedVal(previous) + diff || searchList[x].SignedVal(searchList[x].value) == searchList[x].SignedVal(previous) - diff) + if (Searches[x].SignedVal(Searches[x].Value) == Searches[x].SignedVal(previous) + diff || Searches[x].SignedVal(Searches[x].Value) == Searches[x].SignedVal(previous) - diff) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } else { - if (searchList[x].UnsignedVal(searchList[x].value) == searchList[x].UnsignedVal(previous) + diff || searchList[x].UnsignedVal(searchList[x].value) == searchList[x].UnsignedVal(previous) - diff) + if (Searches[x].UnsignedVal(Searches[x].Value) == Searches[x].UnsignedVal(previous) + diff || Searches[x].UnsignedVal(Searches[x].Value) == Searches[x].UnsignedVal(previous) - diff) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } } @@ -1020,164 +1036,164 @@ namespace BizHawk.MultiClient switch (GetOperator()) { case SOperator.LESS: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].signed == asigned.SIGNED) + if (Searches[x].Signed == Watch.DISPTYPE.SIGNED) { - if (searchList[x].SignedVal(searchList[x].value) < searchList[x].SignedVal((int)value)) + if (Searches[x].SignedVal(Searches[x].Value) < Searches[x].SignedVal((int)value)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } else { - if (searchList[x].UnsignedVal(searchList[x].value) < searchList[x].UnsignedVal((int)value)) + if (Searches[x].UnsignedVal(Searches[x].Value) < Searches[x].UnsignedVal((int)value)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } } break; case SOperator.GREATER: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].signed == asigned.SIGNED) + if (Searches[x].Signed == Watch.DISPTYPE.SIGNED) { - if (searchList[x].SignedVal(searchList[x].value) > searchList[x].SignedVal((int)value)) + if (Searches[x].SignedVal(Searches[x].Value) > Searches[x].SignedVal((int)value)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } else { - if (searchList[x].UnsignedVal(searchList[x].value) > searchList[x].UnsignedVal((int)value)) + if (Searches[x].UnsignedVal(Searches[x].Value) > Searches[x].UnsignedVal((int)value)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } } break; case SOperator.LESSEQUAL: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].signed == asigned.SIGNED) + if (Searches[x].Signed == Watch.DISPTYPE.SIGNED) { - if (searchList[x].SignedVal(searchList[x].value) <= searchList[x].SignedVal((int)value)) + if (Searches[x].SignedVal(Searches[x].Value) <= Searches[x].SignedVal((int)value)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } else { - if (searchList[x].UnsignedVal(searchList[x].value) <= searchList[x].UnsignedVal((int)value)) + if (Searches[x].UnsignedVal(Searches[x].Value) <= Searches[x].UnsignedVal((int)value)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } } break; case SOperator.GREATEREQUAL: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].signed == asigned.SIGNED) + if (Searches[x].Signed == Watch.DISPTYPE.SIGNED) { - if (searchList[x].SignedVal(searchList[x].value) >= searchList[x].SignedVal((int)value)) + if (Searches[x].SignedVal(Searches[x].Value) >= Searches[x].SignedVal((int)value)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } else { - if (searchList[x].UnsignedVal(searchList[x].value) >= searchList[x].UnsignedVal((int)value)) + if (Searches[x].UnsignedVal(Searches[x].Value) >= Searches[x].UnsignedVal((int)value)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } } break; case SOperator.EQUAL: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].signed == asigned.SIGNED) + if (Searches[x].Signed == Watch.DISPTYPE.SIGNED) { - if (searchList[x].SignedVal(searchList[x].value) == searchList[x].SignedVal((int)value)) + if (Searches[x].SignedVal(Searches[x].Value) == Searches[x].SignedVal((int)value)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } else { - if (searchList[x].UnsignedVal(searchList[x].value) == searchList[x].UnsignedVal((int)value)) + if (Searches[x].UnsignedVal(Searches[x].Value) == Searches[x].UnsignedVal((int)value)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } } break; case SOperator.NOTEQUAL: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].signed == asigned.SIGNED) + if (Searches[x].Signed == Watch.DISPTYPE.SIGNED) { - if (searchList[x].SignedVal(searchList[x].value) != searchList[x].SignedVal((int)value)) + if (Searches[x].SignedVal(Searches[x].Value) != Searches[x].SignedVal((int)value)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } else { - if (searchList[x].UnsignedVal(searchList[x].value) != searchList[x].UnsignedVal((int)value)) + if (Searches[x].UnsignedVal(Searches[x].Value) != Searches[x].UnsignedVal((int)value)) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } } @@ -1185,28 +1201,28 @@ namespace BizHawk.MultiClient case SOperator.DIFFBY: int diff = GetDifferentBy(); if (diff < 0) return false; - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].signed == asigned.SIGNED) + if (Searches[x].Signed == Watch.DISPTYPE.SIGNED) { - if (searchList[x].SignedVal(searchList[x].value) == searchList[x].SignedVal((int)value) + diff || searchList[x].SignedVal(searchList[x].value) == searchList[x].SignedVal((int)value) - diff) + if (Searches[x].SignedVal(Searches[x].Value) == Searches[x].SignedVal((int)value) + diff || Searches[x].SignedVal(Searches[x].Value) == Searches[x].SignedVal((int)value) - diff) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } else { - if (searchList[x].UnsignedVal(searchList[x].value) == searchList[x].UnsignedVal((int)value) + diff || searchList[x].UnsignedVal(searchList[x].value) == searchList[x].UnsignedVal((int)value) - diff) + if (Searches[x].UnsignedVal(Searches[x].Value) == Searches[x].UnsignedVal((int)value) + diff || Searches[x].UnsignedVal(Searches[x].Value) == Searches[x].UnsignedVal((int)value) - diff) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } } @@ -1221,27 +1237,27 @@ namespace BizHawk.MultiClient bool i = false; switch (GetDataType()) { - case asigned.UNSIGNED: + case Watch.DISPTYPE.UNSIGNED: i = InputValidate.IsValidUnsignedNumber(SpecificValueBox.Text); if (!i) return null; return (int)Int64.Parse(SpecificValueBox.Text); //Note: 64 to be safe since 4 byte values can be entered - case asigned.SIGNED: + case Watch.DISPTYPE.SIGNED: i = InputValidate.IsValidSignedNumber(SpecificValueBox.Text); if (!i) return null; int value = (int)Int64.Parse(SpecificValueBox.Text); switch (GetDataSize()) { - case atype.BYTE: + case Watch.TYPE.BYTE: return (int)(byte)value; - case atype.WORD: + case Watch.TYPE.WORD: return (int)(ushort)value; - case atype.DWORD: + case Watch.TYPE.DWORD: return (int)(uint)value; } return value; - case asigned.HEX: + case Watch.DISPTYPE.HEX: i = InputValidate.IsValidHexNumber(SpecificValueBox.Text); if (!i) return null; @@ -1287,80 +1303,80 @@ namespace BizHawk.MultiClient switch (GetOperator()) { case SOperator.LESS: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].address < address) + if (Searches[x].Address < address) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } break; case SOperator.GREATER: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].address > address) + if (Searches[x].Address > address) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } break; case SOperator.LESSEQUAL: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].address <= address) + if (Searches[x].Address <= address) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } break; case SOperator.GREATEREQUAL: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].address >= address) + if (Searches[x].Address >= address) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } break; case SOperator.EQUAL: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].address == address) + if (Searches[x].Address == address) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } break; case SOperator.NOTEQUAL: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].address != address) + if (Searches[x].Address != address) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } break; @@ -1368,15 +1384,15 @@ namespace BizHawk.MultiClient { int diff = GetDifferentBy(); if (diff < 0) return false; - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].address == address + diff || searchList[x].address == address - diff) + if (Searches[x].Address == address + diff || Searches[x].Address == address - diff) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } } @@ -1407,95 +1423,95 @@ namespace BizHawk.MultiClient switch (GetOperator()) { case SOperator.LESS: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].changecount < changes) + if (Searches[x].Changecount < changes) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } break; case SOperator.GREATER: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].changecount > changes) + if (Searches[x].Changecount > changes) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } break; case SOperator.LESSEQUAL: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].changecount <= changes) + if (Searches[x].Changecount <= changes) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } break; case SOperator.GREATEREQUAL: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].changecount >= changes) + if (Searches[x].Changecount >= changes) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } break; case SOperator.EQUAL: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].changecount == changes) + if (Searches[x].Changecount == changes) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } break; case SOperator.NOTEQUAL: - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].changecount != changes) + if (Searches[x].Changecount != changes) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } break; case SOperator.DIFFBY: int diff = GetDifferentBy(); if (diff < 0) return false; - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - if (searchList[x].address == changes + diff || searchList[x].address == changes - diff) + if (Searches[x].Address == changes + diff || Searches[x].Address == changes - diff) { - searchList[x].deleted = false; + Searches[x].Deleted = false; } else { - searchList[x].deleted = true; + Searches[x].Deleted = true; } } break; @@ -1503,23 +1519,23 @@ namespace BizHawk.MultiClient return true; } - private void ConvertListsDataType(asigned s) + private void ConvertListsDataType(Watch.DISPTYPE s) { - for (int x = 0; x < searchList.Count; x++) - searchList[x].signed = s; + for (int x = 0; x < Searches.Count; x++) + Searches[x].Signed = s; for (int x = 0; x < undoList.Count; x++) - undoList[x].signed = s; + undoList[x].Signed = s; for (int x = 0; x < redoList.Count; x++) - redoList[x].signed = s; + redoList[x].Signed = s; SetSpecificValueBoxMaxLength(); sortReverse = false; sortedCol = ""; DisplaySearchList(); } - private void ConvertListsDataSize(atype s, bool bigendian) + private void ConvertListsDataSize(Watch.TYPE s, bool bigendian) { - ConvertDataSize(s, bigendian, ref searchList); + ConvertDataSize(s, bigendian, ref Searches); ConvertDataSize(s, bigendian, ref undoList); ConvertDataSize(s, bigendian, ref redoList); SetSpecificValueBoxMaxLength(); @@ -1528,7 +1544,7 @@ namespace BizHawk.MultiClient DisplaySearchList(); } - private void ConvertDataSize(atype s, bool bigendian, ref List list) + private void ConvertDataSize(Watch.TYPE s, bool bigendian, ref List list) { List converted = new List(); int divisor = 1; @@ -1536,26 +1552,26 @@ namespace BizHawk.MultiClient { switch (s) { - case atype.WORD: + case Watch.TYPE.WORD: divisor = 2; break; - case atype.DWORD: + case Watch.TYPE.DWORD: divisor = 4; break; } } for (int x = 0; x < list.Count; x++) - if (list[x].address % divisor == 0) + if (list[x].Address % divisor == 0) { - int changes = list[x].changecount; - list[x].type = s; - list[x].bigendian = GetBigEndian(); + int changes = list[x].Changecount; + list[x].Type = s; + list[x].BigEndian = GetBigEndian(); list[x].PeekAddress(Domain); - list[x].prev = list[x].value; - list[x].original = list[x].value; - list[x].lastchange = list[x].value; - list[x].lastsearch = list[x].value; - list[x].changecount = changes; + list[x].Prev = list[x].Value; + list[x].Original = list[x].Value; + list[x].LastChange = list[x].Value; + list[x].LastSearch = list[x].Value; + list[x].Changecount = changes; converted.Add(list[x]); } list = converted; @@ -1566,15 +1582,15 @@ namespace BizHawk.MultiClient Watch specificValue = new Watch(); int? value = GetSpecificValue(); ValidateSpecificValue(value); - specificValue.value = (int)value; - specificValue.signed = asigned.UNSIGNED; - specificValue.type = GetDataSize(); - string converted = specificValue.ValueToString(); + specificValue.Value = (int)value; + specificValue.Signed = Watch.DISPTYPE.UNSIGNED; + specificValue.Type = GetDataSize(); + string converted = specificValue.ValueString; unsignedToolStripMenuItem.Checked = true; signedToolStripMenuItem.Checked = false; hexadecimalToolStripMenuItem.Checked = false; SpecificValueBox.Text = converted; - ConvertListsDataType(asigned.UNSIGNED); + ConvertListsDataType(Watch.DISPTYPE.UNSIGNED); } private void signedToolStripMenuItem_Click(object sender, EventArgs e) @@ -1582,15 +1598,15 @@ namespace BizHawk.MultiClient Watch specificValue = new Watch(); int? value = GetSpecificValue(); ValidateSpecificValue(value); - specificValue.value = (int)value; - specificValue.signed = asigned.SIGNED; - specificValue.type = GetDataSize(); - string converted = specificValue.ValueToString(); + specificValue.Value = (int)value; + specificValue.Signed = Watch.DISPTYPE.SIGNED; + specificValue.Type = GetDataSize(); + string converted = specificValue.ValueString; unsignedToolStripMenuItem.Checked = false; signedToolStripMenuItem.Checked = true; hexadecimalToolStripMenuItem.Checked = false; SpecificValueBox.Text = converted; - ConvertListsDataType(asigned.SIGNED); + ConvertListsDataType(Watch.DISPTYPE.SIGNED); } private void hexadecimalToolStripMenuItem_Click(object sender, EventArgs e) @@ -1598,15 +1614,15 @@ namespace BizHawk.MultiClient Watch specificValue = new Watch(); int? value = GetSpecificValue(); ValidateSpecificValue(value); - specificValue.value = (int)value; - specificValue.signed = asigned.HEX; - specificValue.type = GetDataSize(); - string converted = specificValue.ValueToString(); + specificValue.Value = (int)value; + specificValue.Signed = Watch.DISPTYPE.HEX; + specificValue.Type = GetDataSize(); + string converted = specificValue.ValueString; unsignedToolStripMenuItem.Checked = false; signedToolStripMenuItem.Checked = false; hexadecimalToolStripMenuItem.Checked = true; SpecificValueBox.Text = converted; - ConvertListsDataType(asigned.HEX); + ConvertListsDataType(Watch.DISPTYPE.HEX); } private void SearchListView_MouseDoubleClick(object sender, MouseEventArgs e) @@ -1622,16 +1638,16 @@ namespace BizHawk.MultiClient { switch (GetDataType()) { - case asigned.UNSIGNED: + case Watch.DISPTYPE.UNSIGNED: switch (GetDataSize()) { - case atype.BYTE: + case Watch.TYPE.BYTE: SpecificValueBox.MaxLength = 3; break; - case atype.WORD: + case Watch.TYPE.WORD: SpecificValueBox.MaxLength = 5; break; - case atype.DWORD: + case Watch.TYPE.DWORD: SpecificValueBox.MaxLength = 10; break; default: @@ -1639,16 +1655,16 @@ namespace BizHawk.MultiClient break; } break; - case asigned.SIGNED: + case Watch.DISPTYPE.SIGNED: switch (GetDataSize()) { - case atype.BYTE: + case Watch.TYPE.BYTE: SpecificValueBox.MaxLength = 4; break; - case atype.WORD: + case Watch.TYPE.WORD: SpecificValueBox.MaxLength = 6; break; - case atype.DWORD: + case Watch.TYPE.DWORD: SpecificValueBox.MaxLength = 11; break; default: @@ -1656,16 +1672,16 @@ namespace BizHawk.MultiClient break; } break; - case asigned.HEX: + case Watch.DISPTYPE.HEX: switch (GetDataSize()) { - case atype.BYTE: + case Watch.TYPE.BYTE: SpecificValueBox.MaxLength = 2; break; - case atype.WORD: + case Watch.TYPE.WORD: SpecificValueBox.MaxLength = 4; break; - case atype.DWORD: + case Watch.TYPE.DWORD: SpecificValueBox.MaxLength = 8; break; default: @@ -1684,7 +1700,7 @@ namespace BizHawk.MultiClient byteToolStripMenuItem.Checked = true; bytesToolStripMenuItem.Checked = false; dWordToolStripMenuItem1.Checked = false; - ConvertListsDataSize(atype.BYTE, GetBigEndian()); + ConvertListsDataSize(Watch.TYPE.BYTE, GetBigEndian()); } private void bytesToolStripMenuItem_Click(object sender, EventArgs e) @@ -1692,7 +1708,7 @@ namespace BizHawk.MultiClient byteToolStripMenuItem.Checked = false; bytesToolStripMenuItem.Checked = true; dWordToolStripMenuItem1.Checked = false; - ConvertListsDataSize(atype.WORD, GetBigEndian()); + ConvertListsDataSize(Watch.TYPE.WORD, GetBigEndian()); } private void dWordToolStripMenuItem1_Click(object sender, EventArgs e) @@ -1700,7 +1716,7 @@ namespace BizHawk.MultiClient byteToolStripMenuItem.Checked = false; bytesToolStripMenuItem.Checked = false; dWordToolStripMenuItem1.Checked = true; - ConvertListsDataSize(atype.DWORD, GetBigEndian()); + ConvertListsDataSize(Watch.TYPE.DWORD, GetBigEndian()); } private void includeMisalignedToolStripMenuItem_Click_1(object sender, EventArgs e) @@ -1772,7 +1788,7 @@ namespace BizHawk.MultiClient private bool SaveSearchFile(string path) { - return WatchCommon.SaveWchFile(path, Domain.Name, searchList); + return WatchCommon.SaveWchFile(path, Domain.Name, Searches); } public void SaveAs() @@ -1789,7 +1805,7 @@ namespace BizHawk.MultiClient private void LoadSearchFromRecent(string file) { - bool r = LoadSearchFile(file, false, false, searchList); + bool r = LoadSearchFile(file, false, false, Searches); if (!r) { DialogResult result = MessageBox.Show("Could not open " + file + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); @@ -1859,7 +1875,7 @@ namespace BizHawk.MultiClient { var file = GetFileFromUser(); if (file != null) - LoadSearchFile(file.FullName, true, false, searchList); + LoadSearchFile(file.FullName, true, false, Searches); DisplaySearchList(); } @@ -1940,7 +1956,7 @@ namespace BizHawk.MultiClient private void searchToolStripMenuItem_DropDownOpened(object sender, EventArgs e) { - if (searchList.Count == 0) + if (Searches.Count == 0) searchToolStripMenuItem.Enabled = false; else searchToolStripMenuItem.Enabled = true; @@ -2056,17 +2072,23 @@ namespace BizHawk.MultiClient switch (GetDataType()) { - case asigned.UNSIGNED: + case Watch.DISPTYPE.UNSIGNED: if (!InputValidate.IsValidUnsignedNumber(e.KeyChar)) + { e.Handled = true; + } break; - case asigned.SIGNED: + case Watch.DISPTYPE.SIGNED: if (!InputValidate.IsValidSignedNumber(e.KeyChar)) + { e.Handled = true; + } break; - case asigned.HEX: + case Watch.DISPTYPE.HEX: if (!InputValidate.IsValidHexNumber(e.KeyChar)) + { e.Handled = true; + } break; } } @@ -2119,7 +2141,7 @@ namespace BizHawk.MultiClient { SaveUndo(); - MessageLabel.Text = MakeAddressString(searchList.Where(x => x.deleted == true).Count()) + " removed"; + MessageLabel.Text = MakeAddressString(Searches.Where(x => x.Deleted == true).Count()) + " removed"; TrimWeededList(); UpdateLastSearch(); DisplaySearchList(); @@ -2141,9 +2163,9 @@ namespace BizHawk.MultiClient private void ClearWeeded() { - foreach (Watch watch in searchList) + foreach (Watch watch in Searches) { - watch.deleted = false; + watch.Deleted = false; } } @@ -2153,7 +2175,7 @@ namespace BizHawk.MultiClient ClearWeeded(); foreach (Watch watch in toRemove) { - searchList.Where(x => x.address == watch.address).FirstOrDefault().deleted = true; + Searches.Where(x => x.Address == watch.Address).FirstOrDefault().Deleted = true; } DoTruncate(); } @@ -2188,12 +2210,12 @@ namespace BizHawk.MultiClient private void CopyValueToPrev() { - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - searchList[x].lastsearch = searchList[x].value; - searchList[x].original = searchList[x].value; - searchList[x].prev = searchList[x].value; - searchList[x].lastchange = searchList[x].value; + Searches[x].LastSearch = Searches[x].Value; + Searches[x].Original = Searches[x].Value; + Searches[x].Prev = Searches[x].Value; + Searches[x].LastChange = Searches[x].Value; } DisplaySearchList(); DoPreview(); @@ -2201,9 +2223,9 @@ namespace BizHawk.MultiClient private void UpdateLastSearch() { - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { - searchList[x].lastsearch = searchList[x].value; + Searches[x].LastSearch = Searches[x].Value; } } @@ -2252,20 +2274,20 @@ namespace BizHawk.MultiClient { for (int i = 0; i < indexes.Count; i++) { - switch (searchList[indexes[i]].type) + switch (Searches[indexes[i]].Type) { - case atype.BYTE: - Global.CheatList.Remove(Domain, searchList[indexes[i]].address); + case Watch.TYPE.BYTE: + Global.CheatList.Remove(Domain, Searches[indexes[i]].Address); break; - case atype.WORD: - Global.CheatList.Remove(Domain, searchList[indexes[i]].address); - Global.CheatList.Remove(Domain, searchList[indexes[i]].address + 1); + case Watch.TYPE.WORD: + Global.CheatList.Remove(Domain, Searches[indexes[i]].Address); + Global.CheatList.Remove(Domain, Searches[indexes[i]].Address + 1); break; - case atype.DWORD: - Global.CheatList.Remove(Domain, searchList[indexes[i]].address); - Global.CheatList.Remove(Domain, searchList[indexes[i]].address + 1); - Global.CheatList.Remove(Domain, searchList[indexes[i]].address + 2); - Global.CheatList.Remove(Domain, searchList[indexes[i]].address + 3); + case Watch.TYPE.DWORD: + Global.CheatList.Remove(Domain, Searches[indexes[i]].Address); + Global.CheatList.Remove(Domain, Searches[indexes[i]].Address + 1); + Global.CheatList.Remove(Domain, Searches[indexes[i]].Address + 2); + Global.CheatList.Remove(Domain, Searches[indexes[i]].Address + 3); break; } } @@ -2279,20 +2301,20 @@ namespace BizHawk.MultiClient { for (int i = 0; i < indexes.Count; i++) { - switch (searchList[indexes[i]].type) + switch (Searches[indexes[i]].Type) { - case atype.BYTE: - Cheat c = new Cheat("", searchList[indexes[i]].address, (byte)searchList[indexes[i]].value, + case Watch.TYPE.BYTE: + Cheat c = new Cheat("", Searches[indexes[i]].Address, (byte)Searches[indexes[i]].Value, true, Domain); Global.MainForm.Cheats1.AddCheat(c); break; - case atype.WORD: + case Watch.TYPE.WORD: { - byte low = (byte)(searchList[indexes[i]].value / 256); - byte high = (byte)(searchList[indexes[i]].value); - int a1 = searchList[indexes[i]].address; - int a2 = searchList[indexes[i]].address + 1; - if (searchList[indexes[i]].bigendian) + byte low = (byte)(Searches[indexes[i]].Value / 256); + byte high = (byte)(Searches[indexes[i]].Value); + int a1 = Searches[indexes[i]].Address; + int a2 = Searches[indexes[i]].Address + 1; + if (Searches[indexes[i]].BigEndian) { Cheat c1 = new Cheat("", a1, low, true, Domain); Cheat c2 = new Cheat("", a2, high, true, Domain); @@ -2308,17 +2330,17 @@ namespace BizHawk.MultiClient } } break; - case atype.DWORD: + case Watch.TYPE.DWORD: { - byte HIWORDhigh = (byte)(searchList[indexes[i]].value / 0x1000000); - byte HIWORDlow = (byte)(searchList[indexes[i]].value / 0x10000); - byte LOWORDhigh = (byte)(searchList[indexes[i]].value / 0x100); - byte LOWORDlow = (byte)(searchList[indexes[i]].value); - int a1 = searchList[indexes[i]].address; - int a2 = searchList[indexes[i]].address + 1; - int a3 = searchList[indexes[i]].address + 2; - int a4 = searchList[indexes[i]].address + 3; - if (searchList[indexes[i]].bigendian) + byte HIWORDhigh = (byte)(Searches[indexes[i]].Value / 0x1000000); + byte HIWORDlow = (byte)(Searches[indexes[i]].Value / 0x10000); + byte LOWORDhigh = (byte)(Searches[indexes[i]].Value / 0x100); + byte LOWORDlow = (byte)(Searches[indexes[i]].Value); + int a1 = Searches[indexes[i]].Address; + int a2 = Searches[indexes[i]].Address + 1; + int a3 = Searches[indexes[i]].Address + 2; + int a4 = Searches[indexes[i]].Address + 3; + if (Searches[indexes[i]].BigEndian) { Cheat c1 = new Cheat("", a1, HIWORDhigh, true, Domain); Cheat c2 = new Cheat("", a2, HIWORDlow, true, Domain); @@ -2369,7 +2391,7 @@ namespace BizHawk.MultiClient if (indexes.Count == 1) { - if (Global.CheatList.IsActiveCheat(Domain, searchList[indexes[0]].address)) + if (Global.CheatList.IsActiveCheat(Domain, Searches[indexes[0]].Address)) { contextMenuStrip1.Items[6].Text = "&Unfreeze address"; contextMenuStrip1.Items[6].Image = @@ -2508,7 +2530,7 @@ namespace BizHawk.MultiClient string[] filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); if (Path.GetExtension(filePaths[0]) == (".wch")) { - LoadSearchFile(filePaths[0], false, false, searchList); + LoadSearchFile(filePaths[0], false, false, Searches); DisplaySearchList(); } } @@ -2518,7 +2540,7 @@ namespace BizHawk.MultiClient string columnName = SearchListView.Columns[columnToOrder].Text; if (sortedCol.CompareTo(columnName) != 0) sortReverse = false; - searchList.Sort((x, y) => x.CompareTo(y, columnName, (prevDef)Global.Config.RamSearchPreviousAs) * (sortReverse ? -1 : 1)); + Searches.Sort((x, y) => x.CompareTo(y, columnName, (Watch.PREVDEF)Global.Config.RamSearchPreviousAs) * (sortReverse ? -1 : 1)); sortedCol = columnName; sortReverse = !(sortReverse); SearchListView.Refresh(); @@ -2562,7 +2584,7 @@ namespace BizHawk.MultiClient } else if (e.KeyCode == Keys.A && e.Control && !e.Alt && !e.Shift) //Select All { - for (int x = 0; x < searchList.Count; x++) + for (int x = 0; x < Searches.Count; x++) { SearchListView.SelectItem(x, true); } @@ -2580,7 +2602,7 @@ namespace BizHawk.MultiClient if (indexes.Count > 0) { Global.MainForm.LoadHexEditor(); - Global.MainForm.HexEditor1.GoToAddress(searchList[indexes[0]].address); + Global.MainForm.HexEditor1.GoToAddress(Searches[indexes[0]].Address); } } diff --git a/BizHawk.MultiClient/tools/RamWatch.cs b/BizHawk.MultiClient/tools/RamWatch.cs index 63cc4e3849..c6e40be42e 100644 --- a/BizHawk.MultiClient/tools/RamWatch.cs +++ b/BizHawk.MultiClient/tools/RamWatch.cs @@ -33,7 +33,7 @@ namespace BizHawk.MultiClient string systemID = "NULL"; MemoryDomain Domain = new MemoryDomain("NULL", 1, Endian.Little, addr => 0, (a, v) => { }); - List watchList = new List(); + List Watches = new List(); string currentFile = ""; bool changes = false; List domainMenuItems = new List(); @@ -62,15 +62,15 @@ namespace BizHawk.MultiClient public List GetRamWatchList() { List w = new List(); - for (int x = 0; x < watchList.Count; x++) - w.Add(new Watch(watchList[x])); + for (int x = 0; x < Watches.Count; x++) + w.Add(new Watch(Watches[x])); return w; } public void DisplayWatchList() { - WatchListView.ItemCount = watchList.Count; + WatchListView.ItemCount = Watches.Count; } public void UpdateValues() @@ -80,17 +80,17 @@ namespace BizHawk.MultiClient return; } - for (int x = 0; x < watchList.Count; x++) + for (int x = 0; x < Watches.Count; x++) { - watchList[x].PeekAddress(Domain); + Watches[x].PeekAddress(Domain); } if (Global.Config.DisplayRamWatch) { - for (int x = 0; x < watchList.Count; x++) + for (int x = 0; x < Watches.Count; x++) { - bool alert = Global.CheatList.IsActiveCheat(Domain, watchList[x].address); - Global.OSD.AddGUIText(watchList[x].ToString(), + bool alert = Global.CheatList.IsActiveCheat(Domain, Watches[x].Address); + Global.OSD.AddGUIText(Watches[x].ToString(), Global.Config.DispRamWatchx, (Global.Config.DispRamWatchy + (x * 14)), alert, Color.Black, Color.White, 0); } } @@ -106,7 +106,7 @@ namespace BizHawk.MultiClient public void AddWatch(Watch w) { - watchList.Add(w); + Watches.Add(w); Changes(); UpdateValues(); DisplayWatchList(); @@ -186,80 +186,72 @@ namespace BizHawk.MultiClient private void WatchListView_QueryItemBkColor(int index, int column, ref Color color) { - if (index >= watchList.Count) + if (index >= Watches.Count) { return; } if (column == 0) { - if (watchList[index].type == atype.SEPARATOR) + if (Watches[index].Type == Watch.TYPE.SEPARATOR) + { color = this.BackColor; - if (Global.CheatList.IsActiveCheat(Domain, watchList[index].address)) + } + if (Global.CheatList.IsActiveCheat(Domain, Watches[index].Address)) + { color = Color.LightCyan; + } } } void WatchListView_QueryItemText(int index, int column, out string text) { text = ""; - if (index >= watchList.Count) + + if (Watches[index].Type == Watch.TYPE.SEPARATOR || index >= Watches.Count) { return; } if (column == 0) //Address { - if (watchList[index].type != atype.SEPARATOR) - { - text = watchList[index].address.ToString(addressFormatStr); - } + text = Watches[index].Address.ToString(addressFormatStr); } if (column == 1) //Value { - text = watchList[index].ValueToString(); + text = Watches[index].ValueString; } if (column == 2) //Prev { - if (watchList[index].type != atype.SEPARATOR) + switch(Global.Config.RamWatchPrev_Type) { - switch(Global.Config.RamWatchPrev_Type) - { - case 1: - text = watchList[index].PrevToString(); - break; - case 2: - text = watchList[index].LastChangeToString(); - break; - } + case 1: + text = Watches[index].PrevString; + break; + case 2: + text = Watches[index].LastChangeString; + break; } } if (column == 3) //Change Counts { - if (watchList[index].type != atype.SEPARATOR) - text = watchList[index].changecount.ToString(); + text = Watches[index].Changecount.ToString(); } if (column == 4) //Diff { - if (watchList[index].type != atype.SEPARATOR) + switch(Global.Config.RamWatchPrev_Type) { - switch(Global.Config.RamWatchPrev_Type) - { - case 1: - text = watchList[index].DiffToString(watchList[index].diffPrev); - break; - case 2: - text = watchList[index].DiffToString(watchList[index].diffLastChange); - break; - } + case 1: + text = Watches[index].DiffToString(Watches[index].DiffPrev); + break; + case 2: + text = Watches[index].DiffToString(Watches[index].DiffLastChange); + break; } } if (column == 5) //Notes { - if (watchList[index].type == atype.SEPARATOR) - text = ""; - else - text = watchList[index].notes; + text = Watches[index].Notes; } } @@ -319,7 +311,7 @@ namespace BizHawk.MultiClient if (result == true || suppressAsk) { - watchList.Clear(); + Watches.Clear(); DisplayWatchList(); UpdateWatchCount(); currentFile = ""; @@ -332,15 +324,15 @@ namespace BizHawk.MultiClient private bool SaveWatchFile(string path) { - return WatchCommon.SaveWchFile(path, Domain.Name, watchList); + return WatchCommon.SaveWchFile(path, Domain.Name, Watches); } private void UpdateWatchCount() { int count = 0; - foreach (Watch w in watchList) + foreach (Watch w in Watches) { - if (!(w.type == atype.SEPARATOR)) + if (!(w.Type == Watch.TYPE.SEPARATOR)) { count++; } @@ -352,11 +344,11 @@ namespace BizHawk.MultiClient public bool LoadWatchFile(string path, bool append) { string domain = ""; - bool result = WatchCommon.LoadWatchFile(path, append, watchList, out domain); + bool result = WatchCommon.LoadWatchFile(path, append, Watches, out domain); if (result) { - foreach (Watch w in watchList) + foreach (Watch w in Watches) { InitializeAddress(w); } @@ -396,7 +388,7 @@ namespace BizHawk.MultiClient if (r.userSelected == true) { InitializeAddress(r.watch); - watchList.Add(r.watch); + Watches.Add(r.watch); Changes(); UpdateWatchCount(); DisplayWatchList(); @@ -406,11 +398,11 @@ namespace BizHawk.MultiClient private void InitializeAddress(Watch w) { w.PeekAddress(Domain); - w.prev = w.value; - w.original = w.value; - w.lastchange = w.value; - w.lastsearch = w.value; - w.changecount = 0; + w.Prev = w.Value; + w.Original = w.Value; + w.LastChange = w.Value; + w.LastSearch = w.Value; + w.Changecount = 0; } void Changes() @@ -423,7 +415,7 @@ namespace BizHawk.MultiClient { RamWatchNewWatch r = new RamWatchNewWatch(); r.location = GetPromptPoint(); - r.SetToEditWatch(watchList[pos], "Edit Watch"); + r.SetToEditWatch(Watches[pos], "Edit Watch"); Global.Sound.StopSound(); r.ShowDialog(); Global.Sound.StartSound(); @@ -431,7 +423,7 @@ namespace BizHawk.MultiClient if (r.userSelected == true) { Changes(); - watchList[pos] = r.watch; + Watches[pos] = r.watch; DisplayWatchList(); } } @@ -452,7 +444,7 @@ namespace BizHawk.MultiClient { foreach (int index in indexes) { - watchList.Remove(watchList[indexes[0]]); //index[0] used since each iteration will make this the correct list index + Watches.Remove(Watches[indexes[0]]); //index[0] used since each iteration will make this the correct list index } indexes.Clear(); DisplayWatchList(); @@ -469,7 +461,7 @@ namespace BizHawk.MultiClient RamWatchNewWatch r = new RamWatchNewWatch(); r.location = GetPromptPoint(); int x = indexes[0]; - r.SetToEditWatch(watchList[x], "Duplicate Watch"); + r.SetToEditWatch(Watches[x], "Duplicate Watch"); Global.Sound.StopSound(); r.ShowDialog(); @@ -479,7 +471,7 @@ namespace BizHawk.MultiClient { InitializeAddress(r.watch); Changes(); - watchList.Add(r.watch); + Watches.Add(r.watch); DisplayWatchList(); } } @@ -498,9 +490,9 @@ namespace BizHawk.MultiClient if (indexes.Count == 0) return; foreach (int index in indexes) { - temp = watchList[index]; - watchList.Remove(watchList[index]); - watchList.Insert(index - 1, temp); + temp = Watches[index]; + Watches.Remove(Watches[index]); + Watches.Insert(index - 1, temp); //Note: here it will get flagged many times redundantly potentially, //but this avoids it being flagged falsely when the user did not select an index @@ -525,13 +517,13 @@ namespace BizHawk.MultiClient if (indexes.Count == 0) return; foreach (int index in indexes) { - temp = watchList[index]; + temp = Watches[index]; - if (index < watchList.Count - 1) + if (index < Watches.Count - 1) { - watchList.Remove(watchList[index]); - watchList.Insert(index + 1, temp); + Watches.Remove(Watches[index]); + Watches.Insert(index + 1, temp); } @@ -754,13 +746,13 @@ namespace BizHawk.MultiClient if (InputValidate.IsValidHexNumber(Str)) { - watchList[e.Item].address = int.Parse(Str, NumberStyles.HexNumber); + Watches[e.Item].Address = int.Parse(Str, NumberStyles.HexNumber); EditWatchObject(index); } else { MessageBox.Show("Invalid number!"); //TODO: More parameters and better message - WatchListView.Items[index].Text = watchList[index].address.ToString(); //TODO: Why doesn't the list view update to the new value? It won't until something else changes + WatchListView.Items[index].Text = Watches[index].Address.ToString(); //TODO: Why doesn't the list view update to the new value? It won't until something else changes } } @@ -817,7 +809,7 @@ namespace BizHawk.MultiClient { Changes(); Watch w = new Watch(); - w.type = atype.SEPARATOR; + w.Type = Watch.TYPE.SEPARATOR; ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices; int x; @@ -825,10 +817,10 @@ namespace BizHawk.MultiClient { x = indexes[0]; if (indexes[0] > 0) - watchList.Insert(indexes[0], w); + Watches.Insert(indexes[0], w); } else - watchList.Add(w); + Watches.Add(w); DisplayWatchList(); } @@ -884,7 +876,7 @@ namespace BizHawk.MultiClient RamPoke p = new RamPoke(); Global.Sound.StartSound(); if (indexes.Count > 0) - p.SetWatchObject(watchList[indexes[0]], Domain); + p.SetWatchObject(Watches[indexes[0]], Domain); p.location = GetPromptPoint(); p.ShowDialog(); UpdateValues(); @@ -979,7 +971,7 @@ namespace BizHawk.MultiClient if (indexes.Count == 1) { - if (Global.CheatList.IsActiveCheat(Domain, watchList[indexes[0]].address)) + if (Global.CheatList.IsActiveCheat(Domain, Watches[indexes[0]].Address)) { contextMenuStrip1.Items[4].Text = "&Unfreeze address"; contextMenuStrip1.Items[4].Image = @@ -1036,8 +1028,8 @@ namespace BizHawk.MultiClient private void ClearChangeCounts() { - for (int x = 0; x < watchList.Count; x++) - watchList[x].changecount = 0; + for (int x = 0; x < Watches.Count; x++) + Watches[x].Changecount = 0; DisplayWatchList(); MessageLabel.Text = "Change counts cleared"; } @@ -1108,7 +1100,7 @@ namespace BizHawk.MultiClient if (indexes.Count > 0) { Global.MainForm.LoadHexEditor(); - Global.MainForm.HexEditor1.GoToAddress(watchList[indexes[0]].address); + Global.MainForm.HexEditor1.GoToAddress(Watches[indexes[0]].Address); } } @@ -1148,20 +1140,20 @@ namespace BizHawk.MultiClient { for (int i = 0; i < indexes.Count; i++) { - switch (watchList[indexes[i]].type) + switch (Watches[indexes[i]].Type) { - case atype.BYTE: - Cheat c = new Cheat("", watchList[indexes[i]].address, (byte)watchList[indexes[i]].value, + case Watch.TYPE.BYTE: + Cheat c = new Cheat("", Watches[indexes[i]].Address, (byte)Watches[indexes[i]].Value, true, Domain); Global.MainForm.Cheats1.AddCheat(c); break; - case atype.WORD: + case Watch.TYPE.WORD: { - byte low = (byte)(watchList[indexes[i]].value / 256); - byte high = (byte)(watchList[indexes[i]].value); - int a1 = watchList[indexes[i]].address; - int a2 = watchList[indexes[i]].address + 1; - if (watchList[indexes[i]].bigendian) + byte low = (byte)(Watches[indexes[i]].Value / 256); + byte high = (byte)(Watches[indexes[i]].Value); + int a1 = Watches[indexes[i]].Address; + int a2 = Watches[indexes[i]].Address + 1; + if (Watches[indexes[i]].BigEndian) { Cheat c1 = new Cheat("", a1, low, true, Domain); Cheat c2 = new Cheat("", a2, high, true, Domain); @@ -1177,17 +1169,17 @@ namespace BizHawk.MultiClient } } break; - case atype.DWORD: + case Watch.TYPE.DWORD: { - byte HIWORDhigh = (byte)(watchList[indexes[i]].value / 0x1000000); - byte HIWORDlow = (byte)(watchList[indexes[i]].value / 0x10000); - byte LOWORDhigh = (byte)(watchList[indexes[i]].value / 0x100); - byte LOWORDlow = (byte)(watchList[indexes[i]].value); - int a1 = watchList[indexes[i]].address; - int a2 = watchList[indexes[i]].address + 1; - int a3 = watchList[indexes[i]].address + 2; - int a4 = watchList[indexes[i]].address + 3; - if (watchList[indexes[i]].bigendian) + byte HIWORDhigh = (byte)(Watches[indexes[i]].Value / 0x1000000); + byte HIWORDlow = (byte)(Watches[indexes[i]].Value / 0x10000); + byte LOWORDhigh = (byte)(Watches[indexes[i]].Value / 0x100); + byte LOWORDlow = (byte)(Watches[indexes[i]].Value); + int a1 = Watches[indexes[i]].Address; + int a2 = Watches[indexes[i]].Address + 1; + int a3 = Watches[indexes[i]].Address + 2; + int a4 = Watches[indexes[i]].Address + 3; + if (Watches[indexes[i]].BigEndian) { Cheat c1 = new Cheat("", a1, HIWORDhigh, true, Domain); Cheat c2 = new Cheat("", a2, HIWORDlow, true, Domain); @@ -1223,20 +1215,20 @@ namespace BizHawk.MultiClient { for (int i = 0; i < indexes.Count; i++) { - switch (watchList[indexes[i]].type) + switch (Watches[indexes[i]].Type) { - case atype.BYTE: - Global.CheatList.Remove(Domain, watchList[indexes[i]].address); + case Watch.TYPE.BYTE: + Global.CheatList.Remove(Domain, Watches[indexes[i]].Address); break; - case atype.WORD: - Global.CheatList.Remove(Domain, watchList[indexes[i]].address); - Global.CheatList.Remove(Domain, watchList[indexes[i]].address + 1); + case Watch.TYPE.WORD: + Global.CheatList.Remove(Domain, Watches[indexes[i]].Address); + Global.CheatList.Remove(Domain, Watches[indexes[i]].Address + 1); break; - case atype.DWORD: - Global.CheatList.Remove(Domain, watchList[indexes[i]].address); - Global.CheatList.Remove(Domain, watchList[indexes[i]].address + 1); - Global.CheatList.Remove(Domain, watchList[indexes[i]].address + 2); - Global.CheatList.Remove(Domain, watchList[indexes[i]].address + 3); + case Watch.TYPE.DWORD: + Global.CheatList.Remove(Domain, Watches[indexes[i]].Address); + Global.CheatList.Remove(Domain, Watches[indexes[i]].Address + 1); + Global.CheatList.Remove(Domain, Watches[indexes[i]].Address + 2); + Global.CheatList.Remove(Domain, Watches[indexes[i]].Address + 3); break; } } @@ -1398,7 +1390,7 @@ namespace BizHawk.MultiClient string columnName = WatchListView.Columns[columnToOrder].Text; if (sortedCol.CompareTo(columnName) != 0) sortReverse = false; - watchList.Sort((x, y) => x.CompareTo(y, columnName, Global.Config.RamWatchPrev_Type == 1 ? prevDef.LASTFRAME : prevDef.LASTCHANGE) * (sortReverse ? -1 : 1)); + Watches.Sort((x, y) => x.CompareTo(y, columnName, Global.Config.RamWatchPrev_Type == 1 ? Watch.PREVDEF.LASTFRAME : Watch.PREVDEF.LASTCHANGE) * (sortReverse ? -1 : 1)); sortedCol = columnName; sortReverse = !(sortReverse); WatchListView.Refresh(); @@ -1426,7 +1418,7 @@ namespace BizHawk.MultiClient private void SelectAll() { - for (int x = 0; x < watchList.Count; x++) + for (int x = 0; x < Watches.Count; x++) WatchListView.SelectItem(x, true); } @@ -1453,7 +1445,7 @@ namespace BizHawk.MultiClient } else if (e.KeyCode == Keys.A && e.Control && !e.Alt && !e.Shift) //Select All { - for (int x = 0; x < watchList.Count; x++) + for (int x = 0; x < Watches.Count; x++) { WatchListView.SelectItem(x, true); } diff --git a/BizHawk.MultiClient/tools/RamWatchNewWatch.cs b/BizHawk.MultiClient/tools/RamWatchNewWatch.cs index ec4d59cde2..e6d8deed9e 100644 --- a/BizHawk.MultiClient/tools/RamWatchNewWatch.cs +++ b/BizHawk.MultiClient/tools/RamWatchNewWatch.cs @@ -22,17 +22,17 @@ namespace BizHawk.MultiClient InitializeComponent(); } - private void SetTypeRadio(atype a) + private void SetTypeRadio(Watch.TYPE a) { switch (a) { - case atype.BYTE: + case Watch.TYPE.BYTE: Byte1Radio.Checked = true; break; - case atype.WORD: + case Watch.TYPE.WORD: Byte2Radio.Checked = true; break; - case atype.DWORD: + case Watch.TYPE.DWORD: Byte4Radio.Checked = true; break; default: @@ -40,17 +40,17 @@ namespace BizHawk.MultiClient } } - private void SetSignedRadio(asigned a) + private void SetSignedRadio(Watch.DISPTYPE a) { switch (a) { - case asigned.SIGNED: + case Watch.DISPTYPE.SIGNED: SignedRadio.Checked = true; break; - case asigned.UNSIGNED: + case Watch.DISPTYPE.UNSIGNED: UnsignedRadio.Checked = true; break; - case asigned.HEX: + case Watch.DISPTYPE.HEX: HexRadio.Checked = true; break; default: @@ -64,13 +64,13 @@ namespace BizHawk.MultiClient this.Text = message; customSetup = true; - AddressBox.Text = string.Format("{0:X4}", w.address); - NotesBox.Text = w.notes; + AddressBox.Text = string.Format("{0:X4}", w.Address); + NotesBox.Text = w.Notes; - SetTypeRadio(w.type); - SetSignedRadio(w.signed); + SetTypeRadio(w.Type); + SetSignedRadio(w.Signed); - if (w.bigendian == true) + if (w.BigEndian == true) BigEndianRadio.Checked = true; else LittleEndianRadio.Checked = true; @@ -93,8 +93,8 @@ namespace BizHawk.MultiClient if (!customSetup) { Watch w = new Watch(); - SetTypeRadio(w.type); - SetSignedRadio(w.signed); + SetTypeRadio(w.Type); + SetSignedRadio(w.Signed); AddressBox.Text = "0000"; } @@ -113,7 +113,9 @@ namespace BizHawk.MultiClient //Put user settings in the watch file userSelected = true; if (InputValidate.IsValidHexNumber(AddressBox.Text)) - watch.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber); + { + watch.Address = int.Parse(AddressBox.Text, NumberStyles.HexNumber); + } else { MessageBox.Show("Not a valid address (enter a valid Hex number)", "Invalid Address", MessageBoxButtons.OK, MessageBoxIcon.Error); @@ -124,25 +126,41 @@ namespace BizHawk.MultiClient } if (SignedRadio.Checked) - watch.signed = asigned.SIGNED; + { + watch.Signed = Watch.DISPTYPE.SIGNED; + } else if (UnsignedRadio.Checked) - watch.signed = asigned.UNSIGNED; + { + watch.Signed = Watch.DISPTYPE.UNSIGNED; + } else if (HexRadio.Checked) - watch.signed = asigned.HEX; + { + watch.Signed = Watch.DISPTYPE.HEX; + } if (Byte1Radio.Checked) - watch.type = atype.BYTE; + { + watch.Type = Watch.TYPE.BYTE; + } else if (Byte2Radio.Checked) - watch.type = atype.WORD; + { + watch.Type = Watch.TYPE.WORD; + } else if (Byte4Radio.Checked) - watch.type = atype.DWORD; + { + watch.Type = Watch.TYPE.DWORD; + } if (BigEndianRadio.Checked) - watch.bigendian = true; + { + watch.BigEndian = true; + } else if (LittleEndianRadio.Checked) - watch.bigendian = false; + { + watch.BigEndian = false; + } - watch.notes = NotesBox.Text; + watch.Notes = NotesBox.Text; this.Close(); } diff --git a/BizHawk.MultiClient/tools/Watch.cs b/BizHawk.MultiClient/tools/Watch.cs index c228f8a93f..d2e59ae319 100644 --- a/BizHawk.MultiClient/tools/Watch.cs +++ b/BizHawk.MultiClient/tools/Watch.cs @@ -5,254 +5,338 @@ using System.Text; namespace BizHawk.MultiClient { - public enum atype { BYTE, WORD, DWORD, SEPARATOR }; //TODO: more custom types too like 12.4 and 24.12 fixed point - public enum asigned { SIGNED, UNSIGNED, HEX }; - public enum prevDef { LASTSEARCH, ORIGINAL, LASTFRAME, LASTCHANGE }; - + /// /// An object that represent a ram address and related properties /// public class Watch { + public enum TYPE { BYTE, WORD, DWORD, SEPARATOR }; + public enum DISPTYPE { SIGNED, UNSIGNED, HEX }; + public enum PREVDEF { LASTSEARCH, ORIGINAL, LASTFRAME, LASTCHANGE }; + + #region Constructors + public Watch() { - address = 0; - value = 0; - type = atype.BYTE; - signed = asigned.UNSIGNED; - bigendian = true; - notes = ""; - changecount = 0; - prev = 0; - original = 0; - lastchange = 0; - lastsearch = 0; - deleted = false; + Address = 0; + Value = 0; + Type = TYPE.BYTE; + Signed = DISPTYPE.UNSIGNED; + BigEndian = true; + Notes = ""; + Changecount = 0; + Prev = 0; + Original = 0; + LastChange = 0; + LastSearch = 0; + Deleted = false; + Domain = Global.Emulator.MainMemory; } 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; - original = w.original; - lastchange = w.lastchange; - lastsearch = w.lastsearch; - deleted = w.deleted; + Address = w.Address; + Value = w.Value; + Type = w.Type; + Signed = w.Signed; + BigEndian = w.BigEndian; + Notes = w.Notes; + Changecount = w.Changecount; + Prev = w.Prev; + Original = w.Original; + LastChange = w.LastChange; + LastSearch = w.LastSearch; + Deleted = w.Deleted; } - public Watch(int Address, int Value, atype Type, asigned Signed, bool BigEndian, string Notes) + public Watch(MemoryDomain _domain, int _address, int _value, TYPE _type, DISPTYPE _disptype, bool _bigendian, string _notes) { - address = Address; - value = Value; - type = Type; - signed = Signed; - bigendian = BigEndian; - notes = Notes; - changecount = 0; - prev = Value; - original = Value; - lastchange = Value; - lastsearch = Value; + Domain = _domain; + Address = _address; + Value = _value; + Type = _type; + Signed = _disptype; + BigEndian = _bigendian; + Notes = _notes; + Changecount = 0; + Prev = _value; + Original = _value; + LastChange = _value; + LastSearch = _value; } - public int address { get; set; } - public int value { get; set; } //Current value - public int prev { get; set; } - public int original { get; set; } - public int lastchange { get; set; } - public int lastsearch { get; set; } - public int diffPrev { get { return value - prev; } } - public int diffOriginal { get { return value - original; } } - public int diffLastChange { get { return value - lastchange; } } - public int diffLastSearch { get { return value - lastsearch; } } - public atype type { get; set; } //Address type (byte, word, dword, etc - public asigned signed { get; set; } //Signed/Unsigned? - public bool bigendian { get; set; } - public string notes { get; set; } //User notes - public int changecount { get; set; } - public bool deleted { get; set; } //For weeding out addresses in things like ram search, without actually removing them from the list (in order to preview, undo, etc) + #endregion + + #region Properties + + public MemoryDomain Domain; + public int Address; + public int Value; + public int Prev; + public int Original; + public int LastChange; + public int LastSearch; + public TYPE Type; + public DISPTYPE Signed; + public bool BigEndian; + public string Notes; + public int Changecount; + public bool Deleted; + + public int DiffPrev + { + get + { + return Value - Prev; + } + } + + public int DiffOriginal + { + get + { + return Value - Original; + } + } + + public int DiffLastChange + { + get + { + return Value - LastChange; + } + } + + public int DiffLastSearch + { + get + { + return Value - LastSearch; + } + + } + + public string ValueString + { + get + { + return ValToString(Value); + } + } + + public string PrevString + { + get + { + return ValToString(Prev); + } + } + + public string OriginalString + { + get + { + return ValToString(Original); + } + } + + public string LastChangeString + { + get + { + return ValToString(LastChange); + } + } + + public string LastSearchString + { + get + { + return ValToString(LastSearch); + } + } + + public string DiffPrevString + { + get + { + return DiffToString(Prev); + } + } + + public string DiffOriginalString + { + get + { + return DiffToString(Original); + } + } + + public string DiffLastChangeString + { + get + { + return DiffToString(LastChange); + } + } + + public string DiffLastSearchString + { + get + { + return DiffToString(LastSearch); + } + } + + public char TypeChar + { + get + { + switch (Type) + { + case TYPE.BYTE: + return 'b'; + case TYPE.WORD: + return 'w'; + case TYPE.DWORD: + return 'd'; + case TYPE.SEPARATOR: + return 'S'; + default: + return 'b'; //Just in case + } + } + } + + public char SignedChar + { + get + { + switch (Signed) + { + case DISPTYPE.SIGNED: + return 's'; + case DISPTYPE.UNSIGNED: + return 'u'; + case DISPTYPE.HEX: + return 'h'; + default: + return 's'; //Just in case + } + } + } + + #endregion + + #region Public Methods public bool SetTypeByChar(char c) //b = byte, w = word, d = dword { switch (c) { case 'b': - type = atype.BYTE; + Type = TYPE.BYTE; return true; case 'w': - type = atype.WORD; + Type = TYPE.WORD; return true; case 'd': - type = atype.DWORD; + Type = TYPE.DWORD; return true; case 'S': - type = atype.SEPARATOR; + Type = TYPE.SEPARATOR; return true; default: return false; } } - public char GetTypeByChar() - { - switch (type) - { - case atype.BYTE: - return 'b'; - case atype.WORD: - return 'w'; - case atype.DWORD: - return 'd'; - case atype.SEPARATOR: - return 'S'; - default: - return 'b'; //Just in case - } - } - public bool SetSignedByChar(char c) //s = signed, u = unsigned, h = hex { switch (c) { case 's': - signed = asigned.SIGNED; + Signed = DISPTYPE.SIGNED; return true; case 'u': - signed = asigned.UNSIGNED; + Signed = DISPTYPE.UNSIGNED; return true; case 'h': - signed = asigned.HEX; + Signed = DISPTYPE.HEX; return true; default: return false; } } - public char GetSignedByChar() - { - switch (signed) - { - case asigned.SIGNED: - return 's'; - case asigned.UNSIGNED: - return 'u'; - case asigned.HEX: - return 'h'; - default: - return 's'; //Just in case - } - } - public void PeekAddress(MemoryDomain domain) { - if (type == atype.SEPARATOR) + if (Type == TYPE.SEPARATOR) return; - prev = value; + Prev = Value; - switch (type) + switch (Type) { - case atype.BYTE: - value = domain.PeekByte(address); + case TYPE.BYTE: + Value = domain.PeekByte(Address); break; - case atype.WORD: - if (bigendian) + case TYPE.WORD: + if (BigEndian) { - value = 0; - value |= domain.PeekByte(address) << 8; - value |= domain.PeekByte(address + 1); + Value = 0; + Value |= domain.PeekByte(Address) << 8; + Value |= domain.PeekByte(Address + 1); } else { - value = 0; - value |= domain.PeekByte(address); - value |= domain.PeekByte(address + 1) << 8; + Value = 0; + Value |= domain.PeekByte(Address); + Value |= domain.PeekByte(Address + 1) << 8; } break; - case atype.DWORD: - if (bigendian) + case TYPE.DWORD: + if (BigEndian) { - value = 0; - value |= domain.PeekByte(address) << 24; - value |= domain.PeekByte(address + 1) << 16; - value |= domain.PeekByte(address + 2) << 8; - value |= domain.PeekByte(address + 3) << 0; + Value = 0; + Value |= domain.PeekByte(Address) << 24; + Value |= domain.PeekByte(Address + 1) << 16; + Value |= domain.PeekByte(Address + 2) << 8; + Value |= domain.PeekByte(Address + 3) << 0; } else { - value = 0; - value |= domain.PeekByte(address) << 0; - value |= domain.PeekByte(address + 1) << 8; - value |= domain.PeekByte(address + 2) << 16; - value |= domain.PeekByte(address + 3) << 24; + Value = 0; + Value |= domain.PeekByte(Address) << 0; + Value |= domain.PeekByte(Address + 1) << 8; + Value |= domain.PeekByte(Address + 2) << 16; + Value |= domain.PeekByte(Address + 3) << 24; } break; } - if (value != prev) + if (Value != Prev) { - lastchange = prev; - changecount++; - } - } - - private void PokeByte(MemoryDomain domain) - { - domain.PokeByte(address, (byte)value); - } - - private void PokeWord(MemoryDomain domain) - { - if (bigendian) - { - domain.PokeByte(address + 0, (byte)(value >> 8)); - domain.PokeByte(address + 1, (byte)(value)); - } - else - { - domain.PokeByte(address + 0, (byte)(value)); - domain.PokeByte(address + 1, (byte)(value >> 8)); - } - } - - private void PokeDWord(MemoryDomain domain) - { - if (bigendian) - { - domain.PokeByte(address + 0, (byte)(value << 24)); - domain.PokeByte(address + 1, (byte)(value << 16)); - domain.PokeByte(address + 2, (byte)(value << 8)); - domain.PokeByte(address + 3, (byte)(value)); - } - else - { - domain.PokeByte(address + 0, (byte)(value)); - domain.PokeByte(address + 1, (byte)(value << 8)); - domain.PokeByte(address + 2, (byte)(value << 16)); - domain.PokeByte(address + 3, (byte)(value << 24)); + LastChange = Prev; + Changecount++; } } public void PokeAddress(MemoryDomain domain) { - if (type == atype.SEPARATOR) + if (Type == TYPE.SEPARATOR) return; - switch (type) + switch (Type) { - case atype.BYTE: + case TYPE.BYTE: PokeByte(domain); break; - case atype.WORD: + case TYPE.WORD: PokeWord(domain); break; - case atype.DWORD: + case TYPE.DWORD: PokeDWord(domain); break; } @@ -260,11 +344,11 @@ namespace BizHawk.MultiClient public uint UnsignedVal(int val) { - switch (type) + switch (Type) { - case atype.BYTE: + case TYPE.BYTE: return (uint)(byte)val; - case atype.WORD: + case TYPE.WORD: return (uint)(ushort)val; } return (uint)val; @@ -272,11 +356,11 @@ namespace BizHawk.MultiClient public int SignedVal(int val) { - switch (type) + switch (Type) { - case atype.BYTE: + case TYPE.BYTE: return (int)(sbyte)val; - case atype.WORD: + case TYPE.WORD: return (int)(short)val; } return val; @@ -284,37 +368,41 @@ namespace BizHawk.MultiClient public override string ToString() { - if (type == atype.SEPARATOR) + if (Type == TYPE.SEPARATOR) + { return "----"; + } - StringBuilder str = new StringBuilder(notes); + StringBuilder str = new StringBuilder(Notes); str.Append(": "); - str.Append(ValToString(value)); + str.Append(ValToString(Value)); return str.ToString(); } public string ValToString(int val) { - if (type == atype.SEPARATOR) + if (Type == TYPE.SEPARATOR) + { return ""; + } else { - switch (signed) + switch (Signed) { default: - case asigned.UNSIGNED: + case DISPTYPE.UNSIGNED: return UnsignedVal(val).ToString(); - case asigned.SIGNED: + case DISPTYPE.SIGNED: return SignedVal(val).ToString(); - case asigned.HEX: - switch (type) + case DISPTYPE.HEX: + switch (Type) { default: - case atype.BYTE: + case TYPE.BYTE: return String.Format("{0:X2}", val); - case atype.WORD: + case TYPE.WORD: return String.Format("{0:X4}", val); - case atype.DWORD: + case TYPE.DWORD: return String.Format("{0:X8}", val); } } @@ -329,88 +417,88 @@ namespace BizHawk.MultiClient return converted; } - public string ValueToString() + #endregion + + #region Helpers + + private void PokeByte(MemoryDomain domain) { - return ValToString(value); + domain.PokeByte(Address, (byte)Value); } - public string PrevToString() + private void PokeWord(MemoryDomain domain) { - return ValToString(prev); + if (BigEndian) + { + domain.PokeByte(Address + 0, (byte)(Value >> 8)); + domain.PokeByte(Address + 1, (byte)(Value)); + } + else + { + domain.PokeByte(Address + 0, (byte)(Value)); + domain.PokeByte(Address + 1, (byte)(Value >> 8)); + } } - public string OriginalToString() + private void PokeDWord(MemoryDomain domain) { - return ValToString(original); + if (BigEndian) + { + domain.PokeByte(Address + 0, (byte)(Value << 24)); + domain.PokeByte(Address + 1, (byte)(Value << 16)); + domain.PokeByte(Address + 2, (byte)(Value << 8)); + domain.PokeByte(Address + 3, (byte)(Value)); + } + else + { + domain.PokeByte(Address + 0, (byte)(Value)); + domain.PokeByte(Address + 1, (byte)(Value << 8)); + domain.PokeByte(Address + 2, (byte)(Value << 16)); + domain.PokeByte(Address + 3, (byte)(Value << 24)); + } } - public string LastChangeToString() - { - return ValToString(lastchange); - } + #endregion - public string LastSearchToString() - { - return ValToString(lastsearch); - } + #region Compare Methods - public string DiffPrevToString() - { - return DiffToString(prev); - } - - public string DiffOriginalToString() - { - return DiffToString(original); - } - - public string DiffLastChangeToString() - { - return DiffToString(lastchange); - } - - public string DiffLastSearchToString() - { - return DiffToString(lastsearch); - } - - private int ComparePrevious(Watch Other, prevDef previous) + private int ComparePrevious(Watch Other, PREVDEF previous) { switch (previous) { - case prevDef.LASTSEARCH: + case PREVDEF.LASTSEARCH: return CompareLastSearch(Other); - case prevDef.ORIGINAL: + case PREVDEF.ORIGINAL: return CompareOriginal(Other); default: - case prevDef.LASTFRAME: + case PREVDEF.LASTFRAME: return ComparePrev(Other); - case prevDef.LASTCHANGE: + case PREVDEF.LASTCHANGE: return CompareLastChange(Other); } } - private int CompareDiff(Watch Other, prevDef previous) + private int CompareDiff(Watch Other, PREVDEF previous) { switch (previous) { - case prevDef.LASTSEARCH: + case PREVDEF.LASTSEARCH: return CompareDiffLastSearch(Other); - case prevDef.ORIGINAL: + case PREVDEF.ORIGINAL: return CompareDiffOriginal(Other); default: - case prevDef.LASTFRAME: + case PREVDEF.LASTFRAME: return CompareDiffPrev(Other); - case prevDef.LASTCHANGE: + case PREVDEF.LASTCHANGE: return CompareDiffLastChange(Other); } } private int CompareAddress(Watch Other) { - if (this.address < Other.address) + if (this.Address < Other.Address) return -1; - else if (this.address > Other.address) + else if (this.Address > Other.Address) return 1; else return 0; @@ -418,18 +506,18 @@ namespace BizHawk.MultiClient private int CompareValue(Watch Other) { - if (signed == asigned.SIGNED) + if (Signed == DISPTYPE.SIGNED) { - if (SignedVal(this.value) < SignedVal(Other.value)) + if (SignedVal(this.Value) < SignedVal(Other.Value)) return -1; - else if (SignedVal(this.value) > SignedVal(Other.value)) + else if (SignedVal(this.Value) > SignedVal(Other.Value)) return 1; else return 0; } - if (UnsignedVal(this.value) < UnsignedVal(Other.value)) + if (UnsignedVal(this.Value) < UnsignedVal(Other.Value)) return -1; - else if (UnsignedVal(this.value) > UnsignedVal(Other.value)) + else if (UnsignedVal(this.Value) > UnsignedVal(Other.Value)) return 1; else return 0; @@ -437,18 +525,18 @@ namespace BizHawk.MultiClient private int ComparePrev(Watch Other) { - if (signed == asigned.SIGNED) + if (Signed == DISPTYPE.SIGNED) { - if (SignedVal(this.prev) < SignedVal(Other.prev)) + if (SignedVal(this.Prev) < SignedVal(Other.Prev)) return -1; - else if (SignedVal(this.prev) > SignedVal(Other.prev)) + else if (SignedVal(this.Prev) > SignedVal(Other.Prev)) return 1; else return 0; } - if (UnsignedVal(this.prev) < UnsignedVal(Other.prev)) + if (UnsignedVal(this.Prev) < UnsignedVal(Other.Prev)) return -1; - else if (UnsignedVal(this.prev) > UnsignedVal(Other.prev)) + else if (UnsignedVal(this.Prev) > UnsignedVal(Other.Prev)) return 1; else return 0; @@ -456,18 +544,18 @@ namespace BizHawk.MultiClient private int CompareOriginal(Watch Other) { - if (signed == asigned.SIGNED) + if (Signed == DISPTYPE.SIGNED) { - if (SignedVal(this.original) < SignedVal(Other.original)) + if (SignedVal(this.Original) < SignedVal(Other.Original)) return -1; - else if (SignedVal(this.original) > SignedVal(Other.original)) + else if (SignedVal(this.Original) > SignedVal(Other.Original)) return 1; else return 0; } - if (UnsignedVal(this.original) < UnsignedVal(Other.original)) + if (UnsignedVal(this.Original) < UnsignedVal(Other.Original)) return -1; - else if (UnsignedVal(this.original) > UnsignedVal(Other.original)) + else if (UnsignedVal(this.Original) > UnsignedVal(Other.Original)) return 1; else return 0; @@ -475,18 +563,18 @@ namespace BizHawk.MultiClient private int CompareLastChange(Watch Other) { - if (signed == asigned.SIGNED) + if (Signed == DISPTYPE.SIGNED) { - if (SignedVal(this.lastchange) < SignedVal(Other.lastchange)) + if (SignedVal(this.LastChange) < SignedVal(Other.LastChange)) return -1; - else if (SignedVal(this.lastchange) > SignedVal(Other.lastchange)) + else if (SignedVal(this.LastChange) > SignedVal(Other.LastChange)) return 1; else return 0; } - if (UnsignedVal(this.lastchange) < UnsignedVal(Other.lastchange)) + if (UnsignedVal(this.LastChange) < UnsignedVal(Other.LastChange)) return -1; - else if (UnsignedVal(this.lastchange) > UnsignedVal(Other.lastchange)) + else if (UnsignedVal(this.LastChange) > UnsignedVal(Other.LastChange)) return 1; else return 0; @@ -494,18 +582,18 @@ namespace BizHawk.MultiClient private int CompareLastSearch(Watch Other) { - if (signed == asigned.SIGNED) + if (Signed == DISPTYPE.SIGNED) { - if (SignedVal(this.lastsearch) < SignedVal(Other.lastsearch)) + if (SignedVal(this.LastSearch) < SignedVal(Other.LastSearch)) return -1; - else if (SignedVal(this.lastsearch) > SignedVal(Other.lastsearch)) + else if (SignedVal(this.LastSearch) > SignedVal(Other.LastSearch)) return 1; else return 0; } - if (UnsignedVal(this.lastsearch) < UnsignedVal(Other.lastsearch)) + if (UnsignedVal(this.LastSearch) < UnsignedVal(Other.LastSearch)) return -1; - else if (UnsignedVal(this.lastsearch) > UnsignedVal(Other.lastsearch)) + else if (UnsignedVal(this.LastSearch) > UnsignedVal(Other.LastSearch)) return 1; else return 0; @@ -513,9 +601,9 @@ namespace BizHawk.MultiClient private int CompareDiffPrev(Watch Other) { - if (this.diffPrev < Other.diffPrev) + if (this.DiffPrev < Other.DiffPrev) return -1; - else if (this.diffPrev > Other.diffPrev) + else if (this.DiffPrev > Other.DiffPrev) return 1; else return 0; @@ -523,9 +611,9 @@ namespace BizHawk.MultiClient private int CompareDiffOriginal(Watch Other) { - if (this.diffOriginal < Other.diffOriginal) + if (this.DiffOriginal < Other.DiffOriginal) return -1; - else if (this.diffOriginal > Other.diffOriginal) + else if (this.DiffOriginal > Other.DiffOriginal) return 1; else return 0; @@ -533,9 +621,9 @@ namespace BizHawk.MultiClient private int CompareDiffLastChange(Watch Other) { - if (this.diffLastChange < Other.diffLastChange) + if (this.DiffLastChange < Other.DiffLastChange) return -1; - else if (this.diffLastChange > Other.diffLastChange) + else if (this.DiffLastChange > Other.DiffLastChange) return 1; else return 0; @@ -543,9 +631,9 @@ namespace BizHawk.MultiClient private int CompareDiffLastSearch(Watch Other) { - if (this.diffLastSearch < Other.diffLastSearch) + if (this.DiffLastSearch < Other.DiffLastSearch) return -1; - else if (this.diffLastSearch > Other.diffLastSearch) + else if (this.DiffLastSearch > Other.DiffLastSearch) return 1; else return 0; @@ -553,9 +641,9 @@ namespace BizHawk.MultiClient private int CompareChanges(Watch Other) { - if (this.changecount < Other.changecount) + if (this.Changecount < Other.Changecount) return -1; - else if (this.changecount > Other.changecount) + else if (this.Changecount > Other.Changecount) return 1; else return 0; @@ -563,17 +651,17 @@ namespace BizHawk.MultiClient private int CompareNotes(Watch Other) { - if (this.notes == null & Other.notes == null) + if (this.Notes == null & Other.Notes == null) return 0; - else if (this.notes == null) + else if (this.Notes == null) return -1; - else if (Other.notes == null) + else if (Other.Notes == null) return 1; else - return this.notes.CompareTo(Other.notes); + return this.Notes.CompareTo(Other.Notes); } - public int CompareTo(Watch Other, string parameter, prevDef previous) + public int CompareTo(Watch Other, string parameter, PREVDEF previous) { int compare = 0; if (parameter == "Address") @@ -716,5 +804,7 @@ namespace BizHawk.MultiClient return compare; } + + #endregion } } diff --git a/BizHawk.MultiClient/tools/WatchCommon.cs b/BizHawk.MultiClient/tools/WatchCommon.cs index 2e9143b499..301821e000 100644 --- a/BizHawk.MultiClient/tools/WatchCommon.cs +++ b/BizHawk.MultiClient/tools/WatchCommon.cs @@ -25,16 +25,20 @@ namespace BizHawk.MultiClient for (int x = 0; x < watchList.Count; x++) { - str.Append(string.Format("{0:X4}", watchList[x].address) + "\t"); - str.Append(watchList[x].GetTypeByChar().ToString() + "\t"); - str.Append(watchList[x].GetSignedByChar().ToString() + "\t"); + str.Append(string.Format("{0:X4}", watchList[x].Address) + "\t"); + str.Append(watchList[x].TypeChar.ToString() + "\t"); + str.Append(watchList[x].SignedChar.ToString() + "\t"); - if (watchList[x].bigendian == true) + if (watchList[x].BigEndian == true) + { str.Append("1\t"); + } else + { str.Append("0\t"); + } - str.Append(watchList[x].notes + "\n"); + str.Append(watchList[x].Notes + "\n"); } sw.WriteLine(str.ToString()); @@ -87,7 +91,7 @@ namespace BizHawk.MultiClient temp = s.Substring(0, s.IndexOf('\t')); try { - w.address = int.Parse(temp, NumberStyles.HexNumber); + w.Address = int.Parse(temp, NumberStyles.HexNumber); } catch { @@ -114,11 +118,11 @@ namespace BizHawk.MultiClient continue; } if (y == 0) - w.bigendian = false; + w.BigEndian = false; else - w.bigendian = true; + w.BigEndian = true; - w.notes = s.Substring(2, s.Length - 2); //User notes + w.Notes = s.Substring(2, s.Length - 2); //User notes watchList.Add(w); }