[Help] The King of Fighters 98 UM (PS2)

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
Hiro_Tex
Posts: 1
Joined: Fri Apr 19, 2019 8:24 pm

[Help] The King of Fighters 98 UM (PS2)

Post by Hiro_Tex »

Hi all, i need help in decompressing the format .grc, because i don't know how to make scripts for QuickBMS, i already have a compressed and decompressed file if you need examples. The algorithm is as follows:
- Read one byte at the time
- If the byte is less than 0xC0, export it.
- If the byte is 0xC0, end the decompression.
- If the byte is 0xC1, export the next byte directly
- if the byte is more than 0xC1 (0xC2, 0xC3...), subtract 0xC0 and you have the number of bytes that will be exported (for example, if you have 0xC3, 3 bytes will be exported), and read the next byte, this byte contains the number from where you have to start exporting, for example, if you have "00 00 00 C3 03", you will have in the exported file "00 00 00 00 00 00", and if you have 08 08 00 00 00 C2 05, you will have in the exported file "08 08 00 00 00 08 08".

Image

I have attached the 2 files.

If anyone can make a script for this or tell me how to do it, I will be very thankful!
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: [Help] The King of Fighters 98 UM (PS2)

Post by aluigi »

This algorithm already exists in quickbms and it's called grc:

Code: Select all

comtype grc
get ZSIZE asize
xmath SIZE "ZSIZE * 10"
get NAME basename
clog NAME 0 ZSIZE SIZE
nonokyo
Posts: 2
Joined: Tue Jul 07, 2020 9:11 pm

Re: [Help] The King of Fighters 98 UM (PS2)

Post by nonokyo »

Hello
I need your help please. I need to get the artworks from de the PS2 SNK games and the files are *.GRC

I don't know how to get them with quickbms (I'm a very noob ^^), someone can help to extract the pictures from these files ?

Thanks a lot
emir
Posts: 11
Joined: Fri Oct 24, 2014 11:20 am

Re: [Help] The King of Fighters 98 UM (PS2)

Post by emir »

Code: Select all

int GrcEncrypt(char* GrcBug, char* DecBug, int GrcSize)
{
        int i=0;
        int k=0;
        int len;
        int dat;
        int declen;
       
        do
        {
                dat = GrcBug[i++] & 0xff;

                if( (dat & 0xc0) == 0xc0)
                {
                        len = dat & 0x3F;

                        if(len == 1)
                        {
                                DecBug[k++] = GrcBug[i++] & 0xff;
                        }
                        else
                        {
                                declen = GrcBug[i++] & 0xff;

                                if(len <= 0) continue;

                                do
                                {
                                        DecBug[k++] = DecBug[k - declen];
                                }
                                while(--len != 0);
                        }
                }
                else
                {
                        DecBug[k++] = dat;
                }
        }
        while ( i < GrcSize );

        return k;
}
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: [Help] The King of Fighters 98 UM (PS2)

Post by aluigi »

@nonokyo
Simple, copy the script I posted in a text file, then double-click on quickbms.exe, select the text file, select the grc file and then a folder where extracting the files.

@emir
That's the same algorithm used in quickbms with "comtype grc":

Code: Select all

int ungrc(u8 *in, int insz, u8 *out) {
    u8  *inl = in + insz;
    u8  *o = out;
    u8  c, back;
    while(in < inl) {
        c = *in++;
        if(c < 0xc0) {
            *o++ = c;
        } else if(c == 0xc0) {
            break;
        } else if(c == 0xc1) {
            *o++ = *in++;
        } else if(c > 0xc1) {
            back = *in++;
            for(c -= 0xc0; c > 0; c--) {
                *o = *(o - back);
                o++;
            }
        }
    }
    return o - out;
}