KDV
- Company: Nova Logic
- Extension: kdv
There are different formats and flavours of a newer format used in various simulator games by Nova Logic. It seems that the format was tweaked a bit for each new game.
Old KDV
This is an animation format used in Comanche: Maximum Overkill. It employs PCX RLE.
File header (all values are little-endian):
4 bytes - "KRL0" 4 bytes - total contents size 4 bytes - "KDV0" 4 bytes - contents size (the same as above minus eight bytes) 4 bytes - number of frames 4 bytes - data offset 4 bytes - palette offset 4 bytes - width 4 bytes - height N*4 bytes - frame offsets
New KDV
This format uses chunk structure and newer revisions even allow sound data.
All chunk names are in reverse so e.g. header chunk uses "xVDK" tag while frame chunk uses "iVDK" tag.
File should start with a header and a palette chunk (unless it is a 24-bit video) but header chunk may occur in the middle of the file as well.
Header chunk
4 bytes - "xVDK" 4 bytes - size (usually 20 or 28 bytes) 4 bytes - width 4 bytes - height 4 bytes - number of frames (until next header chunk) ... - unknown
Palette chunk
4 bytes - "pVDK" 4 bytes - size N bytes - palette data
Sound chunk
4 bytes - "sVDK" 4 bytes - size N bytes - audio payload
Audio payload is stored in "SAMP" subchunks (one for each channel) with additional 8 bytes before actual PCM data.
8-bit video frame
4 bytes - "iVDK" 4 bytes - size N bytes - frame data
Image is split into 4x4 blocks, each block has a 2-bit opcode associated with it grouped into bytes interspersed with other data bytes. Zero colour value in block painting means that the pixel should be left unchanged.
While the operations remain the same, there are tweaks depending on game:
- Werewolf vs. Comanche reads all four colours per 4-colour block;
- Armored Fist always reserve colour 0 for skips;
- Comanche Gold uses a different meaning for block opcodes and introduces "repeat operation" opcode.
Block operations for old version(s):
- 0 - read 3-4 colours (depending on the game), then 32-bit mask and paint the block using that data;
- 1 - read 2 colours, then 16-bit mask and paint the block using that data;
- 2 - read colour value, if it is non-zero then fill block with it, otherwise read all 16 colours for the block;
- 3 - skip block.
Block operations for the Comanche Gold version:
- 0 - 4-colour pattern fill;
- 1 - 2-colour pattern fill (two same colour values mean raw block instead);
- 2 - fill/skip;
- 3 - repeat previous operation while reading only the new pattern (if applicable).
To give an example, block operation 1 means reading two colours and 16-bit mask and the following "repeat previous operation" will read a new 16-bit mask but keep the same colours (or
Please note that in case of raw block it is treated as an exceptional situation and "previous operation" means last operation that was not a raw block.
24-bit video frame
4 bytes - "i42K" 4 bytes - size N bytes - frame data
Decoding is performed in the same way as Comanche Gold variant but raw block is signalled with six zeroes (two RGB triplets) and the colour reading uses 128-colour circular buffer of previous colours. So if colour value top bit is set, its low bits are cache index, otherwise it is the first byte of RGB triplet. Colours are added to the cache only for fill and 2-colour pattern operations. Raw block reads RGB triplets (and triplet (0,0,0) still means skip).