MiniDoom

src/g_game.ml

Implements high-level game loop control, transitions, and session state.

Package
(global)
Reachable
Yes

Imports

Declarations

_G_ButtonIsDown

inline function _G_ButtonIsDown(arr, idx)

Reads one checked mouse/joystick button from an arbitrary button sequence.

ParameterTypeDefaultDescription
arrdynamic—Arr value supplied to `_G_ButtonIsDown`.
idxdynamic—Zero-based element or table index.

View source

_G_CopyFrags

function _G_CopyFrags(fr)

Copies a frag row into a fixed MAXPLAYERS array without retaining the caller's storage.

ParameterTypeDefaultDescription
frdynamic—Fr value supplied to `_G_CopyFrags`.

View source

_G_cpars

_G_cpars

Stores the g cpars collection used by the g game subsystem.

View source

_G_dclicks

_G_dclicks

Tracks the mutable g dclicks value used by the g game subsystem.

View source

_G_defDemo

_G_defDemo

Stores the mutable g def demo text used by the g game subsystem.

View source

_G_defEpisode

_G_defEpisode

Tracks the mutable g def episode value used by the g game subsystem.

View source

_G_defMap

_G_defMap

Tracks the mutable g def map value used by the g game subsystem.

View source

_G_defSkill

_G_defSkill

Exposes `skill_t.sk_medium` through the legacy `_G_defSkill` alias.

View source

_G_demo_p

_G_demo_p

Tracks the mutable g demo p value used by the g game subsystem.

View source

_G_demoend

_G_demoend

Tracks the mutable g demoend value used by the g game subsystem.

View source

_G_DemoReadU8

inline function _G_DemoReadU8()

Consumes one unsigned demo byte, returning zero past the buffer while keeping the cursor monotonic.

View source

_G_DemoWriteU8

inline function _G_DemoWriteU8(v)

Appends one masked byte to the bounded demo recording buffer and advances its cursor.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.

View source

_G_devAutoFire

_G_devAutoFire

Tracks whether g dev auto fire is active in the g game subsystem.

View source

_G_devAutoForward

_G_devAutoForward

Tracks whether g dev auto forward is active in the g game subsystem.

View source

_G_devAutoTurn

_G_devAutoTurn

Tracks whether g dev auto turn is active in the g game subsystem.

View source

_G_devAutoUse

_G_devAutoUse

Tracks whether g dev auto use is active in the g game subsystem.

View source

_G_devAutoUseTicker

_G_devAutoUseTicker

Tracks the mutable g dev auto use ticker value used by the g game subsystem.

View source

_G_devInputInit

_G_devInputInit

Tracks whether g dev input init is active in the g game subsystem.

View source

_G_devPrintTicker

_G_devPrintTicker

Tracks the mutable g dev print ticker value used by the g game subsystem.

View source

_G_EnsureDir

function _G_EnsureDir(path)

Creates a directory if it is missing.

ParameterTypeDefaultDescription
pathdynamic—Filesystem path to process.

View source

_G_EnsureInputState

function _G_EnsureInputState()

Guarantees fixed keyboard, mouse, and joystick state buffers before responder or ticcmd access.

View source

_G_EnvString

function _G_EnvString(name)

Reads a Windows environment variable as a MiniLang string.

ParameterTypeDefaultDescription
namedynamic—Resource or object name to resolve.

View source

_G_IDiv

inline function _G_IDiv(a, b)

Truncates movement/input quotients toward zero and returns zero for invalid divisors.

ParameterTypeDefaultDescription
adynamic—First input operand.
bdynamic—Second input operand.

View source

_G_InitDevInputTweaks

function _G_InitDevInputTweaks()

Parses developer auto-input flags once and seeds their persistent movement/fire toggles.

View source

_G_joybuttons

_G_joybuttons

Stores the g joybuttons collection used by the g game subsystem.

View source

_G_joyxmove

_G_joyxmove

Tracks the mutable g joyxmove value used by the g game subsystem.

View source

_G_joyymove

_G_joyymove

Tracks the mutable g joyymove value used by the g game subsystem.

View source

_G_keydown

_G_keydown

Tracks the mutable g keydown value used by the g game subsystem.

View source

_G_KeyIndex

inline function _G_KeyIndex(k)

Rejects key codes outside the fixed input-state byte table.

ParameterTypeDefaultDescription
kdynamic—K value supplied to `_G_KeyIndex`.

View source

_G_KeyIsDown

inline function _G_KeyIsDown(k)

Reads one checked keyboard state bit from the current input snapshot.

ParameterTypeDefaultDescription
kdynamic—K value supplied to `_G_KeyIsDown`.

View source

_G_loadName

_G_loadName

Stores the mutable g load name text used by the g game subsystem.

View source

_G_mousebuttons

_G_mousebuttons

Stores the g mousebuttons collection used by the g game subsystem.

View source

_G_mousex

_G_mousex

Tracks the mutable g mousex value used by the g game subsystem.

View source

_G_mousey

_G_mousey

Tracks the mutable g mousey value used by the g game subsystem.

View source

_G_pars

_G_pars

Stores the g pars collection used by the g game subsystem.

View source

_G_ParTimeTics

function _G_ParTimeTics(episode, map)

Looks up the vanilla par time for the active episode and map in game tics.

ParameterTypeDefaultDescription
episodedynamic—Episode value supplied to `_G_ParTimeTics`.
mapdynamic—Map value supplied to `_G_ParTimeTics`.

View source

_G_PathBaseName

function _G_PathBaseName(path)

Extracts the final filename component from a WAD path.

ParameterTypeDefaultDescription
pathdynamic—Filesystem path to process.

View source

_G_SanitizeSaveDirName

function _G_SanitizeSaveDirName(name)

Converts a WAD filename into a safe directory name.

ParameterTypeDefaultDescription
namedynamic—Resource or object name to resolve.

View source

_G_saveDesc

_G_saveDesc

Stores the mutable g save desc text used by the g game subsystem.

View source

_G_SaveDir

function _G_SaveDir()

Resolves and creates the per-WAD savegame directory.

View source

_G_SaveFileName

function _G_SaveFileName(slot)

Builds the per-WAD savegame path under %APPDATA%\MiniDoom.

ParameterTypeDefaultDescription
slotdynamic—Slot value supplied to `_G_SaveFileName`.

View source

_G_saveSlot

_G_saveSlot

Tracks the mutable g save slot value used by the g game subsystem.

View source

_G_ShowLoadingFrame

function _G_ShowLoadingFrame(text)

Presents a loading label and forces one renderer/event pulse during synchronous map setup.

ParameterTypeDefaultDescription
textdynamic—Text to process.

View source

_G_turnheld

_G_turnheld

Tracks the mutable g turnheld value used by the g game subsystem.

View source

angleturn

angleturn

Stores the angleturn collection used by the g game subsystem.

View source

demobuffer

demobuffer

Holds the optional demobuffer resource used by the g game subsystem.

View source

DEMOMARKER

const DEMOMARKER = 128

Defines demomarker for the g game subsystem.

View source

demoname

demoname

Stores the mutable demoname text used by the g game subsystem.

View source

forwardmove

forwardmove

Stores the forwardmove collection used by the g game subsystem.

View source

G_BeginRecording

function G_BeginRecording()

Writes the deterministic demo header and arms command recording for subsequent tics.

View source

G_BuildTiccmd

function G_BuildTiccmd(cmd)

Samples current controls into a bounded Doom ticcmd, including pause/save special commands.

ParameterTypeDefaultDescription
cmddynamic—Cmd value supplied to `G_BuildTiccmd`.

View source

G_CheckDemoStatus

function G_CheckDemoStatus()

Ends active demo recording/playback flags and reports that the transition was handled.

View source

G_CheckSpot

function G_CheckSpot(playernum, mthing)

Rejects occupied multiplayer spawn points using the current player mobj as collision probe.

ParameterTypeDefaultDescription
playernumdynamic—Index identifying player.
mthingdynamic—Mthing value supplied to `G_CheckSpot`.

View source

G_ClearInputState

function G_ClearInputState()

Releases every latched gameplay control when an exclusive UI captures input.

View source

G_CmdChecksum

function G_CmdChecksum(cmd)

Folds all serialized ticcmd fields into the consistency checksum used by demo/network checks.

ParameterTypeDefaultDescription
cmddynamic—Cmd value supplied to `G_CmdChecksum`.

View source

G_CreateDirectoryW

extern function G_CreateDirectoryW(path as wstr, security as ptr) from "kernel32.dll" symbol "CreateDirectoryW" returns bool

Creates a directory for per-WAD savegame storage.

ParameterTypeDefaultDescription
pathwstr—Filesystem path to process.
securityptr—Optional native security-attributes pointer.

Returns: The resulting directory for per-WAD savegame storage.

View source

G_DeathMatchSpawnPlayer

function G_DeathMatchSpawnPlayer(playernum)

Tries random unoccupied deathmatch starts before falling back to the player's cooperative start.

ParameterTypeDefaultDescription
playernumdynamic—Index identifying player.

View source

G_DeferedInitNew

function G_DeferedInitNew(skill, episode, map)

Stores a requested skill/episode/map triple for execution at the next game-action boundary.

ParameterTypeDefaultDescription
skilldynamic—Skill value supplied to `G_DeferedInitNew`.
episodedynamic—Episode value supplied to `G_DeferedInitNew`.
mapdynamic—Map value supplied to `G_DeferedInitNew`.

View source

G_DeferedPlayDemo

function G_DeferedPlayDemo(demo)

Queues a named demo lump for playback on the next game-action pass.

ParameterTypeDefaultDescription
demodynamic—Demo value supplied to `G_DeferedPlayDemo`.

View source

G_DoCompleted

function G_DoCompleted()

Finalizes player totals, resolves the next map, builds wminfo, and enters intermission.

View source

G_DoLoadGame

function G_DoLoadGame()

Validates a save header, rebuilds the map, and restores archived players, world, thinkers, and specials.

View source

G_DoLoadLevel

function G_DoLoadLevel()

Clears per-level player state, runs map setup, and starts the status bar, HUD, and renderer view.

View source

G_DoNewGame

function G_DoNewGame()

Consumes the deferred new-game parameters and clears the pending game action.

View source

G_DoPlayDemo

function G_DoPlayDemo()

Parses a demo header, configures recorded game flags/players, and starts playback on its map.

View source

G_DoReborn

function G_DoReborn(playernum)

Respawns a dead player at a valid deathmatch or cooperative start while preserving netgame rules.

ParameterTypeDefaultDescription
playernumdynamic—Index identifying player.

View source

G_DoSaveGame

function G_DoSaveGame()

Saves do Save Game state for the gameplay system.

View source

G_DoWorldDone

function G_DoWorldDone()

Applies the intermission's next-map result and synchronously loads the destination level.

View source

G_ExitLevel

function G_ExitLevel()

Queues normal map completion while clearing any previously selected secret-exit route.

View source

G_GetEnvironmentVariableW

extern function G_GetEnvironmentVariableW(name as wstr, buffer as bytes, size as int) from "kernel32.dll" symbol "GetEnvironmentVariableW" returns int

Reads Windows environment variables for user-specific savegame storage.

ParameterTypeDefaultDescription
namewstr—Resource or object name to resolve.
bufferbytes—Buffer that supplies or receives data.
sizeint—Requested size in bytes or elements.

Returns: The requested Windows environment variables for user-specific savegame storage.

View source

G_InitNew

function G_InitNew(skill, episode, map)

Commits skill/map selection, resets player run state, and queues the selected level for loading.

ParameterTypeDefaultDescription
skilldynamic—Skill value supplied to `G_InitNew`.
episodedynamic—Episode value supplied to `G_InitNew`.
mapdynamic—Map value supplied to `G_InitNew`.

View source

G_InitPlayer

function G_InitPlayer(playernum)

Resets one player's counters, view state, inventory defaults, and transient powers for a new run.

ParameterTypeDefaultDescription
playernumdynamic—Index identifying player.

View source

G_LoadGame

function G_LoadGame(name)

Records a save path and defers deserialization to the central game-action dispatcher.

ParameterTypeDefaultDescription
namedynamic—Resource or object name to resolve.

View source

G_PlayDemo

function G_PlayDemo(name)

Stores the requested demo lump and defers playback setup through the game-action dispatcher.

ParameterTypeDefaultDescription
namedynamic—Resource or object name to resolve.

View source

G_PlayerFinishLevel

function G_PlayerFinishLevel(playernum)

Controls player Finish Level transitions in the gameplay system.

ParameterTypeDefaultDescription
playernumdynamic—Index identifying player.

View source

G_PlayerReborn

function G_PlayerReborn(playernum)

Reinitializes a dead player loadout while preserving accumulated level/frags statistics.

ParameterTypeDefaultDescription
playernumdynamic—Index identifying player.

View source

G_ProcessGameActionOnly

function G_ProcessGameActionOnly()

Processes deferred game actions while skipping gameplay tick simulation.

View source

G_ProcessPendingGameAction

function G_ProcessPendingGameAction()

Executes deferred game actions without advancing world simulation.

View source

G_ReadDemoTiccmd

function G_ReadDemoTiccmd(cmd)

Decodes one four-byte Doom demo command or terminates playback at the marker/end of buffer.

ParameterTypeDefaultDescription
cmddynamic—Cmd value supplied to `G_ReadDemoTiccmd`.

View source

G_RecordDemo

function G_RecordDemo(name)

Allocates a recording buffer, writes the Doom demo header, and marks play as non-user recording.

ParameterTypeDefaultDescription
namedynamic—Resource or object name to resolve.

View source

G_Responder

function G_Responder(ev)

Applies keyboard/mouse/joystick events and handles screenshot, pause, and spy controls.

ParameterTypeDefaultDescription
evdynamic—Input event to process.

View source

G_SaveGame

function G_SaveGame(slot, description)

Stores a slot/description pair and defers serialization to the central game-action dispatcher.

ParameterTypeDefaultDescription
slotdynamic—Slot value supplied to `G_SaveGame`.
descriptiondynamic—Description value supplied to `G_SaveGame`.

View source

G_ScreenShot

function G_ScreenShot()

Queues a uniquely named PCX screenshot through the deferred action system.

View source

G_SecretExitLevel

function G_SecretExitLevel()

Queues normal map completion and clears any pending secret-exit route.

View source

G_Ticker

function G_Ticker()

Dispatches pending actions, net respawns, and exactly one subsystem ticker for the current gamestate.

View source

G_TimeDemo

function G_TimeDemo(name)

Starts timed demo playback with rendering/tic counters reset for benchmark reporting.

ParameterTypeDefaultDescription
namedynamic—Resource or object name to resolve.

View source

G_WorldDone

function G_WorldDone()

Advances from intermission to the next level or commercial finale route.

View source

G_WriteDemoTiccmd

function G_WriteDemoTiccmd(cmd)

Encodes one ticcmd into the four-byte Doom demo format or stops cleanly near buffer capacity.

ParameterTypeDefaultDescription
cmddynamic—Cmd value supplied to `G_WriteDemoTiccmd`.

View source

gameaction

gameaction

Exposes `gameaction_t.ga_nothing` through the legacy `gameaction` alias.

View source

joybfire

joybfire

Tracks the mutable joybfire value used by the g game subsystem.

View source

joybspeed

joybspeed

Tracks the mutable joybspeed value used by the g game subsystem.

View source

joybstrafe

joybstrafe

Tracks the mutable joybstrafe value used by the g game subsystem.

View source

joybuse

joybuse

Tracks the mutable joybuse value used by the g game subsystem.

View source

key_down

key_down

Tracks the mutable key down value used by the g game subsystem.

View source

key_fire

key_fire

Tracks the mutable key fire value used by the g game subsystem.

View source

key_left

key_left

Tracks the mutable key left value used by the g game subsystem.

View source

key_right

key_right

Tracks the mutable key right value used by the g game subsystem.

View source

key_speed

key_speed

Tracks the mutable key speed value used by the g game subsystem.

View source

key_strafe

key_strafe

Tracks the mutable key strafe value used by the g game subsystem.

View source

key_strafeleft

key_strafeleft

Tracks the mutable key strafeleft value used by the g game subsystem.

View source

key_straferight

key_straferight

Tracks the mutable key straferight value used by the g game subsystem.

View source

key_up

key_up

Tracks the mutable key up value used by the g game subsystem.

View source

key_use

key_use

Tracks the mutable key use value used by the g game subsystem.

View source

MAXPLMOVE

MAXPLMOVE

Tracks the mutable maxplmove value used by the g game subsystem.

View source

mousebfire

mousebfire

Tracks the mutable mousebfire value used by the g game subsystem.

View source

mousebforward

mousebforward

Tracks the mutable mousebforward value used by the g game subsystem.

View source

mousebstrafe

mousebstrafe

Tracks the mutable mousebstrafe value used by the g game subsystem.

View source

netdemo

netdemo

Tracks whether netdemo is active in the g game subsystem.

View source

NUMKEYS

const NUMKEYS = 256

Defines the numkeys count used by the g game subsystem.

View source

secretexit

secretexit

Tracks whether secretexit is active in the g game subsystem.

View source

sendpause

sendpause

Tracks whether sendpause is active in the g game subsystem.

View source

sendsave

sendsave

Tracks whether sendsave is active in the g game subsystem.

View source

sidemove

sidemove

Stores the sidemove collection used by the g game subsystem.

View source

SLOWTURNTICS

const SLOWTURNTICS = 6

Defines slowturntics for the g game subsystem.

View source

starttime

starttime

Tracks the mutable starttime value used by the g game subsystem.

View source

timingdemo

timingdemo

Tracks whether timingdemo is active in the g game subsystem.

View source

TURBOTHRESHOLD

const TURBOTHRESHOLD = 50

Defines turbothreshold for the g game subsystem.

View source

VERSIONSIZE

const VERSIONSIZE = 16

Defines versionsize for the g game subsystem.

View source