Difference between revisions of "U8 (File Format)"

From Custom Mario Kart
Jump to navigation Jump to search
m (Add small disclaimer of string pool offsets.)
(DARCH is just app/lib to create ARC files whoops)
 
(10 intermediate revisions by 5 users not shown)
Line 1: Line 1:
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|File format: U8 archives]]« for details.
+
== Overview ==
 +
An '''U8''' file (also known as '''ARC''') is an archive containing a hierarchical file system. In [[Mario Kart Wii]], almost all U8 files are compressed using the [[YAZ0]] compression and stored as [[SZS]] files. Uncompressed U8 files can be found with the '''.arc''' extension.
  
 
+
== File Header ==
__TOC__
+
The file begins with the header. It is a 0x20 structure as follows:
 
 
 
 
== U8 header ==
 
The header of a U8 file is 32 bytes long. All numeric values are stored as [[big endian]] values.
 
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 14: Line 11:
 
! Description
 
! Description
 
|-
 
|-
| 0x00 || u32 || File magic. Always 0x55AA382D = ''U.8-''.
+
| 0x00 || UInt32 || File magic. Always 0x55AA382D.
 
|-
 
|-
| 0x04 || u32 || Offset to the first node.
+
| 0x04 || Int32 || Offset to the first node.
 
|-
 
|-
| 0x08 || u32 || Size of all nodes including the string table.
+
| 0x08 || Int32 || Size of all nodes including the string table.
 
|-
 
|-
| 0x0c || u32 || File offset of data.
+
| 0x0c || Int32 || File offset of data.
 
|-
 
|-
| 0x10 || u32[4] || Reserved.
+
| 0x10 || Int32[4] || Reserved.
 
|}
 
|}
  
 
== File System ==
 
== File System ==
The tile system consists on a list of nodes (12 byte each) followed by a string pool for the file names.  
+
The file system consists on a list of nodes (0xC 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.
 
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).
+
The first node is always a root node.
 
Each node has the following data structure:
 
Each node has the following data structure:
  
Line 38: Line 35:
 
! Description
 
! Description
 
|-
 
|-
| 0x00 || byte || 0x00=data file, 0x01=directory entry (other values never seen)
+
| 0x00 || Byte || '''Node type:''' 0x00=File, 0x01=Directory
 
|-
 
|-
| 0x01 || u24 || Three bytes: Offset into the string pool for the file name
+
| 0x01 || UInt24 || Offset into the string pool for the file name
 
|-
 
|-
| 0x04 || u32 || '''File:''' Offset of begin of data<br/>'''Directory:''' Index of the parent directory.
+
| 0x04 || UInt32 || '''File:''' Offset of begin of data<br/>'''Directory:''' Index of the parent directory.
 
|-
 
|-
| 0x08 || u32 || '''File:''' Size of data<br/>'''Directory:''' Index of the first node that is not part of this directory (skip to node).
+
| 0x08 || UInt32 || '''File:''' Size of data<br/>'''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 size value of the root node 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 is null-terminated and coded ASCII.
 
* The string pool offsets are relative to the start of the string pool.
 
* The string pool offsets are relative to the start of the string pool.
* 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 string pool contains only the last part of the filename.
 
* The file name of the root node is always empty.
 
* 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 <tt>"."</tt>. 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.
 
* In Mario Kart the node at index #1 is nearly always a directory with name <tt>"."</tt>. 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:
 
* 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.
+
** Files are ordered by ASCII byte value (case-insensitive).
** The case of letters is ignored.
+
** For each directory: Files are inserted before sub directories.
** 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")
 
<pre>
 
* 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
 
</pre>
 
 
 
; GNU C example
 
<pre>
 
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;
 
</pre>
 
  
 
== File Data ==
 
== File Data ==
Line 114: Line 58:
  
 
== Tools ==
 
== Tools ==
The following tools can handle U8 files (often stored as .arc or .szs):
+
The following tools can handle U8 files:
 
+
* [[CTools Pack]], by [[Chadderz]]
* [[CTools Pack]], by [[MrBean35000vr]] and [[Chadderz]]
+
* [https://github.com/Gericom/EveryFileExplorer Every File Explorer], by Gericom
* [https://static.wiidatabase.de/Every-File-Explorer.zip Every File Explorer], by [[Gericom]]
+
* [[RANWr]], by [[Gabriela_]]
* [[SZS Modifier]], by [[MrBean35000vr]] and [[Chadderz]]
+
* [https://github.com/riidefi/RiiStudio RiiStudio], by [[Riidefi]]
 +
* [[SZS Modifier]], by [[MrBean35000vr]] and Chadderz
 
* [[Wexos's Toolbox]], by [[Wexos]]
 
* [[Wexos's Toolbox]], by [[Wexos]]
 
* [[Wiimms SZS Tools]], by [[Wiimm]]
 
* [[Wiimms SZS Tools]], by [[Wiimm]]
  
 
[[Category:File Format/Wii]]
 
[[Category:File Format/Wii]]

Latest revision as of 19:11, 14 May 2023

Overview

An U8 file (also known as ARC) is an archive containing a hierarchical file system. In Mario Kart Wii, almost all U8 files are compressed using the YAZ0 compression and stored as SZS files. Uncompressed U8 files can be found with the .arc extension.

File Header

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

Offset Type Description
0x00 UInt32 File magic. Always 0x55AA382D.
0x04 Int32 Offset to the first node.
0x08 Int32 Size of all nodes including the string table.
0x0c Int32 File offset of data.
0x10 Int32[4] Reserved.

File System

The file system consists on a list of nodes (0xC 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 is always a root node. Each node has the following data structure:

Each Wii disc uses the same directory and file structure.

Offset Type Description
0x00 Byte Node type: 0x00=File, 0x01=Directory
0x01 UInt24 Offset into the string pool for the file name
0x04 UInt32 File: Offset of begin of data
Directory: Index of the parent directory.
0x08 UInt32 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 is equal to the total number of nodes. The string pool start with the first byte behind the last node.
  • The string pool is null-terminated and coded ASCII.
  • The string pool offsets are relative to the start of the string pool.
  • The string pool contains only the last part of the filename.
  • 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:
    • Files are ordered by ASCII byte value (case-insensitive).
    • For each directory: Files are inserted before sub directories.

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: