Ejemplo n.º 1
0
            public Header(byte[] bytes)
            {
                magic = EndianBytesOperator.readString(bytes, 0, 4);
                if (magic != "PrOD")
                {
                    throw new InvalidDataException();
                }

                constNum1 = EndianBytesOperator.readUInt(bytes, 0x04);
                if (constNum1 != 0x01000000)
                {
                    throw new InvalidDataException();
                }

                constNum2 = EndianBytesOperator.readUInt(bytes, 0x08);
                if (constNum2 != 0x00000001)
                {
                    throw new InvalidDataException();
                }

                lstUSOffset = EndianBytesOperator.readUInt(bytes, 0x0C);
                fileSize    = EndianBytesOperator.readUInt(bytes, 0x10);
                meshCount   = EndianBytesOperator.readUInt(bytes, 0x14);
                STOffset    = EndianBytesOperator.readUInt(bytes, 0x18);

                NullPadding = EndianBytesOperator.readUInt(bytes, 0x1C);
                if (NullPadding != 0x00000000)
                {
                    throw new InvalidDataException();
                }
            }
Ejemplo n.º 2
0
            public Mesh(byte[] bytes, uint offset, List <string> names, uint stOffset)
            {
                instancesSize = EndianBytesOperator.readUInt(bytes, (int)offset + 0x0);
                size          = 0x10 + instancesSize;

                instancesCount = EndianBytesOperator.readUInt(bytes, (int)offset + 0x04);
                nameOffset     = EndianBytesOperator.readUInt(bytes, (int)offset + 0x08);
                name           = EndianBytesOperator.readString(bytes, (int)(stOffset + nameOffset));
                names.Add(name);

                instances = new List <MeshInstance>();
                for (int i = 0; i < instancesCount; i++)
                {
                    instances.Add(new MeshInstance(bytes, (uint)(offset + 0x10 + MeshInstance.size * i)));
                }
            }
Ejemplo n.º 3
0
        public static byte[] decode(byte[] src)
        {
            if (!IsYaz0(src))
            {
                return(src);
            }

            uint decompressedSize = EndianBytesOperator.readUInt(src, 0x04);

            byte[] dst    = new byte[decompressedSize];
            uint   srcPos = 0x10;
            uint   dstPos = 0;

            byte Opcode = 0x00;
            List <KeyValuePair <int, KeyValuePair <int, int> > > finds = new List <KeyValuePair <int, KeyValuePair <int, int> > >();

            while (true)
            {
                Opcode = src[srcPos];
                srcPos++;
                for (int i = 0; i < 8; i++, Opcode <<= 1)
                {
                    if ((Opcode & 0x80) != 0)
                    {
                        dst[dstPos] = src[srcPos];
                        dstPos++;
                        srcPos++;
                    }
                    else
                    {
                        byte b1 = src[srcPos];
                        byte b2 = src[srcPos + 1];
                        srcPos += 2;

                        uint copyLen = 0;
                        if ((b1 >> 4) == 0)
                        {
                            copyLen = (uint)src[srcPos] + 0x12;
                            srcPos++;
                        }
                        else
                        {
                            copyLen = (uint)(b1 >> 4) + 0x02;
                        }
                        uint dist    = (uint)((b1 & 0x0F) << 8 | b2) + 1;
                        uint copyPos = dstPos - dist;
                        finds.Add(new KeyValuePair <int, KeyValuePair <int, int> >((int)dstPos, new KeyValuePair <int, int>((int)copyPos, (int)copyLen)));
                        for (int j = 0; j < copyLen; j++)
                        {
                            dst[dstPos] = dst[copyPos];
                            dstPos++;
                            copyPos++;
                        }
                    }

                    if (dstPos >= decompressedSize)
                    {
                        return(dst);
                    }
                }
            }
        }