Ejemplo n.º 1
0
        static void FixCheckSum(string[] args)
        {
            string input = "";

            Console.WriteLine("Parsing arguments...");
            foreach (string a in args)
            {
                string ar = a.Trim().ToLower();
                if (ar.StartsWith("/input:")) //the SNES ROM file
                {
                    int idx = ar.IndexOf(':') + 1;
                    input = ar.Substring(idx);
                }
            }
            if (input.Length > 0 && File.Exists(input))
            {
                //ensure ROM is a valid size...
                PadROM(File.ReadAllBytes(input), input);
                SNESChecksum.FixROM(input);
            }
            else
            {
                Console.WriteLine("Invalid argument. No input file specified or file does not exist.");
                return;
            }
        }
Ejemplo n.º 2
0
    /// <summary>
    /// Write to ROM file
    /// </summary>
    public static bool WriteToROM()
    {
        bool goodCheck = IsChecksumGood();

        if (!goodCheck)
        {
            allofROM = SNESChecksum.FixROM(allofROM);
        }
        File.WriteAllBytes(filePath, allofROM);
        return(!goodCheck);
    }
Ejemplo n.º 3
0
        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);
            }
        }