.PAK File From JALECO Classic Game

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
indrasudo
Posts: 8
Joined: Tue Oct 12, 2021 10:07 am

.PAK File From JALECO Classic Game

Post by indrasudo »

The Archive from japanese game by JALECO 1998
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: .PAK File From JALECO Classic Game

Post by aluigi »

Do you know the exact name of that game?

It looks like all the files are compressed with lzss and there are no filenames:

Code: Select all

# JALECO Classic Game of 1998

comtype lzss0
get FILES long
for i = 0 <= FILES
    get OFFSET long
    putarray 0 i OFFSET
next i
for i = 0 < FILES
    getarray OFFSET 0 i
    math i + 1
    getarray SIZE   0 i
    math SIZE - OFFSET

    goto OFFSET
    get ZSIZE long
    math OFFSET + 4
    math SIZE   - 4
    clog "" OFFSET ZSIZE SIZE
next
BloodRaynare
Posts: 367
Joined: Fri Mar 10, 2017 7:23 am

Re: .PAK File From JALECO Classic Game

Post by BloodRaynare »

Well what a coincidence, I was working with these files yesterday as well, these files were from "Bakusou Kyoudai Let's & Go!! Eternal Wings". And this is just the glimpse of one of the formats.
For some reason, in this game Jaleco uses a varying format with a simple headers (Some are nested archives, then some files starts with only one ZSIZE field without any FILES or OFFSET fields preceding it, probably because it only holds one file, or my favorite, one of the files inside the archive was uncompressed, without any flags to indicate it), making it bit confusing to write a extraction scripts.

Here's my own spin of the extraction scripts:

Code: Select all

# Bakusou Kyoudai Let's & Go!! Eternal Wings
# Extraction scripts by BloodRaynare

math EXTRACTION_MODE = 0

comtype lzss0

get FNAME basename

if EXTRACTION_MODE == 2
   get ZSIZE long
   string NAME p "%s." FNAME
   clog NAME 4 ZSIZE 0x1000000
else
   get FILES long
   for i = 0 < FILES
      get OFFSET long
      putarray 0 i OFFSET
   next i
   get ENDSIZE long
   
   for i = 0 < FILES
      getarray OFFSET 0 i
      math i + 1
      if EXTRACTION_MODE == 1
         if FILES == i
            xmath SIZE "ENDSIZE - OFFSET"
         else
            getarray NEXT_OFFSET 0 i
            xmath SIZE "NEXT_OFFSET - OFFSET"
         endif
         string NAME p "%s.%03i" FNAME i
         log NAME OFFSET SIZE
      else
         goto OFFSET
         get ZSIZE long
         if ZSIZE == 0
            savepos CURRPOS
            if CURRPOS >= ENDSIZE
               break
            endif
            get ZSIZE_TEST2 long
            if ZSIZE_TEST2 == 0
               math EXTRACTION_MODE == 3
            else
               continue
            endif
         endif
         math ZSIZE x+ 2
         if EXTRACTION_MODE != 3
            math OFFSET + 4
         endif
         string NAME p "%s.%03i" FNAME i
         if EXTRACTION_MODE == 3
            if ZSIZE_TEST2 == 0
               if FILES == i
                  xmath SIZE "ENDSIZE - OFFSET"
               else
                  getarray NEXT_OFFSET 0 i
                  xmath SIZE "NEXT_OFFSET - OFFSET"
               endif
            else
               math SIZE = ZSIZE
            endif
            log NAME OFFSET SIZE
         else
            clog NAME OFFSET ZSIZE 0x1000000
         endif
      endif
   next
endif


Yeah, the scripts was a bit messy and could be a bit cleaner, but this is the best I can do.
Also notice that I added a variable to set the extraction mode along with the condition to accommodate it, it's because of the variations of the files inside the disc.