# Doom

Doom is a legendary video game released in December 1993, perhaps the most famous video game of all time, the game that popularized the first man shooter genre and shocked by its at the time extremely advanced 3D graphics (yes, **Doom is 3D**) and caused one of the biggest revolutions in video game history. It was made by Id Software, most notably by John Carmack (graphics + engine programmer) and John Romero (tool programmer + level designer) -- all in all the game was developed by about 5 to 6 men in about a year. Doom is sadly proprietary, it was originally distributed as shareware (a gratis "demo" was available for playing and sharing with the option to buy a full version). However the game engine was later (1999) released as free (as in freedom) software under GPL which gave rise to many source ports and "improved" "modern" engines (which however look like shit, the original looks by far the best, if you want to play Doom use Chocolate Doom or Crispy Doom, avoid anything with GPU rendering). The assets remain non-free but a completely free alternative is offered by the Freedoom project that has created free as in freedom asset replacements for the game. Anarch is an official LRS game inspired by Doom, completely in the public domain.

{ NOTE: Some followers expressed disgust about the fact that I "glorify" Doom, a proprietary game -- yes, Doom is proprietary and thus an unethical piece of shit. Ethical "fixes" exist, namely Freedoom. Here I merely describe the historical significance of "Doom as a concept", it's the same as with "Unix" as a concept -- Unix was also proprietary, but its invention was very significant historically, it was a discovery of a certain kind of formula, almost like discovering a law of nature in science. Even if this is initially seized and held by capitalists, later on free clones usually manage to at least partially free the concept from proprietary hands. Just so we understand each other: I am fully AGAINST proprietary games, but things aren't black and white, a disaster may have historical significance and lead to something good, and vice versa. I am just capturing facts. ~drummyfish }

Doom has a cool wiki at https://doomwiki.org.

Only pussies play Doom on low difficulty. { Sorry Ramon, love u <3 :D ~drummyfish }

{ Great books about Doom I can recommend: *Masters of Doom* (about the development) and *Game Engine Black Book: Doom* (details about the engine internals). Also recently John Romero, who has a rare condition of being able to perfectly recall every day of his life, has written a book about the development, called *Doom Guy*. ~drummyfish }

In part owing to the release of the engine under a FOSS license and its relatively suckless design (C language, software rendering, ...), Doom has been ported, both officially and unofficially, to a great number of platforms (e.g. Gameboy Advance, PS1, even SNES) and has become a kind of **de facto standard benchmark** for computer platforms -- you will often hear the phrase: **"but does it run Doom?"** Porting a Doom to any platform has become kind of a meme, purportedly someone even ported it to a pregnancy test (though it didn't actually run on the test, it was really just a display). { Still Anarch may be even more portable than Doom :) ~drummyfish }

The major leap that Doom engine's graphics brought about was unprecedented, but Doom was not just a game with good graphics, it had fantastic gameplay, brutally good music and a fitting, badass art style, all polished and coherent in a very beautifully gory harmony, and on top of that there was the novel and revolutionary deathmatch multiplayer (the name *deathmatch* itself was coined by Romero during Doom multiplayer sessions), as well as a HUGE modding and mapping scene. Doom was a success in every way -- arguably no other game has since caused a revolution of greater proportions (no, not even Minecraft, World of Warcraft and whatever else). Many game magazines just started reviews with: "OK, Doom is clearly the best game ever made, let's just examine the details...". The game's overall style and atmosphere were just "cool", as were the developers themselves, Doom was very appealing by its sincere message that read "fuck it, we don't give a shit, let's make a great game". It was a pure metal/bloody/gory/demon slaying shooter without any corporate garbage stuffed in for more popularity and profit that you'd see today. It was a game made by a bunch of guys doing it their own way without giving much shit about family friendliness or marketing bullshit, you won't see that anymore. Doom didn't pretend, it didn't care about backstory, everyone knew it was about shooting and so they just made it a bloody shooter. John Carmack famously stated that story in a video game is like story in a porn movie -- it's expected to be there but not very important. Nowadays you may at best see developers try to artificially imitate this attitude but it's always laughably transparent, it will only ever be a pretense as the times when you could simply make a game with artistic freedom, without having to bow to managers, gender departments, publishers and other overlords are simply long gone by.

Doom wasn't the first 3D game, nor was it the first FPS, some of its predecessors could even be considered "more 3D" in a sense -- for example flight simulators -- what was so special and breathtaking about Doom was the mastery with which it combined all the graphic tricks in a novel way and still managed to complement them with excellent gameplay to deliver unprecedented "immersion", such that mere mortals of the 1990s couldn't expect and weren't ready for. Doom had fully textured environments, including floors and ceilings, which along with the fog, sector lighting, level verticality and interactivity made the player really feel present in the game despite not being able to look up and down. Games had textured walls before, and others had textured floors, some had lighting effects and distance fog, but Doom was the first to have it all and have it done the right way.

As stated, the game's backstory was simple and didn't stand in the way of gameplay, it's basically about a tough marine (so called *Doomguy*) on a Mars military base slaying hordes of demons from hell, all in a rock/metal style with a lot of gore and over-the-top violence (chain saws n stuff).

*Doom* was followed by *Doom II* in 1995, which "content-wise" was basically just a data disc, the same game with new levels and some minor additions. More Doom games followed, notably *Final Doom* and *Doom 64*, but these are a bit less known now. After the turn of the new millennium *Doom III* came out in 2004, which was a kind of "reboot" rather than a sequel. The game also got an expansion pack. *Doom IV* was in development but got canceled, so the next official game was *Doom 2016* -- another reboot. In 2020 *Doom: Eternal* was released.

Some **interesting trivia** about Doom include:

- Someone created a Doom system monitor for Unix systems called psDooM where the monsters in game are the operating system processes and killing the monsters kills the processes.
- In 2024 some researchers made an experimental completely neural network AI game engine (called GameNGen) and implemented Doom with it -- basically they just made the network play Doom for a long time and so trained it to estimate the next frame from current input and a few previous frames. It can be played at 20+ FPS and looks a lot like Doom but it's also "weird", glitching, and having little persistence (it only remembers a few seconds back). Still pretty impressive.
- Although the game was officially released on Gameboy Advance, fans still made their own port to the console. It is called *gbaDoom* and is a prBoom engine port, adding many more features against the official release: for example the exact same maps as in original Doom without reduced geometry, normal blood, better graphics and even allowing mods that aren't too heavy on performance, including Freedoom.
- The Crispy Doom engine adds `GOOBERS` cheat code which makes all floors and ceilings the same height, effectively making the game a flat wolf3d-style game.
- By simple modification of the engine (making the pseudorandomness generator always return the same value, e.g. zero) it's possible to essentially turn off all randomness and the game then becomes quite weird. For example the "melting" screen effect turn to just a screen swipe, strobe light effects disappear, weapon fire loses any spread and all monsters always make the same death sound.
- Someone (kgsws) has been hacking the ORIGINAL Doom engine in an impressive way WITHOUT modifying the source code or the binary, rather using arbitrary code execution bug; he added very advanced features known from newer source ports, for example an improved 3D rendering algorithms allowing geometry above geometry etc. (see e.g. https://yt.artemislena.eu/watch?v=RdbRPNPUWlU). It's called the Ace engine.
- A special mod of Doom, called Marine Doom, was at one point used for military training.
- Doom sprites were made from photos of physical things: weapons are modified photos of toys, enemies were made from clay and then photographed from multiple angles (actually a great alternative to 3D modeling that's less dependent on computers and produces more realistic results). The clay models still exist.
- The strongest weapon in the game is name BFG9000, which stands for "big fucking gun".
- There is some kind of "controversial" Doom mod called *Moon Man* where you shoot feminists, jews, niggas and such, apparently it triggers SJWs or something.
- It's estimated that by late 1995 Doom was installed on more computers than Windows 95.
- The name *Doom* comes from a line in a movie called *The Color of Money*.
- Arguably the greatest Doom speedrunner, but likely one of the greatest speedrunners ever, is ZeroMaster, a guy from Norway who just keeps beating record after record, many of which were thought to literally be impossible. He also writes tool and scripts to help search for new bugs and viable strategies and also makes insane tool assisted speedruns.
- The initial release even featured support for a three-monitor wide view, something truly advanced for the time. This was disabled in newer versions but the code stayed and later source ports, such as Cholocate Doom, reenabled it.
- According to DYKG, the engine initially supported even sloped floors, but the feature was later on scratched.

## Doom Engine/Code

*See also game engine for the list of different Doom engines. Tl;dr: to play doom nowadays use either Chocolate Doom or Crispy Doom.*

Doom source code is written in C89 and is about 36000 lines of code long, spread over some 124 files, of which some were auto-generated (e.g. the AI state machines). The original system requirements stated roughly a 30 MHz CPU and 4 MB RAM as a minimum. It had 27 levels (9 of which were shareware), 8 weapons and 10 enemy types. The engine wasn't really as flexible in a way "modern" programmers expect, many things were hard coded, there was no scripting or whatever (see? you don't fucking need it), new games using the engine had to usually modify the engine internals. Compared to its predecessor (Wolf 3D), successor (Quake) and competition (Duke 3D), Doom's code is arguably the nicest and closest to LRS.

The code itself looks alright, files are conveniently organized into groups by their prefix (`g_`: game, `r_`: rendering, `s_`: sound etc.). The same goes for the function names. There seems to be tabs mixed with spaces though, sometimes a bit shitty formatting, but overall MUCH better than duke 3D's code (well, that doesn't say much though). Comments are plentiful.

The game only used fixed point, no float!

The **Doom engine** (also called *id Tech 1*) was revolutionary and advanced (not only but especially) video game graphics by a great leap, considering its predecessor Wolf3D was really primitive in comparison (Doom basically set the direction for future trends in games such as driving the development of more and more powerful GPUs in a race for more and more impressive visuals). In early stages the game used a portal renderer but it turned out running too slow with more complex scenes, so John Carmack switched to a new technique called **BSP rendering** (levels were made of convex 2D sectors that were then placed in a BSP tree which helped quickly sort the walls for rendering front-to-back) that was able to render realtime 3D views of textured (all walls, floors and ceilings) environments with primitive lighting (per-sector plus diminishing lighting), enemies and items represented by 2D billboards ("sprites"). The BSP rending was especially elegant in that it always drew each screen pixel exactly once, without overdraw or "holes" left behind, and thanks to this it wasn't even necessary to clear the video buffer inbetween frames. No GPU acceleration was used, graphics was rendered purely with CPU (so called software rendering, GPU rendering would come with Doom's successor Quake, and would also later be brought to Doom by newer community made engines, though the original always looks the best). This had its limitations, for example the camera could not look up and down, there could be no tilted walls and the levels could not have rooms above other rooms. The geometry of levels was only static, i.e. it could not change during play (only height of walls could, which is why walls always opened upwards), because rendering was dependent on precomputed BSP trees (which is what made it so fast). For these reasons some call Doom "pseudo 3D" or 2.5D rather than "true 3D", some retards took this even as far as calling Doom 2D with its graphics being just an "illusion", as if literally every 3D graphics ever wasn't a mere illusion. Nevertheless, though with limitations, Doom did present 3D views and internally it did work with 3D coordinates (for example the player or projectiles have 2D position plus height coordinate), despite some dumb YouTube videos saying otherwise. For this reason we prefer to call Doom a **primitive 3D** engine, but 3D nonetheless. Other games later used the Doom engine, such as Heretic, Hexen and Strife. The Doom engine was similar to and competing with Build engine that ran games like Duke Nukem 3D, Blood and Shadow Warrior. All of these 90s shooters were amazing in their visuals and looked far better than any modern shit. Build engine games had similar limitations to those of the Doom engine but would improve on them (e.g. faking looking up and down by camera tilting, which could in theory be done in Doom too, or allowing sloped floor and dynamic level geometry).

The game data is stored in so called **WAD files** (short for *where's all the data*). While many things are hardcoded in the engine, such as the total number of levels or types of weapons, most other things such as textures, levels, color palettes, weapons and enemy sprites are in the WAD files and so can be replaced without having to mess with the engine itself. There are two types of WAD files (both however still come with the same .wad extension, they are distinguished only by the file magic number): IWAD (internal WAD) and PWAD (patch WAD). IWAD is the most important one, representing the base game, so for example Doom, Hexen and Freedoom will all have their own specific IWAD. Only one IWAD is loaded at any time. PWAD allows to add or modify things in the IWAD which makes it possible to easily correct bugs in the game data and make mods. Unlike with IWADs, multiple PWADs can be loaded at any time -- when loaded, a resource that's present in the PWAD will override the same resource in the base IWAD. All resources in the WAD files are stored as so called *lumps* which we may simply see as "blobs of data" or "files". A nice CLI tool for working with WADs is e.g. deutex.

Doom WAD (full version) is a bit over 11 MB in size (MD5 1cd63c5ddff1bf8ce844237f580e9cf3), Doom 2 WAD is over 14 MB (MD5 25e1459ca71d321525f84628f45ca8cd).

Indexed (palette) mode with "only" 256 colors was used for rendering. Precomputed color tables were used to make dimming of colors faster. Similarly a look up table was used for random number generation -- two independent pseudorandom generators are present, one is used for things such as visual effects while the other one is utilized purely for the game simulation so that it stays deterministic independently on graphics etc.

Doom also has a deterministic FPS-independent physics which allows for efficient recording of demos of its gameplay and creating tool assisted speedruns, i.e. the time step of game simulation is fixed (35 tics per second). Such demos can be played back in high quality while being minuscule in size and help us in many other ways, for example for verifying validity of speedruns. This is very nice and serves as an example of a well written engine (unlike later engines from the same creators, e.g. those of Quake games which lacked this feature -- here we can see how things get progressively shittier in computer technology as we go forward in time).

There is no antialiasing in the engine, i.e. aliasing can be noticed on far-away textures, but it is suppressed by the use of low-res textures and dimming far-away areas. There is also no edge smoothing (kind of misleadingly known as "antialiasing") in the geometry rendering, the engine is subpixel accurate in rendering of the top and bottoms of the walls, i.e. the line these boundaries form may result in rasterizing slightly different pixels even if the start and end pixel is the same, depending on the subpixel position of the start and endpoint -- this feature doesn't much help in static screenshots but makes animation nicer.

Some **interesting places in code**: `m_random.c:31`: pseudorandom number table; `i_main.c`: the C main function (for DOS); `d_main.c:354`: game loop; `r_main.c:870`: 3D rendering function. `am_map.c:992`: variable named `fuck` (the code contains total of 20 lines containing "fuck").

## See Also

- Anarch
- Freedoom
- Duke 3D
- Wolf 3D
- Cytadela
- Gloom (fun Amiga Doom clone)
- Quake
- Postal
- Blood
- Jedi engine
- Build engine
- Chasm: The Rift
- raycasting (not used in Doom but achieves similar look)
- Doomer
- Boomer