PDQ2

From MultimediaWiki
Jump to navigation Jump to search

This is a codec used in DOS and Saturn versions of one game and there's not much known about it (not even the proper name). From compression point of view the codec operates on 4x4 tiles that can be either coded raw or copied from some other place in the frame. DOS version allows additional LZ compression of frame data. Also while Saturn version encodes 16-bit pixels, DOS version works on 8-bit paletted format.

Frame structure (all multi-byte values endianness is native to the platform i.e. LE for DOS and BE for Saturn):

  • 1 byte -- frame type (0 - DOS normal frame, 1 - DOS packed frame, 0x80 - Saturn frame)
  • 2 bytes -- if zero frame should be cleared
  • 2 bytes -- size of opcodes part
  • 2 bytes -- size of motion vectors part
  • 2 bytes -- unknown data part
  • N bytes -- opcodes
  • X bytes -- unknown data
  • M bytes -- MV data
  • P bytes -- colour data

Decoding goes as following: while not all tiles are processed read opcode, depending on it read motion vector or colour data, paint/copy tile (or several, if the opcode signals it).

Known opcodes:

  • 0x85 -- motion tile, motion vector is coded as two signed 16-bit ints
  • 0x86 -- invalid opcode
  • 0x87 -- modifier; read next opcode, its top bit tells if it's a tile run or a tile skip minus one
  • 0x88 -- motion tile, motion vector is coded as two bytes, unsigned for X component and signed for Y component
  • 0x89 -- raw tile, read 16 pixel values from colour data for it
  • 0x8A -- motion tile, motion vector is coded as two bytes, X is in -256..-1 range, Y is in -128..127 range
  • all other opcodes are for motion tiles, coding MV as signed nibbles e.g. 0xC4 corresponds to (4,-4)