Mercurial > touhou-doc
annotate 06/pbg3.xhtml @ 13:2925b0e246c6 default tip
Fix a lot of things, and add a TODO.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 17 Feb 2012 12:54:08 +0100 |
parents | b1bec4b5ccf3 |
children |
rev | line source |
---|---|
1
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
1 <?xml version="1.0" encoding="utf-8"?> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
2 <?xml-stylesheet type="text/css" href="../style.css"?> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
3 <!DOCTYPE html> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
5 <head> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
6 <title>PBG3 format</title> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
7 </head> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
8 <body> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
9 <h1>PBG3 format</h1> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
10 <p>The PBG3 format is an archive format used by EoSD.</p> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
11 |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
12 <p>It is a bitstream composed of a header, a file table, and LZSS-compressed files.</p> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
13 |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
14 |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
15 <h2>Reading integers</h2> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
16 <p>Integers in PBG3 files are never signed, they are not byte-aligned, and have a variable size.<br/> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
17 Their size is given by two bits: 00 means the number is stored in one byte, 10 means it is stored in three bytes.</p> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
18 |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
19 <p>Ex:</p> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
20 <pre> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
21 0x0012 is stored as: 0000010010 |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
22 0x0112 is stored as: 010000000100010010 |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
23 </pre> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
24 |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
25 |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
26 <h2>Reading strings</h2> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
27 <p>Strings are stored as standard NULL-terminated sequences of bytes.<br/> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
28 The only catch is they are not byte-aligned.</p> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
29 |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
30 |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
31 <h2>Header</h2> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
32 <p>The header is composed of three fields:</p> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
33 <ul> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
34 <li>magic (string): "PBG3"</li> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
35 <li>number of entries (integer)</li> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
36 <li>offset of the file table (integer)</li> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
37 </ul> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
38 |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
39 <p>The size of the header is thus comprised between 52 bits and 100 bits.</p> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
40 |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
41 |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
42 <h2>File table</h2> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
43 <p>The file table starts at a byte boundary, but as the rest of the file, isn't byte-aligned.<br/> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
44 It consists of a sequence of entries.<br/> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
45 Each entry is composed of five fields:</p> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
46 <ul> |
13
2925b0e246c6
Fix a lot of things, and add a TODO.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
1
diff
changeset
|
47 <li>unknown1 (int): the same for every entry of an archive, and without much change between two archives #TODO</li> |
1
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
48 <li>unknown2 (int) #TODO</li> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
49 <li>checksum (int): simple checksum of compressed data</li> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
50 <li>size (int): size of uncompressed data</li> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
51 <li>name (string): name of the file</li> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
52 </ul> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
53 |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
54 <p>The checksum is a mere sum of the compressed data.<br/> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
55 Files are compressed using the LZSS algorithm, with a dictionary size of 8192 bytes and a minimum matching length of 4 bytes.<br/> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
56 The size of the offset component of (offset, length) tuples is 13 bits, whereas the size of the length component is 4 bits.<br/> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
57 A file ends with a (0, 0) tuple, that is, 18 zero bits.</p> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
58 |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
59 <p>Uncompressing a LZSS-compressed file is quite easy, see lzss.py.</p> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
60 </body> |
b1bec4b5ccf3
Add anm and pbg3 file formats, and improve the std one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
61 </html> |