A BLK file contains a set of uncompressed, 128x128 size, 16-bit sprites. They can be in either 555 (15-bit) or 565 (16-bit) color, depending on what the users graphic card needs.
A file is made up of a File Header, a set of Sprite Headers (one for each sprite) and then the data for each sprite.
File Header:
Type | Name | Description |
unsigned int | flags | Bit 1: if set, 565 format, otherwise in 555 format. All other bits are reserved and should be set to zero. |
unsigned short | width | This value is the number of 128x128 blocks which make up the width of the background. |
unsigned short | height | This value is the number of 128x128 blocks which make up the height of the background. |
unsigned short | nosprites | This value is the number of sprites in the file. |
All of the sprites are 128x128. When drawing a background, they are tiled in columns.
Sprite Header:
Type | Name | Description |
unsigned int | offset | The offset into the file where the image data for this sprite is held. Useful if you need to seek to a specific image quickly. |
unsigned short | width | The width of this sprite. |
unsigned short | height | The height of this sprite. |
The actual sprite data is just a raw set of 16-bit color values. The size is (width * height * 2) bytes (*2 due to the fact that the values are shorts, ie 2-byte values).
555 format: bits 0/1/2/3/4 represent the blue value, 5/6/7/8/9 the green and 10/11/12/13/14 the red. Bit 15 should be set to zero.
565 format: bits 0/1/2/3/4 represent the blue value, 5/6/7/8/9/10 the green and 11/12/13/14/15 the red.