Swiftpack.co -  ryanggrey/Chip8EmulatorPackage as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
A Chip-8 emulator Swift package. For use in macOS, iOS, watchOS and tvOS projects.
.package(url: "https://github.com/ryanggrey/Chip8EmulatorPackage.git", from: "0.0.13")

Chip 8 Emulator Swift Package

A Chip-8 emulator Swift package. For use in macOS, iOS, watchOS and tvOS projects.

This package implements the core functionality of a Chip-8 emulator in Swift. It contains no platform UI elements and this is left to a consumer projects to implement.


The emulator package contains a Chip8Engine which drives the Chip-8 run loop.

Start the engine


Stop the engine


Feed inputs into the engine

chip-8 keys (Chip8InputCode)

  • chip8Engine.handleKeyDown(key: key)
  • chip8Engine.handleKeyUp(key: key)

Receive callbacks from the engine

The callbacks are handled through the delegate pattern. Set the delegate of the engine:

override func viewDidLoad() {
  chip8Engine.delegate = self


The engine will call the delegate render method when the engine determines that a render of the pixels is necessary.

This will only be called when the pixels have changed. The engine assumes that pixels have been rendered on a call to the delegate and will not re-call with the same pixels.

Implement the rendering method:

extension YourViewController: Chip8EngineDelegate {
  func render(screen: Chip8Screen) {
    // ...


The engine will call the delegate beep method when the engine determines that a sound effect needs to be played.

Implement the beep method using the provided BeepPlayer (or through a custom implementation):

extension YourViewController: Chip8EngineDelegate {
  func beep() {
    // haptics etc.

Consumer Projects



The ROMs bundled into this project are from https://github.com/dmatlack/chip8


beep.wav file in Assets is from Mixkit, originally titled mixkit-player-jumping-in-a-video-game-2043.wav. See here for Mixkit license.


I made heavy use of the following resources when working on this project:


Stars: 4
Last commit: 1 week ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API