File Formats

File Formats

BCFNT

CTR Font Format #

.bcfnt files are bitmap fonts made for the 3ds. The system font uses this format too except the header is changed from CFNT to CFNU and all file offsets are changed to absolute in memory offsets.

CFNT Header #

OffsetSizeDescription
0x000x04Magic Header (either CFNT or CFNU or FFNT)
0x040x02Endianness (0xFEFF = little, 0xFFFE = big)
0x060x02Header Size
0x080x04Version (observed to be 0x03000000)
0x0C0x04File size (the total)
0x100x04Number of “blocks” to read

FINF Header #

Version 3 (BCFNT) #

OffsetSizeDescription
0x000x04Magic Header (FINF)
0x040x04Section Size
0x080x01Font Type
0x090x01Line Feed
0x0A0x02Alter Char Index
0x0C0x03Default Width (3 bytes: Left, Glyph Width, Char Width)
0x0F0x01Encoding
0x100x04TGLP Offset
0x140x04CWDH Offset
0x180x04CMAP Offset
0x1C0x01Height
0x1D0x01Width
0x1E0x01Ascent
0x1F0x01Reserved

Version 4 (BFFNT) #

OffsetSizeDescription
0x000x04Magic Header (FINF)
0x040x04Section Size
0x080x01Font Type
0x090x01Height
0x0A0x01Width
0x0B0x01Ascent
0x0C0x02Line Feed
0x0E0x02Alter Char Index
0x100x03Default Width (3 bytes: Left, Glyph Width, Char Width)
0x130x01Encoding
0x140x04TGLP Offset
0x180x04CWDH Offset
0x1C0x04CMAP Offset

TGLP Header #

Version 3 (BCFNT) #

OffsetSizeDescription
0x000x04Magic Header (TGLP)
0x040x04Section Size
0x080x01Cell Width
0x090x01Cell Height
0x0A0x01Baseline Position
0x0B0x01Max Character Width
0x0C0x04Sheet Size
0x100x02Number of Sheets
0x120x02Sheet Image Format 0-13: (RGBA8, RGB8, RGBA5551, RGB565, RGBA4, LA8, HILO8, L8, A8, LA4, L4, A4, ETC1, ETC1A4)
0x140x02Number of columns
0x160x02Number of rows
0x180x02Sheet Width
0x1A0x02Sheet Height
0x1C0x04Sheet Data Offset

Version 4 (BFFNT) #

OffsetSizeDescription
0x000x04Magic Header (TGLP)
0x040x04Section Size
0x080x01Cell Width
0x090x01Cell Height
0x0A0x01Number of Sheets
0x0B0x01Max Character Width
0x0C0x04Sheet Size
0x100x02Baseline Position
0x120x02Sheet Image Format 0-13: (RGBA8, RGB8, RGBA5551, RGB565, RGBA4, LA8, HILO8, L8, A8, LA4, L4, A4, ETC1, ETC1A4)
0x140x02Number of Sheet columns
0x160x02Number of Sheet rows
0x180x02Sheet Width
0x1A0x02Sheet Height
0x1C0x04Sheet Data Offset

CMAP Header #

OffsetSizeDescription
0x000x04Magic Header (CMAP)
0x040x04Section Size
0x080x02Code Begin
0x0A0x02Code End
0x0C0x02Mapping Method (0 = Direct, 1 = Table, 2 = Scan)
0x0E0x02Reserved?
0x100x04Next CMAP Offset

Depending on the mapping method the next bytes are read like so:

BCMA

BCMA is the file format used for the electronic manuals on the Nintendo 3DS. It presumably stands for Binary CTR Manual.

Region and language codes #

In several places, three letter uppercase region codes and two letter lowercase language codes are used. These will be indicated by the italic placeholders REG and la respectively on this page.

The following region and language codes are known:

Region codeRegionLanguage codeLanguage
EUREuropedeGerman
enBritish English
frFrench
esSpanish
itItalic
nlDutch
ptPortuguese
ruRussian
JPNJapanjaJapanese

Top-level archive overview #

A BCMA file is a regular, uncompressed DARC archive which contains a set of LZ10-compressed DARC archives. These subarchives contoin files containing either textures in the BCLIM format or metadata and manual pages in the binary CLYT format.

BCSAR

The BCSAR (Binary CTR Sound ARchive) format is the 3DS’s equivalent of the Wii’s BRSAR format. They’re not the same structures, though, but they do have the same purpose.

BCSAR are located in the RomFS, this is usually stored under “romfs:/sound/.bcsar”. This contains various audio formats, such as CSTM, CWSD, CSEQ, and CWAV.

BCSAR Header #

OFFSETSIZEDESCRIPTION
0x00x4MAGIC “CSAR”
0x40x2Byte order mark (0xFEFF = Big Endian, 0xFFFE = Little Endian)
0x60x2Length of BCSAR header
0x80x4Version
0xC0x4Length of the entire BCSAR (starting from 0x0)
0x100x4Amount of main partitions in the BCSAR [STRG + INFO + FILE = 0x03 (= 3)]
0x140x4STRG partition reference ID? (Always 0x2000)
0x180x4Location of STRG partition
0x1C0x4Length of STRG partition
0x200x4INFO partition reference ID? (Always 0x2001)
0x240x4Location of INFO partition
0x280x4Length of INFO partition
0x2C0x4Main FILE partition reference ID? (Always 0x2002)
0x300x4Location of main FILE partition
0x340x4Length of main FILE partition
0x380x4Reserved for 4th main partition location?
0x3C0x4Reserved for 4th main partition length?

Partitions #

STRG #

STRG contains the names of the audio files in the BCSAR.

BCSTM

This document is about the format of CTR Streams (CSTM).

Overview #

The structure is similar to that of a BCWAV, with a few differences, such as its different INFO block format, the addition of a SEEK block, and the organization of the DATA block samples into blocks.

These files are either found in rom:\sound\stream\ or they can be inside of a CSAR.

OFFSETSIZEDESCRIPTION
0x0004Magic (CSTM)
0x0042Endianness (0xFEFF = little, 0xFFFE = big)
0x0062Header Size (0x40 due to Info Block alignment)
0x0084Version (0x02000000)
0x00C4File Size
0x0102Number of Blocks (3)
0x0122Reserved
0x01412Info Block Sized Reference (Offset relative to start of file)
0x02012Seek Block Sized Reference (Offset relative to start of file)
0x02C12Data Block Sized Reference (Offset relative to start of file)

Block Header #

OFFSETSIZEDESCRIPTION
0x0004Magic
0x0044Size

Block Types #

MAGICTYPE
INFOInfo Block
SEEKSeek Block
DATAData Block

Info Block #

OFFSETSIZEDESCRIPTION
0x0008Block Header
0x0088Stream Info Reference (Offset relative to this field)
0x0108Track Info Reference Table Reference (Offset relative to Stream Info Reference field)
0x0188Channel Info Reference Table Reference (Offset relative to Stream Info Reference field)
0x02056Stream Info
0x058XTrack Info Reference Table
XXChannel Info Reference Table
XXTrack Info Entries
XXChannel Info Entries

If encoding is DSP ADPCM:

BCWAV

This document is about the format of Binary CTR Wave files (BCWAV). The structure is very similar to Microsoft’s Wave file.

Overview #

Microsoft’s WAV structure is RIFF Header which defines the data inside which is WAVE, then the media player expects a “fmt " chunk and a “data” chunk. Nintendo’s format uses a CWAV header (no need for a general structure for media, only wave), which points to an INFO struct (the equivalent to fmt) and a DATA struct (the equivalent to data).

CBMD

CBMD - CTR Banner Model Data

This page describes the format used for banners’ models. These are stored in CXI ExeFS:/banner and optionally in extdata exbanner. CBMD is a container file for CGFX blocks. This is used for banners of titles you see in the home menu. BNR used for the app banners in the CXI/exbanner is the same as CBMD with CWAV at the end.

CBMD Header #

OffsetLengthDescription
0x00x4Magic “CBMD”
0x40x4Zero
0x80x4Offset for common CGFX
0xc0x34Optional offsets for region/language specific CGFX
0x400x44Padding?
0x840x4BCWAV offset

The common CGFX is used if the CGFX offset for the system region/language is zero. Those optional offsets can be used in extdata exbanner, but separate CBMD banner files for each region/language can be used as well.

CCI

See also: NCSD.

This page documents the format of NCSD. CTR cart images (CCI) is NCSD, but is used for other things as well. CSU is NCSD used for system updates and development tools.

This is a container format which generally holds CXI files inside.

Overview #

NCSD images start with a NCSD header, followed by up to a maximum of 8 partitions according to spec. The first partition(NCCH 0) usually starts at 0x4000, this is generally the main NCCH executable. The following info on partitions 1, 2, and 7 are only valid for .CCI. The second partition(NCCH 1) contains the game “Manual”(title ID for the .CXI containing the Manual always starts with ‘0005’). The third partition(NCCH 2) contains the download play “Child”(The title ID for the NCCH containing the Child always starts with ‘0006’). The eighth block(NCCH 7) contains “Update Data”(The title ID for the NCCH containing the Update Data always starts with ‘8000’) The format of partitions can be determined from the partition FS flags, while the contents can be determined from the partitions flags.

CGFX

CGFX is a container format used to store graphics resources. It can contain 3D models, textures and animation data.

CGFX #

CGFX header :

OffsetLengthDescription
0x00x4Magic “CGFX”
0x40x2Byte order mark: FFFE (little endian) or FEFF (big endian)
0x60x2CGFX header size
0x80x4Revision
0xC0x4File size (bytes)
0x100x4Number of entries

A typical CGFX file contains two main entries, beginning directly after the CGFX header: DATA and IMAG.

CIA

Overview #

CIA stands for CTR Importable Archive. This format allows the installation of titles to the 3DS. CIA files and titles on Nintendo’s CDN contain identical data. As a consequence, valid CIA files can be generated from CDN content. This also means CIA files can contain anything that titles on Nintendo’s CDN can contain.

Under normal circumstances CIA files are used where downloading a title is impractical or not possible. Such as distributing a Download Play child, or installing forced Gamecard updates. Those CIA(s) are stored by the titles in question, in an auxiliary CFA file.

CLAN Format

CLAN (.bclan) is the layout animation format used on the 3DS. It stands for (Binary) CTR Layout Animation, and is similar to the RLAN format used on the Wii.

OffsetSizeTypeDescription
0x000x4StringSignature (CLAN)
0x040x2UInt16Byte Order Mark
0x060x2UInt16Header Length
0x080x4UInt32Revision
0x0C0x4UInt32File Size
0x100x4UInt32Nr Sections

pat1 (Pattern 1) #

OffsetSizeTypeDescription
0x000x4StringSignature (pat1)
0x040x4UInt32Section Size
0x080x4UInt32Flags?
0x0C0x4UInt32?
0x100x4Int32?
0x140x4UInt32?
0x180x10StringPattern name

pai1 (Pattern Instruction? 1) #

OffsetSizeTypeDescription
0x000x4StringSignature (pai1)
0x040x4UInt32Section Size
0x080x4UInt32?
0x0C0x4UInt32Flags?
0x100x4UInt32Nr entries?
0x140x4UInt32Entries offset (relative to pai1)

Instruction? entry #

OffsetSizeTypeDescription
0x000x14StringTarget panel name
0x140x4UInt32Flags?
0x180x4UInt32Animation entry offset (relative to entry)
0x1C0x4UInt32? (if flag bit 1 is set)

Animation entry #

OffsetSizeTypeDescription
0x000x4StringAnimation type

CLYT Format

CLYT (.bclyt) is the layout format used on the 3DS. It stands for (Binary) CTR Layout, and is similar to the RLYT format used on the Wii.

OffsetSizeTypeDescription
0x000x4StringSignature (CLYT)
0x040x2UInt16Byte Order Mark
0x060x2UInt16Header Length
0x080x4UInt32Revision
0x0C0x4UInt32File Size
0x100x2UInt16Nr Sections
0x120x2UInt16Padding

lyt1 (Layout 1) #

OffsetSizeTypeDescription
0x000x4StringSignature (lyt1)
0x040x4UInt32Section Size
0x080x4UInt32Origin type

CRO0

CRO with extension .cro is used for “DLLs”. CRS with extension .crs is in the same format of CRO but storing the symbol information of the static module (the main application). The end of the file is aligned to a 0x1000-byte boundary with 0xCC bytes.

The first hash-table entry hashes the 0x100-byte header following the hash-table. The following hash-table entries hash the sections specified in the header.

When the RO module loads the entire CRO into process memory(mapped in the 0x00100000-0x04000000 region), it modifies the mapped CRO data. The magic field is also changed to “FIXD” if fix level is not 0.

CRR0

OffsetSizeDescription
0x00x4Magic “CRR0”
0x40x4Reserved
0x80x4Next loaded CRR (Must be zero in file, set by RO during loading)
0xC0x4Previous loaded CRR (Must be zero in file, set by RO during loading)
0x100x4Debug Info Offset
0x140x4Debug Info Size
0x180x8Reserved
0x200x4UniqueID Mask
0x240x4UniqueID Pattern
0x280x18Reserved
0x400x100RSA-2048 modulo
0x1400x100RSA-2048 signature signed by Nintendo, starting at offset 0x20 with size 0x120
0x2400x100RSA-2048 signature verified with the above modulo, over the data starting at 0x340 with the size from 0x358
0x3400x4Process UniqueID<<8, from the ProgramID
0x3440x4Size of the whole CRR0 file
0x3480x8Reserved
0x3500x4Hash-table Offset
0x3540x4Total hashes in the hash-table
0x3580x4Offset to the plain region containing text tags, from the process NCCH
0x35C0x4Size of plain region
0x360SHA-256 hash-table

Each hash stored in the hash-table is over the corresponding executable CRO0 hash-table.

CTPK

CTPK - CTR Texture PacKage

CTPK is a container file for one or multiple textures that are in various formats readable by the 3ds system. Offsets are relative to the beginning of the header section unless specified.

CTPK Header #

OffsetLengthDescription
0x00x4Magic “CTPK”
0x40x2Version?
0x60x2Number of Texture Entries
0x80x4Texture Data section offset
0xC0x4Texture Data section size
0x100x4Hash section offset
0x140x4Conversion Info section offset
0x180x8Padding

Texture Info Entry #

The Header block is followed by a texture info entry for each texture in the container. This block is usually followed by the bitmap size arrays and then the file paths. 0x20 byte aligned.

DARC

This page documents the format of DARC.

Overview #

DARC files are archives. Containers of files.

This is very similiar to NARC (the DS archives).

ARC header #

OffsetSizeTypeDescription
0x0004char[4]Magic Number ‘darc’
0x0042uint16Endianess (=0xFFFE: Little)
0x0062uint16Header’s length
0x0084uint32Version
0x00C4uint32File’s length
0x0104uint32File table offset (from the beginning of the file)
0x0144uint32File table length
0x0184uint32Files data offset

File table #

The file table starts at 0x01C.

DSP Binary

OffsetSizeDescription
0x00x100RSA Signature over bytes 0x100-0x300
0x1004Magic ('DSP1')
0x1044DSP binary size
0x1082Memory layout (bits 0-7: Program ram, 8-15: Data ram). Each bit represents a memory region. The region is always 0x8000 bytes in size (the first region starts at 0x1FF00000; the next is a 0x1FF08000 and so on). The HW registers for DSP memory configuration are CFG11_SHAREDWRAM_32K_DATA and CFG11_SHAREDWRAM_32K_CODE, located at physical address 0x10140000 (mapped to 0x1EC40000).
0x10C1?
0x10D1Special segment memory type (0=1=0x1FF00000(Program ram)+,2=0x1FF40000(Data ram)+)
0x10E1Num segments (must be 1-10)
0x10F1Flags:

MPO

Overview #

MPO = Multi-Picture Object

Document describing the file format used in mpo files: 🔗 http://www.cipa.jp/std/documents/e/DC-007_E.pdf

Nintendo uses a common format for its 3D pictures. MPO is basically two JPG files concatenated in one file. The two JPG files has an EXIF data structure in their headers (This was developed by CIPA).

EXIF is a standard that specifies the formats for images, sound, and ancillary tags used by digital cameras (including smartphones), scanners and other systems handling image and sound files recorded by digital cameras. 🔗 1

NCCH

The following text tries to document the structure of the NCCH (Nintendo Content Container Header) container format. This format is used to store the content of any installed title.

Overview #

There are two known NCCH container specializations used on the 3DS, “executable” and “non-executable”, officially known as CXI and CFA, respectively.

CXI #

The CXI (CTR Executable Image) specialization of the NCCH container contains executable code, which runs on a single ARM11 core.

NCSD

This page documents the format of NCSD.

Overview #

There are two known specialisations of the NCSD container format. The CTR Cart Image (CCI) format and the 3DS’ raw NAND format. CCI is the format of game ROM images.

CTR System Update (CSU) is a variant of CCI, where the only difference is in the file extension. This is used with developer System Updates and associated Tools.

NCSD images start with a NCSD header, followed by up to a maximum of 8 NCCH partitions.

Nintendo 3DS Sound

Nintendo 3DS Sound is the music playing and audio recording application that is included with all retail consoles.

Voice Recorder #

Like its predecessor for the DSi, up to 10-second recordings can be stored, with limited integration of those with other software.

Practically speaking, the single page of internal storage is for DSi-mode software, and the 10 pages of SD card storage are for 3DS software (like Flipnote Studio 3D).

PSLB

This page documents the format of PSLB.

Overview #

PSLB are data-interchange files like JSON or XML.

OffsetSizeTypeDescription
0x0004char[4]Magic Number ‘PSLB’
0x0044uint32Unkown
0x0084uint32Unkown
0x00C4uint32Unkown

Data #

The data is constructed of 1 byte that represents what type of data follows

ValueType
1String
2int32
3float (4 byte)
4Byte
5Map
6List

The string type is a combination of an uint32 for the length of the string followed by the characters of the string.

SARC

SARC File Format #

.sarc files are similar to the ARC format with a slightly different structure.

File Format #

SARC Header #

OffsetSizeDescription
0x000x04Magic Bytes “SARC”
0x040x02Header Length
0x060x02Byte-order marker (0xFEFF = big, 0xFFFE = little)
0x080x04File Length
0x0C0x04Data Offset (absolute)
0x100x04Unknown (always 0x00000100)

SFAT Header #

OffsetSizeDescription
0x000x04Magic bytes “SFAT”
0x040x02Header Length
0x060x02Node Count
0x080x04Filename Hash Multiplier (usually 0x65)

SFAT Node #

OffsetSizeDescription
0x000x04Name Hash
0x040x04SFNT Filename Offset (relative to SFNT data section)
0x080x04File Data Start (relative to SARC data start)
0x0C0x04File Data End (relative to SARC data end)

Node hashing function #

The node hash is calculated via:

SHBIN

The SHBIN (SHader BINary) format is used to contain compiled and linked shader programs. These can include vertex shaders and geometry shaders. In commercial applications, SHBIN files can be found as standalone files with the extension .shbin, or within container formats like, for example, CGFX (with the extension .bcsdr). They are typically compiled from .vsh files, .gsh files, and sometimes .asm files.

A SHBIN’s structure starts with a binary header (DVLB), then a single program header (DVLP), then one or more executable headers DVLE(s). The binary header specifies the number and location of DVLEs. The program header specifies the generic parts of the shader (i.e. the shader program data, the operand descriptor data, and a filename symbol table). The executable headers specify the contextual details (i.e. entry point, constant values, debug symbols, etc). There may be multiple executable headers, so in this sense multiple shaders sharing the same program code can be stored in a single SHBIN. Hence for the following, note the distinction between “program” and “executable”.

Ticket

Tickets are a format used to store an encrypted titlekey (using 128-Bit AES-CBC). With 3DS, the Ticket format was updated (now v1) from Wii/DSi format (v0).

Structure #

All of the data in the file is represented in Big Endian.

OffsetSizeDescription
0x000YSignature Data
Y0x210Ticket Data

Y denotes the total size of the “Signature Data” section and depends on the signature type.

Title Metadata

Title metadata is a format used to store information about a title (installed title, DLC, etc.) and all its installed contents, including which contents they consist of and their SHA256 hashes.

🔗 Code is available by trap15 to parse the available information from the 3DS format of TMDs.

Structure #

All the data in the file represented in Big Endian, unless otherwise noted.

OffsetSizeDescription
0x0YSignature Data
Y0xC4Header
0xC4 + Y0x24*64Content Info Records.
0x9C4 + Y0x30*ContentCountContent Chunk Records.

Y denotes the total size of the “Signature Data” section and depends on the signature type.