Guest post by Imran Nazar , a developer, author, and gamer.
I get nostalgic sometimes. I think back to the days of the Commodore 64, the Gameboy and other such simple consoles of the 1980s, and I wonder: can you play those games on a modern computer? Is it possible to relive the original Tetris, to play Giana Sisters or Elite all over again?
The answer, of course, is that you can. By putting a layer in between your computer and the game, the computer can be made to look like the original console for the game. The basic process is called emulation, and there are hundreds of emulators of every kind of system or console, all the way from a VMS mainframe to the PlayStation 2.
Which pieces do you need for an emulator to work?
- Some kind of graphic output so you can see the game when it’s running. (Sound output is also useful, but not an absolute requirement.)
- A way to take in keypad input, such as directional and fire buttons, to allow you to actually play the game.
- Most of all, because the emulator runs every bit of the game in its own environment, you need speed for the core process: ideally, millions of basic operations per second.
HTML5 for Emulation?
With the introduction of HTML5 elements, and related work on Firefox and other browsers, we can now get all of these things in the browser:
- Graphics are made simple by the element, which can be used in its 2D context to output a rasterised screen. It’s much simpler to use the canvas than involve plugins such as Flash and Silverlight, since the canvas is built into the browser from the start.
So, all the bits are there in a browser. There are just a few questions left.
How do you write an emulator, anyway? I’ve done more than a fair share of emulator development, but I’ve never come across a coherent tutorial series that explained, step by step, how to do it. I decided to make just that: a series of articles that starts with the very basics, and ends up with a working game console emulator. One of the simplest consoles in existence is probably the Gameboy handheld: since the focus of these articles was to be the structure of the emulator, and not the intricacies of the particular console, the Gameboy’s a good place to start.
Having answered the question of how to put together an emulator, the only other question is: why write a console emulator? It’s a good way to learn the ins and outs of a particular console, and excellent for bringing together the lowest and highest levels of development.