ReadASCII() public method

Read raw bytes and convert to string. (Ex: Calibration ID)
public ReadASCII ( long pos, int length ) : string
pos long /// A ///
length int /// A ///
return string
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);

            rom.FindMetadata();

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

            DataFile.RomXml romXml = null;
            if (xmlExists)
            {
                Console.WriteLine("Loading existing XML file " + xmlPath);
                romXml = new DataFile.RomXml();
                romXml.Load(xmlPath);
                romMetadata      = romXml.RomMetadata;
                tableSearchRange = romXml.TableSearchRange;
            }
            else
            {
                Console.WriteLine("No existing XML file has been found!");
                romXml           = null;
                romMetadata      = new DataFile.RomMetadata();
                tableSearchRange = null;
            }

            romMetadata.Filesize = rom.Size;
            int calIDpos = romMetadata.CalibrationIDPos;

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

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

            rom.FindMaps(tableSearchRange, out list2D, out list3D);

            rom.ProgressChanged -= OnProgressChanged;

            romLoaded = true;

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

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

            rom.FindMetadata ();

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

            DataFile.RomXml romXml = null;
            if (xmlExists) {
                Console.WriteLine ("Loading existing XML file " + xmlPath);
                romXml = new DataFile.RomXml ();
                romXml.Load (xmlPath);
                romMetadata = romXml.RomMetadata;
                tableSearchRange = romXml.TableSearchRange;
            } else {
                Console.WriteLine ("No existing XML file has been found!");
                romXml = null;
                romMetadata = new DataFile.RomMetadata ();
                tableSearchRange = null;
            }

            romMetadata.Filesize = rom.Size;
            int calIDpos = romMetadata.CalibrationIDPos;

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

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

            rom.FindMaps (tableSearchRange, out list2D, out list3D);

            rom.ProgressChanged -= OnProgressChanged;

            romLoaded = true;

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

            //PrintSharedStatistics ();
        }
Beispiel #4
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);
            }
        }