Thursday, April 08, 2010

Code Reuse At Sega

Out of curiosity, and to follow up a previous post, I examined some of the Super Hang-On code to figure out the level of code reuse between the games as they share the same hardware. A quick glance at the code shows that a lot of the core routines, responsible for generating the road detailed in this post are identical. It appears that the slave CPU code to handle road splits is removed from Super Hang-On.

It's probably not a surprise, given that there are other obvious similarities between the titles, including some of the sampled sounds being identical.

Now the OutRun hardware supports two road layers. But as far as I know, Super Hang-On only uses a single road layer. Interestingly, there was a conversion of Super Hang-On to the Space Harrier hardware, which only supports a single road layer. Presumably, OutRun wasn't converted in the same manner, because of its reliance on two road layers for the wider roads (even when two distinct roads aren't displayed, the two road layers are sometimes in use).

One other example of code reuse I've found is between OutRun and Sonic the Hedgehog 2 on the Megadrive. Both games share the same random number generator, right down to the default random seed that's used.


Michael said...

I really thought that Hang-On (1985), Outrun (1986) and Super Hang-On (1987) were separate projects. Does Outrun borrow from the old Hang-On code or was Outrun written from scratch then Super Hang-On shared code from Outrun only?

yt said...

I haven't checked the Hang-On codebase yet.

Super Hang-On definitely borrows code from OutRun. And bear in mind I only checked the slave CPU code.

Whilst many functions are the same, the code is modified in areas and not completely identical. For example, there are a lot of special cases to handle the road split in the OutRun codebase that aren't present in Super Hang-On.