NES emulator! 🎉
A highly accurate NES emulator and NSF music player written in Rust.
The project is split into two crates:
- nes-emulator; provides the core that deals with the logic of emulating a NES system without any I/O capabilities
- nes-emulator-ui; acts as a frontend that can be used either as:
- A headless command line tool for running tests or benchmarks
- A graphical UI with a suite of interactive debugging tools, based on
Egui
.
- Cycle accurate CPU (including all dummy reads/write cycles for instructions that may have side effects)
- Interrupt handling works in terms of the raising and lowering edge of each clock cycle
- Unofficial opcodes
- RST line handling, for DMAs
- Cycle-accurate DMA handling, including combined DMC + OAM DMAs - SOME BUGS STILL
- Cycle accurate (including all sprite evaluation)
- 8x16 Sprites
- Emulates all redundant reads that can have side effects for cartridges
- Emulates Sprite 0 hit bug
- Monochrome
- Color Emphasis
- Shared t,v,fine-x internal register state affecting scrolling and PPU data reads
- I/O latch decay
- Skipped dot for odd frames
- Mirroring Modes
- Single Screen A
- Single Screen B
- Horizontal
- Vertical
- Four-screen
- 2x Pulse channels
- Triangle channel
- Noise channel
- DMC channel
- $4017 register write delay
- NTSC (2C02)
- PAL (2C07) INCOMPLETE
- Dendy (UA6538)
- PPU and CPU emulation in lockstep with cycle accuracy. The CPU clock is the main clock and everything makes progress each read/write cycle for the CPU.
- Game Genie Codes
- Clocking Modes:
- Real-time (emulation progresses according the passing of real (wall clock) time
- Greedy (emulation progresses as fast as possible - useful for running tests)
- iNES 000: NROM
- iNES 001: MMC1 / SxROM
- iNES 002: UxROM
- iNES 003: CNROM
- iNES 004: MMC3, MMC6 / TxROM
- iNES 007: AxROM
- iNES 031: NSF Player
- iNES 066: GxROM
- CPU Breakpoints (read or write, optionally ignoring dummy I/O cycles)
- Stack Unwinding
- CPU Tracing - comparable with Mesen trace logs
- General Tracing - Ability to record detailed traces of different hardware events that can be visualized in real-time
- Watch Points
- PPU Breakpoints (based on frame, line and dot counts)
- Hook into PPU MUX (background + sprite composition) for debugging
- Optional transistor-level PPU simulator can be run in parallel with the emulated PPU
- iNES
- iNES 2
- NSF
nes-emulator-ui 0.1.0
USAGE:
nes_emulator.exe [OPTIONS] [ROM]
ARGS:
<ROM>
OPTIONS:
-d, --rom-dir <ROM_DIR> Add a directory to find macro roms that are specified with a
relative path
-g, --genie <GENIE_CODES> Game Genie Code
-h, --help Print help information
-m, --macros <MACROS> Load the macros in the given library
-p, --play <PLAY_MACROS> Play a single macro or "all" to execute all loaded macros
-q, --headless Disables any IO and all synchronization (i.e. emulates frames as
quickly as possible; good for benchmarking and running tests)
-r, --relative-time Step emulator by relative time intervals, not necessarily
keeping up with real time
--results <RESULTS_JSON> Write the results of running macros to the given file in JSON
format
-t, --trace <TRACE> Record a trace of CPU instructions executed
-V, --version Print version information
Key | Action |
---|---|
Esc | Pause/Resume |
Ctrl-R | Reset |
Ctrl-T | Power Cycle |
Enter | Start |
Space | Select |
W | Up |
A | Left |
S | Down |
D | Right |
Left | A |
Right | B |
- https://www.nesdev.com
- http://www.ffd2.com/fridge/docs/6502-NMOS.extra.opcodes (seems more reliable than undocumented_opcodes.txt)
- https://www.nesdev.com/undocumented_opcodes.txt
- https://github.com/christopherpow/nes-test-roms
- https://github.com/kamiyaowl/rust-nes-emulator-embedded (I originally forked this project for the initial CPU implementation)
- https://github.com/bokuweb/rustynes
- https://github.com/starrhorne/nes-rust