/* * This method takes the first Address and Data from the patch and tests if the current values in the * ROM match the values of the patch - if they match the patch is already applied. This doesn't test * all values to speed things up. */ public bool CheckIsApplied(NitroROM rom) { if (m_DecompressAllOverlays && Helper.CheckAllOverlaysDecompressed() == false) { m_IsApplied = false; return(false); } INitroROMBlock fileToPatch = null; if (m_FileToPatch != null) { fileToPatch = Program.m_ROM.GetFileFromName(m_FileToPatch); } else if (m_OverlayID != null) { fileToPatch = new NitroOverlay(Program.m_ROM, uint.Parse(m_OverlayID)); } AddressDataPair testAddressDataPair = null; switch (rom.m_Version) { case NitroROM.Version.EUR: testAddressDataPair = (m_EURPatch.Count == 0) ? null : m_EURPatch.ElementAt(0); break; case NitroROM.Version.USA_v1: testAddressDataPair = (m_USv1Patch.Count == 0) ? null : m_USv1Patch.ElementAt(0); break; case NitroROM.Version.USA_v2: testAddressDataPair = (m_USv2Patch.Count == 0) ? null : m_USv2Patch.ElementAt(0); break; case NitroROM.Version.JAP: testAddressDataPair = (m_JAPPatch.Count == 0) ? null : m_JAPPatch.ElementAt(0); break; } if (testAddressDataPair == null || testAddressDataPair.m_Data == null || testAddressDataPair.m_Data.Length == 0) { m_IsApplied = false; return(false); } for (int i = 0; i < testAddressDataPair.m_Data.Length; i++) { if (fileToPatch == null) { if (Program.m_IsROMFolder) { Program.m_ROM.arm9R.BaseStream.Position = testAddressDataPair.m_Address + (uint)i - Program.m_ROM.headerSize; if (Program.m_ROM.arm9R.ReadByte() != testAddressDataPair.m_Data[i]) { m_IsApplied = false; return(false); } } else { if (rom.Read8(testAddressDataPair.m_Address + (uint)i) != testAddressDataPair.m_Data[i]) { m_IsApplied = false; return(false); } } } else if (fileToPatch != null && fileToPatch.Read8(testAddressDataPair.m_Address + (uint)i) != testAddressDataPair.m_Data[i]) { m_IsApplied = false; return(false); } } //If it reaches here, the patch has already been applied m_IsApplied = true; return(true); }