Thursday, June 03, 2010

Collision

I'm currently working on disassembling the OutRun collision and crash handling code.

Once you start looking into the code in detail, you realise what an adventurous coding exercise OutRun is. I mean, how many ways do you need to crash in one game? Evidentally quite a lot... I can't quite fathom the level of detail they went into with regard to the collision routines. It's not sloppy coding as such, just simply attention to detail on an excessive scale. Sega  must have had a supply of strong caffeine in the 80s.

Check out the graph I produced in IDA below of one of the main crash routines. This isn't even all of the collision and crash code, it's simply one function which can be toggled by the master jump table!


On a positive note, all the code blocks covered by the above graph are now decompiled and commented. On a negative note, mainly for my sanity, there are still more. Argh!

There are two main types of crash in OutRun: hitting traffic and hitting scenery. Hitting scenery can be broken down into three new types of crash depending on the speed your travelling at. There's the low speed bump, where the car rises in the air (using the same movement lookup table as the birds flying on the logo in attract mode fact fans), the medium speed spin and the full speed flip. Each of these has multiple internal states to contend with and each crash factors in aspects like your speed, road curvature, height, whether there's a further crash resulting from the first crash and a selection of passenger animations. For example just the lower speed crashes offer a choice of the woman hitting the man, the man scratching head & girl tapping car, the man scratching head & girl pointing or man looking subdued and girl pointing.

Also, whilst the object format of the crash routines bears some similarity to previous bits of code I decompiled, actually most of it is new. Plus the animation sequencing format seems to be different, though I figured that out too.

PS I'm going to bed!

1 comment:

bluepillnation said...

They used to say that if it could be done with a sprite, Sega could do it - sometimes they even did stuff that people thought couldn't be done with a sprite, come to think of it...

OutRun in particular looked like it came from a few years into the future back in 1986, even though technology-wise it was an evolution from Hang-On and Space Harrier rather than an out-and-out revolution. It certainly took other manufacturers a while to catch up. Konami's WEC Le Mans was released the same year, and while it matched OutRun technically graphics-wise, it didn't move as smoothly and wasn't as much fun to play, Taito's Chase HQ didn't come along until 1988 and Jaleco's Big Run was 1989, though that used 3 68k processors to shift graphics. :)