Difference between revisions of "BRRES (File Format)"

From Custom Mario Kart
Jump to navigation Jump to search
m (→‎Links: Removed dead link)
 
(41 intermediate revisions by 13 users not shown)
Line 1: Line 1:
'''BRRES Files''' are used to make objects. They contain models, textures and animations
+
== Overview ==
 +
The '''BRRES''' ('''B'''inary '''R'''evolution '''RES'''ource) are archive-like files containing object data, models, textures, and animations.
  
Known editors:
+
== Format ==
* [[SZS Modifier]]  
+
BRRES files are similar to [[U8]] files. They contain multiple sections, sometimes known as files. The format has been used in many games by Nintendo. This article describes [[Mario Kart Wii]] BRRES files.
  
= Format =
 
BRRES Files are similar to [[SZS (File Format)|SZS Files]]. They contain multiple files, here is the format described.
 
 
== Header ==
 
== Header ==
The header is a 0x10 structure. It is as follows:
+
The file begins with the header. It is a 0x10 structure as follows:
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! Offset
+
! Offset !! Type !! Description
! Type
 
! Description
 
 
|-
 
|-
| 0x00
+
| 0x00 || String || '''File magic'''. ''bres'' in ASCII.
| char[4]
 
| 'BRES' in ASCII; File identifier
 
 
|-
 
|-
| 0x04
+
| 0x04 || UInt16 || {{BOM}}
| int
 
| '''Unknown'''
 
 
|-
 
|-
| 0x08
+
| 0x06 || UInt16 || '''Padding''' (usually 0x0000). Some other formats with similar file header like [[BREFT]]/[[BREFT]] use the field as version number.
| int
 
| Length of the file in bytes.
 
 
|-
 
|-
| 0x0C
+
| 0x08 || UInt32 || '''Length of the file''' in bytes.
| short
 
| Start of the beginning of the rootdata (0x0010)
 
 
|-
 
|-
| 0x0E
+
| 0x0C || UInt16 || '''Offset to root section''' relative to start (usually 0x0010).
| short
 
| Amount of files (+1?)
 
 
|-
 
|-
 +
| 0x0E || UInt16 || '''Number of sections''' (including root).
 +
|-
 +
| 0x10 || colspan=2 {{unknown|End of file header}}
 +
|}
 +
 +
== Sections ==
 +
=== Root ===
 +
The root section of the brres file contains all pointers to files and file names.
 +
The header of the root is 0x8 in length.
 +
{| class="wikitable"
 +
|-
 +
! Offset !! Type !! Description
 +
|-
 +
| 0x00 || String || '''Section magic'''. ''root'' in ASCII.
 +
|-
 +
| 0x04 || UInt32 || '''Length of section''' in bytes.
 
|}
 
|}
  
== Root ==
+
This header is then followed by a [[BRRES Index Group (File Format)|BRRES Index Group]]. The entries in this group are the folders of this brres file, and point to more [[BRRES Index Group (File Format)|BRRES Index Group]]s within the root section. These then point to the actual sections of the BRRES file.
The root of the brres file contains all pointers to files and filenames
+
 
The header of the root is 0x10 in length
+
=== Others ===
 +
Other [[BRRES Sub Files (File Format)|BRRES sections]] tend to be within specific folders, as set out by the root section. The identifiers of these sections, as well as the normal folder and a description are listed below.
 +
BRRES Files contain only a few file formats, they are:
 +
 
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! Offset
+
! Identifier !! Folder !! Subfolder !! Description
! Type
+
|-
! Description
+
| [[MDL0 (File Format)|MDL0]] || 3DModels(NW4R) || – || Model files.
 +
|-
 +
| [[TEX0 (File Format)|TEX0]] ||  Textures(NW4R) || – || Texture files.
 +
|-
 +
| [[SRT0 (File Format)|SRT0]] ||  AnmTexSrt(NW4R) || – || Texture movement animations.
 +
|-
 +
| [[CHR0 (File Format)|CHR0]] || AnmChr(NW4R) || – || Model movement animations.
 +
|-
 +
| [[PAT0 (File Format)|PAT0]] || AnmTexPat(NW4R) || – || Texture swapping animations.
 
|-
 
|-
| 0x00
+
| [[CLR0 (File Format)|CLR0]] || AnmClr(NW4R) || – || Color changing animations.
| char[4]
 
| 'root' in ASCII
 
 
|-
 
|-
| 0x04
+
| [[SHP0 (File Format)|SHP0]] || AnmShp(NW4R) || – || Polygon morphing (used in flags).
| int
 
| Length of rootdata
 
 
|-
 
|-
| 0x08
+
| rowspan = 5 | [[SCN0 (File Format)|SCN0]] || rowspan = 5 | AnmScn(NW4R)
| int
+
| LightSet(NW4R) || rowspan = 5 | Scene file for games with live rendered videos.
| '''Unknown'''
 
 
|-
 
|-
| 0x0C
+
| AmbLights(NW4R)
| int
 
| Amount of folders
 
 
|-
 
|-
 +
| Lights(NW4R)
 +
|-
 +
| Fogs(NW4R)
 +
|-
 +
| Cameras(NW4R)
 +
|-
 +
| PLT0 || Palettes(NW4R) || – || Color Palettes for CI4 and CI8 textures.
 +
|-
 +
| VIS0 || AnmVis(NW4R) || – || Bone visibility. '''Not seen in Mario Kart Wii'''.
 
|}
 
|}
  
=Included Files=
+
== String Table ==
BRRES Files contain only a few file formats, they are:
+
At the end of the BRRES file is a string table. This is a series of 4-byte length prefixed strings, padded to start at four byte offsets. Various sections point to this table, which is how all text in BRRES files is stored.
* MDL0 - Model Files
+
 
* TEX0 - Texture Files
+
== GNU C Header Example ==
* SRT0 - Animation Files
+
<pre>
 +
 
 +
typedef struct brres_header_t
 +
{
 +
    char  magic[4];            // = string "bres"
 +
    u16  bom;                // byte order mark
 +
                              // the data is 'bom' dependent big or little endian
 +
    u16  bom_padding;        // usally 0
 +
    u32  size;                // file size
 +
    u16  root_off;            // offset of root section
 +
    u16  n_sections;          // number of sections
 +
}
 +
__attribute__ ((packed)) brres_header_t;
 +
 
 +
 
 +
typedef struct brres_entry_t
 +
{
 +
    u16  id;                  // entry id
 +
    u16  unknown;            // always 0?
 +
    u16  left_idx;            // index to left element in virtual tree
 +
    u16  right_idx;          // index to right element in virtual tree
 +
    u32  name_off;            // offset into string table
 +
    u32  data_off;            // offset to data
 +
}
 +
__attribute__ ((packed)) brres_entry_t;
 +
 
 +
 
 +
typedef struct brres_group_t
 +
{
 +
    u32            size;      // size of complete group
 +
    u32            n_entries;  // number of entires
 +
    brres_entry_t  entry[0];  // list of entries, N := 1 + n_entries
 +
                              // entry with index #0 is a special
 +
                              // root node not counting in 'n_entries'
 +
}
 +
__attribute__ ((packed)) brres_group_t;
 +
 
 +
 
 +
typedef struct brres_root_t
 +
{
 +
    char          magic[4];  // = string "root"
 +
    u32            size;      // size of complete header
 +
    brres_group_t  group[0];  // first group
 +
}
 +
__attribute__ ((packed)) brres_root_t;
 +
</pre>
 +
 
 +
== Tools ==
 +
The following tools can handle BRRES files:
 +
* [[BrawlBox]], by Kryal and BlackJax
 +
* [[BrawlCrate]], by soopercool101
 +
* [[CTools Pack]], by [[Chadderz]]
 +
* [https://github.com/riidefi/RiiStudio RiiStudio], by [[Riidefi]]
 +
* [[SZS Modifier]], by [[MrBean35000vr]] and Chadderz
 +
* [[Wiimms SZS Tools]], by [[Wiimm]]
 +
 
 +
=== Notes ===
 +
* [[Wiimms SZS Tools]] are able to extract all files of a BRRES file. They are also able to create a complete new BRRES file from scratch by copying the content of a local directory structure.
 +
* [[BrawlBox]] is able to add materials and shaders to models, as well as import new animations and textures into a BRRES. However, it was designed for [[Super Smash Bros. Brawl]], but has support for Mario Kart Wii's files (as of version 0.65b).
 +
 
  
[[Category: File Format]]
+
{{BRRES links}}
 +
[[Category:File Format/Wii]]

Latest revision as of 20:55, 30 December 2023

Overview

The BRRES (Binary Revolution RESource) are archive-like files containing object data, models, textures, and animations.

Format

BRRES files are similar to U8 files. They contain multiple sections, sometimes known as files. The format has been used in many games by Nintendo. This article describes Mario Kart Wii BRRES files.

Header

The file begins with the header. It is a 0x10 structure as follows:

Offset Type Description
0x00 String File magic. bres 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 Padding (usually 0x0000). Some other formats with similar file header like BREFT/BREFT use the field as version number.
0x08 UInt32 Length of the file in bytes.
0x0C UInt16 Offset to root section relative to start (usually 0x0010).
0x0E UInt16 Number of sections (including root).
0x10 End of file header

Sections

Root

The root section of the brres file contains all pointers to files and file names. The header of the root is 0x8 in length.

Offset Type Description
0x00 String Section magic. root in ASCII.
0x04 UInt32 Length of section in bytes.

This header is then followed by a BRRES Index Group. The entries in this group are the folders of this brres file, and point to more BRRES Index Groups within the root section. These then point to the actual sections of the BRRES file.

Others

Other BRRES sections tend to be within specific folders, as set out by the root section. The identifiers of these sections, as well as the normal folder and a description are listed below. BRRES Files contain only a few file formats, they are:

Identifier Folder Subfolder Description
MDL0 3DModels(NW4R) Model files.
TEX0 Textures(NW4R) Texture files.
SRT0 AnmTexSrt(NW4R) Texture movement animations.
CHR0 AnmChr(NW4R) Model movement animations.
PAT0 AnmTexPat(NW4R) Texture swapping animations.
CLR0 AnmClr(NW4R) Color changing animations.
SHP0 AnmShp(NW4R) Polygon morphing (used in flags).
SCN0 AnmScn(NW4R) LightSet(NW4R) Scene file for games with live rendered videos.
AmbLights(NW4R)
Lights(NW4R)
Fogs(NW4R)
Cameras(NW4R)
PLT0 Palettes(NW4R) Color Palettes for CI4 and CI8 textures.
VIS0 AnmVis(NW4R) Bone visibility. Not seen in Mario Kart Wii.

String Table

At the end of the BRRES file is a string table. This is a series of 4-byte length prefixed strings, padded to start at four byte offsets. Various sections point to this table, which is how all text in BRRES files is stored.

GNU C Header Example


typedef struct brres_header_t
{
    char  magic[4];            // = string "bres"
    u16   bom;                 // byte order mark
                               // the data is 'bom' dependent big or little endian
    u16   bom_padding;         // usally 0
    u32   size;                // file size
    u16   root_off;            // offset of root section
    u16   n_sections;          // number of sections
}
__attribute__ ((packed)) brres_header_t;


typedef struct brres_entry_t
{
    u16   id;                  // entry id
    u16   unknown;             // always 0?
    u16   left_idx;            // index to left element in virtual tree
    u16   right_idx;           // index to right element in virtual tree
    u32   name_off;            // offset into string table
    u32   data_off;            // offset to data
}
__attribute__ ((packed)) brres_entry_t;


typedef struct brres_group_t
{
    u32            size;       // size of complete group
    u32            n_entries;  // number of entires
    brres_entry_t  entry[0];   // list of entries, N := 1 + n_entries
                               // entry with index #0 is a special
                               // root node not counting in 'n_entries'
}
__attribute__ ((packed)) brres_group_t;


typedef struct brres_root_t
{
    char           magic[4];   // = string "root"
    u32            size;       // size of complete header
    brres_group_t  group[0];   // first group
}
__attribute__ ((packed)) brres_root_t;

Tools

The following tools can handle BRRES files:

Notes

  • Wiimms SZS Tools are able to extract all files of a BRRES file. They are also able to create a complete new BRRES file from scratch by copying the content of a local directory structure.
  • BrawlBox is able to add materials and shaders to models, as well as import new animations and textures into a BRRES. However, it was designed for Super Smash Bros. Brawl, but has support for Mario Kart Wii's files (as of version 0.65b).


All about BRRES files

BRRES fileIndex GroupSub Files

CHR0CLR0MDL0PAT0SCN0SHP0SRT0TEX0