Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Sign in or sign up before continuing. Don't have an account yet? Register now to get started.
Register now
Changes
Page history
Add compression raw/data size alignment requirements
authored
Nov 02, 2019
by
Nico Bendlin
Show whitespace changes
Inline
Side-by-side
compression.md
View page @
f84a1be9
...
...
@@ -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 0
7
cmpSize =
7
00 00 00 0
8
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 1
7
identical bytes:
the minimum compressible raw data are 1
8
identical bytes:
01 4C 4F 42 magic
06 method
00 00 1
1
rawSize = 1
7
00 00 1
2
rawSize = 1
8
00 00 00 04 cmpSize = 4
80 flags = 10______
__ literal = __
0
D
01 len/off = 1
6
/-1
0
E
01 len/off = 1
7
/-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
...
...
...
...