Important information: this site is currently scheduled to go offline indefinitely by end of the year.

Star Stable Online - CSA & TGA files

Read or post about compression. And decompression. Or ask questions how to decompress your files.
Post Reply
locknut
advanced
Posts: 57
Joined: Tue Jan 04, 2022 2:50 pm
Has thanked: 1 time
Been thanked: 32 times

Re: Star Stable Online - CSA & TGA files

Post by locknut »

Hi!
I stumbled on this forum thread while researching the CSA file format ("Cold Storage Archive" btw). I saw that there are a lot of discussions regarding the texture resources and thought that I should contribute.

Long Story Short
they are not encrypted. They are just compressed with a newer, optimized version of Crunch. Specifically the version that is bundled with Unity 2017.3. It's open source, so if you have a developer environment then you can build the tool from sources at https://github.com/Unity-Technologies/crunch/tree/unity.

Slightly Longer Story
No QuickBMS script I have seen does a very good job at unpacking the CSA files so I wrote my own tool for that. In my opinion, the best approach is to use the csaheader files to unpack the packed resources into a proper folder structure. The QBMS scripts tries to unpack with an internal source path, which is why the output folder looks so weird and many files are corrupted or duplicated.

Doing it properly, you will end up with ~52.000 files in a handful of different formats. The textures are as you already know stored in .PTE files, and there are about 19.000 of them. PTE is also a container format, but it only contains a single texture. The texture is always in DDS-format, but most of them are compressed with Crunch as mentioned above. ~15K textures are compressed, and the rest are plain old DDS.

So to summarize how to do this with code or a script:
  1. Loop through each header file and extract the name, size and offset of each resource in the corresponding csa data file.
  2. Save each resource you are interesting in from the datafiles as separate files.
  3. For each PTE, extract the texture as a CRN or DDS file depending on it's type
  4. Use Crunch to convert them into a common format such as PNG. Handily enough, Crunch can read both CRN & DDS, so you can convert all files in one go. I only found one file that Crunch failed on (Item_PandorianCompass.PTE), so that had to be converted by hand.
The only data that is actually encrypted (well obfuscated at least) are text strings. It's a simple Caesar cipher which you reverse by adding each byte of the data with (lenOfData%16)+1.

3D Object Converter does a pretty good job with reading the mesh files, but unfortunately it doesn't work well with the textures, materials, bones and animations etc... If it was open source I would have fixed it, but it's not and I cant be bothered to write a new converter from scratch just for this.

I hope this helps anyone!
Samyy360
advanced
Posts: 43
Joined: Sun Jan 10, 2021 6:46 pm
Has thanked: 3 times
Been thanked: 6 times

Re: Star Stable Online - CSA & TGA files

Post by Samyy360 »

so what are we doing wrong, was it the version of crunch we were using?
User avatar
kapibarcia
beginner
Posts: 28
Joined: Fri Sep 25, 2020 4:28 pm
Location: Poland
Has thanked: 7 times
Been thanked: 5 times
Contact:

Re: Star Stable Online - CSA & TGA files

Post by kapibarcia »

Samyy360 wrote: Tue Jan 04, 2022 9:27 pm so what are we doing wrong, was it the version of crunch we were using?
The version we used before was an older version and Star Stable Online uses a newer version of Crunch. At least that's what I understood from locknut's post.
zla kapibara!!!!#8536
User avatar
ikskoks
Moderator
Posts: 1668
Joined: Thu Jul 26, 2012 5:06 pm
Location: Poland, Łódź
Has thanked: 648 times
Been thanked: 431 times
Contact:

Re: Star Stable Online - CSA & TGA files

Post by ikskoks »

So mystery finally has been solved. I was following this topic in case if someone would crack this.
Thanks for the info, locknut.

Luckily I had one sample left from my research and I was able to test the solution - it works fine.
I have put in the attachment compiled crunch version for Unity with sample CRN file.
Use it like this:

Code: Select all

crunch_unity.exe -file CS_SignLogo_01.crn
You do not have the required permissions to view the files attached to this post.
Samyy360
advanced
Posts: 43
Joined: Sun Jan 10, 2021 6:46 pm
Has thanked: 3 times
Been thanked: 6 times

Re: Star Stable Online - CSA & TGA files

Post by Samyy360 »

so now that we have everything, can someone do a clean tutorial of how to use crunch, this crunch is not even opening for me
locknut
advanced
Posts: 57
Joined: Tue Jan 04, 2022 2:50 pm
Has thanked: 1 time
Been thanked: 32 times

Re: Star Stable Online - CSA & TGA files

Post by locknut »

kapibarcia wrote: Tue Jan 04, 2022 9:52 pm
Samyy360 wrote: Tue Jan 04, 2022 9:27 pm so what are we doing wrong, was it the version of crunch we were using?
The version we used before was an older version and Star Stable Online uses a newer version of Crunch. At least that's what I understood from locknut's post.
Yup,pretty much :-)
User avatar
ikskoks
Moderator
Posts: 1668
Joined: Thu Jul 26, 2012 5:06 pm
Location: Poland, Łódź
Has thanked: 648 times
Been thanked: 431 times
Contact:

Re: Star Stable Online - CSA & TGA files

Post by ikskoks »

can someone do a clean tutorial of how to use crunch, this crunch is not even opening for me
Crunch is regular command line program. And it works fine.
There are many tutorials on the web already https://www.google.com/search?client=fi ... ne+program
Samyy360
advanced
Posts: 43
Joined: Sun Jan 10, 2021 6:46 pm
Has thanked: 3 times
Been thanked: 6 times

Re: Star Stable Online - CSA & TGA files

Post by Samyy360 »

I understood the second step when using the crunch, but what do I do with the .pte file, is it just to change the extension to .dds or .crn?
Samyy360
advanced
Posts: 43
Joined: Sun Jan 10, 2021 6:46 pm
Has thanked: 3 times
Been thanked: 6 times

Re: Star Stable Online - CSA & TGA files

Post by Samyy360 »

wrong command?
You do not have the required permissions to view the files attached to this post.
Samyy360
advanced
Posts: 43
Joined: Sun Jan 10, 2021 6:46 pm
Has thanked: 3 times
Been thanked: 6 times

Re: Star Stable Online - CSA & TGA files

Post by Samyy360 »

help
You do not have the required permissions to view the files attached to this post.
locknut
advanced
Posts: 57
Joined: Tue Jan 04, 2022 2:50 pm
Has thanked: 1 time
Been thanked: 32 times

Re: Star Stable Online - CSA & TGA files

Post by locknut »

Samyy360 wrote: Thu Jan 06, 2022 6:13 pm I understood the second step when using the crunch, but what do I do with the .pte file, is it just to change the extension to .dds or .crn?
It depends on if you have the full PTE file, or if the texture has already been extracted from it. You can check this if you open it with a hexeditor. If the file starts with the string "DDS" or "Hx", then it only contains the texture and you are OK to just rename the file to .DDS or .CRN depending on if it started with DDS or Hx.

If the file does not start with DDS or Hx, then you have the full PTE-file and must delete some bytes from it. Again, open it with a hexeditor and delete all bytes before the "DDS" or "Hx" string.
locknut
advanced
Posts: 57
Joined: Tue Jan 04, 2022 2:50 pm
Has thanked: 1 time
Been thanked: 32 times

Re: Star Stable Online - CSA & TGA files

Post by locknut »

Samyy360 wrote: Thu Jan 06, 2022 7:02 pmhelp
You need to provide the full path to the image, unless it's in the current working folder of the command prompt. I dont think you put it in the system32 folder :-)
User avatar
ikskoks
Moderator
Posts: 1668
Joined: Thu Jul 26, 2012 5:06 pm
Location: Poland, Łódź
Has thanked: 648 times
Been thanked: 431 times
Contact:

Re: Star Stable Online - CSA & TGA files

Post by ikskoks »

As far as I know PTE and TGA are (almost?) the same file formats. Both are containers for CRN files used by crunch.

By the way, if anyone have issues with converting PTE/TGA files to CRN,
then you can use this quickbms script to do it automatically:
https://github.com/bartlomiejduda/Tools ... script.bms

I have also updated wiki article with the new findings http://wiki.xentax.com/index.php/Star_S ... ne_TGA_PTE
Samyy360
advanced
Posts: 43
Joined: Sun Jan 10, 2021 6:46 pm
Has thanked: 3 times
Been thanked: 6 times

Re: Star Stable Online - CSA & TGA files

Post by Samyy360 »

i tried doing the .crn or .dds manually and i couldn't but the bms script that ikskoks provided worked, i'll try crunch now, thanks for being so patient, it's helping a lot
Samyy360
advanced
Posts: 43
Joined: Sun Jan 10, 2021 6:46 pm
Has thanked: 3 times
Been thanked: 6 times

Re: Star Stable Online - CSA & TGA files

Post by Samyy360 »

okok, if it had worked, the .dds was supposed to be located where? what did I do wrong?
You do not have the required permissions to view the files attached to this post.
Post Reply