TIS file format

Applies to:
BG1, BG1: TotS, BG2, BG2: ToB, PST, IWD, IWD:HoW, IWD:TotL, IWD2

General Description
This file format describes a tileset. TIS files are generally comprised of a large number of tiles, each of which consists of a palette and a rectangular block of pixels. Each pixel is an index into the associated palette. Each tile has its own palette and a block of pixels. The pixel data is not compressed. TIS files contain only the graphics for an area - the location information is stored in a .WED file.

Engine specific notes:
• PST can only load TIS files when they are stored in a BIFF file.

Detailed Description
Each tile consists of a 256 colour palette, with each entry being an RGBA value stored in BGRA order (note that the Alpha value is unused), followed by 8-bit pixel values, which are indices into the palette. The pixel values are row by row, from left to right and top to bottom. Index 0 is hardcoded to be the transparent index.

Header

The Header has a constant length of 18h bytes.

Offset Size (data type) Description
0x0000 (4 char ) Signature ('TIS ')
0x0004 (4 char) Version ('V1  ')
0x0008 (4 dword) Count of tiles within this tileset
0x000c (4 dword) Length of tiles section
0x0010 (4 dword) Size of the header (offset to tiles)
0x0014 (4 dword) Dimension of 1 tile in pixels (64x64)

The tile data itself always starts at 0x18.
  • One tile inside TIS files is 0x000c offset value  bytes long
  • All tiles are composed of 0x0014 offset value pixels
  • Usually in areas that contain doors/ overlays areas there are several more tiles than it may be visible on main area
  • Such a tile has size :   (Width(in tiles)*Height(in tiles) + DoorsTilesClosedState + OverlayShapesTiles) *(offset 0x000c value) bytes
  • The special "green" colour is used to mark overlay areas in OverlayShapesTiles
  • DoorTilesClosedState and OverlayShapesTiles are also referenced from WED files but as the alternative tiles from Tilemap structure and their appearance is defined by offset 0x0006 of this structure