Ram Poke - pass in a memory domain and poke addresses in that domain instead of defaulting to main memory. Format address & value numbers in output message appropriately
This commit is contained in:
parent
a3c500193f
commit
31a85ab785
|
@ -14,10 +14,9 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
//TODO:
|
//TODO:
|
||||||
//If signed/unsigned/hex radios selected, auto-change the value box, and auto limit box length
|
//If signed/unsigned/hex radios selected, auto-change the value box, and auto limit box length
|
||||||
//Checked signed/u/h value on RamPoke_Load and set value appopriately
|
|
||||||
//Memory domain selection
|
//Memory domain selection
|
||||||
//Output message, format number of digits appropriately
|
|
||||||
public Watch watch = new Watch();
|
public Watch watch = new Watch();
|
||||||
|
public MemoryDomain domain = Global.Emulator.MainMemory;
|
||||||
public Point location = new Point();
|
public Point location = new Point();
|
||||||
|
|
||||||
public RamPoke()
|
public RamPoke()
|
||||||
|
@ -25,9 +24,10 @@ namespace BizHawk.MultiClient
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetWatchObject(Watch w)
|
public void SetWatchObject(Watch w, MemoryDomain d)
|
||||||
{
|
{
|
||||||
watch = w;
|
watch = w;
|
||||||
|
domain = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RamPoke_Load(object sender, EventArgs e)
|
private void RamPoke_Load(object sender, EventArgs e)
|
||||||
|
@ -139,10 +139,18 @@ namespace BizHawk.MultiClient
|
||||||
else
|
else
|
||||||
watch.value = int.Parse(ValueBox.Text);
|
watch.value = int.Parse(ValueBox.Text);
|
||||||
|
|
||||||
watch.PokeAddress(Global.Emulator.MainMemory);
|
watch.PokeAddress(domain);
|
||||||
|
|
||||||
//TODO: format value based on watch.type
|
string value;
|
||||||
OutputLabel.Text = watch.value.ToString() + " written to " + String.Format("{0:X}", watch.address);
|
if (HexRadio.Checked)
|
||||||
|
value = "0x" + String.Format("{0:X" + GetValueNumDigits() + "}", watch.value);
|
||||||
|
else
|
||||||
|
value = watch.value.ToString();
|
||||||
|
string address = String.Format("{0:X" + GetNumDigits(domain.Size).ToString()
|
||||||
|
+ "}", watch.address);
|
||||||
|
|
||||||
|
|
||||||
|
OutputLabel.Text = value + " written to " + address;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddressBox_Leave(object sender, EventArgs e)
|
private void AddressBox_Leave(object sender, EventArgs e)
|
||||||
|
@ -231,7 +239,7 @@ namespace BizHawk.MultiClient
|
||||||
case asigned.UNSIGNED:
|
case asigned.UNSIGNED:
|
||||||
i = InputValidate.IsValidUnsignedNumber(ValueBox.Text);
|
i = InputValidate.IsValidUnsignedNumber(ValueBox.Text);
|
||||||
if (!i) return -99999999;
|
if (!i) return -99999999;
|
||||||
return (int)Int64.Parse(ValueBox.Text); //Note: 64 to be safe since 4 byte values can be entered
|
return (int)Int64.Parse(ValueBox.Text); //Note: 64 to be safe
|
||||||
case asigned.SIGNED:
|
case asigned.SIGNED:
|
||||||
i = InputValidate.IsValidSignedNumber(ValueBox.Text);
|
i = InputValidate.IsValidSignedNumber(ValueBox.Text);
|
||||||
if (!i) return -99999999;
|
if (!i) return -99999999;
|
||||||
|
@ -258,5 +266,32 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
ValueHexLabel.Text = "";
|
ValueHexLabel.Text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int GetValueNumDigits()
|
||||||
|
{
|
||||||
|
switch (GetDataSize())
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case atype.BYTE:
|
||||||
|
return HexRadio.Checked ? 2 : 3;
|
||||||
|
case atype.WORD:
|
||||||
|
return HexRadio.Checked ? 4 : 5;
|
||||||
|
case atype.DWORD:
|
||||||
|
return HexRadio.Checked ? 8 : 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int GetNumDigits(Int32 i)
|
||||||
|
{
|
||||||
|
//if (i == 0) return 0;
|
||||||
|
//if (i < 0x10) return 1;
|
||||||
|
//if (i < 0x100) return 2;
|
||||||
|
//if (i < 0x1000) return 3; //adelikat: commenting these out because I decided that regardless of domain, 4 digits should be the minimum
|
||||||
|
if (i < 0x10000) return 4;
|
||||||
|
if (i < 0x100000) return 5;
|
||||||
|
if (i < 0x1000000) return 6;
|
||||||
|
if (i < 0x10000000) return 7;
|
||||||
|
else return 8;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -467,7 +467,7 @@ namespace BizHawk.MultiClient
|
||||||
Global.Sound.StartSound();
|
Global.Sound.StartSound();
|
||||||
|
|
||||||
if (indexes.Count > 0)
|
if (indexes.Count > 0)
|
||||||
p.SetWatchObject(searchList[indexes[0]]);
|
p.SetWatchObject(searchList[indexes[0]], Domain);
|
||||||
p.location = GetPromptPoint();
|
p.location = GetPromptPoint();
|
||||||
p.ShowDialog();
|
p.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
|
@ -927,7 +927,7 @@ namespace BizHawk.MultiClient
|
||||||
RamPoke p = new RamPoke();
|
RamPoke p = new RamPoke();
|
||||||
Global.Sound.StartSound();
|
Global.Sound.StartSound();
|
||||||
if (indexes.Count > 0)
|
if (indexes.Count > 0)
|
||||||
p.SetWatchObject(watchList[indexes[0]]);
|
p.SetWatchObject(watchList[indexes[0]], Domain);
|
||||||
p.location = GetPromptPoint();
|
p.location = GetPromptPoint();
|
||||||
p.ShowDialog();
|
p.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue