BRLYT (File Format)

From Custom Mario Kart
Jump to navigation Jump to search

BRLYT files (Binary Revolution LaYouT) are the files used as layout in the Wii system. They manage how the UI TPL images show in the game, with specified flags such as material settings, colors, positions, size, rotations and more. BRLYT files are used with BRLAN animations, BRFNT fonts and also with BRCTR files in Mario Kart Wii. They are always found into blyt folders into U8 files.

File Format

Header

The file starts with a header that is 0x10 bytes long:

Offset Type Description
0x00 String File magic. Always RLYT in ASCII.
0x04 UInt16 Byte order mark (BOM): The value is always 0xFEFF. If value 0xFFFE is read, then the false endian is used. Mario Kart Wii uses nearly always big endian (bytes 0xFE,0xFF).
0x06 UInt16 Version number of the file format. Only seen as 00 0A.
0x08 UInt32 Length of the file in bytes.
0x0C UInt16 Length of this header in bytes.
0x0E UInt16 Number of sections.
0x10 End of file header

After the header follows the sections. BRLYT files constist of many different sections. The section can be identified by checking the first four bytes; it is a magic that identifies the section.

Section Header

Every section starts with the same header

Offset Type Description
0x00 UInt32 Section magic.
0x04 UInt32 Section size.

lyt1

The lyt1 sections comes directly after the header and defines the main layout.

Offset Type Description
0x00 Section Header Header. (Magic lyt1)
0x08 Byte Is Centered.
0x09 Byte[3] Padding.
0x0C Float Width of the layout.
0x10 Float Height of the layout.

usd1

The usd1 section stores user data info defined by the user. The section occurs when a pane has user data stored and then it comes after that section. The section starts with a header as follows:

Offset Type Information
0x00 Section Header Header. (Magic usd1)
0x08 UInt16 Number of user data entries.
0x0A UInt16 Padding.
Entries

An entry can store a string, multiple Int32s or multiple floats. All these entries comes after the header, and then the actual data is stored. Each entry is a structure as follows:

Offset Type Description
0x00 UInt32 Name offset. Points to a null-termined string which is the name of this entry. Relative to the start of this entry.
0x04 UInt32 Data offset. Points to the data of this entry. Relative to the start of this entry.
0x08 UInt16 Number of entries or length if the string if the data is a string.
0x0A Byte Type. 0 = String, 1 = Int32, 2 = Float
0x0B Byte Padding.

Resources

These sections contains info about resources. They are always specified after the lyt section in the order as follows. If a section is not needed (it doesn't contain any entries), then the section is not written to the file.

txl1

The txl1 sections stores TPL filenames. The section starts with a header:

Offset Type Description
0x00 Section Header Header. (Magic txl1)
0x08 UInt16 Number of TPL filenames.
0x0A UInt16 Padding.

After this section header comes the offsets to the strings. Each entry has the following structure.

Offset Type Description
0x00 UInt32 Offset to a TPL filename which is stored as a null-termined string. Relative to the start of the txl1 section.
0x04 UInt32 Padding.

mat1

The mat1 section holds data about materials used in the layout. The section starts with a header:

Offset Type Description
0x00 Section Header Header. (Magic mat1)
0x08 UInt16 N= Number of materials.
0x0A UInt16 Padding;
0x0C UInt32[N] Offsets to the materials. Relative to the start of this section.

Each material is the following structure:

Offset Type Description
0x00 Char[20] Material name.
0x14 Int16[4] Fore Color in RGBA format.
0x1C Int16[4] Back Color in RGBA format.
0x24 Int16[4] Color Register 3 in RGBA format.
0x2C Byte[4] TEV Color 1 in RGBA format.
0x30 Byte[4] TEV Color 2 in RGBA format.
0x34 Byte[4] TEV Color 3 in RGBA format.
0x38 Byte[4] TEV Color 4 in RGBA format.
0x3C UInt32 Bitfield for material structures. After this field, the structures defined in the bitfield are defined.
Bit Flag / data
0-3 Unused.
4 Has Material Color.
5 Unused.
6 Has Channel Control.
7 Has Blend Mode.
8 Has Alpha Compare.
9-13 TEV Stage Count.
14-16 Indirect Texture Stage Count.
17-18 Indirect Texture SRT Count.
19 Has TEV Swap Table.
20-23 TexCoord Gen Count.
24-27 Texture SRT Count.
28-31 Texture Map Count.

Alpha Comparison

Offset Type Description
0x00 Byte Compare conditions. AAAA BBBB

A = Condition 1
B = Condition 0

0x01 Byte Operation.
0x02 Byte Value to operate on for condition 0.
0x03 Byte Value to operate on for condition 1.

Below are the possible comparisons on the values.

Type Description
0x00 Never pass.
0x01 Alpha < Value.
0x02 Alpha <= Value.
0x03 Alpha == Value.
0x04 Alpha != Value.
0x05 Alpha >= Value.
0x06 Alpha > Value.
0x07 Always pass.

Below are the possible operations on the comparisons.

Type Description
0x00 AND.
0x01 OR.
0x02 XOR.
0x03 NOR.

Channel Control

Both sources are indices into the material table.

Offset Type Description
0x00 Byte Color material source.
0x01 Byte Alpha material source.
0x02 UInt16 Padding.

Indirect Texture SRT

There can only be a total of three indirect texture SRTs (Scale, Rotation, Translation).

Offset Type Description
0x00 Float[2] Translation.
0x08 Float Rotation.
0x0C Float[2] Scale.

Indirect Stage

Offset Type Description
0x00 Byte Texture coordinate index.
0x01 Byte Texture map index.
0x02 Byte Wrap S.
0x03 Byte Wrap T.

fnl1

The fnl1 section is a list of fonts.

Offset Type Description
0x00 Section Header Header. (Magic fnl1)
0x08 UInt16 N = Number of fonts.
0x0A UInt16 Padding.

After this section header comes the offsets to the strings. Each entry has the following structure.

Offset Type Description
0x00 UInt32 Offset to a font filename which is stored as a null-termined string. Relative to the start of the fnl1 section.
0x04 UInt32 Padding.

Panes

pan1

The pan1 section contains information about a null pane. All panes should children to a null pane. In Mario Kart Wii this pane is always called "RootPane". The null doesn't show up in game, but it can be animated so that all children to it are also animated. All other panes uses the same structure, but after this more data comes. The section has the following structure:

Offset Type Description
0x00 Section Header Header. (Base Magic pan1)
0x08 Byte Flag (0x1 = Visible, 0x2 = Influenced Alpha, 0x4 = Is Widescreen).
0x09 Byte Origin type.
0x0A Byte Alpha.
0x0B Byte Padding.
0x0C Char[16] Pane name.
0x1C Char[8] User information, stored as a string.
0x24 Float[3] Translation.
0x30 Float[3] Rotation.
0x3C Float[2] Scale.
0x44 Float Width of the pane.
0x48 Float Height of the pane.

pas1

The pas1 section is used as start of pane children data, after this section other panes can be defined as children. pae1 ends it.

Offset Type Description
0x00 String Section magic. Always pas1 in ASCII.
0x04 UInt32 Section size.

pae1

The pae1 section is used to end pane children. pas1 starts it.

Offset Type Description
0x00 String Section magic. Always pae1 in ASCII.
0x04 UInt32 Section size.

pic1

The pic1 section defines a simple image pane. This extends from the normal panel structure.

Offset Type Description
0x00 pan1 Base pane structure.
0x4C Byte[4][4] Vertex colors of the pane in RGBA format.
0x5C UInt16 Material index.
0x5E Byte Number of UV sets.
0x5F Byte Padding

After that the UV sets are specified.

bnd1

The bnd1 section specifies a boundary pane. Its purpose is to delimit the cursor interaction with buttons and the structure is the same as a pan1 pane.

txt1

The txt1 section contains information about a textbox pane. It also stores the text but in Mario Kart Wii it's useless because the text is loaded from a BMG file instead. This extends from the normal panel structure.

Offset Type Description
0x00 pan1 Base pane structure.
0x4C UInt16 String size.
0x4E UInt16 Maximum string size.
0x50 UInt16 Material index.
0x52 UInt16 Font index.
0x54 Byte String origin.
0x55 Byte Line alignment.

0 = Not specified
1 = Left
2 = Center
3 = Right

0x56 UInt16 Padding.
0x58 UInt32 T = Text offset. Relative to the start of this section.
0x5C Byte[4] Top color in RGBA format.
0x60 Byte[4] Bottom color in RGBA format.
0x64 Float Font Size X.
0x68 Float Font Size Y.
0x6C Float Character size.
0x70 Float Line size.
T String Null-termined string of the text in UTF-16.

wnd1

The wnd1 describes a window pane. A window pane is a more advanced image pane, because windows can represent multiple materials. This extends from the normal panel structure.

Window Content

Offset Type Description
0x00 pan1 Base pane structure.
0x4C Float Coordinate 1.
0x50 Float Coordinate 2.
0x54 Float Coordinate 3.
0x58 Float Coordinate 4.
0x5C Byte Number of frames.
0x5D Byte Flag.
0x5E UInt16 Padding.
0x60 UInt32 Offset to window content.
0x64 UInt32 Window frame offsets offset. Points to offsets which points to the window materials. Relative to the start of this section.
0x68 Byte[4][4] Vertex color in RGBA format.
0x78 UInt16 Material index.
0x7A Byte Number of UV sets.
0x7B Byte Padding.

After that the UV sets are specified.

Window Frames

After all of the window contents are identified, the window frames for materials are specified.

Window Frame
Offset Type Description
0x00 UInt16 Material index.
0x02 Byte Flip Type.
0x03 Byte Padding.

Below is a table of possible material flip types.

Type Description
0 None
1 Flip (Horizontal)
2 Flip (Vertical)
3 Rotate 90 Degrees
4 Rotate 180 Degrees
5 Rotate 270 Degrees

Groups

grp1

The grp1 section defines a group.

Offset Type Description
0x00 Section Header Header. (Magic grp1)
0x08 Char[16] Group name.
0x18 UInt16 N = Number of entries.
0x1A UInt16 Padding.
0x1C Char[N][16] An array of entries in this group.

grs1

The grs1 section defines a group of groups. gre1 ends the group of groups.

Offset Type Description
0x00 Section Header Header. (Magic grs1)

gre1

The gre1 section ends a group of groups. grs1 starts the group of groups.

Offset Type Description
0x00 Section Header Header. (Magic gre1)

Common data structures

UV coordinate set

Specifies the UV coordinates for an image. Each entry is a 0x20 byte structure as follows:

Offset Type Description
0x00 Float[2] Top left U and V coordinate.
0x08 Float[2] Top right U and V coordinate.
0x10 Float[2] Bottom left U and V coordinate.
0x18 Float[2] Bottom right U and V coordinate.

Tools

The following tools can handle BRLYT files: