At this point, we’re used to modern computers being able to perform near-perfect emulation of older gaming hardware via software trickery. The latest project from Tom “Tom7” Murphy, though, seems poised to coin its own definition for “reverse emulation” by running a playable Super NES game on actual unmodified NES hardware.
Murphy breaks down this wizardry in a pair of detailed videos laying out his tinkering process. Though the NES hardware itself is untouched, the cartridge running this reverse emulation is a heavily customized circuit board (ordered from China for about $10), with a compact, multi-core Raspberry Pi 3 attached to handle the actual Super NES emulation.
The Pi essentially replaces the PPU portion of the cartridge, connecting to the NES via a custom-coded EEPROM chip that tells the system how to process and display what would normally be an overwhelming stream of graphical data coming from the miniature computer. Only the CIC “copyright” chip from the original cartridge remains unmodified to get around the hardware’s lockout chip.
Murphy—you may remember him from previous efforts to teach an AI how to play NES games—says that the Raspberry Pi actually has too much latency to effectively “stream” tile-by-tile graphical instructions to the NES’ cartridge CPU. By the time the Pi manages to “discharge” a set of instruction bits (only 180ns after they were generated), the NES itself has already moved on to the next part of its read-write cycle.
Murphy used a one-cycle delay to compensate for this latency, essentially guessing where the fairly predictable PPU would be writing to next and just sending data to that location ahead of time. That process works pretty well but results in the persistent flickering and graphical noise you see throughout his video demonstrations.
Supercharging the NES
Despite the latency issue, using the power of a Raspberry Pi lets Murphy do a lot of things a standard NES cartridge could never do. On a standard NES game, for instance, any 16×16 pixel block has to use a single palette of three colors (plus one background color). The NES hardware itself, though, actually generates each scanline as a set of discrete 8×1 pixel strips. By switching the palette in between each strip, the system can actually display many more colors in each tile (though each frame is still limited to four distinct palettes).
The Pi’s “streaming” PPU also lets Murphy update every tile on the screen as often as he wants, getting around the PPU-to-CPU bandwidth limitations that constrained scrolling speeds in standard NES games. That allows for effects such as full-motion video and other complex animations that wouldn’t be possible using the usual sprite-and-background model.
Even with these advantages, there are obvious inherent limitations to reverse-emulating the Super NES on older hardware. The NES can’t handle all of the 56,000+ colors possible on a Super NES, for instance, so the Raspberry Pi has to essentially round to the nearest available NES-safe color using a lookup table. The NES controller doesn’t have enough buttons to simulate all Super NES inputs, either, though apparently the same basic electrical signals from an NES controller d-pad work unmodified when controlling a Super NES ROM.
The reverse emulation also doesn’t currently support Super NES audio, which would sound rather transformed on the NES’ limited four-channel audio output anyway. Murphy theorizes, though, that it might be possible to send high-quality pulse-code modulated audio waves to the NES through a reverse-emulated cartridge CPU. In that case, the cartridge would essentially act as a bus that simply reads data from the Pi and writes it to the NES’ audio memory as quickly as possible.
While super-charging classic video game hardware is fun, Murphy is already doing some sci-fi speculation about how the human brain could reverse emulate a much more advanced computer. Maybe one day we’ll all be “outputting” computer-derived answers to complex questions, all fed through our limited brains by a super-brain running in our pockets.