NARC (File Format)

From Wexos's Wiki
(Redirected from NARC)
Jump to navigationJump to search

NARC (Nitro ARChive) is an archive format used in Nintendo DS games such as Mario Kart DS, as well as some Nintendo 3DS and Wii U games.

File Format

Header

The file starts with the following header:

Offset Type Description
0x00 Char[4] File magic. Always NARC in ASCII.
0x04 UInt16 Looks like a byte-order-mark, however, in Mario Kart DS this value indicates big endian while the file is in little endian.
0x06 UInt16 Probably a version number. Always 0x100 in Mario Kart DS.
0x08 UInt32 File size of the whole file in bytes.
0x0C UInt16 Header size in bytes.
0x0E UInt16 Number of sections in the file.

BTAF

The BTAF section contains allocated file data. This file data is then linked by BTNF.

Offset Type Description
0x00 Char[4] Section magic. Always BTAF in ASCII.
0x04 UInt32 Section size in bytes.
0x08 Int32 Number of files. The file entries follow after this field.

File Entry

Each file entry points to the file data. The entry has the following structure:

Offset Type Description
0x00 UInt32 File data start offset. Points to the start of the file data, relative to the end of the GMIF header.
0x04 UInt32 File data end offset. Points to the end of the file data, relative to the end of the GMIF header.

BTNF

The BTNF stores the structure of the archive. It contains the folders and files. This section will not always be align by 4, and therefore Nintendo pads this section at the end with 0xFF if needed, to align for the next section. It starts with the following header:

Offset Type Description
0x00 Char[4] Section magic. Always BTNF in ASCII.
0x04 UInt32 Section size in bytes.

Directory

After the header comes the directories. The amount are not stored in the BTNF header, however, the parent directory index of the first entry stores the total amount of directories, meaning there will always be at least one directory. Each directory has the following structure:

Offset Type Description
0x00 UInt32 Directory child nodes offset. It points to the structure where the subfiles and subfolders are stored. Relative to the end of the BTNF header.
0x04 UInt16 First file index. The index of the first file entry in BTAF.
0x06 UInt16 Index of the parent directory. The index starts at 0xF000, meaning 0xF005 would be directory 5. For the root node, the total number of directories are stored.

Child Nodes

Each directory points to the child nodes. The directory points to the following structure:

Offset Type Description
0x00 Byte Flag (F).

This flag is used to figure what data follows. If F is 0, that means end of directory, and no more data follows. If F is not 0, then the highest bit A (Axxx xxxx) in F specifies what data follows.

If A is 0, then a file entry follows. It has the following structure:

Offset Type Description
0x00 String Name of the file. The length of this string is F.

If A is not 0, then a directory entry follows. It has the following structure:

Offset Type Description
0x00 String Name of the directory. The length of this string is F & 0x7F (since the highest bit is always set to 1).
F & 0x7F UInt16 Child directory index. This directory is a child of the current directory. The index starts at 0xF000, meaning 0xF005 would be directory 5.

GMIF

The GMIF section stores all file data. The file data is linked by the file entries in BTAF. This section has the following structure:

Offset Type Description
0x00 Char[4] Section magic. Always GMIF in ASCII.
0x04 UInt32 Section size in bytes (S).

After the header, the file data is located, with a size of S - 8. The file entries points to this data. All file data start addresses are aligned by 4, and 0xFF is used as padding byte.

Tools

The following tools can handle NARC files:

  • Every File Explorer, by Gericom