상속: LookupTable2D
예제 #1
0
        public static LookupTable CreateLookupTable(string name, uint address, Stream stream)
        {
            byte[] tba = new byte[32];
            stream.Read(tba, 0, 32);
            Blob          tb = new Blob(address, tba);
            LookupTable3D lut3d;

            if (LookupTable3D.TrySynthesizeLut3D(out lut3d, name, tb, address))
            {
                return(lut3d);
            }
            LookupTable2D lut2d;

            if (LookupTable2D.TrySynthesizeLut2D(out lut2d, name, tb, address))
            {
                return(lut2d);
            }
            LookupTable lut;

            if (LookupTable.TrySynthesizeLut(out lut, name, address))
            {
                return(lut);
            }
            throw new Exception("Bad lut address!!");
        }
예제 #2
0
 public static bool TrySynthesizeLut3D(out LookupTable3D lut, string name, Blob blob, uint addr)
 {
     lut = new LookupTable3D(name, blob, addr);
     if (lut.CheckData())
     {
         return(true);
     }
     return(false);
 }
예제 #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;
        }
예제 #4
0
 public static bool TrySynthesizeLut3D(out LookupTable3D lut,string name,Blob blob, uint addr)
 {
     lut = new LookupTable3D(name,blob, addr);
     if(lut.CheckData())
         return true;
     return false;
 }