Thursday, July 5, 2012

The Half Minute Hero 2 Archive


I've been working on unpacking and repacking the Yuusha 30 Second (Half Minute Hero 2) PSP game. I don't really have much experience in this kind of thing. I've only played around with one other archive, the first Half Minute Hero before, and all I did was unpack it. So I'm learning as I go. This is a document of what I've been able to accomplish so far:


1. Of course, you need the ISO.

2. Open the ISO with Daemon Tools
    Here are the files of note:
Raw Images (for the game's gallery mode) are stored in /PSP_GAME/USRDIR/RES/GALLERYTEX
The AT3 music is all stored in /PSP_GAME/USRDIR/RES/BGM
Cinematics (there's not really much) are all stored in /PSP_GAME/USRDIR/RAWRES
All the actual game data is in the JRZ archives /PSP_GAME/USRDIR

3. The JRZ format is as follows:
There is a header that goes from 0x00 to 0x2B. I haven't quite deciphered it.  Here is a sample:
               5F 5F 44 45 46 4C 41 54 45 5F 41 52 43 48 49 56 45 5F 53 5F 30 31 5F 5F
               (The above is "__DEFLATE_ARCHIVE_S_01__", but I don't know the next unique part)
               09 00 00 00 00 00 01 00 64 00 00 00 01 00 00 00 01 00 00 00

After that first header are the file descriptions.  They're in the following format, little endian:

               2 Bytes unknown
               2 Bytes for the number of bytes in the file name
               4 bytes unknown
               4 bytes unknown
               4 bytes for the file size
               4 bytes for the extracted file size
               4 bytes unknown
               4 bytes for the file offset

       Here is a sample:

               - PARTY01.BMP -
               00 00
               0C 00 (Number of Bytes for the Filename)
               00 00 00 00
               00 00 00 00
               92 0A 00 00 (File Size A)
               36 04 01 00 (Extracted File Size A)
               00 00 00 00
               A9 B1 3B 00 (File Offset A, so value is 0x3BB1A9)
               50 41 52 54 59 30 31 2E 42 4D 50 00 (File Name + 00)

Finally, is the file data, stored according to the file descriptions.

4. Decompressing the JRZ archives:
I use QuickBMS by aluigi.  The following bms script can be run against any JRZ file:

               GoTo 0x2C
               for i = 0 < 1000
                    get DUMMY short
                    get FILENAMELENGTH short
                    get DUMMY long
                    get DUMMY long
                    get FILESIZE long
                    get DUMMY long
                    get DUMMY long
                    get OFFSET long
                    getdstring NAME FILENAMELENGTH
                    log NAME OFFSET FILESIZE
               next i

5. Decompress Resulting Files
The resulting files seem to be in a zlib compressed stream.
        I use aluigi's offzip tool to unpack them.
        Here's the command format I use:

               offzip -a -m 8 "[FILE TO UNPACK]" "[DESTINATION]" 0

        Of course, I use script that automates running the command on all unpacked files.

6. Resulting Files:
We have a lot of *.BMP files, these are the sprites and such.
I think that *.S2MP files are map data.
All the text is buried within the *.DAT files.

7. Extracting Text
I haven't figured out the text format yet and it's something I'm working on.
        But if I take the *.DAT files and scrape all the 0x00 and 0xFF bytes, I get all the text.
        Each snippet of dialogue is preceded by a 0x01. I made a script to automate this.
        There are English letters in there, so I'm hoping the text substitution is easy.  I'm hoping the
        null characters are just padding so that the filesizes wouldn't even change.

So far, I've only extracted everything. I'm still working on putting it all back together. When I have a chance, I want to try:

1. Decompressing and Recompressing everything
2. Decompressing, editing text, and recompressing everything
3. Decompressing, editing an image, and recompressing everything
4. Writing tools to automate this entire process better.

I'm aware some of those "unknown" values might be checksums.  I know that things can be trickier than they seem. English may not be easy to insert, character spacing might be an issue, and so on.

If you'd like to help, please let me know!  I could certainly use it to figure this all out.  As I said, I don't really know what I'm doing, so even advice and hints would be much appreciated.

No comments:

  © Blogger template 'Isolation' by Ourblogtemplates.com 2008

Back to TOP