DKRDS Tile Layout (File Format)
DKRDS Tile Layout is a nameless file format used in Diddy Kong Racing DS with the purpose of assembling a set of reusable 32x32-pixel tiles for screen backgrounds, such as minimaps. Each tile is composed of a 4x4 grid of 8x8 character tiles sourced from a DKRDS Texture Tileset file. At least two format variants exist, distinguished by their per-entry size. Other filetypes that are commonly associated with tile layouts, and necessary to create screen backgrounds, are DKRDS Tilemap and DKRDS Palette Bank. Its type identifier in assets.bin is 0x00.
File Format
The file byte order is always little endian.
Header
All variants begin with a 4-byte header.
| Offset | Type | Description |
|---|---|---|
| 0x00 | Int32 | Number of tiles (T). |
| 0x04 | End of header | |
Tile Entries
After the header comes the tile entries. The total file size is always 4 + T x size, where size is 32 or 48 depending on the variant.
Variant A
The first variant is used when the sub-tiles carry their own palette in each tilemap value (4bpp mode with per-tile palette selection). It contains a single section of 32-byte entries. Each entry describes one 32x32 tile as 16 tilemap references arranged in a 4-column x 4-row grid (row-major, left-to-right then top-to-bottom).
| Offset | Type | Description |
|---|---|---|
| 0x00 | UInt16[16][T] | Sub-tile entries. |
Sub-tile Entry
Each entry is composed of a reference ID and tile attributes. Only up to 1024 different sub-tile references can be defined. They use the following bit layout:
A A A A B C D D D D D D D D D D 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| Bits | Description |
|---|---|
| 0-3 | Palette ID. Selects one of the 16 palettes from the DKRDS Palette Bank file. |
| 4 | Flip vertical. If 1, it mirrors the 8x8 sub-tile on the Y axis. |
| 5 | Flip horizontal. If 1, it mirrors the 8x8 sub-tile on the X axis. |
| 6-15 | Sub-tile ID. This is the index into the DKRDS Texture Tileset file (0-1023). |
Variant B
The second variant is used when palette and flip information is stored separately from the sub-tile references (4bpp or 8bpp mode). The file is divided into two back-to-back sections (32-byte and 16-byte each) rather than interleaved per-entry data.
| Offset | Type | Description |
|---|---|---|
| 0x00 | UInt16[16][T] | Sub-tile entries. |
| T * 32 | Byte[16][T] | Tile attributes. |
Sub-tile Entry
Each entry contains a direct sub-tile reference. The value here is only a tile index, so up to 65536 different sub-tiles can be referenced in contrast of Variant A's limit of 1024.
| Bits | Description |
|---|---|
| 0-15 | Sub-tile ID. This is the index into the DKRDS Texture Tileset file (0-65535). |
Tile Attribute
Each byte corresponds to a sub-tile and encodes palette and flip data using the following bit layout:
A A B B B B C D 0 1 2 3 4 5 6 7
| Bits | Description |
|---|---|
| 0-1 | Unknown. Changing these values seems to produce no visible difference in-game, but existing files still use different values for each sub-tile. |
| 2-5 | Palette ID. Selects one of the 16 palettes from the DKRDS Palette Bank file. |
| 6 | Flip vertical. If 1, it mirrors the 8x8 sub-tile on the Y axis. |
| 7 | Flip horizontal. If 1, it mirrors the 8x8 sub-tile on the X axis. |
Tools
The following tools can handle DKRDS Tile Layout:
- (none)