News:

Herr Otto Partz says you're all nothing but pipsqueaks!

Main Menu

Dissecting the Stunts files, trying to. Anyone know more?

Started by Cyberman, July 23, 2004, 08:15:12 PM

Previous topic - Next topic

Cyberman

As the title says, I recently started to dissect the files of Stunts. Originally, I wanted to know if it?s possible to replace the graphics of the opponents.
Needless to say, I had no luck. So I started to dissect the files, trying to figure them out.
Not much did I find, perhaps someone knows more?

I took much information(almost all) from the Stunts FAQ, didn?t mark it, though, as I simply added what little I found.
(Note: I pasted everything from a text-file I keep, I hope the formatting survived it.)

BTW: I hope it?s the right forum, didn?t find a more fitting. If that has been posted already, please point me to the thread, I did search, but there?s always the chance I used the wrong words...

Anyway, here?s the info:

Version 1.0 had partially uncompressed files, while those of 1.1. are compressed. Not all of them  just some.
The files containing graphics are apparently compressed in ALL versions.
The RESource files, however, are uncompressed in V1.0 - that?s why programs like Opponent Blaster can change them easily.

The files of V1.1 are NOT encrypted, rather compressed. The initial "p" in their extensions probably means "Packed". So, "RESource" becomes "Packed REsource".
An indication for packed raher than encrypted is that the packed files contain the size of the old files(compareable with the Opp?.RES files), and, well, they?re simply smaller. Not just a few bytes.

The "PVS" thus would mean "Packed VS" - whatever a VS file is, though one can assume the "V" standing for "Vector", as we know that Stunts uses Vectorgraphics, instead of bitmaps.

The packing method is unknown, I don?t think it?s any of the common archivers, though. It doesn?t look like it?s been compressed by ARJ, ZIP, LHA or such, even if the header is stripped away.

Now the structure, as far as I can tell(not far) - I took most information from  available resources:

*) RES files
There are (perhaps) two of them - one for cars, one for opponents. They might be of the same basic structure,
but I have no  information about that. It seems likely, though.

Opponent structure(uncompressed):

OFFSET   SIZE      DESCRIPTION

0x0000   LongInt   Resource file size in bytes
 ...
0x0005   Byte      0x1B - probably an End of Header tag
0x0006   215Bytes  I wish I knew. It looks like some sort of Index table,
                            perhaps the positions to the texts below(for win, loss,
                            etc...). Surely it?s no binary data, it?s too structured
                             for that.
0x00DE   2 Chars   Opponent's initials    
 ...
0x00E0   7Byte     Nothing, Zero. Apparently unused
0x00E7   20Byte    Junk? Some bytes, ones and zeroes. Can be overwritten
0x0103   151Byte   Nothing, a few bytes in between, nothing serious(?)
 ...
0x019B   Byte      Paved road
0x019C   Byte      Dirty road
0x019D   Byte      Icy road
0x019E   Byte      Paved sharp corner
0x019F   Byte      Dirty sharp corner
0x01A0   Byte      Icy sharp corner
0x01A1   Byte      Paved corner
0x01A2   Byte      Dirty corner
0x01A3   Byte      Icy corner
0x01A4   Byte      Bridge
0x01A5   Byte      Paved slalom road
0x01A6   Byte      Corkscrew up/down
0x01A7   Byte      Chicane
0x01A8   Byte      Loop
0x01A9   Byte      Corkscrew left/right, Pipe
 ...
0x01AB   Text      Here begins a large chunk of text - Name, Expertise,
                          Problems, Info,  it?s all here, simply written up.
                          No coding, no structure, apparently.
0x034F   35Bytes   Some bytes, they seem to be important. Perhaps the
                           coordinates for the evaluation videos? Or the text
                           coordinates, though I doubt that.
0x0372   till EOF  The Win/Lose/Crash texts

Note: The texts have no special encoding, other than ENTER indicated by "]", text fragments
     are ended with 0x02E00 apparently.


Opponent structure(compressed):
I wish I could say I know as much about these as about the uncompressed - the sorry truth is, I know hardly anything.

OFFSET   SIZE      DESCRIPTION

0x0000   1Byte     0x02 - Header ID? Indication for Compressed file?
0x0001   2Byte     Size of UNCOMPRESSED file + 1
0x0003   1Byte     0x00 - always. Don?t know why
0x0004   1Byte     Either 0x0A or 0x0B - perhaps the second half of a word?
                          (previous byte)

That?s it. There are several characters at the beginning, but I have no idea what they mean. They might be part of a Huffman encoding, though.



*) Highscore files:

OFFSET   SIZE      DESCRIPTION

    0x0000   17 Chars  Driver's name
                         (zero-terminated string)
    0x0011   24 Chars  Driver's car name
                         (zero-terminated string)
    0x0029   1 Byte    OppWinFlag - zero when won, one when lost
    0x002A   2 char    Opponent?s initials
    0x002B   1 Char    Separator("/")
    0x002C   5 Char    Opponents car (short version)
    0x0032   Word      Time achieved by human driver

    The time value has to be divided by 20 to get a result in seconds, e.g.

         2131 / 20 = 106.55 seconds = 1 minute, 46 seconds, 55 hundredth

Note: Version 1.1 apparently doesn?t work "clean" - the strings are not, like in V1.0, folloed by ".", but mere memory copies - with whatever junk lay in there. Do not read beyond the final Zero!


*) Track files
  are well-known enough, I think - no need to describe them here again.

*) PVS files
As said above, they?re probably compressed. So the PVS might mean "Packed Vertex Structure", since the graphics are vector-based, instead of simple bitmat.
They?re used for the opponents animation as well as the background, apparently. The opponent pictures are NOT saved in them, they?re somewhere else, maybe hardcodec somewhere, along with the number of opponents.

OFFSET   SIZE      DESCRIPTION

0x0000   1Byte     0x02 - Header ID? Indication for Compressed file?
0x0001   2Byte     Size of UNCOMPRESSED file + 1

alanrotoi

About the text of the dialogs of the opponents it's easy to edit with a hexa editor like pc tools 4.21 deluxe.

al il professore

welcome to the business. well those compressed files are okay, but we cant uncompress them -yet-

i say -yet- because something tells me one day they will be (unpacked). The lead programmer of stunts told it was 'some internal compression tool' that was used to pack the files... my opinion: it makes the sources protected (compression=confidentiality comparable to password protection) and its probably a model of compression used somewhere else in another game, etc. well... there were no infinite methods of compression used by those times and someone knows how to unpack those (like you said) VECTOR coordinates files.

i would like to study the things you said about the difference of packing between version 1.0 and version 1.1 because its interesting.

but now there are more funny things to do with stunts by hacking the sources than 'changing the buckheads of the opponents'... but changing the buckheads sort of gif animations or id cards photos can lead to further modification i would be the first to support (edit 3D cars! edit track elements!)
It is reasonable to expect that genetic influences on traits like IQ should become less important as one gains experiences with age. Surprisingly, the opposite occurs.

Cyberman

The packing applies not only to the vector files - the resource files are packed as well.

If you want to try, I?d recommend trying to decompress the PRE files back to RES.
Even if they changed between 1.0 and 1.1, chances are good they?re still similar enough to give a clue or two.
After all, the filesize seems to fit.

Akoss Poo a.k.a. Zorromeister

I think it's better to drive Stunts than to dissect the files....  :?
Chürműű! :-)

513.59 km

al il professore

the pre files are used in version 1.0 and match the res files in version 1.1? that's it?
It is reasonable to expect that genetic influences on traits like IQ should become less important as one gains experiences with age. Surprisingly, the opposite occurs.

Cyberman

Other way around, but yes.
The RES files of 1.0 - the opponent RES files, I mean, are probably the same as the PRE files(used for opponents) in 1.1 .

That?s just an assumption, but it seems likely, as the PRE files seem to be compressed, and contain in their header the size of the uncompressed file - which is known for the opponent RES files.
It?d be quite a coincidence if they?re not the same, though the size matches.

al il professore

compression method... okay... and once uncompressed... do you know how to decompile C or assembly?
It is reasonable to expect that genetic influences on traits like IQ should become less important as one gains experiences with age. Surprisingly, the opposite occurs.

zaqrack

as i know resource and 3d files dont need to be decompiled.
The engine is stored in other files, these are only datas which are readedby the main engine.

Cyberman

Right.

The engine itself, or at least a part of it, probably rests within the EGA/MCGA/etc files - those with ".COD", ".HDR" and ".DIF".

They?re EXE files I think, with the "HDR" part containing the Header(recognizable through the "MZ" at beginning), what the "DIF" is for, I can?t tell, but it seems likely they contain some "DIFference" data - maybe to change between different computer systems?

These files seem to be different in 1.0 to 1.1 too.

dstien

My interpretation of the RES file structure:

WORD lenRemainder
BYTE lenMultiplier   // total = (lenMultiplier * 0xFFFF) + lenRemainder
BYTE unknown         // Passes == 0?
WORD numVars

CHAR ids[numVars][4]
DWORD offsets[numVars]

BYTE values[]       // Rest of file


A RES file has numVars variables, each with a 4-chars identification and an offset pointing to the data in values[]. Text is null-terminated strings, the structure of other value types depend on the id.

Here's an example of the unlock questions and answers from MISC.PRE (more on the decompression later):

Num Id   Offset   Value
--- ---- -------- -------
  1 ea00 000002C2 camera
  2 ea01 00000314 destructive
  3 ea02 00000368 conventions
  4 ea03 000003BC previewing
  5 ea04 000003FC proper
  6 ea05 00000426 cables
  7 ea06 00000460 loop
  8 ea07 000004AC displaying
  9 ea08 000004EB you
10 ea09 00000537 query
11 ea0a 00000571 button
12 ea0b 000005AC directory
13 ea0c 000005F9 around
14 ea0d 00000648 currently
15 ea0e 00000687 selected
16 ea0f 000006D4 immediately
17 ea0g 00000727 track
18 ea0h 00000766 three
19 ea0i 000007A0 110
20 ea0j 000007D7 buttons
(...)
51 eq00 00000292 106 1 @       mode while in this]viewing mode.]
52 eq01 000002C9 1 122 ...and @             stunts that]can smash your car to pieces in...]
53 eq02 00000320 2 5 8 ...control your car, as well as]the @            of using the...]
54 eq03 00000374 3 134 ...editor'). In addition,]@           might give you a]better...]
55 eq04 000003C7 4 8 1 @       direction. If you get on]the track...]
56 eq05 00000403 5 123 hit the @      and crash...]
57 eq06 0000042D 6 3 7 while you are driving through]the @     ...]
58 eq07 00000465 7 2 1 @            the current car, an]acceleration curve (showing...]
59 eq08 000004B7 8 5 7 Just your everyday type of]vehicle. @    ...]
60 eq09 000004EF 9 3 9 ...course, you'll be interrupted]while driving with a @      ...]
61 eq0a 0000053D 103 5 your driving performance. This]@       is...]
62 eq0b 00000578 112 1 @          . Highlight the]desired replay...]
63 eq0c 000005B6 122 1 @        ,you can choose to race]any one at a time. Each...]
64 eq0d 00000600 134 11this screen, you'll see a bird's]eye view of the @           ...]
65 eq0e 00000652 146 1 @          piece is the area upon]which it...]
66 eq0f 00000690 2 8 1 @            on the standard track]by clicking on the car...]
67 eq0g 000006E0 3 2 1 @      selection screen. Your]goal is to be on it. Your real...]
68 eq0h 0000072D 4 4 4 ...time than missing @      ]pieces of regular...]
69 eq0i 0000076C 6 5 8 ...out at the peak, while]more than @    MPH]
70 eq0j 000007A4 7 5 7 ...retail price), and a set]of @        ...]
(...)

zaqrack


Krys TOFF

Nice work, keep it up dstien. ;)
And welcome to the forum.

dstien

Thanks! I have reversed the first decompression pass, enough to unpack PRE and code files (COD/CMN/DIF), the other files use an additional layer of compression which I'm currently looking into. P3S and PVS files can contain multiple shapes and bitmaps, organized in the same structure as RES files. The game accepts uncompressed data files (P3S => 3SH, PVS => XVS), so it doesn't look like there's need for an encoder. 8)

zaqrack

Quote from: dstien on March 07, 2008, 04:05:26 AM
The game accepts uncompressed data files (P3S => 3SH, PVS => XVS), so it doesn't look like there's need for an encoder. 8)

Now this is the news of the year! We seem to be only a margin away from understanding those files and finally creating new cars. If only we could create new track elemets, stunts would be perfect :) If you need any help for your work, just let us know!