From 3a36835af2e05e549295ba0a33e8ea8944469d96 Mon Sep 17 00:00:00 2001 From: adelikat Date: Wed, 5 Oct 2016 20:58:26 -0500 Subject: [PATCH] Ram Search - with the Diff column displayed, don't throw exceptions, Fixes #637. The Diff column still has issues with 4 byte watches though, but this fixes unending exceptions at least --- BizHawk.Client.Common/tools/Watch/ByteWatch.cs | 4 ++-- BizHawk.Client.Common/tools/Watch/WordWatch.cs | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/BizHawk.Client.Common/tools/Watch/ByteWatch.cs b/BizHawk.Client.Common/tools/Watch/ByteWatch.cs index f5ecd6204b..24bd2f79f8 100644 --- a/BizHawk.Client.Common/tools/Watch/ByteWatch.cs +++ b/BizHawk.Client.Common/tools/Watch/ByteWatch.cs @@ -232,7 +232,7 @@ namespace BizHawk.Client.Common get { string diff = string.Empty; - byte diffVal = Convert.ToByte(_value - _previous); + int diffVal = _value - _previous; if (diffVal > 0) { diff = "+"; @@ -242,7 +242,7 @@ namespace BizHawk.Client.Common diff = "-"; } - return string.Format("{0}{1}", diff, FormatValue(diffVal)); + return string.Format("{0}{1}", diff, FormatValue((byte)Math.Abs(diffVal))); } } diff --git a/BizHawk.Client.Common/tools/Watch/WordWatch.cs b/BizHawk.Client.Common/tools/Watch/WordWatch.cs index b8e1268ce3..8d8e06f8f9 100644 --- a/BizHawk.Client.Common/tools/Watch/WordWatch.cs +++ b/BizHawk.Client.Common/tools/Watch/WordWatch.cs @@ -245,7 +245,18 @@ namespace BizHawk.Client.Common { get { - return FormatValue((ushort)(_previous - _value)); + string diff = string.Empty; + int diffVal = _value - _previous; + if (diffVal > 0) + { + diff = "+"; + } + else if (diffVal < 0) + { + diff = "-"; + } + + return string.Format("{0}{1}", diff, FormatValue((ushort)Math.Abs(diffVal))); } }