King's Bounty Graphics Format
King's Bounty stores all its graphics in external files in this format, packed into group files.
The CGA & EGA graphic files (4 and 16 colors) have the ".4" and ".16" extensions (title.4, title.16) and are kept in the 416.CC file.
The VGA graphic files (256 colors) have the ".256" extension (title.256) and are kept in the 256.CC file, except for endpic.256, which is kept in 416.CC for some reason.
All files are compressed as described in the CC Format.
The file starts with the number of chunks (graphics) in the file, followed by a number of values giving the offset of each chunk and a mask/color key offset.
If a graphic doesn't have a mask (background tile, title screen), the offset for the mask is 0x0000.
|UINT16LE||count||Number of images in the file|
|struct Entry||entries||Array of image and mask offsets|
|UINT16LE||offset||Offset from start of file to image data|
|UINT16LE||mask_offset||Offset from start of file to mask data (0 if no mask)|
For VGA images, mask_offset points somewhere inside the image data, specifying which pixel should be treated as the color key.
|UINT16LE||width||Image width, also pitch|
Image data is Linear CGA.
The actual colours for each pixel depend on the active CGA palette, the game allows up to 8 choices. See wp:Color Graphics Adapter for details.
Unlike many other DOS games, EGA data is linear too, 4bpp this time.
The VGA data is standard 8bpp single-plane data. The palette can be found in MCGA.DRV file, at offset 0x032D. It's in classic VGA format (6-bit RGB).
Masks are always linear 1bpp without the width and height data (the values of the actual image are used). Masks do not exist for VGA graphics, color keys are used instead (see above).
Devised by the openkb project with best regards to the modding community.