CTPK (File Format)

From Wexos's Wiki
(Redirected from CTPK)
Jump to navigationJump to search

CTPK (Citra Texture PacKage) is an archive format used in Nintendo 3DS games, used to store texture data.

File Format

The file byte order is always little endian.

Header

Every CTPK file begins with a 0x20 byte header structure.

Offset Type Description
0x00 Char[4] File magic. Always CTPK in ASCII.
0x04 UInt16 Version number.
0x06 UInt16 Number of Texture Entries.
0x08 UInt32 Texture Data offset.
0x0C UInt32 Size of Texture Data in bytes.
0x10 UInt32 Hash Table offset.
0x14 UInt32 Texture Format Information Table offset.
0x18 Byte[8] Padding.

Texture Entry

Followed by the header, there is an entry for each texture. They have the following tructure:

Offset Type Description
0x00 UInt32 File name offset.
0x04 UInt32 Size of the texture in bytes.
0x08 UInt32 Offset in Texture Data.
0x0C UInt32 Image format.
0x10 UInt16 Width.
0x12 UInt16 Height.
0x14 Byte Mip level.
0x15 Byte Type:
  • 0x0 = Cube map
  • 0x1 = 1D
  • 0x2 = 2D
0x16 UInt16 Cube map flags.
0x18 UInt32 Bitmap size offset, relative to the start of the entry.
0x1C UInt32 Unix timestamp.

Followed by all entries comes all bitmap sizes (UInt32s) and texture file names (null-terminated strings).

Hash Table

This section contains checksums for each texture entry. Each entry of the table is 8 bytes long and has the following structure:

Offset Type Description
0x00 UInt32 CRC32 of the texture file name.
0x04 Int32 Texture index.

Texture Format Information Table

This section contains format and compression information for each texture entry. Each entry of the table is 4 bytes long and has the following structure:

Offset Type Description
0x00 Byte Image format.
0x01 Byte[3] Unknown flags.

Texture Data

This section contains texture data, aligned by 0x80.

Version List

Version Found in
0.1

Tools

The following tools can handle CTPK files:

  • (none)