Defcon 5 VID

From MultimediaWiki
Jump to navigation Jump to search
  • Company: Millennium Interactive Ltd.
  • Extension: vid

This is a format used in some versions of the game that works by painting frame with square blocks filled with single colour and then painting untouched pixels.

File header:

 2 bytes - number of frames
 2 bytes - frame width divided by 8
 2 bytes - frame height divided by 8
 2 bytes - audio part length
 2 bytes - some palette information
 2 bytes - unknown
 2 bytes - palette start colour
 2 bytes - palette length
 N*3 bytes - VGA palette
 1 byte  - number of tile sizes (usually 5)
 M bytes - tile sizes (usually 32, 16, 8, 4, 2)
 F*2 bytes - frame sizes

Frame data consists of palette update (the same parameters as in the file header), audio data (two chunks of fixed length reported in the header - for each of the channels), and video data.

Video data itself consists of tile painting commands and (optional) leftover pixels. Overall decoding looks like this:

 fill frame with zero values
 for each tile size {
   for (;;) {
     fill = get_byte();
     if (fill == 0) break;
     for (;;) {
       top_offs = get_byte();
       if (top_offs == 0xFF) break;
       offset = top_offs * 256 + get_byte();
       paint square of the current tile size using current fill value at the given offset from the start of the frame
     }
   }
 }
 for each pixel of the frame {
   if (pixel == 0) {
     pixel = get_byte();
   }
 }