private void btnSavePatch_Click(object sender, EventArgs e) { string name = txtPatchName.Text; string author = (txtAuthor.Text != "") ? txtAuthor.Text : null; bool isFileToPatch = chkApplyToFile.Checked; bool isOverlayToPatch = chkApplyToOverlay.Checked; String fileToPatch = (isFileToPatch) ? txtApplyToFile.Text : null; String overlayID = (isOverlayToPatch) ? txtOverlayID.Text : null; bool decompressAllOverlays = chkDecompressAllOverlays.Checked; List<Patch.AddressDataPair> eurPatch = new List<Patch.AddressDataPair>(), usv1Patch = new List<Patch.AddressDataPair>(), usv2Patch = new List<Patch.AddressDataPair>(), japPatch = new List<Patch.AddressDataPair>(); List<Patch.AddressDataPair> eurRestoreData = new List<Patch.AddressDataPair>(), usv1RestoreData = new List<Patch.AddressDataPair>(), usv2RestoreData = new List<Patch.AddressDataPair>(), japRestoreData = new List<Patch.AddressDataPair>(); // Read entered patch data eurPatch = ParseEnteredPatchData("EUR"); usv1Patch = ParseEnteredPatchData("USv1"); usv2Patch = ParseEnteredPatchData("USv2"); japPatch = ParseEnteredPatchData("JAP"); // Generate the restore data for current ROM version by reading the current data at the addresses to be patched Program.m_ROM.BeginRW(); if (decompressAllOverlays) Helper.DecompressOverlaysWithinGame(); switch (Program.m_ROM.m_Version) { case NitroROM.Version.EUR: eurRestoreData = Patch.GenerateRestoreData(eurPatch); break; case NitroROM.Version.USA_v1: usv1RestoreData = Patch.GenerateRestoreData(usv1Patch); break; case NitroROM.Version.USA_v2: usv2RestoreData = Patch.GenerateRestoreData(usv2Patch); break; case NitroROM.Version.JAP: japRestoreData = Patch.GenerateRestoreData(japPatch); break; } Program.m_ROM.EndRW(); // Finally, add the parsed details to the list of patches if (editingIndex == -1) m_Patches.Add(new Patch(name, author, eurPatch, usv1Patch, usv2Patch, japPatch, eurRestoreData, usv1RestoreData, usv2RestoreData, japRestoreData, fileToPatch, overlayID, decompressAllOverlays)); else m_Patches[editingIndex] = new Patch(name, author, eurPatch, usv1Patch, usv2Patch, japPatch, eurRestoreData, usv1RestoreData, usv2RestoreData, japRestoreData, fileToPatch, overlayID, decompressAllOverlays); // Write the updated patches to XML Patch.PatchToXML(m_Patches); // Reload the list of patches m_Patches = Patch.XMLToPatch(); populatePatchListTable(); }
private void btnSavePatch_Click(object sender, EventArgs e) { string name = txtPatchName.Text; string author = (txtAuthor.Text != "") ? txtAuthor.Text : null; bool isFileToPatch = chkApplyToFile.Checked; bool isOverlayToPatch = chkApplyToOverlay.Checked; String fileToPatch = (isFileToPatch) ? txtApplyToFile.Text : null; String overlayID = (isOverlayToPatch) ? txtOverlayID.Text : null; bool decompressAllOverlays = chkDecompressAllOverlays.Checked; List <Patch.AddressDataPair> eurPatch = new List <Patch.AddressDataPair>(), usv1Patch = new List <Patch.AddressDataPair>(), usv2Patch = new List <Patch.AddressDataPair>(), japPatch = new List <Patch.AddressDataPair>(); List <Patch.AddressDataPair> eurRestoreData = new List <Patch.AddressDataPair>(), usv1RestoreData = new List <Patch.AddressDataPair>(), usv2RestoreData = new List <Patch.AddressDataPair>(), japRestoreData = new List <Patch.AddressDataPair>(); // Read entered patch data eurPatch = ParseEnteredPatchData("EUR"); usv1Patch = ParseEnteredPatchData("USv1"); usv2Patch = ParseEnteredPatchData("USv2"); japPatch = ParseEnteredPatchData("JAP"); // Generate the restore data for current ROM version by reading the current data at the addresses to be patched Program.m_ROM.BeginRW(); if (decompressAllOverlays) { Helper.DecompressOverlaysWithinGame(); } switch (Program.m_ROM.m_Version) { case NitroROM.Version.EUR: eurRestoreData = Patch.GenerateRestoreData(eurPatch); break; case NitroROM.Version.USA_v1: usv1RestoreData = Patch.GenerateRestoreData(usv1Patch); break; case NitroROM.Version.USA_v2: usv2RestoreData = Patch.GenerateRestoreData(usv2Patch); break; case NitroROM.Version.JAP: japRestoreData = Patch.GenerateRestoreData(japPatch); break; } Program.m_ROM.EndRW(); // Finally, add the parsed details to the list of patches if (editingIndex == -1) { m_Patches.Add(new Patch(name, author, eurPatch, usv1Patch, usv2Patch, japPatch, eurRestoreData, usv1RestoreData, usv2RestoreData, japRestoreData, fileToPatch, overlayID, decompressAllOverlays)); } else { m_Patches[editingIndex] = new Patch(name, author, eurPatch, usv1Patch, usv2Patch, japPatch, eurRestoreData, usv1RestoreData, usv2RestoreData, japRestoreData, fileToPatch, overlayID, decompressAllOverlays); } // Write the updated patches to XML Patch.PatchToXML(m_Patches); // Reload the list of patches m_Patches = Patch.XMLToPatch(); populatePatchListTable(); }