We’ve all seen Doom played on the Raspberry Pi before… but this isn’t a port of the game. No, this was a school project at the Imperial College of London — writing the game in bare assembly. They wrote it from scratch.
Yep. There’s not even an operating system on the Pi. It’s 9800 lines of bare metal ARM assembly. If that doesn’t hurt your brain we dunno what does!
They are using the official textures from the game, and it’s not quite a perfect replica — but it’s pretty darn close.
Part of the project was to build an emulator to make it easier to test the game, but it didn’t work out the greatest — so most of the actual game development was performed on the actual hardware. Yikes!
Stick around after the break to see Doom in all its former glory. Top notch work guys!
Reminds us of running Doom on the Intel Edison…
More like a custom coding of Mannequins of Doom (still way better then my uber limited assembly code skills).
Wow, that must have been a colossal pain in he ass!
well it must have been A LOT of work, but not that hard imho, the doom engine is very well documented and all the trigonometry math is fixed point. I think you could probably pull this off without even understanding large parts of the original code, and just reimplementing it in any other language.
never the less an impressive feat
Yep.
0x5f3759df anyone ?
Carmack’s “Fast Inverse Square Root” function for normalizing vectors was legendary, and still is.
I used it in embedded applications on several occasions since the C standard library doesn’t have it.
I thought that was for Quake, not Doom
At any rate… This hack is epic. Well done!
Anything made by Carmack reminds me of that function.
Even though it has been attributed to John Carmack for as long as I can remember, the Wiki article now says “Adjustments and alterations passed through both Silicon Graphics and 3dfx Interactive”, so it seems he was not the only contributor after all.
It is still not known how the constant was originally derived.
“evil floating point bit level hacking” nice.
This hack, though… man, only 9800 lines of assembly? I had no idea something this sophisticated could be accomplished with so “little” (still… that’s a LOT of work), nicely-done.
thats one of the best points of assembly, the tiny code size that can be achieved. i guess that and it runs really fast.
Which source code do you use in your embedded applications, the source from the quad III engine but modified or what?
The polluting effect of the C pre-processor. 5f3759df is not the same as 5F3759DF in many languages. And it shouldn’t be. (and 0x is not part of a number unless it is at least radix 36). You damn kids get off my lawn!
Other than that, this is pretty cool, aside form using a Pi that is. ARM assembly code is really nice and efficient. If they didn’t use Thumb, then they got to use real ARM and conditional execution on any instruction which gets rid of tons of “if branches”. Love it.
“Fast Inverse Square Root” predated Carmack, as did a number of other awesome “magic number” hacks.
“Fast inverse square root (sometimes referred to as Fast InvSqrt() or by the hexadecimal constant 0x5f3759df) is a method of calculating x−½, the reciprocal (or multiplicative inverse) of a square root for a 32-bit floating point number in IEEE 754 floating point format. The algorithm was probably developed at Silicon Graphics in the early 1990s … The algorithm was originally attributed to John Carmack, but an investigation showed that the code had deeper roots in both the hardware and software side of computer graphics.”
https://en.wikipedia.org/wiki/Fast_inverse_square_root
Holy crap! I’d play that!
This is a very impressive feat of programming. Is it a perfect reproduction? Close enough!
Ehmm, sorry guys, but this is not Doom. It is Wolfenstein.
But anyway nice work!
Could you elaborate? Wolfenstein only had walls meeting at 90 degrees. On screenshot you see that is not the case.
It’s missing floor and ceiling textures, and textures on walls that don’t go all the way to the ceiling – the stair risers.
I must agree. This looks like Wolfenstein with doom textures. It’s still a work of art considering how it was made. Perhaps there was a publishing error?
That was my first thought too. But after closer examination – Wolfenstein only had perpendicular walls, didn’t have stairs, didn’t have floor/ceiling level changes. So it’s kind of closer to Doom in that regard.
However, given they didn’t use Doom’s original map I’m suspecting this is not the true Doom engine, but a one that kind of looks like it.
And as others said – 10K of assembly is mind blowing. Nice work.
Or…
sudo apt-get install prboom
cp your ID game software files into the man page documented folders, and run:
prboom
Your cpu natively executes linux shell commands? Can I have one too?
You didn’t get the point of this hack.
Or…just turn it on and it’s already there running. No OS necessary.
very cool, takes me back to the raycasting days. there’s another arm doom for riscos, it’s mostly just the rendering functions, but thats where the heavy lifiting is.
Looks good, needs more secret doors.
How did they talk to the Broadcom video chip? Did they rwork from the docs broadcom dropped?
it’s probably just a memory mapped frame buffer
9800 lines of ARM assembler hurts your brain? Phh. Kids today…
Yeah, I was just going to say the same…
I still remember some of the code I was maintaining for an ex-employer where 150k lines of assembler was rather common. I think our biggest block (as every “program” was called) was around 300k lines but I’m sure there were bigger ones somewhere. This was all for real-time systems on custom processors. The biggest 68k stuff I’ve worked on was about 80k-ish lines of code if my memory still serves me correct.
However – kids learning assembler today is great and I hope more do :)
But can it run stock WAD files?
Great to see this kind of stuff done by today’s students. Teaches much more practical application of low level coding than boring exercise and is fun too.
I was shocked that a full-featured port of Doom fit in <10k lines of asm but then I watched the video. Still, very cool.
Taking out cyberdemons with a pistol? Looks like they implemented the cheat codes as well ;-)
This is still a pretty awesome feat of coding.
Is there a link to the source code? Or the final version?
You’d need to re-make the controller, too – if you wanted to try it out.
Seriously, how one can ‘IDDQD’ or ‘IDKFA’ on this one? Useless! ;-)