Need to run some old software? Fancy reliving the glory days of 8-bit consoles? Mike Saunders shows you how.
Wirth’s law states that software is getting slower more rapidly than hardware is becoming faster. We see this all the time with giant, bloated apps and frameworks, where everything is so abstracted away that even rendering a single pixel on the screen takes millions of CPU cycles. But there’s one category of software that hasn’t been afflicted by this, and it’s emulators. They have benefited enormously from boosts in CPU power over the last decade.
Today, it’s possible to emulate many computers and video games consoles at full speed, and even do extra tricks (like up-scaling graphics to work better with high-resolution displays). Over the next few pages we’ll explore a selection of the best emulators available for Linux – let’s party like it’s 1988!
Few people have fond memories of MS-DOS, due the tedious fiddling in AUTOEXEC.BAT and CONFIG.SYS that was required to make many programs run. On Linux, there are two programs that emulate a PC and provide an implementation of DOS: the first being DOSEMU, which hasn’t been updated for many years and can be tricky to set up, and the latter is DOSBox, which is fantastic and what we’ll concentrate on here. DOSBox is available in the package repositories of all major distros, so have a nosey around in your package manager to find it, or grab the source code from www.dosbox.com.
If you start it from a terminal window by entering dosbox, a new window will appear representing the emulated PC, with a DOS session inside. Look at the prompt and you’ll see that you’re initially on the Z: drive; enter dir to list the programs inside. Some basic tools are provided for a functioning DOS session, but how do you access your programs?
The solution is to use mounting. In your home directory, create a folder called DOS and place some DOS programs inside. Back in DOSBox, enter the following commands:
mount c /home/mike/DOS
(Of course, change /home/mike to match your login name here.) This makes /home/mike/DOS accessible as a C: drive inside DOSBox, so entering c: switches to that virtual drive, and you can now run programs just as you would normally.
Now, entering those commands every time you run DOSBox could get tiresome, but there are ways to automate it. When you first run the program, a hidden directory is created inside your home directory called .dosbox. So if you cd into that and enter ls, you’ll see an auto-generated configuration file containing the DOSBox version number – eg dosbox-0.74.conf. Edit this file, and scroll right down to the [autoexec] section at the bottom. Anything you add here will be automatically run when DOSBox starts, so place your mount command(s) here.
When you’re running DOS games, DOSBox may capture the mouse cursor inside its window. To get it back, press Ctrl+F10. If you find your games not running smoothly enough, try using Ctrl+F12 to increase the number of CPU cycles that are emulated each millisecond (they’re shown in the titlebar). You can reduce them with Ctrl+F11, and set the number permanently in the configuration file. Also, search for the sensitivity setting and reduce it if you find the mouse pointer too jumpy. For more tips on using DOSBox, switch to the Z: drive and enter intro.
Frontier was released in 1993 and had planetary landings. Elite Dangerous, over 20 years later, doesn’t. Pull your thumb out, Braben!
If you have a copy of Windows sitting around on a DVD, you can install it inside a virtual machine such as VirtualBox. This is also included in many distro’s package repositories – or grab it from
The main benefit to this approach is that your Windows software is almost guaranteed to work, but there are some performance penalties from running in a virtual machine. In VirtualBox, it’s possible to determine the amount of RAM and hard drive space that’s given to the emulated PC, and even take snapshots for quick rollbacks if an update or installation goes wrong.
Another option is to use Wine, which lets you run Windows programs on Linux (it intercepts Windows system calls and redirects them to their Linux equivalents). The main benefit here is that you don’t need a copy of Windows, and it’s open source. For more on this, read our Wine tutorial on page 88 of issue 11. And if you don’t have that issue, grab it from http://shop.linuxvoice.com, or buy a subscription to get access to all back issues in digital formats.
Consoles: 8-bit and 16-bit
For emulating Nintendo’s classic 8-bit NES console, we recommend Nestopia, available in most distro’s package repositories or at http://nestopia.sf.net. Nestopia uses more CPU time than other NES emulators, but it’s extremely accurate as a result and can play almost anything. Plug in a joypad, start it, and go to Emulator > Configuration in the menu. Switch to the Input tab, then click on the emulated NES joypad buttons to assign them to your real joypad. With that done, go to File > Open to load a ROM and begin playing. Nestopia lets you save and restore states – that is, snapshots of the emulated NES’s RAM – so you can store your progress right before taking on a particularly hairy jump or boss.
If you were more of a Sega fan, you’ll be on the lookout for a Master System or Game Gear emulator. These machines were largely identical internally, sporting the same Z80 processor and other chips. The Game Gear had a larger colour palette, but you could get an adaptor for it to run Master System games, and porting between the two consoles was a doddle for developers. Many Game Gear units have stopped working over the years or developed unusable displays; it’s possible to rectify this with some soldering work, but for most of us, emulation is the simplest option.
The best emulator here is Mednafen (http://mednafen.sf.net). This is actually a multi-system emulator, and along with the Master System and Game Gear it can also emulate the Super NES, Game Boy (original, Colour and Advance), Atari Lynx, Virtual Boy and other systems. Search for it in your distro’s package manager, or to build it from source code install the development headers for libsdl1.2, libasound, libsndfile and zlib1g.
Start Mednafen by giving it a ROM file, like so:
Mednafen is command-line driven, so there’s no fancy GUI to perform a setup. Fortunately, however, you don’t have to spend ages poking around inside configuration files to configure input devices. With a joypad plugged in, press Shift+Alt+1 to configure device 1: text prompts along the bottom of the window will show you which buttons to press. Mednafen emulates “turbo” buttons – ie rapid-fire versions of the normal buttons – which is useful for some shoot-em-ups.
If your games don’t have any sound, close the emulator and open .mednafen/mednafen-09x.cfg in your home directory. Search for the sound.device and sound.driver lines, and change them to the following:
Save the file and restart the emulator; this fixed the lack of sound on our Xubuntu 14.10 installation. It’s also worth noting that Mednafen has plenty of extra features, such as state saving (F5) and loading (F7). To switch to full-screen mode hit Alt+Enter, and to quit press Esc. See http://mednafen.sf.net/documentation/ for the full list of available keybindings.
As mentioned, Mednafen also does a good job with Super NES and Game Boy emulation, but there’s one thing to note: for each console you emulate, you’ll need to redo the joypad setup procedure with Shift+Alt+1. In other words, the setup you made for the Master System or Game Gear won’t apply to the other consoles. Your configuration will be saved automatically, though, so you won’t need to go through the procedure every time you play a game.
Mednafen doesn’t work especially well with Mega Drive (aka Genesis) games in our experience, so for that machine we recommend DGen/SDL from
http://dgen.sf.net. To compile the source code, download dgen-sdl-1.33.tar.gz from the site and extract and compile it as follows:
tar xfv dgen-sdl-1.33.tar.gz
./configure && make
You will need to install the SDL 1.2 development libraries – in Ubuntu and other Debian-based distros, this is in the libsdl1.2-dev package. Once it’s built, run it in place like so:
As with Mednafen, there’s no pointy-click GUI, but you can bring up a prompt by hitting colon. For instance, typing :calibrate will set up your joypad. Use Alt+Enter to switch to full-screen mode, F2 and F3 to save and load states, and Esc to close. (If you’re new to Linux and find the process of compiling source code baffling, see www.linuxvoice.com/linux-101-how-to-compile-software for our in-depth guide.)
Nestopia is a cycle- accurate emulator, so it tries to be as close to a real NES as possible.
And now we come to the best part: the home computers of yesteryear. Most of us at Linux Voice cut our teeth on the ZX Spectrum, Commodore 64 or Amstrad CPC in the late 80s, before moving on to the Amiga and Atari ST in the early 90s. Emulation of these machines is a bit more involved than MS-DOS and the old consoles, but it’s still doable, so let’s go through them individually.
For the Amiga, the best option at present is FS-UAE (http://fs-uae.net). This software is available in many distro repositories, and the website has excellent download information including copy-and-paste instructions to get it installed on Ubuntu, Debian, Fedora, OpenSUSE and other distros. It’s possible to use FS-UAE at the command line, but it’s better to enter fs-uae-launcher in a terminal window to bring up the graphical configuration tool.
You’ll need two things for Amiga emulation: an image of Kickstart, the ROM-based operating system included in the Amiga, along with floppy disk images of your games (or Workbench). It’s possible to buy Kickstart and Workbench from www.amigaforever.com, but these images are also available to download from various places on the web. We won’t provide links here, due to the dubious legality, but if you still have an Amiga you may not feel that you’re “stealing” anything by simply obtaining images for things you already bought.
So, once you have a KICK.ROM file, click on the Hardware Options tab in FS-UAE and then Browse to select it. Go back to the Main Configurations Option tab and choose your Amiga floppy disk image(s) – these normally end in .adf. When you’re ready, click Start at the bottom, and the Amiga will boot up. Note the awesome emulated noise of the whirring floppy disk drive! FS-UAE will grab your mouse pointer for itself; to get it back, press F12+G simultaneously.
For the Atari ST, Hatari (http://hatari.tuxfamily.org) is an excellent emulator that’s included in many distro repositories and has a point-and-click GUI to set it up. As with the Amiga, you’ll need a ROM image of the ST’s operating system before you begin; place this in
/usr/share/hatari/tos.img. Then start the emulator by pointing it at as disk image file, eg:
The GEM desktop will appear, and the disk image you specified will be provided as the A: drive. Hit F12 to bring up the graphical options dialog box; under the System menu you can change the type of machine being emulated, and also provide more RAM or CPU speed. Click on the Hatari Screen button to switch to full-screen mode.
The Atari ST played second fiddle to the Amiga in many respects, but it was still a good machine for the time.
ZX Spectrum and C64
Finally, let’s look at the classic 8-bitters. The best ZX Spectrum emulator is Fuse (http://fuse-emulator.sf.net), which is provided in the fuse-emulator-gtk package in Debian-based distros. With this installed, enter fuse-gtk at the command line and the main window will pop up. You’ll see a warning that the Spectrum ROM file is missing – but in this case, Fuse uses its own, which works well enough. Click File > Open to load a Spectrum game (in .z80 or .sna format – they are snapshots of RAM).
By default the window is rather small, so click Options > Filter to change the graphics mode (eg double or triple size). Under Machine > Select you can change the type of Spectrum that’s emulated, while the Machine menu also has other options useful for finding pokes and exploring the emulated Spectrum’s memory map.
For Commodore 64 emulation, our pick of the bunch is VICE (http://vice-emu.sf.net), the Versatile Commodore Emulator. To use this, you’ll need some ROM images from the original machine – and again, if you own a real C64, you may be able to find them on the web with a bit of searching. Once you have the files kernal (not a typo!), basic and chargen in the current directory and VICE installed, enter x64 to start the emulator. The BASIC prompt will appear; click File > Smart-attached Disk/Tape to load a game or program and have it automatically start. VICE is extremely configurable, so click the Settings menu to see what it’s capable of.
Many distros don’t have DGen/SDL in their repositories, but it’s easy enough to build from its source code.
Many people dismissed the Raspberry Pi – and especially the model 1 – as too weak for game console emulation. But it’s actually very good when emulating the 8-bit and 16-bit consoles, and there’s a specialised distro called RetroPie that makes it easy to get started. Go to http://blog.petrockblock.com/retropie, download the SD card image, and write it to your Pi SD card like you would with a regular Raspbian image.
If you go into the /home/pi/RetroPie/roms directory on the SD card, you’ll see subdirectories for all the supported platforms: most of the names are obvious, but note that gb is Game Boy and gbc is Game Boy Colour. So place your ROMs in the appropriate directories, connect a USB joypad, and boot up the Pi. The Emulation Station front-end will load; this provides access to all emulators that have ROMs in place. You’ll be asked to set up your joypad; note, however, that this only works in the Emulation Station interface. To set up a joypad for use inside the emulators themselves, hit F4 to switch to the command line and enter:
Choose menu option 3 (Setup) and then option 317 (register RetroArch controller). Follow the steps and reboot to have your joypad working in the emulators. Note that you can also hit F4 and run sudo raspi-config to perform the usual Raspbian setup steps, like expanding the filesystem to fill the full SD card.