Sorry for the delay, I made some last-minute cosmetic changes. Here are all the tools I made, and something like a dev-log:
At the beginning I wanted to make a general cpk repacker. What I noticed is that it is not necessery to compress the files, for example all the cpk files (in the archive) are stored uncompressed, like in the mapXR.cpk (which contains only cpk files). However, you still need to edit the Toc values (offsets). Since it's easier to work with smaller files, I worked with the cpks from the demo, and I managed to make a 1:1 copy of the map archives. The rootR.cpk is almost the same, except the directory value is not constant. Everything worked fine in the demo, but because the files weren't compressed, the rootR was a bit bigger.
Then I tried these with the full game files, but there was a problem I realised when testing. In the Toc, every file has a 64bit offset. Theorically, the game could use files that are over 4GB (the size of all files in rootR is about 3.4GB). However most standart tools in programming (eg, fseek, ftell) use a 32 bit signed integer
(2,147,483,647 bytes max). Although you can work around this by using 64bit values, we don't know how whether the game supports it or not (since it was probably not designed for this large files). I tried the game with a rootR repacked with 64bit offsets, but it only showed the black screen, so it probably uses 32bit signed offset too (or I made something wrong
) Also you have to add padding after the files so it could be divided by 32 (AlignValue).
So if we have to keep the files under 2GB we have the following options:
- compress all files: we have to reverse the uncompressing feature in utftab, I think i could be done, but the source files have a very few comments or info.
- replace the original compressed file with the still compressed one from the english one: if you edit the unpacker script at around line 90, you can unpack the files, but for repacking you will need both rootR, or the sizes for the new files for setting the correct sizes in the Toc. I will try this method if we can't compress the files
- append the modified files to the end of the archive and point their offset to the new places. This is probably the easiest method, but you have to be very careful to not go over 2GB. You can't replace large datafiles like the voices with this, but if you just add the texts and textures it should still be a bit under 2GB. I made a working tool for this.
And while I was writing this I just remembered that the english scrips are not in the rootR but next to it, and I forgot to include them. <goes to test it> Well, the only thing I noticed is that Press X is also in english on the title screen. By the way, this new eboot is fantastic!
So, here are the tools: cpkforp 1.1c with gui
This is what most of you will need. It can add files to a cpk based on a file list. For this, you will need the original rootR (you can rename it if you want), the files from the english version (with keeping the original directory order), a special filelist with the files and file IDs in the archive and another one with the files you want to add. Run the program without any parameters for help. I also made a nice (?) gui for starting it for those who don't like command lines. However, the message log only updates after the program has finished. Well, better than nothing. About the lists, of course it would be better to read that directly from the cpk, but I wanted to keep it simple as possible so I made another program to do it. cpkforp source
It's been a long time I made something like this in C, it is not fool-proof but it works and almost fully commented so you don't have to spend hours thinking about what a line does. I post this for learning/development but you can use it as long as it is not commercial. cpkbuild beta with tocdump
This was the original program. Tocdump dumps the header parts of a cpk and cpkbuild makes a cpk file based on these and the new files. cpkbuild's code was upgraded to cpkforp, however tocdump is actually a modified version of hcs' cpk unpacker. I broke something in tocdump when I made it work with rootR, so it only works with that file now, before it could work with the mapXR files too. Recommended only for devs (hint: turn on verbose mode) rootR filelists
I made these with tocdump, you will need it for cpkforp. The first file is the list of all files, in the second are only the new files. You can copy any line from the firt one to the second as long as the final size of the cpk is under 2GB (2,147,483,647 bytes).
You can download all the files from here or from this link too: http://www.mediafire.com/?avc13v5oa17d2