We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS

LZ1: Difference between revisions

From SnesLab
Jump to: navigation, search
(Create LZ1 page, mentions of addresses in SMW removed due to discrepencies with the Japanese version)
 
mNo edit summary
Line 41: Line 41:
       LLLLLLLLLL: Length
       LLLLLLLLLL: Length
</pre>
</pre>
== Decompression ==
During the decompression, the decompressed chunks are outputted into a buffer in the RAM.
== Usage ==
== Usage ==



Revision as of 15:52, 7 October 2021

LZ1 or LC_LZ1, as named by Lunar Compress, is a lossless data compression format, used by A Link to the Past to compress graphics. It is also used by Super Mario World japanese version only.

Compression

The compressed data consists of "chunks", each with a header:

bits
76543210
CCCLLLLL

CCC:   Command bits
LLLLL: Length

If the header byte is $FF, the end of the compressed data has been reached, and decompression will be aborted.

Here is a list of commands bits which the LZ1 decompression function can use during the decompression:

000    "Direct Copy"
       Followed by (L+1) bytes of data
001    "Byte Fill"
       Followed by one byte to be repeated (L+1) times
010    "Word Fill"
       Followed by two bytes. Output first byte, then second, then first,
       then second, etc. until (L+1) bytes has been outputted
011    "Increasing Fill"
       Followed by one byte to be repeated (L+1) times, but the byte is
       increased by 1 after each write
100    "Repeat"
       Followed by two bytes (small endian byte order, this being the only difference between LZ1 and LZ2) containing address (in the
       output buffer) to copy (L+1) bytes from
101    (Unused command)
110    (Unused command)
111    "Long length"
       This command has got a two-byte header:
       111CCCLL LLLLLLLL
       CCC:        Real command
       LLLLLLLLLL: Length

Decompression

During the decompression, the decompressed chunks are outputted into a buffer in the RAM.

Usage

You can use the LZ1 compression to mainly compress graphics. Technically you can compress anything with this format, but graphics is preferred due to their big size. Seeing the SNES isn't fast, the decompression takes a while to finish, so whenever you overuse the compression the loading time will increase.

External links

Lunar Compress, a library by FuSoYa made to handle loading various game graphics format, including LZ1.