Python3 script for unpack/pack GCM/iso files. This tool can rebuild FileStringTable (FST) of GCM and patch boot.bin with a new apploader.img, boot.dol, add/remove/edit of folder and files of the game.
Unpack GCM/iso file **game.iso** in folder **unpack_iso**: (If the destination folder is not specified, it will use the game_code-DVD_number as folder.)
Japanese charset is not handled for now except if you have installed Japanese local. The original GCM/iso and repack GCM/iso are different most of the time. This is because GCM DVD contains "empty spaces" with data unused (old datas or random datas I don't know). So this datas are useless and loss during unpack.
Python3 script for unpack/pack AFS files. Rebuild of Table of content (TOC) and Filename directory (FD) is not implemented yet. This tool is under development.
### User manual
unpack **source_afs.afs** in the default new folder _source_afs_.
If optional_dest_folder is specified we unpack in _optional_dest_folder_.
If the FD is present we use OS mtime to store the date of the file.
Print stats about the AFS file or the unpacked AFS folder. This stats contains informations about FD, offsets ranges and files (and sys files) addresses space, and duplicated filenames grouped by filenames.
```
afstool.py --stats source
```
### Extracted file tree
root folder contains all files of the unpacked AFS
sys folder contains AFS system files of the game and generated files needed for AFS operations:
* tableofcontent.bin - TOC sys file: You can edit this file it will be handled by the --pack command.
* filenamedirectory.bin - FD sys file: This file is created only if there is a FD in the AFS.
* filename_resolver.csv - Created when multiple files have the same name in the FD. New names use "filename (N).ext" format with N:Integer.
* afs_rebuild.conf - Edit this file for rebuilding the AFS.
* afs_rebuild.csv - Edit this file with correct values set in afs_rebuild.conf for rebuilding the AFS.
### afs_rebuild.conf & afs_rebuild.csv
files_rebuild_strategy is used to organise files (indexes, offsets) in AFS. The strategy use informations in afs_rebuild.csv autogenerated during unpack. 4 strategies are available:
* auto: Rebuild all files indexes and offsets with custom sort. afs_rebuild.csv indexes and offsets will be ignored.
* index: Keep the specified index for designated files. afs_rebuild.csv offsets will be ignored.
* offset: Keep the specified offset for designated files. afs_rebuild.csv indexes will be ignored.
* mixed: Keep the specified offset and index for designated files.
afs_rebuild.csv contains entries describing how to pack files in the AFS. All int values are stored in hexadecimal: 0xabcdef. Offsets have to be aligned to 0x800 (2048). Put one line per selected file that you wan't to constraint using this format:
* unpacked_filename/index/offset/packed_name
For instance: "dummy (5).bin/0x12/0x80000/dummy.bin". You can put "auto" to index or offset when you want set the packed filename: "dummy (5).bin/auto/auto/dummy.bin". For an empty block add only index/offset couple: "0x12/0x80000" (Not implemented yet). First remove all files without constraints from afs_rebuild.csv. Then put auto in indexes, offsets, and names that doesn't have constraints.
- **D** is the resolved name and extension of the file. If the file is compressed it use the **.pzzp** (PZZ Part) extension and if the file is uncompressed by default it's **.dat**
The names of unpacked files and the presence of empty unpacked files are important to keep informations relative to the initial pzz and ensure a correct pack.