A Swift package for interpreting Chip-8 ROMs
// ROM
let rom: [Byte] = [...]
// Initialize Chip8 with ROM data loaded at address 0x200
let chip8 = Chip8(rom: rom)
// Or load ROM data at specific address
let address: Word = 0x0200
chip8.load(rom: rom, address: address)
// Reset and erase the RAM
chip8.reset()
// Reset without erasing the RAM
chip8.reset(soft: true)
// Emulate one CPU cycle
chip8.cycle()
// Emulate one timer tick
chip8.tick()
Implementation of the main loop is purposely left for the consuming application. The consuming application (presumably a GUI) will need to handle key presses, set up screen redrawing, and create timing for delay and sound.