File Hosting Not logged in.
Login Register Emblem CTGP-Nitro
234 users
User list
Online users


DS LZ77 is the format of compression employed in various places used by the DS, one such use being compression of NARC files into CARC files.

The compressed file starts off with a magic byte which typically has the value 0x10. The following 3 bytes encode the 24-bit length of the uncompressed data. Following this is the data of the file.
The data is compressed in chunks. Each chunk starts with a header byte, which tells how the chunk is compressed. A chunk has 8 segments, each of which can be compressed or not. A set bit in the header byte signifies a compressed chunk, starting at the most significant bit (left to right). In an uncompressed segment, a single byte is the content of the segment. In a compressed chunk, two bytes make up the segment, however these two bytes are actually a reference to an earlier point in the uncompressed file. The two bytes can be interpreted as a big-endian 16-bit word, where the low 12 bits are an offset (minus 1), and the high 4 bits are a length (minus 3). The number of bytes in the length are copied from the current position in the uncompressed file from offset bytes before the current position. Due to the format of this, the length can be only up to 18 bytes, and the offset can be at most 0x1000 bytes.
Due to the format of the compression, the compressed file can only be up to about 8.5 times smaller than the source file, and up to about 1.1 times the size of the source file.

Last edit by Garhoogin on Mon May 25 00:24:06 CDT 2020