Video: Watch Doom running on Apple’s $50 Lightning to HDMI Adapter

A developer has managed to port the Doom video game to run on Apple’s Lightning to HDMI Adapter, and published a video of it in action.

This is possible because the Lightning to HDMI Adapter contains a tiny computer tasked with the compression, decompressions and conversion of the video signal and data between the Lightning and HDMI standards.

The demo video uploaded to YouTube showcases the game running surprisingly smoothly, directly on the $50 adapter. The game is rendered on a MacBook display, and only the memory is “borrowed” from the laptop because the dongle lacks persistent storage—all processing happens on the dongle itself. It’s crazy to think that chips embedded in this tiny adapter actually have more processing power than most PCs from the 1990s when Doom was released!

Watch Doom running on Apple Lightning to HDMI Adapter

The chipset powering the Lightning to HDMI Adapter runs a stripped-down version of iOS (with SecureROM, iBoot and XNU as a kernel). The silicon is tasked with the decompression and conversion of the video stream into the HDMI signal, which can then be output from the dongle to a TV or compatible screen via an HDMI cable.

The developer explained in the YouTube comments:

Production firmware’s userspace is ultra-minimalistic though—there’s a ramdisk, but it’s not even a filesystem but a statically compiled Mach-O (it’s like ELF, but for Apple OS). Internal development bundles do have a proper ramdisk with filesystem and a bunch of executables/shared libraries on it.

And:

The Mac here just loads such firmware into it, since the dongle doesn’t have any persistent storage. The colorful logs going in one of the terminals are UART output from it—first iBoot and then kernel and userspace. Arbitrary code execution is achieved due to iOS-world bootrom exploit—checkm8, which also works here because codebase is literally the same.

Running the game at 60fps and proper resolution would be doable.

Bringing up framebuffer on that thing is not easy and would require a lot of reverse-engineering. So what I do instead is launching some embedded debug utility (IOMFBUnitTest, only exists in development firmware) in the context of my own process and hooking it in a few places, so the dirty job is mostly done there

And:

Unfortunately, the function that actually populates frames into framebuffer is copying only 4 bytes per iteration (so basically 1 pixel) and in between it does some math that I couldn’t yet comprehend. It for sure must be possible to reimplement the function properly and thus improve the performance vastly.

What about the controls and sound?

Terminal window on the right outputs serial logs of the dongle, and of course we can also send data in the opposite direction. This is for controls. Sound is a whole different story, but on the HDMI variant of the adapter must also be possible. He’s planning to release the port as a package for jailbroken iOS devices at some point.

If it has a CPU, it can run Doom

The Doom game running on Apple's Lightning to HDI adapter connected to a Mac and an external display.

Doom is the legendary first-person shooter created by ID Software and released in December 1993 for PCs running DOS. The game became hugely popular, spanning many official and unofficial ports—especially after the Doom source code was released under the GNU General Public License in 1999. Since Doom was written for an ancient CPU architecture and does not rely on modern technologies, it requires almost no processing power to run.

This has enabled programmers to port Doom to run on unexpected hardware like smart thermostats, pianos, pinball machines, Redbox kiosks, quantum computers and even on Apple Watch, in iOS’s picture-in-picture mode and the MacBook Pro’s discontinued Touch Bar.

Other projects saw Doom running in ASCII mode in terminal, over an audio connection and inside other software like MS Paint, LibreOffice Calc, Minecraft: Pi Edition and Stardew Valley, plus Excel tables and Word and PDF documents.