MCPcopy Index your code
hub / github.com/Comba92/nen-emulator

github.com/Comba92/nen-emulator @v1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0 ↗ · + Follow
667 symbols 1,694 edges 26 files 29 documented · 4%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Nen Emulator

NES emulator, written in Rust. High mappers compatibility, FDS support.

Download

Download is avaible in the releases section. An eframe frontend with egui is available, with a GUI and a lot of user functionality. A SDL2 and SDL3 frontend for the emulator is avaible, with very basic user functionality. A (WIP) WASM frontend is also avaible here: https://comba92.github.io/nen-emulator/frontend-wasm/index.html

Usage (eframe frontend)

Game ROMs can be loaded by dragging and dropping the files into the window, or by using the file dialog in the top bar.

[!TIP] Zip files are supported.

Controls

[!TIP] Both keyboards and controllers are supported. [!TIP] Controls can be changed in the keybids menu.

Keyboard Button
S A button
A B button
W Start
E Select
ArrowKeys You know what they do!
P Pause/unpause the emulator
R Reset current game
M Mute/unmute sound
0 Save state
9 Load state

Features

The emulator supports all the basic NES features you'd expect from a NES emulator. - [x] The 6502 CPU is emulated with most of its quirks. - [x] PPU pixel rendering emulation. Emulates the LoopyRegister behaviour and the pixel fethcer. - [x] The APU channels are all fully emulated. - [x] Both NTSC and PAL games are supported. - [x] The Famicon Disk System is supported. - [x] Custom color palettes are supported - [x] Games with tricky and obscure behaviour run correctly, except for one or two exceptions. - [x] RAM random initializing for games which uses it to seed RNG - [x] Saving/loading of battery RAM when the game is changed or the emulator is closed. - [x] Savestates - [x] Setting to disable the sprites limit for scanline.

Compatibility

  • iNes and NES2.0 headers are supported.
  • Headerless ROMs are supported thanks to a games database.
  • FDS disks roms for the Famicom Disk System are supported.
  • Zip files are supported.

Supported Mappers

The most popular

Other mappers

Building

Building requires, of course, Rust and it's development tools.

Three frontends are avaible. The eframe frontend is the default one. To build it:

cargo run -r
cargo run -r --features=persistence # enable savestates feature
cargo run -r --features=opengl # use opengl graphical backend for eframe

A SDL2 and a SDL3 frontends are also available. They are their own separate package, so the -p flag is needed. To build them:

cargo build -r -p nenemu_sdl2 # Dynamically linked with SDL2, no savestates feature
cargo build -r -p nenemu_sdl2 --features="static"  # Statically linked with SDL2

The WASM frontend is still WIP, but already avaible here: https://comba92.github.io/nen-emulator/frontend-wasm/index.html

Various resources (not updated)

This section contains some of the resources I've used during development. Sadly I didn't keep track of all of them. I did found a lot of interesting articles, blogs, and readings, but forgot to add them here.

  • https://www.nesdev.org/wiki
  • https://www.nesdev.org/NESDoc.pdf
  • https://www.copetti.org/writings/consoles/nes/

Design

  • https://gendev.spritesmind.net/forum/viewtopic.php?p=35653&sid=8395d8875e87653545c0905281b093a0#p35653
  • https://gist.github.com/adamveld12/d0398717145a2c8dedab
  • https://www.nesdev.org/wiki/Catch-up
  • https://www.reddit.com/r/EmuDev/comments/10m9had/cpu_ppu_timing_catch_up_method/

CPU

  • https://www.nesdev.org/6502.txt
  • https://www.nesdev.org/6502_cpu.txt
  • https://bugzmanov.github.io/nes_ebook/chapter_3.html
  • http://www.6502.org/users/obelisk/6502
  • https://www.pagetable.com/c64ref/6502
  • https://www.masswerk.at/6502/6502_instruction_set.html

Illegal Opcodes

  • https://www.nesdev.org/undocumented_opcodes.txt

Correct XAA

  • http://www.ffd2.com/fridge/docs/6502-NMOS.extra.opcodes
  • https://www.nesdev.org/the%20%27B%27%20flag%20&%20BRK%20instruction.txt

Memory

  • https://en.wikibooks.org/wiki/NES_Programming/Memory_Map
  • https://www.nesdev.org/wiki/CPU_memory_map
  • https://www.nesdev.org/wiki/PPU_memory_map
  • https://emudev.de/nes-emulator/cartridge-loading-pattern-tables-and-ppu-registers/

Ppu

  • https://bugzmanov.github.io/nes_ebook/chapter_6.html
  • https://austinmorlan.com/posts/nes_rendering_overview/
  • https://leeteng.com/blog/content/writing-nes-emulator
  • https://emudev.de/nes-emulator/palettes-attribute-tables-and-sprites/
  • https://www.youtube.com/watch?v=-THeUXqR3zY

Mappers

  • https://mapper.nes.science/
  • https://bumbershootsoft.wordpress.com/2022/10/22/nes-beyond-40kb/

APU

  • https://emudev.de/nes-emulator/charming-sound-the-apu/
  • https://www.slack.net/~ant/nes-emu/apu_ref.txt
  • https://nesmaker.nerdboard.nl/2022/03/25/the-apu/

Tests

  • https://www.nesdev.org/wiki/Emulator_tests
  • https://www.nesdev.org/wiki/Tricky-to-emulate_games
  • https://github.com/SingleStepTests/ProcessorTests/tree/main/nes6502
  • https://github.com/PyAndy/Py3NES/issues/1

Extension points exported contracts — how you extend this code

Mapper (Interface)
(no doc) [37 implementers]
nenemu_core/src/mapper.rs
BankCfg (Interface)
(no doc) [4 implementers]
nenemu_core/src/bus.rs

Core symbols most depended-on inside this repo

set_page
called by 167
nenemu_core/src/bus.rs
new
called by 165
nenemu_core/src/mapper.rs
set_button
called by 120
nenemu_core/src/lib.rs
len
called by 52
nenemu_core/src/rom.rs
into
called by 31
nenemu_core/src/emu.rs
set_zn
called by 29
nenemu_core/src/cpu.rs
get_op_val
called by 29
nenemu_core/src/cpu.rs
nop
called by 28
nenemu_core/src/cpu.rs

Shape

Method 471
Class 123
Function 48
Enum 23
Interface 2

Languages

Rust100%

Modules by API surface

nenemu_core/src/cpu.rs107 symbols
nenemu_eframe/src/main.rs59 symbols
nenemu_core/src/ppu.rs53 symbols
nenemu_core/src/ppu_old.rs52 symbols
nenemu_core/src/emu.rs46 symbols
nenemu_core/src/mapper.rs42 symbols
nenemu_core/src/lib.rs38 symbols
nenemu_core/src/bus.rs38 symbols
nenemu_core/src/apu.rs38 symbols
nenemu_core/src/mapper/fds.rs27 symbols
nenemu_core/src/mapper/konami.rs23 symbols
nenemu_core/tests/games_db.rs22 symbols

For agents

$ claude mcp add nen-emulator \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page