Yu-Gi-Oh! Power of Chaos (*.bin, *.txt and *.yga)

How to translate the files of a game
Rancher
Posts: 17
Joined: Wed May 06, 2015 7:12 pm

Yu-Gi-Oh! Power of Chaos (*.bin, *.txt and *.yga)

Post by Rancher »

Taken from the GameFAQs concerning .dat files which contain above mentioned files; it would be a good idea to create a QuickBMS script for this game format, too:

------------------------
10. Data Files Structure
------------------------
The structure of the data files are the same in all three of the Power of Chaos
games. There two files in which all of the information is stored:

data.dat - everything except sound data (text files [*.txt], bitmaps [*.bmp],
opponent decks [*.ydc], etc.)
Voice.dat - sound data (sound effects, music, and voice-overs [*.wav])

Both of them operate the same way:
Offset: Purpose:
0-7 (8 bytes) a tag acknowledging that the file is from Power of
Chaos
8-11 (4 bytes) unknown
12-279 (268 bytes each) individual file information
280-547
...
etc.
the rest file contents

Individual file information segments consist of four parts: filename (bytes
0-255), file starting offset (256-259 bytes), uncompressed size(?) (bytes 260-
263), and compressed (in-file) size (264-267 bytes). The procedure for
extracting this information goes as follows:

filename
--------
swap the hexadecimal values of each byte and chop off the trailing zeros

file offset, uncompressed size(?), and compressed size
------------------------------------------------------
byte0 + 256^1 * byte1 + 256^2 * byte2 + 256^3 * byte3

Using the file starting offset and compressed size, you can easily pull out the
file information. How the files are compressed is unknown (toss me an e-mail if
you figure it out), but most of the files are stored uncompressed, so this
isn't too much of a problem.

By the way, I've slapped together a small program that does all of this:
http://crispymarshmallow.home.comcast.net/unpacker.exe (needs Microsoft .NET
Framework 2.0)

Some stuff you might want to look at:
data.dat:
\card\*.bmp - card images
\?\file\*.ydc - the opponent's decks (? = y, k, or j)

voice.dat:
everything - all game audio is at your disposal


An extractor already exists; here's the source code of it and the documentation.

Anyway, I attached two .bin files with card descriptions: a binary and a decompiled one I found on Google (I don't know if the content is the same; this game has a lot of mods floating around the net), binary .txt files (I found a decompiled version of "list_card.txt" here) and .yga one. Please help me decompile and recompile them back. Thank you in advance!
Rancher
Posts: 17
Joined: Wed May 06, 2015 7:12 pm

Re: Yu-Gi-Oh! Power of Chaos (*.bin, *.txt and *.yga)

Post by Rancher »

Anyone?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Yu-Gi-Oh! Power of Chaos (*.bin, *.txt and *.yga)

Post by aluigi »

In my opinion the algorithm is lzss with the init char set to 0x00 (comtype lzss0).
The only problem I see with card_desceng.bin is that the output file from about offset 0x1e8cc is no longer good, so I guess it's a variant but my scanner didn't give other results. My other idea is that it's just lzss 0x00 but the file is divided in chunks.

For example title.txt should contain a bitmap file after the text I guess, but it's output is ok till one point and then starts to be garbage.
Rancher
Posts: 17
Joined: Wed May 06, 2015 7:12 pm

Re: Yu-Gi-Oh! Power of Chaos (*.bin, *.txt and *.yga)

Post by Rancher »

So there is no solution for now? Did you see the decompiled files I added as a reference?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Yu-Gi-Oh! Power of Chaos (*.bin, *.txt and *.yga)

Post by aluigi »

They are not the same.
card_desceng.dec.bin is NOT the decompressed data of card_desceng.bin.

Try this to understand what I mean:

Code: Select all

comtype lzss0
get ZSIZE asize
xmath SIZE "ZSIZE * 10"
clog "dump.dat" 0 ZSIZE SIZE

With card_desceng.bin you can see that the output is perfect till offset 0x1e8cc and then it starts to be wrong probably because that's data of another compressed file and not part of the current data.
Rancher
Posts: 17
Joined: Wed May 06, 2015 7:12 pm

Re: Yu-Gi-Oh! Power of Chaos (*.bin, *.txt and *.yga)

Post by Rancher »

A guy on Xentax managed to decompress card_desceng.bin, but recompression is the problem. I'll quote:

admirzuza wrote:how to compress files back after decompressing?

decompression works fine, but compression doesnt work (several bytes are missing)

in attached zip file u will find original compressed file (card_desceng_compressed), file after being decompressed (card_desceng_decompressed), and file being compressed back again but with different size thn original (card_desceng_compress2)..

NOTE: nothing has been changed inside files during compression/decompression

thanks :wink:

Luigi, can you try again based on the attached files? If those help at all, considering he didn't share what he did to decompress them. Anyone else? What about recompression? Thank you.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Yu-Gi-Oh! Power of Chaos (*.bin, *.txt and *.yga)

Post by aluigi »

I have tried the reimport mode and it worked correctly:
quickbms script.bms card_desceng_compressed.bin
quickbms -r -w script.bms card_desceng_compressed.bin

The re-extracted file is correct and the new and old archive are the same if the file has not been modified.
Rancher
Posts: 17
Joined: Wed May 06, 2015 7:12 pm

Re: Yu-Gi-Oh! Power of Chaos (*.bin, *.txt and *.yga)

Post by Rancher »

Great news! Can you share the script? Thanks.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Yu-Gi-Oh! Power of Chaos (*.bin, *.txt and *.yga)

Post by aluigi »

I used just the one above I posted the 02 Jul 2015.
Considering that in that post I wrote that the script decompresses the data incorrectly, I don't know if it may be considered a success.
Probably it's a success with small files that should not be affected by the error.
Rancher
Posts: 17
Joined: Wed May 06, 2015 7:12 pm

Re: Yu-Gi-Oh! Power of Chaos (*.bin, *.txt and *.yga)

Post by Rancher »

I just tried the script to decompress the file, but as you said, it works until one point and then it starts to malfunction. :( I'll try to get in touch with the guy who managed to decompress it, maybe it would help you write a reimport script based on his script.