Here lies an NES emulator I wrote to learn about emulation and generally sharpen my understanding of the C language. Don't let this fool you though. It is a pretty decent emulator with full 6502 instruction set (official, unofficial and most illegal opcodes) to say the least. It is also an impressive NSF player.
Below shows the features that have been implemented. This is obviously subject to change as I will continue to implement features where I can over time. Any help is welcome.
- CPU (6502)
- Official opcodes
- Unofficial opcodes
- Cycle accuracy (official & unofficial)
- Dummy reads/writes
- BCD arithmetic (Not needed by NES anyway)
- Memory
- Battery backed (persistent) save RAM
- Open-bus
- PPU (Picture Processing Unit)
- Open-bus
- NTSC
- PAL
- Dendy
- APU (Audio Processing Unit)
- Pulse channel
- Triangle channel
- Noise channel
- Delta Modulation Channel
- Gaming input
- Keyboard input
- Keyboard (multiplayer)
- Original NES controller
- Gamepad controller (Multiplayer)
- Turbo keys
- Custom Touch controller (Android)
- Formats
- iNES
- NES2.0
- NSF
- NSFe
- NSF2
- UNIF
- FDS
- IPS
- Mappers
- #0 NROM
- #1 MMC1
- #2 UxROM
- #3 CNROM
- #4 MMC3
- #5 MMC5
- #7 AxROM
- #11 Color Dreams
- #66 GNROM
- Game genie (for cheat codes)
I haven't really taken time to do a survey but based on mappers implemented we can put the estimate at 90% of NES games. This is assuming none of them are using a quirk that I haven't gotten round to implementing. Games using mid-scanline trickery may not work as expected unless I find time to iron out timing issues in the PPU. Below are a few demos:
Contra
Metal gear
Legend of Zelda
1943: Battle of Midway
NSF Player: Ninja Gaiden
NSFe Player: Castlevania 3
Android: Ninja Gaiden
Xbox and Playstation controllers have not been tested on the emulator and are not guaranteed to work as shown here.
Key | Keyboard | Playstation | Xbox |
---|---|---|---|
Start | Enter | Start | Menu |
Select | Shift | Select | View |
A | J | ▢ | X |
B | K | ◯ | B |
Turbo A | H | △ | Y |
Turbo B | B | X | A |
up | Up | D-pad/stick Up | D-pad/stick Up |
down | Down | D-pad/stick Down | D-pad/stick Down |
left | Left | D-pad/stick Left | D-pad/stick Left |
right | Right | D-pad/stick Right | D-pad/stick Right |
Compiling the emulator requires:
- a C11 (or higher) compiler e.g. gcc
- cmake
- make (linux), msvc nmake (windows)
Assuming have the above requirements installed on your system, Acquire and build the source as follows:
$ git clone --recurse-submodules https://github.com/obaraemmanuel/NES
$ cd NES
$ mkdir build
$ cmake . -B build
$ cd build
$ make
You can now run the built emulator
$ ./nes ~/nes/roms/Contra.nes
To run with Game Genie enabled provide path to the original game genie ROM as an extra argument
$ ./nes ~/nes/roms/Contra.nes ~/nes/roms/game_genie.nes