NES - fix game genie codes with an empty compare text value

This commit is contained in:
adelikat 2012-09-01 14:18:54 +00:00
parent 9b7404b059
commit e741aa2af0
1 changed files with 27 additions and 2 deletions

View File

@ -383,10 +383,35 @@ namespace BizHawk.MultiClient
{ {
Cheat c = new Cheat(); Cheat c = new Cheat();
c.name = GameGenieCode.Text; c.name = GameGenieCode.Text;
if (String.IsNullOrWhiteSpace(AddressBox.Text))
{
return;
}
else if (String.IsNullOrWhiteSpace(ValueBox.Text))
{
return;
}
c.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber); c.address = int.Parse(AddressBox.Text, NumberStyles.HexNumber);
c.value = byte.Parse(ValueBox.Text, NumberStyles.HexNumber); c.value = byte.Parse(ValueBox.Text, NumberStyles.HexNumber);
c.compare = byte.Parse(CompareBox.Text, NumberStyles.HexNumber);
c.domain = Global.Emulator.MemoryDomains[1]; if (!String.IsNullOrWhiteSpace(CompareBox.Text))
{
try
{
c.compare = byte.Parse(CompareBox.Text, NumberStyles.HexNumber);
}
catch
{
c.compare = null;
}
}
else
{
c.compare = null;
}
c.domain = Global.Emulator.MemoryDomains[1]; //System Bus only
c.Enable(); c.Enable();
Global.MainForm.Cheats1.AddCheat(c); Global.MainForm.Cheats1.AddCheat(c);