On the point of being a joke, it seems like DOOM has been modified to run on anything these days. So it was only natural that we would see it ported to the RP2040 by [Graham Sanderson]the tiny chip that powers the Raspberry Pi Pico.
You may be thinking, what’s different about this gate? There are 55 articles on DOOM here on Hackaday, proving it runs on everything from web checkboxes to desk phones. The RP2040 has 256K of RAM, two reasonably clocked processor cores, and 2MB of flash, so it’s not the most limited platform ever run by DOOM. But [Graham] also set some very lofty goals: all nine levels should be playable, graphics and music faithful, multiplayer, and it would be output directly to VGA. It should play just like the original. DOOM has a demo that is saved as a series of input events. They make excellent regression tests as if the character gets stuck or doesn’t make it to the end; then you are not accurate according to the original code.
There are two major problems right outside the gate. First, a single level is larger than the 2MB of storage the RP2040 has. And to drive the 320×200 display, you either have to spend a large chunk of your CPU budget on the radius or allocate a massive amount of RAM to frame buffers, making level decompression that much harder.
A standard compression scheme wouldn’t make it because it needed a high compression ratio and random access, since decompressing in RAM wasn’t an option. However, careful optimization and compression of the various data structures yielded great results. Save game files are given a similar treatment to make sure they fit into the remaining flash after all levels (34k).
The result is fantastic and it supports DOOM, Ultimate DOOM and DOOM II. The description goes into much more detail than we could here; enjoy reading. If you decide to take a day trip to the depths of hell on your own Pi Pico, let us know in the comments.
Thanks to [Xark] on the Hackaday Discord server for the tip.
This post DOOM comes to the RP2040
was original published at “https://hackaday.com/2022/03/15/doom-comes-to-the-rp2040/”