From 211ef7e1b9363399023da4782b2c87299728af1c Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Sat, 19 Mar 2011 02:24:29 +0000 Subject: [PATCH] Ram Watch - ability to freeze 2 byte watch --- BizHawk.MultiClient/tools/RamWatch.cs | 46 ++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/BizHawk.MultiClient/tools/RamWatch.cs b/BizHawk.MultiClient/tools/RamWatch.cs index 3aec8c09b1..24d6c2be31 100644 --- a/BizHawk.MultiClient/tools/RamWatch.cs +++ b/BizHawk.MultiClient/tools/RamWatch.cs @@ -17,7 +17,7 @@ namespace BizHawk.MultiClient public partial class RamWatch : Form { //TODO: - //Ability to freeze 2 & 4 byte + //Ability to freeze 4 byte //.wch format includes platform and domain type //address num digits based on domain size //Restore window size should restore column order as well @@ -1097,15 +1097,51 @@ namespace BizHawk.MultiClient FreezeAddress(); } + private int WORDGetLowerByte(int value) + { + return value / 256; + } + + private int WORDGetUpperByte(int value) + { + return value >> 2; + } + private void FreezeAddress() { ListView.SelectedIndexCollection indexes = WatchListView.SelectedIndices; - //TODO: if 2 byte or 4 byte, freeze correct addresses if (indexes.Count > 0) { - Cheat c = new Cheat("", watchList[indexes[0]].address, (byte)watchList[indexes[0]].value, - true, Domain); - Global.MainForm.Cheats1.AddCheat(c); + switch (watchList[indexes[0]].type) + { + case atype.BYTE: + Cheat c = new Cheat("", watchList[indexes[0]].address, (byte)watchList[indexes[0]].value, + true, Domain); + Global.MainForm.Cheats1.AddCheat(c); + break; + case atype.WORD: + byte low = (byte)(watchList[indexes[0]].value / 256); + byte high = (byte)(watchList[indexes[0]].value % 256); + int a1 = watchList[indexes[0]].address; + int a2 = watchList[indexes[0]].address + 1; + if (watchList[indexes[0]].bigendian) + { + Cheat c1 = new Cheat("", a1, low, true, Domain); + Cheat c2 = new Cheat("", a2, high, true, Domain); + Global.MainForm.Cheats1.AddCheat(c1); + Global.MainForm.Cheats1.AddCheat(c2); + } + else + { + Cheat c1 = new Cheat("", a1, high, true, Domain); + Cheat c2 = new Cheat("", a2, low, true, Domain); + Global.MainForm.Cheats1.AddCheat(c1); + Global.MainForm.Cheats1.AddCheat(c2); + } + break; + case atype.DWORD: + break; + } } }