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.
files_rebuild_strategy is used to organise files (indexes, offsets, packed name if there is a FD) 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 packed packed_filename if there is a FD or else unpacked_filename. afs_rebuild.csv indexes and offsets will be ignored.
**toc_offset_of_fd_offset**: The TOC offset of the FD offset is at the end of the TOC. Some AFS use pad after the offsets/lengths serie. Use auto when it's possible.
All offsets and indexes are stored in hexadecimal with 0x prefix: 0xabcdef. Use auto for offsets or indexes when it's possible. Offsets have to be aligned to 0x800 (2048).
afs_rebuild.csv contains entries describing how to pack files in the AFS. Put one line per selected file that you wan't to constraint using the format: "unpacked_filename/index/offset/packed_name", for instance: "dummy (5).bin/0x12/0x80000/dummy.bin". You can put auto to index or offset: "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 and offsets 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.