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