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);
case 4:
if (BigEndian)
return (MakeWordBig(addr) * 65536) + MakeWordBig(addr + 2);
return (MakeWordBig(addr) << 16) + MakeWordBig(addr + 2);
else
return (MakeWordLittle(addr) * 65536) + MakeWordLittle(addr);
return (MakeWordLittle(addr) << 16) + MakeWordLittle(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)
{
return Domain.PeekByte(addr) + (Domain.PeekByte(addr + 1) * 256);
return Domain.PeekByte(addr) + (Domain.PeekByte(addr + 1) << 8);
}
public void Restart()

View File

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

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