.tpl

From NSMBW Modding Database
Jump to navigation Jump to search

.tpl files are containers for images. They are used in New Super Mario Bros Wii, Mario Kart Wii, and many other games. They are even used in the Wii menu.

TPL stands for Texture Palette Library.

TPL files can be contained within a Wii U8 Archive .arc file, or directly accessible through the filesystem. In NSMBW, .tpl files can be found in several .arc files, for example in openingTitle.arc. The .tpl file here is called wiiMario_Title_logo_local_00.tpl.

.tpl files are usually inside the folder timg, if they are stored inside archives.

In Newer Super Mario Bros Wii, .tpl files can additionally be found in the folder LevelSamples.

File Format

A .tpl file consists of one or more images:

General File Layout
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:

File Header
Offset Size Description
0x00 4 File identifier, originally the version number. Always 0x00 0x20 0xAF 0x30
0x04 4 Number of images. In NSMBW/Newer, this is 1 in most cases.
0x08 4 Offset of the Image Table, always 0x0c in NSMBW.

Image Offset Table

The image table contains one pair of values for each image:

Image Offset Table
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.

Palette Header
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.

Image Header
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.
Source: File Header Information by Tockdom (modified)


Image

The image data itself is encoded using the same implementations of each of the formats as TEX0 files. It can be exported to a .png file.

Tools

The following tools can handle .tpl files: