Difference between revisions of "BREFF and BREFT (File Format)"

From Custom Mario Kart
Jump to navigation Jump to search
m
m
Line 286: Line 286:
 
<!-- * [[CTools Pack]], by [[MrBean35000vr]] and [[Chadderz]] -->
 
<!-- * [[CTools Pack]], by [[MrBean35000vr]] and [[Chadderz]] -->
 
* [[Wiimms SZS Tools]], by [[Wiimm]]
 
* [[Wiimms SZS Tools]], by [[Wiimm]]
* [[Brawlbox]], by [[Kryal]] & [[BlackJax]]
+
* [[BrawlBox]], by [[Kryal]] & [[BlackJax]]
  
 
[[category:File Format]]
 
[[category:File Format]]

Revision as of 00:32, 20 December 2012

BREFF and BREFT appears always as pair and always in a subdirectory of ./effect/. BREFF seems to contain control information and BREFT the graphic and texture data.

File Format

File Header

The file begins with the header of 0x10 bytes. The structure is the same as for BRRES files:

Offset Size Description
0x00 4 File identifier: 'REFF' for BREFF and or 'REFT' for BREFT in ASCII.
0x04 2 Byte order mark. 0xFEFF is the big endian byte order, 0xFFFE is little endian.
0x06 2 Value 9 for all files in MKW.
0x08 4 Length of the file in bytes.
0x0c 2 Offset to section header relative to begin of file. (usually 0x0010)
0x0e 2 Number of sections, 1 for all files in MKW.
0x10 End of header

Section Header

All Mario Kart Wii files have only one section. Therefor it is nor clear how multiple sections are combined. Maybe its only a row of sections.

Offset Size Description
0x00 4 File identifier: 'REFF' or 'REFT' in ASCII. Same as file identifier of header.
0x04 4 Length of section in bytes.
0x08 4 O = Offset of sub file list header. The offset is relative to this value.
0x0c 4 Value 0 for all files in MKW.
0x10 4 Value 0 for all files in MKW.
0x14 2 L = Length of name including the terminating NULL byte.
0x16 2 Value 0 for all files in MKW.
0x18 L ASCII name of object, terminated with a NULL byte.
0x18 + L O - L - 0x10 padding, most NULL bytes.
0x08 + O End of section header

Sub File List

Offset Size Description
0x00 4 Size of sub file list and all sub file items.
0x04 2 number of sub files (= number of sub file headers)
0x06 2 unknown
0x08 Start of first sub file item

Sub File Item

The list of sub file items begins direct behind the sub file list (see above). The length of a record depends on the name length and is not aligned. If accessing one of the numeric values (namelength, offset or size), it is important to read and write byte by byte, because some CPUs do not support accessing u16/u32 values on not aligned addresses.

Offset Size Description
0x00 2 L = Length of name including the terminating NULL byte.
0x02 L ASCII name of object, terminated with a NULL byte.
0x02 + L 4 Offset of data. The offset is relative to the beginning of the sub file list.
0x06 + L 4 Size of data in bytes. Add 0x20 for BREFT Files (hey Nintendo: Header size forgotten?)
0x0a + L Start of next sub file item or END OF LIST (not aligned)

Content

Example Listings

The first example listing shows the content of the steam object of Toad's Factory:

* Files of BREFF:rk_steam.breff

 idx     offset/hex  size/hex size/dec magic vers file or directory
-------------------------------------------------------------------------------
  0:       0..     10      10       16  REFF   -  header.bin
  1:      10..     34      24       36  REFF   -  root.bin
  2:      34..     ac      78      120  ...x   -  file-list.bin
  3:       0<       -       0>       -  -      -  files/
  4:      ac..    3ec     340      832  ....   -  files/rk_steam
  5:     3ec..    784     398      920  ....   -  files/rk_steamBAK
  6:     784..    ac4     340      832  ....   -  files/rk_steam0
  7:     ac4..    e64     3a0      928  ....   -  files/rk_steam_Copy_1
  8:     e64..   11a4     340      832  ....   -  files/rk_steam0_Copy

* Files of BREFT:rk_steam.breft

 idx     offset/hex  size/hex size/dec magic vers file or directory
-------------------------------------------------------------------------------
  0:       0..     10      10       16  REFT   -  header.bin
  1:      10..     60      50       80  REFT   -  root.bin
  2:      60..     a0      40       64  ...@   -  file-list.bin
  3:       0<       -       0>       -  -      -  files/
  4:      a0..    8c0     820     2080  ....   -  files/rk_smoke2
  5:     8c0..   10e0     820     2080  ....   -  files/rk_steam

The second example listing shows the content of the flame pool object of different Bowser Castle tracks:

* Files of BREFF:rk_flamePole.breff

 idx     offset/hex  size/hex size/dec magic vers file or directory
-------------------------------------------------------------------------------
  0:       0..     10      10       16  REFF   -  header.bin
  1:      10..     38      28       40  REFF   -  root.bin
  2:      38..     dc      a4      164  ....   -  file-list.bin
  3:       0<       -       0>       -  -      -  files/
  4:      dc..    920     844     2116  ....   -  files/rk_flamePole
  5:     920..   1058     738     1848  ....   -  files/rk_flamePole0
  6:    1058..   16b8     660     1632  ....   -  files/rk_flamePoleS
  7:    16b8..   1d20     668     1640  ....   -  files/rk_flamePoleFoot
  8:    1d20..   223c     51c     1308  ....   -  files/rk_flamePoleFoot0
  9:    223c..   2758     51c     1308  ....   -  files/rk_flamePoleFootS

* Files of BREFT:rk_flamePole.breft

 idx     offset/hex  size/hex size/dec magic vers file or directory
-------------------------------------------------------------------------------
  0:       0..     10      10       16  REFT   -  header.bin
  1:      10..     60      50       80  REFT   -  root.bin
  2:      60..     a0      40       64  ...@   -  file-list.bin
  3:       0<       -       0>       -  -      -  files/
  4:      a0..   10c0    1020     4128  ....   -  files/yoganTest
  5:    10c0..   30e0    2020     8224  ....   -  files/yogan4

BREFF sub files

?

BREFT sub files

A BREFT sub file starts with a header of 32 bytes followed by the texture data. The size of the sub file item only counts the size of the texture data.

Offset Size Description
0x00 4 Unknown (Null for all 1200 BREFT files of MKW)
0x04 2 Width of texture in pixel (values in the range 0x8..0x100)
0x06 2 Height of texture in pixel (values in the range 0x10..0x100)
0x08 4 N = size of texture data.
0x0c 1 Image format of texture (see below for details)

Found in MKW: 7* 0x00, 675* 0x01, 462* 0x03, 5* 0x04, 25* 0x05, 2* 0x06, 24* 0x0e

0x0d 3 Unknown (Null for all 1200 BREFT files of MKW). Perhaps 0x0c is a mistake and a little endian 32-bit number.
0x10 4 Unknown (Null for all 1200 BREFT files of MKW)
0x14 1 Null or the total number of images (main image + mipmaps). In MKW only 2 files has the value of 2 here (factory_course.szs and _d variant, effect/Alarm/rk_alarm.breft, alarmMip). For all other files the value is 0.
0x15 3 Unknown (Null for all 1200 BREFT files of MKW). Perhaps 0x14 is a mistake and a little endian 32-bit number.
0x18 4 Unknown (Null for all 1200 BREFT files of MKW)
0x1c 4 Unknown (Null for all 1200 BREFT files of MKW)
0x20 N Texture data
0x20+N End of sub file

Image Formats

Image Formats
ID Name Bits per pixel Block width Block height Block size Type
0x00 I4 4 8 8 32 bytes Gray
0x01 I8 8 8 4 32 bytes Gray
0x02 IA4 8 8 4 32 bytes Gray + Alpha
0x03 IA8 16 4 4 32 bytes Gray + Alpha
0x04 RGB565 16 4 4 32 bytes Color
0x05 RGB5A3 16 4 4 32 bytes Color + Alpha
0x06 RGBA32 (RGBA8) 32 4 4 64 bytes Color + Alpha
0x08 C4 (CI4) 4 8 8 32 bytes Palette (IA8, RGB565, RGB5A3)
0x09 C8 (CI8) 8 8 4 32 bytes Palette (IA8, RGB565, RGB5A3)
0x0A C14X2 (CI14x2) 16 4 4 32 bytes Palette (IA8, RGB565, RGB5A3)
0x0E CMPR 4 8 8 32 bytes Color + optional Alpha (compressed)

Tools

The following tools can handle BREFF and BREFT files: