diff --git a/BizHawk.Client.Common/tools/Cheat.cs b/BizHawk.Client.Common/tools/Cheat.cs index 9fca21efdb..08ffc3ea38 100644 --- a/BizHawk.Client.Common/tools/Cheat.cs +++ b/BizHawk.Client.Common/tools/Cheat.cs @@ -297,6 +297,11 @@ namespace BizHawk.Client.Common if (!IsSeparator) { _val++; + if (_val > _watch.MaxValue) + { + _val = 0; + } + Pulse(); Changes(); } @@ -307,6 +312,11 @@ namespace BizHawk.Client.Common if (!IsSeparator) { _val--; + if ((uint)_val > _watch.MaxValue) + { + _val = (int)_watch.MaxValue; + } + Pulse(); Changes(); } diff --git a/BizHawk.Client.Common/tools/Watch.cs b/BizHawk.Client.Common/tools/Watch.cs index 37ecb0341d..a7c87c9c3d 100644 --- a/BizHawk.Client.Common/tools/Watch.cs +++ b/BizHawk.Client.Common/tools/Watch.cs @@ -52,6 +52,8 @@ namespace BizHawk.Client.Common public abstract string ValueString { get; } public abstract WatchSize Size { get; } + public abstract uint MaxValue { get; } + public abstract int? Previous { get; } public abstract string PreviousStr { get; } public abstract void ResetPrevious(); @@ -400,6 +402,11 @@ namespace BizHawk.Client.Common public override string Diff { get { return string.Empty; } } + public override uint MaxValue + { + get { return 0; } + } + public override void Update() { return; } } @@ -488,6 +495,11 @@ namespace BizHawk.Client.Common } } + public override uint MaxValue + { + get { return byte.MaxValue; } + } + public string FormatValue(byte val) { switch (Type) @@ -645,6 +657,11 @@ namespace BizHawk.Client.Common _changecount = changeCount; } + public override uint MaxValue + { + get { return ushort.MaxValue; } + } + public override int? Value { get { return GetWord(); } @@ -886,6 +903,11 @@ namespace BizHawk.Client.Common } } + public override uint MaxValue + { + get { return uint.MaxValue; } + } + public override string ValueString { get { return FormatValue(GetDWord()); }