TXD: Difference between revisions
Jump to navigation
Jump to search
(first draft, overview of chunk types) |
(added basic file structure, clean-up of chunk definitions) |
||
Line 56: | Line 56: | ||
uint8_t data[data_size]; | uint8_t data[data_size]; | ||
} mipmaps[mipmap_count - 1]; | } mipmaps[mipmap_count - 1]; | ||
} | } txd_texture_data_t; | ||
typedef struct txd_extra_info_s { | typedef struct txd_extra_info_s { | ||
Line 63: | Line 63: | ||
uint32_t marker; | uint32_t marker; | ||
uint8_t data[chunk_size]; | uint8_t data[chunk_size]; | ||
} | } txd_extra_info_t; | ||
The basic file structure is (indentation means the chunks are sub-chunks): | |||
* txd_file_t | |||
** txd_info_t | |||
** txd_texture_t | |||
*** txd_texture_data_t | |||
*** txd_extra_info_t | |||
** txd_texture_t | |||
*** txd_texture_data_t | |||
*** txd_extra_info_t | |||
** ... | |||
** txd_extra_info_t | |||
Notes: | |||
* Chunk id's are scope-dependent. For example, within the ''txd_file_t'' chunk, a chunk with id 0x01 is a ''txd_info_t'' chunk, but within a ''txd_texture_t' chunk, id 0x01 is used by ''txd_texture_data_t'' chunks. |
Revision as of 06:17, 30 April 2007
Renderware TeXture Dictionary. Used by the Renderware Game Engine, which is used by games like Grand Theft Auto: San Andreas, Sonic The Hedgehog and NRL Rugby League. The format has undergone some changes over the years. The one described here is that in use by Grand Theft Auto: San Andreas. Other versions might be slightly different.
TXD files consist of chunks and sub-chunks, which are really just chunks encapsulated in the data field of other chunks. All chunks have the following basic structure:
typedef struct txd_chunk_s { uint32_t id; uint32_t chunk_size; // does not include id, chunk_size and marker uint32_t marker; // 0x1803ffff uint8_t data[chunk_size]; } txd_chunk_t
The following chunks are known:
typedef struct txd_file_s { uint32_t id; // 0x16 (22) uint32_t chunk_size // file_size - 12 uint32_t marker; uint8_t data[chunk_size]; }
typedef struct txd_info_s { uint32_t id; // 0x01 (1) uint32_t chunk_size; // 0x04 (4) uint32_t marker; uint16_t count; // number of textures in the dictionary uint16_t unknown; } txd_info_t;
typedef struct txd_texture_s { uint32_t id; // 0x15 (21) uint32_t chunk_size; uint32_t marker; uint8_t data[chunk_size]; } txd_texture_t;
typedef struct txd_texture_data_s { uint32_t id; // 0x01 (1) uint32_t chunk_size; uint32_t marker; uint32_t filter_flags; char texture_name[32]; char alpha_name[32]; uint32_t alpha_flags; uint32_t direct3d_texture_format; // "DXT1", "DXT3" uint16_t width; uint16_t height; uint8_t depth; uint8_t mipmap_count; uint8_t texcode_type; uint8_t flags; uint8_t palette[depth==8 ? 256 * 4 : 0]; uint32_t data_size; uint8_t data[data_size]; struct mipmaps_s { uint32_t data_size; uint8_t data[data_size]; } mipmaps[mipmap_count - 1]; } txd_texture_data_t;
typedef struct txd_extra_info_s { uint32_t id; // 0x03 (3) uint32_t chunk_size; uint32_t marker; uint8_t data[chunk_size]; } txd_extra_info_t;
The basic file structure is (indentation means the chunks are sub-chunks):
- txd_file_t
- txd_info_t
- txd_texture_t
- txd_texture_data_t
- txd_extra_info_t
- txd_texture_t
- txd_texture_data_t
- txd_extra_info_t
- ...
- txd_extra_info_t
Notes:
- Chunk id's are scope-dependent. For example, within the txd_file_t chunk, a chunk with id 0x01 is a txd_info_t chunk, but within a txd_texture_t' chunk, id 0x01 is used by txd_texture_data_t chunks.