#nes #nintendo #emulator

app plastic

An accurate NES emulator. Front-end for plastic-core

2 releases

0.3.1 Oct 19, 2024
0.3.0 Oct 19, 2024

#8 in Emulators

Download history 241/week @ 2024-10-14 123/week @ 2024-10-21

364 downloads per month

MIT license

370KB
8K SLoC

plastic

NES emulator in Rust

Build status codecov dependency status license
Crates.io Version docs.rs
Crates.io Version Crates.io Version

plastic is a NES emulator built from scratch using Rust.

This is a personal project for fun and to experience emulating hardware and connecting them together.

Building and installation

Pre-built

There are pre-built binaries in the releases tab, Plastic comes in different UIs, one which is the most used normal UI built with egui and another one which is a terminal UI (TUI) built with ratatui. check Interfaces for more details.

Building

If you want to experience the latest development version, you can build Plastic yourself. For example:

cargo run --release

Components

  • 6502 CPU, all official and unofficial instructions with accurate timing (without BCD mode).
  • Picture Processing Unit, almost accurate with some small timing issues that would not effect most games.
  • Cartridge and INES file handling (still missing INES2.0)
  • Mappers:
    • Mapper 0
    • Mapper 1
    • Mapper 2
    • Mapper 3
    • Mapper 4
    • Mapper 5 (Milestone)
    • Mapper 6
    • Mapper 7
    • Mapper 8
    • Mapper 9
    • Mapper 10
    • Mapper 11
    • Mapper 66
  • Audio Processing Unit:
    • 2 Pulse wave(square)
    • Triangle
    • Noise
    • DMC
    • IRQ support
  • Controller: controllable using the keyboard and controller (tested with PS4 controller)

Interfaces

The main emulator is at plastic_core And its a struct NES, where the UI would clock it, and then take the resulting audio and pixel buffers to handle them.

We have 2 UIs, one main and the other just for fun.

EGui UI

Simple ui built with egui

Advantages
  1. Very simple and easy to use immediate mode UI.

TUI

TUI demo

This is just for fun, but it is actually working way better than I expected. Check the demo.

If you have one of these terminals mentioned in this docs Then you will have a much better experience, since these terminals support detecting button Release, normally other terminals don't have this feature, so the input for this UI can be a bit wonky.

I used gilrs for gamepad support and its working very nicely, keyboard on the other hand is not very responsive, so it is advised to use gamepad. Also since this uses one character for each pixel, it is advised to use the smallest font size your terminal emulator supports. Have fun.

Controls

In all the UI providers I followed the same controlling scheme, as well as the ability to reset through <CTRL-R>:

Keyboard

keyboard nes controller
J B
K A
U Select
I Start
W Up
S Down
A Left
D Right

Gamepad

gamepad (PS4) nes controller
X B
O A
Select Select
Start Start
Button Up Up
Button Down Down
Button Left Left
Button Right Right

For now its static, and there is no way to change it except for doing it in the code, TODO later.

License

This project is under MIT license.

NES is a product and/or trademark of Nintendo Co., Ltd. Nintendo Co., Ltd. and is not affiliated in any way with Plastic or its author

References

Most of the documentation for NES components can be found in the NES dev wiki

For the CPU(6502), this has the instruction set, and I used Klaus2m5's tests for testing the CPU alone without the other NES components.

Dependencies

~14–52MB
~895K SLoC