compress

fun compress(input: ByteArray, arm9: Boolean = false): ByteArray

Compresses input using BLZ.

Return

The BLZ-encoded byte array. Returns a "not encoded" marker if compression would not reduce the size.

Parameters

input

The raw binary data to compress.

arm9

When true the first 0x4000 bytes are left uncompressed (required for DS ARM9 secure-area binaries). The binary is validated: magic bytes at 0x00/0x04/0x08 must equal 0xE7FFDEFF, the half-word at 0x0C must be 0xDEFF, and the word at 0x7FE must be 0. The secure-area CRC-16 (bytes 0x10–0x7FF) is recalculated and written to 0x0E before compression.

Throws

IllegalArgumentException

if arm9 is true but the binary fails validation.