# ntrcomp

## Description

`ntrcomp` is a set of tools that creates compressed data in a format that can be handled by the TWL-SDK `MI_Uncompress*()` commands.

## Using the Tool

### Start Command

`% ntrcomp <-d(8|16)|r|l|lex|h(4|8)> [-s] [-<t|T>[width]] [-H] [-A(4|8|16|32)] [-o outputFile] <inputFile>`
% ntrcomp -x [-o outputFile] [-s] <inputFile>

Compresses and converts the input file that is designated by `inputFile` into a designated format. Run-length compression, LZ77 extended compression, Huffman compression, and difference filter conversion are all possible.

With the `-s` option, the message indicating successful compression will not be displayed.

With the -H option, the data size is also appended to the data after expansion occurs. This is because header information is added to the data and compressed.

With the `-A` option, the end of the output file is padded with zeros so that the file size is in alignment with the byte size of the n argument.

With the -o option, the file name of the output file can be designated. If nothing is designated, the output file is created with the name (main portion of the input file name)_(compression method).bin.

With the `-t` or `-T` option, the output file can be created as a C format text file. By adding options (1|2|4), you can choose between types u8, u16, and u32. (The default is u8.)
The output is little-endian with -t and big-endian with -T for u16 and u32.

With the -x option, files compressed using `ntrcomp` can be decompressed on a PC.

### The formats for the designation of the compression method

The following formats can be designated for the compression method:

Options | Conversion Method | Parameters
--- | --- | ---
`-d` | Difference filter | Designates the bit size of the comparison unit { 8 | 16 }
`-r` | Run-length compression | None.
`-h` | Huffman compression | Designates the bit size to encode { 4 | 8 }
`-lex` | LZ77 extended compression | None.
`-l` | LZ77 compression (for backward compatibility) | None.

Although you can expect a higher compression ratio with LZ77 extended compression (lex) as compared to LZ77 compression, the `-l` option is preserved for backward compatibility.
Although either format can be decompressed using the same `MI_UncompressLZ*` line of functions, note that files compressed using LZ77 extended compression cannot be decompressed by programs that use a version of the SDK prior to 4.2.

Although extended LZ compression (-lex) may have a worst-case compression time several times greater than when using conventional LZ compression (-l), and although you can expect compression at more consistent speeds with the conventional version regardless of the data when compressing data at runtime, decompression speed is about the same for both methods.

## Location

`$TwlSDK/tools/bin/ntrcomp.exe`

## See Also

`MI_UncompressHuffman, MI_UncompressRL*, MI_UncompressLZ*`

## Revision History

2007/11/01 Added decompression options, added LZ77 extended compression (lex), deleted the optional parameter for LZ77 compression, added an endian specification to text output options, revised so that 8-byte, 16-byte, and 32-byte alignment can be specified.
2005/03/03 Added descriptions of newly established options.
2004/08/20 Initial version.

CONFIDENTIAL