Welcome to the Creatures Wiki! Log in and join the community.

BLK files

From Creatures Wiki
Jump to navigation Jump to search

BLK files are basically S16 files with a slightly different header, and with slightly incorrect offsets due to the different header. They contain 128x128 sprites which are the 'blocks' which make up the background.

The format is as follows (all values are little-endian):

type description
uint32 RGB pixel format: 0=555, 1=565, 0x1000000=macOS variant (big-endian 555)
uint16 the width of the background, in blocks (not pixels!)
uint16 the height of the background, in blocks (not pixels!)
uint16 the number of sprites in the file (must always equal backgroundwidth * backgroundheight)
Image headers
    uint32 offset of first image data from the start of the file, minus 4.
    uint16 width of first image (always 128px)
    uint16 height of first image (always 128px)
    ... offset, width, and height of rest of images
Image data
    uint16[image width * image height]     Data for first image.

Images are stored as an array of horizontal scanlines.

Each pixel is represented as a 16-bit integer in the format specified in the header.

    ... data for rest of images

The sprites are sorted first vertically, then horizontally (so in an image which was 8 sprites (ie, 8*128 = 1024 pixels) wide and 2 sprites high, you'd get 2 sprites representing the first column, then 2 sprites representing the second column, etc.).

macOS version[edit]

For the Macintosh Creatures Evolution Engine, BLK files use big-endian values instead of little-endian ones. These files can be detected by comparing the first 32-bit little-endian flag value to 0x1000000 (i.e.., the 32-bit big-endian encoding of 0x1). They use the RGB555 format.