Code Monkey home page Code Monkey logo

nimes's Introduction

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:

nimes's People

Contributors

def- avatar dloss avatar hcorion avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.