Dustforce (extensionless)

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

Dustforce (extensionless)

Post by puggsoy »

This is for the extensionless sprite files from Dustforce, in the folder content/sprites.

Code: Select all

# Dustforce extensionless sprite format
#
# Written by puggsoy
# script for QuickBMS http://quickbms.aluigi.org

comtype zlib_noerror
get FSIZE asize
goto 0x12
get OFFSET long
math OFFSET += 0x1C
goto 0x1A

for STOP = false != true
   get NMSZ byte
   getdstring NAMEEND NMSZ
   get NMSZ byte
   getdstring TMPNAME NMSZ
   string TMPNAME += NAMEEND
   get ZERO long
   get SKIP1 short
   get SKIP2 short
   getdstring DUMMY 7
   savepos TMP
   math SKIP1 *= 0x1B
   math TMP += SKIP1
   goto TMP
   callfunction getbounds 1
   savepos TMP
   math HIGHEST += 1
   math HIGHEST - LOWEST
   set PICNUM HIGHEST
   
   for i = 0 < PICNUM
      goto OFFSET
      get SIZE long
      savepos OFFSET
      set NAME TMPNAME
      string NAME += "_"
      string NAME += i
      string NAME += ".dec"
      
      clog NAME OFFSET SIZE SIZE
      
      math OFFSET += SIZE
      
      if OFFSET >= FSIZE
         set STOP true
         set i PICNUM
      else
         math OFFSET += 2
      endif
   next i
   
   goto TMP
next

startfunction getbounds
   set HIGHEST 0
   set LOWEST 0xFF
   
   for i = 0 < SKIP2
      get t short
      
      if t > HIGHEST
         set HIGHEST t
      endif
      
      if t < LOWEST
         set LOWEST t
      endif
      
      getdstring DUMMY 8
   next i
endfunction


This was tough. Right now all it does is extract the individual image files and gives them the extension .dec. These files are raw 32-bit BGRA, all 102x102 pixels. They're all parts though, so I need to try and figure out how to put them together (the files they're extracted from probably have info). Once I know how I'll probably make a program to extract and convert them into proper images in one go. I thought this script might still be useful though.