public static Lut CreateLut(string name, uint address, Stream stream) { byte[] tba = new byte[32]; stream.Read(tba, 0, 32); Blob tb = new Blob(address, tba); Lut3D lut3d; if (Lut3D.TrySynthesizeLut3D(out lut3d, name, tb, address)) { return(lut3d); } Lut2D lut2d; if (Lut2D.TrySynthesizeLut2D(out lut2d, name, tb, address)) { return(lut2d); } Lut lut; if (Lut.TrySynthesizeLut(out lut, name, address)) { return(lut); } throw new Exception("Bad lut address!!"); }
public override Table CreateChild(Lut ilut,Definition d) { Lut3D lut = (Lut3D)ilut; xml = new XElement("table"); xml.SetAttributeValue("name", name); xml.SetAttributeValue("address", ilut.dataAddress.ToString("X")); XElement tx = new XElement("table"); tx.SetAttributeValue("name", "X"); tx.SetAttributeValue("address", lut.colsAddress.ToString("X")); tx.SetAttributeValue("elements", lut.cols); xml.Add(tx); XElement ty = new XElement("table"); ty.SetAttributeValue("name", "Y"); ty.SetAttributeValue("address", lut.rowsAddress.ToString("X")); ty.SetAttributeValue("elements", lut.rows); xml.Add(ty); return TableFactory.CreateTable(xml, d); //TODO also set attirbutes and split this up! Copy to table2D!! }
public override Table CreateChild(Lut lut,Definition d) { return base.CreateChild(lut,d); }
public static bool TrySynthesizeLut(out Lut lut, string name, uint da) { lut = new Lut(name, da); return lut.CheckData(); }
public virtual Table CreateChild(Lut lut, Definition d) { XElement xml = new XElement("table"); xml.SetAttributeValue("name", name); xml.SetAttributeValue("address", lut.dataAddress.ToString("X")); return TableFactory.CreateTable(xml, d); //TODO also set attirbutes and split this up! }
public void ExposeTable(string name, Lut lut) { Table baseTable = GetBaseTable(name); if (baseTable != null) { Table childTable = baseTable.CreateChild(lut, this); //TODO: HANDLE STATIC AXES!! if (lut.dataAddress < 0x400000) { //TODO: HANDLE UPDATES TO EXISTING TABLES!!?? if (ExposedRomTables.ContainsKey(childTable.name)) ExposedRomTables.Remove(childTable.name); ExposedRomTables.Add(childTable.name, childTable); } else { if (ExposedRamTables.ContainsKey(childTable.name)) ExposedRamTables.Remove(childTable.name); ExposedRamTables.Add(childTable.name, childTable); } } //if (bt == null) return; //bt.SetAttributeValue("address", lut.dataAddress.ToString("X"));//(System.Int32.Parse(temptable.Value.Attribute("offset").Value.ToString(), System.Globalization.NumberStyles.AllowHexSpecifier) + offset).ToString("X")); //IEnumerable<XAttribute> tempattr = bt.Attributes(); //List<String> remattr = new List<String>(); //foreach (XAttribute attr in tempattr) //{ // if (attr.Name != "address" && attr.Name != "name") // { // remattr.Add(attr.Name.ToString()); // } //} //foreach (String rem in remattr) //{ // bt.Attribute(rem).Remove(); //} //List<String> eleremlist = new List<String>(); //foreach (XElement ele in bt.Elements()) //{ // IEnumerable<XAttribute> childtempattr = ele.Attributes(); // List<String> childremattr = new List<String>(); // if (ele.Name.ToString() != "table") // { // eleremlist.Add(ele.Name.ToString()); // continue; // } // if (ele.Attribute("type").Value.ContainsCI("static")) // { // eleremlist.Add(ele.Name.ToString()); // } // else if (ele.Attribute("type").Value.ContainsCI("x axis")) // { // ele.Attribute("name").Value = "X"; // } // else if (ele.Attribute("type").Value.ContainsCI("y axis")) // { // ele.Attribute("name").Value = "Y"; // } // foreach (XAttribute attr in childtempattr) // { // if (attr.Name != "address" && attr.Name != "name") // { // childremattr.Add(attr.Name.ToString()); // } // } // foreach (String rem in childremattr) // { // ele.Attribute(rem).Remove(); // } //} //foreach (String rem in eleremlist) //{ // bt.Element(rem).Remove(); //} }
/// <summary> /// Try to read the Patch metadata from the file and add this data to table lists. /// </summary> private bool TryParseDefs(Blob metadata, ref int offset, String defPath) { UInt32 cookie = 0; while ((metadata.Content.Count > offset + 8) && metadata.TryGetUInt32(ref cookie, ref offset)) { if (cookie == OpTable3d)//TODO CONDITIONALLY READ LUTS! { string metaString = null; uint metaOffset = 0; if (this.TryReadDefData(metadata, out metaString, out metaOffset, ref offset)) { Blob tableBlob; this.parentMod.TryGetMetaBlob(metaOffset, 10, out tableBlob, this.parentMod.blobList.Blobs); Lut3D lut = new Lut3D(metaString,tableBlob, metaOffset); if (metaString != null) RomLutList.Add(lut); } else { Trace.WriteLine("Invalid definition found."); return false; } } else if (cookie == OpTable2d)//TODO CONDITIONALLY READ LUTS! { string metaString = null; uint metaOffset = 0; if (this.TryReadDefData(metadata, out metaString, out metaOffset, ref offset)) { Blob tableBlob; this.parentMod.TryGetMetaBlob(metaOffset, 10, out tableBlob, this.parentMod.blobList.Blobs); Lut2D lut = new Lut2D(metaString,tableBlob, metaOffset); if (metaString != null) RomLutList.Add(lut); } else { Trace.WriteLine("Invalid definition found."); return false; } } else if (cookie == OpTable1d) { string metaString = null; uint metaOffset = 0; if (this.TryReadDefData(metadata, out metaString, out metaOffset, ref offset)) { Lut lut = new Lut(metaString,metaOffset); if (metaString != null) RomLutList.Add(lut); } else { Trace.WriteLine("Invalid definition found."); return false; } } else if (cookie == OpRAM) { string paramName = null; string paramId = null; uint paramOffset = 0; uint paramLenght = 0; if (this.TryReadDefData(metadata, out paramId, out paramOffset, ref offset)) { if (this.TryReadDefData(metadata, out paramName, out paramLenght, ref offset)) { // found modName, output to string! KeyValuePair<String, Table> tempTable = CreateRomRaiderRamTable(paramName, (int)paramOffset, paramId, (int)paramLenght); if (tempTable.Key != null) this.RamTableList.Add(tempTable.Key, tempTable.Value); } } else { Trace.WriteLine("Invalid definition found."); return false; } } else if (cookie == Mod.endoffile) { break; } } return true; }
public override Table CreateChild(Lut lut,Definition d) { return base.CreateChild(lut,d); //TODO FIX?? AND CHECK FOR STATIC AXES!! }
public static bool TrySynthesizeLut(out Lut lut, string name, uint da) { lut = new Lut(name, da); return(lut.CheckData()); }