Skip to content

39bytes/nes.rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nes.rs

An emulator for the Nintendo Entertainment System written in Rust, with SDL2 and web frontends.



emu.mp4

This isn't meant to be a full-featured or 100% accurate emulator, but rather a fun educational project. It still aims to be fairly accurate, emulating some hardware quirks such as unofficial CPU opcodes.

Running (SDL2)

Ensure that you have cargo installed.

cargo build --release
cd target/release
./nesrs <path-to-rom>

Controls are bound to:

  • Z: B
  • X: A
  • A: Select
  • S: Start
  • Arrow keys: Up/Down/Left/Right

Meta controls (Not controller inputs):

  • Space: Pause/unpause emulation
  • [: Decrease volume
  • ]: Increase volume
  • 1-5: Load save state [1-5]
  • Shift+[1-5]: Write save state to slot [1-5]

Running the WASM frontend locally

Ensure that you have wasm-pack, Node and pnpm installed. First, build the wasm crate:

cd emu-wasm
wasm-pack build

Then just spin up the frontend:

cd web
pnpm i
pnpm dev

Testing

cargo test

This will run test ROMs for the CPU emulation.

Passing tests

  • nestest (kevtris)
  • instr_test-v5 (blargg)

Compatability

iNES Mappers 0, 1, 2, 3, 4 and 9 are supported. Any game that uses a different mapper will not work for now. To find out which mapper a game uses, search it on NesCartDB.

TODO

Emulation

  • Accurate audio emulation
    • Implement DMC channel for APU
    • Investigate issues with envelope/sweep unit
    • Fix issues with buffer underrun/overrun and reduce audio latency
  • Investigate performance issues
  • Implement more mappers
    • Mapper 4 (MMC3)
    • Mapper 5 (MMC5)
    • Mapper 7 (AxROM)
    • Mapper 9 (MMC2)
    • Mapper 10 (MMC4)
    • Mapper 66 (GxROM)
  • Run test ROMs for PPU emulation

QOL

  • Save states
  • Remappable controls

Resources

About

A NES emulator written in Rust 🎮🦀

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published