Convert a whole bunch of ram stuff from int to long

This commit is contained in:
adelikat 2015-01-18 18:59:23 +00:00
parent 89b3c31872
commit 515a41592c
10 changed files with 67 additions and 62 deletions

View File

@ -62,7 +62,7 @@ namespace BizHawk.Client.Common
get { return !IsSeparator && _enabled; }
}
public int? Address
public long? Address
{
get { return _watch.Address; }
}
@ -237,7 +237,7 @@ namespace BizHawk.Client.Common
}
}
public bool Contains(int addr)
public bool Contains(long addr)
{
switch (_watch.Size)
{
@ -254,7 +254,7 @@ namespace BizHawk.Client.Common
}
}
public byte? GetByteVal(int addr)
public byte? GetByteVal(long addr)
{
if (!Contains(addr))
{
@ -366,7 +366,7 @@ namespace BizHawk.Client.Common
public override int GetHashCode()
{
return this.Domain.GetHashCode() + this.Address ?? 0;
return this.Domain.GetHashCode() + (int)(this.Address ?? 0);
}
public static bool operator ==(Cheat a, Cheat b)

View File

@ -64,7 +64,7 @@ namespace BizHawk.Client.Common
get { return _cheatList[index]; }
}
public Cheat this[MemoryDomain domain, int address]
public Cheat this[MemoryDomain domain, long address]
{
get
{
@ -194,7 +194,7 @@ namespace BizHawk.Client.Common
return _cheatList.Any(c => c == cheat);
}
public bool Contains(MemoryDomain domain, int address)
public bool Contains(MemoryDomain domain, long address)
{
return _cheatList.Any(c => c.Domain == domain && c.Address == address);
}
@ -249,7 +249,7 @@ namespace BizHawk.Client.Common
Changes = true;
}
public bool IsActive(MemoryDomain domain, int address)
public bool IsActive(MemoryDomain domain, long address)
{
return _cheatList.Any(cheat =>
!cheat.IsSeparator &&
@ -263,7 +263,7 @@ namespace BizHawk.Client.Common
/// But if the cheat is multi-byte, this will return just the cheat value for that specific byte
/// </summary>
/// <returns>Returns null if address is not a part of a cheat, else returns the value of that specific byte only</returns>
public byte? GetByteValue(MemoryDomain domain, int addr)
public byte? GetByteValue(MemoryDomain domain, long addr)
{
var activeCheat = _cheatList.FirstOrDefault(cheat => cheat.Contains(addr));
if (activeCheat == (Cheat)null)
@ -281,7 +281,7 @@ namespace BizHawk.Client.Common
/// <param name="addr">The starting address for which you will get the number of bytes
/// <param name="size">The number of bytes of the cheat to return</param>
/// <returns>The value, or null if it can't resolve the address with a given cheat</returns>
public int? GetCheatValue(MemoryDomain domain, int addr, Watch.WatchSize size)
public int? GetCheatValue(MemoryDomain domain, long addr, Watch.WatchSize size)
{
var activeCheat = _cheatList.FirstOrDefault(cheat => cheat.Contains(addr));
if (activeCheat == (Cheat)null)

View File

@ -48,7 +48,7 @@ namespace BizHawk.Client.Common
#region API
public IEnumerable<int> OutOfRangeAddress
public IEnumerable<long> OutOfRangeAddress
{
get
{
@ -198,7 +198,7 @@ namespace BizHawk.Client.Common
return before - _watchList.Count;
}
public bool Preview(int address)
public bool Preview(long address)
{
IEnumerable<IMiniWatch> listOfOne;
@ -356,11 +356,11 @@ namespace BizHawk.Client.Common
_history.AddState(_watchList);
}
var removeList = indices.Select(i => _watchList[i]);
var removeList = indices.Select(i => _watchList[i]); // This will fail after int.MaxValue but Ram Search fails on domains that large anyway
_watchList = _watchList.Except(removeList).ToList();
}
public void AddRange(List<int> addresses, bool append)
public void AddRange(List<long> addresses, bool append)
{
if (!append)
{
@ -874,7 +874,7 @@ namespace BizHawk.Client.Common
}
}
private long GetValue(int addr)
private long GetValue(long addr)
{
//do not return sign extended variables from here.
switch (_settings.Size)
@ -912,7 +912,7 @@ namespace BizHawk.Client.Common
public interface IMiniWatch
{
int Address { get; }
long Address { get; }
long Previous { get; } //do not store sign extended variables in here.
void SetPreviousToCurrent(MemoryDomain domain, bool bigendian);
}
@ -927,10 +927,10 @@ namespace BizHawk.Client.Common
private sealed class MiniByteWatch : IMiniWatch
{
public int Address { get; private set; }
public long Address { get; private set; }
private byte _previous;
public MiniByteWatch(MemoryDomain domain, int addr)
public MiniByteWatch(MemoryDomain domain, long addr)
{
Address = addr;
_previous = domain.PeekByte(Address % domain.Size);
@ -949,10 +949,10 @@ namespace BizHawk.Client.Common
private sealed class MiniWordWatch : IMiniWatch
{
public int Address { get; private set; }
public long Address { get; private set; }
private ushort _previous;
public MiniWordWatch(MemoryDomain domain, int addr, bool bigEndian)
public MiniWordWatch(MemoryDomain domain, long addr, bool bigEndian)
{
Address = addr;
_previous = domain.PeekWord(Address % domain.Size, bigEndian);
@ -971,10 +971,10 @@ namespace BizHawk.Client.Common
public sealed class MiniDWordWatch : IMiniWatch
{
public int Address { get; private set; }
public long Address { get; private set; }
private uint _previous;
public MiniDWordWatch(MemoryDomain domain, int addr, bool bigEndian)
public MiniDWordWatch(MemoryDomain domain, long addr, bool bigEndian)
{
Address = addr;
_previous = domain.PeekDWord(Address % domain.Size, bigEndian);
@ -993,13 +993,13 @@ namespace BizHawk.Client.Common
private sealed class MiniByteWatchDetailed : IMiniWatch, IMiniWatchDetails
{
public int Address { get; private set; }
public long Address { get; private set; }
private byte _previous;
private byte _prevFrame;
private int _changecount;
public MiniByteWatchDetailed(MemoryDomain domain, int addr)
public MiniByteWatchDetailed(MemoryDomain domain, long addr)
{
Address = addr;
SetPreviousToCurrent(domain, false);
@ -1054,13 +1054,13 @@ namespace BizHawk.Client.Common
private sealed class MiniWordWatchDetailed : IMiniWatch, IMiniWatchDetails
{
public int Address { get; private set; }
public long Address { get; private set; }
private ushort _previous;
private ushort _prevFrame;
private int _changecount;
public MiniWordWatchDetailed(MemoryDomain domain, int addr, bool bigEndian)
public MiniWordWatchDetailed(MemoryDomain domain, long addr, bool bigEndian)
{
Address = addr;
SetPreviousToCurrent(domain, bigEndian);
@ -1114,13 +1114,13 @@ namespace BizHawk.Client.Common
public sealed class MiniDWordWatchDetailed : IMiniWatch, IMiniWatchDetails
{
public int Address { get; private set; }
public long Address { get; private set; }
private uint _previous;
private uint _prevFrame;
private int _changecount;
public MiniDWordWatchDetailed(MemoryDomain domain, int addr, bool bigEndian)
public MiniDWordWatchDetailed(MemoryDomain domain, long addr, bool bigEndian)
{
Address = addr;
SetPreviousToCurrent(domain, bigEndian);

View File

@ -42,7 +42,7 @@ namespace BizHawk.Client.Common
}
}
protected int _address;
protected long _address;
protected MemoryDomain _domain;
protected DisplayType _type;
protected bool _bigEndian;
@ -68,7 +68,7 @@ namespace BizHawk.Client.Common
public string DomainName { get { return _domain != null ? _domain.Name : string.Empty; } }
public virtual int? Address { get { return _address; } }
public virtual long? Address { get { return _address; } }
public virtual string AddressString { get { return _address.ToString(AddressFormatStr); } }
@ -213,7 +213,7 @@ namespace BizHawk.Client.Common
protected uint GetDWord()
{
if (Global.CheatList.IsActive(_domain, _address))
if (Global.CheatList.IsActive(_domain, (int)_address))
{
return (uint)Global.CheatList.GetCheatValue(_domain, _address, WatchSize.DWord).Value;
}
@ -263,7 +263,7 @@ namespace BizHawk.Client.Common
public string Notes { get { return _notes; } set { _notes = value; } }
public static Watch GenerateWatch(MemoryDomain domain, int address, WatchSize size, DisplayType type, string notes, bool bigEndian)
public static Watch GenerateWatch(MemoryDomain domain, long address, WatchSize size, DisplayType type, string notes, bool bigEndian)
{
switch (size)
{
@ -279,7 +279,7 @@ namespace BizHawk.Client.Common
}
}
public static Watch GenerateWatch(MemoryDomain domain, int 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, long prev, int changecount)
{
switch (size)
{
@ -341,7 +341,7 @@ namespace BizHawk.Client.Common
public override int GetHashCode()
{
return this.Domain.GetHashCode() + this.Address ?? 0;
return this.Domain.GetHashCode() + (int)(this.Address ?? 0);
}
public static bool operator ==(Watch a, Watch b)
@ -384,7 +384,7 @@ namespace BizHawk.Client.Common
get { return new SeparatorWatch(); }
}
public override int? Address
public override long? Address
{
get { return null; }
}
@ -464,7 +464,7 @@ namespace BizHawk.Client.Common
private byte _previous;
private byte _value;
public ByteWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, string notes)
public ByteWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, string notes)
{
_address = address;
_domain = domain;
@ -481,14 +481,14 @@ namespace BizHawk.Client.Common
}
}
public ByteWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, byte prev, int changeCount, string notes = null)
public ByteWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, byte prev, int changeCount, string notes = null)
: this(domain, address, type, bigEndian, notes)
{
_previous = prev;
_changecount = changeCount;
}
public override int? Address
public override long? Address
{
get { return _address; }
}
@ -692,7 +692,7 @@ namespace BizHawk.Client.Common
private ushort _previous;
private ushort _value;
public WordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, string notes)
public WordWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, string notes)
{
_domain = domain;
_address = address;
@ -711,7 +711,7 @@ namespace BizHawk.Client.Common
}
}
public WordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, ushort prev, int changeCount, string notes = null)
public WordWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, ushort prev, int changeCount, string notes = null)
: this(domain, address, type, bigEndian, notes)
{
_previous = prev;
@ -911,7 +911,7 @@ namespace BizHawk.Client.Common
private uint _value;
private uint _previous;
public DWordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, string notes)
public DWordWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, string notes)
{
_domain = domain;
_address = address;
@ -930,7 +930,7 @@ namespace BizHawk.Client.Common
}
}
public DWordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, uint prev, int changeCount, string notes = null)
public DWordWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, uint prev, int changeCount, string notes = null)
: this(domain, address, type, bigEndian, notes)
{
_previous = prev;

View File

@ -713,11 +713,11 @@ namespace BizHawk.Client.EmuHawk
if (selected.Select(x => x.Domain).Distinct().Count() > 1)
{
ToolHelpers.ViewInHexEditor(selected[0].Domain, new List<long> { (long)(selected.First().Address ?? 0) }, selected.First().Size); // int to long TODO: cheat address should be long
ToolHelpers.ViewInHexEditor(selected[0].Domain, new List<long> { selected.First().Address ?? 0 }, selected.First().Size);
}
else
{
ToolHelpers.ViewInHexEditor(selected.First().Domain, selected.Select(x => x.Address ?? 0).Cast<long>(), selected.First().Size); // int to long TODO: cheat address should be long
ToolHelpers.ViewInHexEditor(selected.First().Domain, selected.Select(x => x.Address ?? 0), selected.First().Size);
}
}
}

View File

@ -52,7 +52,7 @@ namespace BizHawk.Client.EmuHawk
"NULL", 1024, MemoryDomain.Endian.Little, addr => 0, delegate(long a, byte v) { v = 0; });
private int _row;
private int _addr;
private long _addr;
private string _findStr = string.Empty;
private bool _mouseIsDown;
private byte[] _rom;
@ -152,7 +152,7 @@ namespace BizHawk.Client.EmuHawk
}
BigEndian = _domain.EndianType == MemoryDomain.Endian.Big;
_maxRow = (int)(_domain.Size / 2); // int to long TODO: this probably is bad
_maxRow = _domain.Size / 2;
ResetScrollBar();
SetDataSize(DataSize);
@ -548,16 +548,16 @@ namespace BizHawk.Client.EmuHawk
private byte MakeByte(long address)
{
return Global.CheatList.IsActive(_domain, (int)address) // int to long todo
? Global.CheatList.GetByteValue(_domain, (int)address).Value
return Global.CheatList.IsActive(_domain, address)
? Global.CheatList.GetByteValue(_domain, address).Value
: _domain.PeekByte(address);
}
private int MakeValue(long address)
{
if (Global.CheatList.IsActive(_domain, (int)address)) // int to long TODO: cheats should use long
if (Global.CheatList.IsActive(_domain, address))
{
return Global.CheatList.GetCheatValue(_domain, (int)address, (Watch.WatchSize)DataSize ).Value;
return Global.CheatList.GetCheatValue(_domain, address, (Watch.WatchSize)DataSize ).Value;
}
switch (DataSize)
@ -721,17 +721,17 @@ namespace BizHawk.Client.EmuHawk
{
default:
case 1:
return new ByteWatch(_domain, (int)address, Watch.DisplayType.Hex, BigEndian, string.Empty); // int to long TODO: watches should use long for address
return new ByteWatch(_domain, address, Watch.DisplayType.Hex, BigEndian, string.Empty);
case 2:
return new WordWatch(_domain, (int)address, Watch.DisplayType.Hex, BigEndian, string.Empty);
return new WordWatch(_domain, address, Watch.DisplayType.Hex, BigEndian, string.Empty);
case 4:
return new DWordWatch(_domain, (int)address, Watch.DisplayType.Hex, BigEndian, string.Empty);
return new DWordWatch(_domain, address, Watch.DisplayType.Hex, BigEndian, string.Empty);
}
}
private bool IsFrozen(long address)
{
return Global.CheatList.IsActive(_domain, (int)address); // int to long TODO: cheat should accept long
return Global.CheatList.IsActive(_domain, address);
}
private void UnFreezeAddress(long address)
@ -740,7 +740,7 @@ namespace BizHawk.Client.EmuHawk
{
// TODO: can't unfreeze address 0??
Global.CheatList.RemoveRange(
Global.CheatList.Where(x => x.Contains((int)address)).ToList());
Global.CheatList.Where(x => x.Contains(address)).ToList());
}
MemoryViewerBox.Refresh();
@ -753,7 +753,7 @@ namespace BizHawk.Client.EmuHawk
{
var watch = Watch.GenerateWatch(
_domain,
(int)address,
address,
WatchSize,
Watch.DisplayType.Hex,
string.Empty,
@ -772,7 +772,7 @@ namespace BizHawk.Client.EmuHawk
{
var watch = Watch.GenerateWatch(
_domain,
(int)address, // int to long TODO: address sould be long here
address,
WatchSize,
Watch.DisplayType.Hex,
string.Empty,
@ -1662,7 +1662,7 @@ namespace BizHawk.Client.EmuHawk
break;
case Keys.End:
newHighlighted = (int)(_domain.Size - DataSize); // int to long TODO: newHighlighted must be long
newHighlighted = _domain.Size - DataSize;
if (e.Modifiers == Keys.Shift)
{
for (var i = _addressHighlighted; i < newHighlighted; i += DataSize)
@ -1970,7 +1970,7 @@ namespace BizHawk.Client.EmuHawk
var textrect = new Rectangle(textpoint, new Size(fontWidth * DataSize, fontHeight));
if (Global.CheatList.IsActive(_domain, (int)_addressHighlighted)) // int to long TODO
if (Global.CheatList.IsActive(_domain, _addressHighlighted))
{
e.Graphics.FillRectangle(new SolidBrush(Global.Config.HexHighlightFreezeColor), rect);
e.Graphics.FillRectangle(new SolidBrush(Global.Config.HexHighlightFreezeColor), textrect);

View File

@ -1420,7 +1420,7 @@ namespace BizHawk.Client.EmuHawk
{
if (SelectedWatches.Any())
{
ToolHelpers.ViewInHexEditor(_searches.Domain, SelectedWatches.Select(x => x.Address ?? 0).Cast<long>(), SelectedSize); // int to long TODO: address should be long
ToolHelpers.ViewInHexEditor(_searches.Domain, SelectedWatches.Select(x => x.Address ?? 0), SelectedSize);
}
}

View File

@ -1040,11 +1040,11 @@ namespace BizHawk.Client.EmuHawk
if (selected.Select(x => x.Domain).Distinct().Count() > 1)
{
ToolHelpers.ViewInHexEditor(selected[0].Domain, new List<long> { (long)(selected.First().Address ?? 0) }, selected.First().Size); // int to long todo: address should be long
ToolHelpers.ViewInHexEditor(selected[0].Domain, new List<long> { selected.First().Address ?? 0 }, selected.First().Size);
}
else
{
ToolHelpers.ViewInHexEditor(selected.First().Domain, selected.Select(x => x.Address ?? 0).Cast<long>(), selected.First().Size); // int to long todo: address should be long
ToolHelpers.ViewInHexEditor(selected.First().Domain, selected.Select(x => x.Address ?? 0), selected.First().Size);
}
}
}

View File

@ -84,7 +84,7 @@ namespace BizHawk.Client.EmuHawk
else
{
NotesBox.Text = _watchList[0].Notes;
AddressBox.SetFromRawInt(_watchList[0].Address ?? 0);
AddressBox.SetFromRawInt((int)(_watchList[0].Address ?? 0)); // int to long todo
}
SetBigEndianCheckBox();

View File

@ -24,6 +24,11 @@ namespace BizHawk.Common.NumberExtensions
return string.Format("{0:X" + numdigits + "}", n);
}
public static string ToHexString(this long n, int numdigits)
{
return string.Format("{0:X" + numdigits + "}", n);
}
public static string ToHexString(this ulong n, int numdigits)
{
return string.Format("{0:X" + numdigits + "}", n);