Beispiel #1
0
        public override TableMetaData CreateChild(LookupTable ilut,ECUMetaData d)
        {
            //TODO: This is a major KLUDGE.
            if (ilut.GetType() != typeof(LookupTable2D))
                return base.CreateChild(ilut, d);

            XElement xel;
            LookupTable2D lut = (LookupTable2D)ilut;
            xel = new XElement("table");
            xel.SetAttributeValue("name", name);
            xel.SetAttributeValue("address", ilut.dataAddress.ToString("X"));
            if (this.xAxis != null)
            {
                XElement tx = new XElement("table");
                tx.SetAttributeValue("name", "X");
                tx.SetAttributeValue("address", lut.colsAddress.ToString("X"));
                tx.SetAttributeValue("elements", lut.cols);
                xel.Add(tx);
            }
            else
            {
                XElement ty = new XElement("table");
                ty.SetAttributeValue("name", "Y");
                ty.SetAttributeValue("address", lut.colsAddress.ToString("X"));
                ty.SetAttributeValue("elements", lut.cols);
                xel.Add(ty);
            }
            return TableFactory.CreateTable(xel, name, d);
            //TODO also set attirbutes and split this up! Copy to table2D!!
            //return base.CreateChild(lut,d);
            //TODO FIX?? AND CHECK FOR STATIC AXES!!
        }
Beispiel #2
0
 public override TableMetaData CreateChild(LookupTable ilut, ECUMetaData d)
 {
     XElement xel;
     LookupTable3D lut = (LookupTable3D)ilut;
     xel = new XElement("table");
     xel.SetAttributeValue("name", name);
     xel.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);
     xel.Add(tx);
     XElement ty = new XElement("table");
     ty.SetAttributeValue("name", "Y");
     ty.SetAttributeValue("address", lut.rowsAddress.ToString("X"));
     ty.SetAttributeValue("elements", lut.rows);
     xel.Add(ty);
     return TableFactory.CreateTable(xel, name, d);
     //TODO also set attirbutes and split this up! Copy to table2D!!
 }
Beispiel #3
0
        /// <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 (metadata.TryGetUInt32(ref metaOffset, ref offset))
                    {
                        if (this.TryReadDefString(metadata, out metaString, ref offset))
                        {

                            Blob tableBlob;
                            this.parentMod.TryGetMetaBlob(metaOffset, 10, out tableBlob, this.parentMod.blobList.Blobs);
                            LookupTable3D lut = new LookupTable3D(metaString, tableBlob, metaOffset);
                            if (metaString != null) RomLutList.Add(lut);
                        }
                        else
                        {
                            Trace.WriteLine("Invalid definition found.");
                            return false;
                        }
                    }
                    else
                    {
                        Trace.WriteLine("Invalid definition found.");
                        return false;
                    }
                }
                else if (cookie == OpTable2d)//TODO CONDITIONALLY READ LUTS!
                {
                    string metaString = null;
                    uint metaOffset = 0;
                    if (metadata.TryGetUInt32(ref metaOffset, ref offset))
                    {
                        if (this.TryReadDefString(metadata, out metaString, ref offset))
                        {

                            Blob tableBlob;
                            this.parentMod.TryGetMetaBlob(metaOffset, 10, out tableBlob, this.parentMod.blobList.Blobs);
                            LookupTable2D lut = new LookupTable2D(metaString, tableBlob, metaOffset);
                            if (metaString != null) RomLutList.Add(lut);
                        }
                        else
                        {
                            Trace.WriteLine("Invalid definition found.");
                            return false;
                        }
                    }
                    else
                    {
                        Trace.WriteLine("Invalid definition found.");
                        return false;
                    }
                }
                else if (cookie == OpTable1d)
                {
                    string metaString = null;
                    uint metaOffset = 0;
                    if (metadata.TryGetUInt32(ref metaOffset, ref offset))
                    {
                        if (this.TryReadDefString(metadata, out metaString, ref offset))
                        {

                            LookupTable lut = new LookupTable(metaString, metaOffset);
                            if (metaString != null) RomLutList.Add(lut);
                        }
                        else
                        {
                            Trace.WriteLine("Invalid definition found.");
                            return false;
                        }
                    }
                    else
                    {
                        Trace.WriteLine("Invalid definition found.");
                        return false;
                    }
                }
                else if (cookie == OpRAM)
                {
                    string paramName = null;
                    string paramId = null;
                    string paramType = null;
                    uint paramOffset = 0;

                    if (metadata.TryGetUInt32(ref paramOffset, ref offset))
                    {
                        if (this.TryReadDefString(metadata, out paramId, ref offset))
                        {
                            if (this.TryReadDefString(metadata, out paramType, ref offset))
                            {
                                if (this.TryReadDefString(metadata, out paramName, ref offset))
                                {
                                    // found modName, output to string!
                                    KeyValuePair<String, TableMetaData> tempTable = CreateRomRaiderRamTable(paramName, (int)paramOffset, paramId, paramType);
                                    if (tempTable.Key != null) this.RamTableList.Add(tempTable.Key, tempTable.Value);
                                }
                                else
                                {
                                    Trace.WriteLine("Invalid definition found.");
                                    return false;
                                }
                            }
                            else
                            {
                                Trace.WriteLine("Invalid definition found.");
                                return false;
                            }
                        }
                        else
                        {
                            Trace.WriteLine("Invalid definition found.");
                            return false;
                        }
                    }
                    else
                    {
                        Trace.WriteLine("Invalid definition found.");
                        return false;
                    }
                }
                else if (cookie == OpRAMAllBits)
                {
                    string paramName = null;
                    string paramId = null;
                    string paramType = null;
                    uint paramOffset = 0;
                    if (metadata.TryGetUInt32(ref paramOffset, ref offset))
                    {
                        if (this.TryReadDefString(metadata, out paramId, ref offset))
                        {
                            if (this.TryReadDefString(metadata, out paramType, ref offset))
                            {
                                if (this.TryReadDefString(metadata, out paramName, ref offset))
                                {

                                    // found modName, output to string!
                                    int len = Utils.ConvertStorageTypeToIntBytes(paramType);
                                    uint address = paramOffset;
                                    for (int i = 0; i < len; i++)
                                    {

                                        for (int j = 0; j < 8; j++)
                                        {
                                            int bit = ((j) + (8 * (i)));
                                            string bitstring = bit.ToString();
                                            KeyValuePair<String, TableMetaData> tempTable = CreateRomRaiderRamTableBit(paramName + " Bit " + bitstring, (int)address, paramId, j);
                                            if (tempTable.Key != null) this.RamTableList.Add(tempTable.Key, tempTable.Value);

                                        }
                                        address++;
                                    }
                                }
                                else
                                {
                                    Trace.WriteLine("Invalid definition found.");
                                    return false;
                                }
                            }
                            else
                            {
                                Trace.WriteLine("Invalid definition found.");
                                return false;
                            }
                        }
                        else
                        {
                            Trace.WriteLine("Invalid definition found.");
                            return false;
                        }
                    }
                    else
                    {
                        Trace.WriteLine("Invalid definition found.");
                        return false;
                    }
                }
                else if (cookie == OpRAMBit)
                {
                    string paramName = null;
                    string paramId = null;
                    uint paramOffset = 0;
                    uint paramBit = 0;
                    if (metadata.TryGetUInt32(ref paramOffset, ref offset))
                    {
                        if (this.TryReadDefString(metadata, out paramId, ref offset))
                        {
                            if (metadata.TryGetUInt32(ref paramBit, ref offset))
                            {
                                if (this.TryReadDefString(metadata, out paramName, ref offset))
                                {
                                    int bit = bit = Utils.SingleBitBitmaskToBit((int)paramBit);
                                    // found modName, output to string!
                                    KeyValuePair<String, TableMetaData> tempTable = CreateRomRaiderRamTableBit(paramName, (int)paramOffset, paramId, bit);
                                    if (tempTable.Key != null) this.RamTableList.Add(tempTable.Key, tempTable.Value);
                                }
                                else
                                {
                                    Trace.WriteLine("Invalid definition found.");
                                    return false;
                                }
                            }
                            else
                            {
                                Trace.WriteLine("Invalid definition found.");
                                return false;
                            }
                        }
                        else
                        {
                            Trace.WriteLine("Invalid definition found.");
                            return false;
                        }
                    }
                    else
                    {
                        Trace.WriteLine("Invalid definition found.");
                        return false;
                    }
                }
                else if (cookie == Mod.endoffile)
                {
                    break;
                }
            }

            return true;
        }
Beispiel #4
0
        public void ExposeTable(string name, LookupTable lut)
        {
            TableMetaData baseTable = GetBaseTable(name);
            if (baseTable != null)
            {

                TableMetaData 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();
            //}
        }
Beispiel #5
0
 public static bool TrySynthesizeLut(out LookupTable lut, string name, uint da)
 {
     lut = new LookupTable(name, da);
     return(lut.CheckData());
 }
Beispiel #6
0
 public static bool TrySynthesizeLut(out LookupTable lut, string name, uint da)
 {
     lut = new LookupTable(name, da);
     return lut.CheckData();
 }
Beispiel #7
0
 public virtual TableMetaData CreateChild(LookupTable lut, ECUMetaData d)
 {
     XElement xel = new XElement("table");
     xel.SetAttributeValue("name", name);
     xel.SetAttributeValue("address", lut.dataAddress.ToString("X"));
     return TableFactory.CreateTable(xel,name, d);
     //TODO also set attirbutes and split this up!
 }
Beispiel #8
0
 public override TableMetaData CreateChild(LookupTable lut,ECUMetaData d)
 {
     return base.CreateChild(lut,d);
 }