diff --git a/BizHawk.MultiClient/tools/RamSearch.cs b/BizHawk.MultiClient/tools/RamSearch.cs index 13846f879c..e83c80cc4a 100644 --- a/BizHawk.MultiClient/tools/RamSearch.cs +++ b/BizHawk.MultiClient/tools/RamSearch.cs @@ -19,7 +19,6 @@ namespace BizHawk.MultiClient //TODO: //Window position gets saved but doesn't load properly //Add to Ram watch fails to open ram watch if it has neve been opened - //Implement DWORD start new search & updateValues //Doesnt' release handle after saving file, Ram Watch too? //Implement Preview search //Implement Check Misaligned (does 2 & 4 byte on each possible address instead of every other (or every 4) @@ -47,35 +46,11 @@ namespace BizHawk.MultiClient public void UpdateValues() { - //TODO: update based on atype for (int x = 0; x < searchList.Count; x++) { searchList[x].prev = searchList[x].value; - switch (searchList[x].type) - { - case atype.BYTE: - searchList[x].value = Global.Emulator.MainMemory.PeekByte(searchList[x].address); - break; - case atype.WORD: - if (searchList[x].bigendian) - { - searchList[x].value = ((Global.Emulator.MainMemory.PeekByte(searchList[x].address) * 256) + - Global.Emulator.MainMemory.PeekByte((searchList[x].address) + 1)); - } - else - { - searchList[x].value = (Global.Emulator.MainMemory.PeekByte(searchList[x].address) + - (Global.Emulator.MainMemory.PeekByte((searchList[x].address) + 1) * 256)); - } - break; - case atype.DWORD: - //TODO - break; - default: - searchList[x].value = Global.Emulator.MainMemory.PeekByte(searchList[x].address); - break; - } - + searchList[x].PeekAddress(Global.Emulator.MainMemory); + if (searchList[x].prev != searchList[x].value) searchList[x].changecount++; @@ -301,7 +276,7 @@ namespace BizHawk.MultiClient int startaddress = 0; if (Global.Emulator.SystemId == "PCE") startaddress = 0x1F0000; //For now, until Emulator core functionality can better handle a prefix - int count = 1; + int count = 0; int divisor = 1; switch (GetDataSize()) { @@ -320,33 +295,21 @@ namespace BizHawk.MultiClient { searchList.Add(new Watch()); searchList[x].address = count + startaddress; + searchList[x].type = GetDataSize(); + searchList[x].bigendian = GetBigEndian(); + searchList[x].signed = GetDataType(); + searchList[x].PeekAddress(Global.Emulator.MainMemory); + searchList[x].prev = searchList[x].value; 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; + case atype.BYTE: //TODO: misaligned option 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].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 + count += 4; break; } diff --git a/BizHawk.MultiClient/tools/RamWatch.cs b/BizHawk.MultiClient/tools/RamWatch.cs index 05b8c9a2c7..dda0bc2bb0 100644 --- a/BizHawk.MultiClient/tools/RamWatch.cs +++ b/BizHawk.MultiClient/tools/RamWatch.cs @@ -18,7 +18,6 @@ namespace BizHawk.MultiClient { //TODO: //Call AskSave in main client X function - //DWORD display //On Movie UP/Down set highlighted items to be what the user had selected (in their new position) //DisplayWatches needs to do value display properly like updatevalues, or just run update values //When Watch object has a changes member, display in watch list with a reset changes function @@ -42,32 +41,8 @@ namespace BizHawk.MultiClient public void UpdateValues() { for (int x = 0; x < watchList.Count; x++) - { - if (watchList[x].type == atype.SEPARATOR) continue; - switch (watchList[x].type) - { - case atype.BYTE: - watchList[x].value = Global.Emulator.MainMemory.PeekByte(watchList[x].address); - break; - case atype.WORD: - { - if (watchList[x].bigendian) - { - watchList[x].value = ((Global.Emulator.MainMemory.PeekByte(watchList[x].address)*256) + - Global.Emulator.MainMemory.PeekByte((watchList[x+1].address)+1) ); - } - else - { - watchList[x].value = (Global.Emulator.MainMemory.PeekByte(watchList[x].address) + - (Global.Emulator.MainMemory.PeekByte((watchList[x].address)+1)*256) ); - } - } - break; - case atype.DWORD: - break; - } - WatchListView.Refresh(); - } + watchList[x].PeekAddress(Global.Emulator.MainMemory); + WatchListView.Refresh(); } public void AddWatch(Watch w) diff --git a/BizHawk.MultiClient/tools/Watch.cs b/BizHawk.MultiClient/tools/Watch.cs index c2667d0d1e..9f4b4e7d36 100644 --- a/BizHawk.MultiClient/tools/Watch.cs +++ b/BizHawk.MultiClient/tools/Watch.cs @@ -115,5 +115,51 @@ namespace BizHawk.MultiClient return 's'; //Just in case } } + + 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) + + domain.PeekByte(addr + 1)); + } + else + { + temp = ((domain.PeekByte(addr) + + domain.PeekByte(addr + 1) * 256)); + } + return temp; + } + + private void PeekDWord(MemoryDomain domain) + { + value = ((PeekWord(domain, address) * 65536) + + PeekWord(domain, address + 2)); + } + + public void PeekAddress(MemoryDomain domain) + { + if (type == atype.SEPARATOR) + return; + + switch(type) + { + case atype.BYTE: + PeekByte(domain); + break; + case atype.WORD: + value = PeekWord(domain, address); + break; + case atype.DWORD: + PeekDWord(domain); + break; + } + } } }