Lz11Codec
object Lz11Codec
LZ11 (LZX) codec for Nintendo DS files.
Identified by magic byte 0x11. Uses an extended LZ back-reference scheme with three token tiers that allow copy lengths well beyond the 18-byte cap of LZ10, while sharing the same 4096-byte sliding window.
Header (4 bytes, little-endian):
Byte 0 : 0x11
Bytes 1–3 : uncompressed size, 24-bit LEContent copied to clipboard
Flag bytes are processed MSB-first (same as LZ10). A 1-bit introduces a back-reference token; a 0-bit introduces a literal byte.
Back-reference token tiers (chosen by the high nibble of the first token byte):
hi >= 2 → Tier 1 (2 bytes): len = hi + 1 (3–16), dist = (lo12) + 1
hi == 0 → Tier 2 (3 bytes): len = (b0_lo4 << 4 | b1_hi4) + 17 (17–272)
hi == 1 → Tier 3 (4 bytes): len = (b0_lo4 << 12 | b1 << 4 | b2_hi4) + 273Content copied to clipboard
Distance is always stored as (dist − 1) in the low 12 bits of the last two bytes of the token.