-
Notifications
You must be signed in to change notification settings - Fork 31
Description
KotOR2 for Android from Aspyr is out. Our unobb tool doesn't handle those obb data files.
To recap: obb files are big data files used by Android apps. They don't have a set format; what's inside them is handled by the apk itself.
For the first KotOR game, Aspyr just used normal PKZIP files. For Jade Empire, they made them a virtual filesystem, with zlib compressed blocks of 4096 bytes.
Looking at the files in KotOR2, they seem to be still that virtual filesystem Aspyr introduced with Jade Empire. With a key difference: some files are not zlib compressed, but uncompressed. Might have been that Jade Empire already supports that too in principle, but that just no file there was uncompressed.
This has two implications for our unobb reader:
- The file identification fails, because we depend on there being a zlib header (78 9C)
- The compressed resource index list can't be found, since we depend on there being a compressed chunk beforehand
Manually ripping a resource list block from the KotOR2 obb files yields a zlib compressed resource list of the usual format.
This means, I need to revise our resource index list searching for obb files. Instead of searching backwards for a zlib header and then checking that the previous block metadata looks okay, why not just go by the metadata right at the end of the file (the last 16 bytes)? That should contain the offset of the resource list. Throw on inconsistent data there, and we don't need to check for the a zlib header at the start either.
Another thing I need to fix: check if compressed size == uncompressed size. If so, it's an uncompressed file. Read it directly instead of running it through zlib. Open question: what if the file is larger than 4096 bytes? Is there a block split somewhere or can we just read the whole thing as is?
There's also liblzma in the apk. At first I suspected Aspyr uses that in this obb format version, but I might be wrong. Open question: are all files in the obb either uncompressed or zlib? Or is there lzma too?
In either case, that looks like a nice little puzzle to solve/fix over the holidays for me :)