SIDE - Space Invaders Didactic Emulator

Select a topic from the list, or just start reading.

  1. Yet another Space Invaders emulator?
  2. What does it mean a "didactic" emulator?
  3. Who's this emulator for
  4. What's next
  5. System requirements and installation
  6. License
  7. Acknowledgements
  8. Downloads

Quick link to design doc and hardware table.

Back to the Art of Programming site section.

1. Yet another Space Invaders emulator?

Space Invaders must be one of the most emulated games ever. There are several reasons for that. Its historical value, for example: published in 1978, it is the first original videogame, the first that set up a new world rather than just transposing some aspects of ours, like sport simulations. Fun is another reason, its simple but incredibly addictive gameplay has allowed the game to live to these days, for more than twenty years. Also, the game is relatively easy to emulate and doesn't offer particularly difficult challenges.

Because of that, there are dozens of Space Invaders emulators around, so why to write another one? Well, my goal is not to write an emulator and then forget about it, but rather to write a series of didactic emulators that can be used by programmers that are moving their first steps in the emulation world. For the reasons stated above, Space Invaders is a perfect starting point. It is simple enough, yet still interesting to play with and very rewarding to emulate. This last bit is in fact common to all emulators, the feeling of amusement and joy, the emotion of watching an old game coming to life again is one of the most rewarding experiences that computer programming can give.

That's why I think there is room for yet another Space Invaders emulator, and I hope for those that will follow too.

2. What does it mean a "didactic" emulator?

This is not a complete course on emulation. The basic concepts are not at all difficult to understand and there already are good references on the net. Good documentation is scarce, however, and for many games the only available information comes from the source code of some compatible emulator. Unfortunately, most emulators are written with speed and overall performance in mind, and they are not designed for use as reference guides. Browsing for info through thousands of lines of source code is painful and it takes a lot of time. Success is not guaranteed either. I try to address these and other issues in my emulators, as explained below.

Documentation. There is plenty of documentation for each emulator in the series. This goes from documents describing the hardware being emulated to the complete HTML help for all the public variables and functions. There are a lot of comments in the source code too, with in-depth explanations of all the tricky bits that are sometimes necessary.

Source code. The source code has been explicitly written to be highly readable. Identifiers are meaningful and descriptive, and the code itself is carefully formatted and organized. There are no optimizations and no cryptic pieces of code. There are no #ifdef's or #define's. Together with the numerous comments, that makes the source code very useful to understand how the program works. Also, there is a clean separation between the emulation code and the presentation code. The first is highly modular and portable while the latter, which is a very small part, must be rewritten for each platform. Here you will find the Windows code only but I have ported the emulator to Linux KDE in less than one hour (graphics, sounds and all) without knowing Linux at all, thanks to the terrific power of KDeveloper and the QT libraries. So, well, it is portable.

Architecture. The program architecture is designed to be simple and easy to understand. Only a handful of classes is used. Again, some optimizations have been sacrificed for a simpler architecture but do not worry, as it is still much faster than needed.

3. Who's this emulator for

This emulator has been written as an educational tool for those who are interested in knowing how an emulator works. For that use, some knowledge about emulators in general and some programming skills are required. But it is also a fully functional emulator that can be used to have some good fun, and since it is very small in size it can be downloaded very quickly or even sent to friends by e-mail as an attachment. Note however that the required Space Invaders ROM is protected by copyright, please make sure you have the rights to use one and do not distribute it in the same package with the emulator.

4. What's next

The next emulator in this series will be for Pacman. Then, it's difficult to say. I would like to emulate a complete game system, such as the Gameboy or the Super Nintendo, but that is still much far away. I'm not completely satisfied by the use of C++ too, because it cannot be used to write a portable graphics interface without using an external library. As personal computers get faster and faster, Java is becoming a viable alternative to traditional languages used in emulation, such as Assembly and C, and I'm considering switching to it somewhere later in the project.

5. System requirements and installation

The emulator should run under any 32-bit version of Windows (such as Windows 9x, Windows NT and Windows 2000.) The program has been written assuming a video mode with 64K or more colors: video modes with 256 colors or less will probably fail to display colors correctly, or even to show the game screen. DirectX is required to play sounds. (The emulation code is portable however I have implemented the presentation layer only for the platforms stated above).

The Space Invaders ROM should be named "invaders.rom" and placed in the same directory as the program executable. The ROM file is not supplied with the emulator, you must get a copy elsewhere. Please note that the original ROM is protected by copyright, and you should have the rights to own and use one before using a copy with the emulator. The ROM file is not part of the emulator files, do not distribute it together with the emulator.

Note that if you have four distinct ROM files it is possible to join them to create a single "invaders.rom" file from a DOS prompt as follows:

copy /b invaders.h+invaders.g+invaders.f+invaders.e invaders.rom

There is no need to install the program, simply unpack it (preserving the folder names) into a directory of your choice and it is ready to run. To uninstall, just delete it. The program does not write to the disk or into the registry, so there is no additional cleanup to do when uninstalling.

6. License

Space Invaders Didactic Emulator is Copyright (c) 1997-2003 by Alessandro Scotti.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

7. Acknowledgements

Thanks to Joe Linoff for writing ccdoc, the wonderful tool used to generate the source code documentation, and for making it free.

Thanks to Marat Fayzullin for writing Z80 emulator and for publishing its source code, which is an invaluable reference and the place I've looked first when unsure about something.

Thanks to the MAME authors for an incredibly great emulator and for the richest source of information about games in the emulation world.

Thanks to all the folks who have made available the documentation on the 8080, the Z80 and Space Invaders.

The acknowledgements above are in no particular order, my program owes to all of them.

8. Downloads

The emulator documentation and source code is available as a single package here. Here is a minimalist front-end for Linux (KDE).

I have compiled the emulator for Windows (see above), you can download the executable here (23K). You'll probably need the sound samples too.

The Space Invaders ROM file is not available on this site because it is copyrighted.

Copyright (c) 1997-2003,2004 Alessandro Scotti. All rights reserved.

 Home :: Computer Programming

Site Map