Exemple #1
0
        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!!");
        }
Exemple #2
0
 public static bool TrySynthesizeLut3D(out Lut3D lut, string name, Blob blob, uint addr)
 {
     lut = new Lut3D(name, blob, addr);
     if (lut.CheckData())
     {
         return(true);
     }
     return(false);
 }
Exemple #3
0
 public static bool TrySynthesizeLut3D(out Lut3D lut,string name,Blob blob, uint addr)
 {
     lut = new Lut3D(name,blob, addr);
     if(lut.CheckData())
         return true;
     return false;
 }
Exemple #4
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 (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;
        }