Making a button interface from an old keyboard
Next thing we need is someway of interfacing the arcade sticks and buttons to the PC. You can buy an I-PAC interface for about £30 and you can get a full joystick and button kit plus interface for about £90 - £100. Quite reasonable I think but you guessed it, Im making my own.
Im not an electronics wizz but im sure a keyboard is just a whole bunch of switches that make a conection when you press one of the keys. So then why can't I connect a microswitch across the same connection. Turns out, you can. There are some articles about it already on the internet.
Luckily enough, I have a couple of old keyboards in the garage and before long they had been unscrewed and opened up. They are all slightly different but this one had 2 membranes of connections crossing each other where the keys are located all running back to a small board. Was now just a matter of tracing each one to find the key combinations.
A handy keyboard interface from a perfectly good keyboard
Now that I had mapped the keyboard interface, it was just a matter of working out the best keys for my controls. It was then that I realised one thing I had overlooked. Joypads! Mame has pretty good support for multi button pads so why not use them. Luckily enough, in a box somewhere was not 1 but 2 old knackered joypad controlers. The sticks didnt work on them anymore but that didn't matter. Soon they were in bits before me.
Takes me back to the old days when I would regularly butcher joysticks after someone had broken your favourite controller playing an old C64 olympics game!
Look at that, almost as if it was meant for someone to solder microswithes to
I see a number of advantages using the gamepad approach, the first of which is that they are usb and therefore interchangeable. There is also a problem with keyboard 'ghosting' caused by pressing multiple keys simultaneously which this should prevent and mapping all the required buttons to the interface could be quite a drawn out affair.
I will still need the keyboard interface, for the auxiliary controls such as coin insert and player start so I'll set these up on the keyboard and keep the game controls to the joypad.
Designing the controls
Now I have just one more task before I start on the building part of the project, the controls. While this may seem straight forward, Im not going to dismiss it early on only to discover a showstopper after Im screwing the cabinet together.
My plan is to have 2 removable panels for the controls. The idea being that for 90% of the time it's going to be used for one player games or alternating 2 player games such as galaxians and pacman where 2 players share one controler alternating. In this scenario, I don't want the main player to be off to the left of the screen, they should be central. So, I should be able to slide the left control into the center and remove the 2nd player when not needed. The mechanism for this is yet to be defined.
I have my keyboard and joystick/button interfaces, I just need to plan the layout of the controls and what buttons I need for all the games I'm likely to play. I've seen lots of mame cabinets that just have a joystick and a cluster of 6 buttons to the right. Not bad for most games but there are some special cases where this wont be good enough. I want to keep the controls as faithfull to the originals as I can, not easy as I'm emulating so many different ones.
After a while playing about with 2 penny pieces, I think I have the ideal layout which works for Street Fighter, Asteroids, Defender, Track n Field and button movement.
The blue thumb button to the right of the stick is vital for Defender, the thrust fire and smart bomb/hyperspace are covered by the 3 red buttons and there is also a central green hyperspace button for Defender. The blue and green buttons become the laft/right controls for Asteroids.
Asteroids and Defender layout.
Using the buttons for left/right control as in Asteroids the 2 buttons in the bottom row of the main button cluster are for the fire and any other control required. In fact any of the 6 button cluster can be used here.
Galaxians should be played with buttons
Street Fighter 2:
Street Fighter layout. This layout covers pretty much anything else.
And so, with all these combined you get this
The final layout, for one and two players plus p1 and p2 start.
With the addition of the p1 and p2 start buttons along the top and possibly insert coins but Im hoping to put these in the coin door which Im hoping to add.
There will probably be auxilary buttons somewhere for pause and escape back to menu and maybe tab to open the options screen but these may be hidden round the side or underneath.
A look at the MaLa frontend
As a diversion to the hardware side of things, I've took a break to look at the frontend. MaLa seems quite popular with cabinet builders so I downloaded it and set it up.
Once installed and configured, it pretty much starts working straight away. All it needs to know is the locations of your Mame install and your Roms directory etc, it does the rest. One thing of note, it almost destroyed my main PC with windows 7! The whole screen went haywire and I had to unplug and restart. Luckily no permanent damage was done and I was a bit tentative as to try it on the cab PC. I was sure however it was an OS issue so installed it anyway and was fine on my XP cabinet PC.
Doesn't look like an arcade machine but quite nice.
MaLa is pretty customisable and there are many frontends available to download. You can configure screenshots and movies to display when you select a game, play a movie on startup and has a nice screensaver that cycles throught random movie files. You can even set it up to launch when windows starts and close windows when MaLa exits.
However, as Iv'e said before, it has to look as real as possible so no fancy frontends required but with the options MaLa offers it might do just what I need. If I can record a bunch of attract screens from my games and have these play in the screen saver and maybe get one of these to play on startup then I'll be happy with that.
Unfortunately, it's a big IF. I recorded some avi's using Mame's built in record function but thay are uncompressed and some are absolutely huge. Of course, on my crappy cab PC they clunk and grind away my HD when they are playing and are too juttery to work properly. I tried recording them with Fraps which was better but some work ok, some play at the wrong frame rate. So frustrating. I'm begining to think about upgrading the hardware, maybe!
Writing your own Mame Frontend
Today, for the 1st time I am happy. Probably the only time on the project so far that something 'seems' to be going right and I actually feel a sense of acheivement.
Not totally happy with MaLa I looked at how I could write a frontend of my own. I had knocked together a 'noddy' app that would launch the Mame command line. It works but is just simply executing of a process from a .net winform but at least it works and got me interested in looking at this a bit more:
Im keeping it simple, the frontend just needs to be a collection of game 'Insert Coin' screenshots that can be cycled through with the left/right control and launched with the fire button. There is also going to be a screensaver mode that will cycle through random movies of the games after a period of inactivity. I fact a better option than playing a movie might be to just launch a random game in Mame on a timer and let it play through a startup sequence on its own until you press a button. Mame has a command line option just for this handily:
mame galaxian -seconds_to_run 30
This will run galaxians for 30 seconds, I can then keep doing this until a control is activated.
There was one thing I overlooked of course. Reading the joypad. This wasn't going to be out of the box possible without DirectX and after further investigation Microsoft has dropped the Directx SDK in favour of XNA. To be honest I could have done without having to get into all this stuff but needs must and it will certainly make things interesting. However, XNA only supports machines of a certain spec, specifically the graphics card ability and of course, my cab PC falls way below it.
So, after some googling I stumbled across SLimDX, an open source framework for developing DirectX for .net. I downloaded and installed along with a handy directinput example and before you know it I had the foundations of my ArcadeFrontEnd working with a joypad on my cab PC.
Some time later, I had my front end running on the cab PC. It launches full screen and the screenshots slide in left and right with the pad, thanks to a transitioning library I found on code.google.
Simple, but as I've said, It has to look real, like an actual running arcade machine and this does. No fancy stuff, which is what I wanted and I think there is nothing cooler than having the cabinet just playing through game startup and attract sequences in the background.
Now I just need an acronym to name it!