Friday, September 15, 2023

Editing Doom, Section 2 (Patch a Graphic)

freedoom2.wad: MAP01

Guide Requirements

  • Freedoom (IWAD files)
  • Doom engine source port (executable)
  • Eureka Doom Editor (map editor)
  • SLADE (lump editor)
  • GIMP (image editor)

Please refer to Section 1 if you need information about obtaining the above software.

Remember, Freedoom is a pair of WADs containing maps, graphics, and sound. In this guide, we will borrow a graphic from freedoom2.wad, edit it, and import it into a new WAD which will replace this graphic in the game.

This replacement process is called patching—it is the fundamental idea behind a Patch WAD (PWAD). We will not actually change any data in freedoom2.wad.

Please note, there are key commands (shortcuts) for activating certain menu items in each of the programs in this guide. (Control-S for Save, for example.) Feel free to use shortcuts.

 

 

1. Identify a Graphic

In the map above, there is a wall texture featuring a rusty zig-zag pattern seen immediately at the start of MAP01. To locate this graphic, we will use Eureka Doom Editor.

When you first open Eureka, it may automatically display MAP01 from freedoom2.wad.

 

If not, go to FileOpen Map in the menu bar. Click Load and locate freedoom2.wad on your computer. Typically, the file is located wherever you unzipped Freedoom. 

If you installed Freedoom using the Debian repository, the WAD is located in /usr/share/games/doom

Click the MAP01 button.

Open freedoom2.wad and click MAP01.

Since the wall texture is located immediately at the start of the map, we can locate it by searching for the Player 1 Start

Select View ► Find/Replace from the menu.

Use the Find/Replace command.

  1. The Find panel is set to Things by default. If not, select Things.
  2. Click the Choose box. The Things panel will appear.
  3. Type PLAY into the Match field. The list will reduce to show the player starts.
  4. Click the green soldier graphic. (This is the Player 1 Start in Freedoom.)
  5. Click the Find button in the Find panel. The map will zoom in on the Player 1 Start in the map. You can zoom in even more using the mouse wheel.
  6. Close the Things panel and the Find panel by clicking their X buttons.
Searching for the player start.

We would like to view the interior of this room to inspect the wall texture. To place the viewing camera in this room, move the pointer into the room and type a single quote ('). A pink arrow will appear under the pointer.

Move the camera into the room.

Now switch to 3D view.

  1. Hit the Tab key. The Tab key toggles between the map and 3D view. 
  2. Press the Left Arrow (←) key to turn left.
  3. Tap the D key a few times to step right slightly until the wall is in view. 
  4. Hit the L key to select Linedef mode. 
  5. Click the far wall. 

Inspecting the wall texture in 3D view.

The graphic used on this wall will appear in the Linedef panel in the Sidedef section. The name is AQRUST08. Write down or memorize AQRUST08. (That's a zero-8.)



2. Locate the Graphic

To find which graphic lump this wall texture uses, use the SLADE map editor.

When you first open SLADE, it will ask you for a Base Resource Archive. This means an IWAD file. If you just downloaded Freedoom from the website, just point the file dialog to wherever you unzipped it. 

If you installed Freedoom using the Debian repository, the WAD is located at

/usr/share/games/doom/freedoom1.wad


Now we need to look in the actual freedoom2.wad file to find that graphic. Select File ► Open from the menu and open freedoom2.wad. SLADE will display the contents in a new tab.

To find the wall texture, we need to view the actual map of MAP01. Select Archive ► Map Editor from the menu. Select E1M1 and Open Map.

The location of the wall texture was right at the Player 1 Start. Referring to the in-game Automap (at the start of this section), we need to find a similar structure.

Use the mouse wheel to zoom in on the center left region of the map. The green circles are the player start locations. Right next to it is the target wall. Make sure you are in Lines Mode (the tiny yellow T symbol on the toolbar). 

Hover the pointer over this wall. You will see the graphic and its lump name appear in the lower right area. The example graphic we need to edit is named AQRUST08.

Write this name down or memorize it. Now close the Map Editor.

 

💀

 

Back in the Entry List view, click the Filter (funnel) icon in the lower left corner. Type the name of our graphic AQRUST08 (that's a zero-8). The list should reduce to just one line. Click the line to select.

Select GraphicExport as PNG from the menu. Save the graphic somewhere you can find it later. You may close SLADE for now.


💀

Editing the Graphic

Graphic opened in GIMP.

This guide uses GNU Image Manipulation Program (GIMP). It's a free alternative to Adobe Photoshop. Note, this is not a comprehensive guide on GIMP.

Open the AQRUST08.png file in GIMP.

Doom graphics are called indexed or paletted graphics, because they use a limited set of colors defined in a colormap. It's a good idea to use colors that already exist in the graphic's colormap because conversion to Doom's colormap will be more accurate later.

Show the Colormap.

Select Windows ► Dockable Dialogs ► Colormap. You should see a palette of colors appear.

Multiple region selection. Hold Shift key.

Region selected.
 

Let's fill the zig-zag in the center with a new color. We need to select the area to fill first. Select the Rectangle tool (or type an R). As you continuously hold the Shift key, click and drag out rectangles to fill the zig-zag shape.

Is Nukage Green an official color?

Before we fill the region, we need to select a foreground color. Just click it on the Colormap.


Finally, fill the region with green. Select Edit ► Fill with FG Color.

Using the Text tool.

If you like, use the Text tool (type a T), and add some warning text. Use the Text panel on the left to set the font, size, style, and color.

Once finished, select File ► Export As and save the graphic as a PNG file. Go ahead and overwrite the old AQRUST08.png file—we won't need it again.


💀

Import into SLADE

Create graphic markers.

Open SLADE again. Select File ► New Archive. Select Doom WAD Archive. Select Archive ► New Entry. Name the entry PP_START.

The Type will say Empty (Marker) by default. Click Create.


A marker will appear in green in the list. This means it is not saved to the file yet. Create another marker. Name the entry PP_END. Click Create.

Graphics must be imported between the markers in the list.

Click on PP_START. Select Archive 🠞 Import Files from the menu. Open the AQRUST08.png file. It should now appear between the two markers. You will also see your modified graphic appear in the preview area.

 

Convert graphic.

With AQRUST08 selected, choose Graphic 🠞 Convert to from the menu.

Convert to Doom Gfx.

This dialog will show how colors will convert. Click Convert.

Save the WAD file: File ► Save. Name the file test.wad. The entries will turn black, indicating they are saved to a file.



To load the WAD, and the modified graphic into Doom, at the terminal, type

doom test.wad

Hit the Esc key and start a New Game on whatever difficulty level. You should see the graphic replaced the moment the game starts.






Thursday, September 7, 2023

Editing Doom, Section 1 (Preface)

1993. Id Software. Doom.

A first person shooter that, in many respects, set the standard for first-person shooters. The now decades-long popularity of Doom is not only from the once-novel 3-D graphics, the gore and violence, or the networked multi-player facility. Doom has endured because of the modding community.

Modding Doom, that is, modifying graphics, building new maps, and changing other game assets, has been in practice virtually since the game's release.

John Carmack, programmer of the Doom engine, provided ways to mod the game from the beginning. Id Software officially released the engine source code in 1997. The modding community followed with source ports of the Doom engine that continue to this day.


During the mid-'90s, just about everyone playing Doom was using an Intel–MS-DOS system, better known as a PC, as it was (and continues to be) the largest operating system market. 

Versions of Doom were eventually ported to other platforms (including Macintosh) with varied success.

Around this time, the prevailing software to mod Doom game files were the Doom Editing Utilities or DEU, available only for MS-DOS. Community-built DEU was the ad-hoc alternative to the “official” DoomEd editor, which existed only on Id Software's NeXT machines.

Doom Editing Utilities (DEU) for MS-DOS.

DEU was for map editing, such as creating line-segment regions, setting their properties, and adding items and monsters, among other things. DEU later forked into other projects and currently exists as Eureka.


You may be surprised to learn that the Doom executable program does not actually contain any game data such as levels, graphics, or sound; it is only the engine. Instead, a WAD file holds all of these game parts. WAD stands for Where's All the Data?

The WAD file that comes with Doom (named DOOM.WAD) is called an Internal WAD or IWAD. This is the main game file that contains all of the game assets: maps, wall graphics, floor/ceiling graphics, monster graphics, item graphics, user interface graphics, sound effects, and music. Each of these elements in the WAD is called a lump.

To modify Doom, users create a new WAD to replace (patch) lumps in the IWAD when the game loads. This is called a Patch WAD or PWAD.

Both IWAD and PWAD types use the .WAD file extension, but internally, they are different.


WADs (PWADs) that completely replace all of the assets (maps, graphics, sound) in the game WAD (IWAD) are called total conversions. They can take hundreds of hours to make.

However, most community-made WADs (PWADs) out there are simply new game maps with a few different graphics or sounds. The PWAD replaces or adds to these elements that would ordinarily come from the main IWAD when the game starts.


Doom Engine Source Port

DSDA-Doom running the Freedoom Phase 2 WAD.

Playing Doom or something Doom-like on modern systems requires a Doom engine (an executable program). Doom engines built from the original opened source code are called source ports. They are free to use.

Popular source ports are ZDoom and PrBoom+. The modding community seems to highly regard GZDoom (a variant of ZDoom) because of the extra features for modded WADs, including ways to define new types of monsters and other objects.

Linux users may find the simplest approach is to install Freedoom from the Debian repository, as this includes a source port (currently DSDA-Doom), and the Freedoom WAD files. DSDA Doom is a variant of PrBoom+ (prboom-plus in the repository) and is fine for playing basic modded WADs. With a terminal open, type:

sudo apt install freedoom


Eureka Doom Editor

Typical Doom modders make maps, and there are some amazing ones out there. Currently, the most approachable and cross-platform mapping program is Eureka Doom Editor or simply Eureka. It is distantly related to DEU and shares many of the same features. For this guide, we will be using it to inspect, edit, and build maps.

Debian users will be pleased to know that Eureka is in the official repository. Note, Freedoom and PrBoom+ will accompany this install. Simply open a terminal and type:

sudo apt install eureka


SLADE

SLADE is the modern way to work with lumps in a WAD file. It's approachable, cross-platform, and has a GUI. There's even a map editor. For this guide, we will be using it to import and export files.

SLADE


If you are using macOS or Windows, visit the SLADE web site to download a compiled application. If you are using Linux (the author of SLADE recommends Debian), use the following sequence of bash terminal commands to install with apt

You must be root (superuser) or prefix each line with sudo:

mkdir -p /etc/apt/keyrings
wget http://debian.drdteam.org/drdteam.gpg -P /etc/apt/keyrings
echo -e "\ndeb [signed-by=/etc/apt/keyrings/drdteam.gpg] http://debian.drdteam.org/ stable multiverse" >> /etc/apt/sources.list
apt update
apt install slade

Description of Command Sequence

  1. Create keyrings directory, if it does not exist.
  2. Download the key file into /etc/apt/keyrings.
  3. Add a new line, key path and repository to sources.list.
  4. Update apt.
  5. Install SLADE.

Note: Linux install instructions exist on the SLADE web site, but some of the commands are now depreciated with newer Linux distributions. The above method was confirmed to work with Debian 12 "bookworm".

 

💀

Vocabulary

  • Doom engine: An executable program for playing WAD files.
  • WAD: File containing the game maps, graphics, sounds, and other objects. Stands for "Where's All the Data?" 
  • IWAD: Internal WAD, the main game file containing original artistic assets. Usually copyrighted. Not typically modified.
  • PWAD: Patch WAD. Contains custom maps, graphics, or sounds that add to or replace (patch) those from the IWAD at load time.
  • Lump: An entry in a WAD file. Can represent map parts, graphics, sounds, music, or other objects.
  • Source port: A Doom engine created from Id Software's opened source code.
  • Mod/Modding: Modifying or adding maps, graphics, sound, or other lumps in a WAD file.
  • Doom editor: Software for modding WAD files. Some software is for mapping: DEU, SLADE, Eureka, Ultimate Doom Builder. Some handle lumps: DeuTex, SLADE.

Bookin' It WIth Bookworm (Debian 12)

Debian 12 "bookworm" and I'm still using Motif. Shown are the contents of the .xinitrc and .Xresources files.

Looking back through time, I'm finding Linux has served me well all these years. Sometimes there's the need to use other operating systems; that's what VirtualBox is for. Debian continues to be the workhorse in my life.

Motif is one of those ghosts from Unix that is still an amazing window manager. But if you don't want just one window manager, a display manager like LightDM can facilitate this. For practical work, I use Xfce (which has a Motif theme available for download), as well as a desktop, file manager, and system settings controls.

Another top-notch environment is the Raspberry Pi OS (which uses Debian) using a very professional looking theme for LXDE and the PCMan file manager. It's the closest I've come to Macintosh System 7. When they come out with a 64-bit version, I'll be there to try it.