U8 (File Format)

From Custom Mario Kart
(Redirected from U8)
Jump to: navigation, search

An U8 file is an archive containing a hierarchical file system. In Mario Kart Wii all U8 files are compressed using the YAZ0 format and stored as SZS files. For publishing track files it is better to use the WU8 format to avoid/reduce license conflicts. See »File format: U8 archives« for details.



U8 header

The header of a U8 file is 16 bytes long. All numeric values stored as big endian values.

Offset Type Description
0x00 u32 Always 0x55AA382D = 'U.8-'
0x04 u32 Offset of first node, in Mario Kart Wii always at offset 0x20. Therefore a padding area of 16 bytes will follow the U8 header.
0x08 u32 Size of all nodes including the string table.
0x0c u32 File offset of data
GNU C example
typedef struct u8_header_t
{
  be32_t  magic;         // = 0x55AA382D
  be32_t  node_offset;   // offset of first node, usually sizeof(u8_header_t)
  be32_t  fst_size;      // size of all nodes including the string table
  be32_t  data_offset;   // file offset of data
  char    padding[0];    // filled with 0xcc until the first node
}
__attribute__ ((packed)) u8_header_t;

File System

The tile system consists on a list of nodes (12 byte each) followed by a string pool for the file names. This file system part is identical to the file system of every Wii disc. The first node ('root' node, index #0) is referenced by the U8 header (see above). Each node has the following data structure:

Each Wii disc uses the same directory and file structure.

Offset Type Description
0x00 byte 0x00=data file, 0x01=directory entry (other values never seen)
0x01 u24 Three bytes: Offset into the string pool for the file name
0x04 u32 File: Offset of begin of data
Directory: Index of the parent directory.
0x08 u32 File: Size of data
Directory: Index of the first node that is not part of this directory (skip to node).
  • The size value of the root node (zero base index #0) is equal to the total number of nodes. The string pool start with the first byte behind the last node.
  • The string pool is coded ASCII. Each string is terminated by NULL.
  • The string pool contains only the last part of the filename. The full path with slashes ('/') in the example listing are only printed for a better overview.
  • The file name of the root node is always empty.
  • In Mario Kart the node at index #1 is nearly always a directory with name ".". If this file exists all other files are part of this directory. It is not really needed and never seen for file systems of Wii disc partitions.
  • The natural sort order (that one used by Nintendo) is:
    • ('/' is less than) '.' is less than digits is less than letters is less than others.
    • The case of letters is ignored.
    • For same group of characters use ASCII order.
    • For each directory: Real files are inserted before sub directories.
Example listing (made with "wszst list -lll" or "wszst llll")
* Files of YAZ.U8:Scene/UI/Title_G.szs

 idx off/hex siz/hex size/dec  magic file or directory/
-------------------------------------------------------------------------------
  0:       0<     1b>       -  -
  1:       0<     1b>       -  -     ./
  2:       1<      3>       -  -     ./bg/
  3:       1<      4>       -  -     ./button/
  4:       1<      5>       -  -     ./control/
  5:       1<      6>       -  -     ./debug/
  6:       1<      7>       -  -     ./dpd_pointer/
  7:       1<      a>       -  -     ./message/
  8:     300    2580     9600  MESG  ./message/Common.bmg
  9:    2880   18300    99072  MESG  ./message/Menu.bmg
  a:       1<      b>       -  -     ./message_window/
  b:       1<      c>       -  -     ./pad_recognize/
  c:       1<      d>       -  -     ./press_start/
  d:       1<     1b>       -  -     ./title/
  e:       d<     12>       -  -     ./title/anim/
  f:   1ab80      88      136  RLAN  ./title/anim/title_off.brlan
 10:   1ac20      9c      156  RLAN  ./title/anim/title_off_to_on.brlan
 11:   1acc0      88      136  RLAN  ./title/anim/title_on.brlan
 12:       d<     15>       -  -     ./title/blyt/
 13:   1ad60     370      880  RLYT  ./title/blyt/title.brlyt
 14:   1b0e0     448     1096  RLYT  ./title/blyt/title_boke.brlyt
 15:       d<     1b>       -  -     ./title/timg/
 16:   1b540     840     2112  . .0  ./title/timg/tt_pattern_chek_bokashi_32x32.tpl
 17:   1bd80   80640   525888  . .0  ./title/timg/tt_title_screen_mario0.tpl
 18:   9c3c0   80640   525888  . .0  ./title/timg/tt_title_screen_mario0_bokeboke.tpl
 19:  11ca00   38e40   233024  . .0  ./title/timg/tt_title_screen_title_rogo_bokeboke.tpl
 1a:  155840   38e40   233024  . .0  ./title/timg/tt_title_screen_title_rogo_tm_only.tpl
GNU C example
typedef struct u8_node_t
{
    union
    {
	u8	is_dir;		// directory flag
	be32_t	name_off;	// mask with 0x00ffffff
    };

    be32_t	offset;
    be32_t	size;
}
__attribute__ ((packed)) u8_node_t;

File Data

The file data is dependent of the related file type. See the other file formats descriptions for more details.

Tools

The following tools can handle U8 files (often stored as .arc or .szs)