Just Let It Flow

September 1, 2015

Gran Turismo 2’s Used Car Cycles

Filed under: Uncategorized — adeyblue @ 3:03 am

I don’t want to know how it works, just gimme the lists

Hot off the press of last time when I wanted to know how Intelligent Qube’s IQ calculation worked, again thanks to speedrunning I’ve found myself needing to mine some data out of another game.

This time its Gran Turismo 2 and more specifically, its used cars. Most people have played it in some form, but if not, at the beginning of the game you have 10,000 credits to go and buy your first car with unless you’re fantastic at the license tests. The current World Record holder is, and gets an all gold I-A licence. This gives a prize car which sells for 250,000 credits and so lifts the 10,000 credit restriction.

The previous record before he did that however, had to go the used car route. He chose a 3 Door Civic to win all the League events from 197 hp to the 542 hp Pacific 2, the car tunes well and is light making it an ideal starter car except for one snag – it doesn’t show up in the PAL version. I have the PAL version.

Having to find a different car means knowing what you can choose from. The pool of used cars at the start of the game is roughly 100 strong and for some reason, I didn’t fancy manually listing the data of these cars one by one. Not to mention that in finding a good PAL route, I might need to do this for the second cycle of used cars and beyond – a beyond that contains 60 cycles total. Clearly finding and parsing the game data was a must.

Thankfully, I didn’t have to start from scratch this time. Sometime way back when I was getting TCRF’s Gran Turismo 2 page into shape, I wrote a tool to explode its solitary data archive and decompress the GZip archives that make up some of the files within.

The tool that built the archive retained the names of the files within so unlike some game archives, you can get a good idea of what most of the data is.

Exploded PAL GT2.VOL

Exploded PAL GT2.VOL

From the PAL simulation disc, there are three files that look like happy hunting grounds, all starting .usedcar. Unlike other compressed archives, these don’t have the .gz filename suffix so my tool doesn’t decompress them, but with something like 7Zip you can do it yourself. After that, you get a data file that looks like this:

Decompressed .usedcar file

Decompressed .usedcar file

There isn’t any text in this file, so its down to good ol’ investigation to figure out what it represents. The UCAR at the beginning is obviously a header so we can skip that, then comes a bunch of values that are arranged in nice columns on the right side. In my experience, these are usually offsets to locations in this file. Looking at offset 0xfc and the second offset of 0x810[1] you see this data.

Data at 0xfc (highlighted)

Data at 0xfc (highlighted)

Data at 0x810 (highlighted)

Data at 0x810 (highlighted)

Considering the data for each case starts with the same sequence of 9c000000, it’s a good bet the initial values are offsets. It’s common knowledge that the used car cycle advances every 10 days and goes back to the beginning after day 600 so it’s also a good bet that these offsets are to the data for each used car cycle – there’s 60 of them between the UCAR header and the 0xfc offset.

You can see in the highlighted data above that there’s certain repeated data in each segment, and again it’s in nice columns on the right side. If we take them as offsets again, then 0x9c (the first offset) divided by 4 (the size of each offset) gives 0x27 or 39. The game has 34 manufacturers so its probably not that. Or is it?

One thing you might notice about the repeated data is that the last entry in each set has a value in the third byte. In the first picture, the last of the 9c values isn’t 9c000000 like the rest, but 9c000500, likewise with the c4 values that follow[2]. If you count the number of these occurances before the end of the highlighted data there are eight of them. It just happens to be that there are eight used car lots in the game, so that seems kosher (also it seems five manufacturers were cut during development).

The last bit of the data is the hardest to determine:

The data at 0xfc (cycle offset) + 0x9c (dealer offset)

The data at 0xfc (cycle offset) + 0x9c (dealer offset)

It’s still broadly in columns though they’re now wider with less uniform data. If these are the manufacturers then this is likely to be car data. Since there’s no text in the file, the cars can’t be listed by name so there has to be another method to refer to them – and there is!

If back in the day you looked up making hybrids, accessing the hidden cars or maybe a ‘buy any car’ gameshark code you’ll have come across a list that starts like this:

a-a7r | 0B00B21C | [R]Mazda RX-7 A-spec LM
a-emn | 0B00F5D8 | Mazdaspeed Demio A-spec
a-emr | 0B00F5DC | [R]Mazdaspeed Demio A-spec
a222n | 0B0C30D8 | Mazda RX-7 GT-Turbo ’83
a222r | 0B0C30DC | [R]Mazda RX-7 GT-Turbo ’83
a26sn | 0B0C7758 | Mazda MX-5 Miata 1.6
a26sr | 0B0C775C | [R]Mazda MX-5 Miata 1.6

All three of these data points are unique to each car in the game. We know there’s no text in the usedcar files, so that scrubs the first and third points, leaving the nice 4 byte hex code as an id. Here’s the entire list, so if you take the first four red bytes in the picture above and reverse the order you get 1b0d70d8 or according to the list a Daihatsu Move SR-XX ’97. Looking at the Daihatsu used cars in the first cycle we see:

Used first cycle Daihatsu cars in the PAL version

Used first cycle Daihatsu cars in the PAL version

But that could be a coincedence, unlikely but it could. Instead of doing this process manually to verify the rest of the data, we can do it interactively. Fire up your favourite PS1 emulator (mine’s ePSXe) and memory editor / searcher (CheatEngine). On the emulator ensure you’re not on day 10 or above and navigate to Daihatsu’s used cars. Connect Cheat Engine, search for the first red bytes and see what we can see. Full screen the video to see what’s happening:

The first four bytes are the car, the next three (?!) are the price, and the next one doesn’t seem to have any effect. I’ve since found it represents the colour for non-racing cars, but I don’t know how the game translates this single byte to one of the two byte colours defined for new cars, to the big list of offsets and colour names in the .carcolor file. Alas, you can’t edit this byte to make a car any colour you want, invalid colours for a car just make it its’ default colour.

Anyway, rinse and repeat parsing these eight byte packages stopping at each new offset to break the list up by manufacters and then by cycle and you’re done. To make the list I dumped a bit more useful, I cross referenced the car names with a database of untuned car weights and HP’s and added those to the dumped data.

The other two usedcar files are the ones used for that version of the game, .usedcar_usa for all of the US versions, and _jpn for the Japanese version. They all have identical layouts, if not identical contents. All three lists are on each version’s disc and they’re the same lists across all versions.

As for the dumped lists, they used to be here with some mostly accurate details like HP & weight, but I’ve since put them on a site with totally accurate details and all of the other stuff I mined out of the game’s files, http://gt2.airesoft.co.uk.


[1] The values are stored in a Little Endian manner which means their bytes are stored backwards to how you’d normally read them. So FC000000 in the file really means 0x000000fc and 0x10080000 means 0x00000810 etc.

[2] The values in the third byte are how many cars there are for that dealership. It’s then quite likely that these are packaged as a two byte offset, followed by two bytes for the number of cars in the dealership. If the number of cars is 0, there’s no data needed thus no need to change the offset.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress