Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

AFS (File format): Difference between revisions

No edit summary
Tag: Reverted
No edit summary
Tag: Manual revert
Line 2: Line 2:


''This article is about the AFS file format. See [[AFS (Gotcha Force)]] for current research on Gotcha Force AFS.''
''This article is about the AFS file format. See [[AFS (Gotcha Force)]] for current research on Gotcha Force AFS.''
{{Research | 1| This file format is almost completely documented}}


The AFS file format allow to [http://wiki.xentax.com/index.php/GRAF:AFS_AFS pack a group of files sometimes in folders in one unique file]. There is no compression. Each element (packed files or AFS system files) are aligned to block of 0x800 bytes. Except for packed files AFS system files are in Little Endian.
The AFS file format allow to [http://wiki.xentax.com/index.php/GRAF:AFS_AFS pack a group of files sometimes in folders in one unique file]. There is no compression. Each element (packed files or AFS system files) are aligned to block of 0x800 bytes. Except for packed files AFS system files are in Little Endian.

Revision as of 18:21, 12 September 2022

← Gotcha Force

This article is about the AFS file format. See AFS (Gotcha Force) for current research on Gotcha Force AFS.

The AFS file format allow to pack a group of files sometimes in folders in one unique file. There is no compression. Each element (packed files or AFS system files) are aligned to block of 0x800 bytes. Except for packed files AFS system files are in Little Endian.

An AFS file can be diveded in 4 parts:

  1. The header:
    • 4 bytes: magic number = "AFS\x00" or "AFS\x20"
    • 4 bytes: total number of packed files
  2. The Table Of Content (TOC):
    • It's an array of couples:
      • 4 bytes: file offset
      • 4 bytes: file length
    • After this array we can found 3 configurations:
      • We find the offset of the Filename Directory (FD) (4 bytes) and it's length (4 bytes).
      • We find a padding (NULL bytes) and then the offset of the FD (4 bytes) and it's length (4 bytes).
      • There is no FD (no offset nor length).
  3. The files area containing all packed files
  4. Le Filename Directory (FD) where we found for each file:
    • 32 bytes: file name or path padded with NULL bytes
    • 2 bytes: years
    • 2 bytes: months
    • 2 bytes: days
    • 2 bytes: hours
    • 2 bytes: minutes
    • 2 bytes: secondes
    • 4 bytes: in some AFS we found the length of the file, in some others we found file_offset, file_len, file_offset, file_len ... for every file entry of the FD taking TOC entries in the order. And finaly in some AFS this field has a fixed value or random values.

The FD is not present in all AFS. When present we can find multiple files with same names and sharing sames datas areas or not. The filename can also contains relative or absolutes file paths "../data/file" like found in the game "Kidou Senshi Gundam - Gundam vs. Z Gundam (Japan)".

The AFS is handled by the main executable (boot.dol). So in theory files could be retrieved by 3 differents ways that could also be mixed:

  • Get the file by index: the index of the offset/length in the TOC.
  • Get the file by name in the FD.
  • Get the file by a relative offset from start of the AFS / somewhere in memory / DVD. This method is conceivable since align is the same for multiple file format packed in the DVD: MDT/PZZ and AFS (0x800). The retrievial of the length would be easy using different methods (headers and so on.).

The Virtual World RE afstool.py allow rebuilding the AFS by adding a folder tree and changing every parameters with 4 rebuild strategies: auto, index, offset, mixed.