Skip to content

Commit d34f8a3

Browse files
committed
Widen Watch.Value and related props in RAM Search to ulong/long
1 parent e4468f8 commit d34f8a3

File tree

10 files changed

+134
-94
lines changed

10 files changed

+134
-94
lines changed

src/BizHawk.Client.Common/tools/Cheat.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,17 @@ public enum CompareType
1717

1818
private readonly Watch _watch;
1919
private int? _compare;
20-
private int _val;
20+
21+
private long _val;
22+
2123
private bool _enabled;
2224

23-
public Cheat(Watch watch, int value, int? compare = null, bool enabled = true, CompareType comparisonType = CompareType.None)
25+
public Cheat(
26+
Watch watch,
27+
long value,
28+
int? compare = null,
29+
bool enabled = true,
30+
CompareType comparisonType = CompareType.None)
2431
{
2532
_enabled = enabled;
2633
_watch = watch;
@@ -67,7 +74,8 @@ public Cheat(Cheat cheat)
6774

6875
public long? Address => _watch.Address;
6976

70-
public int? Value => IsSeparator ? null : _val;
77+
public long? Value
78+
=> IsSeparator ? null : _val;
7179

7280
public bool? BigEndian => IsSeparator ? null : _watch.BigEndian;
7381

@@ -232,7 +240,7 @@ public bool Contains(long addr)
232240
}
233241
}
234242

235-
public void PokeValue(int val)
243+
public void PokeValue(long val)
236244
{
237245
if (!IsSeparator)
238246
{
@@ -245,7 +253,7 @@ public void Increment()
245253
if (!IsSeparator)
246254
{
247255
_val++;
248-
if (_val > _watch.MaxValue)
256+
if (unchecked((ulong) _val) > _watch.MaxValue)
249257
{
250258
_val = 0;
251259
}
@@ -260,10 +268,7 @@ public void Decrement()
260268
if (!IsSeparator)
261269
{
262270
_val--;
263-
if ((uint)_val > _watch.MaxValue)
264-
{
265-
_val = (int)_watch.MaxValue;
266-
}
271+
if (unchecked((ulong) _val) > _watch.MaxValue) _val = unchecked((long) _watch.MaxValue);
267272

268273
Pulse();
269274
Changes();

src/BizHawk.Client.Common/tools/RamSearchEngine/IMiniWatch.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ namespace BizHawk.Client.Common.RamSearchEngine
99
internal interface IMiniWatch
1010
{
1111
long Address { get; }
12-
uint Previous { get; }
1312

14-
uint GetValue(MemoryDomain domain, bool bigEndian);
13+
ulong Previous { get; }
14+
15+
ulong GetValue(MemoryDomain domain, bool bigEndian);
1516

1617
void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian);
1718
bool IsValid(MemoryDomain domain);
@@ -21,18 +22,18 @@ internal abstract class MiniWatchBase : IMiniWatch
2122
{
2223
public long Address { get; }
2324

24-
public uint Previous { get; protected set; }
25+
public ulong Previous { get; protected set; }
2526

26-
protected MiniWatchBase(long addr, uint prevValue)
27+
protected MiniWatchBase(long addr, ulong prevValue)
2728
{
2829
Address = addr;
2930
Previous = prevValue;
3031
}
3132

32-
public uint GetValue(MemoryDomain domain, bool bigEndian)
33+
public ulong GetValue(MemoryDomain domain, bool bigEndian)
3334
=> IsValid(domain) ? GetValueInner(Address, domain, bigEndian: bigEndian) : default;
3435

35-
protected abstract uint GetValueInner(long address, MemoryDomain domain, bool bigEndian);
36+
protected abstract ulong GetValueInner(long address, MemoryDomain domain, bool bigEndian);
3637

3738
public bool IsValid(MemoryDomain domain)
3839
=> IsValid(Address, domain);
@@ -48,7 +49,7 @@ internal class MiniByteWatch : MiniWatchBase
4849
public MiniByteWatch(MemoryDomain domain, long addr)
4950
: base(addr: addr, prevValue: domain.PeekByte(addr)) {}
5051

51-
protected override uint GetValueInner(long address, MemoryDomain domain, bool bigEndian)
52+
protected override ulong GetValueInner(long address, MemoryDomain domain, bool bigEndian)
5253
=> domain.PeekByte(address);
5354

5455
protected override bool IsValid(long address, MemoryDomain domain)
@@ -60,7 +61,7 @@ internal class MiniWordWatch : MiniWatchBase
6061
public MiniWordWatch(MemoryDomain domain, long addr, bool bigEndian)
6162
: base(addr: addr, prevValue: domain.PeekUshort(addr, bigEndian: bigEndian)) {}
6263

63-
protected override uint GetValueInner(long address, MemoryDomain domain, bool bigEndian)
64+
protected override ulong GetValueInner(long address, MemoryDomain domain, bool bigEndian)
6465
=> domain.PeekUshort(address, bigEndian);
6566

6667
protected override bool IsValid(long address, MemoryDomain domain)
@@ -72,7 +73,7 @@ internal class MiniDWordWatch : MiniWatchBase
7273
public MiniDWordWatch(MemoryDomain domain, long addr, bool bigEndian)
7374
: base(addr: addr, prevValue: domain.PeekUint(addr, bigEndian: bigEndian)) {}
7475

75-
protected override uint GetValueInner(long address, MemoryDomain domain, bool bigEndian)
76+
protected override ulong GetValueInner(long address, MemoryDomain domain, bool bigEndian)
7677
=> domain.PeekUint(address, bigEndian);
7778

7879
protected override bool IsValid(long address, MemoryDomain domain)

src/BizHawk.Client.Common/tools/RamSearchEngine/IMiniWatchDetails.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ namespace BizHawk.Client.Common.RamSearchEngine
99
/// </summary>
1010
internal interface IMiniWatchDetails : IMiniWatch
1111
{
12-
uint Current { get; }
12+
ulong Current { get; }
13+
1314
int ChangeCount { get; }
1415
void ClearChangeCount();
1516
void Update(PreviousType type, MemoryDomain domain, bool bigEndian);
@@ -25,7 +26,7 @@ public MiniByteWatchDetailed(MemoryDomain domain, long addr) : base(domain, addr
2526
public override void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
2627
=> Previous = _current;
2728

28-
public uint Current => _current;
29+
public ulong Current => _current;
2930

3031
public int ChangeCount { get; private set; }
3132

@@ -62,7 +63,7 @@ public MiniWordWatchDetailed(MemoryDomain domain, long addr, bool bigEndian) : b
6263
public override void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
6364
=> Previous = _current;
6465

65-
public uint Current => _current;
66+
public ulong Current => _current;
6667

6768
public int ChangeCount { get; private set; }
6869

@@ -94,18 +95,18 @@ internal sealed class MiniDWordWatchDetailed : MiniDWordWatch, IMiniWatchDetails
9495
private uint _current;
9596

9697
public MiniDWordWatchDetailed(MemoryDomain domain, long addr, bool bigEndian) : base(domain, addr, bigEndian)
97-
=> Previous = _current = GetValueInner(Address, domain, bigEndian: bigEndian);
98+
=> Previous = _current = unchecked((uint) GetValueInner(Address, domain, bigEndian: bigEndian));
9899

99100
public override void SetPreviousToCurrent(MemoryDomain domain, bool bigEndian)
100101
=> Previous = _current;
101102

102-
public uint Current => _current;
103+
public ulong Current => _current;
103104

104105
public int ChangeCount { get; private set; }
105106

106107
public void Update(PreviousType type, MemoryDomain domain, bool bigEndian)
107108
{
108-
var newValue = GetValueInner(Address, domain, bigEndian: bigEndian);
109+
var newValue = unchecked((uint) GetValueInner(Address, domain, bigEndian: bigEndian));
109110
if (newValue != _current)
110111
{
111112
ChangeCount++;

0 commit comments

Comments
 (0)