Skip to content
Add compression raw/data size alignment requirements authored by Nico Bendlin's avatar Nico Bendlin
......@@ -6,8 +6,8 @@ struct {
uint8_t magic[3]; // has to be {0x4C, 0x4F, 0x42} ("LOB") for Ambermoon
struct {
uint8_t method; // has to be 6 for Ambermoon
uint8_t rawSize[3]; // big-endian size of uncompressed data
uint8_t cmpSize[4]; // big-endian size of compressed data
uint8_t rawSize[3]; // big-endian size of uncompressed data (even)
uint8_t cmpSize[4]; // big-endian size of compressed data (even)
uint8_t cmpData[cmpSize];
}[count];
};
......@@ -98,36 +98,41 @@ Example stream
==============
The 22 character string "ababababababababababab"
can be compressed (including header) to 19 bytes:
can be compressed (including header) to 20 bytes:
01 4C 4F 42 magic
06 method
00 00 16 rawSize = 22
00 00 00 07 cmpSize = 7
00 00 00 08 cmpSize = 8
D8 flags = 11011___
61 literal = 'a'
62 literal = 'b'
0F 02 len/off = 18/-2
61 literal = 'a'
62 literal = 'b'
__ alignment
Since the header has 12 octets, the first code has to be a literal,
and at least one length-distance pair is required to encode more
raw data than required for the compression header and data stream,
the minimum compressible raw data are 17 identical bytes:
the minimum compressible raw data are 18 identical bytes:
01 4C 4F 42 magic
06 method
00 00 11 rawSize = 17
00 00 12 rawSize = 18
00 00 00 04 cmpSize = 4
80 flags = 10______
__ literal = __
0D 01 len/off = 16/-1
0E 01 len/off = 17/-1
Notes
=====
The Ambermoon in-game decompression routine moves the data in long words
to the end of the in-place buffer. Therefore, cmpSize _and_ rawSize both
have to be even, else an address error is raised on/by MC68000 CPUs.
It is strongly recommended that the size of compressed data in the LOB header
exactly matches file/item size minus the JH/LOB header(s), since it is used
in the original decoder to move the data to the end of the buffer before
......
......