.LZ

This file type is used by Nintendo in several games to compress files, resulting in reduced disk space. It is also commonly used in Newer Super Mario Bros. Wii v1.30 to compress Wii U8 Archive files (.arc), non-editable map/overworld files for Newer (.kpbin), and other binary files.

The compression algorithm is an invention by Lempel-Ziv (most famously known for LZ77/LZ78), which uses RLE ("Runtime-Length-Encoding") as compression method.

Important Advice: There are typical problems that arise when a user tries to save a custom level uncompressed, please see here: Usage in Newer.

=*.LZ (File Type)= Files with this file type are compressed files, they cannot be edited as-is. The extension  is added to the extension of the encapsulated file.

Some examples of this include:


 * (Wii U8 Archive) becomes
 * (non-editable overworld file) becomes
 * (binary file) becomes

.LZ-encoded files have to be decoded at runtime or sooner. This method is in the base game New Super Mario Bros. Wii, meaning that the game can interpret *.LZ files.

Encode and Decode
Files can be encoded/compressed and decoded/decompressed to/from the .LZ file format by applying the correct algorithm to the data stream.

Please see Programs and Tools for available methods to decode and encode such files.

=Usage in Newer=  .LZ files take precedence over other files with the same name that do not have the .LZ extension. See next chapter (Compressed Assets in Newer) for more info.

In Newer Super Mario Bros. Wii, several files are compressed to the *.LZ format. Those are:


 * .arc (Wii U8 Archive) files in
 * (Backgrounds)
 * (Mod for additional models)
 * (Levels)
 * Some exceptions: (, folders ) are not compressed
 * .kpbin files in
 * (Overworld)
 * files in
 * (Texture for Maps)
 * files in
 * (Texture for Maps)

Compressed Assets in Newer
As we have learned above, LZ files take precedence over other files with the same name that do not have the LZ extension.

Let's do an example. We'll look at, which is the first level in the game. The following files with the same name exist in the  directory: The file with the .LZ extensions has priority and will be loaded by the game. The other file won't be loaded at all.
 * (compressed)
 * (compressed)
 * There are two options to play custom levels (or replace any other LZ-encoded assets):
 * 1) Encode the custom level/tileset/etc with a tool from Programs and Tools, and directly replace the  file.
 * 2) Delete the  file, and save your level/tileset/etc as   uncompressed, replacing the existing file. Consider backing up deleted files.


 * Examples for 2.
 * Delete
 * Save your custom model as
 * Delete
 * Save your custom level as
 * Delete
 * Save your custom background as

=Programs and Tools= Cue's DS/GBA Compressors can compress and decompress the LZ format (as well as others!). It is used by putting the file you wish to compress/decompress into the folder, and using either one of these two commands: Once done, the file will be LZ compressed, or decompressed depending on which one you use. Note that it doesn't automatically add/remove the *.LZ extension for you.

=Algorithm Details=

Lempel-Ziv
LZ77 and LZ78 are the two lossless data compression algorithms published in papers by Abraham Lempel and Jacob Ziv in 1977 and 1978. They are also known as LZ1 and LZ2 respectively. These two algorithms form the basis for many variations including Lempel–Ziv–Welch (LZW), Lempel-Ziv-Storer-Szymanski (LZSS), Lempel-Ziv-Markov chain algorithm (LZMA) and others. Besides their academic influence, these algorithms formed the basis of several ubiquitous compression schemes, including GIF and the DEFLATE algorithm used in Portable Network Graphics (PNG) and Zip (file format).

They are both theoretically dictionary coders. LZ77 maintains a sliding window during compression. This was later shown to be equivalent to the explicit dictionary constructed by LZ78&mdash;however, they are only equivalent when the entire data is intended to be decompressed.

Since LZ77 encodes and decodes from a sliding window over previously seen characters, decompression must always start at the beginning of the input. Conceptually, LZ78 decompression could allow random access to the input if the entire dictionary were known in advance. However, in practice the dictionary is created during encoding and decoding by creating a new phrase whenever a token is output.

Source: Wikipedia