King's Bounty Graphics Format

From ModdingWiki
Jump to navigation Jump to search
King's Bounty Graphics Format
There is no image of a tileset in this format — upload one!
Format typeTileset
HardwareCGA, EGA, VGA
Max tile count65,535
PaletteExternal
Tile names?No
Minimum tile size (pixels)0×0
Maximum tile size (pixels)65,535×65,535
Plane count1
Plane arrangementLinear
Transparent pixels?Unknown
Hitmap pixels?No
Metadata?None
Supports sub-tilesets?No
Compressed tiles?No
Hidden data?No
Games

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.

Compression

All files are compressed as described in the CC Format.

File structure

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.

Header

Data type Name Description
UINT16LE count Number of images in the file
struct Entry entries[] Array of image and mask offsets

Graphic Entry

Data type Name Description
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.

Image formats

Images

Data type Name Description
UINT16LE width Image width, also pitch
UINT16LE height Image height
BYTE data[] Image data

CGA

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.

EGA

Unlike many other DOS games, EGA data is linear too, 4bpp this time.

VGA

King's Bounty VGA palette

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

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). Mask image data are rounded to the nearest 8-byte boundary and are padded with zeroes (i.e. 48x34 = 204 bytes / 8 => 26 = 208 bytes).

Credits

Devised by the openkb project with best regards to the modding community. If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)