go-nes is a focused, well-tested Go library that implements the core internals of an NES emulator. It intentionally excludes GUI and real hardware I/O (display/windowing, real controllers, audio output). The goal is to provide a clean, reusable emulator core you can embed into your own frontend, educational tooling, or testing harness.
Important
This project is a work in progress and may not yet be feature-complete or fully accurate.
- Accurate 6502 CPU emulation with support for all official/unofficial opcodes and addressing modes.
- Passed the NESTest CPU test ROM for accuracy verification of 6502 instructions and unofficial opcodes.
- Basic PPU implementation for rendering graphics (background and sprites).
- APU stubs for audio processing (full audio implementation is a work in progress).
- Memory mapping that supports various NES mappers (NROM, MMC1, etc.).
nes: High-level NES struct that ties together CPU, PPU, APU, and memory.cpu: Implements the 6502 CPU with all instructions, addressing modes, and status flags.ppu: Handles the NES Picture Processing Unit (PPU) for graphics rendering.apu: Manages the NES Audio Processing Unit (APU) for sound generation.memory: Emulates the NES memory map, including RAM, ROM, and I/O registers.rom: Loads and parses NES ROM files in iNES format.rom/ines: Loads and parses iNES header.rom/mapper: Supports various NES cartridge mappers for memory banking.controller: Emulates NES controller input handling.
- NROM (Mapper 0)
There are a minimal example of how to use the library to load a ROM and run the emulation loop:
// Import the library
import "github.com/ghosind/go-nes"
// Read a ROM file
romData, err := os.ReadFile("path/to/your/game.nes")
// Create a new NES instance
myNes, err := nes.New(romData)
// Run the emulation loop
for {
myNes.Step() // Step the CPU, PPU, and APU
// Handle input, rendering, etc.
}The project includes extensive unit tests covering CPU instructions, memory mapping, and ROM loading. To run all tests, use:
go test ./...To run tests for a specific package, e.g., CPU:
go test ./cpu -v- 6502 CPU implementation with unofficial opcodes
- Complete NESTest compliance
- Memory mapping and RAM emulation
- iNES ROM loading and parsing
- IRQ and NMI handling
- Complete NROM mapper support (mapper 0)
- PPU implementation for full graphics rendering
- APU implementation for audio output
- Support for additional mappers (MMC1, MMC3, etc.)
- Controller input handling
- Debugging and logging utilities
- NES Documentation
- CPU Reference
- Obelisk 6502 Guide
- Unofficial 6502 Opcodes
- PPU Programmer Reference
- iNES File Format
- INES 1.0 Mapper Grid
This project is licensed under the MIT License - see the LICENSE file for details.