Skip to content

Nintendo Entertainment System (NES) emulator for Apple platforms

License

Notifications You must be signed in to change notification settings

glhaynes/Blackbox

Repository files navigation

Blackbox

Nintendo Entertainment System (NES) emulator for Apple platforms

Blackbox is an NES emulator app for iOS, iPadOS, macOS, and visionOS.

It’s a work in progress by Grady Haynes and is freely available under the MIT license. Feedback and contributions are welcomed. It requires a minimum of iOS/iPadOS 16.4, macOS Ventura 13.3, or the visionOS 1.0 simulator. Building Blackbox requires Xcode 14. (visionOS support requires the Xcode 15 beta.)

Blackbox is a hobby project for experimentation and learning, but I’d be delighted for anyone to use it, learn from it, or reuse its code in another project.

It’s named for the classic “black box” games released alongside and soon after the NES’s release in North America in 1985.

Blackbox running Super Mario Bros on a Mac

Blackbox running Golf on an iPhone 14 Pro Max Blackbox’s onboarding screen on an iPhone 14 Pro Max

Blackbox running Balloon Fight on an iPad Pro 11"

Blackbox running Baseball on Apple Vision Pro

Playing NES games

Blackbox is not the best way to play NES games on its supported platforms, at least not currently. It isn’t compatible with most games and has no audio emulation. That said, I’ve had a great time playing through Super Mario Bros. several times during its development!

If your primary goal is playing NES games on Apple platforms, I’d suggest checking out OpenEmu for Mac, Delta for iOS, or Provenance for iOS and tvOS.

To play a game on Blackbox, you’ll need to open a .nes file (a “ROM”) for the game. I can’t provide copyrighted ROMs, but there are many sources on the internet that can provide more information, including how to “dump” a ROM from a cartridge you own.

A freely-distributable sample ROM is included in the app so the app can be tested. See “Acknowledgments” section below for details on it.

Technical Details

Blackbox uses the SwiftUI app lifecycle. It includes:

  • Game controller and keyboard support leveraging the system Game Controller framework
  • An onscreen virtual touch controller available as a Swift package
  • A set of “accessories” providing realtime information on the emulated NES’s CPU state and the PPU’s palettes and pattern tables
  • An onboarding/usage workflow
  • Support for opening NES ROM files (iNES format), including a recents list
  • A sample ROM for testing

It’s built on top of CoreBlackbox, a module that provides the following:

  • A 6502 emulator, “CPU6502”, written in Swift
    • Aside from cycle timing, this is an accurate emulator, including “illegal” instructions.
  • A Swift wrapper around the C-language m6502 CPU emulator from floooh’s “chips” project
    • This is useful during testing/debugging as it’s a “known good”, cycle-accurate, cycle-stepped 6502 emulator.
  • Emulation of the NES’s Picture Processing Unit (PPU)
  • (Very) basic mapper support
  • Loading and parsing iNES files (ROMs)

More of the above components may be separated into their own Swift packages in the future. If you have suggestions for what would be particularly useful, please let me know.

Privacy and Data Collection

Blackbox does not make any network calls; no personal data is recorded or sent by the app.

Acknowledgements

This project relies heavily on some fantastic resources, most prominently those below. I’m grateful for their work.