static void MakeIPS(string[] args) { string input = ""; string input2 = ""; string output = ""; Console.WriteLine("Parsing arguments..."); foreach (string a in args) { string ar = a.Trim().ToLower(); if (ar.StartsWith("/original:")) { int idx = ar.IndexOf(':') + 1; input = ar.Substring(idx); } else if (ar.StartsWith("/modified:")) { int idx = ar.IndexOf(':') + 1; input2 = ar.Substring(idx); } if (ar.StartsWith("/output:")) { int idx = ar.IndexOf(':') + 1; output = ar.Substring(idx); } } if (input.Length > 0 && input2.Length > 0) { IPS.Create(input, input2, output); } else { Console.WriteLine("No Input file specified."); } }
static int[] ROMMult = new int[] { 0x25000, 0x50000, 0x100000, 0x200000, 0x300000, 0x400000, 0x50000, 0x60000, 0x70000, 0x80000 }; //Up to 64Mbit static void FinalizeBuild(Build b, string outfile, string outfolder) { DateTime start = DateTime.Now; foreach (section s in b.buildSections) { if (File.Exists(s.path)) { BuildSection(outfile, s.path, b.path, s); } else { if (s.path.Contains("|")) { string[] files = s.path.Split('|'); bool allgood = true; string allfiles = ""; foreach (string fi in files) { if (!File.Exists(outfolder + fi)) { allgood = false; Console.WriteLine(s.path + " - File does not exist."); } else { allfiles += (allfiles == "") ? outfolder + fi : "|" + outfolder + fi; } } if (allgood) { BuildSection(outfile, allfiles, b.path, s); } } else { if (File.Exists(outfolder + s.path)) { BuildSection(outfile, outfolder + s.path, b.path, s); } else { Console.WriteLine(s.path + " - File does not exist."); } } } } if (!(b.revbyteloc == "")) { int offset = 0; try { offset = int.Parse(b.revbyteloc, NumberStyles.HexNumber); } catch { Console.WriteLine("Invalid Revision Offset HEX value."); } if (offset > 0) { byte[] newfile = File.ReadAllBytes(outfile); newfile[offset] = Convert.ToByte(b.revision); File.WriteAllBytes(outfile, newfile); } } Console.WriteLine("Build Sub-Sections Complete (Elapsed: " + GetElapsedTime(start) + ")"); if (b.pad == "true") { //now check to see if the ROM file has grown larger. byte[] newfile = File.ReadAllBytes(outfile); byte[] oldfile = File.ReadAllBytes(outfolder + b.original); if (newfile.Length > oldfile.Length) {//if so, then pad the file to the next Size PadROM(newfile, outfile); } //recalculate checksum SNESChecksum.FixROM(outfile); } //make xdelta and ips patches if specified... if (b.diff.Split('|').Contains("xdelta")) { xDelta.Make(outfolder + b.original, outfile); } if (b.diff.Split('|').Contains("ips")) { IPS.Create(outfolder + b.original, outfile); } }