Hex Editor - fix issue 150 - exceptions thrown when freezing multi-byte addresses
This commit is contained in:
parent
5f66376f82
commit
e4c7110174
|
@ -243,6 +243,44 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
public byte? GetByteVal(int addr)
|
||||
{
|
||||
if (!Contains(addr))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (_watch.Size)
|
||||
{
|
||||
default:
|
||||
case Watch.WatchSize.Separator:
|
||||
case Watch.WatchSize.Byte:
|
||||
return (byte?)_val;
|
||||
case Watch.WatchSize.Word:
|
||||
if (addr == (_watch.Address ?? 0))
|
||||
{
|
||||
return (byte)(_val >> 8);
|
||||
}
|
||||
|
||||
return (byte)(_val & 0xFF);
|
||||
case Watch.WatchSize.DWord:
|
||||
if (addr == (_watch.Address ?? 0))
|
||||
{
|
||||
return (byte)((_val >> 24) & 0xFF);
|
||||
}
|
||||
else if (addr == (_watch.Address ?? 0) + 1)
|
||||
{
|
||||
return (byte)((_val >> 16) & 0xFF);
|
||||
}
|
||||
else if (addr == ((_watch.Address ?? 0)) + 2)
|
||||
{
|
||||
return (byte)((_val >> 8) & 0xFF);
|
||||
}
|
||||
|
||||
return (byte)(_val & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
public void Increment()
|
||||
{
|
||||
if (!IsSeparator)
|
||||
|
|
|
@ -240,6 +240,22 @@ namespace BizHawk.Client.Common
|
|||
&& cheat.Contains(address));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value of a given byte in a cheat, If the cheat is a single byte this will be the same indexing the cheat,
|
||||
/// 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)
|
||||
{
|
||||
var activeCheat = _cheatList.FirstOrDefault(cheat => cheat.Contains(addr));
|
||||
if (activeCheat == (Cheat)null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return activeCheat.GetByteVal(addr);
|
||||
}
|
||||
|
||||
public void SaveOnClose()
|
||||
{
|
||||
if (Global.Config.CheatsAutoSaveOnClose)
|
||||
|
|
|
@ -560,7 +560,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private byte MakeByte(int address)
|
||||
{
|
||||
return Global.CheatList.IsActive(_domain, address)
|
||||
? (byte) Global.CheatList[_domain, address].Value.Value
|
||||
? Global.CheatList.GetByteValue(_domain, address).Value
|
||||
: _domain.PeekByte(address);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue