Ram Search/Watch, Hex Editor - improve some code efficiency, tiny speedups if any

This commit is contained in:
adelikat 2012-06-09 05:34:01 +00:00
parent f716caeae5
commit f02d28fb38
3 changed files with 14 additions and 24 deletions

View File

@ -174,20 +174,20 @@ namespace BizHawk.MultiClient
return MakeWordLittle(addr); return MakeWordLittle(addr);
case 4: case 4:
if (BigEndian) if (BigEndian)
return (MakeWordBig(addr) * 65536) + MakeWordBig(addr + 2); return (MakeWordBig(addr) << 16) + MakeWordBig(addr + 2);
else else
return (MakeWordLittle(addr) * 65536) + MakeWordLittle(addr); return (MakeWordLittle(addr) << 16) + MakeWordLittle(addr);
} }
} }
private int MakeWordBig(int addr) private int MakeWordBig(int addr)
{ {
return (Domain.PeekByte(addr) * 256) + Domain.PeekByte(addr + 1); return (Domain.PeekByte(addr) << 8) + Domain.PeekByte(addr + 1);
} }
private int MakeWordLittle(int addr) private int MakeWordLittle(int addr)
{ {
return Domain.PeekByte(addr) + (Domain.PeekByte(addr + 1) * 256); return Domain.PeekByte(addr) + (Domain.PeekByte(addr + 1) << 8);
} }
public void Restart() public void Restart()

View File

@ -651,10 +651,7 @@ namespace BizHawk.MultiClient
{ {
if (Global.Config.RamSearchPreviewMode) if (Global.Config.RamSearchPreviewMode)
{ {
if (GenerateWeedOutList()) GenerateWeedOutList();
{
//OutputLabel.Text = MakeAddressString(searchList.Count - weededList.Count) + " would be removed";
}
} }
} }

View File

@ -141,30 +141,23 @@ namespace BizHawk.MultiClient
} }
} }
private void PeekByte(MemoryDomain domain)
{
value = domain.PeekByte(address);
}
private int PeekWord(MemoryDomain domain, int addr) private int PeekWord(MemoryDomain domain, int addr)
{ {
int temp = 0;
if (bigendian) if (bigendian)
{ {
temp = ((domain.PeekByte(addr) * 256) + return ((domain.PeekByte(addr) << 8) +
domain.PeekByte(addr + 1)); domain.PeekByte(addr + 1));
} }
else else
{ {
temp = ((domain.PeekByte(addr) + return ((domain.PeekByte(addr) +
domain.PeekByte(addr + 1) * 256)); domain.PeekByte(addr + 1) << 8));
} }
return temp;
} }
private void PeekDWord(MemoryDomain domain) private void PeekDWord(MemoryDomain domain)
{ {
value = ((PeekWord(domain, address) * 65536) + value = ((PeekWord(domain, address) << 16) +
PeekWord(domain, address + 2)); PeekWord(domain, address + 2));
} }
@ -178,7 +171,7 @@ namespace BizHawk.MultiClient
switch (type) switch (type)
{ {
case atype.BYTE: case atype.BYTE:
PeekByte(domain); value = domain.PeekByte(address);
break; break;
case atype.WORD: case atype.WORD:
value = PeekWord(domain, address); value = PeekWord(domain, address);
@ -204,13 +197,13 @@ namespace BizHawk.MultiClient
{ {
if (bigendian) if (bigendian)
{ {
domain.PokeByte(address, (byte)(value / 256)); domain.PokeByte(address, (byte)(value >> 8));
domain.PokeByte(address + 1, (byte)(value % 256)); domain.PokeByte(address + 1, (byte)(value & 256));
} }
else else
{ {
domain.PokeByte(address + 1, (byte)(value / 256)); domain.PokeByte(address + 1, (byte)(value >> 8));
domain.PokeByte(address, (byte)(value % 256)); domain.PokeByte(address, (byte)(value & 256));
} }
} }