Skip to content

Commit

Permalink
Preliminary Xillia 2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
DaZombieKiller committed Feb 27, 2024
1 parent c066013 commit d73c3cc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion tools/TLTool/DataHeader.InternalHeaderEntry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
using System.Buffers;
using System.IO.Compression;
using LzmaDecoder = SevenZip.Compression.LZMA.Decoder;

Expand Down Expand Up @@ -62,12 +63,22 @@ public Stream OpenRead()
var blockSizes = new ushort[blockCount];
var remaining = uncompressedSize;
decoder.SetDecoderProperties(reader.ReadBytes(5));

for (int i = 0; i < blockSizes.Length; i++)
blockSizes[i] = reader.ReadUInt16();

for (int i = 0; i < blockSizes.Length; i++)
{
if (blockSizes[i] == 0)
{
// If the block size is zero, then the rest of the file is uncompressed.
var buffer = ArrayPool<byte>.Shared.Rent((int)remaining);
stream.ReadExactly(buffer, 0, (int)remaining);
decoded.Write(buffer, 0, (int)remaining);
ArrayPool<byte>.Shared.Return(buffer);
break;
}

decoder.Code(stream, decoded, blockSizes[i], uint.Min(remaining, 0x10000), null);
remaining -= 0x10000;
}
Expand Down

0 comments on commit d73c3cc

Please sign in to comment.