RARC file

From Pikmin Technical Knowledge Base
Jump to navigation Jump to search

The RARC file format is an archive format commonly found in first party Nintendo GameCube games. Many files are stored in these archive files in a similar way to ZIP and 7Z files.

In Pikmin 2's file structure, ARC files are nowhere near as common as the SZS file, which is a version of the format that's compressed via Yaz0 compression.

Extracting and repacking these archives is done by using WiiExplorer. WiiExplorer also allows compressing archives with Yaz0 compression, though at the time of writing, it does not take into account a quirk with Pikmin 2 where Yaz0 compressed archives have to be padded to 0x20 bytes. Use GameCube File Tools for Yaz0 compression instead.




Format Specifications[edit]

Below you'll find helpful tables on how the file is structured

Header[edit]

Each RARC starts with a header

Offset Type Description
0x00 String "RARC" in ASCII
0x04 UInt32 Size of the entire file
0x08 UInt32 Data Header Offset (Always 0x20)
0x0C UInt32 Offset to the File Data section minus 0x20
0x10 UInt32 Length of the File Data section
0x14 UInt32 Size of all the MRAM Files in the File Data section
0x18 UInt32 Size of all the ARAM Files in the File Data section
0x1C UInt32 Size of all the DVD Files in the File Data section

Data Header[edit]

This section has information on the entire archive

Offset Type Description
0x00 UInt32 The number of Directory Nodes
0x04 UInt32 Offset to the Directory Nodes section minus 0x20 (always 0x20)
0x08 UInt32 The number of File Nodes
0x0C UInt32 Offset to the File Nodes section minus 0x20
0x10 UInt32 Size of the String Table
0x14 UInt32 String Table offset minus 0x20
0x18 UInt16 The next available File Index
0x1A bool Keeps the File ID's Synced (Always 0x01, or TRUE in SMG)
0x1B UInt8[5] Padding, All 0x00's

Directory Node section[edit]

This section is a list of information for each folder (or, subdirectory) in the archive.
Each list entry looks like this:

Offset Type Description
0x00 String The first 4 characters in the Directory's name in all caps.
Example: "RootFolder" = "ROOT", and "Tmp" = "TMP " (Names less than 4 characters are padded to 4 characters with spaces)
0x04 UInt32 Offset to the Directory's name in the String Table
0x08 UInt16 Hash of the Directory's name
0x0A UInt16 The number of File Nodes in this directory
0x0C UInt32 Offset to the first File Node in the File Nodes section

File Node section[edit]

This section is a list of information for each file in the archive. It also contains entries for directories so we can know which directory belongs where.
Each list entry looks like this:

Offset Type Description
0x00 UInt16 Node Index (0xFFFF if this entry represents a subdirectory)
0x02 UInt16 Hash of the Node's name
0x04 UInt8 Bitfield Defines certain Node Attributes. See the Node Attributes table below.
0x05 UInt8[1] Padding. 0x00
0x06 UInt16 Offset to the Node's name in the String Table
0x08 UInt32 If this node represents a file: Offset to the File's Data in the File Data section.
If this node represents a directory: Directory Node section index to use
0x0C UInt32 If this node represents a file: Size of the File's Data.
If this node represents a directory: The size of the Directory Node (always 0x10)

Node Attributes[edit]

Mask Name Description
0x01 FILE This node is a File
0x02 DIRECTORY This node is a Directory
0x04 COMPRESSED This node's file is compressed
0x10 PRELOAD_TO_MRAM Set the file to be loaded into Main RAM
0x20 PRELOAD_TO_ARAM Set the file to be loaded into Auxiliary RAM (GameCube only)
0x40 LOAD_FROM_DVD Set the file to be loaded right off the DVD when needed
0x80 YAZ0_COMPRESSED This node's file is specifically YAZ0 compressed. Enable the COMPRESSED flag as well when using this

Among the File Nodes are nodes for a ".." and "." directory. The "." entry points to the current directory, and the ".." directory points to the parent directory (or 0xFFFFFFFF if the current directory is the topmost directory).

String Table[edit]

This section is composed of NULL-terminated ASCII strings. The above information references these strings.

File Data section[edit]

This section is a chunk of all the data that files in the archive contain. Files are sorted in a specific order, and are padded to the nearest 32 byte boundary.
The sorting order is MRAM Files then ARAM Files then DVD Files.