Repository navigation
Architecture Overview
Read next: the README's architecture section, ARCHITECTURE.md and docs/architecture.md. Parts of docs/architecture.md are kept as marked historical text (the pre-v2.0.0 scheduling model, an older crate list); where it says so, the subsystem documents are the current reference.
RustyNES is a Cargo workspace of focused crates. Three decisions carry the design.
A single cycle counter drives the CPU, PPU and APU at the region-exact ratios (3:1 on NTSC and Dendy, 3.2:1 on PAL). Each CPU cycle is clocked in two halves with the PPU caught up to each, so events inside an instruction are visible to the next bus access. See Scheduler.
SystemBus (named LockstepBus until v2.9.8) holds the PPU, APU, cartridge, work RAM and controllers, and the CPU borrows it one instruction at a time. This avoids the ownership cycle of the alternative, where the CPU holds the PPU but the PPU also needs the CPU bus.
The chip crates are #![no_std] with alloc, and the CPU, PPU and APU crates do not depend on one another. The mapper crate depends on the APU crate only for the VRC7 FM synthesizer, and rustynes-core ties the chips together and re-exports their public types, so downstream code depends on rustynes-core. Each chip can therefore be fuzzed and benchmarked on its own. Mapper IRQ logic lives in the mapper: the PPU reports A12 transitions and scanline events, and CPU-cycle counters tick on a per-cycle hook (Mapper-Ecosystem).
| Crate | Role |
|---|---|
rustynes-cpu, rustynes-ppu, rustynes-apu
|
The 6502, the 2C02 and the 2A03 audio unit |
rustynes-mappers |
The cartridge, the mapper trait and the mapper families, expansion audio, the UNIF loader |
rustynes-core |
The bus, scheduler, console (Nes) and save states |
rustynes-frontend |
The desktop and browser application (binary rustynes) |
rustynes-netplay |
Rollback netplay over UDP and WebRTC |
rustynes-script |
Sandboxed Lua 5.4 |
rustynes-cheevos, rustynes-ra
|
RetroAchievements |
rustynes-hdpack, rustynes-gfx-shaders
|
HD packs and the shared WGSL shaders |
rustynes-gamedb |
The per-game header-correction database |
rustynes-mobile, rustynes-android, rustynes-ios
|
The mobile bridge and platform glue |
rustynes-libretro |
The RetroArch core |
rustynes-cosim |
RustyNES as a co-simulation oracle for an external HDL design |
rustynes-probe |
A deterministic re-simulation and divergence probe |
rustynes-test-harness |
Integration tests and the accuracy oracles |
The crates/ directory is the current list.
The same seed, ROM and input sequence give a bit-identical framebuffer and audio. The CPU/PPU power-on alignment comes from a seeded generator, and reset preserves it. Anything non-deterministic (wall-clock pacing, audio rate control, run-ahead orchestration) lives in the frontend, not the core. Since v3.0.0 a change that alters any frame, sample or bus cycle relative to the last release raises an emulation epoch that movies and netplay check (ADR 0045).
CPU-2A03, PPU-2C02, APU-Mixer, Mapper-Ecosystem, Frontend-Architecture.
RustyNES is a cycle-accurate NES emulator written in Rust, licensed GPL-3.0-or-later. It is a derivative work of GPL-licensed emulators; see provenance and NOTICE. This wiki is a summary; the repository's docs/ are authoritative. | GitHub Repository | Web Demo