Welcome to Data Crystal's new home! Data Crystal is now part of the TCRF family (sort of).
The wiki has recently moved; please report any issues in Discord. Pardon the dust.
The wiki has recently moved; please report any issues in Discord. Pardon the dust.
Sega Ages 2500 Series Vol. 17: Phantasy Star generation:2/Notes
Jump to navigation
Jump to search
Compression
CUE found out the coding algorithm. It's a Lempel-Ziv related one, called Lempel-Ziv Renau.
Structure of files :
- Bytes $0000 to $000a : header
- 2 bytes : signature, always "CM"
- 4 bytes: decoded data length, low endian
- 4 bytes: encoded data length, low endian
- From $000a : ENCODED_DATA
- Then FLAGS. Flags are read bit per bit :
- if bit = 0, then put one byte from ENCODED_DATA and put into DECODED_STREAM
- if bit = 1, then the corresponding half-word in ENCODED_DATA is of the form lllloooooooooooo, where l = length and o = offset. Copy then 'length + 3' bytes from DECODED_STREAM[current_position - offset + 1] to DECODED_STREAM[curent_position].
- Fill the file with $00, up to have a file size dividible by $800.
Files specifications
Graphics files (SGGG)
They are just 256 colors palette indexed bitmap files.
- bytes $0 to $3 : 'SGGG' (identifier)
- bytes $4 to $7 : always 1, usage unknown
- bytes $8 to $9 : width (Little Endian)
- bytes $a to $b : height (LE)
- bytes $c to $f : unknown
- bytes $10 to $410 : palette. Each color is 32b RGBA. Alpha max seems to be $80 (and most colors are alpha max). Colors are stored in a weird way though :
- colors $0 to $7
- colors $10 to $17
- colors $8 to $f
- colors $18 to 1f
- and so on...
- from bytes $410 : bitmap. The picture seems cut in 512×512 blocks in scan order, each of which described row per row, from top to bottom.
For example, a 640×448 bitmap is cut in 2 rects, one with pixels (0 - 511, 0 - 447) and the other (512 - 639, 0 - 447). No bitmap actually need more than 2 rects.