private void btnChangeMoveScriptPointer_Click(object sender, EventArgs e)
{
if (selectedROMPath != null && !selectedROMPath.Equals(""))
{
byte[] rom = File.ReadAllBytes(selectedROMPath);
string romCode = GetROMCode();
string[] iniFile = File.ReadAllLines(System.Windows.Forms.Application.StartupPath + @"\Data\BattleScriptPro.ini");
bool getValues = false;
foreach (string s in iniFile)
{
if (s.Equals("[" + romCode + "]"))
{
getValues = true;
continue;
}
if (getValues)
{
if (s.StartsWith("MoveEffectTable"))
{
uint value = 0;
bool success = UInt32.TryParse(s.Split('=')[1], out value);
if (!success)
{
success = UInt32.TryParse(ToDecimal(s.Split('=')[1]), out value);
if (!success)
{
MessageBox.Show("Error parsing the move keyword value from the main ini. Are you sure it is formatted correctly as a number?");
}
}
moveEffectTableLocation = value;
getValues = false;
break;
}
}
}
uint x = 0;
bool newSuccess = UInt32.TryParse(txtMoveEffectScriptLocation.Text, out x);
if (!newSuccess)
{
newSuccess = UInt32.TryParse(ToDecimal(txtMoveEffectScriptLocation.Text), out x);
}
if (x > 0 && x < 0x02000000)
{
x += 0x08000000;
}
for (int i = 0; i < 4; i++)
{
rom[((int)numericUpDown1.Value * 4) + moveEffectTableLocation + 3 - i] = Byte.Parse(ToDecimal("0x" + x.ToString("X8").Substring((i * 2), 2)));
}
File.WriteAllBytes(selectedROMPath, rom);
}
}