diff --git a/BizHawk.MultiClient/tools/HexEditor/HexEditor.cs b/BizHawk.MultiClient/tools/HexEditor/HexEditor.cs index ac5e698a7e..efe4f1eb64 100644 --- a/BizHawk.MultiClient/tools/HexEditor/HexEditor.cs +++ b/BizHawk.MultiClient/tools/HexEditor/HexEditor.cs @@ -671,23 +671,11 @@ namespace BizHawk.MultiClient { default: case 1: - return new ByteWatch(Domain, address) - { - BigEndian = BigEndian, - Type = Watch.DisplayType.Hex, - }; + return new ByteWatch(Domain, address, Watch.DisplayType.Hex, BigEndian, String.Empty); case 2: - return new WordWatch(Domain, address) - { - BigEndian = BigEndian, - Type = Watch.DisplayType.Hex, - }; + return new WordWatch(Domain, address, Watch.DisplayType.Hex, BigEndian, String.Empty); case 4: - return new DWordWatch(Domain, address) - { - BigEndian = BigEndian, - Type = Watch.DisplayType.Hex, - }; + return new DWordWatch(Domain, address, Watch.DisplayType.Hex, BigEndian, String.Empty); } } @@ -731,10 +719,13 @@ namespace BizHawk.MultiClient var Watches = new List(); foreach (var address in addresses) { - Watch w = Watch.GenerateWatch(Domain, address, (Watch.WatchSize)DataSize); - w.Type = Watch.DisplayType.Hex; - - Watches.Add(w); + Watches.Add(Watch.GenerateWatch( + Domain, + address, + (Watch.WatchSize)DataSize, + Watch.DisplayType.Hex, + String.Empty, + BigEndian)); } poke.SetWatch(Watches); diff --git a/BizHawk.MultiClient/tools/Watch/Watch.cs b/BizHawk.MultiClient/tools/Watch/Watch.cs index 2ba3abe113..2bb270625f 100644 --- a/BizHawk.MultiClient/tools/Watch/Watch.cs +++ b/BizHawk.MultiClient/tools/Watch/Watch.cs @@ -199,20 +199,19 @@ namespace BizHawk.MultiClient public string Notes { get { return _notes; } set { _notes = value; } } - //TODO: delete me - public static Watch GenerateWatch(MemoryDomain domain, int address, WatchSize size) + public static Watch GenerateWatch(MemoryDomain domain, int address, WatchSize size, DisplayType type, string notes, bool bigEndian) { switch (size) { default: case WatchSize.Separator: - return new SeparatorWatch(); + return SeparatorWatch.Instance; case WatchSize.Byte: - return new ByteWatch(domain, address); + return new ByteWatch(domain, address, type, bigEndian, notes); case WatchSize.Word: - return new WordWatch(domain, address); + return new WordWatch(domain, address, type, bigEndian, notes); case WatchSize.DWord: - return new DWordWatch(domain, address); + return new DWordWatch(domain, address, type, bigEndian, notes); } } @@ -222,7 +221,7 @@ namespace BizHawk.MultiClient { default: case WatchSize.Separator: - return new SeparatorWatch(); + return SeparatorWatch.Instance; case WatchSize.Byte: return new ByteWatch(domain, address, type, bigendian, (byte)prev, changecount); case WatchSize.Word: @@ -337,21 +336,27 @@ namespace BizHawk.MultiClient private byte _previous; private byte _value; - public ByteWatch(MemoryDomain domain, int address) + public ByteWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, string notes) { _address = address; _domain = domain; _value = _previous = GetByte(); - Notes = String.Empty; + if (Watch.AvailableTypes(WatchSize.Byte).Contains(type)) + { + _type = type; + } + _bigEndian = bigEndian; + if (notes != null) + { + Notes = notes; + } } - public ByteWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, byte prev, int changeCount) - : this(domain, address) + public ByteWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, byte prev, int changeCount, string notes = null) + : this(domain, address, type, bigEndian, notes) { _previous = prev; _changecount = changeCount; - _type = type; - _bigEndian = bigEndian; } public override int? Address @@ -534,21 +539,29 @@ namespace BizHawk.MultiClient private ushort _previous; private ushort _value; - public WordWatch(MemoryDomain domain, int address) + public WordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, string notes) { _domain = domain; _address = address; _value = _previous = GetWord(); - Notes = String.Empty; + + if (Watch.AvailableTypes(WatchSize.Word).Contains(type)) + { + _type = type; + } + _bigEndian = bigEndian; + + if (notes != null) + { + Notes = notes; + } } - public WordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, ushort prev, int changeCount) - : this(domain, address) + public WordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, ushort prev, int changeCount, string notes = null) + : this(domain, address, type, bigEndian, notes) { _previous = prev; _changecount = changeCount; - _type = type; - _bigEndian = bigEndian; } public override int? Value @@ -719,16 +732,26 @@ namespace BizHawk.MultiClient private uint _value; private uint _previous; - public DWordWatch(MemoryDomain domain, int address) + public DWordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, string notes) { _domain = domain; _address = address; _value = _previous = GetDWord(); - Notes = String.Empty; + + if (Watch.AvailableTypes(WatchSize.DWord).Contains(type)) + { + _type = type; + } + _bigEndian = bigEndian; + + if (notes != null) + { + Notes = notes; + } } - public DWordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, uint prev, int changeCount) - : this(domain, address) + public DWordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, uint prev, int changeCount, string notes = null) + : this(domain, address, type, bigEndian, notes) { _previous = prev; _changecount = changeCount; diff --git a/BizHawk.MultiClient/tools/Watch/WatchEditor.cs b/BizHawk.MultiClient/tools/Watch/WatchEditor.cs index b0024d46a0..633c9acfce 100644 --- a/BizHawk.MultiClient/tools/Watch/WatchEditor.cs +++ b/BizHawk.MultiClient/tools/Watch/WatchEditor.cs @@ -224,31 +224,13 @@ namespace BizHawk.MultiClient switch (SizeDropDown.SelectedIndex) { case 0: - _watchList.Add(new ByteWatch(domain, address) - { - Notes = notes, - Type = type, - BigEndian = bigendian, - } - ); + _watchList.Add(new ByteWatch(domain, address, type, bigendian, notes)); break; case 1: - _watchList.Add(new WordWatch(domain, address) - { - Notes = notes, - Type = type, - BigEndian = bigendian, - } - ); + _watchList.Add(new WordWatch(domain, address, type, bigendian, notes)); break; case 2: - _watchList.Add(new DWordWatch(domain, address) - { - Notes = notes, - Type = type, - BigEndian = bigendian, - } - ); + _watchList.Add(new DWordWatch(domain, address, type, bigendian, notes)); break; } break; @@ -261,10 +243,13 @@ namespace BizHawk.MultiClient _watchList.Clear(); foreach (var watch in tempWatchList) { - var newWatch = Watch.GenerateWatch(watch.Domain, watch.Address.Value, watch.Size); - newWatch.Type = watch.Type; - newWatch.Notes = watch.Notes; - _watchList.Add(watch); + _watchList.Add(Watch.GenerateWatch( + watch.Domain, + watch.Address.Value, + watch.Size, + watch.Type, + watch.Notes, + watch.BigEndian)); } DoEdit(); break; @@ -301,9 +286,11 @@ namespace BizHawk.MultiClient _watchList[i] = Watch.GenerateWatch( _watchList[i].Domain, _watchList.Count == 1 ? AddressBox.ToInt() : _watchList[i].Address.Value, - size + size, + _watchList[i].Type, + _watchList[i].Notes, + _watchList[i].BigEndian ); - _watchList[i].Notes = tempNotes; } } if (_changedDisplayType) diff --git a/BizHawk.MultiClient/tools/Watch/WatchList.cs b/BizHawk.MultiClient/tools/Watch/WatchList.cs index 4b373683cd..2c27d657dd 100644 --- a/BizHawk.MultiClient/tools/Watch/WatchList.cs +++ b/BizHawk.MultiClient/tools/Watch/WatchList.cs @@ -498,12 +498,14 @@ namespace BizHawk.MultiClient startIndex = line.IndexOf('\t') + 1; string notes = line.Substring(startIndex, line.Length - startIndex); - Watch w = Watch.GenerateWatch(memDomain, addr, size); - w.BigEndian = bigEndian; - w.Type = type; - w.Notes = notes; - - _watchList.Add(w); + _watchList.Add( + Watch.GenerateWatch( + memDomain, + addr, + size, + type, + notes, + bigEndian)); _domain = Global.Emulator.MemoryDomains[GetDomainPos(domain)]; } }