Monday, March 18, 2013

More Data Hacking...

Although LayOut will handle the obvious visual mechanics of creating an OutRun track, things don't and can't stop there. In fact, OutRun's engine utilises an additional lookup table of pre-calculated values, required by the car physics and attract mode AI code.

This table, stored in the master CPU code, corresponds to the road path data, stored in the slave CPU code. Here is how three typical segments of road might be represented:

This means that at position 161, there's a left bend with property '121', until we reach the straight at position 277. This straight lasts until we reach the right curve at road position 359. This data is stored for every single curve and straight in every track in the game. 

Note, that this table does not define the path of the track at all from a visual point of view; this is purely used by the game's logic. If we get this stuff wrong, the car behaviour won't feel right when cornering. The value is used to adjust both the x position of the Ferrari as it enters a bend and to adjust your speed when you move through the corner. Without this, it would feel as if you drifted around corners too quickly. 

Understanding this table is all very well, but the problem is how to reverse engineer a curve back into this magical 'curve info' value required by the engine. Without knowing this formula, the editor project would be doomed!

I spent a long time experimenting with different ideas, largely aided by Excel and a bit of trial and error. In the end the solution was this:

For each curve in the game, calculate the average of the distances between the points on that curve. Therefore, you can use the standard distance formula for every pair of points:

Once you have the average distance between the points on a curve, you can do:

Curve Info = (1 / AverageDistance) * 4096

Where 4096 represents a 'one' in fixed point format. And finally we can spit out a curve info value in the format required by the game engine. 

Hopefully this gives you an idea of some of the less visually interesting work that I'm doing. 

Saturday, March 16, 2013

Road Width Editing

Road width editing is complete and working. Technically what you edit is the degree of separation between the two roads. The hardware overlaps the two roads, creating the illusion of one wide road. 

Therefore, it's nice and easy to split and rejoin the road into two lanes. 

Not the most exciting thing to look at, at the moment. But you see where this is going. Next on the list is height editing I reckon... 

Saturday, March 09, 2013

Road Path Implementation Complete

Following those exciting Excel spreadsheets and a little ranting, I'm pleased to say road path editing is implemented and working.

Here's an initial screenshot showing the progress of LayOut, the OutRun level editor.

This is just the first small stage; changing the path of the road. It's really easy to layout a complete track; you can produce something usable in under a minute. You define a series of control points and LayOut produces the curves and straights for you. Internally, the editor uses its own format and then exports to the format required by OutRun. This makes it easier to manipulate the track than dealing with the raw data.

Cannonball will have a debug mode to render the output in conjunction with Layout, so you can use both tools together. For now, a lot of this is somewhat hard coded, but the concept is proven.

For now, the road width and objects are still read from the original level data. This will obviously change as we add these options to LayOut. Here you can see we've inserted a curve at the start of Coconut Beach.

Well done to Shawn LeBlanc for naming the editor. I was originally going to call it 'Last Wave', but this sounds more like a sound editing tool and if I ever get round to creating sound editing tools it might cause confusion.

The next step will be to add the ability to define the road width, which encompasses single and dual road support. 

Wednesday, March 06, 2013

Track Editor Plan

As you know, the focus over the next few months is a track editor for OutRun levels. This was always the plan once Cannonball became a reality; I first blogged about this long-term goal back in in 2009!

Cannonball will of course continue, but there's a shift in focus as the next exciting instalment begins. It will mean fewer blog updates whilst I get the project off the ground, until I have something interesting to talk about.

The plan for the initial release is as follows:
  • The editor will be a separate application from Cannonball.
  • The editor will be developed in C++ and QT. This will support a solid cross-platform GUI. 
  • The editor will use Cannonball to preview the final level in some kind of debug mode.
  • The editor will output to a format compatible with Cannonball, and the original OutRun hardware. So you could potentially play the best levels on original hardware.
  • The following features will be supported: Road path/direction, road width, road height, scenery & track debris placement, road palettes.

Future releases could include additions like:
  • Road texture editor.
  • Sprite editor.
  • Sprite palette editor.

I've made a start, I'm learning QT and progress is steady. Maybe you have an idea for a feature or even the name of the editor. If so, comment below!