Difference between revisions of "Rob Northen compression"

From Sega Retro

(Added info about RNC1 compression.)
(Unstubbed. Added some links.)
Line 1: Line 1:
{{stub}}
+
<!--{{stub}}-->
 
'''Rob Northen compression''' ('''RNC''') is a multi-platform compression format created by [[Rob Northen]] in 1991. It is a variant of [[LZSS]] and [[Huffman]]. Decompression libraries have been written for the PC, [[Mega Drive]], Game Boy, SNES and Atari Lynx. RNC is used in a number of games by UK developers (notably Bullfrog and [[Traveller's Tales]]), including ''[[Sonic 3D: Flickies' Island]]'', ''Dungeon Keeper 2'', ''[[Magic Carpet]]'', ''[[Syndicate]]'' and ''Syndicate Wars''.
 
'''Rob Northen compression''' ('''RNC''') is a multi-platform compression format created by [[Rob Northen]] in 1991. It is a variant of [[LZSS]] and [[Huffman]]. Decompression libraries have been written for the PC, [[Mega Drive]], Game Boy, SNES and Atari Lynx. RNC is used in a number of games by UK developers (notably Bullfrog and [[Traveller's Tales]]), including ''[[Sonic 3D: Flickies' Island]]'', ''Dungeon Keeper 2'', ''[[Magic Carpet]]'', ''[[Syndicate]]'' and ''Syndicate Wars''.
  
Line 43: Line 43:
 
** A Huffman code from the bit stream that represents the length - 2 of a distance/length pair.
 
** A Huffman code from the bit stream that represents the length - 2 of a distance/length pair.
  
 
+
==External Links==
 +
*[http://icculus.org/libsyndicate/ libsyndicate] - a library for running Bullfrog game Syndicate, which [http://icculus.org/libsyndicate/libsyndicate.html#htoc6 contains a description of RNC1 files].
 +
* [http://www.yoda.arachsys.com/dk/utils.html Dungeon Keeper Utilities] - Contains an RNC1 compressor/decompressor.
  
 
[[Category:Data Formats]]
 
[[Category:Data Formats]]

Revision as of 19:58, 1 September 2010

Rob Northen compression (RNC) is a multi-platform compression format created by Rob Northen in 1991. It is a variant of LZSS and Huffman. Decompression libraries have been written for the PC, Mega Drive, Game Boy, SNES and Atari Lynx. RNC is used in a number of games by UK developers (notably Bullfrog and Traveller's Tales), including Sonic 3D: Flickies' Island, Dungeon Keeper 2, Magic Carpet, Syndicate and Syndicate Wars.

Header Format

Most RNC compressed files come in a standard 18 byte header:

Data Type Description Size (in Bytes)
Signature ASCII "RNC" 3
Compression Method 1 or 2 (In binary) 1
Uncompressed Size Size of the original file 4
Compressed Size Size of the RNC data (excluding header) 4
Uncompressed CRC Checksum of the original file 2
Compressed CRC Checksum of the RNC data 2
Leeway Difference between compressed and uncompressed data in largest pack chunk (if larger than decompressed data) 1
Pack Chunks Amount of pack chunks 1

Each multi-byte portion of the header is big endian.

Method 1

RNC Method 1 consists of a bit stream and a byte stream. The bit stream is read from right to left, as little endian 16 bit words. The first two bits of the bit stream are ignored.

Each pack chunk contains the following:

  • 3 Huffman trees (one for literal data sizes, one for distance values, and one for length values) in the bit stream. These consist of:
    • A 5 bit value for the amount of leaf nodes in the tree
    • 4 bit values for each node representing their bit depth.
  • One 16 bit value in the bitstream for the amount of subchunks in the pack chunk.
  • The subchunk data, which contains for each subchunk:
    • A Huffman code value from the first tree in the bit stream for the amount of literals in the byte stream.
    • Literals from the byte stream.
    • A Huffman code from the bit stream that represents the distance - 1 of a distance/length pair.
    • A Huffman code from the bit stream that represents the length - 2 of a distance/length pair.

External Links