Beispiel #1
0
        public void LoadRom(string path)
        {
            romLoaded = false;
            rom       = new Subaru.File.Rom(path);

            string xmlPath   = PathWithNewExtension(path, ".xml");
            bool   xmlExists = System.IO.File.Exists(xmlPath);

            Subaru.File.RomXml romXml = null;
            if (xmlExists)
            {
                Console.WriteLine("Loading existing XML file " + xmlPath);
                romXml = new Subaru.File.RomXml();
                romXml.Load(xmlPath);
                romMetadata = romXml.RomMetadata;

                tableSearchStart = romXml.TableSearchStart;
                tableSearchEnd   = romXml.TableSearchEnd > romXml.TableSearchStart ? romXml.TableSearchEnd : int.MaxValue;
            }
            else
            {
                Console.WriteLine("No existing XML file has been found!");
                romXml      = null;
                romMetadata = new RomMetadata();
                // search through whole ROM file
                tableSearchStart = 0;
                tableSearchEnd   = int.MaxValue;
            }

            // correct tableSearchEnd if necessary
            tableSearchEnd = tableSearchEnd > tableSearchStart ? tableSearchEnd : int.MaxValue;

            romMetadata.Filesize = (int)rom.Stream.Length;
            //int calIDpos = romMetadata.CalibrationIDPos;

            calIDfromRom = romMetadata.CalibrationIDPos != 0 ? rom.ReadASCII(romMetadata.CalibrationIDPos, 8) : "Unknown";
            if (calIDfromRom != romMetadata.CalibrationID)
            {
                Console.Error.WriteLine("WARNING: Calibration ID mismatch");
            }

            if (this.ProgressChanged != null)
            {
                rom.ProgressChanged += OnProgressChanged;
            }

            rom.FindMaps(tableSearchStart, tableSearchEnd, out list2D, out list3D);

            rom.ProgressChanged -= OnProgressChanged;

            romLoaded = true;

            if (romXml != null)
            {
                romXml.RomStream = rom.Stream;
                romXml.TryMergeWith(list2D);
                romXml.TryMergeWith(list3D);
            }
        }
Beispiel #2
0
        public void LoadRom(string path)
        {
            romLoaded = false;
            rom = new Subaru.File.Rom (path);

            string xmlPath = PathWithNewExtension (path, ".xml");
            bool xmlExists = System.IO.File.Exists (xmlPath);

            Subaru.File.RomXml romXml = null;
            if (xmlExists) {
                Console.WriteLine ("Loading existing XML file " + xmlPath);
                romXml = new Subaru.File.RomXml ();
                romXml.Load (xmlPath);
                romMetadata = romXml.RomMetadata;

                tableSearchStart = romXml.TableSearchStart;
                tableSearchEnd = romXml.TableSearchEnd > romXml.TableSearchStart ? romXml.TableSearchEnd : int.MaxValue;
            } else {
                Console.WriteLine ("No existing XML file has been found!");
                romXml = null;
                romMetadata = new RomMetadata ();
                // search through whole ROM file
                tableSearchStart = 0;
                tableSearchEnd = int.MaxValue;
            }

            // correct tableSearchEnd if necessary
            tableSearchEnd = tableSearchEnd > tableSearchStart ? tableSearchEnd : int.MaxValue;

            romMetadata.Filesize = (int)rom.Stream.Length;
            //int calIDpos = romMetadata.CalibrationIDPos;

            calIDfromRom = romMetadata.CalibrationIDPos != 0 ? rom.ReadASCII (romMetadata.CalibrationIDPos, 8) : "Unknown";
            if (calIDfromRom != romMetadata.CalibrationID)
                Console.Error.WriteLine ("WARNING: Calibration ID mismatch");

            if (this.ProgressChanged != null)
                rom.ProgressChanged += OnProgressChanged;

            rom.FindMaps (tableSearchStart, tableSearchEnd, out list2D, out list3D);

            rom.ProgressChanged -= OnProgressChanged;

            romLoaded = true;

            if (romXml != null) {
                romXml.RomStream = rom.Stream;
                romXml.TryMergeWith (list2D);
                romXml.TryMergeWith (list3D);
            }
        }