Crystal Beans From Dungeon Explorer:Cutscene Data Compression

From Data Crystal
Revision as of 17:44, 9 January 2012 by Neige (talk | contribs) (Created page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


The compression scheme used for cutscene data is a LZSS with a 256 bytes dictionary initialized to 0. It uses an 8-bits index initialized to 0xEF and a 4-bits count. It's peculiar in that to avoid wasting a nibble it encodes the count of 2 index/count pair in a single byte.


This is a pretty standard procedure apart from the fact that the count byte must be saved to process a second index/count pair and that a variable is needed to check whether the low or high nibble is to be used.

The most significant nibble is used first, then the least significant one.

The dictionary is initialized to 0 and its index is initialized to 0xEF.

The control byte is checked from the most significant bit to the least significant bit. If the bit is set, output a literal byte, otherwise read the source index byte and the count byte if applicable and output count + 2 bytes from the dictionary starting at index.


For the compression, the location of the count byte within the output must be remembered to update its value when making a second index/count pair.