Directory Entry:
| Offset | Length | Description |
| 0x00 | 8 | Filename (padded with spaces) |
| 0x08 | 3 | Extension |
| 0x0B | 1 | File attributes |
| 0x0C | 1 | Reserved |
| 0x0D | 1 | Creation hundredths of a second (0..199) |
| 0x0E | 2 | Creation time |
| 0x10 | 2 | Creation date |
| 0x12 | 2 | Access date |
| 0x14 | 2 | High halfword of cluster number |
| 0x16 | 2 | Last modified time |
| 0x18 | 2 | Last modified date |
| 0x1A | 2 | Start cluster |
| 0x1C | 4 | File size |
File Attributes:
| Bits | Description |
| 7..6 | 00 |
| 5 | Archive |
| 4 | Directory |
| 3 | Volume Label |
| 2 | System |
| 1 | Hidden |
| 0 | Read-Only |
Date Format:
| Bits | Description |
| 15..9 | Years since 1980 (0..127) |
| 8..5 | Month of year (1..12) |
| 4..0 | Day of month (1..31) |
Time Format:
| Bits | Description |
| 15..11 | Hour (0..23) |
| 10..5 | Minutes (0..59) |
| 4..0 | Seconds/2 (0..29) |
LFN Directory Entry:
| Offset | Length | Description |
| 0x00 | 1 | LFN part number (bits 0..5), bit 6 indicates last entry |
| 0x01 | 10 | 5 letters of LFN entry (Unicode) |
| 0x0B | 1 | 0x0F (attributes) |
| 0x0C | 1 | 0x00 |
| 0x0D | 1 | Checksum of short entry |
| 0x0E | 12 | 6 letters of LFN entry (Unicode) |
| 0x1A | 2 | 0x0000 |
| 0x1C | 4 | 2 letters of LFN entry (Unicode) |
More information on the FAT specification can be found in the offical Microsoft white paper at http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx
Chishm's FAT library
Chishm has written a library to read and write files from a FAT formatted compact flash card, using a GBA Movie Player, Supercard CF, or M3 Perfect CF. You can obtain it from http://www.geocities.com/chishm1/gbamp.
To use it, add the sources to your project and include "gba_nds_fat.h" where needed. You must call FAT_InitFiles() before using any other functions, and allow at least one VBlank for the IPC to contain proper time data.
Files are always openned in binary mode, using:
FAT_FILE* file_handle = FAT_fopen ("path/filename", "mode");
Files can be read and written using standard fread and fwrite style calls to FAT_fread and FAT_fwrite. Much of Chishm's library mimics the standard file functions in this way.