ROM Hack Extracting .PCK files?

Zarxrax

Well-Known Member
OP
Member
Joined
Oct 5, 2005
Messages
369
Trophies
1
Website
Visit site
XP
1,573
Country
United States
I would like to extract the English and Japanese scripts from the game Little Charo, but it looks like I'll need some help. After I unpacked the rom, I saw that the data files are stored in a .PCK format. I found some tool thats supposed to extract PCK archives, but it doesn't work on these.
If I open up the scripts in a text editor I can see bits of the script here and there, but its mostly just gibberish.
 

jjjewel

Well-Known Member
Member
Joined
Dec 17, 2009
Messages
1,010
Trophies
0
XP
522
Country
United States
The scripts in .pck files are compressed.

The file with the same name as .pck file but with file extension .tbl contains addresses of the sub-files in .pck. You need to unpack the files first and then decompress them. (Ex. for _out_en.pck, look for the table file in _out_en.tbl.)

(If your tool can unpack and repack the sub-files, you can try BatchLZ77 for compression/decompression. Otherwise, this might need a custom tool.)

BatchLZ77 link
http://code.google.com/p/darthnemesis/down...mp;can=2&q=
 

Zarxrax

Well-Known Member
OP
Member
Joined
Oct 5, 2005
Messages
369
Trophies
1
Website
Visit site
XP
1,573
Country
United States
Hey, I wanted to say thanks.
For some reason, I never saw your reply earlier, though I kept checking this thread for a few days O.o

There are indeed tbl files for each of the pck files.
Any idea as to how I might unpack the sub-files that you mentioned?
 

jjjewel

Well-Known Member
Member
Joined
Dec 17, 2009
Messages
1,010
Trophies
0
XP
522
Country
United States
First, did you check the file in IdxRes folder? Some of the .dat files contain English and Japanese text encoded in Unicode. (Ex. Try IdxRes_EngResult.dat.)

Then for the .pck files, a program called CrystalTile2 will be handy. So try to get it first. (Any version should be fine.)

I'll give a an example of out_en.pck and out_en.tbl then.
- First, open both files in CrystalTile2.
- Look at _out_en.tbl. You'll see 00000000 at hex address 0004, and then 1E270000 at hex address 0008, and so on. These are your addresses where you have to decompress your _out_en.pck.
- Read each number at every 4 bytes backward to get the address, for example you will get 00000000, 0000271E, 000038B7, ...
- Now go to your _out_en.pck. Point your mouse on the exact address you get from the previous step. (Ex. for the first one, point your mouse at hex address 00000000 at the beginning of the file.) Then go to Tools menu and select LZ77/Huffman Extract (U) and save as some filename. The program will ask if you want to open the extract file, choose ok. (Otherwise, locate the file and open it.)
- The file here will be encoded in UTF-8. (You can view the text in CrystalTile2. In my version, it's under TBL/Code Page/Unicode (UTF-8))
- Then repeat the steps for the next address. (0000271E, 000038B7, ...)

This method will be very time consuming though.

If you know some programming, or know someone who can write a program for you, it will be a lot easier. Just read addresses at every 4 bytes from .tbl file and extract each part of the file from .pck. After that you can use BatchLZ77 to decompress the files, or some programmer might even be able to add decompresser in the extraction process.

By the way, I'm not sure if _out_en.pck contains anything you want. By randomly extracting them, I only see messages that say "This file doesn't have English translation." and such. So, if you do it manually, try checking what you get first. There might not be anything worth extracting in there.

(Edited for some misspellings.
happy.gif
)
 

Zarxrax

Well-Known Member
OP
Member
Joined
Oct 5, 2005
Messages
369
Trophies
1
Website
Visit site
XP
1,573
Country
United States
I feel like I'm sooo close to getting this now.
I wrote a program to get the values from the table, and it worked.
So then I thought I would try making the program split the data file according to the values, but this is where I'm having trouble.

Once my files are split, I put them into the batchLZ77, and... it doesn't work. It just outputs empty decompressed files.
So, I'm not really sure where I'm going wrong. It could be that I'm splitting the files totally incorrectly, or it could be that I've just got an off-by-1 error somewhere. Either way, I don't know how to debug it to see what I'm doing wrong.

Here's my code, maybe you could take a look over it, if you can understand it?
It's in C#

http://pastebin.com/YCregGR0
 

Tricky Upgrade

Active Member
Newcomer
Joined
Aug 14, 2010
Messages
27
Trophies
0
Age
31
Location
Mozambique
Website
Visit site
XP
170
Country
Mozambique
Saw your code and I think you should store the data in a byte array (that will make it easier to get the correct position). Basically what you do is this:
- Create two byte arrays (one for the .tbl file and other for the .pck file)
- Read the address in the .tbl array (you can use the BitConverter class)
- Create another byte array (for the file that the .tbl address points to)
- Copy the contents from the .pck array to the one you just created
- And finally write the copied contentes to a file, after this use BatchLZ77 to decompress the file

I don't know how the .tbl determines the end of a file but you can subtract the current address from the next one to get the length of the file.

PS: I can't debug your code since I don't have the files

Edit: Your reading the addresses in the wrong way, the first four bytes are null so you'll want to read 4 bytes from 0x4 (which will leave you in address 0x8) and so on... and replace sizeof(int) with sizeof(byte)
 

Zarxrax

Well-Known Member
OP
Member
Joined
Oct 5, 2005
Messages
369
Trophies
1
Website
Visit site
XP
1,573
Country
United States
Aha, your comment helped me to see what I was doing wrong!

I had stupidly written the line "int buffer = b2.ReadByte();"
Using an int type rather than a byte, it was writing 4 bytes at a time into my output files (3 of them empty).
So I fixed that, and now the output it almost perfect.

My output files are nowhere near the filesize of the input, so I've probably got some stupid mistake in there which is keeping it from reading all the way to the end. I'll take a look at that later on, and then I should hopefully be finished with this, finally!

Edit: yep, I had another issue using int instead of byte. I'm now able to extract all the data.
Now to just sort through it and see if I can find what I need!
 

Zarxrax

Well-Known Member
OP
Member
Joined
Oct 5, 2005
Messages
369
Trophies
1
Website
Visit site
XP
1,573
Country
United States
Alright now, decompression with LZ77...
There are 2 options... type 10, and type 11.
What is the difference and how do I know what to choose? Output of both seems identical.

And then, when viewing the files as utf8, I can read both english and Japanese in the output, but there is still a lot of garbage data. Is this normal?
 

jjjewel

Well-Known Member
Member
Joined
Dec 17, 2009
Messages
1,010
Trophies
0
XP
522
Country
United States
Zarxrax said:
Alright now, decompression with LZ77...
There are 2 options... type 10, and type 11.
What is the difference and how do I know what to choose? Output of both seems identical.

And then, when viewing the files as utf8, I can read both english and Japanese in the output, but there is still a lot of garbage data. Is this normal?

Does it work now? Each of your output's first byte should have a value 0x10. And you can use the default type (Type 10) for BatchLZ77.

When you extract, first you get the table addresses, such as 00000000, 0000271E, 000038B7, ...
So you extract the first part of .pck from 00000000 to 0000271D. (The end of your first file will be 1 byte before the next address, and so on.)

I don't know C#, so I don't know what went wrong. But you can try extracting a few files first. BatchLZ77 will auto-detect it if you extract it wrong. (I didn't try to extract the file and test though. I don't think there will be any problem. But feel free to post here if you encounter problems. I can try to take a look.)

And the game will store some control codes in the scripts too. So, garbage data are common. (They are actually not garbage, but they are not the part of text that you need.
happy.gif
)
 

Zarxrax

Well-Known Member
OP
Member
Joined
Oct 5, 2005
Messages
369
Trophies
1
Website
Visit site
XP
1,573
Country
United States
Yep I got it all extracted like I needed.
Now I just need to organize it and figure which text belongs with which parts of the game.

Thanks for the help everyone
smile.gif
 

Site & Scene News

Popular threads in this forum

Recent Content

General chit-chat
Help Users
    Psionic Roshambo @ Psionic Roshambo: https://www.youtube.com/watch?v=A0FyqCEfD0E