TPL (File Format)
TPL files (Texture Palette Library) are containers for one or more images. They are used in Mario Kart Wii, along with many other games and even the Wii menu. In Mario Kart Wii most TPL files a part of U8 files.
File Format
A TPL file consists of one or more images:
TPL file header | |
Image offset table | |
For each image | Palette header (optional) |
Palette data (optional) | |
Image header | |
Image data |
The file header starts always at offset 0x00. All other part are linked by offsets. All offsets are relative to the beginning of the file header.
File Header
The file header consists of 12 bytes:
Offset | Size | Description |
---|---|---|
0x00 | 4 | File identifier, originally the version number. Always 0x00 0x20 0xAF 0x30 |
0x04 | 4 | Number of images. In MKW this is always 1 with one exception: savebanner.tpl has 2 images. |
0x08 | 4 | Offset of the Image Table, always 0x0c in MKW. |
Image Offset Table
The image table contains one pair of values for each image:
Image | Offset | Size | Description |
---|---|---|---|
Image #0 | 0x00 | 4 | Offset of image header. |
0x04 | 4 | Offset of palette header or NULL. | |
Image #1 | 0x08 | 4 | Offset of image header. |
0x0c | 4 | Offset of palette header or NULL. | |
... |
Palette Header
The palette header usually occurs directly after the file header, at the address specified in the image offset table.
Offset | Size | Description |
---|---|---|
0x00 | 2 | Entry Count |
0x02 | 1 | Unpacked |
0x03 | 1 | 1 byte of padding |
0x04 | 4 | Palette Format |
0x08 | 4 | Palette Data Address |
The palette data address is relative to the start of the file. The palette format values are listed below.
Value | Name |
---|---|
0x00 | IA8 |
0x01 | RGB565 |
0x02 | RGB5A3 |
Image Header
The image header normally occurs after the palette header and data. The image data usually follows, after padding to the nearest 0x20 bytes.
Offset | Type | Description |
---|---|---|
0x00 | u16 | Height |
0x02 | u16 | Width |
0x04 | u32 | Format |
0x08 | u32 | Image Data Address |
0x0C | u32 | WrapS |
0x10 | u32 | WrapT |
0x14 | u32 | MinFilter |
0x18 | u32 | MagFilter |
0x1C | float | LODBias |
0x20 | u8 | EdgeLODEnable |
0x21 | u8 | MinLOD |
0x22 | u8 | MaxLOD |
0x23 | u8 | Unpacked |
The image data address is relative to the start of the file. The image format values are listed below.
ID | Name | Bits per pixel | Block width | Block height | Block size | Type |
---|---|---|---|---|---|---|
0x00 | I4 | 4 | 8 | 8 | 32 bytes | Gray |
0x01 | I8 | 8 | 8 | 4 | 32 bytes | Gray |
0x02 | IA4 | 8 | 8 | 4 | 32 bytes | Gray + Alpha |
0x03 | IA8 | 16 | 4 | 4 | 32 bytes | Gray + Alpha |
0x04 | RGB565 | 16 | 4 | 4 | 32 bytes | Color |
0x05 | RGB5A3 | 16 | 4 | 4 | 32 bytes | Color + Alpha |
0x06 | RGBA32 (RGBA8) | 32 | 4 | 4 | 64 bytes | Color + Alpha |
0x08 | C4 (CI4) | 4 | 8 | 8 | 32 bytes | Palette (IA8, RGB565, RGB5A3) |
0x09 | C8 (CI8) | 8 | 8 | 4 | 32 bytes | Palette (IA8, RGB565, RGB5A3) |
0x0A | C14X2 (CI14x2) | 16 | 4 | 4 | 32 bytes | Palette (IA8, RGB565, RGB5A3) |
0x0E | CMPR | 4 | 8 | 8 | 32 bytes | Color + 1 bit Alpha (compressed) |
Image
The image data itself is encoded using the same implementations of each of the formats as TEX0 files. Detailed explanation of each format is given on the Image Formats page.
Tools
The following tools can handle TPL files:
- BrawlBox, by Kryal and BlackJax96
- CTools Pack, by Chadderz
- SZS Modifier, by Chadderz
- Wiimms SZS Tools, by Wiimm: can convert BREFT, BTI, TEX0, TPL and PNG images in any directions. It may also convert the image and palette formats.
- Wexos's Toolbox, by Wexos