Skip to content

Common Structures

Gota7 edited this page Nov 27, 2018 · 1 revision

Common Structures

When dealing with various Nintendo-Ware files, you will come across various types of structures that repeat among files. Assume all values are unsigned unless specified with "s" by the size. You will encounter multiple of these per file:

File Header

Every file begins with its own header. The header is always padded to 0x20 bytes.

Offset Size Description
0x00 0x4 Magic String
0x04 0x2 Byte Order, Read In Big Endian. (0xFEFF = Big Endian, 0xFFFE = Little Endian)
0x06 0x2 Size of This Header
0x08 0x4 File Version (See Below)
0x0C 0x4 File Size
0x10 0x2 Number of Blocks
0x12 0x2 Padding
0x14 0xC * Number of Blocks Sized References to The Blocks
---- --- Padding For Alignment

EXPLAIN FILE VERSION HERE.

Block Header

Every single block has this 8-byte header in the front of it. It is its own separate structure, since it is not counted in block offsets. However, it does count to the block's size.

Offset Size Description
0x00 0x4 Magic String
0x04 0x4 Block Size (Including This Structure)

Reference

All references are relative to the beginning of the structure that contains the reference. If the offset is -1 or null, the type id is usually left as 0.

Offset Size Description
0x00 0x2 Reference Identifier
0x02 0x2 Padding
0x04 0x4s Offset To Data

Sized Reference

A reference, but with an extra value for the size of the data. If the offset is -1 or null, the size is also 0xFFFFFFFF.

Offset Size Description
0x00 0x2 Reference Identifier
0x02 0x2 Padding
0x04 0x4s Offset To Data
0x08 0x4 Size of Data

Table

A collection of a data type. Tables are always padded to 0x4 when needed (such as when containing bytes).

Offset Size Description
0x00 0x4 Number of Entries
0x04 --- Entries
---- --- Padding For Alignment

Flag Parameters

Formats, such as B_SAR are very clever when they want to add optional information. They use a flag based system, where a bit set means that a 4-byte value will exist for whatever that flag is for.

Offset Size Description
0x00 0x4 Flag Bits
0x04 --- 4 Byte Entries[Number Of Flag Bits Set]

Say the flag bits were 0b101. There would be two 4-byte values after it, the first one being flag 0, then the second one being flag 2.

Id

When referencing different types of entries, it is more efficient to use just part of a UInt32 rather than dedicate another whole value just to distinguish the type.

0xTTEEEEEE T - Type of entry. E - Entry index.

Clone this wiki locally