diff --git a/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj b/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj index 040a7ad46f..f4f912a555 100644 --- a/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj +++ b/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj @@ -20,6 +20,7 @@ DEBUG;TRACE prompt 4 + x86 pdbonly @@ -29,6 +30,24 @@ prompt 4 + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + diff --git a/BizHawk.Client.ApiHawk/Resources/ApiClassDiagram.cd b/BizHawk.Client.ApiHawk/Resources/ApiClassDiagram.cd index 721fa5defc..8ed4bb7d71 100644 --- a/BizHawk.Client.ApiHawk/Resources/ApiClassDiagram.cd +++ b/BizHawk.Client.ApiHawk/Resources/ApiClassDiagram.cd @@ -1,7 +1,7 @@  - + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= Attributes\ConfigPersistAttribute.cs @@ -12,17 +12,6 @@ - - - - - - - - - - - @@ -42,7 +31,7 @@ - + @@ -75,5 +64,17 @@ Interfaces\IToolFormAutoConfig.cs + + + + + + + + + + + + \ No newline at end of file diff --git a/BizHawk.Client.Common/BizHawk.Client.Common.csproj b/BizHawk.Client.Common/BizHawk.Client.Common.csproj index c4dc2d0063..c2fc4366cc 100644 --- a/BizHawk.Client.Common/BizHawk.Client.Common.csproj +++ b/BizHawk.Client.Common/BizHawk.Client.Common.csproj @@ -234,7 +234,7 @@ - + diff --git a/BizHawk.Client.Common/config/Config.cs b/BizHawk.Client.Common/config/Config.cs index a6ea9127eb..c12805b95b 100644 --- a/BizHawk.Client.Common/config/Config.cs +++ b/BizHawk.Client.Common/config/Config.cs @@ -317,7 +317,7 @@ namespace BizHawk.Client.Common // Watch Settings public RecentFiles RecentWatches = new RecentFiles(8); - public Watch.PreviousType RamWatchDefinePrevious = Watch.PreviousType.LastFrame; + public PreviousType RamWatchDefinePrevious = PreviousType.LastFrame; public bool DisplayRamWatch = false; // Hex Editor Colors diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs index 19b228fd4b..add97ecadb 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.NES.cs @@ -44,10 +44,10 @@ namespace BizHawk.Client.Common var watch = Watch.GenerateWatch( Global.Emulator.AsMemoryDomains()["System Bus"], decoder.Address, - Watch.WatchSize.Byte, - Watch.DisplayType.Hex, - code, - false); + WatchSize.Byte, + DisplayType.Hex, + false, + code); Global.CheatList.Add(new Cheat( watch, diff --git a/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs b/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs index 30e94dd5a9..97987623d3 100644 --- a/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs +++ b/BizHawk.Client.Common/movie/conversions/MovieConversionExtensions.cs @@ -1,9 +1,7 @@ using System; using System.IO; using System.Linq; -using System.Collections.Generic; -using BizHawk.Common.ReflectionExtensions; using BizHawk.Emulation.Common; using BizHawk.Emulation.Cores.Nintendo.Gameboy; using BizHawk.Emulation.Common.IEmulatorExtensions; @@ -288,7 +286,7 @@ namespace BizHawk.Client.Common.MovieConversionExtensions if (Global.Emulator.HasRegions()) { var region = Global.Emulator.AsRegionable().Region; - if (region == DisplayType.PAL) + if (region == Emulation.Common.DisplayType.PAL) { movie.HeaderEntries.Add(HeaderKeys.PAL, "1"); } diff --git a/BizHawk.Client.Common/tools/Cheat.cs b/BizHawk.Client.Common/tools/Cheat.cs index 159e19f027..3af9f60748 100644 --- a/BizHawk.Client.Common/tools/Cheat.cs +++ b/BizHawk.Client.Common/tools/Cheat.cs @@ -1,4 +1,6 @@ -using BizHawk.Emulation.Common; +using System.Linq; + +using BizHawk.Emulation.Common; namespace BizHawk.Client.Common { @@ -34,9 +36,10 @@ namespace BizHawk.Client.Common cheat.Domain, cheat.Address ?? 0, cheat.Size, - cheat.Type, - cheat.Name, - cheat.BigEndian ?? false); + cheat.Type, + cheat.BigEndian ?? false, + cheat.Name + ); _compare = cheat.Compare; _val = cheat.Value ?? 0; @@ -87,7 +90,7 @@ namespace BizHawk.Client.Common get { return _watch.Domain; } } - public Watch.WatchSize Size + public WatchSize Size { get { return _watch.Size; } } @@ -97,7 +100,7 @@ namespace BizHawk.Client.Common get { return _watch.SizeAsChar; } } - public Watch.DisplayType Type + public DisplayType Type { get { return _watch.Type; } } @@ -124,13 +127,13 @@ namespace BizHawk.Client.Common switch (_watch.Size) { default: - case Watch.WatchSize.Separator: + case WatchSize.Separator: return string.Empty; - case Watch.WatchSize.Byte: + case WatchSize.Byte: return (_watch as ByteWatch).FormatValue((byte)_val); - case Watch.WatchSize.Word: + case WatchSize.Word: return (_watch as WordWatch).FormatValue((ushort)_val); - case Watch.WatchSize.DWord: + case WatchSize.DWord: return (_watch as DWordWatch).FormatValue((uint)_val); } } @@ -145,13 +148,13 @@ namespace BizHawk.Client.Common switch (_watch.Size) { default: - case Watch.WatchSize.Separator: + case WatchSize.Separator: return string.Empty; - case Watch.WatchSize.Byte: + case WatchSize.Byte: return (_watch as ByteWatch).FormatValue((byte)_compare.Value); - case Watch.WatchSize.Word: + case WatchSize.Word: return (_watch as WordWatch).FormatValue((ushort)_compare.Value); - case Watch.WatchSize.DWord: + case WatchSize.DWord: return (_watch as DWordWatch).FormatValue((uint)_compare.Value); } } @@ -200,7 +203,7 @@ namespace BizHawk.Client.Common private string GetStringForPulse(int val) { - if (_watch.Type == Watch.DisplayType.Hex) + if (_watch.Type == DisplayType.Hex) { return val.ToString("X8"); } @@ -223,13 +226,13 @@ namespace BizHawk.Client.Common { switch(_watch.Size) { - case Watch.WatchSize.Byte: + case WatchSize.Byte: _watch.Poke((_watch as ByteWatch).FormatValue((byte)_val)); break; - case Watch.WatchSize.Word: + case WatchSize.Word: _watch.Poke((_watch as WordWatch).FormatValue((ushort)_val)); break; - case Watch.WatchSize.DWord: + case WatchSize.DWord: _watch.Poke((_watch as DWordWatch).FormatValue((uint)_val)); break; } @@ -242,13 +245,13 @@ namespace BizHawk.Client.Common switch (_watch.Size) { default: - case Watch.WatchSize.Separator: + case WatchSize.Separator: return false; - case Watch.WatchSize.Byte: + case WatchSize.Byte: return (_watch.Address ?? 0) == addr; - case Watch.WatchSize.Word: + case WatchSize.Word: return (addr == (_watch.Address ?? 0)) || (addr == (_watch.Address ?? 0) + 1); - case Watch.WatchSize.DWord: + case WatchSize.DWord: return (addr == (_watch.Address ?? 0)) || (addr == (_watch.Address ?? 0) + 1) || (addr == (_watch.Address ?? 0) + 2) || (addr == (_watch.Address ?? 0) + 3); } @@ -264,17 +267,17 @@ namespace BizHawk.Client.Common switch (_watch.Size) { default: - case Watch.WatchSize.Separator: - case Watch.WatchSize.Byte: + case WatchSize.Separator: + case WatchSize.Byte: return (byte?)_val; - case Watch.WatchSize.Word: + case WatchSize.Word: if (addr == (_watch.Address ?? 0)) { return (byte)(_val >> 8); } return (byte)(_val & 0xFF); - case Watch.WatchSize.DWord: + case WatchSize.DWord: if (addr == (_watch.Address ?? 0)) { return (byte)((_val >> 24) & 0xFF); @@ -330,9 +333,9 @@ namespace BizHawk.Client.Common } } - public void SetType(Watch.DisplayType type) - { - if (Watch.AvailableTypes(_watch.Size).Contains(type)) + public void SetType(DisplayType type) + { + if (_watch.IsDiplayTypeAvailable(type)) { _watch.Type = type; Changes(); diff --git a/BizHawk.Client.Common/tools/CheatList.cs b/BizHawk.Client.Common/tools/CheatList.cs index ac029dddaf..626fc91c77 100644 --- a/BizHawk.Client.Common/tools/CheatList.cs +++ b/BizHawk.Client.Common/tools/CheatList.cs @@ -293,7 +293,7 @@ namespace BizHawk.Client.Common /// The starting address for which you will get the number of bytes /// The number of bytes of the cheat to return /// The value, or null if it can't resolve the address with a given cheat - public int? GetCheatValue(MemoryDomain domain, long addr, Watch.WatchSize size) + public int? GetCheatValue(MemoryDomain domain, long addr, WatchSize size) { var activeCheat = _cheatList.FirstOrDefault(cheat => cheat.Contains(addr)); if (activeCheat == (Cheat)null) @@ -304,21 +304,21 @@ namespace BizHawk.Client.Common switch (activeCheat.Size) { default: - case Watch.WatchSize.Byte: + case WatchSize.Byte: return activeCheat.Value; - case Watch.WatchSize.Word: - if (size == Watch.WatchSize.Byte) + case WatchSize.Word: + if (size == WatchSize.Byte) { return GetByteValue(domain, addr); } return activeCheat.Value; - case Watch.WatchSize.DWord: - if (size == Watch.WatchSize.Byte) + case WatchSize.DWord: + if (size == WatchSize.Byte) { return GetByteValue(domain, addr); } - else if (size == Watch.WatchSize.Word) + else if (size == WatchSize.Word) { if (activeCheat.Address == addr) { @@ -385,7 +385,7 @@ namespace BizHawk.Client.Common else { // Set to hex for saving - cheat.SetType(Watch.DisplayType.Hex); + cheat.SetType(DisplayType.Hex); sb .Append(cheat.AddressStr).Append('\t') @@ -447,8 +447,8 @@ namespace BizHawk.Client.Common else { int? compare; - var size = Watch.WatchSize.Byte; - var type = Watch.DisplayType.Hex; + var size = WatchSize.Byte; + var type = DisplayType.Hex; var bigendian = false; if (s.Length < 6) @@ -485,9 +485,9 @@ namespace BizHawk.Client.Common domain, address, size, - type, - name, - bigendian); + type, + bigendian, + name); Add(new Cheat(watch, value, compare, !Global.Config.DisableCheatsOnLoad && enabled)); } diff --git a/BizHawk.Client.Common/tools/RamSearchEngine.cs b/BizHawk.Client.Common/tools/RamSearchEngine.cs index 56bb121a33..5a59a92819 100644 --- a/BizHawk.Client.Common/tools/RamSearchEngine.cs +++ b/BizHawk.Client.Common/tools/RamSearchEngine.cs @@ -13,7 +13,7 @@ namespace BizHawk.Client.Common { public enum ComparisonOperator { Equal, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual, NotEqual, DifferentBy } public enum Compare { Previous, SpecificValue, SpecificAddress, Changes, Difference } - + private int? _differentBy; //zero 07-sep-2014 - this isnt ideal. but dont bother changing it (to a long, for instance) until it can support floats. maybe store it as a double here. private Compare _compareTo = Compare.Previous; @@ -40,11 +40,11 @@ namespace BizHawk.Client.Common public RamSearchEngine(Settings settings, IMemoryDomains memoryDomains, Compare compareTo, long? compareValue, int? differentBy) : this(settings, memoryDomains) - { - _compareTo = compareTo; - _differentBy = differentBy; - _compareValue = compareValue; - } + { + _compareTo = compareTo; + _differentBy = differentBy; + _compareValue = compareValue; + } #region API @@ -73,7 +73,7 @@ namespace BizHawk.Client.Common switch (_settings.Size) { default: - case Watch.WatchSize.Byte: + case WatchSize.Byte: if (_settings.Mode == Settings.SearchMode.Detailed) { for (int i = 0; i < domain.Size; i++) @@ -90,7 +90,7 @@ namespace BizHawk.Client.Common } break; - case Watch.WatchSize.Word: + case WatchSize.Word: if (_settings.Mode == Settings.SearchMode.Detailed) { for (int i = 0; i < domain.Size - 1; i += _settings.CheckMisAligned ? 1 : 2) @@ -107,7 +107,7 @@ namespace BizHawk.Client.Common } break; - case Watch.WatchSize.DWord: + case WatchSize.DWord: if (_settings.Mode == Settings.SearchMode.Detailed) { for (int i = 0; i < domain.Size - 3; i += _settings.CheckMisAligned ? 1 : 4) @@ -142,6 +142,8 @@ namespace BizHawk.Client.Common _settings.Size, _settings.Type, _settings.BigEndian, + string.Empty, + 0, _watchList[index].Previous, (_watchList[index] as IMiniWatchDetails).ChangeCount ); @@ -154,6 +156,8 @@ namespace BizHawk.Client.Common _settings.Size, _settings.Type, _settings.BigEndian, + string.Empty, + 0, _watchList[index].Previous, 0 ); @@ -185,7 +189,7 @@ namespace BizHawk.Client.Common break; } - if (_settings.PreviousType == Watch.PreviousType.LastSearch) + if (_settings.PreviousType == PreviousType.LastSearch) { SetPreviousToCurrent(); } @@ -292,12 +296,9 @@ namespace BizHawk.Client.Common } } - public void SetType(Watch.DisplayType type) + public void SetType(DisplayType type) { - if (Watch.AvailableTypes(_settings.Size).Contains(type)) - { - _settings.Type = type; - } + _settings.Type = type; } public void SetEndian(bool bigendian) @@ -305,11 +306,11 @@ namespace BizHawk.Client.Common _settings.BigEndian = bigendian; } - public void SetPreviousType(Watch.PreviousType type) + public void SetPreviousType(PreviousType type) { if (_settings.Mode == Settings.SearchMode.Fast) { - if (type == Watch.PreviousType.LastFrame) + if (type == PreviousType.LastFrame) { throw new InvalidOperationException(); } @@ -370,7 +371,7 @@ namespace BizHawk.Client.Common switch (_settings.Size) { default: - case Watch.WatchSize.Byte: + case WatchSize.Byte: if (_settings.Mode == Settings.SearchMode.Detailed) { foreach (var addr in addresses) @@ -387,7 +388,7 @@ namespace BizHawk.Client.Common } break; - case Watch.WatchSize.Word: + case WatchSize.Word: if (_settings.Mode == Settings.SearchMode.Detailed) { foreach (var addr in addresses) @@ -404,7 +405,7 @@ namespace BizHawk.Client.Common } break; - case Watch.WatchSize.DWord: + case WatchSize.DWord: if (_settings.Mode == Settings.SearchMode.Detailed) { foreach (var addr in addresses) @@ -498,7 +499,7 @@ namespace BizHawk.Client.Common } #endregion - + #region Undo API public bool UndoEnabled @@ -516,7 +517,7 @@ namespace BizHawk.Client.Common { get { return _keepHistory && _history.CanRedo; } } - + public void ClearHistory() { _history.Clear(); @@ -553,7 +554,7 @@ namespace BizHawk.Client.Common return watchList.Where(x => GetValue(x.Address) != x.Previous); case ComparisonOperator.GreaterThan: - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => ToFloat(GetValue(x.Address)) > ToFloat(x.Previous)); } @@ -561,7 +562,7 @@ namespace BizHawk.Client.Common return watchList.Where(x => SignExtendAsNeeded(GetValue(x.Address)) > SignExtendAsNeeded(x.Previous)); case ComparisonOperator.GreaterThanEqual: - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => ToFloat(GetValue(x.Address)) >= ToFloat(x.Previous)); } @@ -569,7 +570,7 @@ namespace BizHawk.Client.Common return watchList.Where(x => SignExtendAsNeeded(GetValue(x.Address)) >= SignExtendAsNeeded(x.Previous)); case ComparisonOperator.LessThan: - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => ToFloat(GetValue(x.Address)) < ToFloat(x.Previous)); } @@ -577,7 +578,7 @@ namespace BizHawk.Client.Common return watchList.Where(x => SignExtendAsNeeded(GetValue(x.Address)) < SignExtendAsNeeded(x.Previous)); case ComparisonOperator.LessThanEqual: - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => ToFloat(GetValue(x.Address)) <= ToFloat(x.Previous)); } @@ -587,17 +588,18 @@ namespace BizHawk.Client.Common case ComparisonOperator.DifferentBy: if (_differentBy.HasValue) { - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => (ToFloat(GetValue(x.Address)) + _differentBy.Value == ToFloat(x.Previous)) || (ToFloat(GetValue(x.Address)) - _differentBy.Value == ToFloat(x.Previous))); } - return watchList.Where(x => { + return watchList.Where(x => + { long val = SignExtendAsNeeded(GetValue(x.Address)); long prev = SignExtendAsNeeded(x.Previous); return (val + _differentBy.Value == prev) || (val - _differentBy.Value == prev); - } + } ); } else @@ -615,14 +617,14 @@ namespace BizHawk.Client.Common { default: case ComparisonOperator.Equal: - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => ToFloat(GetValue(x.Address)) == ToFloat(_compareValue.Value)); } return watchList.Where(x => GetValue(x.Address) == _compareValue.Value); case ComparisonOperator.NotEqual: - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => ToFloat(GetValue(x.Address)) != ToFloat(_compareValue.Value)); } @@ -630,28 +632,28 @@ namespace BizHawk.Client.Common return watchList.Where(x => GetValue(x.Address) != _compareValue.Value); case ComparisonOperator.GreaterThan: - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => ToFloat(GetValue(x.Address)) > ToFloat(_compareValue.Value)); } return watchList.Where(x => SignExtendAsNeeded(GetValue(x.Address)) > _compareValue.Value); case ComparisonOperator.GreaterThanEqual: - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => ToFloat(GetValue(x.Address)) >= ToFloat(_compareValue.Value)); } return watchList.Where(x => SignExtendAsNeeded(GetValue(x.Address)) >= _compareValue.Value); case ComparisonOperator.LessThan: - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => ToFloat(GetValue(x.Address)) < ToFloat(_compareValue.Value)); } return watchList.Where(x => SignExtendAsNeeded(GetValue(x.Address)) < _compareValue.Value); case ComparisonOperator.LessThanEqual: - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => ToFloat(GetValue(x.Address)) <= ToFloat(_compareValue.Value)); } @@ -660,7 +662,7 @@ namespace BizHawk.Client.Common case ComparisonOperator.DifferentBy: if (_differentBy.HasValue) { - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => (ToFloat(GetValue(x.Address)) + _differentBy.Value == _compareValue.Value) || (ToFloat(GetValue(x.Address)) - _differentBy.Value == _compareValue.Value)); @@ -783,42 +785,42 @@ namespace BizHawk.Client.Common { default: case ComparisonOperator.Equal: - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => (ToFloat(GetValue(x.Address)) - ToFloat(x.Previous)) == _compareValue.Value); } return watchList.Where(x => (SignExtendAsNeeded(GetValue(x.Address)) - SignExtendAsNeeded(x.Previous)) == _compareValue.Value); case ComparisonOperator.NotEqual: - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => (ToFloat(GetValue(x.Address)) - x.Previous) != _compareValue.Value); } return watchList.Where(x => (SignExtendAsNeeded(GetValue(x.Address)) - SignExtendAsNeeded(x.Previous)) != _compareValue.Value); case ComparisonOperator.GreaterThan: - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => (ToFloat(GetValue(x.Address)) - x.Previous) > _compareValue.Value); } return watchList.Where(x => (SignExtendAsNeeded(GetValue(x.Address)) - SignExtendAsNeeded(x.Previous)) > _compareValue.Value); case ComparisonOperator.GreaterThanEqual: - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => (ToFloat(GetValue(x.Address)) - x.Previous) >= _compareValue.Value); } return watchList.Where(x => (SignExtendAsNeeded(GetValue(x.Address)) - SignExtendAsNeeded(x.Previous)) >= _compareValue.Value); case ComparisonOperator.LessThan: - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => (ToFloat(GetValue(x.Address)) - x.Previous) < _compareValue.Value); } return watchList.Where(x => (SignExtendAsNeeded(GetValue(x.Address)) - SignExtendAsNeeded(x.Previous)) < _compareValue.Value); case ComparisonOperator.LessThanEqual: - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => (ToFloat(GetValue(x.Address)) - x.Previous) <= _compareValue.Value); } @@ -827,7 +829,7 @@ namespace BizHawk.Client.Common case ComparisonOperator.DifferentBy: if (_differentBy.HasValue) { - if (_settings.Type == Watch.DisplayType.Float) + if (_settings.Type == DisplayType.Float) { return watchList.Where(x => (ToFloat(GetValue(x.Address)) - x.Previous + _differentBy.Value == _compareValue) || (ToFloat(GetValue(x.Address)) - x.Previous - _differentBy.Value == x.Previous)); @@ -861,15 +863,15 @@ namespace BizHawk.Client.Common private long SignExtendAsNeeded(long val) { - if (_settings.Type != Watch.DisplayType.Signed) return val; + if (_settings.Type != DisplayType.Signed) return val; switch (_settings.Size) { default: - case Watch.WatchSize.Byte: + case WatchSize.Byte: return (sbyte)val; - case Watch.WatchSize.Word: + case WatchSize.Word: return (short)val; - case Watch.WatchSize.DWord: + case WatchSize.DWord: return (int)val; } } @@ -880,15 +882,15 @@ namespace BizHawk.Client.Common switch (_settings.Size) { default: - case Watch.WatchSize.Byte: + case WatchSize.Byte: var theByte = _settings.Domain.PeekByte(addr % Domain.Size); return theByte; - case Watch.WatchSize.Word: + case WatchSize.Word: var theWord = _settings.Domain.PeekWord(addr % Domain.Size, _settings.BigEndian); return theWord; - case Watch.WatchSize.DWord: + case WatchSize.DWord: var theDWord = _settings.Domain.PeekDWord(addr % Domain.Size, _settings.BigEndian); return theDWord; } @@ -920,9 +922,9 @@ namespace BizHawk.Client.Common private interface IMiniWatchDetails { int ChangeCount { get; } - + void ClearChangeCount(); - void Update(Watch.PreviousType type, MemoryDomain domain, bool bigendian); + void Update(PreviousType type, MemoryDomain domain, bool bigendian); } private sealed class MiniByteWatch : IMiniWatch @@ -1020,10 +1022,10 @@ namespace BizHawk.Client.Common get { return _changecount; } } - public void Update(Watch.PreviousType type, MemoryDomain domain, bool bigendian) + public void Update(PreviousType type, MemoryDomain domain, bool bigendian) { var value = domain.PeekByte(Address % domain.Size); - + if (value != _prevFrame) { _changecount++; @@ -1031,13 +1033,13 @@ namespace BizHawk.Client.Common switch (type) { - case Watch.PreviousType.Original: - case Watch.PreviousType.LastSearch: + case PreviousType.Original: + case PreviousType.LastSearch: break; - case Watch.PreviousType.LastFrame: + case PreviousType.LastFrame: _previous = _prevFrame; break; - case Watch.PreviousType.LastChange: + case PreviousType.LastChange: if (_prevFrame != value) _previous = _prevFrame; break; @@ -1081,7 +1083,7 @@ namespace BizHawk.Client.Common get { return _changecount; } } - public void Update(Watch.PreviousType type, MemoryDomain domain, bool bigendian) + public void Update(PreviousType type, MemoryDomain domain, bool bigendian) { var value = domain.PeekWord(Address % domain.Size, bigendian); if (value != Previous) @@ -1091,13 +1093,13 @@ namespace BizHawk.Client.Common switch (type) { - case Watch.PreviousType.Original: - case Watch.PreviousType.LastSearch: + case PreviousType.Original: + case PreviousType.LastSearch: break; - case Watch.PreviousType.LastFrame: + case PreviousType.LastFrame: _previous = _prevFrame; break; - case Watch.PreviousType.LastChange: + case PreviousType.LastChange: if (_prevFrame != value) _previous = _prevFrame; break; @@ -1141,7 +1143,7 @@ namespace BizHawk.Client.Common get { return _changecount; } } - public void Update(Watch.PreviousType type, MemoryDomain domain, bool bigendian) + public void Update(PreviousType type, MemoryDomain domain, bool bigendian) { var value = domain.PeekDWord(Address % domain.Size, bigendian); if (value != Previous) @@ -1151,13 +1153,13 @@ namespace BizHawk.Client.Common switch (type) { - case Watch.PreviousType.Original: - case Watch.PreviousType.LastSearch: + case PreviousType.Original: + case PreviousType.LastSearch: break; - case Watch.PreviousType.LastFrame: + case PreviousType.LastFrame: _previous = _prevFrame; break; - case Watch.PreviousType.LastChange: + case PreviousType.LastChange: if (_prevFrame != value) _previous = _prevFrame; break; @@ -1177,15 +1179,15 @@ namespace BizHawk.Client.Common public Settings(IMemoryDomains memoryDomains) { BigEndian = memoryDomains.MainMemory.EndianType == MemoryDomain.Endian.Big; - Size = (Watch.WatchSize)memoryDomains.MainMemory.ByteSize; - Type = Watch.DisplayType.Unsigned; + Size = (WatchSize)memoryDomains.MainMemory.ByteSize; + Type = DisplayType.Unsigned; Mode = memoryDomains.MainMemory.Size > (1024 * 1024) ? SearchMode.Fast : SearchMode.Detailed; Domain = memoryDomains.MainMemory; CheckMisAligned = false; - PreviousType = Watch.PreviousType.LastSearch; + PreviousType = PreviousType.LastSearch; } /*Require restart*/ @@ -1193,13 +1195,13 @@ namespace BizHawk.Client.Common public SearchMode Mode { get; set; } public MemoryDomain Domain { get; set; } - public Watch.WatchSize Size { get; set; } + public WatchSize Size { get; set; } public bool CheckMisAligned { get; set; } /*Can be changed mid-search*/ - public Watch.DisplayType Type { get; set; } + public DisplayType Type { get; set; } public bool BigEndian { get; set; } - public Watch.PreviousType PreviousType { get; set; } + public PreviousType PreviousType { get; set; } } #endregion diff --git a/BizHawk.Client.Common/tools/Watch/ByteWatch.cs b/BizHawk.Client.Common/tools/Watch/ByteWatch.cs index 9bfe89a6e4..69e0764d7b 100644 --- a/BizHawk.Client.Common/tools/Watch/ByteWatch.cs +++ b/BizHawk.Client.Common/tools/Watch/ByteWatch.cs @@ -10,37 +10,50 @@ namespace BizHawk.Client.Common { public sealed class ByteWatch : Watch { + #region Fields + private byte _previous; private byte _value; - public ByteWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, string notes) - { - _address = address; - _domain = domain; - _value = _previous = GetByte(); - if (AvailableTypes(WatchSize.Byte).Contains(type)) - { - _type = type; - } + #endregion - _bigEndian = bigEndian; - if (notes != null) + #region cTor(s) + + internal ByteWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, string note, byte value, byte previous, int changeCount) + : base(domain, address, WatchSize.Byte, type, bigEndian, note) + { + this._value = value; + this._previous = previous; + this._changecount = changeCount; + } + + internal ByteWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, string note) + :this(domain, address, type, bigEndian, note, 0, 0, 0) + { + _previous = GetByte(); + _value = GetByte(); + } + + #endregion + + public static IEnumerable ValidTypes + { + get { - Notes = notes; + yield return DisplayType.Unsigned; + yield return DisplayType.Signed; + yield return DisplayType.Hex; + yield return DisplayType.Binary; } } - public ByteWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, byte prev, int changeCount, string notes = null) - : this(domain, address, type, bigEndian, notes) + public override IEnumerable AvailableTypes() { - _previous = prev; - _changecount = changeCount; - } - - public override long? Address - { - get { return _address; } - } + yield return DisplayType.Unsigned; + yield return DisplayType.Signed; + yield return DisplayType.Hex; + yield return DisplayType.Binary; + } public override int? Value { @@ -76,28 +89,7 @@ namespace BizHawk.Client.Common { return Notes + ": " + ValueString; } - - public override bool IsSeparator - { - get { return false; } - } - - public override WatchSize Size - { - get { return WatchSize.Byte; } - } - - public static List ValidTypes - { - get - { - return new List - { - DisplayType.Unsigned, DisplayType.Signed, DisplayType.Hex, DisplayType.Binary - }; - } - } - + public override uint MaxValue { get { return byte.MaxValue; } @@ -210,7 +202,7 @@ namespace BizHawk.Client.Common return diff + FormatValue((byte)(_previous - _value)); } - } + } public override void Update() { diff --git a/BizHawk.Client.Common/tools/Watch/DisplayType.cs b/BizHawk.Client.Common/tools/Watch/DisplayType.cs index 16f9835364..f499e494ff 100644 --- a/BizHawk.Client.Common/tools/Watch/DisplayType.cs +++ b/BizHawk.Client.Common/tools/Watch/DisplayType.cs @@ -1,62 +1,54 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.Client.Common +namespace BizHawk.Client.Common { - public abstract partial class Watch + /// + /// This enum is used to specify how you want your to be displayed + /// + public enum DisplayType { /// - /// This enum is used to specify how you want your to be displayed + /// Separator, only used by /// - public enum DisplayType - { - /// - /// Separator, only used by - /// - Separator, - /// - /// Display the value as a signed integer - /// Used by , and - /// - Signed, - /// - /// Display the value as an unsigned integer - /// Used by , and - /// - Unsigned, - /// - /// Raw hexadecimal display - /// Used by , and - /// - Hex, - /// - /// Raw binary display - /// Used by , and - /// If you can read it easily, you're probably a computer - /// - Binary, - /// - /// Display the value as fractionnal number. 12 before coma and 4 after - /// Used only by as it is 16 bits length - /// - FixedPoint_12_4, - /// - /// Display the value as fractionnal number. 20 before coma and 12 after - /// Used only by as it is 32 bits length - /// - FixedPoint_20_12, - /// - /// Display the value as fractionnal number. 16 before coma and 16 after - /// Used only by as it is 32 bits length - /// - FixedPoint_16_16, - /// - /// The traditionnal float type as in C++ - /// Used only by as it is 32 bits length - /// - Float - } + Separator, + /// + /// Display the value as a signed integer + /// Used by , and + /// + Signed, + /// + /// Display the value as an unsigned integer + /// Used by , and + /// + Unsigned, + /// + /// Raw hexadecimal display + /// Used by , and + /// + Hex, + /// + /// Raw binary display + /// Used by , and + /// If you can read it easily, you're probably a computer + /// + Binary, + /// + /// Display the value as fractionnal number. 12 before coma and 4 after + /// Used only by as it is 16 bits length + /// + FixedPoint_12_4, + /// + /// Display the value as fractionnal number. 20 before coma and 12 after + /// Used only by as it is 32 bits length + /// + FixedPoint_20_12, + /// + /// Display the value as fractionnal number. 16 before coma and 16 after + /// Used only by as it is 32 bits length + /// + FixedPoint_16_16, + /// + /// The traditionnal float type as in C++ + /// Used only by as it is 32 bits length + /// + Float } } diff --git a/BizHawk.Client.Common/tools/Watch/DwordWatch.cs b/BizHawk.Client.Common/tools/Watch/DwordWatch.cs index e0a2c2f717..741dfd1cd5 100644 --- a/BizHawk.Client.Common/tools/Watch/DwordWatch.cs +++ b/BizHawk.Client.Common/tools/Watch/DwordWatch.cs @@ -11,36 +11,56 @@ namespace BizHawk.Client.Common { public sealed class DWordWatch : Watch { + #region Fields + private uint _value; private uint _previous; - public DWordWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, string notes) + #endregion + + #region cTor(s) + + internal DWordWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, string note, uint value, uint previous, int changeCount) + : base(domain, address, WatchSize.DWord, type, bigEndian, note) { - _domain = domain; - _address = address; - _value = _previous = GetDWord(); + this._value = value; + this._previous = previous; + this._changecount = changeCount; + } - if (AvailableTypes(WatchSize.DWord).Contains(type)) + internal DWordWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, string note) + :this(domain, address, type, bigEndian, note, 0, 0, 0) + { + _previous = GetDWord(); + _value = GetDWord(); + } + + #endregion + + public static IEnumerable ValidTypes + { + get { - _type = type; - } - - _bigEndian = bigEndian; - - if (notes != null) - { - Notes = notes; + yield return DisplayType.Unsigned; + yield return DisplayType.Signed; + yield return DisplayType.Hex; + yield return DisplayType.Binary; + yield return DisplayType.FixedPoint_20_12; + yield return DisplayType.FixedPoint_16_16; + yield return DisplayType.Float; } } - public DWordWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, uint prev, int changeCount, string notes = null) - : this(domain, address, type, bigEndian, notes) + public override IEnumerable AvailableTypes() { - _previous = prev; - _changecount = changeCount; - _type = type; - _bigEndian = bigEndian; - } + yield return DisplayType.Unsigned; + yield return DisplayType.Signed; + yield return DisplayType.Hex; + yield return DisplayType.Binary; + yield return DisplayType.FixedPoint_20_12; + yield return DisplayType.FixedPoint_16_16; + yield return DisplayType.Float; + } public override int? Value { @@ -67,22 +87,6 @@ namespace BizHawk.Client.Common _previous = GetWord(); } - public override WatchSize Size - { - get { return WatchSize.DWord; } - } - - public static List ValidTypes - { - get - { - return new List - { - DisplayType.Unsigned, DisplayType.Signed, DisplayType.Hex, DisplayType.FixedPoint_20_12, DisplayType.FixedPoint_16_16, DisplayType.Float - }; - } - } - public override uint MaxValue { get { return uint.MaxValue; } diff --git a/BizHawk.Client.Common/tools/Watch/PreviousType.cs b/BizHawk.Client.Common/tools/Watch/PreviousType.cs index 05e38ca406..53138f6440 100644 --- a/BizHawk.Client.Common/tools/Watch/PreviousType.cs +++ b/BizHawk.Client.Common/tools/Watch/PreviousType.cs @@ -5,14 +5,11 @@ using System.Text; namespace BizHawk.Client.Common { - public abstract partial class Watch + public enum PreviousType { - public enum PreviousType - { - Original = 0, - LastSearch = 1, - LastFrame = 2, - LastChange = 3 - } + Original = 0, + LastSearch = 1, + LastFrame = 2, + LastChange = 3 } } diff --git a/BizHawk.Client.Common/tools/Watch/SeparatorWatch.cs b/BizHawk.Client.Common/tools/Watch/SeparatorWatch.cs index 7b6d0d5cc8..44a23ab2d9 100644 --- a/BizHawk.Client.Common/tools/Watch/SeparatorWatch.cs +++ b/BizHawk.Client.Common/tools/Watch/SeparatorWatch.cs @@ -1,19 +1,19 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace BizHawk.Client.Common { public sealed class SeparatorWatch : Watch { + internal SeparatorWatch() + :base(null, 0, WatchSize.Separator, DisplayType.Separator, true, string.Empty) + { } + public static SeparatorWatch Instance { get { return new SeparatorWatch(); } } - public override long? Address - { - get { return null; } - } - public override int? Value { get { return null; } @@ -27,12 +27,7 @@ namespace BizHawk.Client.Common public override int? Previous { get { return null; } - } - - public override string AddressString - { - get { return string.Empty; } - } + } public override string ValueString { @@ -47,27 +42,7 @@ namespace BizHawk.Client.Common public override string ToString() { return "----"; - } - - public override bool IsSeparator - { - get { return true; } - } - - public override WatchSize Size - { - get { return WatchSize.Separator; } - } - - public static List ValidTypes - { - get { return new List { DisplayType.Separator }; } - } - - public override DisplayType Type - { - get { return DisplayType.Separator; } - } + } public override bool Poke(string value) { @@ -87,5 +62,10 @@ namespace BizHawk.Client.Common } public override void Update() { return; } + + public override IEnumerable AvailableTypes() + { + yield return DisplayType.Separator; + } } } diff --git a/BizHawk.Client.Common/tools/Watch/Watch.cs b/BizHawk.Client.Common/tools/Watch/Watch.cs index c69a4e08c0..c0dd6f762e 100644 --- a/BizHawk.Client.Common/tools/Watch/Watch.cs +++ b/BizHawk.Client.Common/tools/Watch/Watch.cs @@ -4,6 +4,7 @@ using BizHawk.Emulation.Common; using System; using System.Collections.Generic; using System.Globalization; +using System.Linq; namespace BizHawk.Client.Common { @@ -14,36 +15,48 @@ namespace BizHawk.Client.Common protected long _address; protected MemoryDomain _domain; protected DisplayType _type; + protected WatchSize _size; protected bool _bigEndian; - protected int _changecount; - protected string _notes = string.Empty; + protected string _notes; + protected int _changecount = 0; + + #endregion + + #region cTor(s) + + /// + /// Initialize a new instance of + /// + /// where you want to track + /// The address you want to track + /// A (byte, word, double word) + /// How you you want to display the value See + /// Specify the endianess. true for big endian + /// A custom note about the + protected Watch(MemoryDomain domain, long address, WatchSize size, DisplayType type, bool bigEndian, string note) + { + if (IsDiplayTypeAvailable(type)) + { + this._domain = domain; + this._address = address; + this._size = size; + this._type = type; + this._bigEndian = bigEndian; + this._notes = note; + return; + + } + else + { + throw new ArgumentException(string.Format("DisplayType {0} is invalid for this type of Watch", type.ToString()), "type"); + } + } #endregion #region Methods - - #region Static - - /// - /// Gets a list of Available types for specific - /// - /// Desired size - /// An array of that ca be used to be displayed - public static List AvailableTypes(WatchSize size) - { - switch (size) - { - default: - case WatchSize.Separator: - return SeparatorWatch.ValidTypes; - case WatchSize.Byte: - return ByteWatch.ValidTypes; - case WatchSize.Word: - return WordWatch.ValidTypes; - case WatchSize.DWord: - return DWordWatch.ValidTypes; - } - } + + #region Static /// /// Generate a from a given string @@ -105,8 +118,8 @@ namespace BizHawk.Client.Common address, size, type, - notes, - bigEndian + bigEndian, + notes ); } else @@ -123,11 +136,13 @@ namespace BizHawk.Client.Common /// The address into the /// The size /// How the watch will be displayed - /// Endianess (true for big endian) + /// Endianess (true for big endian) + /// A custom note about the + /// The current watch value /// Previous value - /// How many times value has change + /// Number of changes occurs in current /// New instance. True type is depending of size parameter - public static Watch GenerateWatch(MemoryDomain domain, long address, WatchSize size, DisplayType type, bool bigendian, long prev, int changecount) + public static Watch GenerateWatch(MemoryDomain domain, long address, WatchSize size, DisplayType type, bool bigEndian, string note, long value, long prev, int changeCount) { switch (size) { @@ -135,11 +150,11 @@ namespace BizHawk.Client.Common case WatchSize.Separator: return SeparatorWatch.Instance; case WatchSize.Byte: - return new ByteWatch(domain, address, type, bigendian, (byte)prev, changecount); + return new ByteWatch(domain, address, type, bigEndian, note, (byte)value, (byte)prev, changeCount); case WatchSize.Word: - return new WordWatch(domain, address, type, bigendian, (ushort)prev, changecount); + return new WordWatch(domain, address, type, bigEndian, note, (ushort)value, (ushort)prev, changeCount); case WatchSize.DWord: - return new DWordWatch(domain, address, type, bigendian, (uint)prev, changecount); + return new DWordWatch(domain, address, type, bigEndian, note, (uint)value, (uint)prev, changeCount); } } @@ -151,13 +166,35 @@ namespace BizHawk.Client.Common /// The address into the /// The size /// How the watch will be displayed - /// Endianess (true for big endian) + /// Endianess (true for big endian) + /// A customp note about your watch /// New instance. True type is depending of size parameter - public static Watch GenerateWatch(MemoryDomain domain, long address, WatchSize size, DisplayType type, string notes, bool bigEndian) + public static Watch GenerateWatch(MemoryDomain domain, long address, WatchSize size, DisplayType type, bool bigEndian, string note) { - return GenerateWatch(domain, address, size, type, bigEndian, 0, 0); + return GenerateWatch(domain, address, size, type, bigEndian, note, 0, 0, 0); } + /// + /// Generate a new instance + /// Can be either , , or + /// + /// The where you want to watch + /// The address into the + /// The size + /// How the watch will be displayed + /// Endianess (true for big endian) + /// New instance. True type is depending of size parameter + public static Watch GenerateWatch(MemoryDomain domain, long address, WatchSize size, DisplayType type, bool bigEndian) + { + return GenerateWatch(domain, address, size, type, bigEndian, string.Empty, 0, 0, 0); + } + + /// + /// Equality operator between two + /// + /// First watch + /// Second watch + /// True if both watch are equals; otherwise, false public static bool operator ==(Watch a, Watch b) { if (object.ReferenceEquals(a, null) || object.ReferenceEquals(b, null)) @@ -174,16 +211,34 @@ namespace BizHawk.Client.Common } } + /// + /// Equality operator between a and a + /// + /// The watch + /// The cheat + /// True if they are equals; otherwise, false public static bool operator ==(Watch a, Cheat b) { return a.Equals(b); } + /// + /// Inequality operator between two + /// + /// First watch + /// Second watch + /// True if both watch are different; otherwise, false public static bool operator !=(Watch a, Watch b) { return !(a == b); } + /// + /// Inequality operator between a and a + /// + /// The watch + /// The cheat + /// True if they are different; otherwise, false public static bool operator !=(Watch a, Cheat b) { return !(a == b); @@ -193,7 +248,20 @@ namespace BizHawk.Client.Common #region Abstracts + /// + /// Get a list a that can be used for this + /// + /// An enumartion that contains all valid + public abstract IEnumerable AvailableTypes(); + + /// + /// Reset the previous value + /// public abstract void ResetPrevious(); + + /// + /// Update the Watch (read it from + /// public abstract void Update(); #endregion Abstracts @@ -283,6 +351,9 @@ namespace BizHawk.Client.Common #endregion Protected + /// + /// Set the number of changes to 0 + /// public void ClearChangeCount() { _changecount = 0; @@ -315,11 +386,26 @@ namespace BizHawk.Client.Common } } + /// + /// Hash the current watch and gets a unique value + /// + /// int that can serves as a unique representation of current Watch public override int GetHashCode() { return this.Domain.GetHashCode() + (int)(this.Address ?? 0); } + /// + /// Determine if the specified can be + /// used for the current + /// + /// you want to check + /// + public bool IsDiplayTypeAvailable(DisplayType type) + { + return AvailableTypes().Where(d => d == type).Any(); + } + /// /// Transform the current instance into a string /// @@ -348,19 +434,16 @@ namespace BizHawk.Client.Common //zero 15-nov-2015 - bypass LIAR LOGIC, see fdc9ea2aa922876d20ba897fb76909bf75fa6c92 https://github.com/TASVideos/BizHawk/issues/326 public abstract int? ValueNoFreeze { get; } public abstract string ValueString { get; } - public abstract WatchSize Size { get; } public abstract bool Poke(string value); public abstract int? Previous { get; } public abstract string PreviousStr { get; } #endregion Abstracts - #region Virtual - /// /// Gets the address in the /// - public virtual long? Address + public long? Address { get { @@ -369,61 +452,9 @@ namespace BizHawk.Client.Common } /// - /// Gets or sets the endianess of current - /// True for big endian, flase for little endian + /// Gets the format tha should be used by string.Format() /// - public virtual bool BigEndian - { - get - { - return _bigEndian; - } - set - { - _bigEndian = value; - } - } - - /// - /// Gets or set the way current is displayed - /// - public virtual DisplayType Type - { - get - { - return _type; - } - set - { - _type = value; - } - } - - /// - /// Gets the address in the formatted as string - /// - public virtual string AddressString - { - get - { - return _address.ToString(AddressFormatStr); - } - } - - /// - /// Gets a value that defined if the current is actually a - /// - public virtual bool IsSeparator - { - get - { - return false; - } - } - - #endregion Virtual - - public string AddressFormatStr + private string AddressFormatStr { get { @@ -436,6 +467,36 @@ namespace BizHawk.Client.Common } } + /// + /// Gets the address in the formatted as string + /// + public string AddressString + { + get + { + return _address.ToString(AddressFormatStr); + } + } + + /// + /// Gets or sets the endianess of current + /// True for big endian, flase for little endian + /// + public bool BigEndian + { + get + { + return _bigEndian; + } + set + { + _bigEndian = value; + } + } + + /// + /// Gets the number of time tha value of current has changed + /// public int ChangeCount { get @@ -444,6 +505,28 @@ namespace BizHawk.Client.Common } } + /// + /// Gets or set the way current is displayed + /// + public DisplayType Type + { + get + { + return _type; + } + set + { + if (IsDiplayTypeAvailable(value)) + { + _type = value; + } + else + { + throw new ArgumentException(string.Format("DisplayType {0} is invalid for this type of Watch", value.ToString())); + } + } + } + /// /// Gets or sets current /// @@ -478,14 +561,32 @@ namespace BizHawk.Client.Common } } + /// + /// Gets a value that defined if the current address is + /// well in the range of current + /// public bool IsOutOfRange { get { - return !IsSeparator && (Domain.Size != 0 && Address.Value >= Domain.Size); + return !IsSeparator && (_domain.Size != 0 && _address >= _domain.Size); } } + /// + /// Gets a value that defined if the current is actually a + /// + public bool IsSeparator + { + get + { + return this is SeparatorWatch; + } + } + + /// + /// Gets or sets notes for current + /// public string Notes { get @@ -498,6 +599,17 @@ namespace BizHawk.Client.Common } } + /// + /// Gets the current size of the watch + /// + public WatchSize Size + { + get + { + return _size; + } + } + #endregion public static string DisplayTypeToString(DisplayType type) diff --git a/BizHawk.Client.Common/tools/Watch/WatchList.cs b/BizHawk.Client.Common/tools/Watch/WatchList.cs index 0e690bfd4a..c51a335fb6 100644 --- a/BizHawk.Client.Common/tools/Watch/WatchList.cs +++ b/BizHawk.Client.Common/tools/Watch/WatchList.cs @@ -532,9 +532,9 @@ namespace BizHawk.Client.Common memDomain, addr, size, - type, - notes, - bigEndian)); + type, + bigEndian, + notes)); _domain = _memoryDomains[domain]; } diff --git a/BizHawk.Client.Common/tools/Watch/WatchSize.cs b/BizHawk.Client.Common/tools/Watch/WatchSize.cs index f1274eb666..8803470ad5 100644 --- a/BizHawk.Client.Common/tools/Watch/WatchSize.cs +++ b/BizHawk.Client.Common/tools/Watch/WatchSize.cs @@ -5,33 +5,30 @@ using System.Text; namespace BizHawk.Client.Common { - public abstract partial class Watch + /// + /// This enum specify the size of a + /// + public enum WatchSize { /// - /// This enum specify the size of a + /// One byte (8 bits) + /// Use this for /// - public enum WatchSize - { - /// - /// One byte (8 bits) - /// Use this for - /// - Byte = 1, - /// - /// 2 bytes (16 bits) - /// Use this for - /// - Word = 2, - /// - /// 4 bytes (32 bits) - /// Use this for - /// - DWord = 4, - /// - /// Special case used for a separator in ramwatch - /// Use this for - /// - Separator = 0 - } + Byte = 1, + /// + /// 2 bytes (16 bits) + /// Use this for + /// + Word = 2, + /// + /// 4 bytes (32 bits) + /// Use this for + /// + DWord = 4, + /// + /// Special case used for a separator in ramwatch + /// Use this for + /// + Separator = 0 } } diff --git a/BizHawk.Client.Common/tools/Watch/WordWatch.cs b/BizHawk.Client.Common/tools/Watch/WordWatch.cs index 53bf20765d..0dba295bfa 100644 --- a/BizHawk.Client.Common/tools/Watch/WordWatch.cs +++ b/BizHawk.Client.Common/tools/Watch/WordWatch.cs @@ -10,33 +10,51 @@ namespace BizHawk.Client.Common { public sealed class WordWatch : Watch { + #region Fields + private ushort _previous; private ushort _value; - public WordWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, string notes) + #endregion + + #region cTor(s) + + internal WordWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, string note, ushort value, ushort previous, int changeCount) + : base(domain, address, WatchSize.Word, type, bigEndian, note) { - _domain = domain; - _address = address; - _value = _previous = GetWord(); + this._value = value; + this._previous = previous; + this._changecount = changeCount; + } - if (AvailableTypes(WatchSize.Word).Contains(type)) + internal WordWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, string note) + :this(domain, address, type, bigEndian, note, 0, 0, 0) + { + _previous = GetWord(); + _value = GetWord(); + } + + #endregion + + public static IEnumerable ValidTypes + { + get { - _type = type; - } - - _bigEndian = bigEndian; - - if (notes != null) - { - Notes = notes; + yield return DisplayType.Unsigned; + yield return DisplayType.Signed; + yield return DisplayType.Hex; + yield return DisplayType.Binary; + yield return DisplayType.FixedPoint_12_4; } } - public WordWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, ushort prev, int changeCount, string notes = null) - : this(domain, address, type, bigEndian, notes) + public override IEnumerable AvailableTypes() { - _previous = prev; - _changecount = changeCount; + yield return DisplayType.Unsigned; + yield return DisplayType.Signed; + yield return DisplayType.Hex; + yield return DisplayType.Binary; + yield return DisplayType.FixedPoint_12_4; } public override uint MaxValue @@ -69,22 +87,6 @@ namespace BizHawk.Client.Common _previous = GetWord(); } - public override WatchSize Size - { - get { return WatchSize.Word; } - } - - public static List ValidTypes - { - get - { - return new List - { - DisplayType.Unsigned, DisplayType.Signed, DisplayType.Hex, DisplayType.FixedPoint_12_4, DisplayType.Binary - }; - } - } - public override string ValueString { get { return FormatValue(GetWord()); } diff --git a/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.Designer.cs b/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.Designer.cs index 8b764f9462..e76870cf4c 100644 --- a/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.Designer.cs @@ -3346,7 +3346,7 @@ // // JaboResolutionHeightBox // - this.JaboResolutionHeightBox.ByteSize = BizHawk.Client.Common.Watch.WatchSize.Byte; + this.JaboResolutionHeightBox.ByteSize = BizHawk.Client.Common.WatchSize.Byte; this.JaboResolutionHeightBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; this.JaboResolutionHeightBox.Location = new System.Drawing.Point(127, 90); this.JaboResolutionHeightBox.MaxLength = 4; @@ -3355,11 +3355,11 @@ this.JaboResolutionHeightBox.Size = new System.Drawing.Size(52, 20); this.JaboResolutionHeightBox.TabIndex = 34; this.JaboResolutionHeightBox.Text = "0"; - this.JaboResolutionHeightBox.Type = BizHawk.Client.Common.Watch.DisplayType.Signed; + this.JaboResolutionHeightBox.Type = BizHawk.Client.Common.DisplayType.Signed; // // JaboResolutionWidthBox // - this.JaboResolutionWidthBox.ByteSize = BizHawk.Client.Common.Watch.WatchSize.Byte; + this.JaboResolutionWidthBox.ByteSize = BizHawk.Client.Common.WatchSize.Byte; this.JaboResolutionWidthBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; this.JaboResolutionWidthBox.Location = new System.Drawing.Point(127, 60); this.JaboResolutionWidthBox.MaxLength = 4; @@ -3368,7 +3368,7 @@ this.JaboResolutionWidthBox.Size = new System.Drawing.Size(52, 20); this.JaboResolutionWidthBox.TabIndex = 33; this.JaboResolutionWidthBox.Text = "0"; - this.JaboResolutionWidthBox.Type = BizHawk.Client.Common.Watch.DisplayType.Signed; + this.JaboResolutionWidthBox.Type = BizHawk.Client.Common.DisplayType.Signed; // // label71 // diff --git a/BizHawk.Client.EmuHawk/movie/PlayMovie.Designer.cs b/BizHawk.Client.EmuHawk/movie/PlayMovie.Designer.cs index 4a039fa60f..7963846c73 100644 --- a/BizHawk.Client.EmuHawk/movie/PlayMovie.Designer.cs +++ b/BizHawk.Client.EmuHawk/movie/PlayMovie.Designer.cs @@ -251,7 +251,7 @@ // StopOnFrameTextBox // this.StopOnFrameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.StopOnFrameTextBox.ByteSize = BizHawk.Client.Common.Watch.WatchSize.DWord; + this.StopOnFrameTextBox.ByteSize = BizHawk.Client.Common.WatchSize.DWord; this.StopOnFrameTextBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; this.StopOnFrameTextBox.Location = new System.Drawing.Point(438, 355); this.StopOnFrameTextBox.MaxLength = 10; @@ -259,7 +259,7 @@ this.StopOnFrameTextBox.Nullable = true; this.StopOnFrameTextBox.Size = new System.Drawing.Size(54, 20); this.StopOnFrameTextBox.TabIndex = 58; - this.StopOnFrameTextBox.Type = BizHawk.Client.Common.Watch.DisplayType.Unsigned; + this.StopOnFrameTextBox.Type = BizHawk.Client.Common.DisplayType.Unsigned; this.StopOnFrameTextBox.TextChanged += new System.EventHandler(this.StopOnFrameTextBox_TextChanged_1); // // MovieView diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/CheatEdit.Designer.cs b/BizHawk.Client.EmuHawk/tools/Cheats/CheatEdit.Designer.cs index be2ca9931f..dbc4872689 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/CheatEdit.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/CheatEdit.Designer.cs @@ -231,7 +231,7 @@ // // CompareBox // - this.CompareBox.ByteSize = BizHawk.Client.Common.Watch.WatchSize.Byte; + this.CompareBox.ByteSize = BizHawk.Client.Common.WatchSize.Byte; this.CompareBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; this.CompareBox.Location = new System.Drawing.Point(113, 91); this.CompareBox.MaxLength = 2; @@ -239,11 +239,11 @@ this.CompareBox.Nullable = true; this.CompareBox.Size = new System.Drawing.Size(65, 20); this.CompareBox.TabIndex = 15; - this.CompareBox.Type = BizHawk.Client.Common.Watch.DisplayType.Hex; + this.CompareBox.Type = BizHawk.Client.Common.DisplayType.Hex; // // ValueBox // - this.ValueBox.ByteSize = BizHawk.Client.Common.Watch.WatchSize.Byte; + this.ValueBox.ByteSize = BizHawk.Client.Common.WatchSize.Byte; this.ValueBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; this.ValueBox.Location = new System.Drawing.Point(113, 65); this.ValueBox.MaxLength = 2; @@ -252,7 +252,7 @@ this.ValueBox.Size = new System.Drawing.Size(65, 20); this.ValueBox.TabIndex = 12; this.ValueBox.Text = "00"; - this.ValueBox.Type = BizHawk.Client.Common.Watch.DisplayType.Hex; + this.ValueBox.Type = BizHawk.Client.Common.DisplayType.Hex; // // CheatEdit // diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/CheatEdit.cs b/BizHawk.Client.EmuHawk/tools/Cheats/CheatEdit.cs index 6a6517757c..9cc5351bfa 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/CheatEdit.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/CheatEdit.cs @@ -3,14 +3,15 @@ using System.Linq; using System.Windows.Forms; using BizHawk.Client.Common; -using BizHawk.Emulation.Common; +using Emu = BizHawk.Emulation.Common; using BizHawk.Emulation.Common.IEmulatorExtensions; + namespace BizHawk.Client.EmuHawk { public partial class CheatEdit : UserControl { - public IMemoryDomains MemoryDomains { get; set; } + public Emu.IMemoryDomains MemoryDomains { get; set; } public CheatEdit() { @@ -78,7 +79,7 @@ namespace BizHawk.Client.EmuHawk ValueHexIndLabel.Text = CompareHexIndLabel.Text = - _cheat.Type == Watch.DisplayType.Hex ? HexInd : string.Empty; + _cheat.Type == DisplayType.Hex ? HexInd : string.Empty; BigEndianCheckBox.Checked = _cheat.BigEndian.Value; @@ -99,7 +100,7 @@ namespace BizHawk.Client.EmuHawk private void SetFormToDefault() { _loading = true; - SetSizeSelected(Watch.WatchSize.Byte); + SetSizeSelected(WatchSize.Byte); PopulateTypeDropdown(); NameBox.Text = string.Empty; @@ -111,11 +112,11 @@ namespace BizHawk.Client.EmuHawk ValueBox.ByteSize = CompareBox.ByteSize = - Watch.WatchSize.Byte; + WatchSize.Byte; ValueBox.Type = CompareBox.Type = - Watch.DisplayType.Hex; + DisplayType.Hex; ValueBox.ResetText(); CompareBox.ResetText(); @@ -126,31 +127,31 @@ namespace BizHawk.Client.EmuHawk BigEndianCheckBox.Checked = false; - SetTypeSelected(Watch.DisplayType.Hex); + SetTypeSelected(DisplayType.Hex); CheckFormState(); CompareBox.Text = string.Empty; // TODO: A needed hack until WatchValueBox.ToRawInt() becomes nullable _loading = false; } - private void SetSizeSelected(Watch.WatchSize size) + private void SetSizeSelected(WatchSize size) { switch (size) { default: - case Watch.WatchSize.Byte: + case WatchSize.Byte: SizeDropDown.SelectedIndex = 0; break; - case Watch.WatchSize.Word: + case WatchSize.Word: SizeDropDown.SelectedIndex = 1; break; - case Watch.WatchSize.DWord: + case WatchSize.DWord: SizeDropDown.SelectedIndex = 2; break; } } - private void SetTypeSelected(Watch.DisplayType type) + private void SetTypeSelected(Common.DisplayType type) { foreach (var item in DisplayTypeDropDown.Items) { @@ -162,7 +163,7 @@ namespace BizHawk.Client.EmuHawk } } - private void SetDomainSelected(MemoryDomain domain) + private void SetDomainSelected(Emu.MemoryDomain domain) { foreach (var item in DomainDropDown.Items) { @@ -181,13 +182,22 @@ namespace BizHawk.Client.EmuHawk { default: case 0: - DisplayTypeDropDown.Items.AddRange(ByteWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray()); + foreach(DisplayType t in ByteWatch.ValidTypes) + { + DisplayTypeDropDown.Items.Add(Watch.DisplayTypeToString(t)); + } break; case 1: - DisplayTypeDropDown.Items.AddRange(WordWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray()); + foreach (DisplayType t in WordWatch.ValidTypes) + { + DisplayTypeDropDown.Items.Add(Watch.DisplayTypeToString(t)); + } break; case 2: - DisplayTypeDropDown.Items.AddRange(DWordWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray()); + foreach (DisplayType t in DWordWatch.ValidTypes) + { + DisplayTypeDropDown.Items.Add(Watch.DisplayTypeToString(t)); + } break; } @@ -222,17 +232,17 @@ namespace BizHawk.Client.EmuHawk } } - private Watch.WatchSize GetCurrentSize() + private WatchSize GetCurrentSize() { switch (SizeDropDown.SelectedIndex) { default: case 0: - return Watch.WatchSize.Byte; + return WatchSize.Byte; case 1: - return Watch.WatchSize.Word; + return WatchSize.Word; case 2: - return Watch.WatchSize.DWord; + return WatchSize.DWord; } } @@ -295,7 +305,6 @@ namespace BizHawk.Client.EmuHawk { var domain = MemoryDomains[DomainDropDown.SelectedItem.ToString()]; var address = AddressBox.ToRawInt().Value; - //var address = AddressBox.ToRawInt() ?? 0; if (address < domain.Size) { var watch = Watch.GenerateWatch( @@ -303,8 +312,9 @@ namespace BizHawk.Client.EmuHawk AddressBox.ToRawInt().Value, GetCurrentSize(), Watch.StringToDisplayType(DisplayTypeDropDown.SelectedItem.ToString()), - NameBox.Text, - BigEndianCheckBox.Checked); + BigEndianCheckBox.Checked, + NameBox.Text + ); return new Cheat( watch, diff --git a/BizHawk.Client.EmuHawk/tools/GB/GBGameGenie.cs b/BizHawk.Client.EmuHawk/tools/GB/GBGameGenie.cs index 64a3835d4a..2a35ca3afc 100644 --- a/BizHawk.Client.EmuHawk/tools/GB/GBGameGenie.cs +++ b/BizHawk.Client.EmuHawk/tools/GB/GBGameGenie.cs @@ -243,10 +243,10 @@ namespace BizHawk.Client.EmuHawk var watch = Watch.GenerateWatch( MemoryDomains["System Bus"], address, - Watch.WatchSize.Byte, - Watch.DisplayType.Hex, - name, - false); + WatchSize.Byte, + Client.Common.DisplayType.Hex, + false, + name); Global.CheatList.Add(new Cheat( watch, diff --git a/BizHawk.Client.EmuHawk/tools/GameShark.cs b/BizHawk.Client.EmuHawk/tools/GameShark.cs index 7578e49b8e..ca30971a98 100644 --- a/BizHawk.Client.EmuHawk/tools/GameShark.cs +++ b/BizHawk.Client.EmuHawk/tools/GameShark.cs @@ -43,7 +43,7 @@ namespace BizHawk.Client.EmuHawk {'E', 14 }, {'F', 15 } }; - private readonly Dictionary _GENgameGenieTable = new Dictionary + private readonly Dictionary _GENgameGenieTable = new Dictionary { { 'A', 0 }, { 'B', 1 }, @@ -355,7 +355,7 @@ namespace BizHawk.Client.EmuHawk { //A Watch needs to be generated so we can make a cheat out of that. This is due to how the Cheat engine works. //System Bus Domain, The Address to Watch, Byte size (Byte), Hex Display, Description. Not Big Endian. - var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), Watch.WatchSize.Byte, Watch.DisplayType.Hex, txtDescription.Text, false); + var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Byte, Client.Common.DisplayType.Hex, false, txtDescription.Text); //Take Watch, Add our Value we want, and it should be active when addded? if (RAMCompare == null) { @@ -472,17 +472,17 @@ namespace BizHawk.Client.EmuHawk { if (byteSize == 8) { - var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), Watch.WatchSize.Byte, Watch.DisplayType.Hex, txtDescription.Text, false); + var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Byte, Client.Common.DisplayType.Hex, false, txtDescription.Text); Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); } else if (byteSize == 16) { - var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), Watch.WatchSize.Word, Watch.DisplayType.Hex, txtDescription.Text, false); + var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Word, Client.Common.DisplayType.Hex, false, txtDescription.Text); Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); } else if (byteSize == 32) { - var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), Watch.WatchSize.DWord, Watch.DisplayType.Hex, txtDescription.Text, false); + var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.DWord, Client.Common.DisplayType.Hex, false, txtDescription.Text); Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); } //Clear old Inputs @@ -520,7 +520,7 @@ namespace BizHawk.Client.EmuHawk foreach (var t in code) { hexcode <<= 5; - int y; + long y; _GENgameGenieTable.TryGetValue(t, out y); hexcode |= y; } @@ -537,7 +537,7 @@ namespace BizHawk.Client.EmuHawk address = add.ToString("X6"); value = val.ToString("X4"); //Game Geneie, modifies the "ROM" which is why it says, "MD CART" - var watch = Watch.GenerateWatch(MemoryDomains["MD CART"], long.Parse(address, NumberStyles.HexNumber), Watch.WatchSize.Word, Watch.DisplayType.Hex, txtDescription.Text, true); + var watch = Watch.GenerateWatch(MemoryDomains["MD CART"], long.Parse(address, NumberStyles.HexNumber), WatchSize.Word, Client.Common.DisplayType.Hex, true, txtDescription.Text); //Add Cheat Global.CheatList.Add(new Cheat(watch, val)); } @@ -595,7 +595,7 @@ namespace BizHawk.Client.EmuHawk //System Bus Domain, The Address to Watch, Byte size (Byte), Hex Display, Description, Big Endian. if (byteSize == 1) { - var watch = Watch.GenerateWatch(MemoryDomains["68K RAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), Watch.WatchSize.Byte, Watch.DisplayType.Hex, txtDescription.Text, false); + var watch = Watch.GenerateWatch(MemoryDomains["68K RAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Byte, Client.Common.DisplayType.Hex, false, txtDescription.Text); //Take Watch, Add our Value we want, and it should be active when addded? Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); //Clear old Inputs @@ -604,7 +604,7 @@ namespace BizHawk.Client.EmuHawk } if (byteSize == 2) { - var watch = Watch.GenerateWatch(MemoryDomains["68K RAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), Watch.WatchSize.Word, Watch.DisplayType.Hex, txtDescription.Text, true); + var watch = Watch.GenerateWatch(MemoryDomains["68K RAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Word, Client.Common.DisplayType.Hex, true, txtDescription.Text); //Take Watch, Add our Value we want, and it should be active when addded? Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); //Clear old Inputs @@ -729,14 +729,14 @@ namespace BizHawk.Client.EmuHawk if (byteSize == 8) { //We have a Byte sized value - var watch = Watch.GenerateWatch(MemoryDomains["RDRAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), Watch.WatchSize.Byte, Watch.DisplayType.Hex, txtDescription.Text, true); + var watch = Watch.GenerateWatch(MemoryDomains["RDRAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Byte, Client.Common.DisplayType.Hex, true, txtDescription.Text); //Take Watch, Add our Value we want, and it should be active when addded? Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); } if (byteSize == 16) { //We have a Word (Double Byte) sized Value - var watch = Watch.GenerateWatch(MemoryDomains["RDRAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), Watch.WatchSize.Word, Watch.DisplayType.Hex, txtDescription.Text, true); + var watch = Watch.GenerateWatch(MemoryDomains["RDRAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Word, Client.Common.DisplayType.Hex, true, txtDescription.Text); //Take Watch, Add our Value we want, and it should be active when addded? Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); } @@ -850,7 +850,7 @@ namespace BizHawk.Client.EmuHawk //A Watch needs to be generated so we can make a cheat out of that. This is due to how the Cheat engine works. //System Bus Domain, The Address to Watch, Byte size (Word), Hex Display, Description. Big Endian. //We have a Byte sized value - var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), Watch.WatchSize.Byte, Watch.DisplayType.Hex, txtDescription.Text, false); + var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Byte, Client.Common.DisplayType.Hex, false, txtDescription.Text); //Take Watch, Add our Value we want, and it should be active when addded? if (strCompare == "00") { @@ -964,14 +964,14 @@ namespace BizHawk.Client.EmuHawk if (byteSize == 8) { //We have a Byte sized value - var watch = Watch.GenerateWatch(MemoryDomains["MainRAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), Watch.WatchSize.Word, Watch.DisplayType.Hex, txtDescription.Text, false); + var watch = Watch.GenerateWatch(MemoryDomains["MainRAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Word, Client.Common.DisplayType.Hex, false, txtDescription.Text); //Take Watch, Add our Value we want, and it should be active when addded? Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); } if (byteSize == 16) { //We have a Word (Double Byte) sized Value - var watch = Watch.GenerateWatch(MemoryDomains["MainRAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), Watch.WatchSize.Byte, Watch.DisplayType.Hex, txtDescription.Text, false); + var watch = Watch.GenerateWatch(MemoryDomains["MainRAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Byte, Client.Common.DisplayType.Hex, false, txtDescription.Text); //Take Watch, Add our Value we want, and it should be active when addded? Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); } @@ -1043,14 +1043,14 @@ namespace BizHawk.Client.EmuHawk if (byteSize == 8) { //We have a Byte sized value - var watch = Watch.GenerateWatch(MemoryDomains["Work Ram High"], long.Parse(RAMAddress, NumberStyles.HexNumber), Watch.WatchSize.Word, Watch.DisplayType.Hex, txtDescription.Text, true); + var watch = Watch.GenerateWatch(MemoryDomains["Work Ram High"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Word, Client.Common.DisplayType.Hex, true, txtDescription.Text); //Take Watch, Add our Value we want, and it should be active when addded? Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); } if (byteSize == 16) { //We have a Word (Double Byte) sized Value - var watch = Watch.GenerateWatch(MemoryDomains["Work Ram High"], long.Parse(RAMAddress, NumberStyles.HexNumber), Watch.WatchSize.Byte, Watch.DisplayType.Hex, txtDescription.Text, true); + var watch = Watch.GenerateWatch(MemoryDomains["Work Ram High"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Byte, Client.Common.DisplayType.Hex, true, txtDescription.Text); //Take Watch, Add our Value we want, and it should be active when addded? Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); } @@ -1105,7 +1105,7 @@ namespace BizHawk.Client.EmuHawk { //A Watch needs to be generated so we can make a cheat out of that. This is due to how the Cheat engine works. //System Bus Domain, The Address to Watch, Byte size (Byte), Hex Display, Description. Not Big Endian. - var watch = Watch.GenerateWatch(MemoryDomains["Main RAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), Watch.WatchSize.Byte, Watch.DisplayType.Hex, txtDescription.Text, false); + var watch = Watch.GenerateWatch(MemoryDomains["Main RAM"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Byte, Client.Common.DisplayType.Hex, false, txtDescription.Text); //Take Watch, Add our Value we want, and it should be active when addded if (RAMCompare == null) @@ -1238,14 +1238,14 @@ namespace BizHawk.Client.EmuHawk if (byteSize == 16) { //System Bus Domain, The Address to Watch, Byte size (Byte), Hex Display, Description. Not Big Endian. - var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), Watch.WatchSize.Word, Watch.DisplayType.Hex, txtDescription.Text, false); + var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Word, Client.Common.DisplayType.Hex, false, txtDescription.Text); Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); } if (byteSize == 8) { //Is this correct? //I don't think so, but Changing it to CARTROM, causes a major issue. - var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), Watch.WatchSize.Word, Watch.DisplayType.Hex, txtDescription.Text, false); + var watch = Watch.GenerateWatch(MemoryDomains["System Bus"], long.Parse(RAMAddress, NumberStyles.HexNumber), WatchSize.Word, Client.Common.DisplayType.Hex, false, txtDescription.Text); Global.CheatList.Add(new Cheat(watch, int.Parse(RAMValue, NumberStyles.HexNumber))); } //Take Watch, Add our Value we want, and it should be active when addded? diff --git a/BizHawk.Client.EmuHawk/tools/Genesis/GenGameGenie.cs b/BizHawk.Client.EmuHawk/tools/Genesis/GenGameGenie.cs index 698ac317c9..3d5b730ab2 100644 --- a/BizHawk.Client.EmuHawk/tools/Genesis/GenGameGenie.cs +++ b/BizHawk.Client.EmuHawk/tools/Genesis/GenGameGenie.cs @@ -316,10 +316,10 @@ namespace BizHawk.Client.EmuHawk var watch = Watch.GenerateWatch( MemoryDomains["MD CART"], address, - Watch.WatchSize.Word, - Watch.DisplayType.Hex, - name, - true + WatchSize.Word, + Client.Common.DisplayType.Hex, + true, + name ); Global.CheatList.Add(new Cheat( diff --git a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs index 427f0f4345..8cec1a2f05 100644 --- a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs +++ b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs @@ -105,11 +105,11 @@ namespace BizHawk.Client.EmuHawk } } - private Watch.WatchSize WatchSize + private WatchSize WatchSize { get { - return (Watch.WatchSize)DataSize; + return (WatchSize)DataSize; } } @@ -173,7 +173,7 @@ namespace BizHawk.Client.EmuHawk AddressLabel.Text = GenerateAddressString(); } - public void SetToAddresses(IEnumerable addresses, MemoryDomain domain, Watch.WatchSize size) + public void SetToAddresses(IEnumerable addresses, MemoryDomain domain, WatchSize size) { DataSize = (int)size; SetDataSize(DataSize); @@ -546,7 +546,7 @@ namespace BizHawk.Client.EmuHawk { if (Global.CheatList.IsActive(_domain, address)) { - return Global.CheatList.GetCheatValue(_domain, address, (Watch.WatchSize)DataSize ).Value; + return Global.CheatList.GetCheatValue(_domain, address, (WatchSize)DataSize ).Value; } switch (dataSize) @@ -722,12 +722,12 @@ namespace BizHawk.Client.EmuHawk switch (DataSize) { default: - case 1: - return new ByteWatch(_domain, address, Watch.DisplayType.Hex, BigEndian, string.Empty); - case 2: - return new WordWatch(_domain, address, Watch.DisplayType.Hex, BigEndian, string.Empty); + case 1: + return Watch.GenerateWatch(_domain, address, WatchSize.Byte, Client.Common.DisplayType.Hex, BigEndian, string.Empty); + case 2: + return Watch.GenerateWatch(_domain, address, WatchSize.Word, Client.Common.DisplayType.Hex, BigEndian, string.Empty); case 4: - return new DWordWatch(_domain, address, Watch.DisplayType.Hex, BigEndian, string.Empty); + return Watch.GenerateWatch(_domain, address, WatchSize.DWord, Client.Common.DisplayType.Hex, BigEndian, string.Empty); } } @@ -757,8 +757,7 @@ namespace BizHawk.Client.EmuHawk _domain, address, WatchSize, - Watch.DisplayType.Hex, - string.Empty, + Client.Common.DisplayType.Hex, BigEndian); Global.CheatList.Add(new Cheat( @@ -776,8 +775,7 @@ namespace BizHawk.Client.EmuHawk _domain, address, WatchSize, - Watch.DisplayType.Hex, - string.Empty, + Client.Common.DisplayType.Hex, BigEndian); cheats.Add(new Cheat( @@ -1616,9 +1614,8 @@ namespace BizHawk.Client.EmuHawk address => Watch.GenerateWatch( _domain, address, - (Watch.WatchSize)DataSize, - Watch.DisplayType.Hex, - string.Empty, + (WatchSize)DataSize, + Client.Common.DisplayType.Hex, BigEndian)); poke.SetWatch(watches); @@ -2109,7 +2106,7 @@ namespace BizHawk.Client.EmuHawk { var gaps = (int)cheat.Size - (int)DataSize; - if (cheat.Size == Watch.WatchSize.DWord && DataSize == 2) + if (cheat.Size == WatchSize.DWord && DataSize == 2) { gaps -= 1; } diff --git a/BizHawk.Client.EmuHawk/tools/NES/NESGameGenie.cs b/BizHawk.Client.EmuHawk/tools/NES/NESGameGenie.cs index 525db66025..9bce0c8c31 100644 --- a/BizHawk.Client.EmuHawk/tools/NES/NESGameGenie.cs +++ b/BizHawk.Client.EmuHawk/tools/NES/NESGameGenie.cs @@ -183,10 +183,10 @@ namespace BizHawk.Client.EmuHawk var watch = Watch.GenerateWatch( MemoryDomains["System Bus"], AddressBox.ToRawInt().Value, - Watch.WatchSize.Byte, - Watch.DisplayType.Hex, - GameGenieCode.Text, - false); + WatchSize.Byte, + Client.Common.DisplayType.Hex, + false, + GameGenieCode.Text); Global.CheatList.Add(new Cheat( watch, diff --git a/BizHawk.Client.EmuHawk/tools/SNES/SNESGameGenie.cs b/BizHawk.Client.EmuHawk/tools/SNES/SNESGameGenie.cs index 7572eef6d9..160d08cfb3 100644 --- a/BizHawk.Client.EmuHawk/tools/SNES/SNESGameGenie.cs +++ b/BizHawk.Client.EmuHawk/tools/SNES/SNESGameGenie.cs @@ -213,10 +213,10 @@ namespace BizHawk.Client.EmuHawk var watch = Watch.GenerateWatch( MemoryDomains["System Bus"], address, - Watch.WatchSize.Byte, - Watch.DisplayType.Hex, - name, - bigEndian: false + WatchSize.Byte, + Client.Common.DisplayType.Hex, + false, + name ); Global.CheatList.Add(new Cheat( diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/FramesPrompt.Designer.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/FramesPrompt.Designer.cs index 3506464678..d731b5bc4c 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/FramesPrompt.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/FramesPrompt.Designer.cs @@ -68,7 +68,7 @@ // // NumFramesBox // - this.NumFramesBox.ByteSize = BizHawk.Client.Common.Watch.WatchSize.Byte; + this.NumFramesBox.ByteSize = BizHawk.Client.Common.WatchSize.Byte; this.NumFramesBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; this.NumFramesBox.Location = new System.Drawing.Point(138, 16); this.NumFramesBox.MaxLength = 5; @@ -77,7 +77,7 @@ this.NumFramesBox.Size = new System.Drawing.Size(51, 20); this.NumFramesBox.TabIndex = 3; this.NumFramesBox.Text = "1"; - this.NumFramesBox.Type = BizHawk.Client.Common.Watch.DisplayType.Unsigned; + this.NumFramesBox.Type = BizHawk.Client.Common.DisplayType.Unsigned; // // FramesPrompt // diff --git a/BizHawk.Client.EmuHawk/tools/ToolHelpers.cs b/BizHawk.Client.EmuHawk/tools/ToolHelpers.cs index f312ff3b61..cfc212659e 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolHelpers.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolHelpers.cs @@ -93,7 +93,7 @@ namespace BizHawk.Client.EmuHawk } } - public static void ViewInHexEditor(MemoryDomain domain, IEnumerable addresses, Watch.WatchSize size) + public static void ViewInHexEditor(MemoryDomain domain, IEnumerable addresses, WatchSize size) { GlobalWin.Tools.Load(); GlobalWin.Tools.HexEditor.SetToAddresses(addresses, domain, size); diff --git a/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/BizHawk.Client.EmuHawk/tools/ToolManager.cs index c724746669..53d8b4bda6 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -583,7 +583,7 @@ namespace BizHawk.Client.EmuHawk MessageBox.Show("It seems that the object CustomMainForm does not have a public default constructor. Please review the code.", "No, no, no. Wrong Way !", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return null; } - catch (TypeLoadException ex) + catch (TypeLoadException) { MessageBox.Show("It seems that the object CustomMainForm does not exists. Please review the code.", "No, no, no. Wrong Way !", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return null; diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamPoke.Designer.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamPoke.Designer.cs index 266e7242cf..6552bcbd48 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamPoke.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamPoke.Designer.cs @@ -99,7 +99,7 @@ // // ValueBox // - this.ValueBox.ByteSize = BizHawk.Client.Common.Watch.WatchSize.Byte; + this.ValueBox.ByteSize = BizHawk.Client.Common.WatchSize.Byte; this.ValueBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; this.ValueBox.Location = new System.Drawing.Point(82, 57); this.ValueBox.MaxLength = 2; @@ -108,7 +108,7 @@ this.ValueBox.Size = new System.Drawing.Size(116, 20); this.ValueBox.TabIndex = 10; this.ValueBox.Text = "00"; - this.ValueBox.Type = BizHawk.Client.Common.Watch.DisplayType.Hex; + this.ValueBox.Type = BizHawk.Client.Common.DisplayType.Hex; // // ValueHexLabel // diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamPoke.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamPoke.cs index a960fb803b..9b1062bd1e 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamPoke.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamPoke.cs @@ -80,7 +80,7 @@ namespace BizHawk.Client.EmuHawk ValueBox.ByteSize = _watchList[0].Size; ValueBox.Type = _watchList[0].Type; - ValueHexLabel.Text = _watchList[0].Type == Watch.DisplayType.Hex ? "0x" : string.Empty; + ValueHexLabel.Text = _watchList[0].Type == DisplayType.Hex ? "0x" : string.Empty; ValueBox.Text = _watchList[0].ValueString.Replace(" ", string.Empty); DomainLabel.Text = _watchList[0].Domain.Name; SizeLabel.Text = _watchList[0].Size.ToString(); diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.Designer.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.Designer.cs index 767df2c554..ecea381455 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.Designer.cs @@ -957,7 +957,7 @@ // this.SpecificValueBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.SpecificValueBox.ByteSize = BizHawk.Client.Common.Watch.WatchSize.Byte; + this.SpecificValueBox.ByteSize = BizHawk.Client.Common.WatchSize.Byte; this.SpecificValueBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; this.SpecificValueBox.Enabled = false; this.SpecificValueBox.Location = new System.Drawing.Point(114, 38); @@ -967,7 +967,7 @@ this.SpecificValueBox.Size = new System.Drawing.Size(72, 20); this.SpecificValueBox.TabIndex = 15; this.SpecificValueBox.Text = "00"; - this.SpecificValueBox.Type = BizHawk.Client.Common.Watch.DisplayType.Hex; + this.SpecificValueBox.Type = BizHawk.Client.Common.DisplayType.Hex; this.SpecificValueBox.TextChanged += new System.EventHandler(this.CompareToValue_TextChanged); // // NumberOfChangesRadio diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs index f8a70b9b91..b225c9065a 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs @@ -86,7 +86,7 @@ namespace BizHawk.Client.EmuHawk get { return false; } } - private void HardSetDisplayTypeDropDown(Watch.DisplayType type) + private void HardSetDisplayTypeDropDown(BizHawk.Client.Common.DisplayType type) { foreach (var item in DisplayTypeDropdown.Items) { @@ -97,17 +97,17 @@ namespace BizHawk.Client.EmuHawk } } - private void HardSetSizeDropDown(Watch.WatchSize size) + private void HardSetSizeDropDown(WatchSize size) { switch (size) { - case Watch.WatchSize.Byte: + case WatchSize.Byte: SizeDropdown.SelectedIndex = 0; break; - case Watch.WatchSize.Word: + case WatchSize.Word: SizeDropdown.SelectedIndex = 1; break; - case Watch.WatchSize.DWord: + case WatchSize.DWord: SizeDropdown.SelectedIndex = 2; break; } @@ -645,7 +645,7 @@ namespace BizHawk.Client.EmuHawk } } - private void DoDisplayTypeClick(Watch.DisplayType type) + private void DoDisplayTypeClick(BizHawk.Client.Common.DisplayType type) { if (_settings.Type != type) { @@ -668,15 +668,16 @@ namespace BizHawk.Client.EmuHawk WatchListView.Refresh(); } - private void SetPreviousStype(Watch.PreviousType type) + private void SetPreviousStype(PreviousType type) { _settings.PreviousType = type; _searches.SetPreviousType(type); } - private void SetSize(Watch.WatchSize size) + private void SetSize(WatchSize size) { - SpecificValueBox.ByteSize = _settings.Size = size; + _settings.Size = size; + SpecificValueBox.ByteSize = size; if (!string.IsNullOrEmpty(SpecificAddressBox.Text)) { SpecificAddressBox.Text = "0"; @@ -687,29 +688,37 @@ namespace BizHawk.Client.EmuHawk SpecificValueBox.Text = "0"; } - if (!Watch.AvailableTypes(size).Contains(_settings.Type)) - { - _settings.Type = Watch.AvailableTypes(size)[0]; - } - - _dropdownDontfire = true; + bool isTypeCompatible = false; switch (size) { - case Watch.WatchSize.Byte: + case WatchSize.Byte: + isTypeCompatible = ByteWatch.ValidTypes.Where(t => t == _settings.Type).Any(); SizeDropdown.SelectedIndex = 0; break; - case Watch.WatchSize.Word: + + case WatchSize.Word: + isTypeCompatible = WordWatch.ValidTypes.Where(t => t == _settings.Type).Any(); SizeDropdown.SelectedIndex = 1; break; - case Watch.WatchSize.DWord: + + case WatchSize.DWord: + isTypeCompatible = DWordWatch.ValidTypes.Where(t => t == _settings.Type).Any(); SizeDropdown.SelectedIndex = 2; break; } + if (!isTypeCompatible) + { + _settings.Type = Client.Common.DisplayType.Unsigned; + } + + _dropdownDontfire = true; + PopulateTypeDropDown(); _dropdownDontfire = false; SpecificValueBox.Type = _settings.Type; SetReboot(true); + NewSearch(); } private void PopulateTypeDropDown() @@ -718,7 +727,23 @@ namespace BizHawk.Client.EmuHawk var next = string.Empty; DisplayTypeDropdown.Items.Clear(); - var types = Watch.AvailableTypes(_settings.Size); + + IEnumerable types = null; + switch (_settings.Size) + { + case WatchSize.Byte: + types = ByteWatch.ValidTypes; + break; + + case WatchSize.Word: + types = WordWatch.ValidTypes; + break; + + case WatchSize.DWord: + types = DWordWatch.ValidTypes; + break; + } + foreach (var type in types) { var typeStr = Watch.DisplayTypeToString(type); @@ -780,9 +805,9 @@ namespace BizHawk.Client.EmuHawk { _settings.Mode = RamSearchEngine.Settings.SearchMode.Fast; - if (_settings.PreviousType == Watch.PreviousType.LastFrame || _settings.PreviousType == Watch.PreviousType.LastChange) + if (_settings.PreviousType == PreviousType.LastFrame || _settings.PreviousType == PreviousType.LastChange) { - SetPreviousStype(Watch.PreviousType.LastSearch); + SetPreviousStype(PreviousType.LastSearch); } NumberOfChangesRadio.Enabled = false; @@ -1077,16 +1102,32 @@ namespace BizHawk.Client.EmuHawk private void SizeSubMenu_DropDownOpened(object sender, EventArgs e) { - ByteMenuItem.Checked = _settings.Size == Watch.WatchSize.Byte; - WordMenuItem.Checked = _settings.Size == Watch.WatchSize.Word; - DWordMenuItem.Checked = _settings.Size == Watch.WatchSize.DWord; + ByteMenuItem.Checked = _settings.Size == WatchSize.Byte; + WordMenuItem.Checked = _settings.Size == WatchSize.Word; + DWordMenuItem.Checked = _settings.Size == WatchSize.DWord; } private void DisplayTypeSubMenu_DropDownOpened(object sender, EventArgs e) { DisplayTypeSubMenu.DropDownItems.Clear(); - foreach (var type in Watch.AvailableTypes(_settings.Size)) + IEnumerable types = null; + switch (_settings.Size) + { + case WatchSize.Byte: + types = ByteWatch.ValidTypes; + break; + + case WatchSize.Word: + types = WordWatch.ValidTypes; + break; + + case WatchSize.DWord: + types = DWordWatch.ValidTypes; + break; + } + + foreach (var type in types) { var item = new ToolStripMenuItem { @@ -1111,16 +1152,16 @@ namespace BizHawk.Client.EmuHawk switch (_settings.PreviousType) { default: - case Watch.PreviousType.LastSearch: + case PreviousType.LastSearch: Previous_LastSearchMenuItem.Checked = true; break; - case Watch.PreviousType.LastFrame: + case PreviousType.LastFrame: PreviousFrameMenuItem.Checked = true; break; - case Watch.PreviousType.Original: + case PreviousType.Original: Previous_OriginalMenuItem.Checked = true; break; - case Watch.PreviousType.LastChange: + case PreviousType.LastChange: Previous_LastChangeMenuItem.Checked = true; break; } @@ -1141,17 +1182,17 @@ namespace BizHawk.Client.EmuHawk private void ByteMenuItem_Click(object sender, EventArgs e) { - SetSize(Watch.WatchSize.Byte); + SetSize(WatchSize.Byte); } private void WordMenuItem_Click(object sender, EventArgs e) { - SetSize(Watch.WatchSize.Word); + SetSize(WatchSize.Word); } private void DWordMenuItem_Click_Click(object sender, EventArgs e) { - SetSize(Watch.WatchSize.DWord); + SetSize(WatchSize.DWord); } private void CheckMisalignedMenuItem_Click(object sender, EventArgs e) @@ -1162,22 +1203,22 @@ namespace BizHawk.Client.EmuHawk private void Previous_LastFrameMenuItem_Click(object sender, EventArgs e) { - SetPreviousStype(Watch.PreviousType.LastFrame); + SetPreviousStype(PreviousType.LastFrame); } private void Previous_LastSearchMenuItem_Click(object sender, EventArgs e) { - SetPreviousStype(Watch.PreviousType.LastSearch); + SetPreviousStype(PreviousType.LastSearch); } private void Previous_OriginalMenuItem_Click(object sender, EventArgs e) { - SetPreviousStype(Watch.PreviousType.Original); + SetPreviousStype(PreviousType.Original); } private void Previous_LastChangeMenuItem_Click(object sender, EventArgs e) { - SetPreviousStype(Watch.PreviousType.LastChange); + SetPreviousStype(PreviousType.LastChange); } private void BigEndianMenuItem_Click(object sender, EventArgs e) @@ -1459,7 +1500,7 @@ namespace BizHawk.Client.EmuHawk WatchListView.Refresh(); } - private Watch.WatchSize SelectedSize + private WatchSize SelectedSize { get { @@ -1467,11 +1508,11 @@ namespace BizHawk.Client.EmuHawk { default: case 0: - return Watch.WatchSize.Byte; + return WatchSize.Byte; case 1: - return Watch.WatchSize.Word; + return WatchSize.Word; case 2: - return Watch.WatchSize.DWord; + return WatchSize.DWord; } } } diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs index 0eadd6252d..e98fc906ea 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs @@ -352,7 +352,7 @@ namespace BizHawk.Client.EmuHawk var sb = new StringBuilder(); foreach (var watch in SelectedItems) { - sb.AppendLine(watch.ToString()); + sb.AppendLine(ToString()); } if (sb.Length > 0) @@ -925,24 +925,24 @@ namespace BizHawk.Client.EmuHawk private void DefinePreviousValueSubMenu_DropDownOpened(object sender, EventArgs e) { - PreviousFrameMenuItem.Checked = Global.Config.RamWatchDefinePrevious == Watch.PreviousType.LastFrame; - LastChangeMenuItem.Checked = Global.Config.RamWatchDefinePrevious == Watch.PreviousType.LastChange; - OriginalMenuItem.Checked = Global.Config.RamWatchDefinePrevious == Watch.PreviousType.Original; + PreviousFrameMenuItem.Checked = Global.Config.RamWatchDefinePrevious == PreviousType.LastFrame; + LastChangeMenuItem.Checked = Global.Config.RamWatchDefinePrevious == PreviousType.LastChange; + OriginalMenuItem.Checked = Global.Config.RamWatchDefinePrevious == PreviousType.Original; } private void PreviousFrameMenuItem_Click(object sender, EventArgs e) { - Global.Config.RamWatchDefinePrevious = Watch.PreviousType.LastFrame; + Global.Config.RamWatchDefinePrevious = PreviousType.LastFrame; } private void LastChangeMenuItem_Click(object sender, EventArgs e) { - Global.Config.RamWatchDefinePrevious = Watch.PreviousType.LastChange; + Global.Config.RamWatchDefinePrevious = PreviousType.LastChange; } private void OriginalMenuItem_Click(object sender, EventArgs e) { - Global.Config.RamWatchDefinePrevious = Watch.PreviousType.Original; + Global.Config.RamWatchDefinePrevious = PreviousType.Original; } private void WatchesOnScreenMenuItem_Click(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/tools/Watch/WatchEditor.cs b/BizHawk.Client.EmuHawk/tools/Watch/WatchEditor.cs index 53a8dd6a83..159630392a 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/WatchEditor.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/WatchEditor.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Windows.Forms; using BizHawk.Client.Common; -using BizHawk.Emulation.Common; +using Emu = BizHawk.Emulation.Common; namespace BizHawk.Client.EmuHawk { @@ -15,7 +15,7 @@ namespace BizHawk.Client.EmuHawk private readonly List _watchList = new List(); - public IMemoryDomains MemoryDomains { get; set; } + public Emu.IMemoryDomains MemoryDomains { get; set; } private Mode _mode = Mode.New; private bool _loading = true; @@ -64,13 +64,13 @@ namespace BizHawk.Client.EmuHawk case Mode.Edit: switch (_watchList[0].Size) { - case Watch.WatchSize.Byte: + case WatchSize.Byte: SizeDropDown.SelectedItem = SizeDropDown.Items[0]; break; - case Watch.WatchSize.Word: + case WatchSize.Word: SizeDropDown.SelectedItem = SizeDropDown.Items[1]; break; - case Watch.WatchSize.DWord: + case WatchSize.DWord: SizeDropDown.SelectedItem = SizeDropDown.Items[2]; break; } @@ -105,7 +105,7 @@ namespace BizHawk.Client.EmuHawk } } - public void SetWatch(MemoryDomain domain, IEnumerable watches = null, Mode mode = Mode.New) + public void SetWatch(Emu.MemoryDomain domain, IEnumerable watches = null, Mode mode = Mode.New) { if (watches != null) { @@ -160,13 +160,22 @@ namespace BizHawk.Client.EmuHawk { default: case 0: - DisplayTypeDropDown.Items.AddRange(ByteWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray()); + foreach(DisplayType t in ByteWatch.ValidTypes) + { + DisplayTypeDropDown.Items.Add(Watch.DisplayTypeToString(t)); + } break; case 1: - DisplayTypeDropDown.Items.AddRange(WordWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray()); + foreach (DisplayType t in WordWatch.ValidTypes) + { + DisplayTypeDropDown.Items.Add(Watch.DisplayTypeToString(t)); + } break; case 2: - DisplayTypeDropDown.Items.AddRange(DWordWatch.ValidTypes.ConvertAll(e => Watch.DisplayTypeToString(e)).ToArray()); + foreach (DisplayType t in DWordWatch.ValidTypes) + { + DisplayTypeDropDown.Items.Add(Watch.DisplayTypeToString(t)); + } break; } @@ -209,7 +218,7 @@ namespace BizHawk.Client.EmuHawk var domain = MemoryDomains.FirstOrDefault(d => d.Name == DomainDropDown.SelectedItem.ToString()) ?? MemoryDomains.MainMemory; - BigEndianCheckBox.Checked = domain.EndianType == MemoryDomain.Endian.Big; + BigEndianCheckBox.Checked = domain.EndianType == Emu.MemoryDomain.Endian.Big; } #region Events @@ -236,13 +245,13 @@ namespace BizHawk.Client.EmuHawk switch (SizeDropDown.SelectedIndex) { case 0: - _watchList.Add(new ByteWatch(domain, address, type, bigendian, notes)); + _watchList.Add(Watch.GenerateWatch(domain, address, WatchSize.Byte, type, bigendian, notes)); break; case 1: - _watchList.Add(new WordWatch(domain, address, type, bigendian, notes)); + _watchList.Add(Watch.GenerateWatch(domain, address, WatchSize.Word, type, bigendian, notes)); break; case 2: - _watchList.Add(new DWordWatch(domain, address, type, bigendian, notes)); + _watchList.Add(Watch.GenerateWatch(domain, address, WatchSize.DWord, type, bigendian, notes)); break; } @@ -261,8 +270,8 @@ namespace BizHawk.Client.EmuHawk watch.Address ?? 0, watch.Size, watch.Type, - watch.Notes, - watch.BigEndian)); + watch.BigEndian, + watch.Notes)); } DoEdit(); @@ -283,17 +292,17 @@ namespace BizHawk.Client.EmuHawk { for (var i = 0; i < _watchList.Count; i++) { - var size = Watch.WatchSize.Byte; + var size = WatchSize.Byte; switch (SizeDropDown.SelectedIndex) { case 0: - size = Watch.WatchSize.Byte; + size = WatchSize.Byte; break; case 1: - size = Watch.WatchSize.Word; + size = WatchSize.Word; break; case 2: - size = Watch.WatchSize.DWord; + size = WatchSize.DWord; break; } @@ -301,10 +310,10 @@ namespace BizHawk.Client.EmuHawk _watchList[i].Domain, _watchList.Count == 1 ? AddressBox.ToRawInt() ?? 0 : _watchList[i].Address ?? 0, size, - _watchList[i].Type, - _watchList[i].Notes, - _watchList[i].BigEndian - ); + _watchList[i].Type, + _watchList[i].BigEndian, + _watchList[i].Notes + ); } } diff --git a/BizHawk.Client.EmuHawk/tools/Watch/WatchValueBox.cs b/BizHawk.Client.EmuHawk/tools/Watch/WatchValueBox.cs index 7adb703949..be4765ac65 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/WatchValueBox.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/WatchValueBox.cs @@ -5,13 +5,14 @@ using System.Windows.Forms; using BizHawk.Common.StringExtensions; using BizHawk.Common.NumberExtensions; using BizHawk.Client.Common; +using System.Linq; namespace BizHawk.Client.EmuHawk { public class WatchValueBox : TextBox, INumberBox { - private Watch.WatchSize _size = Watch.WatchSize.Byte; - private Watch.DisplayType _type = Watch.DisplayType.Hex; + private WatchSize _size = WatchSize.Byte; + private DisplayType _type = DisplayType.Hex; private bool _nullable = true; public WatchValueBox() @@ -21,7 +22,7 @@ namespace BizHawk.Client.EmuHawk public bool Nullable { get { return _nullable; } set { _nullable = value; } } - public Watch.WatchSize ByteSize + public WatchSize ByteSize { get { @@ -36,9 +37,26 @@ namespace BizHawk.Client.EmuHawk if (changed) { SetMaxLength(); - if (!Watch.AvailableTypes(value).Contains(_type)) + + bool isTypeCompatible = false; + switch (value) { - Type = Watch.AvailableTypes(value)[0]; + case WatchSize.Byte: + isTypeCompatible = ByteWatch.ValidTypes.Where(t => t == _type).Any(); + break; + + case WatchSize.Word: + isTypeCompatible = WordWatch.ValidTypes.Where(t => t == _type).Any(); + break; + + case WatchSize.DWord: + isTypeCompatible = DWordWatch.ValidTypes.Where(t => t == _type).Any(); + break; + } + + if (!isTypeCompatible) + { + _type = DisplayType.Unsigned; } ResetText(); @@ -46,7 +64,7 @@ namespace BizHawk.Client.EmuHawk } } - public Watch.DisplayType Type + public DisplayType Type { get { @@ -69,11 +87,11 @@ namespace BizHawk.Client.EmuHawk switch (ByteSize) { default: - case Watch.WatchSize.Byte: + case WatchSize.Byte: return byte.MaxValue; - case Watch.WatchSize.Word: + case WatchSize.Word: return ushort.MaxValue; - case Watch.WatchSize.DWord: + case WatchSize.DWord: return uint.MaxValue; } } @@ -86,11 +104,11 @@ namespace BizHawk.Client.EmuHawk switch (ByteSize) { default: - case Watch.WatchSize.Byte: + case WatchSize.Byte: return sbyte.MaxValue; - case Watch.WatchSize.Word: + case WatchSize.Word: return short.MaxValue; - case Watch.WatchSize.DWord: + case WatchSize.DWord: return int.MaxValue; } } @@ -103,11 +121,11 @@ namespace BizHawk.Client.EmuHawk switch (ByteSize) { default: - case Watch.WatchSize.Byte: + case WatchSize.Byte: return sbyte.MinValue; - case Watch.WatchSize.Word: + case WatchSize.Word: return short.MinValue; - case Watch.WatchSize.DWord: + case WatchSize.DWord: return int.MinValue; } } @@ -154,20 +172,20 @@ namespace BizHawk.Client.EmuHawk switch (Type) { default: - case Watch.DisplayType.Signed: - case Watch.DisplayType.Unsigned: + case DisplayType.Signed: + case DisplayType.Unsigned: Text = "0"; break; - case Watch.DisplayType.Hex: + case DisplayType.Hex: Text = 0.ToHexString(MaxLength); break; - case Watch.DisplayType.FixedPoint_12_4: - case Watch.DisplayType.FixedPoint_20_12: - case Watch.DisplayType.FixedPoint_16_16: - case Watch.DisplayType.Float: + case DisplayType.FixedPoint_12_4: + case DisplayType.FixedPoint_20_12: + case DisplayType.FixedPoint_16_16: + case DisplayType.Float: Text = "0.0"; break; - case Watch.DisplayType.Binary: + case DisplayType.Binary: Text = "0".PadLeft(((int)_size) * 8); break; } @@ -181,75 +199,75 @@ namespace BizHawk.Client.EmuHawk default: MaxLength = 8; break; - case Watch.DisplayType.Binary: + case DisplayType.Binary: switch (_size) { default: - case Watch.WatchSize.Byte: + case WatchSize.Byte: MaxLength = 8; break; - case Watch.WatchSize.Word: + case WatchSize.Word: MaxLength = 16; break; } break; - case Watch.DisplayType.Hex: + case DisplayType.Hex: switch (_size) { default: - case Watch.WatchSize.Byte: + case WatchSize.Byte: MaxLength = 2; break; - case Watch.WatchSize.Word: + case WatchSize.Word: MaxLength = 4; break; - case Watch.WatchSize.DWord: + case WatchSize.DWord: MaxLength = 8; break; } break; - case Watch.DisplayType.Signed: + case DisplayType.Signed: switch (_size) { default: - case Watch.WatchSize.Byte: + case WatchSize.Byte: MaxLength = 4; break; - case Watch.WatchSize.Word: + case WatchSize.Word: MaxLength = 6; break; - case Watch.WatchSize.DWord: + case WatchSize.DWord: MaxLength = 11; break; } break; - case Watch.DisplayType.Unsigned: + case DisplayType.Unsigned: switch (_size) { default: - case Watch.WatchSize.Byte: + case WatchSize.Byte: MaxLength = 3; break; - case Watch.WatchSize.Word: + case WatchSize.Word: MaxLength = 5; break; - case Watch.WatchSize.DWord: + case WatchSize.DWord: MaxLength = 10; break; } break; - case Watch.DisplayType.FixedPoint_12_4: + case DisplayType.FixedPoint_12_4: MaxLength = 9; break; - case Watch.DisplayType.Float: + case DisplayType.Float: MaxLength = 21; break; - case Watch.DisplayType.FixedPoint_20_12: - case Watch.DisplayType.FixedPoint_16_16: + case DisplayType.FixedPoint_20_12: + case DisplayType.FixedPoint_16_16: MaxLength = 64; break; } @@ -282,44 +300,44 @@ namespace BizHawk.Client.EmuHawk switch (_type) { default: - case Watch.DisplayType.Binary: + case DisplayType.Binary: if (!e.KeyChar.IsBinary()) { e.Handled = true; } break; - case Watch.DisplayType.FixedPoint_12_4: - case Watch.DisplayType.FixedPoint_20_12: - case Watch.DisplayType.FixedPoint_16_16: + case DisplayType.FixedPoint_12_4: + case DisplayType.FixedPoint_20_12: + case DisplayType.FixedPoint_16_16: if (!e.KeyChar.IsFixedPoint()) { e.Handled = true; } break; - case Watch.DisplayType.Float: + case DisplayType.Float: if (!e.KeyChar.IsFloat()) { e.Handled = true; } break; - case Watch.DisplayType.Hex: + case DisplayType.Hex: if (!e.KeyChar.IsHex()) { e.Handled = true; } break; - case Watch.DisplayType.Signed: + case DisplayType.Signed: if (!e.KeyChar.IsSigned()) { e.Handled = true; } break; - case Watch.DisplayType.Unsigned: + case DisplayType.Unsigned: if (!e.KeyChar.IsUnsigned()) { e.Handled = true; @@ -337,7 +355,7 @@ namespace BizHawk.Client.EmuHawk switch (_type) { default: - case Watch.DisplayType.Signed: + case DisplayType.Signed: int? val = ToRawInt() ?? 0; if (val == MaxSignedInt) { @@ -350,7 +368,7 @@ namespace BizHawk.Client.EmuHawk Text = val.ToString(); break; - case Watch.DisplayType.Unsigned: + case DisplayType.Unsigned: var uval = (uint)(ToRawInt() ?? 0); if (uval == MaxUnsignedInt) { @@ -363,7 +381,7 @@ namespace BizHawk.Client.EmuHawk Text = uval.ToString(); break; - case Watch.DisplayType.Binary: + case DisplayType.Binary: var bval = (uint)(ToRawInt() ?? 0); if (bval == MaxUnsignedInt) { @@ -377,7 +395,7 @@ namespace BizHawk.Client.EmuHawk var numBits = ((int)ByteSize) * 8; Text = Convert.ToString(bval, 2).PadLeft(numBits, '0'); break; - case Watch.DisplayType.Hex: + case DisplayType.Hex: var hexVal = (uint)(ToRawInt() ?? 0); if (hexVal == MaxUnsignedInt) { @@ -390,7 +408,7 @@ namespace BizHawk.Client.EmuHawk Text = hexVal.ToHexString(MaxLength); break; - case Watch.DisplayType.FixedPoint_12_4: + case DisplayType.FixedPoint_12_4: var f12val = double.Parse(text); if (f12val > Max12_4 - _12_4_Unit) { @@ -403,7 +421,7 @@ namespace BizHawk.Client.EmuHawk Text = f12val.ToString(); break; - case Watch.DisplayType.FixedPoint_20_12: + case DisplayType.FixedPoint_20_12: var f24val = double.Parse(text); if (f24val >= Max20_12 - _20_12_Unit) { @@ -416,7 +434,7 @@ namespace BizHawk.Client.EmuHawk Text = f24val.ToString(); break; - case Watch.DisplayType.FixedPoint_16_16: + case DisplayType.FixedPoint_16_16: var f16val = double.Parse(text); if (f16val >= Max16_16 - _16_16_Unit) { @@ -429,7 +447,7 @@ namespace BizHawk.Client.EmuHawk Text = f16val.ToString(); break; - case Watch.DisplayType.Float: + case DisplayType.Float: var dval = double.Parse(text); if (dval > double.MaxValue - 1) { @@ -449,7 +467,7 @@ namespace BizHawk.Client.EmuHawk switch (_type) { default: - case Watch.DisplayType.Signed: + case DisplayType.Signed: var val = ToRawInt(); if (!val.HasValue) { @@ -466,7 +484,7 @@ namespace BizHawk.Client.EmuHawk Text = val.ToString(); break; - case Watch.DisplayType.Unsigned: + case DisplayType.Unsigned: var uval = (uint)(ToRawInt() ?? 0); if (uval == 0) { @@ -479,7 +497,7 @@ namespace BizHawk.Client.EmuHawk Text = uval.ToString(); break; - case Watch.DisplayType.Binary: + case DisplayType.Binary: var bval = (uint)(ToRawInt() ?? 0); if (bval == 0) { @@ -493,7 +511,7 @@ namespace BizHawk.Client.EmuHawk var numBits = ((int)ByteSize) * 8; Text = Convert.ToString(bval, 2).PadLeft(numBits, '0'); break; - case Watch.DisplayType.Hex: + case DisplayType.Hex: var hexVal = (uint)(ToRawInt() ?? 0); if (hexVal == 0) { @@ -506,7 +524,7 @@ namespace BizHawk.Client.EmuHawk Text = hexVal.ToHexString(MaxLength); break; - case Watch.DisplayType.FixedPoint_12_4: + case DisplayType.FixedPoint_12_4: var f12val = double.Parse(text); if (f12val < 0 + _12_4_Unit) { @@ -519,7 +537,7 @@ namespace BizHawk.Client.EmuHawk Text = f12val.ToString(); break; - case Watch.DisplayType.FixedPoint_20_12: + case DisplayType.FixedPoint_20_12: var f24val = double.Parse(text); if (f24val < 0 + _20_12_Unit) { @@ -532,7 +550,7 @@ namespace BizHawk.Client.EmuHawk Text = f24val.ToString(); break; - case Watch.DisplayType.FixedPoint_16_16: + case DisplayType.FixedPoint_16_16: var f16val = double.Parse(text); if (f16val < 0 + _16_16_Unit) { @@ -545,7 +563,7 @@ namespace BizHawk.Client.EmuHawk Text = f16val.ToString(); break; - case Watch.DisplayType.Float: + case DisplayType.Float: var dval = double.Parse(text); if (dval > double.MaxValue - 1) { @@ -575,24 +593,24 @@ namespace BizHawk.Client.EmuHawk switch (_type) { - case Watch.DisplayType.Signed: + case DisplayType.Signed: Text = Text.OnlySigned(); break; - case Watch.DisplayType.Unsigned: + case DisplayType.Unsigned: Text = Text.OnlyUnsigned(); break; - case Watch.DisplayType.Binary: + case DisplayType.Binary: Text = Text.OnlyBinary(); break; - case Watch.DisplayType.Hex: + case DisplayType.Hex: Text = Text.OnlyHex(); break; - case Watch.DisplayType.FixedPoint_12_4: - case Watch.DisplayType.FixedPoint_20_12: - case Watch.DisplayType.FixedPoint_16_16: + case DisplayType.FixedPoint_12_4: + case DisplayType.FixedPoint_20_12: + case DisplayType.FixedPoint_16_16: Text = Text.OnlyFixedPoint(); break; - case Watch.DisplayType.Float: + case DisplayType.Float: Text = Text.OnlyFloat(); break; } @@ -614,7 +632,7 @@ namespace BizHawk.Client.EmuHawk switch (_type) { - case Watch.DisplayType.Signed: + case DisplayType.Signed: if (Text.IsSigned()) { if (Text == "-") @@ -623,49 +641,49 @@ namespace BizHawk.Client.EmuHawk } break; - case Watch.DisplayType.Unsigned: + case DisplayType.Unsigned: if (Text.IsUnsigned()) { return (int)uint.Parse(Text); } break; - case Watch.DisplayType.Binary: + case DisplayType.Binary: if (Text.IsBinary()) { return Convert.ToInt32(Text, 2); } break; - case Watch.DisplayType.Hex: + case DisplayType.Hex: if (Text.IsHex()) { return int.Parse(Text, NumberStyles.HexNumber); } break; - case Watch.DisplayType.FixedPoint_12_4: + case DisplayType.FixedPoint_12_4: if (Text.IsFixedPoint()) { return (int)(double.Parse(Text) * 16.0); } break; - case Watch.DisplayType.FixedPoint_20_12: + case DisplayType.FixedPoint_20_12: if (Text.IsFixedPoint()) { return (int)(double.Parse(Text) * 4096.0); } break; - case Watch.DisplayType.FixedPoint_16_16: + case DisplayType.FixedPoint_16_16: if (Text.IsFixedPoint()) { return (int)(double.Parse(Text) * 65536.0); } break; - case Watch.DisplayType.Float: + case DisplayType.Float: if (Text.IsFloat()) { float val = float.Parse(Text); @@ -686,31 +704,31 @@ namespace BizHawk.Client.EmuHawk switch (_type) { default: - case Watch.DisplayType.Signed: + case DisplayType.Signed: Text = val.ToString(); break; - case Watch.DisplayType.Unsigned: + case DisplayType.Unsigned: var uval = (uint)val.Value; Text = uval.ToString(); break; - case Watch.DisplayType.Binary: + case DisplayType.Binary: var bval = (uint)val.Value; var numBits = ((int)ByteSize) * 8; Text = Convert.ToString(bval, 2).PadLeft(numBits, '0'); break; - case Watch.DisplayType.Hex: + case DisplayType.Hex: Text = val.Value.ToHexString(MaxLength); break; - case Watch.DisplayType.FixedPoint_12_4: + case DisplayType.FixedPoint_12_4: Text = string.Format("{0:F5}", val.Value / 16.0); break; - case Watch.DisplayType.FixedPoint_20_12: + case DisplayType.FixedPoint_20_12: Text = string.Format("{0:F5}", val.Value / 4096.0); break; - case Watch.DisplayType.FixedPoint_16_16: + case DisplayType.FixedPoint_16_16: Text = string.Format("{0:F5}", val.Value / 65536.0); break; - case Watch.DisplayType.Float: + case DisplayType.Float: var bytes = BitConverter.GetBytes(val.Value); float _float = BitConverter.ToSingle(bytes, 0); Text = string.Format("{0:F6}", _float); diff --git a/BizHawk.Client.MultiHawk/DisplayManager/DisplayManager.cs b/BizHawk.Client.MultiHawk/DisplayManager/DisplayManager.cs index add6a9f198..ee324ea301 100644 --- a/BizHawk.Client.MultiHawk/DisplayManager/DisplayManager.cs +++ b/BizHawk.Client.MultiHawk/DisplayManager/DisplayManager.cs @@ -374,8 +374,7 @@ namespace BizHawk.Client.MultiHawk } int[] videoBuffer = videoProvider.GetVideoBuffer(); - -TESTEROO: + int bufferWidth = videoProvider.BufferWidth; int bufferHeight = videoProvider.BufferHeight; bool isGlTextureId = videoBuffer.Length == 1; diff --git a/BizHawk.Client.MultiHawk/movie/PlayMovie.Designer.cs b/BizHawk.Client.MultiHawk/movie/PlayMovie.Designer.cs index c877975b72..11e7316376 100644 --- a/BizHawk.Client.MultiHawk/movie/PlayMovie.Designer.cs +++ b/BizHawk.Client.MultiHawk/movie/PlayMovie.Designer.cs @@ -251,7 +251,7 @@ // StopOnFrameTextBox // this.StopOnFrameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.StopOnFrameTextBox.ByteSize = BizHawk.Client.Common.Watch.WatchSize.DWord; + this.StopOnFrameTextBox.ByteSize = BizHawk.Client.Common.WatchSize.DWord; this.StopOnFrameTextBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; this.StopOnFrameTextBox.Location = new System.Drawing.Point(438, 355); this.StopOnFrameTextBox.MaxLength = 10; @@ -259,7 +259,7 @@ this.StopOnFrameTextBox.Nullable = true; this.StopOnFrameTextBox.Size = new System.Drawing.Size(54, 20); this.StopOnFrameTextBox.TabIndex = 58; - this.StopOnFrameTextBox.Type = BizHawk.Client.Common.Watch.DisplayType.Unsigned; + this.StopOnFrameTextBox.Type = BizHawk.Client.Common.DisplayType.Unsigned; this.StopOnFrameTextBox.TextChanged += new System.EventHandler(this.StopOnFrameTextBox_TextChanged_1); // // MovieView diff --git a/BizHawk.sln b/BizHawk.sln index b7d95323c1..a8337f67e5 100644 --- a/BizHawk.sln +++ b/BizHawk.sln @@ -252,8 +252,8 @@ Global {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|Win32.ActiveCfg = Debug|Any CPU {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|Win32.Build.0 = Debug|Any CPU - {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|x86.ActiveCfg = Debug|Any CPU - {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|x86.Build.0 = Debug|Any CPU + {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|x86.ActiveCfg = Debug|x86 + {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Debug|x86.Build.0 = Debug|x86 {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|Any CPU.ActiveCfg = Release|Any CPU {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|Any CPU.Build.0 = Release|Any CPU {8E2F11F2-3955-4382-8C3A-CEBA1276CAEA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU