Difference between revisions of "DAT (File Format)"

From Retro Modding Wiki
Jump to: navigation, search
(Created page with "'''DAT''' is the generic file format used in Super Smash Bros. Melee. These files store animations, textures, models, character attributes, subaction bytecode, etc., everythin...")
 
 
Line 107: Line 107:
 
== Symbol Table ==
 
== Symbol Table ==
 
The Symbol Table section starts immediately after the external reference table. This section contains null terminated strings pointed to by entries in the root table.
 
The Symbol Table section starts immediately after the external reference table. This section contains null terminated strings pointed to by entries in the root table.
 +
 +
[[Category:File Formats]]
 +
[[Category:Super Smash Bros. Melee]]

Latest revision as of 17:05, 1 August 2025

DAT is the generic file format used in Super Smash Bros. Melee. These files store animations, textures, models, character attributes, subaction bytecode, etc., everything except for movies and audio. The file format itself does not care about the type of data stored within it, it is simply a generic container format for storing objects and symbols pointing to objects, as well as relocation information.

CDat is a simple open-source C library for reading and modifying dat files.

Format

Every dat file has six sections laid out in order. These six sections are: Header, Data, Relocation Table, Root Table, External Reference Table, and String Table. Each section follows immediately after the previous section.

Header

Always 0x20 bytes.

Offset Size Description
0x0 4 File Size
0x4 4 Data Section Size
0x8 4 Relocation Entry Count
0xC 4 Root Entry Count
0x10 4 External Reference Entry Count
0x14 12 unused

Data

The data section always starts at 0x20 and runs for the length indicated in the header. This is just a large heap of bytes pointed to by the other sections. The dat format is not concerned with the contents of this section.

Relocation Table

The Relocation Table section starts immediately after the data section and runs for 4 * reloc_entry_count bytes. Each entry is a single 4 byte word.

Offset Size Description
0x0 4 Data Offset

This table is used to maintain pointers between objects when loading dat files into memory. For each data offset, the game will add the file pointer to the data word pointed to by each data offset contained in this table. For example:

for (u32 i = 0; i < reloc_entry_count; ++i) {
    u32 reloc_offset = dat_reloc_section[i];
    u32 *reloc_target = (u32*)(data_section + reloc_offset);
    *reloc_target += (u32)dat_file_ptr;
}

Root Table

The Root Table section starts immediately after the relocation table section and runs for 8 * root_entry_count bytes. Each entry is two 4 byte words.

Offset Size Description
0x0 4 Data Offset. This is an offset into the data section.
0x4 4 Symbol Offset. This is an offset into the string table section.

Roots often point to models or arrays of animations. The type of the root node is interpreted at runtime, type information is not stored in the dat file itself.

External Reference Table

This section is very similar to the root table section. It starts immediately after the root table section and runs for 8 * external_ref_entry_count bytes. Each entry is two 4 byte words, exactly the same as the root table section.

This section contains references to root nodes in other dat files.

Symbol Table

The Symbol Table section starts immediately after the external reference table. This section contains null terminated strings pointed to by entries in the root table.