Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

nimes

NimES: NES Emulator in Nim

Subscribe to updates I use nimes


Statistics on nimes

Number of watchers on Github 195
Number of open issues 0
Average time to close an issue about 1 hour
Main language Nimrod
Average time to merge a PR less than a minute
Open pull requests 1+
Closed pull requests 0+
Last commit almost 3 years ago
Repo Created almost 5 years ago
Repo Last Updated about 2 years ago
Size 1.44 MB
Organization / Authordef-
Contributors2
Page Updated
Do you use nimes? Leave a review!
View nimes activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating nimes for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

NimES: NES emulator in Nim Build Status

This is a NES emulator written in the Nim programming language. I made it mainly for fun and demonstration purposes. Nim can be used to write elegant and performant code and have it run almost anywhere, including Android and JavaScript. You can build the emulator natively (should work on Linux, Mac OS X, Windows and other platforms supporting SDL2), build it to Android or use the JavaScript version that is compiled from the same source code with the help of emscripten.

Live Demo

smb pacman tetris smb3

Building

You need Nim 0.11 or devel and the SDL2 development libraries (Windows, Mac OS X download) installed on your system:

apt-get install libsdl2-dev # Ubuntu/Debian (wheezy-backports for Debian 7)
brew install sdl2           # Mac OS X with homebrew
yum install SDL2-devel      # Fedora/CentOS
pacman -S sdl2              # Arch Linux
emerge libsdl2              # Gentoo

With nimble installed you can then install NimES:

nimble install nimes

There are a few possibilities to build NimES if you got the source already:

nimble install # installs nimes into ~/.nimble/bin OR
nimble build   # builds the binary in src/nimes OR
nim -d:release c src/nimes # same without nimble

$ nimes
Usage: nimes <rom.nes>

If you don't want to use nimble, you'll have to get Nim's SDL2 wrapper manually.

You can also use nake for building:

$ nake
Available tasks:
desktop - Builds NimES for Desktop
web - Builds NimES for the Web
android - Builds NimES for Android
clean - Removes build files

Building with Emscripten

Building to JavaScript is a bit more complicated. You need the Emscripten SDK installed.

nim -d:release -d:emscripten c src/nimes

You need the files tetris.nes, pacman.nes, smb.nes, smb3.nes available for this.

Building for Android

You need the Android SDK (12 or later) and NDK (7 or later) installed. So far NimES on Android only opens a predefined smb3.nes and controls don't even work. This is mainly to demonstrate that it could easily be ported to Android.

nim -d:release -d:android c src/nimes
cd android
ndk-build
ant debug

The resulting apk is in bin/org.nimes-debug.apk. You can try this nimes.apk. Some work will be necessary to improve the performance of the program as well as implement Android controls.

Porting to Android was pretty simple by following this guide.

Controls

Key Action
Z/Y A
X B
Enter Start
Space Select
1-5 Zoom 1-5
R Reset
P Pause
M Mute
F 250% speed while pressed
F9 Reset speed
F10 Speed - 5%
F11 Speed + 5%

TODO / What's missing

  • Loading screen to select games (also in emscripten)
  • Second player
  • Settings for controls/gamepad/joystick
  • Saving
  • Android
  • Performance could be improved significantly by making PPU render by scanline, not by pixel
  • More mappers (0,1,2,3,4,7 working, NES mapper list)
  • PAL video (NTSC only currently)

Source code information

The NES emulation code largely follows fogleman's excellent NES emulator in Go as well as these info materials and some other emulators:

  • http://www.obelisk.demon.co.uk/6502/
  • http://nesdev.com/
nimes open pull requests (View All Pulls)
  • Fix compilation with nim version 0.15.0
nimes list of languages used
  • Nim
Other projects in Nimrod