BattleBlock Theater (PC)

Textures, recreate headers, conversions, algorithms and parsing of image files
puggsoy
Posts: 161
Joined: Sat Dec 13, 2014 1:01 am

BattleBlock Theater (PC)

Post by puggsoy »

The only files that seem to contain any kind of graphical data are the .baf files in GameData\AnimFiles. Looking at them through graphic viewers such as TiledGGD and TextureFinder simply shows static, so they might be compressed somehow. They also likely contain some sort of frame information in addition to the graphics.

I've attached some zipped up sample files.
MerlinSVK
Posts: 165
Joined: Wed Aug 13, 2014 10:00 am

Re: BattleBlock Theater (PC)

Post by MerlinSVK »

It's compressed by Zlib.

decompression

Code: Select all

comtype zlib
get NAME filename
string NAME += ".dat"
get ZSIZE asize
math ZSIZE -= 4
get SIZE long
clog NAME 4 ZSIZE SIZE


compression

Code: Select all

get SIZE asize
log MEMORY_FILE 0 0
putvarchr MEMORY_FILE SIZE 0
log MEMORY_FILE 0 0
get NAME filename
string NAME += ".new"
putvarchr MEMORY_FILE 0 SIZE long
math SIZE -= 4
comtype zlib_compress
append
clog MEMORY_FILE 4 SIZE SIZE
append
get MSIZE asize MEMORY_FILE
log NAME 0 MSIZE MEMORY_FILE


Decompressed files are DDS textures with some added data on the begining.
puggsoy
Posts: 161
Joined: Sat Dec 13, 2014 1:01 am

Re: BattleBlock Theater (PC)

Post by puggsoy »

Oh wow, that's simple! Guess I should always try zlib when something looks compressed. Thank you!

Been looking some more into it, most of the data above the DDS files looks like animation data, which I don't really need. However I have managed to find a number of things:

  • At 0x00 is the number of DDS files (short)
  • At 0x04 is the number of animations (short)
  • At 0x50 is the first DDS length, followed by its offset (long). After this it repeats every 0x30 bytes (i.e. the following length + offset pairs are at 0x88, then 0xC0, and so on) for the number of DDS files.

I don't need the animation number but I noticed it anyway. The rest of the data doesn't seem relevant to extraction, but I would be interested nonetheless if anybody does manage to figure any of it out.

In any case, made a script to extract the DDS files:

Code: Select all

# BattleBlock Theater .baf format
#
# Written by puggsoy and MerlinSVK
# script for QuickBMS http://quickbms.aluigi.org

comtype zlib
get ZSIZE asize
math ZSIZE -= 4
get SIZE long
clog MEMORY_FILE 4 ZSIZE SIZE

get FILENUM short MEMORY_FILE

goto 0x50 MEMORY_FILE

for i = 1 <= FILENUM
   get SIZE long MEMORY_FILE
   get OFFSET long MEMORY_FILE
   get NAME filename
   set NUM string i
   string NAME -= 4
   string NAME += _
   string NAME += NUM
   string NAME += .dds
   
   log NAME OFFSET SIZE MEMORY_FILE
   
   goto 0x30 MEMORY_FILE SEEK_CUR
next i