Tool for encoding and decoding various different compression formats supported by New Super Mario Bros. Wii
  • C 99.9%
  • CMake 0.1%
Find a file
2026-04-30 18:42:09 -04:00
.gitattributes Initial commit 2026-03-04 18:07:16 -05:00
.gitignore Initial commit 2026-03-04 18:07:16 -05:00
ash.c ash: Better and more permissive size checks 2026-03-23 21:21:07 -04:00
asr.c Add ASH compression support 2026-03-23 08:27:45 -04:00
CMakeLists.txt Add ASR0 decompression support 2026-03-21 02:02:54 -04:00
diff.c Avoid casting and reliance on pointer values where possible 2026-03-15 18:59:52 -04:00
huff.c Add ASH compression support 2026-03-23 08:27:45 -04:00
huff.h Add ASH compression support 2026-03-23 08:27:45 -04:00
lh.c Optimize the LZ optimizations 2026-03-18 20:39:37 -04:00
LICENSE Correct name in copyright notice 2026-03-25 00:42:35 -04:00
lrc.c Shorten source file names and fix undefined behavior 2026-03-14 19:49:43 -04:00
lz.c Add ASR compression support 2026-03-21 18:53:18 -04:00
lz.h Add ASR compression support 2026-03-21 18:53:18 -04:00
ncutil.h Add ASH compression support 2026-03-23 08:27:45 -04:00
nsmbw_compress.c Remove excessive argument descriptions 2026-03-23 09:15:52 -04:00
nsmbw_compress.h Add ASH compression support 2026-03-23 08:27:45 -04:00
README.md Remove reference to deleted decomp 2026-04-30 18:42:09 -04:00
rl.c Fix issue with RL compression 2026-03-14 21:00:02 -04:00
szs.c Optimize the LZ optimizations 2026-03-18 20:39:37 -04:00
test.c Add ASH compression support 2026-03-23 08:27:45 -04:00

nsmbw-compress

Tool for encoding and decoding various different compression formats supported by New Super Mario Bros. Wii and other games using the same libraries.

Here's a list of the supported formats:

Format Extension Description Encode Decode Known Uses
lz .LZ Lempel-Ziv Yes Yes New Super Mario Bros. Wii
huff .HUFF Huffman Yes Yes
rl .RL Run-length Yes Yes
lh .LH LZ + Huffman Yes Yes Mario Sports Mix
lrc .LRC LZ + Range Coder No Yes
filter-diff .DIFF Differential Filter Yes Yes
szs .szs SZS/Yaz0 Yes Yes Many first-party Nintendo games
ash .ash ASH0 (LZ + Huffman) Yes Yes Wii Menu
asr .asr ASR0 (LZ + Range Coder) Yes Yes Super Mario Advance 4

Usage

Usage: nsmbw-compress [options] <input> [-o output]
Options:
  -h, --help      Show this help message and exit
  -o, --output    <path> Specify the output file name
  -t, --type      <type> Specify the compression type (see supported types below)
  -x, --uncomp    Decompress the input file instead of compressing
  -l, --lz-mode   <0, 1*, auto> Specify the LZ compression mode
  -b, --huff-size <4, 8, auto*> Specify the bit size for Huffman compression
  -r, --asr-mode  <0, 1, auto*> Specify the mode for ASR compression
  -d, --diff-size <8*, 16> Specify the element size for filter-diff encoding
      --test      Run internal tests and exit
  -v, --verbose   Print verbose output
Supported types for compression:
  lz huff rl lh diff szs ash asr 
Supported types for decompression:
  lz huff rl lh lrc diff szs ash asr

Comparisons

Here is a comparison between compressed sizes of nsmbw-compress, the internal ntcompress tool used by Nintendo, and Cue's Nintendo DS/GBA Compressors for LZ specifically.

The file used here is Kinopio.arc from New Super Mario Bros. Wii, which has an uncompressed size of 381536 bytes. The following table compares the size in bytes of the output of each format:

Format nsmbw-compress ntcompress Cue (lzx)
lz 205415 207455 (+2040) 207177 (+1762)
lz (old-lz11) 212769 214638 (+1869) N/A
huff (4-bit) 345836 345836 (+0) N/A
huff (8-bit) 316208 316208 (+0) N/A
rl 345406 345406 (+0) N/A
lh 158713 166692 (+7979) N/A

In the single-file test, the output of nsmbw-compress is either identical to or smaller than the output of ntcompress in every supported format, with the greatest savings exhibited in LH.

The following table compares the szs format specifically, which was not supported by ntcompress, between nsmbw-compress and Wiimm's SZS Tool (wszst).

Format nsmbw-compress wszst --compr 10 wszst --compr 120
szs 205480 205620 (+140) 205344 (-136)

Wiimm's tool overtakes nsmbw-compress by a fair margin when using the time-consuming backtracking option (specifically --compr 120 in this test). I don't intend to create my own full backtracking alternative, so wszst is still preferred if you need the best possible compression.

Building

Run the following in the repository root:

mkdir build
cd build
cmake ..
cmake --build .

Or simply run your preferred compiler with *.c in the repository root.