Saturday, January 26, 2013

Cannonball 0.17 - Analog Controls

The latest release of Cannonball finally supports analog controls. I've only tested with my Logitech Momo Racing wheel and pedals, so would be interested to get some feedback on how well it works for you, as your hardware may differ.

You can enable analog controls in the Settings -> Controls menu. You should also redefine the gamepad buttons accordingly for start/coin in etc.

There are a few advanced options you might need to edit in the config.xml file. These include which axis the steering and pedals are mapped to. You should be able to check this using the driver software provided with your wheel. Ensure that each control is configured to be on a separate axis in your driver software.

There is a further setting to denote how much of the turning circle of your wheel should be used. For example, I personally prefer tighter steering, so turning 50% left is in fact a hard left.

I will investigate force feedback at a later stage. I think the term force feedback is somewhat misleading though. OutRun didn't offer force feedback. The steering was centered by two large springs. A motor would essentially move the steering column when driving off-road or during a crash sequence creating a vibration effect.

The version of FinalBurn with force feedback actually uses the moving OutRun deluxe motor code to affect the wheel, so it's more akin to vibration. I can look to implement something similar in the future once I figure out the best approach; the stable release of SDL doesn't support this out of the box.

It's fun to finally be able to play with a proper racing setup. It makes some parts easier and some tougher. And we can finally claim that Cannonball is the ultimate version of OutRun.

Update: Also fixed a bug where time trial scores didn't initalize correctly from a new install. If you failed to record a best score in time trial mode previously, then this should be fixed!


d from Shmups said...

Amazing job.
Works with a usb to ps2 converter!
I play with a ps2 dualshock 2 controller.
Gas and brake is on the right analog stick.
Even when not accelerating on the right analog stick, there seems to be a value active that will still push the car to 68mph.
I really wish Cannonball would work with analog steering and with digital gas and brake.
It would be nice to be able to define the digital buttons for control pad to gas and brake.
I'm sure I can somehow manipulate all these digital and analog values and buttons, but I have yet to find a good tool/driver to do this. I'll keep looking.
Keep up the excellent work. It looks like you're shaking these updates out of your sleeve.

yt said...

Yeah, I might change the setup so that you can enable/disable each analog control individually.

Not sure why you've got constant acceleration. It may be because one of the inputs is sending out a signal even when depressed. Hard to say without actually having the joypad in front of me...

Unknown said...

I've got force-feedback working in mame actually using the original deluxe code as well.

I never got around to submitting it to mame because the release after I finished it was one of the major sega overhauls and I kind of got sidetracked (for over two years unfortunately).

Basically there is an interleaved byte and by reading various ranges (bit masks won't work unfortuantely) you can determien the motor direction and force to be applied. The digital FF for the standard machine is farily easy to hook up as well.

I can send you a diff file if you are interested.

Actually you can go ahead and submit it to mame if you want... there would have to be some minor adjustments due to the code in mame, but that's about it.

Unknown said...

I've got force-feedback working in mame actually using the original deluxe code as well.

I never got around to submitting it to mame because the release after I finished it was one of the major sega overhauls and I kind of got sidetracked (for over two years unfortunately).

Basically there is an interleaved byte and by reading various ranges (bit masks won't work unfortuantely) you can determien the motor direction and force to be applied. The digital FF for the standard machine is farily easy to hook up as well.

I can send you a diff file if you are interested.

Actually you can go ahead and submit it to mame if you want... there would have to be some minor adjustments due to the code in mame, but that's about it.

Kungfu Steve said...

If you implement FFB, please make sure to allow for multiple methods.

The original wheel doesnt shake. The entire wheel assembly is on a sliding tray. A motor that sits off of the tray, is connected to the tray via a link arm. As the motor spins, at various speeds depending on grass -vs- crash, and possibly speed of the car at the time... It moves the tray left to right, about an inch. This is radically different in feel, than simple vibration... and is the way that should be replicated.

With minimal effort, one could easily create a similar setup with a drill or demo-saw motor.

I did like the Sitdown version as well, where the cabinet moved. However, the delay was a little disapointing.. as was a lack of wheel shake. Had I owned a Sitdown, I would have found a way to hook up both, plus a much faster side to side action.

Cabinet output should also be part of the equation as well, allowing people to construct motion cabs. Though admittedly, many will less likely use this, rather than a much easier to build shaker wheel.

Additionally, If the game has no Arcade shifter support, then it certainly isnt superior to the original either. A 2way shifter than locks into place, rather than those cheesy center sprung shifters, is the only way to play Outrun... or any shifter game for that matter.

Without trying it yet, if the game is using emulation.. and the games internal calibration isnt in sync with the values of the pots in the controllers... it may be causing problems. Furthermore, some people may be using 100k pots.. where as the game used 5k pots. Also, some people may be using one of the emulation encoders, such as Ipac. Some of these encoders can use either pc or arcade pots. Not sure if it converts the values however.

Some others may also be using half of their pot for brake, and the other half as the gas. Certain controllers do this.. and or certain people wire their controllers to do this. This reduces the possible values of the acceleration, so its not something that should be desired. However, there are some arcade games, and or pc games, that use this functionality.. so people sometimes make a switch, which can alternate wiring, to provide both both methods, to play any kind of game.

yt said...

Cabinet style gears are currently supported.

I think an interesting project would be to build a hardware interface for the PI and use it to run cannonball whilst using the original arcade controls. Then you could swap out faulty pcbs in old cabs for a £30 PI.

Btw, when I said superior I was really referring to ports of Outrun like the Saturn. Nothing is going to beat a deluxe sitdown.

You're right about the steering on the deluxe upright. Mini upright is different again. Check its manual for more details.

yt said...

Howard: the main pain with forcefeedback isnt porting the outrun code, or the directx stuff as such. Its the fact that SDL will only support this with a patch. Making it tricky for porters as they need to build a custom version of SDL.

I started to build this under visual studio, but needed to do a lot of messing around.

I'm beginning to think bypassing SDL and simply using directx on the win32 build might be far easier. Then having a compile time toggle for the code.

RalphUp said...

I also have the 68mph issue when using an XBOX360 wireless pad set in Analog mode.
Plus I cannot set the Brake as LT as it is the -2 (-Z) Axis but the acc as RT works OK as the 2 (+Z) Axis

Also would be nice to have the Y Axis to scroll menu in Analog Mode.

Unknown said...


Well another option is to simply let something else deal with the FF signals.

A new version of mamehooker will be out shortly. You can send outputs via system messages (the way mame does it) or via DDE interface.

The supermodel guys already added mame-style output support without my help and I think it's coded in sdl as well. Of course they added true FF also. Maybe you should look at their code?

The problem with force feedback is it's kind of a microsoft thing anyway. You are probably going to have to use a cmpletely different interface for each port. I know that linux support for FF, for example, is kind of sketchy at best.

PI's i/o pins would probably handle real outrun hardware pretty well. That would be an interesting project.

yt said...

Hmm. Good feedback guys keep it coming. (Dum dum tssss)

Xbox/ps3 controller peeps: can one of you try a special build with some extra debug output for me? Will make it later this week. This will help me get things working for you.

Howard: thanks for the info. Maybe directx route is best then. Will experiment more later this week.

One other thing I shall do is enable a toggle between digital and analog for all controls as requested by some.

d from Shmups said...

Yes please let me know if I can help in any way, I would love to playtest a special build

RalphUp said...

I can test debug version with XBOX360 Wireless and PS2 DualShock with USB adaptor, not the DS3 BT though.

Unknown said...

I don't want to overwhealm you with responses or anything but in regards to 360 pads:

You'll have to keep in mind that some people will be using the official xinput drivers while others are using the XBCD drivers.

The main reason of using one over the other is actually the analog triggers.

Don't quote me on this, but I believe the official microsoft drivers combine both triggers into the Z axis and XBCD splits them into Z and RZ.

The official ones are kind of a pain because it means you can't press both triggers at the same time. Most people use that one though.

Dealing with controllers is a colossal pain in the butt. ;)

In regards to the menu support, I would suggest using the steering wheel axis to control scrolling, as pedals often drift.

Kungfu Steve said...

Well, Im no programmer, but looking at mame, it does not seem to need any specific controller information for analog / digial support. At worst, theres a way to tell mame to halve the inputs, to use only half the axis for one input, and the other half as a different input. But talking about force feedback... thats beyond me. As for menu support, thats pretty much a given that steering would be used over pedal for moving thru menus, purely because a pedal is one direction, and its often analog. (just as in the game, choose the music with wheel... and select with a button or pedal) However, there should be no reason why a pedal would drift any more than a wheel. They both use the exact same analog pots, both use gearing for higher resolution, both use the same encoder. If there is any drift, its probably purely mechanical... such as a loose locking pin. Also, in mame, theres a dead-zone setting, which can help with centering. In the real arcade game however, the centering deadzone may be induced by the games actual program code itself. Which should also relate to the pedals.. and even the tilt-reading pots. I do wonder how the 5k arcade pots differ from 100k pots that pcs use... and how it effects the resolution of the controls. And yeah, I think it would be great to use the real Outrun controls. (but I might want to use a pc instead, rather than a custom board, so could play other games as well. I have the entire outrun control panel, motor, shifter and pedal set. Originally had bought an outrun with board issues. After 2 non-working boards, and roms that didnt fix the problems, I gave the machine away 'as-is', for trade in services... and kept my 2nd set of parts. Im really excited to see new courses... and also, Id really like a few of the Sega Genesis features to be added: 1) Turbo mode: Where the car can achieve speeds & acceleration thats much faster than arcade stock speeds... making turns more hairy, and the game more risky. Change the timer to match the new top speeds, so as not too easy timewise. 2) Heavy Traffic Difficulty: Select a number, to increase the traffic drastically, making the game much more challenging & exciting. 3) The Genesis music track "Step On Beat" :)

Kungfu Steve said...

Hmm, looks like Sega used the same sound chips in many of their boards. May be fun to select songs from other sega arcade games.

Out of sheer theory and interest... I noticed that the original outrun board isnt fully filled with rom chips. (empty slots) Wondering if these could be filled and burned with extra levels, sprites, music, etc. ?

yt said...

For those of you with joypads that don't currently work well. Can you run the following test program:

There are instructions in the readme.txt file. Thanks!

Unknown said...


As a guy who is a programmer and who has contributed from time to time to the mame source, specifically in regards to the i/o system I can tell you that you are incorrect in your assumptions.

Mame handles each type of input differently, but due mostly to very slick macro courtesty of Aaron Giles all of that stuff is handled at the input code and thus when you look at a game driver it appears that they are all treated the same.

Mame handles full axis, split axis, reverse axis, axis with set deadzones and sensitivities and every combination of the above. That doesn't even get into digital gamepads used for analog inputs, mice, raw mice, ect...

Giving very basic support for a joystick is easy. Adding in code to handle all of these annoying little tweaks required for different hardware is not, or at least it's a little time consuming. I know that you mention these things as if they are trivial to add support for but unless you are fond of action mapping (it sucks) all of that has to be handled manually.

yt is up to the job, it'll just take a lot more xml settings and a few case statments.

Pedals can drift because of the split axis vs full axis issue, it has nothing to do with the stability of the physical device, but rather the fact that the joystick might not report a centered axis when both feet are off the pedals depending upon how it's read. I don't now how many pc racers I've went into the menu and the cursor constantly scrolls downwards because the pedals haven't been calibrated yet.

Regardless I only mentioned it because in a previous post someone suggested mapping the menu navigation to the y axis, aka one of the pedals. I think we are in agreement that this is a bad idea.

It wouldn't make any sense to waste time adding support for other sega songs at the chip level imho. We've got wave file support... rip the sounds from one of those emulator jukebox programs and add them that way... they'll sound identical.

RalphUp said...


Centered Axis 0 ranging -5597 to 5602 (i.e. dead zone)

Full Left MIN Axis 0 -32768

Full Right MAX Axis 0 32767

Axis 2 Min -1 Max -32641

Axis 2 Min -1 Max 32639

I would like to use Axis 1 for Menu Up/Down too ;-)

Sparky Kestrel said...

Hi, thanks so much for analog support, it is (almost) working perfectly with my Xbox 360 controller in Windows 8 (64 bit). I get the steering on the left analog stick and accelerate/brake default to the left and right triggers, just where I use them in MAME! Couldn't have asked for a better set up.

A couple of things I have found though:

First, for some reason in analog mode the speed is partially on unless I brake, ie when playing, if I don't touch either trigger the car will automatically move along at 62-63km/h. Both accelerate and brake work, and if I press on the left trigger the car brakes to 0kh/h as I would expect, so no biggie. However, this creates a problem on the high score table, as I cannot enter my initials unless I press brake and then accelerate straight after.

Second, in Windows 8 there are no drivers for the Xbox 360 controller as it is built into the OS software. This is fine, but the analog controller is VERY twitchy and even just pushing very slightly left or right causes it to move left/right respectively. This has one side effect though - sometimes when driving down the road the car will suddenly drift slightly to the left or right even when I am not pushing in either direction (this does not happen in MAME). To remedy this, is it possible to calibrate some sort of (selectable) dead zone in the game? I think I would only need 5% to stop this happening, and as I said, if you did include this I think it would be best to include it as an option only, so those that don't need it could turn it off.

Finally, and this is just a minor niggle and I don't require a fix, but when in the settings menus I can navigate the menus with the controller if the analog mode is off, but when on I have to use the keyboard to navigate the menu. But as I said, this is extremely minor and I don't expect or require a fix.

In other news, I finally tried out Pandora version today too. Perfect, but I don't like acceration on the right analog nub. I noticed others here have said the same with regards to their controllers so an option to inclcude acceleration/braking on digital buttons would be nice (this will then be included in the Pandora version thanks to the person maintiaing that build).
Interestingly enouygh, the 62-63kh/h issue is not present on the Pandora build but I still have to press brake then accelerate stright away to enter my intitials!

Anyway, I express my thanks again for the inclusion on of alaog control and if it is possible to address my second issue (as this is the only one I would really consider a deal breaker) then I think it really would be perfect.

If you have any thoughts/questions about my controller/issues, I would like to hear what you have to say.

Sparky Kestrel said...

Just after I made my post above, I thought if the issue would be different on my laptop (Windows 7 32 bit) since that requires a driver for the Xbox controller. I am running the official Micorosft Xbox 360 driver on my Windows 7 laptop.

The issues above remain though. The analog contgrols map pefectly to the left stick and triggers, but the 62-63kh/h issue (which also affects highscore entry as detailed above) and the deadzone issues are still present.

Also, if you think I might be confusing my controller causing the car to drift with the natural car drifiting already found in Outrun, I am actually well aware of this 'undocumented feature', but my controller issue is diffrerent - the car can be running perfectly straight (or slightly to the left/right as per Outrun's own drift bug) and suddenly the car will turn slightly without touching the analog stick, and I then have to nudge the stick to correct - very infuriating if I have lined up the car in a lane to avoid oncoming traffic and suddnely the car veers straight into its path!

So, my second issue re the Xbox 360's VERY twitchy controls remain in both my Windows machines (Win 8, no driver required and Win 7, official MS driver) and so i really need an (optional) configurable deadzone to play Cannonball properly.

Kungfu Steve said...

"It wouldn't make any sense to waste time adding support for other sega songs at the chip level imho."

It was my thought that it wouldnt take too much tweaking to run the other tunes (roms), considering they are on the same sound chip. Basically, I believe it would just be a rom swap.

The only issue would be in creating a way to select them. Maybe just in-game keypresses?

The advantage over Mp3 or Wav, would be audio quality, and reduced file sizes. Any form of compression, is a translation, and theres always losses in translations... Even if your ears are not good enough to tell the difference. (Or have a horrible onboard, or generic soundcard. Ohh yes, my old PCI soundblaster Audigy, kicks the living crap out of the newest dell machines at work, with built in soundchips. My sansung phone cant compare to my sony mp3 player, &the sony still doesnt come close to my pcs output quality. Of course, listing via Sennheiser HD 590s, really reveal every nuance. Which happen to also kick the crap out of Bose and Beats)

The option for MP3s / lossless music files, would be nice for other tracks, and things like the Genesis track mentioned. But actual rom support for certain games would be a nice feature.

Personally, Ive always envisioned a game engine, which incorporates emulated synths... like the legendary DX-7, for sound tracks and effects, rather than typical captured audio. Because emulation can be tweaked, you can also bypass older hardware limitations... and add features as well. Even use of multiple synth engines at the same time,may be useful.

Finally, Ill say it right out.. that I never cared for any of the 'Updated' Out Run songs. (using real instrumentation) The synth originals just sound so much better to me.

Sparky Kestrel said...

Sorry for the multiple posting, but I found the link above to the joystick tester.

Here are my readings for my Xbox 360 controller:

Joystick 0 axis 0 value -32768 to 32767
(left analog stick, steering)

Joystick 0 axis 2 value 32639
left trigger (Z axis, brake)
Joystcik 0 axis 2 value -32641
right trigger (Z axis, accelerate)

yt said...

So looks like the main thing I need to implement for the controllers is:

1/ a configurable dead zone
2/ split-axis support.

(I'm surprised the driver software with these controllers doesn't let you split the analog controls onto separate axis. That's a bit naff really.)

3/ Ability to toggle between analog/digital for each analog control.
4/ Menu support.

I'm not looking to solve every controller problem ever with this stuff, but the above support should mean most controllers work.

Progress is a bit slow lately, as I've been travelling with work and generally quite busy. But I'll probably roll this stuff into an update at some stage, move onto force feedback, then back to the level editor work.

yt said...

Steve: Regarding the music, unfortunately it's not as simple as that.

Each ROM contains a unique program that drives the sound hardware. This program differs between games, even though they use the same hardware.

For example, with OutRun the ROM contains routines for the passing traffic and Ferrari engine tone.

Therefore, stick with WAVs, they're uncompressed and should sound identical anyway.

bluepillnation said...

Steve (or anyone else wanting to give it a go):

This VST instrument:


is a very accurate emulation of the Yamaha FM chips used in the game. It works with any VST-supporting sequencer or DAW.

This thread (though old) links to a customised version of MAME which assigns controls to the YM2151 emulation via the numeric keypad. You can mute/solo the channels using keys 1-8, and key 9 will dump the current voice patches to an OPM file (compatible with VOPM) on disk.

Custom MAME Thread

There are various MIDI versions of the Outrun music dotted around the web, some of them note-accurate. You can use the above tools and one of these MIDI files to recreate the tunes in your DAW with the original patches played back through VOPM.

This will require a fair bit of effort, but the results will be good, and you can then mix and process the sounds to give them a high-fidelity makeover.

bluepillnation said...

Alternatively, you could WAV dump the solo'ed tracks for each tune to disk and reconstruct them in an audio editor/DAW. This will save messing around with MIDI, but the drawback to this method is that the audio fidelity of the source material will only be as good as MAME's YM2151 emulation.

yt said...

A future project is building a tracker style interface that let's you sequence and re-edit the OutRun music files...

bluepillnation said...

Interesting - I'd definitely be up for alpha- or beta testing that!

I suspect it'd be fairly complex in terms of playback though, as I think the patches are switched between tunes and possibly between patterns. You might know better, having an in-depth knowledge of the original data... Does the structure lend itself to a tracker-like format?

yt said...

Yes, there is the patch creation which would be phase 2.

You could start with some basic tracking of the drums and notes.

Having said that, there's lots I need to work on and not enough time. I need to work on force feedback still. Have been very busy lately, so no free time. Hopefully that should change in the coming weeks.

bluepillnation said...

Take your time man - such a project would be strictly "shits'n'giggles" because only a very few nerdy obsessives like us would probably use it! :)

Kungfu Steve said...

Thanks YT for the reply. But blue, I dont agree with your assessment. Outrun is one of the greatest Driving games ever made... and has a Huge following. I suspect that when certain features get added, the downloads will go through the roof.

But do try not to burn yourself out.
=) Would hate to see this project die before completing certain features.

yt said...

I won't burn myself out :-)

My general pattern over the last 3-4 has been to have a few months off and a proper break. Then I'm always excited to go back to it.

Having said that, I started force-feedback last night. I've got the DirectX side of things done. Need to port the OutRun code next...

Sparky Kestrel said...

After a session playing Cannonball tonight, I have found a couple of things out with regards to the prototype level.

First, it appears that the radically different prototype level only appears in the World version of Outrun. When playing the Japanese version with the prototype level enabled, only the first turn (right instead of left) and the roadside graphics are different, the rest of the level layout is exactly the same as found on the normal game.

Secondly, I have found a bug in Cannonball with regards to the prototype level. I played a game with the prototype enabled, then disabled the level, but the prototype level was still present even though I had disabled it. Trying to select between World or Japan versions made no difference - the relevant protoype level for the version selected was still there. Only after exiting and restarting the game was the original level restored.

Just something to look at as you ready your next version for release.

yt said...

Thanks Adam. I will investigate the issues you mention for the next release.

yt said...

Adam, just to let you know that the bug you mention is fixed in the upcoming release.