Master file table
The master file table stores all data files used by the game (graphics, sounds, text, scripts, maps, and more). It is located near the end of the ROM. The MFT contains directories, and each directory contains files. Directories are identified by a 4-byte ID, files are identified by a 2-byte ID. Neither file names, nor subdirectories are supported.
struct mft_header {
u16 id_low;
u16 id_high;
mft_directory* directory;
};
// NOTE: This applies to all directories, EXCEPT for the script directory. That has its own format.
struct mft_directory {
u32 num_entries;
u32 offset_to_id_array; // Relative to the start of this struct
u32 offset_to_file_array; // Relative to the start of this struct
u16 id_array[num_entries];
u32 file_array[num_entries]; // Entries are relative to the start of this struct
// File contents follow
};
// Return pointer to start of file with the specified id.
void* mft_get_file(mft_directory* dir, u16 id) {
u16* id_array = (char*)dir + dir->offset_to_id_array;
u32* file_array = (char*)dir + dir->offset_to_file_array;
u32 index = index_of(id_array, id);
u32 file_offset = file_array[index];
return (char*)dir + file_offset;
}
// See table below for address
mft_header mft_headers[11];
MFT Address
The mft_headers[]
array starts at the following addresses:
Game | Address |
---|---|
Boktai 1 (J) | 0x085a1584 |
Boktai 1 (U) | 0x085b02c4 |
Boktai 1 (EU) | 0x0856e97c |
Boktai 2 (J, Rev. 0) | 0x085b0ce4 |
Boktai 2 (J, Rev. 1) | 0x085b0d90 |
Boktai 2 (U) | 0x085abbc0 |
Boktai 2 (EU) | 0x085b1874 |
Boktai 3 (J) | 0x08614d6c |
MFT Directories
The following directories exist:
id_low | id_high | Description |
---|---|---|
0x5130 | 0x9225 | TODO |
0xe53e | 0xc305 | Tile maps |
0xac2c | 0xaf05 | Maps |
0xd710 | 0x9305 | Palettes - 20 byte header (ignorable?) followed by 0x200 bytes of raw GBA palette data |
0x4f2d | 0xcee5 | Tile sets |
0x6d24 | 0xa705 | Font |
0x0a4d | 0xcf05 | Particles |
0x2117 | 0x9b05 | TODO (tile sets?) |
0x5f29 | 0xc8e5 | Sprite sets |
0x4679 | 0x9a65 | Sprite set palettes |
0x41f5 | 0xa8d9 | Script directory (Boktai 1) |
0xa41e | 0xa8d9 | Script directory (Boktai 2) |
0x49bc | 0xa8d9 | Script directory (Boktai 3) |
Tools
- Bokasm: Can extract the MFT of Boktai ROMs