diff 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
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/06/pbg3.xhtml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<?xml-stylesheet type="text/css" href="../style.css"?>
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+	<head>
+		<title>PBG3 format</title>
+	</head>
+	<body>
+		<h1>PBG3 format</h1>
+		<p>The PBG3 format is an archive format used by EoSD.</p>
+
+		<p>It is a bitstream composed of a header, a file table, and LZSS-compressed files.</p>
+
+
+		<h2>Reading integers</h2>
+		<p>Integers in PBG3 files are never signed, they are not byte-aligned, and have a variable size.<br/>
+		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>
+
+		<p>Ex:</p>
+<pre>
+    0x0012 is stored as: 0000010010
+    0x0112 is stored as: 010000000100010010
+</pre>
+
+
+		<h2>Reading strings</h2>
+		<p>Strings are stored as standard NULL-terminated sequences of bytes.<br/>
+		The only catch is they are not byte-aligned.</p>
+
+
+		<h2>Header</h2>
+		<p>The header is composed of three fields:</p>
+		<ul>
+			<li>magic (string): "PBG3"</li>
+			<li>number of entries (integer)</li>
+			<li>offset of the file table (integer)</li>
+		</ul>
+
+		<p>The size of the header is thus comprised between 52 bits and 100 bits.</p>
+
+
+		<h2>File table</h2>
+		<p>The file table starts at a byte boundary, but as the rest of the file, isn't byte-aligned.<br/>
+		It consists of a sequence of entries.<br/>
+		Each entry is composed of five fields:</p>
+		<ul>
+			<li>unknown1 (int) #TODO</li>
+			<li>unknown2 (int) #TODO</li>
+			<li>checksum (int): simple checksum of compressed data</li>
+			<li>size (int): size of uncompressed data</li>
+			<li>name (string): name of the file</li>
+		</ul>
+
+		<p>The checksum is a mere sum of the compressed data.<br/>
+		Files are compressed using the LZSS algorithm, with a dictionary size of 8192 bytes and a minimum matching length of 4 bytes.<br/>
+		The size of the offset component of (offset, length) tuples is 13 bits, whereas the size of the length component is 4 bits.<br/>
+		A file ends with a (0, 0) tuple, that is, 18 zero bits.</p>
+
+		<p>Uncompressing a LZSS-compressed file is quite easy, see lzss.py.</p>
+	</body>
+</html>