Space Invaders display
Open and use the device
To open the display, double-click spaceinvaders-display in the device list on the Emulator tab. The following screenshot shows a one-player game with scale = 2 and colorOverlay = true:

| Mark | Explanation |
|---|---|
| 1 | Score. Read the player and high scores. |
| 2 | Invaders. Track the advancing formation. |
| 3 | Player area. Move the cannon and fire from behind the shields. |
| 4 | Lives and credits. Check remaining lives and inserted credits. |
The red upper band and green lower band come from the optional color overlay. The underlying framebuffer is monochrome. Use the main window’s debugger toolbar to pause, resume, or reset the game.
Controls
The game window must have keyboard focus. Inputs are active while a key is held and clear when it is released.
| Key | Action |
|---|---|
| C | Insert coin |
| 1 | Start one-player game |
| 2 | Start two-player game |
| Space | Fire |
| Left / Right | Move |
| T | Tilt |
Movement and fire keys drive the player-one input port. Separate player-two movement and fire inputs are not mapped, so use one-player mode for normal play.
Display settings
On the Emulator tab, select spaceinvaders-display in the peripheral device list and click Show settings…. The settings panel is shown below:

| Mark | Explanation |
|---|---|
| 1 | Scale. Set the display’s integer enlargement factor. |
| 2 | Color overlay. Toggle the red and green arcade-screen bands. |
| 3 | Sound enabled. Enable playback of the game’s sound samples. |
| 4 | Samples directory. Enter the directory containing sound samples. |
| 5 | Browse. Choose the samples directory. |
| 6 | Save. Validate, save, and apply the display settings. Press Escape to discard edits. |
| Setting | Description |
|---|---|
| Scale | Set an integer pixel scale of at least 1. At 2, the display area is 448 by 512 pixels. Saving resizes an open game window. |
| Color overlay | Show red at the top, green at the bottom, and white in the middle. Clear this checkbox for white pixels on black. |
| Sound enabled | Enable playback of the external sound samples. Clearing this checkbox stops playback. |
| Samples directory | Enter the directory containing 0.wav through 9.wav. Relative paths are resolved from emuStudio’s working directory. |
| Browse… | Choose the sound samples directory. This updates the field; click Save to apply it. |
| Save | Save all four settings, apply them immediately, and close the dialog. No restart is needed. Changing the samples directory reloads the sounds when sound is enabled. |
Press Esc to close the dialog without saving. The scale must be a positive integer and the samples directory must be a nonempty, valid path. Invalid input keeps the dialog open so you can correct it. Sound samples are supplied by the user; choosing a directory does not download them.
Volume and recording
In the display toolbar, click Audio volume to open the volume slider. Volume ranges from 0% to 100% and starts at 25%; it changes both playback and recorded sound. The slider value lasts for the current computer session.
Click Start video recording to start capturing, then Stop recording and save video and choose an MP4 file. These names appear as toolbar tooltips. Canceling the save dialog discards the capture. Recording uses the native 224 by 256 pixel frame at 60 frames per second, with the selected color overlay and stereo sound from the active samples. Display scaling does not change the video dimensions. Encoding runs during capture; saving finishes the file in the background. Keep the display open until you stop and save: closing it discards an active recording.
Programming the display
Programs draw by writing directly to byte memory and access the device’s input, shift-register, and sound functions with the 8080 IN and OUT instructions. The device reserves CPU ports 1 through 5; a port’s read and write functions can differ.
Screen memory layout
The framebuffer occupies 2400h through 3FFFh: 7168 bytes for 224 by 256 pixels, with one bit per pixel. A set bit lights a pixel; a clear bit leaves it black. Each column occupies 32 consecutive bytes, starting at its bottom edge. Bit 0 is the lowest pixel in a byte and bit 7 is the highest.
For screen coordinates x = 0..223 and y = 0..255, with (0, 0) at the upper-left corner:
hardwareY = 255 - y
address = 2400h + x * 32 + (hardwareY / 8) ; integer division
mask = 1 << (hardwareY & 7)
To light one pixel without changing its neighbours, OR the byte with mask. To erase it, AND the byte with the 8-bit complement of mask.
| Pixel | Address | Mask |
|---|---|---|
Upper-left (0, 0) | 241Fh | 80h |
Lower-left (0, 255) | 2400h | 01h |
Upper-right (223, 0) | 3FFFh | 80h |
Lower-right (223, 255) | 3FE0h | 01h |
There is no colour attribute memory. With colorOverlay = true, lit pixels are red in rows 0–63, white in rows 64–183, and green in rows 184–255. With the overlay disabled, all lit pixels are white.
I/O ports
| Port | Read | Write |
|---|---|---|
1 | Coin, start, fire, and movement inputs | Ignored |
2 | Cabinet inputs, including tilt | Shift amount (low three bits) |
3 | Shift-register result | Sound control 1 |
4 | Returns zero | Shift data |
5 | Returns zero | Sound control 2 |
Keyboard input
IN 1 returns the following bits. Keyboard inputs are active high: a pressed key sets its bit and releasing the key clears it. Reading a port does not clear the inputs.
| Bit | Mask | Meaning |
|---|---|---|
0 | 01h | Coin (C) |
1 | 02h | Start two-player game (2) |
2 | 04h | Start one-player game (1) |
3 | 08h | Always set |
4 | 10h | Fire (Space) |
5 | 20h | Move left (Left) |
6 | 40h | Move right (Right) |
7 | 80h | Always clear |
On IN 2, only bit 2 (04h) is mapped, for tilt (T). Other bits return zero; cabinet DIP switches and separate player-two movement/fire inputs are not implemented. For example, IN 1 followed by ANI 10h tests whether Fire is held.
Hardware shift register
The 16-bit shift register helps programs align sprite data. OUT 4 loads a new byte into the high half and moves the previous high byte into the low half. OUT 2 selects a shift amount from 0 to 7; other bits are ignored. IN 3 returns the shifted eight-bit result:
OUT 4: register = (newByte << 8) | (oldRegister >> 8)
OUT 2: amount = value & 7
IN 3: result = (register >> (8 - amount)) & FFh
Writing AAh, then 55h, to port 4 leaves 55AAh in the register. Selecting shift amount 2 makes IN 3 return 56h. Reading the result does not change the register. Reset clears both the register and shift amount.
Sound output
OUT 3 and OUT 5 latch sound-control bits. In addition to enabling playback in the configuration, software must set bit 5 of port 3 to enable the emulated amplifier.
| Bit | OUT 3 | OUT 5 |
|---|---|---|
0 | UFO loop (0.wav) | Fleet step 1 (4.wav) |
1 | Shot (1.wav) | Fleet step 2 (5.wav) |
2 | Player hit (2.wav) | Fleet step 3 (6.wav) |
3 | Invader hit (3.wav) | Fleet step 4 (7.wav) |
4 | Bonus (9.wav) | UFO hit (8.wav) |
5 | Amplifier enable | Ignored |
6–7 | Ignored | Ignored |
One-shot effects trigger when their bit changes from 0 to 1 while the amplifier is enabled. Clear the bit before setting it again to replay an effect; repeatedly writing the same value does not retrigger it. Keep the other control bits when changing an effect. The UFO sample loops while port 3 bits 0 and 5 are both set. Clearing bit 0 stops the UFO loop; clearing bit 5 stops all sounds. Reset clears both sound latches and stops playback.
For example, writing 20h, then 22h, then 20h to port 3 enables sound, triggers a shot, and clears its trigger bit ready for another shot.
Raster interrupts
A frame clock alternates 8080 RST 1 and RST 2 interrupts at 120 half-frames per second and refreshes the display at approximately 60 Hz. Timing follows the host clock rather than cycle-exact scanlines. Interrupts also run during headless automation, where you can supply cabinet controls from a file.
RST 1 enters the handler at 0008h; RST 2 enters the handler at 0010h. Before enabling interrupts with EI, initialize a stack in writable RAM and install handlers at both vectors. A handler must preserve the registers it changes and return with RET; use EI before returning to allow subsequent interrupts.
The arcade ROMs already supply these handlers. For your own handlers, use a separate computer configuration and remove the ROM images and write protection covering the vector addresses. A program that does not use interrupts can keep them disabled with DI; the display still refreshes.
Configuration file
You can also edit the existing [DEVICE.settings] section in SpaceInvaders.toml, then close and reopen the computer to apply changes made directly to the file.
[DEVICE.settings]
scale = 2
colorOverlay = true
soundEnabled = true
soundSamplesDirectory = "examples/space-invaders/sounds"
| Setting | Default | Description |
|---|---|---|
scale | 2 | Integer pixel scale, at least 1. At 2, the initial display area is 448 by 512 pixels. |
colorOverlay | true | Red and green bands over the monochrome image. Set to false for white pixels on black. |
soundEnabled | true in GUI, false headless | Enable playback of external sound samples. |
soundSamplesDirectory | examples/space-invaders/sounds | Directory containing the sound samples 0.wav through 9.wav. |
The display is already rotated into the upright arcade orientation. Sound effects use external WAV samples supplied by the user. Missing samples or an unavailable audio device leave emulation running with a warning in the log.