Page 2 of 4

Re: Smackdown vs Raw 2010 - bpe again

Posted: Fri Nov 27, 2009 3:37 pm
by brienj
aluigi wrote:this particular type of compression (that I have called "yuke_bpe") is now included in QuickBMS 0.3.9a
Once again you come through and save me from having to make a program myself. Thanks!

Now if only someone takes the time to make a compressor for this format, I will be totally work free, and use what little free time I have on the game instead. :D

Re: Smackdown vs Raw 2010 - bpe again

Posted: Fri Nov 27, 2009 4:40 pm
by chrrox
The game can read uncompressed and compressed files there is no real need to re compress the content to have it load.

Re: Smackdown vs Raw 2010 - bpe again

Posted: Fri Nov 27, 2009 6:06 pm
by plodtrew
@chrrox, the problem I have with uncompressed files is the bigger filezies. I cant replace the originals with the bigger files on the disc without the game freezing.

Re: Smackdown vs Raw 2010 - bpe again

Posted: Fri Nov 27, 2009 7:02 pm
by chrrox
You must edit the whole pac file that is the problem.
you need to adjust the offsets there to accommodate the bigger file sizes.
even if you could re-compress the files they would not be the exact same size.
the easiest thing to modify would be the last pach file in each pac file because it would be simple to modify the size with a hex editor and it would only be one value you need to edit.
if you mention what you wish to accomplish I can try to help you.

Re: Smackdown vs Raw 2010 - bpe again

Posted: Sat Nov 28, 2009 12:29 am
by brienj
chrrox wrote:The game can read uncompressed and compressed files there is no real need to re compress the content to have it load.
Ok, that's good to know, I was going to test that, but now I don't need to.

Here is a QuickBMS script that will extract the character model PAC files for easy access. It only works on the chXXX.pac files and it will extract the compressed files into a folder and then extract the uncompressed files into another folder. The folder name will start with the basename of the chXXX.pac file. I've only tested it so far on SvR2010 for Xbox 360.

I know it could prolly be rewritten better, but hey, it works. :D

Code: Select all

IDString "EPK8"
Get MASTERNAME FILENAME
Get NAME BASENAME
Set AFOLDER NAME
String AFOLDER + Attire
GoTo 0x0800
IDString "EMD "
Get NUMBERPACS SHORT
Math NUMBERPACS / 4
Set DIRPOSITION 0x0814
For i = 0 < NUMBERPACS
Open "." MASTERNAME
Set FOLDERNAME AFOLDER
String FOLDERNAME + i
Set NAME FOLDERNAME
STRING NAME + \
STRING NAME + FOLDERNAME
STRING NAME + ".pac"
GoTo DIRPOSITION
get PACOFFSET long
get PACLENGTH long
math PACOFFSET += 8    # 0x4000
math PACOFFSET *= 0x800
math PACLENGTH *= 0x100
Log NAME PACOFFSET PACLENGTH
Math DIRPOSITION + 16
Set NAME FOLDERNAME
STRING NAME + ".pac"
Open FOLDERNAME NAME
IDString "PACH"
Get FILENAME BASENAME
Set CFOLDER FILENAME
String CFOLDER + compressed
Set UFOLDER FILENAME
String UFOLDER + uncompressed
GoTo 0x0004
Get NUMBERFILES LONG
SavePos DIROFFSET
Math TMP = NUMBERFILES
Math TMP * 12
Math DATAOFFSET = DIROFFSET
Math DATAOFFSET + TMP
GoTo DIROFFSET
For k = 0 < NUMBERFILES
Get UNKNOWN LONG
Get OFFSET LONG
Get LENGTH LONG
Math TMP = DATAOFFSET
Math TMP + OFFSET
Set NAME CFOLDER
STRING NAME + \
STRING NAME + file
if k < 10
STRING NAME + 0
endif
STRING NAME + k
STRING NAME + ".compressed"
Log NAME TMP LENGTH
next k
For k = 0 < NUMBERFILES
Set NAME file
if k < 10
STRING NAME + 0
endif
STRING NAME + k
STRING NAME + ".compressed"
Open CFOLDER NAME
IDString "BPE "
GoTo 0x008
Get ZSIZE LONG
Get SIZE LONG
ComType yuke_bpe
Set NAME UFOLDER
STRING NAME + \
STRING NAME + file
if k < 10
STRING NAME + 0
endif
STRING NAME + k
Clog NAME 16 ZSIZE SIZE
next k
next i

Re: Smackdown vs Raw 2010 - bpe again

Posted: Sat Nov 28, 2009 12:56 am
by brienj
Here is a QuickBMS script to extract the EDXX.pac files in the edit folder. Once again, it could prolly be done better, but it works! :P

Code: Select all

IDString "EPAC"
Get MASTERNAME FILENAME
Get NAME BASENAME
Set AFOLDER NAME
String AFOLDER + PacFile
GoTo 0x0804
Get NUMBERPACS SHORT
Math NUMBERPACS / 3
Set PACOFFSET 0x4000
Set DIRPOSITION 0x0813
For i = 0 < NUMBERPACS
Open "." MASTERNAME
Set FOLDERNAME AFOLDER
String FOLDERNAME + i
Set NAME FOLDERNAME
STRING NAME + \
STRING NAME + FOLDERNAME
STRING NAME + ".pac"
GoTo DIRPOSITION
Get PACLENGTH LONG
Log NAME PACOFFSET PACLENGTH
Math DIRPOSITION + 12
Math PACOFFSET + PACLENGTH
GoTo PACOFFSET
FindLoc OFFSET string "PACH" 0 0
Set PACOFFSET OFFSET
Set NAME FOLDERNAME
STRING NAME + ".pac"
Open FOLDERNAME NAME
IDString "PACH"
Get FILENAME BASENAME
Set CFOLDER FILENAME
String CFOLDER + compressed
Set UFOLDER FILENAME
String UFOLDER + uncompressed
GoTo 0x0004
Get NUMBERFILES LONG
SavePos DIROFFSET
Math TMP = NUMBERFILES
Math TMP * 12
Math DATAOFFSET = DIROFFSET
Math DATAOFFSET + TMP
GoTo DIROFFSET
For k = 0 < NUMBERFILES
Get UNKNOWN LONG
Get OFFSET LONG
Get LENGTH LONG
Math TMP = DATAOFFSET
Math TMP + OFFSET
Set NAME CFOLDER
STRING NAME + \
STRING NAME + file
if k < 10
STRING NAME + 0
endif
STRING NAME + k
STRING NAME + ".bpe"
Log NAME TMP LENGTH
next k
For k = 0 < NUMBERFILES
Set NAME file
if k < 10
STRING NAME + 0
endif
STRING NAME + k
STRING NAME + ".bpe"
Open CFOLDER NAME
IDString "BPE "
GoTo 0x008
Get ZSIZE LONG
Get SIZE LONG
ComType yuke_bpe
Set NAME UFOLDER
STRING NAME + \
STRING NAME + file
if k < 10
STRING NAME + 0
endif
STRING NAME + k
Clog NAME 16 ZSIZE SIZE
next k
next i

Re: Smackdown vs Raw 2010 - bpe again

Posted: Sat Nov 28, 2009 1:44 am
by brienj
Here is a QuickBMS Script to extract the bgXX.pac files in the bg folder. As before, not the best script writing, but it works. :D

Code: Select all

IDString "EPAC"
Get MASTERNAME FILENAME
Get NAME BASENAME
Set AFOLDER NAME
String AFOLDER + PacFile
GoTo 0x0800
IDString "STG "
Get NUMBERPACS SHORT
Math NUMBERPACS / 3
Set PACOFFSET 0x4000
Set DIRPOSITION 0x0813
For i = 0 < NUMBERPACS
Open "." MASTERNAME
Set FOLDERNAME AFOLDER
String FOLDERNAME + i
Set NAME FOLDERNAME
STRING NAME + \
STRING NAME + FOLDERNAME
STRING NAME + ".pac"
GoTo DIRPOSITION
Get PACLENGTH LONG
Log NAME PACOFFSET PACLENGTH
Math DIRPOSITION + 12
Math PACOFFSET + PACLENGTH
GoTo PACOFFSET
FindLoc OFFSET string "PACH" 0 0
Set PACOFFSET OFFSET
Set NAME FOLDERNAME
STRING NAME + ".pac"
Open FOLDERNAME NAME
IDString "PACH"
Get FILENAME BASENAME
Set CFOLDER FILENAME
String CFOLDER + compressed
Set UFOLDER FILENAME
String UFOLDER + uncompressed
GoTo 0x0004
Get NUMBERFILES LONG
SavePos DIROFFSET
Math TMP = NUMBERFILES
Math TMP * 12
Math DATAOFFSET = DIROFFSET
Math DATAOFFSET + TMP
GoTo DIROFFSET
For k = 0 < NUMBERFILES
Get UNKNOWN LONG
Get OFFSET LONG
Get LENGTH LONG
Math TMP = DATAOFFSET
Math TMP + OFFSET
Set NAME CFOLDER
STRING NAME + \
STRING NAME + file
if k < 10
STRING NAME + 0
endif
STRING NAME + k
STRING NAME + ".bpe"
Log NAME TMP LENGTH
next k
For k = 0 < NUMBERFILES
Set NAME file
if k < 10
STRING NAME + 0
endif
STRING NAME + k
STRING NAME + ".bpe"
Open CFOLDER NAME
IDString "BPE "
GoTo 0x008
Get ZSIZE LONG
Get SIZE LONG
ComType yuke_bpe
Set NAME UFOLDER
STRING NAME + \
STRING NAME + file
if k < 10
STRING NAME + 0
endif
STRING NAME + k
Clog NAME 16 ZSIZE SIZE
next k
next i

Re: Smackdown vs Raw 2010 - bpe again

Posted: Sat Nov 28, 2009 1:58 am
by brienj
If the script extracts a compressed folder, but not an uncompressed folder, then it means the compressed files aren't in BPE format, so you have to open them in hex editor and determine what format they are in. ;)

These should get you started, I'll make more as I figure them out.

Re: Smackdown vs Raw 2010 - bpe again

Posted: Sat Nov 28, 2009 2:31 am
by aluigi
the following quickbms script should be able to extract (and unpack automatically) any EPAC archive:
*edit* use the yuke.bms code posted below (it's EXACTLY like the one I posted plus separate handling of standalone PACH and BPE files)

Re: Smackdown vs Raw 2010 - bpe again

Posted: Sat Nov 28, 2009 2:45 am
by aluigi
well, I have decided to do a complete job including support also for PACH files and EBP chunks (so not only those included in the EPAC archives but also other provided as "stand-alone" files):
http://aluigi.org/papers/bms/yuke.bms

Re: Smackdown vs Raw 2010 - bpe again

Posted: Sat Nov 28, 2009 3:01 am
by aluigi
chrrox pointed me to those "EMD " fields of the EPAC archives which must be skipped, so I have updated the script to version 0.1.1

Re: Smackdown vs Raw 2010 - bpe again

Posted: Sat Nov 28, 2009 3:03 am
by brienj
It works on most of them, but here is one EPAC file it doesn't work on, plus an example of an EPK8 file (this one is John Cena's character file).

An EPAC file that doesn't work and also an example of an EPK8 file.

Thanks for your help. :)

Re: Smackdown vs Raw 2010 - bpe again

Posted: Sat Nov 28, 2009 3:07 am
by brienj
aluigi wrote:chrrox pointed me to those "EMD " fields of the EPAC archives which must be skipped, so I have updated the script to version 0.1.1
I get an error now that says: MEMORY_FILE has not been used in the script yet :eek:

Re: Smackdown vs Raw 2010 - bpe again

Posted: Sat Nov 28, 2009 3:40 am
by chrrox
the problem is the svr pac files don't contain that part so it just needs a simple if statement checking if the 4 bytes it reads is that and if not don't skip those 4 bytes.

Re: Smackdown vs Raw 2010 - bpe again

Posted: Sat Nov 28, 2009 3:56 am
by brienj
I figured it out, until he comes back, this is the script that will work:

Code: Select all

# Yuke games: EPAC archives, PACH files and BPE chunks (script 0.1.1)
# script for QuickBMS http://aluigi.org/papers.htm#quickbms

comtype yuke_bpe

# the following is only for being able to handle all the 3 files
get NAME filename
string NAME += ".unpacked"
getdstring SIGN 4
if SIGN == "PACH"
    print "PACH file"
    get SIZE asize
    log MEMORY_FILE 0 SIZE
    callfunction pach_unpack
    cleanexit
elif SIGN == "BPE "
    print "BPE chunk"
    get DUMMY long
    get ZSIZE long
    get SIZE long
    savepos OFFSET
    clog NAME OFFSET ZSIZE SIZE
    cleanexit
elif SIGN != "EPAC"
    cleanexit
endif

#idstring "EPAC"
print "EPAC archive"
goto 0x80C
for
    getdstring NAME 4
    if NAME == ""
        cleanexit
    endif
    get OFFSET long
    get SIZE long
    math OFFSET += 8    # 0x4000
    math OFFSET *= 0x800
    math SIZE   *= 0x100
    if NAME != "EMD "
        log MEMORY_FILE OFFSET SIZE
        callfunction pach_unpack
    endif
next

startfunction pach_unpack
    # unpack the PACH files
    getdstring SIGN 4 MEMORY_FILE
    if SIGN == "PACH"
        get CHUNKS long MEMORY_FILE
        savepos INFO_OFF MEMORY_FILE
        math BASE_OFF = CHUNKS
        math BASE_OFF *= 12
        math BASE_OFF += 8
        putvarchr MEMORY_FILE2 SIZE 0   # partial pre-allocation (speed)
        log MEMORY_FILE2 0 0
        append
        for j = 0 < CHUNKS
            goto INFO_OFF MEMORY_FILE
            get DUMMY long MEMORY_FILE
            get CHUNK_OFF long MEMORY_FILE
            get CHUNK_SIZE long MEMORY_FILE
            savepos INFO_OFF MEMORY_FILE
            math CHUNK_OFF += BASE_OFF
            goto CHUNK_OFF MEMORY_FILE
            getdstring SIGN 4 MEMORY_FILE
            if SIGN == "BPE "
                get DUMMY long MEMORY_FILE
                get ZSIZE long MEMORY_FILE
                get SIZE long MEMORY_FILE
                savepos OFFSET MEMORY_FILE
                clog MEMORY_FILE2 OFFSET ZSIZE SIZE MEMORY_FILE
            else
                log MEMORY_FILE2 CHUNK_OFF CHUNK_SIZE MEMORY_FILE
            endif
        next j
        append
        get SIZE asize MEMORY_FILE2
        log NAME 0 SIZE MEMORY_FILE2
    else
        log NAME 0 SIZE MEMORY_FILE
    endif
endfunction