Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/im-rises/space_invaders_arcade_emulator
Space Invaders Arcade game emulator made in Rust 🦀
https://github.com/im-rises/space_invaders_arcade_emulator
arcade-game emulator game rust space-invaders video-game
Last synced: 2 months ago
JSON representation
Space Invaders Arcade game emulator made in Rust 🦀
- Host: GitHub
- URL: https://github.com/im-rises/space_invaders_arcade_emulator
- Owner: Im-Rises
- License: mit
- Created: 2022-04-29T22:32:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-06T21:56:54.000Z (over 1 year ago)
- Last Synced: 2024-04-15T01:19:01.159Z (8 months ago)
- Topics: arcade-game, emulator, game, rust, space-invaders, video-game
- Language: Rust
- Homepage: https://im-rises.github.io/space-invaders-arcade-emulator-website/
- Size: 32.8 MB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# space_invaders_arcade_emulator
## Description
Space Invaders arcade game emulator made in Rust with SDL2 and SDL2_mixer.
Complete Emulator of the Intel 8080, the app is implemented to run the Space Invaders Arcade game.
Everything is working including the Space Invaders Easter Egg.
You can also play it in the browser, I ported the code to WebGL, you can find the
code [here](https://github.com/Im-Rises/space-invaders-arcade-emulator-website).# 🚀🚀 Play in the browser [here](https://im-rises.github.io/space-invaders-arcade-emulator-website/). 🚀🚀
## Features
- Full emulation
- Sound
- Two-players mode
- Window resizing without deformation## Images
| Title screen | Game screen |
|------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------|
| ![title_screen](https://user-images.githubusercontent.com/59691442/181736212-8d8cfa4e-4c85-48ce-92ac-1165dcb73891.png) | ![playing_demo](https://user-images.githubusercontent.com/59691442/181736224-da769503-2a2e-45d6-af2c-9204a96e78e1.png) || Taito Cop Easter Egg | Score advance table with Invaders |
|--------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------|
| ![taito_cop_easter_egg](https://user-images.githubusercontent.com/59691442/183047666-97f9711c-e2a4-4659-86df-410db5562450.png) | ![score_advance_table](https://user-images.githubusercontent.com/59691442/183058044-b5d532d6-bad2-4629-a55c-f669c82a5e29.png) |## Videos
https://user-images.githubusercontent.com/59691442/183045566-0a3df947-06e7-4c46-9fc6-9d2b8f7d9a46.mp4
## Quick start
To download the emulator, you can click one of the icons below depending on your operating system, or you can click the
release section of the GitHub page.For each version when you unzip the downloaded release, you will get the executable and two folder, one
named `game_roms` where you must put the game's roms:- invaders.h
- invaders.g
- invaders.e
- invaders.fDepending on you `operating system` you will need to install some libs, they are installed differently depending on your
system, please follow one of the section below `Windows` or `Linux` or `MacOs`.### Windows
For Windows users you don't need to install the libs, you just need to be carefully that you have the `SDL2.dll`
and `SDL2_mixer.dll` next to the `space_invaders_arcade_emulator.exe` or the emulator won't start.Once everything is set up by you can start the emulator by double-clicking the executable of typing the following
command next to it:```bash
.\space_invaders_arcade_emulator.exe
```### Linux
For Linux users, you need to install the SDL2 lib, to do so type one of the following commands:
```bash
sudo apt-get install libsdl2-2.0-0 libsdl2-mixer-2.0-0
```or if you're a developer and want to compile the Emulator, please install this version of SDL2:
```bash
sudo apt-get install libsdl2-dev libsdl2-mixer-dev
```Then you can start by double-clicking the executable of typing the following command next to it:
```bash
./space_invaders_arcade_emulator
```### MacOs
For macOS users you will need to install Brew, please follow the instruction in the link below:
Once it is installed, you can type the following command to install SDL2.
```bash
brew install sdl2
brew install sdl2_mixer
```You also need to add `SDL2` to the paths by typing:
```bash
export LIBRARY_PATH="$LIBRARY_PATH:$(brew --prefix)/lib"
```Then you can start by double-clicking the executable of typing the following command next to it:
```bash
./space_invaders_arcade_emulator
```## Controls
You can use the keyboard to play the game.
| Arcade buttons | Emulator/Keyboard |
|----------------|-------------------|
| Insert coin | C |
| Shoot | ↑ |
| ← | ← |
| → | → |
| Start 1 | 1 |
| Start 2 | 2 |The original game is mapped with some inputs that allow the constructor to choose the difficulty. I Mapped those inputs
to the keyboard. This allows you to increase the numer of lives and change the extra ship necessity points.Before pressing start with player 1 or 2, you can choose the number of life you want to have for a game party.
| Emulator/Keyboard | Emulator buttons |
|-------------------|--------------------------------------------------|
| O | Show additional info in demo |
| K | 1 more life |
| L | 2 more lives |
| M | extra ship at 1000 points instead of 1500 points |> **Note**
> If you don't keep pressed K or L before pressing start and starting a new game you will have 3 lives.
> In the same way, you can enable the extra ship to came at 1000 points instead of 1500, but you just need to press
> the button one time (a confirmation will be displayed in the console).## Code architecture
The Emulator is divided into 4 parts:
- main (starter)
- si_arcade (console emulation)
- my_sdl2 (video, audio and inputs si_arcade interpreter)
- binary_lib (a set of binary functions to manipulate data)The sound is implemented using `.wav` files, they are loaded in the `si_aracade` part of the program and totally
interpreted in the `my_sdl2` part.## Compilation
First thing you need is to install cargo and rust. You can find them by following the instructions in the link below:
You also need to download the following audio files:
- 0.wav
- 1.wav
- 2.wav
- 3.wav
- 4.wav
- 5.wav
- 6.wav
- 7.wav
- 8.wavThe `wav` files wan be downloaded in the links below:
They all must be put in the `game_audios` folder.
> **Warning**
> Be carefully when downloading the .wav files, some files pay have the wrong name.Depending on your OS, you will need to follow specific steps to compile the app. Please refer to the sections
below `Windows`, `Linux` and `macOs`.### Windows
~~Windows users need to install SDL2 for your OS. The setup instruction can be followed in the link below:~~
I set up a static SDL2 Linking so Windows user just need to download the project and everything will be set up for SDL2.
I used the instructions in the link below to set up the dynamic linking:### Linux
Linux Users need to install the SDL2 libs (SDL2 and SDL2_mixer). To do so, type in your bash system the following
commands.If you want to compile the program, install the developer version with the command below:
```bash
sudo apt-get install libsdl2-dev libsdl2-mixer-dev
```### MacOs
For macOS users you will need to install Brew, please follow the instruction in the link below:
Once it is installed, you can type the following command to install SDL2.
```bash
brew install sdl2
brew install sdl2_mixer
```You also need to add `SDL2` to the paths by typing:
```bash
export LIBRARY_PATH="$LIBRARY_PATH:$(brew --prefix)/lib"
```---
With Rust and SDL2 libs installed, you can now compile the project in two-way, debug or release. To compile go to the
project root folder and type one of the two following commands below (If you want to use the emulator please compile
using the second command).```bash
cargo build
```or
```bash
cargo build --release
```The compiled app will be in the folder `target/debug` or `target/release` depending on the compilation you did.
## Rust tests
You can test the good behaviour of the project by typing the commands onf of the following command. It will start the
unit test of the CPU.It will start a test rom for the Intel 8080 CPU. You can find it in the link below:
```bash
cargo test
```or
```bash
cargo test --release
```Currently, the CPU is passing the following tests:
- [x] cpudiag.bin
- [x] TST8080.COM
- [x] 8080PRE.COM
- [x] CPUTEST.COM
- [x] 8080EXER.COM
- [x] 8080EXM.COMThe tests are named:
- cpu_test_rom_cpudiag
- cpu_test_rom_tst8080
- cpu_test_rom_8080pre
- cpu_test_rom_cputest
- cpu_test_rom_8080exer
- cpu_test_rom_8080exmYou can start them individuality by typing:
```bash
cargo test
```or
```bash
cargo test --release
```Example: If you want to start the cpu_test_rom_tst8080 test.
```bash
cargo test cpu_test_rom_tst8080
```or
```bash
cargo test cpu_test_rom_tst8080 --release
```To show the CPU test logs, you can use the `--show-output` flag.
```bash
cargo test --release -- --show-output
```You can also debug disassembly by uncommenting the two following lines in the `cpu.rs` file in the `test`
module.~~~
// let mut f = File::create("test_roms/my_output.log").expect("Cannot create debug log file");
~~~~~~
// write_debug_to_file(&mut cpu_debug, &mut f, cycles_counter);
~~~This will output the complete disassembly of the CPU in the `test_roms/my_output.log` file.
> **Note**
> Depending on the test the output is different. Refer to this project for more explanation about how they work.
> https://github.com/superzazu/8080
> http://www.emulator101.com/full-8080-emulation.html
>
> The last test (cpu_test_rom_8080exm) can take a lot of time in debug mode, you should test it in release mode, use the
> command below:
> ```bash
> cargo test cpu_test_rom_8080exm --release
> ```## GitHub Actions
[![Rust](https://github.com/Im-Rises/space_invaders_arcade_emulator/actions/workflows/rust.yml/badge.svg?branch=main)](https://github.com/Im-Rises/space_invaders_arcade_emulator/actions/workflows/rust.yml)
[![rust-clippy analyze](https://github.com/Im-Rises/space_invaders_arcade_emulator/actions/workflows/rust-clippy.yml/badge.svg?branch=main)](https://github.com/Im-Rises/space_invaders_arcade_emulator/actions/workflows/rust-clippy.yml)
[![rustfmt check](https://github.com/Im-Rises/space_invaders_arcade_emulator/actions/workflows/rustfmt.yml/badge.svg?branch=main)](https://github.com/Im-Rises/space_invaders_arcade_emulator/actions/workflows/rustfmt.yml)
[![rust-publish](https://github.com/Im-Rises/space_invaders_arcade_emulator/actions/workflows/rust-publish.yaml/badge.svg?branch=main)](https://github.com/Im-Rises/space_invaders_arcade_emulator/actions/workflows/rust-publish.yaml)The project is set with a set of different scripts:
- rust : Check the code compilation.
- rust-clippy analyze : Evaluate the code quality (error, warnings, etc...).
- rustfmt check : Check the code good formatting
- rust-publisher : Publish the app to releases when pushing to the main branch.## Documentation
emulator101:
Computer Archeology:
Emudev.de:
Rust:
SDL2 Rust:
SDL2 libs download:
rust-clippy:
rustfmt:
Intel 8080 documentations:
Intel 8080 opcodes table:
Wikipedia:
Test Roms for the Intel 8080:
Space Invaders Audio files:
## Contributors
Quentin MOREL :
- @Im-Rises
-[![GitHub contributors](https://contrib.rocks/image?repo=Im-Rises/GameBoyEmulator)](https://github.com/Im-Rises/GameBoyEmulator/graphs/contributors)