nes

package module
v0.0.0-...-636210a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2022 License: MIT Imports: 6 Imported by: 0

README

NES

A partially complete NES emulator written in Go. Compiles to WASM and available for play at https://nesdev.netlify.app.

Summary

This emulator exposes a relatively simple Go package with a minimal API that can be wrapped with pretty much any GUI. The currently implemented wrapper is a WASM website, but one could easily also build a native GUI on top of this package with minimal effort.

I chose WASM because I wanted to learn about the tech and see how good performance would be. On my local setup, performance playing titles like Pac-Man, Donkey Kond and Super Mario Bros appears to be acceptabe.

Building

The WASM website is relatively naive, just an index.html the Go supplied wasm_exec.js and the built nes.wasm file.

Simply compile cmd/wasm/main.go and host the contents on web/ online!

GOOS=js GOARCH=wasm go build -o web/nes.wasm cmd/wasm/main.go

Testing

Testing of the CPU is based on the golden log file. It loads nestes.nes and steps through the log file verifying cycle counts and register values.

go test

Usage

The website can be run locally by running

go run cmd/server/main.go

And loading http://localhost:8000.

The website is super basic as of yet. It consists of a file input and a canvas. Load your favorite (legally obtained of course 😉) ROM and begin playing!

Controls

Controls are hardcoded and only keyboard controls are supported currently.

Arrow keys, Enter, Space, D and F map to the NES arrow buttons, Start, Select, B, and A buttons respectively

Mappers supported

  • NROM
  • MMC1
  • UNROM
  • CNROM
  • MMC3 (Coming soon!)

Currently implemented mappers should support around 60% of all games. MMC3 support should bring this number closer to 85%.

Work remaining

In short, a lot 😅

  • Audio support has not been started
  • Put more design effort into the website

Documentation

Index

Constants

View Source
const (
	ButtonA byte = 1 << iota
	ButtonB
	ButtonSelect
	ButtonStart
	ButtonUp
	ButtonDown
	ButtonLeft
	ButtonRight
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Console

type Console struct {
	// contains filtered or unexported fields
}

func NewConsole

func NewConsole(r io.Reader) (*Console, error)

func (*Console) RenderFrame

func (c *Console) RenderFrame(image *image.RGBA)

func (*Console) SetJoypad

func (c *Console) SetJoypad(button byte, pressed bool)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL