BIN (File Format) - RainThunder/fefates-tools GitHub Wiki

.bin is a basic format used to store the data in Fire Emblem Awakening and Fire Emblem Fates.

Structure

.bin file format is pointer-based. All data are stored in little endian format.

Offset Size Description
0x0 20 Header
0x20 D Data region
0x20 + D P1 * 4 Pointer region 1
0x20 + D + P1 * 4 P2 * 8 Pointer region 2
0x20 + D + P1 * 4 + P2 * 8 remainder End region

D, P1, P2 are determined in the file's header.

Header

Offset Size Description
0x0 4 File size
0x4 4 Data region size (D)
0x8 4 Pointer count 1 (P1)
0xC 4 Pointer count 2 (P2)
0x10 16 Padding

Pointer region 1

Pointer region 1 is a list of all pointers in the data region. In all official files, this list was sorted in the following procedure:

  • Pointers that pointed to somewhere in the data region (e.g. support table in GameData.bin)
    • Sort those pointers in ascending order.
    • Add them into the list.
  • Label pointers:
    • Group all label pointers that pointed to the same label into a group.
    • Sort all pointers in each group, in ascending order.
    • Sort those groups by the lowest pointer in the group, in ascending order.
    • Add all pointer groups into the list.

The sorting process is supposed to make the file easier to read, although it isn't necessary. An .bin file with unsorted pointer region 1 will work without any problem.

Pointer region 2

There are P2 number of the following structure:

Offset Size Description
0x0 4 Data block offset (relative to the data region offset, i.e. 0x20)
0x4 4 Label offset (relative to the end region offset)

In the official files, all structures are sorted by data block offset, in ascending order. It is unknown whether or not an unsorted pointer region 2 works.

End region

The end region of all official .bin files only contains labels. Each label is a null-terminated string in Shift-JIS encoding, and is referenced somewhere in data region. Because this format is pointer-based, the end region may contains data that are not labels, pointed from certain pointer in data region.

In the official files, all labels are sorted as follows:

  • Sort all labels that are referenced in pointer region 2, in the order of that region.
  • Sort the rest of the labels, following the order of the pointers in data region.

Similar to the pointer region 1, label sorting is not necessary.

Example

GameData/GameData.bin (can be downloaded from this repository)

Offset Size Description
0x0 4 File size (0x32FF7)
0x4 4 Data region size (0x1EE88)
0x8 4 Pointer count 1 (0x1264)
0xC 4 Pointer count 2 (0x519)
0x10 16 Padding
0x20 0x1EE88 Data region
0x1EEA8 0x1264 * 4 Pointer region 1
0x23838 0x519 * 8 Pointer region 2
0x26100 0xCEF7 Label region

Pointer region 1: List of all pointers in the data region.

Offset Value +0x20 Data region +0x20 Description
0x1EEA8 0x0 0x20 0x64 0x84 Chapter data pointer
0x1EEAC 0x8 0x28 0xDC0 0xDE0 Character data pointer
... ... ... ... ... ...
0x1F83C 0x64 0x84 0x260E0 0x26100 CID_NONE (default chapter label)

Explanation: The value at offset 0x1EEA8 in the GameData.bin file is 0x0. Add that value to 0x20, the result is 0x20. The value at offset 0x20 in the GameData.bin file is 0x64. Again, add 0x20 to 0x64, the result is 0x84. The block that is at offset 0x84 is chapter data.

Pointer region 2

Offset Data block offset (relative) Data block offset (relative) + 0x20 Description Label offset (relative) Label offset (relative) + First label offset Description
0x23838 0x64 0x84 "None" chapter block offset 0x0 0x26100 CID_NONE ("None" chapter label)
... ... ... ... ... ... ...
0x25240 0x14FB0 0x14FD0 Bronze Sword block offset 0x2D5E IID_青銅の剣 (Bronze Sword label)

Modification

Some Nightmare modules in this repository supports in-place editing in the data region for certain files.

Because .bin file format is pointer-based, it's possible to redirect the pointer in certain part of the data region to the end of file, add some data there, then modify the file size in the header. It's the easiest way to expand the data, and is known to work. The first successful modification was done by TildeHat on gbatemp forum.[1] The GameData.bin file in the same-sex marriage project was modified using the same technique. Support table was redirected to the end of file, then custom support was added.

However, if you want to add new data that contains pointer, you need to add more pointer to the pointer regions. For GameData.bin editing, it's recommended to use gamedata_module.py in this repository to add new data. It automatically resize the file and fixed all pointers.

Notable .bin files in Fire Emblem Fates

Main game

  • GameData/GameData.bin: Store the most important data in the game, like characters, items, etc.
  • GameData/AcceShop.bin: Accessory data in Accessory Shop.
  • All .bin files in GameData/Person folder: Store the unit data in specific map.
  • All .bin files in GameData/Dispos folder: Unit distribution in specific map.
  • All .bin files in GameData/Terrain folder: Terrain data in specific map.
  • All .bin files in m folder: Contains the game's text. Can be dumped to text files using FEAT.
  • castle/castle_person.bin: Data of all possible people in My Castle
  • castle/castle_join.bin: Handles all character that joins the user's party via My Castle.
  • castle/castle_building.bin: All building data in My Castle can be found in this file.
  • castle/castle_food.bin: Food resources data
  • castle/castle_gemstone.bin: Gemstone resources data
  • face/FaceData.bin: All data of character portrait. This data is used in FEITS.
  • All file in asset folder: All assets.

DLC

  • fst.bin: Store the list of files in the DLC.
⚠️ **GitHub.com Fallback** ⚠️