Tool to recompress TIM2 Graphics file (PS2)

Textures, recreate headers, conversions, algorithms and parsing of image files
Mirakichi
Posts: 25
Joined: Wed Jul 26, 2017 2:44 pm

Tool to recompress TIM2 Graphics file (PS2)

Post by Mirakichi »

Hi guys, I would like to know if anyone can provide me a tool to recompress this graphic file https://drive.google.com/file/d/1xlxfBN ... p=drivesdk
This graphic is in TIM2 format, and is from Fatal Frame II PS2. This file originally after extracted from the game, is compressed, the header when the file is compressed is "LESS".
I use this tool to decompress it https://github.com/wmltogether/ZeroUnpa ... DeLESS.exe
I can view it with the "Texture Finder" and the "Optix Image Studio".
But the tool only decompress, but don't make the inverse process (compress TIM2 to LESS again)
I need recompress the file to insert it edited in the game. Later I will post a sample of this same file compressed.
Mirakichi
Posts: 25
Joined: Wed Jul 26, 2017 2:44 pm

Re: Tool to recompress TIM2 Graphics file (PS2)

Post by Mirakichi »

Link with the same LESS file above, but compressed https://drive.google.com/file/d/1FIptWt ... p=drivesdk
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Tool to recompress TIM2 Graphics file (PS2)

Post by Acewell »

here is bms script to do the same as that "DeLESS.exe" :D

Code: Select all

# script for QuickBMS http://aluigi.altervista.org/quickbms.htm

comtype lzss0
get NAME basename
string NAME + .LED
get TOTAL_SIZE long
idstring "LESS"
get UNK long
get CHUNKS long
get DATA_OFFSET long
get UNK2 long
get ZERO long
get TOTAL_ZSIZE long
for i = 0 < CHUNKS
    get SKIP short
    get CHUNK_ZSIZE short
    savepos TMP
    goto DATA_OFFSET
    do
        get CHECK byte
    while CHECK == 0
    goto -1 0 seek_cur
    savepos DATA_OFFSET
    append
    clog NAME DATA_OFFSET CHUNK_ZSIZE TOTAL_SIZE
    append
    math DATA_OFFSET + CHUNK_ZSIZE
    goto TMP
next i


and here is bms script to extract the tm2 textures from the LED file :)

Code: Select all

# script for QuickBMS http://aluigi.altervista.org/quickbms.htm

get FILES long
goto 0x10
for i = 0 < FILES
    get OFFSET long
    savepos TMP
    goto OFFSET
    goto 0x10 0 seek_cur
    get SIZE long
    math SIZE + 0x10
    get NAME basename
    string NAME + _
    string NAME + i
    string NAME + .tm2
    log NAME OFFSET SIZE
    goto TMP
next i


both scripts should be available for reimport with Quickbms :)
episoder
Posts: 123
Joined: Fri Oct 27, 2017 7:36 pm

Re: Tool to recompress TIM2 Graphics file (PS2)

Post by episoder »

seems like an illegal operation. may not work with the ps2 disc filesystem. reverse compression is not predictable. modifying a file changes the compressed size. if it's bigger it should only re-import the part that fits in the total_size of the original. with the rest potentially missing and failing to decompress correct in-engine. re-importing a file that compresses smaller should crash the compression algorithm on eof, reading further to fill the compressed total_size.
Mirakichi
Posts: 25
Joined: Wed Jul 26, 2017 2:44 pm

Re: Tool to recompress TIM2 Graphics file (PS2)

Post by Mirakichi »

Thankyou very much Acewell!
Mirakichi
Posts: 25
Joined: Wed Jul 26, 2017 2:44 pm

Re: Tool to recompress TIM2 Graphics file (PS2)

Post by Mirakichi »

Hi Acewell, I made some tests, the script reimport only the tm2 files to the LED file, but the reimport mode won't work to recompress the LED to LESS, and the LED file is in the original size.
Can you create a tool to recompress the LED?
The script says that the algorithm used is "lzss"
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Tool to recompress TIM2 Graphics file (PS2)

Post by Acewell »

sorry i don't make tools, if reimport doesn't work there is nothing more i can do. :(
that "deless" bms script was just for fun anyway. :)
Mirakichi
Posts: 25
Joined: Wed Jul 26, 2017 2:44 pm

Re: Tool to recompress TIM2 Graphics file (PS2)

Post by Mirakichi »

Thanks, having the tm2 textures is
already a breakthrough. In
my translation of this game
is only missing the graphics,
the texts are almost 100%
Mirakichi
Posts: 25
Joined: Wed Jul 26, 2017 2:44 pm

Re: Tool to recompress TIM2 Graphics file (PS2)

Post by Mirakichi »

Hey Acewell, can you make for me an Text Exporter/Inserter for this file? https://drive.google.com/file/d/1MLDtrh ... p=drivesdk
You can see the texts using the Windhex and the table file included.
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: Tool to recompress TIM2 Graphics file (PS2)

Post by Acewell »

i think swuforce is the guy you want, i don't deal with text. :)
Mirakichi
Posts: 25
Joined: Wed Jul 26, 2017 2:44 pm

Re: Tool to recompress TIM2 Graphics file (PS2)

Post by Mirakichi »

He tried to make, but said "it's to complex". This text file uses absolute pointers, ex: 45DA01>01DA45 and so on... I've translated some texts using the Windhex, the problem that is are manys texts and many blocks, have blocks with + 200 pointers, are 66 blocks. If anyone make a exporter/inserter, will make easily the my translation.