From MultimediaWiki
Jump to navigation Jump to search

IMD is the file extension of a multimedia file format used in a number of Coktel Vision games that was later reworked to VMD.

File Format

All multi-byte numbers are stored in little-endian format. Frame rate is hardcoded to 12 fps.

A IMD file starts with the following 816- (0x330-)byte header:

 bytes 0-1      placeholder for IMD handle
 bytes 2-3      version (or format flags)
 bytes 4-5      total number of frames
 bytes 6-7      top corner coordinate of video frame
 bytes 8-9      left corner coordinate of video frame
 bytes 10-11    width of video frame
 bytes 12-13    height of video frame
 bytes 14-15    unknown flags
 bytes 16-17    position of first frame data in file
 bytes 18-785  256 RGB palette entries, 3 bytes/entry in R-G-B order
 if((version & 0xFF) >= 3){
   2 bytes - count of standard coordinate quads (should be 0 or 1)
   for each quad{
     2 bytes - top corner coordinate
     2 bytes - left corner coordinate
     2 bytes - width
     2 bytes - height
 if((version & 0xFF) >= 4)
   4 bytes - file position of seek table
 if(version & 0x8000)
   4 bytes - file position of frame coordinates table
 if(version & 0x4000){
   2 bytes - sound frequency
   2 bytes - sound chunk size
   2 bytes - sound chunks count (should be < 40)
 if(version & 0x2000){
   2 bytes - frame data size
   if(frame data size == 0){
     4 bytes - frame data size
     4 bytes - video buffer size
     2 bytes - video buffer size

Note that the RGB color components are 6-bit VGA palette components which means that they range from 0..63. The components need to be scaled if they are to be used in rendering typical RGB images where the components are 8 bits.

Seek table consists of 4-byte file offsets to frame data. Frame coordinates table consists of 8 bytes (2-byte entries for top, left, width and height of frame) entries.

Frame format

Looks like each frame consists of chunks starting with 2-byte code:

  • 0xFF00 - one sound chunk
  • 0xFF01 - some sound chunks (the number is specified in header)
  • 0xFFF0 - two bytes of data, unknown
  • 0xFFF1 - chunk size is stored in following 2 bytes
  • 0xFFF3 - chunk size is stored in following 4 bytes
  • 0xFFFD - next two bytes are frame number jump to

Video frame format

First byte of frame data is frame type. Frame flags:

  • frame type & 0x10 means that next 49 bytes after the frame type are palette data
  • frame type & 0x80 means that frame is compressed and should be uncompressed before further processing

Frame coding mode (frame & 0x6F):

  • frame type 0x00 means that
  • frame type 0x01 is delta RLE - if code & 0x80 then copy ((code & 0x7F)+1) bytes from stream, else skip (code + 1) pixels
  • frame type 0x02 means that it is raw frame data
  • frame type 0x42 means that it is raw frame data that frame contains raw data that should be scaled four times horizontally
  • frame types 0x12, 0x22, 0x32, 0x52 and 0x62 mean that frame contains raw data that should be scaled two times vertically
  • another frame types indicate delta RLE (like frame type 0x01) also scaled two times vertically

Frame Uncompressing

It is very similar or identical to VMD uncompressing scheme.

Games Using IMD

These are some of the Coktel Vision computer games that are known to use the VMD file format:

Probably Gobliins 2 and Woodruff too