From d9ebc40aaec6e9286a693c4806e3fc11642d5fb0 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Sun, 20 Feb 2011 23:54:58 +0000 Subject: [PATCH] Ram Search - StartNewSearch works with 2-byte value selected --- BizHawk.MultiClient/tools/RamSearch.cs | 50 ++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/BizHawk.MultiClient/tools/RamSearch.cs b/BizHawk.MultiClient/tools/RamSearch.cs index f78b9b69c6..363400f4c5 100644 --- a/BizHawk.MultiClient/tools/RamSearch.cs +++ b/BizHawk.MultiClient/tools/RamSearch.cs @@ -264,11 +264,55 @@ namespace BizHawk.MultiClient int startaddress = 0; if (Global.Emulator.SystemId == "PCE") startaddress = 0x1F0000; //For now, until Emulator core functionality can better handle a prefix - for (int x = 0; x < Global.Emulator.MainMemory.Size; x++) + int count = 0; + int divisor = 1; + switch (GetDataSize()) + { + case atype.WORD: + divisor = 2; + break; + case atype.DWORD: + divisor = 4; + break; + default: + divisor = 1; + break; + } + + for (int x = 0; x < (Global.Emulator.MainMemory.Size / divisor); x++) { searchList.Add(new Watch()); - searchList[x].address = x + startaddress; - searchList[x].prev = searchList[x].value = Global.Emulator.MainMemory.PeekByte(x); + searchList[x].address = count + startaddress; + switch (GetDataSize()) + { + case atype.BYTE: + searchList[x].prev = searchList[x].value = Global.Emulator.MainMemory.PeekByte(count); + searchList[x].bigendian = GetBigEndian(); //Pointless in 1 byte, but might as well + searchList[x].signed = GetDataType(); + searchList[x].type = atype.BYTE; + count++; + break; + case atype.WORD: + if (GetBigEndian()) + { + searchList[x].prev = searchList[x].value = ((Global.Emulator.MainMemory.PeekByte(searchList[x].address) * 256) + + Global.Emulator.MainMemory.PeekByte((searchList[x + 1].address) + 1)); + } + else + { + searchList[x].prev = searchList[x].value = (Global.Emulator.MainMemory.PeekByte(searchList[x].address) + + (Global.Emulator.MainMemory.PeekByte((searchList[x].address) + 1) * 256)); + } + searchList[x].bigendian = GetBigEndian(); //Pointless in 1 byte, but might as well + searchList[x].signed = GetDataType(); + searchList[x].type = atype.BYTE; + count += 2; + break; + case atype.DWORD: + //TODO + break; + } + } OutputLabel.Text = "New search started"; DisplaySearchList();