# compstatic

## Description

This command is for NITRO ROMs. See `compstatic.TWL` for details on TWL ROMs.

The `compstatic` tool compresses ROM image overlays and static regions loaded by a NITRO application's IPL. Compressing enables you to save ROM capacity.

## Using the Tool

### Start Command

    % compstatic [-d] [-9] [-c] [-a[FILE]] [-F|-eSUFFIX] [-lFILE] STATICMODULE OVERLAYDEFS [OVERLAYTABLE]

or

    % compstatic [-d] [-9] [-c] [-a[FILE]] [-F|-eSUFFIX] [-lFILE] -f RESPONSE_FILE

The `-9` option is used to compress the ROM static region files, specified in `STATICMODULE`, as ARM9 code. The decompression process is integrated with `crt0.o` and the FS library of TWL-SDK, so the application programmer does not need to add any additional operation.

The `–f` option allows the executable and overlay process files targeted for compression to be designated with a file (`RESPONSE_FILE`). Use the file containing recorded target filenames instead of specifying `STATICMODULE OVERLAYDEFS` and `OVERLAYTABLE` with command-line arguments. This `RESPONSE_FILE` used with the `-f` option stores the actual `STATICMODULE`, `OVERLAYDEFS`, and `OVERLAYTABLE` filenames in order and terminates each filename with a `'\0'`. The files designated at this time are considered to be designated with a relative path from the directory where `RESPONSE_FILE` is located.

When the `-c` option is specified, the overlay file specified by `OVERLAYDEFS` is also compressed.

Control the post-compression filenames with the `-e` and `-F` options. If these options are not in place, compression results are output to a file of the original filename but with the extension `_LZ` attached to the end. Use the `-e` option when you want to change this `_LZ` extension. Also, if the the `-F` option is designated, the original file is overwritten with the compressed file.

Specify the `-l` option together with the `-c` option. With these options, you can specify overlay modules to exclude from compression in the list file described later, and pass the list file as a parameter.

The `-a` option enables you to embed the overlay digest value in the static region. Use this to confirm the validity of the overlay module that performs wireless transfer. It is necessary to allocate a region to embed the digest value in advance. When you use the `ARM9-TS-C.lcf.template` to create an LCF file, a linker script is generated that allocates the necessary region. See the description of `makelcf` for more information on creating an LCF file.

Use the `-d` option to output `compstatic` debugging messages. It outputs debugging messages during execution. Normally there is no need to specify this.

The library on the uncompressed side is currently not supported and thus cannot be used for the compression process of the ARM7's static region.

When using TWL-SDK's `make` environment, the ARM9 static region and the overlay compression process are available when some value is defined in the environmental variable `TWL_COMPRESS`.

## Compression Specification List Format

All overlay modules are compressed when the `-c` option is specified. A specific file can be excluded from compression by using the format described below.

This list uses the notation shown below, with the overlay module filename and compression specifier written on a single line and separated by a comma.

    main_overlay_1.sbin, E
    main_overlay_2.sbin, E
    main_overlay_3.sbin, S

For the overlay module filename, enter the filename actually output to `$(BINDIR)` before the file is compressed.

The compression specifier has the following meanings.

`Compression Specifier` | Description
--- | ---
`S` | `SMART`: It applies compression according to the `-c` option. This is the default behavior.
`E` | `EXCLUSION`: It excludes the file from compression.

When the TWL-SDK make environment is used, define both the `COMPSTATIC_SPEC_FILE` and `TWL_COMPRESS` environment variables.

    TWL_COMPRESS         = TRUE
    COMPSTATIC_SPEC_FILE = FilePath

Beginning with TWL-SDK 5.4, a compression specification list file is automatically generated based on parameter information in the LSF file. (See makelcf)
If `COMPSTATIC_SPEC_FILE` is not specified, the automatically generated file is used.

## Location

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

## See Also

`makerom
makelcf`

## Revision History

2009/05/14 Added a description of the `-l` option. In conjunction with that, added a section entitled "Compression Specification List Format"
2008/10/28 Corrected and revised the description of the `-a` option.
2006/05/16 Added a description of the `-f` option.
2004/09/21 Initial version.

CONFIDENTIAL