Crystal Beans from Dungeon Explorer/Main Data Compression

From Data Crystal
Jump to navigation Jump to search

This is a sub-page of Crystal Beans from Dungeon Explorer.

Overview

The main data compression is a LZSS compression scheme with a dictionary of 4096 bytes initialized to 0. The index is 12 bits initialized to 0xFEE and the length is 4 bits.

Decompression

This is a standard LZSS decompression procedure. The control byte is tested from the least significant to the most significant bit. If the bit is 1, output a literal byte, otherwise read an index/length pair and output length + 3 bytes from the dictionary starting at index. The first byte of the index/length pair is the low byte of the index, the first nibble of the second byte is the upper 4 bits of the index, the second nibble of the second byte is the length (for example, bytes 0xAB 0xCD correspond to index 0xCAB and length 0xD).

Compression

Since the scheme is somewhat standard, the only thing to watch for are the encoding of the control byte and the index/length pair.