IcySon55 / Kuriimu

A general purpose game translation toolkit for authors of fan translations.
GNU General Public License v3.0
332 stars 50 forks source link

(PLUGIN REQUEST) Yo-kai Sangokushi Main Archive File (.BIN) #530

Closed NeonToaster1 closed 3 years ago

NeonToaster1 commented 6 years ago

Issue: plugin request Console: Nintendo 3DS Format extension(s): .BIN Type: archive Game Name: Yo-kai Sangokushi

First 8 bytes of the file(s): .BIN - 1D 78 33 01 DD 4A 00 00 (I'm pretty sure these are correct but they may not be)

More details: Unlike the other Yo-kai Watch games, this game uses .BIN as the main archive file (due to this spinoff game being developed by Koei Tecmo). I'm assuming that just like the mainline Yo-kai Watch games, all of the data for the game is in this file, and Karameru can't open it.

Sample files (if possible): LINKDATA_A.BIN - https://drive.google.com/file/d/1It2yy8rYCYldFGnDuRVHeMlS_Gti5HGp/view?usp=sharing

DarkSynopsis commented 6 years ago

Already an issue tied to this, https://github.com/IcySon55/Kuriimu/issues/346

NeonToaster1 commented 6 years ago

Didn't know that. Sorry about that!

I hope eventually a plugin can be made! :)

kuronosuFear commented 5 years ago

Hi! Bumping this request.

Sangokushi might look the same as some other files in #346 but they don't use compression, so this certainly needs its own Kuriimu\Karameru implementation

I've made my own file extractor (no re-compiler function... yet), but of course having it compatible with Kuriimu is a different beast. https://github.com/kuronosuFear/Sangokushi-Xtractor/releases

Offset 0x0000 - Marker [1D 78 33 01]
Offset 0x0004 - Size of Table [DD 4A 00 00] (0x00004add); Note needs to be multiplied by 0x10 for the correct table size.
Offset 0x0008 -  Alignment [20 00 00 00] (0x00000020); To get the correct offsets/address per entry in the table, use this as a multiplier
Offset 0x000c - Null
Offset 0x0010 - Table's first entry
#Table Structure (16 bytes per entry)
#[entryAddress : dword][null : dword][rawSizeOfData : dword][decompressedSize : dword]

Size of the Table = 0x00004add0 (306,640) Number of entries = 19,165

There are two kinds of data: Compressed (uses zlib: best compression [78 DA] header) and Uncompressed/RAW

The uncompressed/raw files can easily be extracted, and it can be identified by checking if the decompressedSize in the entry is 0.

Meanwhile, the compressed data has its own custom structure:

[decompressedSize : dword][firstChunkSize : dword][firstChunkData:chunkSize]
[secondChunkSize : dword][secondChunkData : secondChunkSize]
.
.
[lastChunkSize : dword][lastChunkData : lastChunkSize]

All starting offsets of the entries are aligned to 0x20, so KoeiTcmo does some padding if it's compressed data falls a little bit short.

Each zlib compressed chunk corresponds to 0x8000 bytes of the actual file. (It must be a resource/memory saving technique for the 3DS)

Writing a re-compiler seems very feasible.

So far, the only thing Karameru/Kukkii supports are the extracted *.sarc files.

Me and @NeonToaster1 identified where the text data are, but it isn't compatible with Kuriimu at the moment. (The extracted text files do not have a unique marker on their own. We're guessing that they're referenced by a different file somewhere)

Hopefully these data/findings help Sangokushi in being supported by Kuriimu.

IcySon55 commented 5 years ago

Working so far. Batch dumping is possible. Any idea if there's an accompanying file with filenames in the game?

Oh ok, it's compressed chunks. I remember this from PSARC, it sucked there and it'll suck here too! :/

kuronosuFear commented 5 years ago

No luck with finding the filename table yet. We just hope it isn't hidden in one more layer of encryption/compression.

IcySon55 commented 5 years ago

OK loading and extraction are done with: https://github.com/IcySon55/Kuriimu/commit/ca28f9e8376a6a0dabe3ef20fcd4178b28f72cee

If you can build Kuriimu then you can use it already.

kuronosuFear commented 5 years ago

Python script/executable can be found here that supports archive extraction and rebuilding: https://github.com/kuronosuFear/SangoKuro

onepiecefreak3 commented 3 years ago

Kuriimu2 now offers the X3 plugin from Karameru with save support and file replacement in its newest dev build and upcoming Release 1.2.1. If there are any more bugs regarding this format, please refer to Kuriimu2. Issue closed.