You know when you’re having that long-overdue clean-out and you find a few things stashed away you’d forgotten about? From when you said “that’ll make a great project one day” then tossed it in your equivalent of the bargain bin? Just happened to me.
A few years ago, I got a great Atari 2600 VCS job lot. Two consoles (a light-sixer and a Vader – now both composite modded) and a stack of games. Out of all the games only one appeared to be beyond repair. That cartridge, Activision’s F-14 Tomcat, was duly placed in the bits and bobs box until a project came to light for it.
Almost simultaneously, I came across the cart and a couple of 9-pin sub-D joystick ports. The brain, it ticked. And tocked. And finally came up with a Raspberry Pi Zero. Of course, an Atari 2600 in a cartridge! Why not? Why? Who cares.
Before I did anything else, I prototyped the build on a Raspberry Pi 2 and a breadboard. My requirements were:
- Inputs for two joysticks
- A power button
- A method for shutting the Pi down cleanly
- The TV colour switch
- The difficulty switches for both players
- Select and reset
- Some method of access to the console
Thankfully, the newer Pis have enough GPIO inputs to handle all this.
The Atari emulation itself is very straightforward. I decided to use the excellent RetroPie operating system as it handles all the game selection menus for you. I would then use Stella for the actual emulation of the Atari 2600.
The trick now was how to couple-up the joysticks and buttons to the emulator. The easiest approach is to trigger keypresses and map the emulator to them. After some research and a few false-starts, I settled on Adafruit’s Retrogame package, which did exactly what I needed. With a simple config file, I could map changes on the GPIO pins to keypresses. It worked perfectly. Soon I had a breadboard mockup where I was controlling the games by shorting the pins to ground.
Another problem with keys was to be able to shutdown the Pi cleanly. I ended up writing a short Python script using the python-uinput package. This does a similar job to Retrogame but I was able to configure things so if the power button was pressed once it would quit the current game (and return to the selection menu) but if held for three seconds, it would trigger a system shutdown. Implementing this script also gave me the chance to add an LED to the front so I could see when the system had finished shutting down (I also really like LEDs).
The last part was adding a barrel connector hooked up to the UART pins so should I ever need to, I can get console access without having to take everything apart. I tend to do this just out of habit with build like this and have a ready-made USB-to-UART lead with a 3.5” stereo jack on the end.
First off, lets get that cartridge cleanup, open and remove all that complex circuitry. Oh.
So there you go. Hours of fun on Combat ahead. Think I’ll skip E.T. though. The Pi Zero has enough grunt to run Stella very well indeed, although it finds Emulationstation a bit of a struggle (but not bad enough to be unusable).
I’ll be bringing this little gizmo to the Milton Keynes Raspberry Jam on the 15th July 2017. Hopefully I’ll see you there!