public static XElement Header(RomMetadata romMetadata, Dictionary <string, int> categories) { return(new XElement("XDFHEADER", new XElement("deftitle", romMetadata.CalibrationID), new XElement("description", ScoobyRom.MainClass.GeneratedBy), new XElement("author", "unknown"), new XElement("baseoffset", 0), // <DEFAULTS datasizeinbits="16" sigdigits="2" outputtype="1" signed="0" lsbfirst="0" float="0" /> new XElement("DEFAULTS", new XAttribute("datasizeinbits", 16), new XAttribute("sigdigits", 2), new XAttribute("outputtype", 1), new XAttribute("signed", 0), new XAttribute("lsbfirst", 0), new XAttribute("float", 0)), // <REGION type="0xFFFFFFFF" startaddress="0x0" size="0x100000" regionflags="0x0" name="Binary File" desc="This region describes the bin file edited by this XDF" /> new XElement("REGION", new XAttribute("type", HexNum(-1)), new XAttribute("startaddress", HexNum(0)), new XAttribute("size", HexNum(romMetadata.Filesize)), new XAttribute("regionflags", HexNum(0)), new XAttribute("name", "Binary File"), new XAttribute("desc", "This region describes the bin file edited by this XDF")), CategoriesDef(categories) )); }
public static XElement Header(RomMetadata romMetadata, Dictionary <string, int> categories) { return new XElement ("XDFHEADER", new XElement ("deftitle", romMetadata.CalibrationID), new XElement ("description", ScoobyRom.MainClass.GeneratedBy), new XElement ("author", "unknown"), new XElement ("baseoffset", 0), // <DEFAULTS datasizeinbits="16" sigdigits="2" outputtype="1" signed="0" lsbfirst="0" float="0" /> new XElement ("DEFAULTS", new XAttribute ("datasizeinbits", 16), new XAttribute ("sigdigits", 2), new XAttribute ("outputtype", 1), new XAttribute ("signed", 0), new XAttribute ("lsbfirst", 0), new XAttribute ("float", 0)), // <REGION type="0xFFFFFFFF" startaddress="0x0" size="0x100000" regionflags="0x0" name="Binary File" desc="This region describes the bin file edited by this XDF" /> new XElement ("REGION", new XAttribute ("type", HexNum (-1)), new XAttribute ("startaddress", HexNum (0)), new XAttribute ("size", HexNum (romMetadata.Filesize)), new XAttribute ("regionflags", HexNum (0)), new XAttribute ("name", "Binary File"), new XAttribute ("desc", "This region describes the bin file edited by this XDF")), CategoriesDef (categories) ); }
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 (); }
public void WriteXml(string path, RomMetadata romMetadata, IList <Table2D> list2D, IList <Table3D> list3D) { XmlTextWriter xw = new XmlTextWriter(path, System.Text.Encoding.UTF8); // necessary, otherwise single line xw.Formatting = Formatting.Indented; var table2DXElements = list2D.Where(t => t.HasMetadata).OrderBy(t => t.Location).Select(t => GetXElement(t)).AsParallel(); var table3DXElements = list3D.Where(t => t.HasMetadata).OrderBy(t => t.Location).Select(t => GetXElement(t)).AsParallel(); XElement romEl = new XElement(X_rom, romMetadata.XElement, TableSearchXElement(), table2DXElements, table3DXElements); XDocument doc = XDoc(romEl); doc.WriteTo(xw); xw.Close(); }
void ParseXml(XElement root) { romMetadata = RomMetadata.FromXML(root.Element("romid")); ParseTableSearch(root.Element(X_tableSearch)); foreach (XElement el in root.Elements()) { if (el.Name == X_table2D) { xml2D.Add(ParseTable2D(el)); } else if (el.Name == X_table3D) { xml3D.Add(ParseTable3D(el)); } } }
public static void WriteXdfFile(string path, RomMetadata romMetadata, Dictionary <string, int> categories, IList<Table2D> list2D, IList<Table3D> list3D) { // TunerPro (v5.00.8853 2015-11-26) parser does not support UTF-8 language encoding! // using Encoding.ASCII results in wrong translation of special characters like "°, ³" XmlTextWriter xw = new XmlTextWriter (path, System.Text.Encoding.GetEncoding ("ISO-8859-1")); // necessary, otherwise single line xw.Formatting = Formatting.Indented; // XDF categories start at 1 var l2D = list2D == null ? null : list2D.Select (t => t.TunerProXdf (categories [t.CategoryForExport] + 1)); var l3D = list3D == null ? null : list3D.Select (t => t.TunerProXdf (categories [t.CategoryForExport] + 1)); XDocument doc = TunerProXdfDocument ( Header (romMetadata, categories), l2D, l3D ); doc.WriteTo (xw); xw.Close (); }
public static void WriteXdfFile(string path, RomMetadata romMetadata, Dictionary <string, int> categories, IList <Table2D> list2D, IList <Table3D> list3D) { // TunerPro (v5.00.8853 2015-11-26) parser does not support UTF-8 language encoding! // using Encoding.ASCII results in wrong translation of special characters like "°, ³" XmlTextWriter xw = new XmlTextWriter(path, System.Text.Encoding.GetEncoding("ISO-8859-1")); // necessary, otherwise single line xw.Formatting = Formatting.Indented; // XDF categories start at 1 var l2D = list2D == null ? null : list2D.Select(t => t.TunerProXdf(categories [t.CategoryForExport] + 1)); var l3D = list3D == null ? null : list3D.Select(t => t.TunerProXdf(categories [t.CategoryForExport] + 1)); XDocument doc = TunerProXdfDocument( Header(romMetadata, categories), l2D, l3D ); doc.WriteTo(xw); xw.Close(); }
public static RomMetadata FromXML(XElement romidElement) { RomMetadata d = new RomMetadata(); if (romidElement == null) { return(d); } d.Xmlid = (string)romidElement.Element(RRX_xmlid); XElement el; el = romidElement.Element(RRX_internalidaddress); if (el != null) { d.CalibrationIDPos = ParseHexInt((string)el, el); } d.CalibrationID = (string)romidElement.Element(RRX_internalidstring); el = romidElement.Element(RRX_ecuid); if (el != null) { d.Romid = ParseHexLong((string)el, el); } d.Year = (string)romidElement.Element(RRX_year); d.Market = (string)romidElement.Element(RRX_market); d.Make = (string)romidElement.Element(RRX_make); d.Model = (string)romidElement.Element(RRX_model); d.Submodel = (string)romidElement.Element(RRX_submodel); d.Transmission = (string)romidElement.Element(RRX_transmission); d.Memmodel = (string)romidElement.Element(RRX_memmodel); d.Flashmethod = (string)romidElement.Element(RRX_flashmethod); return(d); }
public static RomMetadata FromXML(XElement romidElement) { RomMetadata d = new RomMetadata (); if (romidElement == null) return d; d.Xmlid = (string)romidElement.Element (RRX_xmlid); XElement el; el = romidElement.Element (RRX_internalidaddress); if (el != null) d.CalibrationIDPos = ParseHexInt ((string)el, el); d.CalibrationID = (string)romidElement.Element (RRX_internalidstring); el = romidElement.Element (RRX_ecuid); if (el != null) d.Romid = ParseHexLong ((string)el, el); d.Year = (string)romidElement.Element (RRX_year); d.Market = (string)romidElement.Element (RRX_market); d.Make = (string)romidElement.Element (RRX_make); d.Model = (string)romidElement.Element (RRX_model); d.Submodel = (string)romidElement.Element (RRX_submodel); d.Transmission = (string)romidElement.Element (RRX_transmission); d.Memmodel = (string)romidElement.Element (RRX_memmodel); d.Flashmethod = (string)romidElement.Element (RRX_flashmethod); return d; }
void ParseXml(XElement root) { romMetadata = RomMetadata.FromXML (root.Element ("romid")); ParseTableSearch (root.Element (X_tableSearch)); foreach (XElement el in root.Elements ()) { if (el.Name == X_table2D) { xml2D.Add (ParseTable2D (el)); } else if (el.Name == X_table3D) { xml3D.Add (ParseTable3D (el)); } } }
public void WriteXml(string path, RomMetadata romMetadata, IList<Table2D> list2D, IList<Table3D> list3D) { XmlTextWriter xw = new XmlTextWriter (path, System.Text.Encoding.UTF8); // necessary, otherwise single line xw.Formatting = Formatting.Indented; var table2DXElements = list2D.Where (t => t.HasMetadata).OrderBy (t => t.Location).Select (t => GetXElement (t)).AsParallel (); var table3DXElements = list3D.Where (t => t.HasMetadata).OrderBy (t => t.Location).Select (t => GetXElement (t)).AsParallel (); XElement romEl = new XElement (X_rom, romMetadata.XElement, TableSearchXElement (), table2DXElements, table3DXElements); XDocument doc = XDoc (romEl); doc.WriteTo (xw); xw.Close (); }
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 (); }