From SMWiki
Revision as of 08:45, 24 October 2010 by Alcaro (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

LC_RLE1, as named by Lunar Compress, is a lossless data compression format, used by Super Mario World to compress the overworld layer 2 event data's tilemap properties.



The compression is a simple run-length encoding format. It's one-dimensional, which means the decompressed data gets stored normally in the output buffer unlike LC_RLE2.

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

C:       Command bit

Here's a list of the command bit values the LC_RLE1 routine can use during decompression:

0    "Direct Copy"
     Followed by (L+1) bytes of data
1    "RLE"
     Followed by one byte to be repeated (L+1) times

The end of the decompression data is reached when the header byte and the following byte both are $FF. This means that the compression does not support 128 bytes of $FF compressed (because the result will be $FF $FF, which aborts the decompression). However, you can compress 127 bytes instead so that the result becomes $FE $FF)


During the decompression, the decompressed chunks can be outputted into a buffer which is either RAM or SRAM. SMW uses the RAM address $7F:0000 as its decompression buffer. The maximum RLE decompression length is 128 bytes.


You can use the LC_RLE1 compression to mainly compress things like tilemap. Technically you can compress anything with this format, but tilemaps are preferred due to the often-occuring consecutive repeating bytes.


You can see an LC_RLE1 decompression routine setup at SNES $04:DD40. The decompression routine itself is located at SNES $04:DD57. The decompression routine does not support data which crosses bank boundaries. Therefore, you will have to take care of that.

Personal tools