public bool RomCrcValid(ROM rom) { if (LogicParser.SubParser.RomCrc != null) { return(PatchUtil.Crc32(rom.romData, rom.romData.Length) == LogicParser.SubParser.RomCrc); } else { return(true); } }
public uint GetGimmickHash() { byte[] gimmickBytes = LogicParser.SubParser.GetGimmickBytes(); if (gimmickBytes.Length > 0) { return(PatchUtil.Crc32(gimmickBytes, gimmickBytes.Length)); } else { return(0); } }
public uint GetSettingHash() { byte[] settingBytes = LogicParser.SubParser.GetSettingBytes(); if (settingBytes.Length > 0) { return(PatchUtil.Crc32(settingBytes, settingBytes.Length)); } else { return(0); } }
private void LoadRom() { OpenFileDialog ofd = new OpenFileDialog { Filter = "GBA ROMs|*.gba|All Files|*.*", Title = "Select TMC ROM" }; if (ofd.ShowDialog() != DialogResult.OK) { return; } try { ROM_ = new ROM(ofd.FileName); } catch (Exception e) { Console.WriteLine(e); throw; } if (ROM.Instance.version.Equals(RegionVersion.None)) { MessageBox.Show("Invalid TMC ROM. Please Open a valid ROM.", "Incorrect ROM", MessageBoxButtons.OK); statusText.Text = "Unable to determine ROM."; ROM_ = null; return; } if (!shuffler.RomCrcValid(ROM_)) { Console.WriteLine(StringUtil.AsStringHex8((int)PatchUtil.Crc32(ROM_.romData, ROM_.romData.Length))); MessageBox.Show("ROM does not match the expected CRC for the logic file", "Incorrect ROM", MessageBoxButtons.OK); statusText.Text = "ROM not valid"; ROM_ = null; return; } }
public string GetEventWrites() { StringBuilder eventBuilder = new StringBuilder(); foreach (Location location in Locations) { location.WriteLocationEvent(eventBuilder); } foreach (EventDefine define in LogicParser.GetEventDefines()) { define.WriteDefineString(eventBuilder); } byte[] seedValues = new byte[4]; seedValues[0] = (byte)((Seed >> 00) & 0xFF); seedValues[1] = (byte)((Seed >> 08) & 0xFF); seedValues[2] = (byte)((Seed >> 16) & 0xFF); seedValues[3] = (byte)((Seed >> 24) & 0xFF); eventBuilder.AppendLine("#define seedHashed 0x" + StringUtil.AsStringHex8((int)PatchUtil.Crc32(seedValues, 4))); eventBuilder.AppendLine("#define settingHash 0x" + StringUtil.AsStringHex8((int)GetSettingHash())); return(eventBuilder.ToString()); }