GTA 1 PSX - *.vsr

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
czdvoika
Posts: 7
Joined: Tue Feb 05, 2019 6:01 am

GTA 1 PSX - *.vsr

Post by czdvoika »

Hi there, i wrote my first bms script whohou :D but files after unpack is compress or crypted, pls help.
I try localization this game

Code: Select all

IDstring 3RSV
get FILESIZE long
goto 0x00000B0

for i = 0
get OFFSET long
get SIZE long
get DUMMY long
get DUMMY long
get DUMMY long
get DUMMY long
get DUMMY long
get DUMMY long
get DUMMY long
get DUMMY long
log "" OFFSET SIZE
next i


files: https://filebin.net/kobwodyxfdkgwp33

tnx tnx
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: GTA 1 PSX - *.vsr

Post by aluigi »

There is no download starting at that link.
czdvoika
Posts: 7
Joined: Tue Feb 05, 2019 6:01 am

Re: GTA 1 PSX - *.vsr

Post by czdvoika »

Hi aluigi :) here are the files. This is slus version and new script in archive.
https://drive.google.com/file/d/11XObi9 ... sp=sharing
you are the best :)
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: GTA 1 PSX - *.vsr

Post by aluigi »

It's a chunked format (like RIFF) and the "DATA" chunk has various "BIN " sub-chunks containing pointers to information, but I don't understand if it's encrypted because doesn't have any sense.
czdvoika
Posts: 7
Joined: Tue Feb 05, 2019 6:01 am

Re: GTA 1 PSX - *.vsr

Post by czdvoika »

thank you for the advice, obviously it will not work without documentation :)
Kruci
Posts: 2
Joined: Fri Nov 27, 2020 7:19 pm

Re: GTA 1 PSX - *.vsr

Post by Kruci »

In short:
probably Huffman coding
https://en.wikipedia.org/wiki/Huffman_coding


If you extract files by your script from 0x000038 than each file with 0 size is directory.
Third dir (0000000f) is named "HUFF_TABLES" (filenames are in MISSION.VSR)
That could be Huffman coding (kind of compression).
Huffman coding compress based on characters counts, usually saved as "char" and its "count".
Files in that folders looks like it stores 2B "character" a 2B "usage count".
Probably then used on matching files with same name (first in this dir for first on others dir).

Guessed file formats:

Code: Select all

BIN HUFF_TABLES FORMAT (total guess):
-------------------------------------

4B  " NIB"
4B  filesize
4B  data size
??? elements
2B  ??? character
2B  ??? count


Code: Select all

VSR format:
-----------

4B  3RSV
4B  data size of block BLOCKSIZE (FILESIZE = BLOCKSIZE + 8B)
4B  data size of dirs/files block CRID
4B  data size of block NRSV
4B  data size of strings block TRTS
4B  data size of data block ATAD
4B  number of files+dirs
4B  number of file names
4B  ??? zeros
4B  offset block SFFO
4B  data size of offset block SFFO

+ data size of offset block SFFO
4B  CRID
4B  data size of dirs/files block CRID

Element of this block 40B:
4B  ??? either first top dir have here 0x1, or it do not belong to element data and at end is not padding/mark 4B
4B  data start offset (0 for dir)
4B  data size
2B  id for this folder (?unique to folder?), ?name of this file/dir, ?equals to string from strings block?
2B  id for all files (?unique to all files/folders?)
2B  file or dir mark (0x16 = dir, 0xE = file)
2B  ??? 0xCCCC
4B  ??? 0xFFFFFFFF
4B  ??? 0x0
4B  number of files/dirs in this dir
4B  ??? 0x0
4B  ??? 0x0

4B  ??? either padding/end mark of block or last part of element (then first 4B is not part of element)

+ size of dirs/files block CRID
4B  NRSV
4B  data size of block NRSV

??? 4B 0x0

+data size of block NRSV
4B  TRTS
4B  data size of strings block TRTS
4B  elements count STR_ECOUNT
STR_ECOUNT * 4B  offsets to strings (from start of data of this block)
XB strings - files/dirs names, ends with 0x00 char

+ data size of strings block TRTS
4B  ATAD
4B  data size of data block ATAD
XB  files data
czdvoika
Posts: 7
Joined: Tue Feb 05, 2019 6:01 am

Re: GTA 1 PSX - *.vsr

Post by czdvoika »

Kruci wrote:In short:
probably Huffman coding
https://en.wikipedia.org/wiki/Huffman_coding

O diky za vycerpavajici analýzu, zkusím neco počíst o huffman codovani a dam vedet :) supr

Translator:
.Thanks for the exhausting analysis, I'll try to read something about huffman coding and let me know :)
Kruci
Posts: 2
Joined: Fri Nov 27, 2020 7:19 pm

Re: GTA 1 PSX - *.vsr

Post by Kruci »

Huffman coding is "simple", but building it is complicated (trees).
Huffman coding just converts "bytes" to variable length data (different length in bits).
For example: text ABCCC could convert to bits "0" "10" "11" or "1" "00" "01"
Because it convert each character to same "bits character", you could see patterns if you see data as bits.

Do not study it much, try find some tools, and try if it work.
It may be some modified Huffman coding, or something different.
I never used any program for Huffman coding, so I know only that QuickBMS have some support,
and there are online "Huffman coding visualization", "Huffman coding encoder", "Huffman coding calculator"
For example:
http://huffman.ooz.ie/?text=ABCCC
https://resources.nerdfirst.net/huffman