29 Menu & Config: Menu System
This tour covers Doom’s menu system, including its API, state management, data structures, rendering, and input handling.
Menu System API (m_menu.h)
The menu system API declarations in m_menu.h
define the core functions called during initialization and the main game loop: - Lines 38–55
Global State (m_menu.c)
Global variables used to display message overlays: - Lines 92–95
Menu activity flag: - menuactive
(line 126) indicates if a menu is open
Cursor state: - itemOn
tracks the selected menu item
- skullAnimCounter
controls cursor animation
Menu navigation: - currentMenu
tracks which menu is currently active
Menu Representation in Memory
Two main types: - menuitem_t
defines a single menu entry (lines 140–147) - menu_t
defines a menu structure (lines 158–163)
Top-level and nested menus: - MainMenu[]
= top-level entries (lines 250–255) - MainDef
= main menu layout/behavior (261–269) - EpiDef
= episode selection (292–299) - NewDef
= skill selection (324–332) - OptionsDef
= options submenu at (60,37) (364–372)
Rendering Functions (m_menu.c)
- M_DrawMainMenu
(856–859): draws the DOOM logo - M_DrawThermo
(1182–1186): thermometer UI - M_DrawEmptyCell
(1209–1212): unselected menu indicator - M_DrawSelCell
(1218–1221): selected menu cell - M_WriteText
(1297–1301): draws text - M_WriteText
(548–551): savegame labels - M_WriteText
(1773–1776): centered messages - M_Drawer
(1740–1743): main renderer
Integration with Game Loop (d_main.c)
- M_Drawer
is invoked from D_DoomLoop
: - First after rendering the 3D view (314–316) - Again after buffer prep (I_UpdateNoBlit
) to overlay menu (340–343)
Input Handling and Animation
- Arrow key navigation (1624–1631): skips disabled items - M_Ticker
(1835–1839): animates skull cursor
You’ve now seen how Doom’s menu system defines its API, manages state, lays out menu data, renders everything, handles input, and even animates the skull cursor. That concludes this tour.