MCPcopy
hub / github.com/fogleman/nes

github.com/fogleman/nes @main sqlite

repository ↗ · DeepWiki ↗
420 symbols 863 edges 28 files 110 documented · 26%
README

Summary

This is an NES emulator written in Go.

Screenshots

Screenshots

Title Screens

http://www.michaelfogleman.com/static/nes/

Dependencies

github.com/go-gl/gl/v2.1/gl
github.com/go-gl/glfw/v3.1/glfw
github.com/gordonklaus/portaudio

The portaudio-go dependency requires PortAudio on your system:

To build portaudio-go, you must first have the PortAudio development headers and libraries installed. Some systems provide a package for this; e.g., on Ubuntu you would want to run apt-get install portaudio19-dev. On other systems you might have to install from source.

On Mac, you can use homebrew:

brew install portaudio

Installation

The go get command will automatically fetch the dependencies listed above, compile the binary and place it in your $GOPATH/bin directory.

go get github.com/fogleman/nes

Usage

nes [rom_file|rom_directory]
  1. If no arguments are specified, the program will look for rom files in the current working directory.

  2. If a directory is specified, the program will look for rom files in that directory.

  3. If a file is specified, the program will run that rom.

For 1 & 2, the program will display a menu screen to select which rom to play. The thumbnails are downloaded from an online database keyed by the md5 sum of the rom file.

Menu Screenshot

Controls

Joysticks are supported, although the button mapping is currently hard-coded. Keyboard controls are indicated below.

Nintendo Emulator
Up, Down, Left, Right Arrow Keys
Start Enter
Select Right Shift
A Z
B X
A (Turbo) A
B (Turbo) S
Reset R

Mappers

The following mappers have been implemented:

  • NROM (0)
  • MMC1 (1)
  • UNROM (2)
  • CNROM (3)
  • MMC3 (4)
  • AOROM (7)

These mappers cover about 85% of all NES games. I hope to implement more mappers soon. To see what games should work, consult this list:

NES Mapper List

Known Issues

  • there are some minor issues with PPU timing, but most games work OK anyway
  • the APU emulation isn't quite perfect, but not far off

Documentation

Interested in writing your own emulator? Curious about the NES internals? Here are some good resources:

Extension points exported contracts — how you extend this code

Filter (Interface)
(no doc) [13 implementers]
nes/filter.go
Mapper (Interface)
(no doc) [7 implementers]
nes/mapper.go
Memory (Interface)
(no doc) [10 implementers]
nes/memory.go
View (Interface)
(no doc) [2 implementers]
ui/director.go

Core symbols most depended-on inside this repo

Read
called by 46
nes/mapper.go
setZN
called by 29
nes/cpu.go
chrBankOffset
called by 16
nes/mapper4.go
prgBankOffset
called by 12
nes/mapper4.go
Write
called by 12
nes/mapper.go
readKey
called by 11
ui/util.go
Save
called by 10
nes/mapper.go
Load
called by 10
nes/mapper.go

Shape

Method 323
Function 65
Struct 27
Interface 4
TypeAlias 1

Languages

Go100%

Modules by API surface

nes/cpu.go102 symbols
nes/apu.go64 symbols
nes/ppu.go40 symbols
ui/util.go21 symbols
nes/mapper4.go20 symbols
nes/mapper1.go16 symbols
nes/console.go16 symbols
ui/menuview.go15 symbols
ui/director.go13 symbols
ui/texture.go12 symbols
nes/memory.go12 symbols
ui/gameview.go10 symbols

Dependencies from manifests, versioned

github.com/go-gl/glv0.0.0-2019032018090 · 1×
github.com/go-gl/glfwv0.0.0-2020042021221 · 1×
github.com/gordonklaus/portaudiov0.0.0-2018081712080 · 1×

For agents

$ claude mcp add nes \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact