Kung Fu Panda - PS2 [WBK]

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
Warthog1336
Posts: 140
Joined: Mon Feb 05, 2018 5:45 pm

Kung Fu Panda - PS2 [WBK]

Post by Warthog1336 »

Hi! I need a script for unpacking this WBK archive format (not the same as Spider-Man 2 WAVEBK), please.

Samples: PS2

Thanks!
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Kung Fu Panda - PS2 [WBK]

Post by aluigi »

There is a "NSLB" magic at the beginning and PS adpcm data from offset 0x10000 but didn't investigate the format because it's not very simple.
JackTheRipper
Posts: 51
Joined: Mon Jan 10, 2022 12:12 am

Re: Kung Fu Panda - PS2 [WBK]

Post by JackTheRipper »

For now, with newer VGMStream builds it can support WBKs with NSLB

Alternately, you can use VGMToolBox on Sony ADPCM extractor.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: Kung Fu Panda - PS2 [WBK]

Post by AlphaTwentyThree »

Here's the script I just wrote but just for that single file. I set all streams to mono but there may be other wbk files that contain stereo files and have the interleave saved in the specs area. Let me know if it works.

Code: Select all

# Kung Fu Panda (PS2) - *.wbk extractor

# (c) 2022-01-10 by AlphaTwentyThree of Zenhax
# script for QuickBMS http://quickbms.aluigi.org

idstring "NSLB"
goto 0x24
get LISTOFF long # stream specs
goto 0x2c
get HEADER long
goto 0x34
get BASEOFF long
goto 0x3c
get FSIZE long
xmath ENTRIES "(HEADER - LISTOFF) / 0x50"
xmath FILES "(LISTOFF - 0x80) / 0x14"
goto 0x80
for i = 0 < FILES
   get NAMEPOS long
   math NAMEPOS += HEADER
   savepos MYOFF
   goto NAMEPOS
   get NAME string
   putArray 0 i NAME
   goto MYOFF
next i
for i = 0 < ENTRIES2
   get SPECSOFF long
   math SPECSOFF += LISTOFF
   get OFFSET long
   math OFFSET += BASEOFF
   get SIZE long
   get UNK2 long
   getArray NAME 0 i
   savepos MYOFF
   goto SPECSOFF
   get FREQ short
   set CH 1
   set INTERLEAVE 0x10
   callfunction SS2 1
   goto MYOFF
next i

startfunction SS2
   xmath PSIZE "SIZE + 0x28"
   putVarChr MEMORY_FILE SIZE 0
   log MEMORY_FILE 0 0
   set MEMORY_FILE binary "\x53\x53\x68\x64\x18\x00\x00\x00\x10\x00\x00\x00\xb0\x36\x00\x00\x02\x00\x00\x00\xc0\x2f\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x53\x53\x62\x64\x00\xe8\x11\x00"
   append
   log MEMORY_FILE OFFSET SIZE
   append
   putVarChr MEMORY_FILE 0x24 SIZE long
   putVarChr MEMORY_FILE 0xc FREQ long
   putVarChr MEMORY_FILE 0x14 INTERLEAVE long
   putVarChr MEMORY_FILE 0x10 CH byte
   get SIZE asize MEMORY_FILE
   string NAME += ".ss2"
   log NAME 0 SIZE MEMORY_FILE
endfunction
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: Kung Fu Panda - PS2 [WBK]

Post by AlphaTwentyThree »

Something is wrong - those archives have a really strange quirk when they contain a stereo file: The stereo file's offset isn't listed in the TOC anymore but in the header. Additionally, offsets of the other files in the TOC get some shift when they lie where the stereo file also occupies space. Why on earth they would program it this way is absolutely unintelligible...
Seems possible to adjust though.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: Kung Fu Panda - PS2 [WBK]

Post by AlphaTwentyThree »

Ok, I've adjusted the script to a single wbk file, moved over to the next and all the offsets were wrong again. This is really frustrating. Need to find a new strategy. I'm suspecting that I need to put everything into an array, sort it and somehow calculate the offset shift after the stereo file another way. For that one file it was 0x20000 at least but it wasn't stated inside the header anywhere.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: Kung Fu Panda - PS2 [WBK]

Post by AlphaTwentyThree »

I'm on the brink of giving up to be honest. I've tried to find some system where to add or subtract some value from the offset and could find any. Here's a screenshot of a random file where I automatically marked where the offset is wrong:
Image

the colums show file number, offset where the specs can be found, offset, size and some unknown value. There seems to rhyme or reason behind which files are wrong as you can see.
I don't know if I'll continue very far from here any more...
I could try to get the correct files where the offset is correct and upload the script if you want though. The first file in the list seems to be the music at least it seems.
AlphaTwentyThree
Posts: 909
Joined: Sat Aug 09, 2014 11:21 am

Re: Kung Fu Panda - PS2 [WBK]

Post by AlphaTwentyThree »

Checking again with another file reveals that even more offsets point to the wrong files. I'm pretty much lost here...