Code Monkey home page Code Monkey logo

hnes's Introduction

hnes

Build Status

Welcome to hnes. hnes is a NES emulator written in Haskell.

Screenshots

Mapper support

The following mappers are supported:

  • NROM (0)
  • UNROM (2)
  • AOROM (7)

Lots of games run, but more don't. You can see which roms are compatible here: http://tuxnes.sourceforge.net/nesmapper.txt The best games seem to be MMC3, so that is a priority.

Mappers are basically custom memory modules that exist on the cartridges themselves, that allow referencing more memory than the NES originally shipped with. Sometimes they even do computation. A very clever idea, but a nightmare to emulate, since each mapper has to be emulated as well

Controls

Nintendo Emulator
Up, Down, Left, Right Arrow Keys
Start Enter
Select Space
A Z
B X

Building

Get Stack for building Haskell projects.

Windows instructions:

$ stack exec -- pacman -Sy mingw-w64-x86_64-pkg-config mingw-w64-x86_64-SDL2
$ stack build

OS X instructions:

$ brew install sdl2
$ stack build

Ubuntu Linux instructions:

$ sudo apt-get install libsdl2-dev
$ stack build

FreeBSD instructions:

$ pkg install sdl2
$ stack build

Running

To run:

stack exec -- hnes roms/tests/cpu/nestest/nestest.nes

Task list

  • Basic structure
  • Mappers
    • Loading roms
    • Mappers
      • UNROM
      • NROM
      • AOROM
      • CNROM
      • MMC1
      • MMC3
  • CPU
    • All official opcodes
    • All illegal opcodes
    • Nestest passing
    • Blarggs CPU test roms passing
  • PPU
    • SDL integration
    • Background rendering
    • Scrolling
    • Sprite rendering
    • VBlank timing for Battletoads edge case
  • APU
  • Controller input handled
  • Performance tuning
  • Command line interface
    • Parse args
    • Use optparse-applicative
    • Some debug params?

Tests

There's a small test suite that is used to check for CPU and PPU accuracy. They use test roms rather than hand coding tests.

Just run stack test:

Known issues.

There are so many, where do I even begin.

  • Performance is pretty average still. I get around 80 fps on my 2015 i5 MacBook.
  • VBlank timing is off. I don't know the exact reasons, but it causes scrolling issues.

hnes's People

Contributors

chrisdone avatar dbousamra avatar ivandsm avatar jonathanjameswatson avatar rezbyte avatar ron-wolf avatar tyfkda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hnes's Issues

Error compilation WINDOWS 10

Hello I tried to run your emulator on my windows 10 computer

I have an error during the stack build (the old commands were successful)

> stack build
sdl2-2.3.0: configure
sdl2-2.3.0: build
Progress 1/2

--  While building package sdl2-2.3.0 using:
      C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_2.0.0.2_ghc-8.2.1.exe --builddir=.stack-work\dist\e53504d9 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
    Logs have been written to: C:\Users\CleaverCode\Desktop\hnes\.stack-work\logs\sdl2-2.3.0.log

    Configuring sdl2-2.3.0...
    Preprocessing library for sdl2-2.3.0..
    In file included from C:/Users/CleaverCode/AppData/Local/Programs/stack/x86_64-windows/msys2-20180531/mingw64/include/SDL2/SDL.h:32:0,
                     from Enum.hsc:910:
    C:/Users/CleaverCode/AppData/Local/Programs/stack/x86_64-windows/msys2-20180531/mingw64/include/SDL2/SDL_main.h:111:17: error: conflicting types for 'SDL_main'
     #define main    SDL_main
                     ^
    C:\Users\CleaverCode\AppData\Local\Temp\stack6704\sdl2-2.3.0\Enum.hsc:912:5: note: in expansion of macro 'main'
    C:/Users/CleaverCode/AppData/Local/Programs/stack/x86_64-windows/msys2-20180531/mingw64/include/SDL2/SDL_main.h:117:39: note: previous declaration of 'SDL_main' was here
     extern C_LINKAGE SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]);
                                           ^~~~~~~~
    compiling .stack-work\dist\e53504d9\build\SDL\Raw\Enum_hsc_make.c failed (exit code

Performance

Hey, Any luck with the performance issues?
I see you're using -O2 which is good, but I'm guessing -XStrict hadd little effect?
I think the use of ST is probably good. Using mutable unboxed vectors is probably the fastest choice of data structure unless perhaps you plan on reversing time in your emulator, or exploring different branches of emulation. It's hard to see whats really causing the issue. Maybe use a better tool for visualizing the profiling info, e.g. https://github.com/maoe/tkyprof.

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.