For a list of code tutorials, see Coding Tutorials

Coding Questions

Since 1999 when John Carmack released the source code for Wolfenstein 3D, modding has taken a turn for the innovative, as users can finetune and improve the engine in a seemingly infinite amount of ways.

Episode and Difficulty Select Screens

The Episode and Difficulty names, as well as most other menu labels can be edited in the FOREIGN.H file.

As an example, here's the code that decides the text for the New Game menu option:

#define STR_NG	"New Game"

To change how it appears in game, simply change the text within the quotation marks. Do not change the string name that comes before it.

Wolfenstein 3D measures time in tics, a single tic being 1/70 of a second.

This is a typedef struct that stores a collection of variables to track information about the Player, including but not limited to ammo count, level ratio information, and current map. It is found in WL_DEF.H, and looks as follows in Wolf4SDL (The DOS version varies only very slightly).

// gamestate structure

typedef struct
    short       difficulty;
    short       mapon;
    int32_t     oldscore,score,nextextra;
    short       lives;
    short       health;
    short       ammo;
    short       keys;
    weapontype  bestweapon,weapon,chosenweapon;

    short       faceframe;
    short       attackframe,attackcount,weaponframe;

    short       episode,secretcount,treasurecount,killcount,
    int32_t     TimeCount;
    int32_t     killx,killy;
    boolean     victoryflag;            // set during victory animations
} gametype;

If you want to add new things for the game to track (for example, portable medkits or a second ammo type), this is the best place to call those new variables, as the gamestate structure as a whole is saved to the SAVGAME file, as referenced in the SaveTheGame and LoadTheGame booleans called in WL_MAIN.CPP.

This can occur because your changes have exceeded the memory limits for DOS. Each addition to the engine can take up more memory, and in the original Wolf3D source code there is initially only 63 bytes to work with.

You can read more about Abnormal Program Terminations on AReyeP and MCS' Wolfenstein 3D Page, and go to the Saving Memory section to find ways to save memory that have been shared by the community.

If you don't want to worry about memory limits (at least for a while), Chris Chokan released a fork of the DOS source code with many changes to save memory, and is an option for building your project.

  • coding.txt
  • Last modified: 2020/04/03 19:16
  • by zombie