Skip to content

def-/nimes

Repository files navigation

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.

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:

About

NimES: NES Emulator in Nim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages