Power retro gaming with a Raspberry Pi
30th Dec 2012 | 10:00
Use the Raspberry Pi to take a trip down memory lane
There are many fine national institutions this sceptred isle has to offer: fish and chips, the perfect pint and Great Yarmouth Pleasure Beach to name but a few.
There is one institution, however, that stands proud, shoulder to shoulder with the iconic monuments that make Britain great. One that has bred a generation of imaginative free thinkers. One that symbolises everything that was good back in 'the day'. That one is none other than the mighty 8-bit home computing revolution.
These revolutionary creations were the heavyweight champions of 80s gaming, and some of the most cherished items of computing memorabilia to grace the pages of eBay. To relive those bygone days often requires us to install any number of emulators onto our hulking behemoth PCs, which takes away some of the spirit that embodies the golden age of the home computer.
There's another option, of course; we could purchase one of our beloved machines from eBay and hook it up to the old 52-inch plasma TV. However, these computers are getting a bit long in the tooth, and unless they've been cherished and looked after there's the possibility they could go zap and pop once plugged in to the wall.
Raspberry Pi: Everything you need to know
There is an alternative, though - one that combines the modern with the not-so-modern.
The Raspberry Pi - arguably one of the best innovations since the home computer, and one that is heralding a new golden era of computing.
This credit-card-sized computer is seeing its fair share of imaginative doings from the public; being sent to the edges of space, turned into a 40s wireless set, home automation controllers and many other projects that have gone to prove just how versatile and elastic the users, and the RPI, can be.
Therefore, we're going to take a leaf from their books, and see what we can do with a few items from eBay, a Raspberry Pi, sticky-backed plastic and help from the growing population of RPi owners, in order to help us re-create a classic 80s retro home computer.
The legal bit The legality of emulation is something of a grey area at the best of times, but in essence: if you own the console, and game, then you are allowed to obtain a copy of the corresponding roms to emulate them. At least that's what we think. If you're not sure, it's always best to look it up, just in case.
Our first port of call is that lovable rubber-keyboarded gem, popularly known as the Speccy. Indeed, the ZX Spectrum 48k was a powerhouse of innovation back in its day, turning bedroom programmers into commercial software giants overnight, where teenagers could come home from school and tap away until dinner time to create some of the best-loved games in computing history.
Anyway, enough nostalgia as it's bringing a tear to the eye. After a brief browse through the pages of eBay, we found a dead ZX Spectrum that came in at the paltry sum of £2.99 - after all it would be sacrilegious to mutilate a living Speccy. It looked a little worse for wear, but then most of us who can recall playing on one of these don't look overly healthy these days either.
Our first task was to make sure the RPi was up to spec; we'd been playing around with it since its arrival in the post, and as things move fast in the world of Pi we felt it was time to do an upgrade to Wheezy.
The system download can be found on the Raspberry Pi pages, along with full instructions on how to transfer it to an SD card, and get up and running. After that we did the necessary sudo apt-get update/upgrade, and within minutes our RPi was up to date and running like a charm.
Next came the dismantling of the ZX Spectrum, easy enough once the five screws on the bottom of the machine had been removed and the keyboard ribbons detached. The motherboard had a single central screw, which after being removed left only the bare plastic casing. The RPi is considerably smaller than the original Spectrum motherboard, so some careful placement was needed to make sure the RPi was situated conveniently and securely within its new housing.
To that end, we found that the RPi's RCA Video and Audio ports lined up nicely with the Spectrum's original Mic and Ear ports, but the RPi's SD card ran into the side of the plastic casing. A quick snip from the pliers made a slot that would allow us to swap SD cards, even when the case was screwed back together, and extending the homemade slot also gave us access to the power via an HTC charger.
Next, we hooked up the HDMI and Ethernet, and with the help of some ever-faithful black electrician's tape, we secured the RPi to the base of the Spectrum case, and taped the cables to the chassis to stop them from ripping the RPi out of its allotted place should they ever be moved.
Now we had the problem of the keyboard. Although there was a project previous to us trying this out, whereby a chap called Brian rebuilt a ZX Spectrum using a BeagleBoard, and successfully managed to get the keyboard working, our attempts fell somewhat short.
In other words, we failed miserably, making a bit of a mess of the keyboard ribbons and the USB interface we shanghaied from a USB keyboard for just the purpose. Still, never mind, we simply caved in and ran a traditional keyboard and mouse through the Spectrum's large IO port.
Once the case was back on, the ZXRPi didn't look too bad, albeit something that would send Heath Robinson spinning gaily in his grave. However, when hooked up to the TV and stylishly, yet discretely, placed in the TV cabinet, things didn't look too bad.
The only thing left now was to install a decent Spectrum emulator and get hold of some old games. The Spectrum emulator itself was easy enough to install and get running; for this project we're using Fuse Emulator, and to get it working do the following:
Drop in to a terminal and type: sudo apt-get install fuse-emulator-common and press Enter. Type, 'y' to confirm the download and install.
Once Fuse has been installed, and you are returned to the prompt, type: sudo apt-get install spectrum-roms fuse-emulator-utils and press Enter. When, once again, you return to the prompt, type in: sudo amixer cset numid=3 2 and press Enter.
This will allow the sound through HDMI, although it's rather flaky, so replacing the '2' with a '1' will force the sound through the audio port on the RPi.
When you're ready, come out of the terminal, and click the Start LXDE button, and navigate to Games > Fuse Spectrum Emulator (GTK+ Version). Click on this and expand the window by dragging one of the corners.
Next, download a Spectrum game, from somewhere such as World of Spectrum; once it's downloaded, from the Fuse top menu select Media > Tape > Open, then in the Spectrum window type, 'J' for Load, followed by 'Ctrl+PP' for "".
Your game should now load up, with sound coming from the audio port, which can be hooked up to a stereo or headphones. All that's left now is to try to complete Manic Miner, which you failed at nearly 30 years ago.
The thought of having a retro-styled case for our Raspberry Pi appealed to us greatly, despite the lack of hardware hacking to get 100% functionality, so we started to look around for other retro machines that tickled our fancy.
Our attention was drawn to an old friend, the Sega Mega Drive; a discrete, sleek-looking unit, even by today's standard, that like the Spectrum would make an ideal retro case for our RPi.
First, though, we need to prepare the RPi for its new life inside one of the best consoles ever made; and we want it to be able to play not only Sega Mega Drive games, but a plethora of other games from the hardware of the era.
To do this, we installed the excellent RetroPie project from petRockBlog; all you need to do is follow the instructions as they are given here.
In this instance, we decided to compile the most recent sources of programs, scripts and cores by selecting the second option from the main menu, the Source-based (custom) installation method. As is mentioned on the site, though, it takes several hours to compile everything, and the RPi is pretty much maxed out for the entire time, so don't expect it to do any work during the three hours of the installation; but bear with it, it's certainly worth the wait.
Once the installation had finished, the RPi got a well-deserved break in the form of a reboot. After that, it was a simple case of locating a game (we're assuming you're following the copyright guideline, as mentioned in this article) and running it, via a terminal, in this format: retroarch -L /home/pi/RetroPie/emulatorcores/Genesis-Plus- GX/libreto.so /home/pi/RetroPie/roms/megadrive/Sonic.md
In the example above, we had a Sonic the Hedgehog rom, which was located in the roms folder under 'megadrive'. Obviously, you will have to alter the command to represent your machine emulation, and the game you want to launch.
Picking up a dead Mega Drive was easy enough, and it cost less than a few quid to get it to the doorstep; but rather than rip out the insides straightaway, we had another cunning plan: would it be possible to house the Raspberry Pi inside the cartridge of a Sega Mega Drive game?
The Mega Drive we received was a little worse for wear; since its birth in 1992 it has seen its fair share of action, so although it was rough we thought this just added to its retro charm somewhat. Obviously, the game would have to be Sonic, and once we got an old Sonic the Hedgehog cartridge it looked as though it may be possible to squeeze the RPi into its innards.
Indeed, the RPi does fit in to a Mega Drive games cartridge, but it leaves very little room for cable management, even with sections of the cartridge plastic snipped away to accommodate the SD card. So, rather than having a savagely hashed cartridge atop the Mega Drive, with a tangle of cables, we decided to install the RPi within the body of the Mega Drive, and use what items we had lying around to try to keep some functionality from the original console.
We planted the RPi onto the Mega Drive base, with the SD card within easy reach through the side expansion port, which can be sealed with the plastic cover, and ran two USB extension cables from the RPi, and fitted them into the front gamepad controller ports.
The HDMI and Ethernet cables were pushed through the power and TV ports at the rear of the unit, and the power came via the side expansion. After making sure everything was battened down, and that the Raspberry Pi wasn't in any danger of sliding out of the side of the case, we started to feed the necessary cables through the correct holes. We carefully attached the lid of the Mega Drive, making sure the screws didn't catch any of the cables or the RPi itself, slid it into its new home under the TV and fed the now reconditioned MegaPi some power.
Obviously, the power and volume controls at the front of the console didn't work, but they added to the retro appeal of having a 90s console, with a modern spin. Our MegaPi functioned perfectly and we settled in for an evening of Mega Drive classics, via the Genesis emulator in RetroPie.
Our next software project bordered on the perverse, from the point of view of a Linux magazine. We managed to get DOS 6.22 and Windows 3.1 running under QEMU on the RPi.
Rather than building the image directly from within QEMU, we used a pre-built VirtualBox image, which we converted to a raw IMG file by issuing the following command: vboxmanage clonehd "image.vdi" "image.img" --format RAW
Replace image.vdi and image.img with the name of your images, then convert the raw image to a QEMU qcow image by typing in: qemu-img convert -f raw image.img -O qcow2 image.qcow
The result was extraordinary, and oddly satisfying to see Windows 3.1 start up and hear those 'ta-da' chimes. Needless to say, it ran like a pig in treacle, but the RPi hasn't got a whole lot of RAM, and after several minutes of running Microsoft's retro OS the screen froze and QEMU refused to boot the image until we deleted and re-converted it. Perhaps Ebon team coded in some kind of Microsoft failsafe kill switch?