public CodeGenerator(byte[] formdata) { tabdata = formdata; InitializeComponent(); CenterToParent(); RTB_Code.Clear(); TB_Write.Clear(); CB_Box.Items.Clear(); for (int i = 1; i <= 31; i++) { CB_Box.Items.Add(i.ToString()); } CB_Source.SelectedIndex = 0; CB_Slot.SelectedIndex = 0; CB_Box.SelectedIndex = 0; }
public CodeGenerator(Form1 frm1) { m_parent = frm1; InitializeComponent(); this.CenterToParent(); RTB_Code.Clear(); TB_Write.Clear(); SaveGame = m_parent.SaveGame; CB_Box.Items.Clear(); for (int i = 1; i <= 31; i++) { CB_Box.Items.Add(i.ToString()); } CB_Source.SelectedIndex = 0; CB_Slot.SelectedIndex = 0; CB_Box.SelectedIndex = 0; }
private void B_Load_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog { Filter = "Code File|*.bin" }; if (ofd.ShowDialog() != DialogResult.OK) { return; } string path = ofd.FileName; byte[] ncf = File.ReadAllBytes(path); uint length = BitConverter.ToUInt32(ncf, 0); if (ncf.Length != length + 4) { Util.Error("Not a valid code file."); return; } if (RTB_Code.Text.Length > 0) { DialogResult ld = Util.Prompt(MessageBoxButtons.YesNo, "Replace current code?"); if (ld == DialogResult.Yes) { RTB_Code.Clear(); } else if (ld != DialogResult.No) { return; } } for (int i = 4; i <= ncf.Length - 12; i += 12) { RTB_Code.AppendText(BitConverter.ToUInt32(ncf, i + 0 * 4).ToString("X8") + " "); RTB_Code.AppendText(BitConverter.ToUInt32(ncf, i + 1 * 4).ToString("X8") + " "); RTB_Code.AppendText(BitConverter.ToUInt32(ncf, i + 2 * 4).ToString("X8") + Environment.NewLine); } }
private void B_Diff_Click(object sender, EventArgs e) { string result = ""; RTB_Code.Clear(); byte[] cybersav = Main.originalSAV; byte[] newcyber = Main.SAV.Data; int boxoffset = Main.SAV.Box; int lines = 0; // 65400 for (int i = 0; i < newcyber.Length - 0x200; i += 4) { // Skip Party and Boxes if (i == 0x14200) { i += (260 * 6 + 4); // +4 to skip over party count } if (i == boxoffset) { i += (232 * 30 * 31); } if (BitConverter.ToUInt32(cybersav, i) == BitConverter.ToUInt32(newcyber, i)) { continue; } result += ((0x20000000 + i).ToString("X8") + " "); result += (BitConverter.ToUInt32(newcyber, i).ToString("X8") + Environment.NewLine); lines++; if ((lines % 128 == 0) && CHK_Break.Checked) { result += (Environment.NewLine + "--- Segment " + (lines / 128 + 1) + " ---" + Environment.NewLine + Environment.NewLine); } if (lines > 10000) { goto toomany; } } // Loop Through Party for (int i = 0x14200; i < 0x14200 + 260 * 6; i += 260) { byte[] newdata = new byte[260]; Array.Copy(newcyber, i, newdata, 0, 260); byte[] olddata = new byte[260]; Array.Copy(cybersav, i, olddata, 0, 260); if (newdata.SequenceEqual(olddata)) { continue; } for (int z = 0; z < newdata.Length; z += 4) { result += ((0x20000000 + i + z).ToString("X8") + " "); result += (BitConverter.ToUInt32(newdata, z).ToString("X8") + Environment.NewLine); lines++; if ((lines % 128 == 0) && CHK_Break.Checked) { result += (Environment.NewLine + "--- Segment " + (lines / 128 + 1) + " ---" + Environment.NewLine + Environment.NewLine); } if (lines > 10000) { goto toomany; } } } // Fix Party Count if Necessary if (cybersav[0x14818] != newcyber[0x14818]) { result += ((0x00000000 + 0x14818).ToString("X8") + " "); result += (newcyber[0x14818].ToString("X8") + Environment.NewLine); lines++; if ((lines % 128 == 0) && CHK_Break.Checked) { result += (Environment.NewLine + "--- Segment " + (lines / 128 + 1) + " ---" + Environment.NewLine + Environment.NewLine); } if (lines > 10000) { goto toomany; } } // Loop Through Boxes for (int i = boxoffset; i < boxoffset + (232 * 30 * 31); i += 232) { byte[] newdata = new byte[232]; Array.Copy(newcyber, i, newdata, 0, 232); byte[] olddata = new byte[232]; Array.Copy(cybersav, i, olddata, 0, 232); if (newdata.SequenceEqual(olddata)) { continue; } for (int z = 0; z < newdata.Length; z += 4) { result += ((0x20000000 + i + z).ToString("X8") + " "); result += (BitConverter.ToUInt32(newdata, z).ToString("X8") + Environment.NewLine); lines++; if ((lines % 128 == 0) && CHK_Break.Checked) { result += (Environment.NewLine + "--- Segment " + (lines / 128 + 1) + " ---" + Environment.NewLine + Environment.NewLine); } if (lines > 10000) { goto toomany; } } } if ((lines / 128 > 0) && CHK_Break.Checked) { Util.Alert(String.Format("{0} Code Segments.", (1 + (lines / 128))), String.Format("{0} Lines.", lines)); } RTB_Code.Text = result; return; toomany: { Util.Alert("Too many differences detected.", "Export your save instead."); } }
private void B_Clear_Click(object sender, EventArgs e) { RTB_Code.Clear(); }
private void B_Diff_Click(object sender, EventArgs e) { string result = ""; RTB_Code.Clear(); byte[] cybersav = m_parent.cyberSAV; byte[] editedsav = m_parent.savefile; byte[] newcyber = new Byte[m_parent.cyberSAV.Length]; Array.Copy(editedsav, 0x5400, newcyber, 0, newcyber.Length); int boxoffset = 0x22600; if (m_parent.savegame_oras) { boxoffset = 0x33000; } if (!m_parent.cybergadget) { Array.Copy(editedsav, m_parent.savindex * 0x7F000 + 0x5400, newcyber, 0, newcyber.Length); } int lines = 0; // 65400 for (int i = 0; i < newcyber.Length - 0x200; i += 4) { // Skip Party and Boxes if (i == 0x14200) { i += (260 * 6 + 4); // +4 to skip over party count } if (i == boxoffset) { i += (232 * 30 * 31); } if (BitConverter.ToUInt32(cybersav, i) != BitConverter.ToUInt32(newcyber, i)) { result += ((0x20000000 + i).ToString("X8") + " "); result += (BitConverter.ToUInt32(newcyber, i).ToString("X8") + "\n"); lines++; if ((lines % 128 == 0) && CHK_Break.Checked) { result += ("\r\n--- Segment " + (lines / 128 + 1).ToString() + " ---\r\n\r\n"); } if (lines > 10000) { goto toomany; } } } // Loop Through Party for (int i = 0x14200; i < 0x14200 + 260 * 6; i += 260) { byte[] newdata = new Byte[260]; Array.Copy(newcyber, i, newdata, 0, 260); byte[] olddata = new Byte[260]; Array.Copy(cybersav, i, olddata, 0, 260); if (!newdata.SequenceEqual(olddata)) { for (int z = 0; z < newdata.Length; z += 4) { result += ((0x20000000 + i + z).ToString("X8") + " "); result += (BitConverter.ToUInt32(newdata, z).ToString("X8") + "\n"); lines++; if ((lines % 128 == 0) && CHK_Break.Checked) { result += ("\r\n--- Segment " + (lines / 128 + 1).ToString() + " ---\r\n\r\n"); } if (lines > 10000) { goto toomany; } } } } // Fix Party Count if Necessary if (cybersav[0x14818] != newcyber[0x14818]) { result += ((0x00000000 + 0x14818).ToString("X8") + " "); result += (newcyber[0x14818].ToString("X8") + "\n"); lines++; if ((lines % 128 == 0) && CHK_Break.Checked) { result += ("\r\n--- Segment " + (lines / 128 + 1).ToString() + " ---\r\n\r\n"); } if (lines > 10000) { goto toomany; } } // Loop Through Boxes for (int i = boxoffset; i < boxoffset + (232 * 30 * 31); i += 232) { byte[] newdata = new Byte[232]; Array.Copy(newcyber, i, newdata, 0, 232); byte[] olddata = new Byte[232]; Array.Copy(cybersav, i, olddata, 0, 232); if (!newdata.SequenceEqual(olddata)) { for (int z = 0; z < newdata.Length; z += 4) { result += ((0x20000000 + i + z).ToString("X8") + " "); result += (BitConverter.ToUInt32(newdata, z).ToString("X8") + "\n"); lines++; if ((lines % 128 == 0) && CHK_Break.Checked) { result += ("\r\n--- Segment " + (lines / 128 + 1).ToString() + " ---\r\n\r\n"); } if (lines > 10000) { goto toomany; } } } } if ((lines / 128 > 0) && CHK_Break.Checked) { MessageBox.Show((1 + (lines / 128)).ToString() + " Code Segments\n\nLines: " + lines.ToString(), "Alert"); } RTB_Code.Text = result; return; toomany: { MessageBox.Show("Too many differences. Export your save instead.", "Alert"); } }