返回资讯中心
外部精选
软件工程
#开发者实时流

Running Doom on 3D Printer

Doom has always taken a unique place in the lineup of games. It was a successor to Wolfenstein 3D and in the 30 years since its release, Doom has managed to become an industry standard benchmark. It has run on everythin…

Hacker News 最新bitilia2026/11/23 · 今天10 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

Doom has always taken a unique place in the lineup of games. It was a successor to Wolfenstein 3D and in the 30 years since its release, Doom has managed to become an industry standard benchmark. It has run on everything from pregnancy tests to a smart fridge. You will often hear techbros look at a weird piece of tech and ask, “Can it run Doom?”

As Dr Ian Malcolm says, “Yeah, but your scientists were so preoccupied with whether or not they could, they didn’t stop to think if they should.” But now Doom can run on everything. Today, I will be adding to that collection with an Ender 3 3D printer and going through my experience and thought process doing so.

The first step to running Doom on any weird piece of tech is realising your hardware limitations. What microcontroller have you got? What output will you be using? And, most complicated of all, what will you use as your input keys?

The board in my Ender 3 V2 is a 32-bit board with around 50 GPIO pins. It also has a grand total of 256 KB of flash and 48 KB of RAM, which for scale is much less than Doom’s 4 MB WAD file. I really didn’t want to turn my printer into a large paperweight, so I didn’t rewire any of the inputs and instead used the available ones, such as using the X endstop as the shoot button.

Deciding on the outputs wasn’t hard. The Ender 3 V2 has a display, which luckily isn’t as bad as the old 128 × 64 pixel LCD screen from the original Ender 3s.

The input was another story. The usual inputs that a user interacts with are the SD card slot and the rotary knob, which turns left, right and can be pressed down. The knob could cover turning and walking forward, and pressing “use” could be run repeatedly on a timer. This still left shooting. As I said earlier, I ended up using the X endstop, which was, to be fair, as ergonomic as we were going to get.

Doom is a whopping 4 MB unless you strip out a lot of its content, which is what I ended up doing in order to get it running. I didn’t want to cheat and connect a Raspberry Pi, or replace the stock board, as I really wanted someone else to be able to recreate it on a fully stock machine without issues. The base is linuxdoom-1.10, the C source id Software released in 1997. I made some changes and borrowed one main idea from FastDoom: instead of textures, each wall texture and floor is drawn as its single average colour.

This alone wouldn’t fix the size issue, so each game object shrank from 156 to 124 bytes, map segments from 32 to 12 bytes, and the sine tables from 64 KB to 22 KB.

That still left the bottleneck of the 11.5 KB/s cable to the screen. Each frame is compared with the last, and only changed areas are sent, as merged rectangles. Even so, a moving frame is 2–3 KB, which works out to around 3 frames per second at peak movement.

Usually I skim over details like this in my write-ups, but this one was too funny. I flashed a diagnostic build and nothing would boot. As I found out after quite a bit of debugging, during startup I had set it up to turn off all heating elements, just because I have made the mistake of leaving it on before, and let me tell you, 200 °C does not feel nice.

After this shut-off, the code was set to wait 2 ms for an interrupt just to make sure instructions were fully processed, but interrupts were only launched a couple of lines later, so my script just sat there waiting for an interrupt that was never coming, and due to how early in the flash this was, I had no way of logging diagnostics and had to learn to fix this the hard way.

I am sorry, but I won’t be sharing the code I used to do this, because it is one thing for me to experiment with code on a machine running at 350 W with dangerous heating elements; it is a whole other thing to distribute that code.

To round this off, this was a fun experiment, and by the time I got it running I was already in the final stages of “just work already”. Now I am going to go and find out whether I can still flash the original firmware back onto it so I can use it, or whether it goes on the pile of bad decisions.

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →