Rob Northen compression
From Sega Retro
Rob Northen compression (RNC) is a multi-platform compression format created by Rob Northen in 1991. It is a variant of LZSS and Huffman Coding. 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, Blam! Machinehead, Dungeon Keeper 2, Magic Carpet, Syndicate and Syndicate Wars.
Most RNC compressed files come in a standard 18 byte header:
|Data Type||Description||Size (in Bytes)|
|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.
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.
Method two also consists of a bit stream and a byte stream. It also ignores the first two bits. However, the bit stream is read from left to right as bytes. Also, it does not contain Huffman trees or sub chunks. Instead, it uses a fixed prefix coding in the following format:
|Bit Stream||Byte Stream||Description|
|0||X||Literal Byte X|
|10 + Length + Distance||X||Move Length Bytes from (Distance * 256) + X + 1|
|10111XXXX||XXXX * 4 + 12 Bytes||Get XXXX * 4 + 12 Literal Bytes|
|110||X||Move 2 Bytes from X + 1|
|1110 + Distance||X||Get 3 bytes from (Distance * 256) + X + 1|
|1111 + Distance||X Y||If X != 0, Get Y + 8 Bytes from (Distance * 256) + X + 1|
|11110||0||End of File|
|11111||0||End of pack chunk|
The Length and Distance Codes are the following:
Mega Drive games which use Rob Northen compression
- This list is vastly incomplete; please help expand it.
- 3 Ninjas Kick Back
- Addams Family
- Addams Family Values
- The Adventures of Mighty Max
- Astérix and the Great Rescue
- Astérix and the Power of the Gods
- The Incredible Hulk
- The Itchy & Scratchy Game (unreleased)
- Mr. Nutz
- The Pagemaster
- RoboCop 3
- Spot Goes to Hollywood
- Street Racer
- Tintin in Tibet
- World Championship Soccer II
- rnc_propack_source - fully decompiled RNC ProPack source code: RNC1, RNC2 (packing, unpacking).
- libsyndicate - a library for running Bullfrog game Syndicate, which contains a description of RNC1 files.
- Dungeon Keeper Utilities - Contains an RNC1 compressor/decompressor.
- Pro-Pack - The official DOS/Amiga compressor/decompressor for the RNC format. Contains 68k assembly code for both formats.