• Stars
    star
    314
  • Rank 133,353 (Top 3 %)
  • Language
    Go
  • License
    MIT License
  • Created over 1 year ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

NES/Famicom emulator with network multiplayer

Dendy

Dendy is a NES/Famicom emulator written in Go and named after the soviet Famicom bootleg. It serves no practical purpose other than to be a toy project for me, so do not expect it to beat any of the existing emulators in terms of performance or accuracy. Yet, it is capable of running most of the games I tried, so it’s not completely useless, and it's still a great learning experience.

Screenshots

Try it

$ go install github.com/maxpoletaev/dendy/cmd/dendy@latest
$ dendy romfile.nes

You may need to install additional dependencies required by raylib. See https://github.com/gen2brain/raylib-go#requirements for more details.

Controls

Joystick

Player 1 joystick is emulated using the keyboard. The default mapping is as follows:

                   ┆┆
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                                       β”‚
β”‚    [W]                                β”‚
β”‚ [A]   [D]                             β”‚
β”‚    [S]                       [J] [K]  β”‚
β”‚           [Enter] [RShift]            β”‚
β”‚                                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Zapper (Light Gun)

Zapper is emulated using the mouse and can be used in games like Duck Hunt. Point the mouse cursor at the right position on the screen and click to shoot.

Multiplayer

Dendy can be played over the network with another player. Run the emulator with the -listen=<host>:<port> flag to start a netplay server that will be waiting for the second player to connect via the -connect=<host>:<port> flag. Once the connection is established, the game will start for both sides. The player who started the server will be controlling the first joystick.

The feature works by synchronizing the state of the emulated NES and sending the controller input over the network to the other player. The algorithm allows slight drifts in the clock speed and network latency by generating fake input events for the other player if the state of the emulator is ahead of the other player’s state. Theoretically, this should keep the game playable for both players even if the network connection is not very stable (e.g. over the Internet), but it is not very well tested.

Most of the ideas for the netplay implementation were borrowed from RetroArch.

Status

CPU

  • Official opcodes
  • Unofficial opcodes
  • Runtime disassembly
  • Cycle-accurate emulation
  • Accurate clock speed
  • Interrupts

Graphics

  • Background rendering
  • Sprite rendering
  • 8Γ—16 sprites
  • Palettes
  • Scrolling
  • Color emphasis
  • Cycle-accurate emulation

Input/Output

  • Graphics output
  • Controller 1
  • Zapper

Sound

TODO

Cartridges

The goal is to support top 7 mappers covering the majority of games. The percentage indicates the number of games that use the mapper according to nescartdb.com.

  • MMC1 (Mapper 1) - 28%
  • MMC3 (Mapper 4) - 24%
  • UxROM (Mapper 2) - 11%
  • NROM (Mapper 0) - 10%
  • CNROM (Mapper 3) - 6%
  • AxROM (Mapper 7) - 3%
  • MMC5 (Mapper 5) - 1%

Test ROMs

The checked items are the ones that pass the tests completely or with minor inaccuracies (that might be caused by the test ROMs themselves).

  • Nestest CPU
  • Blargg’s CPU tests
  • Blargg’s PPU tests
  • Blargg’s APU tests

Resources

Although NES emulation is a pretty well-covered topic, It is still a very interesting and challenging project to work on. Here are some of the resources that I found particularly useful while writing this emulator. Big thanks to everyone who made them!

Documentation

Videos

  • The NES Emulator from Scratch series covers most of the topics from the CPU to the sound, but I found the two videos about the PPU to be the most useful for understanding the obscure details of the NES rendering pipeline: [1], [2].

Code

During bad times, it’s always nice to look at other people’s code to see how they solved the same problems. Here are some of the emulators written by other people that I often referred to when I was stuck:

More Repositories

1

golang-book

An Introduction to programming in Go
HTML
447
star
2

django-micro

Django as a microframework
Python
273
star
3

opencart-exchange1c

[deprecated] Data exchange with 1C for OpenCart
PHP
104
star
4

opencart-webapi

[deprecated] Remotely work with the OpenCart 1.5.3+ via the REST API
PHP
79
star
5

jquery-bem

[Deprecaetd] Plugin for comfortable work with BEM DOM from jQuery
JavaScript
64
star
6

node-beml

HTML preprocessor for BEM
JavaScript
64
star
7

kivi

Dynamo-inspired distributed leader-less key-value database that has no unique features and no apparent reason to exist
Go
38
star
8

php-commerceml

Library for easy parsing CommerceML files
PHP
20
star
9

gulp-django-utils

Gulp helpers for Django
JavaScript
8
star
10

django-roxyfileman

Integrate Django with Roxy Fileman
JavaScript
7
star
11

gulp-beml

Gulp plugin for BEML processing
JavaScript
7
star
12

python-xmltag

Tool for easy creating XML and HTML documents
Python
6
star
13

gossip

Reliable decentralized broadcast protocol implemetation
Go
6
star
14

django-frontserver

Run grunt/gulp watcher and django server with a single command
Python
5
star
15

react-svgdom-loader

Import SVG as ReactDOM element
JavaScript
4
star
16

storagl

Simple storage for screenshots and other shared files with short direct links.
Python
4
star
17

van

In-app command/event bus with dependency-injection
Go
3
star
18

pdfserver

The easiest way to generate PDF from HTML
Python
3
star
19

grunt-beml

Grunt plugin for processing BEML templates
JavaScript
2
star
20

django-goodforms

Custom renderer for django.forms
Python
2
star
21

opencart-priceparser

Module for import price lists in OpenCart
PHP
2
star
22

yotaman

Console client for my.yota.ru (unofficial)
Go
2
star
23

bitbucket-stats

Team statistic from Bitbucket
Python
2
star
24

pg_migrate.sh

Schema migration tool for PostgreSQL
Shell
1
star
25

pypograph

Simple typographic tool for Python/Django
Python
1
star
26

python-langpack

Key-based translation framework for gettext haters
Python
1
star
27

6502

MOS 6502 CPU emulator
Rust
1
star
28

opencart-rossko

Module for integration OpenCart with Rossko
PHP
1
star
29

python-passbook

Generate and sign .pkpass files
Python
1
star
30

brickboy

Gameboy emulator in good old C
C
1
star
31

tdlib-docker

Docker image with precompiled tdlib
Dockerfile
1
star