MiniDoom

src/w_wad.ml

Implements WAD/lump lookup, caching, and resource loading helpers.

Package
(global)
Reachable
Yes

Imports

Declarations

_W_AddCachedDataName

function _W_AddCachedDataName(data, name)

Appends one data/name pair to the cached lump name lookup without using concatenation.

ParameterTypeDefaultDescription
datadynamic—Binary or structured data to process.
namedynamic—Resource or object name to resolve.

View source

_W_AddFilesFromArgv

function _W_AddFilesFromArgv()

Adds files from argument entries to the WAD resource.

View source

_W_AddLoadedFile

inline function _W_AddLoadedFile(path, data)

Appends an in-memory WAD file record and returns the stable index stored by its lump directory entries.

ParameterTypeDefaultDescription
pathdynamic—Filesystem path to process.
datadynamic—Binary or structured data to process.

View source

_W_CACHE_NULL_PTR

const _W_CACHE_NULL_PTR = -1

Defines w cache null ptr for the w wad subsystem.

View source

_W_CopyBytes

inline function _W_CopyBytes(b, off, n)

Returns an independent byte slice for a requested WAD-file range.

ParameterTypeDefaultDescription
bdynamic—Second input operand.
offdynamic—Zero-based byte or element offset.
ndynamic—Number of values to process.

View source

_W_ExtractFileBase

function _W_ExtractFileBase(path)

Extracts an uppercase, extension-free filename into an eight-byte lump name and rejects overlong bases.

ParameterTypeDefaultDescription
pathdynamic—Filesystem path to process.

View source

_W_files

_W_files

Stores the w files collection used by the w wad subsystem.

View source

_W_IntToString

function _W_IntToString(v)

Formats integer values for WAD diagnostics without implicit stringification.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.

View source

_W_IsHDWADData

inline function _W_IsHDWADData(data)

Validates the minimum header length and four-byte MDHD signature of an in-memory HDWAD package.

ParameterTypeDefaultDescription
datadynamic—Binary or structured data to process.

View source

_W_IsWadFilename

inline function _W_IsWadFilename(path)

Recognizes a case-insensitive .wad suffix without allocating a normalized path copy.

ParameterTypeDefaultDescription
pathdynamic—Filesystem path to process.

View source

_W_Name8Equals

inline function _W_Name8Equals(a, b)

Compares two canonical eight-byte lump names without string allocation.

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

View source

_W_Name8FromString

inline function _W_Name8FromString(name)

Uppercases, truncates, and zero-pads a string to Doom's fixed eight-byte lump-name representation.

ParameterTypeDefaultDescription
namedynamic—Resource or object name to resolve.

View source

_W_Name8ToString

function _W_Name8ToString(name)

Converts an internal eight-byte lump name to a safe display string.

ParameterTypeDefaultDescription
namedynamic—Resource or object name to resolve.

View source

_W_profile_count

_W_profile_count

Tracks the mutable w profile count value used by the w wad subsystem.

View source

_W_profile_info

_W_profile_info

Stores the w profile info collection used by the w wad subsystem.

View source

_W_ReadI32LE

inline function _W_ReadI32LE(b, off)

Decodes one signed 32-bit little-endian field from a WAD header or directory entry.

ParameterTypeDefaultDescription
bdynamic—Second input operand.
offdynamic—Zero-based byte or element offset.

View source

_W_RememberCachedDataName

function _W_RememberCachedDataName(data, name)

Associates cached lump bytes with a known name without touching lumpinfo metadata.

ParameterTypeDefaultDescription
datadynamic—Binary or structured data to process.
namedynamic—Resource or object name to resolve.

View source

_W_SlotEmpty

inline function _W_SlotEmpty(slot)

Tests the cache-slot convention in which empty, void, or negative pointer values mean no resident lump.

ParameterTypeDefaultDescription
slotdynamic—Slot value supplied to `_W_SlotEmpty`.

View source

_W_ToIntOr

function _W_ToIntOr(v, fallback)

Converts int or values for the WAD resource.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.
fallbackdynamic—Value returned when the requested conversion or lookup is unavailable.

View source

_W_ToPathString

inline function _W_ToPathString(v)

Converts path string values for the WAD resource.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.

View source

_W_ToUpperAscii

inline function _W_ToUpperAscii(s)

Uppercases ASCII lump-name characters in a newly allocated string while preserving nonletters.

ParameterTypeDefaultDescription
sdynamic—S value supplied to `_W_ToUpperAscii`.

View source

ExtractFileBase

function ExtractFileBase(path, dest)

Copies a canonical filename base into a byte buffer or reference slot for compatibility with the original API.

ParameterTypeDefaultDescription
pathdynamic—Filesystem path to process.
destdynamic—Dest value supplied to `ExtractFileBase`.

View source

filelength

inline function filelength(handle)

Returns the byte length of a validated loaded-file handle.

ParameterTypeDefaultDescription
handledynamic—Handle value supplied to `filelength`.

View source

filelump_t struct

lumpcache

lumpcache

Holds the optional lumpcache resource used by the w wad subsystem.

View source

lumpinfo

lumpinfo

Holds the optional lumpinfo resource used by the w wad subsystem.

View source

lumpinfo_t struct

numlumps

numlumps

Tracks the mutable numlumps value used by the w wad subsystem.

View source

reloadfile

reloadfile

Tracks the mutable reloadfile value used by the w wad subsystem.

View source

reloadlump

reloadlump

Tracks the mutable reloadlump value used by the w wad subsystem.

View source

reloadname

reloadname

Holds the optional reloadname resource used by the w wad subsystem.

View source

strupr

inline function strupr(s)

Exposes allocation-safe ASCII uppercase conversion under the legacy WAD API name.

ParameterTypeDefaultDescription
sdynamic—S value supplied to `strupr`.

View source

W_AddFile

function W_AddFile(filename)

Loads a WAD or single-lump file, validates its directory, and appends normalized entries in load-order override precedence.

ParameterTypeDefaultDescription
filenamedynamic—Filesystem name of the target resource.

View source

W_CacheLumpName

function W_CacheLumpName(name, tag)

Resolves a canonical lump name, ensures its data is resident under the requested tag, and preserves name metadata for patch users.

ParameterTypeDefaultDescription
namedynamic—Resource or object name to resolve.
tagdynamic—Zone-memory or resource-lifetime tag.

View source

W_CacheLumpNum

function W_CacheLumpNum(lump, tag)

Allocates and fills a lump's zone-cache slot on first use, retags resident data, and records patch-name identity.

ParameterTypeDefaultDescription
lumpdynamic—Lump value supplied to `W_CacheLumpNum`.
tagdynamic—Zone-memory or resource-lifetime tag.

View source

W_CheckNumForName

function W_CheckNumForName(name)

Searches the merged directory backward so later WADs override earlier lumps with the same canonical name.

ParameterTypeDefaultDescription
namedynamic—Resource or object name to resolve.

View source

W_GetCachedLumpPtr

function W_GetCachedLumpPtr(lump)

Returns a resident lump's zone pointer without loading it, or the null-pointer sentinel for invalid or empty slots.

ParameterTypeDefaultDescription
lumpdynamic—Lump value supplied to `W_GetCachedLumpPtr`.

View source

W_GetNumForName

function W_GetNumForName(name)

Resolves a lump name to its overriding directory index and raises a fatal error when absent.

ParameterTypeDefaultDescription
namedynamic—Resource or object name to resolve.

View source

W_HDWAD_MAX_VERSION

const W_HDWAD_MAX_VERSION = 6

Defines the maximum w hdwad max version accepted by the w wad subsystem.

View source

W_HDWAD_MIN_VERSION

const W_HDWAD_MIN_VERSION = 1

Defines the minimum w hdwad min version accepted by the w wad subsystem.

View source

W_InitFile

function W_InitFile(filename)

Initializes the merged lump directory and cache from a single WAD path.

ParameterTypeDefaultDescription
filenamedynamic—Filesystem name of the target resource.

View source

W_InitMultipleFiles

function W_InitMultipleFiles(filenames)

Clears prior resource state, loads each configured WAD in order, validates the result, and creates empty zone-cache slots.

ParameterTypeDefaultDescription
filenamesdynamic—Filenames value supplied to `W_InitMultipleFiles`.

View source

W_LumpLength

function W_LumpLength(lump)

Validates a lump index and returns its directory byte size.

ParameterTypeDefaultDescription
lumpdynamic—Lump value supplied to `W_LumpLength`.

View source

W_NameForCachedData

function W_NameForCachedData(data)

Returns the WAD lump name for a cached byte view, when known.

ParameterTypeDefaultDescription
datadynamic—Binary or structured data to process.

View source

W_NumLumps

function W_NumLumps()

Returns the current merged directory size after all WAD and single-lump files have been added.

View source

W_Profile

function W_Profile()

Samples cache residency for every lump and accumulates a per-snapshot history used to inspect resource-cache behavior.

View source

W_ReadLump

function W_ReadLump(lump, dest)

Copies one validated lump byte range from its owning loaded file into the caller's destination buffer.

ParameterTypeDefaultDescription
lumpdynamic—Lump value supplied to `W_ReadLump`.
destdynamic—Dest value supplied to `W_ReadLump`.

View source

W_Reload

function W_Reload()

Re-reads the designated reloadable WAD, invalidates its resident cache entries, and updates directory positions and sizes in place.

View source

wad_cached_patch_bytes

wad_cached_patch_bytes

Stores the wad cached patch bytes collection used by the w wad subsystem.

View source

wad_cached_patch_last_data

wad_cached_patch_last_data

Holds the optional wad cached patch last data resource used by the w wad subsystem.

View source

wad_cached_patch_last_name

wad_cached_patch_last_name

Stores the mutable wad cached patch last name text used by the w wad subsystem.

View source

wad_cached_patch_names

wad_cached_patch_names

Stores the wad cached patch names collection used by the w wad subsystem.

View source

wadfile_t struct

wadinfo_t struct