# Traveller's Tales games DAT files extractor (script 0.3) # LEGO Batman # LEGO Star Wars # LEGO Indiana Jones # LEGO Harry Potter # Transformers # others, check them on http://www.ttgames.com # # this script is a complete chaos... it's only a work-around since I didn't finish the research # if you want all the files in PERFECT state you must set NAMELESS to 1 # # script for QuickBMS http://aluigi.org/papers.htm#quickbms print "NOTE that this script is a work-around so will not work with all the files\nif you want to extract ALL the files without names (but they will be 100% corrects) edit this script setting NAMELESS to 1" set NAMELESS long 0 # set to 1 to extract the files without names comtype lz2k get INFO_OFF long if INFO_OFF & 0x80000000 math INFO_OFF ^= 0xffffffff math INFO_OFF <<= 8 math INFO_OFF += 0x100 endif get INFO_SIZE long log MEMORY_FILE INFO_OFF INFO_SIZE get TYPE_BOH long MEMORY_FILE get FILES long MEMORY_FILE savepos INFO_OFF MEMORY_FILE math TMP = FILES math TMP *= 16 math NAME_INFO = INFO_OFF math NAME_INFO += TMP goto NAME_INFO MEMORY_FILE get NAMES long MEMORY_FILE savepos NAME_INFO MEMORY_FILE math TMP = NAMES math TMP *= 8 math NAME_OFF = NAME_INFO math NAME_OFF += TMP goto NAME_OFF MEMORY_FILE get NAMECRC_OFF long MEMORY_FILE savepos NAME_OFF MEMORY_FILE math NAMECRC_OFF += NAME_OFF goto NAMECRC_OFF MEMORY_FILE for i = 0 < FILES get CRC long MEMORY_FILE putarray 0 i CRC next i if TYPE_BOH <= -2 get DUMMY1 long MEMORY_FILE get DUMMY2 long MEMORY_FILE if DUMMY1 > 0 #print "Error: not implemented yet" #cleanexit endif endif # print "files: %FILES%" # print "names: %NAMES%" # print "info_off: %INFO_OFF%" # print "info_size: %INFO_SIZE%" # print "name_info: %NAME_INFO%" # print "name_off: %NAME_OFF%" # print "namecrc_off: %NAMECRC_OFF%" set NAMEZ long 0 set FULLNAME string "" set FULLPATH string "" for i = 0 < FILES # do NOT try to understand this part because I have not understood it too :) do goto NAME_INFO MEMORY_FILE get NEXT short MEMORY_FILE get PREV short MEMORY_FILE get OFF long MEMORY_FILE savepos NAME_INFO MEMORY_FILE math OFF += NAME_OFF goto OFF MEMORY_FILE get NAME string MEMORY_FILE if NEXT & 0x8000 # 16bit sign conversion math NEXT |= 0xffff0000 endif putarray 1 NAMEZ NAME if NEXT > 0 # folder getarray OLDNAME 1 PREV string FULLPATH >>= OLDNAME if NAME != "" string FULLPATH += NAME string FULLPATH += \ endif endif math NAMEZ += 1 while NEXT > 0 set FULLNAME string FULLPATH string FULLNAME += NAME if NAMELESS == 0 math CRC = 0x811c9dc5 strlen NAMESZ FULLNAME for j = 0 < NAMESZ getvarchr CHR FULLNAME j if CHR >= 0x61 if CHR <= 0x7a math CHR -= 0x20 endif endif math CRC ^= CHR math CRC *= 0x199933 next j for j = 0 < FILES getarray TMP 0 j if CRC == TMP break endif next j if j >= FILES print "Alert: the crc of the file %FULLNAME% has not been found, it can't be extracted!" #cleanexit # all wrongs! math j = i #math TMP = NEXT #math j = 0 #math j -= NEXT #math j -= 1 endif math TMP = j else math TMP = i endif math TMP *= 16 math TMP += INFO_OFF goto TMP MEMORY_FILE get OFFSET long MEMORY_FILE math OFFSET <<= 8 get ZSIZE long MEMORY_FILE get SIZE long MEMORY_FILE get PACKED long MEMORY_FILE goto OFFSET getdstring SIGN 4 if SIGN == "LZ2K" set PACKED long 2 else set PACKED long 0 endif if PACKED & 2 callfunction UNLZ2K log FULLNAME 0 SIZE MEMORY_FILE2 else if SIZE != 0 if ZSIZE != 0 if SIZE != ZSIZE print "SIZE (%SIZE%) and ZSIZE (%ZSIZE%) differ, contact me" cleanexit endif endif endif log FULLNAME OFFSET SIZE endif next i startfunction UNLZ2K putvarchr MEMORY_FILE2 SIZE 0 log MEMORY_FILE2 0 0 append for TMPSZ = 0 < ZSIZE goto OFFSET getdstring SIGN 4 if SIGN != "LZ2K" print "Error: the signature at offset %OFFSET% (%SIGN%) is not LZ2K, contact me" cleanexit endif get LZ2K_SIZE long get LZ2K_ZSIZE long savepos OFFSET if LZ2K_ZSIZE == LZ2K_SIZE log MEMORY_FILE2 OFFSET LZ2K_SIZE else clog MEMORY_FILE2 OFFSET LZ2K_ZSIZE LZ2K_SIZE endif math OFFSET += LZ2K_ZSIZE savepos TMP MEMORY_FILE2 math TMPSZ += 12 math TMPSZ += LZ2K_ZSIZE next append endfunction