PAK Format (The Learning Company)

From ModdingWiki
Jump to navigation Jump to search
PAK Format (The Learning Company)
There is no image of a tileset in this format — upload one!
Format typeTileset
HardwareEGA
Max tile count232-1
PaletteExternal
Tile names?No
Minimum tile size (pixels)0×0
Maximum tile size (pixels)65535×65535
Plane count4
Plane arrangementLinear
Transparent pixels?Palette-based
Hitmap pixels?No
Metadata?None
Supports sub-tilesets?No
Compressed tiles?No
Hidden data?Yes
Games

The PAK Format is used to store multiple 16-color graphics files.

Signature

The format has no signature, however a handful of checks can be used to detect the format:

  • The first value in the offset field should equal 12 + imageCount * 2, i.e. the first image immediately follows the header structure. It is possible to have a valid file without this, however all official files checked so far follow this rule.
  • Four 0xFF bytes should immediately follow the last entry in the offset field.
  • All values in the offset field should be offsets contained within the file.

File format

The file begins with the following structure:

Data type Description
UINT32LE imageCount Number of images in the file
UINT16LE unknown ! Unknown
UINT16LE unknown ! Unknown
UINT16LE offset[imageCount] Offset of image data
UINT32LE end Always 0xFFFFFFFF

The offset field is made up of one UINT16LE for each file (so it will be repeated imageCount times.) The actual value must be multipled by 16 to get the file offset. Each offset is from the start of the file.

Following this structure the image data begins.

Image offset

At the given offset the image data is in the following format:

Data type Description
UINT16LE unknown Always 0x0000
UINT16LE width Image width - 1, in bytes
UINT16LE headerLen ! Header length?
UINT16LE header[headerLen] Header data
BYTE unknown[] ! More data, unknown format/length
BYTE image[] Image data

The image data is in 4bpp linear format, big endian packed. As an example, the values 0x12 0x34 would represent four pixels, left to right, of colour values 1, 2, 3 and 4.

To calculate the image width, take the width field, increment it by one, then double it. For example if width is 5, the image would be (5 + 1) * 2 = 12 pixels wide.

The colour values are not EGA colours, possibly because the same graphics files are used for CGA, EGA and other video adapters. There is possibly a mapping table somewhere which controls which values are mapped to which colours.

Credits

This file format was reverse engineered by Malvineous. 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!)