188444f9879122263a575b161295cb6d784b13bd
Some checks failed
CI / rust (push) Has been cancelled
- Add ExRAM (modes 0-1) and fill-mode nametable routing via read_nametable_byte / write_nametable_byte mapper hooks - Separate sprite and BG CHR bank sets ($5120-$5127 vs $5128-$512B); BG banks are only active in 8x16 sprite mode - Use mapper.ppu_read_sprite() for sprite tile loads so they always use the sprite bank set regardless of PPU fetch phase - Replace CPU-cycle IRQ stub with scanline-based counter matching Mesen2 hardware behaviour: fire when counter == irq_scanline at dot 2 (start of scanline), irq_scanline=0 never fires - Add Mapper::notify_frame_start() called unconditionally at the PPU frame boundary; MMC5 uses it to hard-reset the scanline counter even when rendering is disabled (e.g. during room transitions), preventing stale counter values from shifting the CHR split by 8+ scanlines - Fix CHR bank calculation for modes 0-2: use << 3/2/1 shifts instead of & !7/3/1 masking to correctly convert bank numbers to 1KB indices - Correct $5204 read: bit 7 = IRQ pending (cleared on read), bit 6 = in-frame flag; IRQ line stays asserted until $5204 is read - Dispatch $4020-$5FFF CPU reads/writes to mapper cpu_read_low / cpu_write_low so MMC5 internal registers are accessible
nesemu
NES/Famicom emulation workspace in Rust.
The workspace is built around a reusable core library. It also contains optional adapter crates and a GTK4 desktop frontend for manual testing.
What Is Here
nesemu: core emulation librarynesemu-adapter-api: backend-agnostic adapter traitsnesemu-adapter-headless: null/headless adapter implementationsnesemu-desktop: GTK4 desktop frontend
What The Core Library Provides
- CPU, PPU, APU, bus, and cartridge mapper emulation
- iNES ROM parsing
- Save/load state support
- Host-facing runtime wrappers for frame execution and pacing
- Public API and behavior tests
Quick Start
Add the main crate as a dependency:
[dependencies]
nesemu = { path = "../nesemu" }
Enable optional adapter support if needed:
[dependencies]
nesemu = { path = "../nesemu", features = ["adapter-api", "adapter-headless"] }
Recommended import style:
use nesemu::prelude::*;
Minimal setup:
use nesemu::{Cpu6502, NativeBus, create_mapper, parse_rom};
let rom_bytes = std::fs::read("game.nes")?;
let rom = parse_rom(&rom_bytes)?;
let mapper = create_mapper(rom)?;
let mut bus = NativeBus::new(mapper);
let mut cpu = Cpu6502::default();
cpu.reset(&mut bus);
Higher-level runtime setup:
use nesemu::{FRAME_RGBA_BYTES, NesRuntime};
let rom_bytes = std::fs::read("game.nes")?;
let mut runtime = NesRuntime::from_rom_bytes(&rom_bytes)?;
runtime.run_until_frame_complete()?;
let mut rgba = vec![0; FRAME_RGBA_BYTES];
runtime.render_frame_rgba(&mut rgba)?;
Desktop Frontend
Run the GTK4 desktop frontend:
cargo run -p nesemu-desktop -- path/to/game.nes
Linux build requirements: GTK4 development packages and pkg-config (for example on Debian/Ubuntu: libgtk-4-dev pkg-config).
Controls:
Esc: quitP: pause/resumeOpen ROM: load.nesfile- Arrow keys: D-pad
X: AZ: BEnter: StartLeft Shift/Right Shift: Select
Development
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
cargo test --all-features
Documentation Map
- API Contract: supported external surface and stability expectations
- Integration Guide: how to embed the library into a host or frontend
- Architecture: internal module layout and layering
Description
Languages
Rust
100%