As promised, a tool to quickly insert changed files into FF12 vbf archive. Please note it's still
WORK IN PROGRESS. Keep a copy of your original file, just in case.
So what's the problem? Repacking 30GB archive can take even two hours (eg. with both unpacked directory and vbf on the same HDD).
With this tool it takes a few seconds at most (though it depends on number of files and their size).
The general idea of vbf:
1. All files are compressed (with uncompressed chunks whenever compression wasn't viable).
2. Static sections written one after another (header, md5s, file data, names, block data, compressed files).
3. If a file is modified and compressed, few issues are possible:
a). the original file is the same size, the compressed file is of a greater size.
b). the original file is of a greater size.
In case of a) there is a problem, because the file doesn't fit into space available. My solution is to move the file to the end of VBF archive, leave the original space unused.
In case of b) there is a problem, because the file has more blocks (64kB each block), so the block data is larger, yet doesn't fit into space available. My solution is to move few first files in archive to the end of VBF archive to make some room for all the additional header data (trying to free at least 10MB but have to always move whole files).
Now, the file data contains sizes and offsets, but in case a modified file compresses to a smaller size, we don't know anymore, what was the original space available (you can't subtract offsets of two consecutive files, as these do not have to be placed one after another). So let's say the next time the file after additional modifications is slightly larger but sill would fit within original boundaries. But since we don't know what the boundaries were, the file would be relocated to the end anyway.
To solve that, I've added additional file to the VBF archive, that keeps track of original offsets and sizes, so such an issue won't happen (the files when relocating, are getting some additional padding, so further alleviate the issue). If VBF doesn't contain this "vbf_extra.bin" file, it will be automatically created. If it exists, it will be read and used during reinsertions. This extra file is uncompressed to make it easier to read/modify.
Basically, only headers are recalculated each time. Only files present in patch directory are compressed and inserted.
Code:
FF12 Zodiac Age (PC) vbf tool v1.0 by ffgriever
Usage: ff12-vbf option input output
Options:
-r replace files in output vbf with files in input dir
(output defaults to {input}.bin)
-u unpack vbf into output dir
(output defaults to {input}_dir)
As you see it lacks "creation" mode (full repack). I will add that later for completion sake, but I'm actually trying to avoid the hassle of rebuilding whole archive - that's the whole point of the tool, to save time

.
Typical output (first time, creating vbf_extra.bin):
Code:
ff12-vbf -r "D:\ff12 hd\pliki_gotowe" FFXII_TZA.vbf
Reading file structure...
Reading directory structure
gamedata/d3d11/artdata/font/us/fontex_subtitle.dds.phyre (5546.47kB)
ps2data/plan_master/us/plan_map/naf_a/naf_a01/global/naf_a01.ebp (50.62kB)
Creating indexes
vbf_extra.bin not found. Creating and moving files around.
Freed 172803635 bytes, vbf_extra.bin written at 0x74d4e1e9e
Patching gamedata/d3d11/artdata/font/us/fontex_subtitle.dds.phyre
Not enough space, file has been relocated to 74d661e9e...
Patching ps2data/plan_master/us/plan_map/naf_a/naf_a01/global/naf_a01.ebp
Not enough space, file has been relocated to 74d68d4ea...
Done!
Typical output (consecutive times):
Code:
ff12-vbf -r "d:\ff12 hd\pliki_gotowe" FFXII_TZA.vbf
Reading file structure...
Reading directory structure
gamedata/d3d11/artdata/font/us/fontex_subtitle.dds.phyre (5546.47kB)
ps2data/plan_master/us/plan_map/naf_a/naf_a01/global/naf_a01.ebp (50.62kB)
Creating indexes
Patching gamedata/d3d11/artdata/font/us/fontex_subtitle.dds.phyre
Patching ps2data/plan_master/us/plan_map/naf_a/naf_a01/global/naf_a01.ebp
Done!
In my case the structure of "pliki_gotowe" was:
Code:
├───gamedata
│ └───d3d11
│ └───artdata
│ └───font
│ └───us
│ fontex_subtitle.dds.phyre
│
└───ps2data
└───plan_master
└───us
└───plan_map
└───naf_a
└───naf_a01
└───global
naf_a01.ebp
Basically, all the files you want to insert, all in appropriate directories. The insertion took less than three seconds instead of 50 minutes.
Here is the link:
http://ff12.pl/down/ff12-tools-20180212.7zLet me know if you find any bugs.