
I studied the vanilla source code of the 1992 Wolfenstein 3D game. Despite the fact that she is already 25 years old, and she is completely outdated for modern platforms, you can still compile it if you recreate the environment.
This requires only:
')
- Wolfenstein 3D source code.
 - Dosbox
 - Compiler Borland C ++ 3.1.
 - Wolfenstein 3D shareware (to borrow resources).
 
File system setup
Open the command line and create two folders, one for each of the required DOS disks:
cd ~ mkdir system cd system mkdir c mkdir a cd ~ 
Download files
- Download Borland 3.1 in 
system/a . - Download the source code Wolfenstein 3D in the 
system/c - We download VGA files to 
system/c (at the end of the article I will explain why this is necessary). 
  cd system/a curl -O http://fabiensanglard.net/Compile_Like_Its_1992/tools/BCPP31.zip cd ../c curl -O http://fabiensanglard.net/Compile_Like_Its_1992/tools/wolfsrc.zip curl -O http://fabiensanglard.net/Compile_Like_Its_1992/tools/vgafiles.zip 
Now all files are in the file system. Just to check, we enter:
  cd .. find ~/system 
You should have the following:
  /Users/fabiensanglard/system /Users/fabiensanglard/system/a /Users/fabiensanglard/system/a/BCPP31.zip /Users/fabiensanglard/system/c /Users/fabiensanglard/system/c/vgafiles.zip /Users/fabiensanglard/system/c/wolfsrc.zip 
Unpack everything
  cd ~/system/a unzip BCPP31.zip cd ~/system/c unzip vgafiles.zip unzip wolfsrc.zip 
Dosbox
Download and run 
DosBox :

We mount
Mount the file system, one folder for each of the disks:
  Z:/> mount c ~/system/c Z:/> mount a ~/system/a 
Install the compiler
It is time to install Borland C ++ 3.1:
  Z:\> a: A:\> cd BCPP31 A:\> install 

Press "enter" when selecting the source disk (drive A must be selected)

Leave all the default settings and select “Start Installation”:

Notifications warn you that you can’t find the Microsoft Windows folder, but we don’t need it, just hit enter.



Installing Wolfenstein 3D Source Code
The system works and has a compiler: it is time to unpack (again) the source code.
  A:\> c: C:\> cd\ C:\> install 

Let's enter "C"

Leave the default path: 
\WOLFSRC
Confirm ("Y") the creation of the directory.
Fits!

Compile
Launch Borland C ++ 3.1:
  C:\> cd\ C:\> cd borlandc C:\> cd bin C:\> bc.exe 

After clicking on OK, use the mouse or hotkeys to select Project → Open Project 
..\..\WOLFSRC\WOLF3D.PRJ :

Select Options → Directories and change the value as follows:
  Include Directories: C:\BORLANDC\INCLUDE Library Directories: C:\BORLANDC\LIB Ouptput Directories: OBJ Source Directories: C:\WOLFSRC 

Let's try to compile: Compile -> Build All

We get the error: “Cannot find executable TASM”

Let's exit Borland C ++, we need to configure PATH:
  C:\> CD .. C:\> PATH=C:\BORLANDC\BIN C:\> BC.EXE 
Try compiling again (Compile -> Build All):

Compilation was done, but a layout error occurred: “Unable to find OBJ file”, because the path to SIGNON.OBJ and GAMEPAL.OBJ in the project is incorrect.
They are noted in 
C:\SOURCE\WOLF\ :

Remove them from the project (Select Projext → Delete item). Add them again via PROJECT → Add Item .... Add 
WOLFSRC\OBJ\SIGNON.OBJ and 
WOLFSRC\OBJ\GAMEPAL.OBJ
Let's try to compile again (Compile → Build All)

It worked! But will the game start?

We get resources
Download the shareware version, or even better: buy Wolfenstein 3D as a full version.
  cd ~/system/c curl -O http://fabiensanglard.net/Compile_Like_Its_1992/tools/1wolf14.zip unzip 1wolf14.zip 
Let's go back to DosBox and install the game in 
C:\WOLF3D .
  C:\> c: C:\> cd \ C:\> cd 1wolf14 C:\1WOLF14> install 
After installing the game, copy the newly compiled .EXE file into the game folder,
  C:\> c: C:\> cd wolf3d C:\WOLF3D> copy WOLF3D.EXE WOLF3D.OLD C:\WOLF3D> copy ../WOLRSRC/WOLF.EXE 
Run the game
Let's try to run:
  C:\> cd wolf3d C:\WOLF3D> copy WOLF3D.EXE WOLF3D.OLD C:\WOLF3D> copy ../WOLRSRC/OBJ/WOLF3D.EXE . C:\WOLF3D> WOLF3D.EXE 
Hmm, it looks weird ...

Oh…

What?

I do not remember that the game was so ...

So, somewhere an error occurred!
What happened?
The point is in the production pipeline of the game and how it was used by the engine. When Adrian Carmack and Kevin Cloud finished working on all the graphic files, they used the IGRABed tool to package them. The result was 3 + 2 files.
- VGAHEAD.WL1
 - VGAGRAPH.WL1
 - VGADICT.WL1
 
The VGAHEAD file is an index containing pointers to VGAGRAPH, which stores data compressed by the Huffman algorithm. VGADICT contains Huffman dictionaries for unpacking data.
Two other files created:
compiled into the engine, as shown in the figure below:

What are the 
.H and 
.EQU files 
.EQU ? In short, they allow you to access by name. When IGRABed collects all the files, it also creates an enumeration (enum) with the corresponding indexes:
GRE.H  enum{ H_WOLFLOGOPIC GETPSYCHEDPIC L_GUYPIC . . } graphicnums 
GRE.EQU  H_WOLFLOGOPIC = 0 GETPSYCHEDPIC = 1 L_GUYPIC = 2 
Thus, when the engine requests the desired resource, it can use a logical name (L_GUYPIC), rather than a “magic number” (2).
This means that the engine was released with 
hard-coded image indices in VGA files. Since the resources and the code base evolved after the release of wolf3D shareware (in Spear of Destiny), the new compiled game indexes do not match the location of the source resource files.
Start the game (again)
Fortunately, this problem has a simple solution: someone re-generated VGA resources to match the indexes in the .H and .EQU files released with the source code. Simply copy these files (if you use resources from the shareware version, you will need to change the file extension from .WL6 to .WL1).
  C:\> copy C:\vgafiles\VGADICT.WL6 C:\WOLF3D\VGADICT.WL1 C:\> copy C:\vgafiles\VGAGRAPH.WL6 C:\WOLF3D\VGAGRAPH.WL1 C:\> copy C:\vgafiles\VGAHEAD.WL6 C:\WOLF3D\VGAHEAD.WL1 
Let's try again:
  C:\WOLF3D> WOLF3D.EXE 
Works!

But we still haven't finished!
VGA frame buffer and screen aspect ratio
This may not be obvious to people who have never seen the original game, but the above picture from DosBox does not exactly coincide with what the players saw in 1992. The VGA frame buffer had a size of 320x200, but for a CRT monitor the aspect ratio is 4: 3. This means that the frame buffer when stretched to the monitor vertically stretched. DosBox has an option to compensate for this:
  vi ~/Library/Preferences/DOSBox\ 0.74\ Preferences [render] # frameskip:  ,  DOSBox   . # aspect:    .      ,       ! # scaler:   /   . #    'forced',  scaler ,      . #  : none, normal2x, normal3x, advmame2x, advmame3x, advinterp2x, advinterp3x, ... frameskip=0 aspect=false scaler=normal2x 
Change the aspect value to 
true .
Let's try again:
  C:\WOLF3D> WOLF3D.EXE 
Finally it worked!


