Back to the showcase

NES Core

Madru.Nes

Plugin v1.0.1 Gaming Desktop Command line Web Worker

The time-critical part of an NES emulator in one portable package: 6502 CPU, dot-accurate PPU, five-channel APU, save states, cheats and memory access for any Objo project.

by @madru

The hardware heart of an NES emulator, packaged as an Objo plugin by
@madru: a 6502 CPU, a dot-accurate PPU, the
five-channel APU, the memory bus and 25 mapper implementations covering 28 iNES
mapper numbers. One small portable assembly with no native binaries to install:
the same package runs identically on macOS, Windows and Linux, in desktop,
command line, web and worker projects. ROM header parsing, cheats, files and
the user interface stay in Objo, where they belong.

Highlights

  • The whole console, one class. Everything is exposed through
    Madru.Nes.NesCore: insert a cartridge, run a frame, read the screen as a
    Picture, take the frame's sound samples, save and load states, and inspect
    emulated memory live.
  • 28 mappers. 25 mapper implementations cover 28 iNES / NES 2.0 mapper
    numbers, from NROM and UNROM through MMC1, MMC3 and MMC5 to VRC boards.
    IsMapperSupported() tells you before you load.
  • Sound on every platform. TakeSamples() returns each frame's audio in
    the exact format of Objo's AudioOutput API, so a few lines of code give you
    sound on macOS, Windows and Linux. SetChannelMask() mutes individual
    channels and ChannelInfo() reports each channel's live register state.
  • Tools welcome. Game Genie style ROM patches, battery-backed cartridge RAM
    for in-game saves, full save states, a CPU bus PeekMemory(), CPU registers,
    OAM and palette RAM snapshots, and the pattern tables rendered as a Picture.
  • NTSC and PAL. LoadCartridge() takes the region and SetPal() switches
    it later; the core paces output exactly like the real console.
  • Sharp scaling built in. SetPixelScale() renders each NES pixel as a
    crisp NxN block with no smoothing filter, so the screen stays pixel-perfect
    at any window size.

Using it in code

Var core As New Madru.Nes.NesCore()
# prg and chr are the cartridge ROM banks, mapper the iNES mapper number
core.LoadCartridge(prg, chr, mapper, submapper, mirroring, hasBattery, prgRam, chrRam, isPal, 0, 0)
core.RunFrame()
Var screen As Picture = core.FramePicture()

For a complete reference implementation, see the
NES Emulator app in this showcase:
its menus, rendering, sound and cheat handling are ordinary Objo source talking
to this plugin. A second, pure Objo core ships in the same app, so you can
compare the two approaches line by line.

Requirements

  • Objo Studio 26.10.1 or newer, which covers both plugin support and the
    AudioOutput sound API.
  • The plugin is free software under GPL-3.0-or-later; the licence file ships
    inside the package.

About

NES Core is made by @madru, who also built the Game Boy Core plugin and the Game Boy Emulator, ChartView, Minesweeper and Sokoban entries in this showcase.

Adding NES Core to a project

  1. Download the .objopackage file.
  2. Import it into Studio’s Plugin Library.
  3. Select the plugin in your project and use its API in code.
The Using Plugins guide covers installation, side-by-side versions and updating projects.

← Back to the showcase