Original version that ran on the Taito 8080 hardware.
Clone the repo and build the emulator with cargo build --release
.
The game rom cannot be distributed here for copyright reasons. Sound samples are available in the assets-folder. Sounds were created at jsfxr with the same copyright as the source code. Sounds could be customized with other samples if filenames and format are kept as-is (8-bit mono 11025Hz).
Sounds and the game rom should be located in a common folder called assets
as a sub-directory in the current working directory. The game rom should be in one single file called invaders.rom
, with the whole program in correct order. Then execute the binary ./target/release/inv8080rs
directly or do cargo run --release
to start the emulator.
-
cpu.rs Intel 8080 CPU model. Only the instructions used by the game are implemented.
Instructions are modeled as enums, carrying any immediate data. Execution is one big match-statement. Common cpu-operations have their own functions ("micro-code") to avoid duplication.
-
emu.rs SDL2-based I/O (keyboard, graphics, sound).
Runs the cpu-model in a loop at approximately the original speed (2 MHz) with the original 60 Hz display update. Two interrupts are generated during each frame (one in the middle of execution and one at the end). The execution is single-threaded.
The framebuffer is a piece of RAM-memory that needs to be rotated 90 degrees ccw before display. This transformation is done on-the-fly in the cpu:s
display
-function. The colored overlay is handled by drawing the display in several passes in different colors. The band at the bottom with remaining ships and score is not exactly as in the arcade game. The remaining ships are white here, not green. A slight retro pixelated effect is applied via alpha-blending of a grid on top of the game scene.Sound is handled with queues for each individual sample. Each sample is played only once while the corresponding bit is set. The looping feature for the UFO-sound has not been implemented.
Mapping keys to input-bus bits straightforwardly using scan-codes.
5
add credits1
start 1-player mode2
start 2-player modeLeft arrow
player 1 leftRight arrow
player 1 rightLeft ctrl
player 1 fireD
player 1 leftG
player 1 rightA
player 1 fireT
tilt and game over!Esc
quit
-
utils.rs A couple of useful functions.
-
main.rs Creates a CPU model, sets some options, connects it to the emulator, then runs the emulator.
- Emulator 101, most people reference this excellent walk-through. It seems like the original site is down so I'm linking to the Internet Archive instead for now.
- Computer Archeology - Space Invaders, could be enough for a more experienced emulator writer to implement everything.
- Emulation of the Space Invaders Arcade Hardware
- Space Invaders Emulator
- System 16 - The Arcade Museum, some non-technical info about the Taito 8080 hardware used for Space Invaders among others. Links to some cool old advertising flyers.
- Intel 8080 OPCODES, compact table of the Intel 8080 instructions and flags.
- Emutalk - Space Invaders thread, helpful insights by people having the same bugs as me.
- Intel 8080 Microcomputer Systems User's Manual, from september 1975. Chapter 4 - Instruction Set is invaluable.
- Intel 8080 Assembly Language Programming Manual, also from 1975. It is also very useful to understand in more detail how to implement the opcodes correctly as well as understanding 8080 assembler code.
- Understanding the x86's Decimal Adjust after Addition (DAA) instruction, DAA is needed for scoring and credits.