NES emulator kind of working

It's still very rough in places, but my NES emulator is now functional enough to play some games. GitHub - default-kramer/nes-emu

Choose the ROM you want to play by editing the rom-path in main.rkt, and then run raco make main.rkt && racket main.rkt. Only some games (Mapper 0) are supported. If you get an error right away before emulation begins, it is probably some kind of game-not-supported error. But if emulation starts and then something goes wrong, please let me know via a bug report.

So far it is pure Racket; no FFI nor any extra libraries. The emulator runs in a separate place and sticks each video frame into some shared-bytes. The UI thread uses argb-pixels->pict on those shared-bytes, and then draw-pict to display the pict on the canvas drawing context. This can do 60FPS no problem, and can do over 120FPS on my laptop (depending on how many sprites are active). I did not expect pict to be that fast!

Future work includes:

  • Cleaning up the code
  • Supporting more games
  • Adding sound (and maybe a Bithoven plugin??)
8 Likes

Great project!

In case anyone is wondering about the slang "Mapper 0" the explanation is that is short for "Memory mapper zero".

Games for the NES console were distributed as cartridges containing rom image and in some cases other chips. The memory map determines how an address is translated into a physical location. Since this is done in hardware enthusiasts have made lists of the various memory mappers used by different games. A very common one is "Mapper 0" (also known as NROM).

The list of games using Mapper 0 is here:

https://nesdir.github.io/mapper0.html

In short, if you want to try Kramer's emulator, make sure to pick a game from the above list.

3 Likes