Crusade FPK

From MultimediaWiki
Jump to navigation Jump to search

This is an animation format employed by the game Crusade. This format encodes frame updates with RLE, run lengths and colour values in separate streams, and each stream may be further compressed with LZSS.

File header:

 8 bytes - "FPK_V1.0"
 2 bytes - number of frames
 2 bytes - frames per second

Frame header:

 2 bytes - flags
 2 bytes - frame update start position
 2 bytes - current frame width
 2 bytes - current frame height
 2 bytes - opcodes data size
 2 bytes - colours data size

Flag meanings (in the order they checked):

  • 0x04 - 255-colour VGA palette present
  • 0x10 - frame data present
  • 0x02 - run lengths bitstream is LZSS-compressed
  • 0x01 - colour data is LZSS-compressed

Run lengths bitstream is a mix of bit and nibble values, bits being packed into 32-bit flag words, interspersed with nibble values packed into bytes and bytes values. Encoded values look like this ('0' or '1' mean bit values, <n> means nibble value, <b> means byte value):

  • 0 -- 1
  • 10 <n=0> <b> -- extended length b+20
  • 10 <n> -- extended length n+4
  • 110 -- 2
  • 1110 -- 3
  • 1111 -- 4 (or end of stream)