MiniDoom

src/m_fixed.ml

Implements Doom's signed 16.16 fixed-point multiply and divide with explicit 32-bit wrap, saturation, and zero handling.

Package
(global)
Reachable
Yes

Imports

Declarations

_absS32

inline function _absS32(x)

Returns a signed 32-bit magnitude while saturating the unrepresentable INT32_MIN case.

ParameterTypeDefaultDescription
xdynamic—Horizontal map- or screen-space coordinate.

View source

_idivS32

inline function _idivS32(a, b)

Returns a signed integer quotient truncated toward zero, or zero for invalid operands and a zero divisor.

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

View source

_s32

function _s32(x)

Reinterprets the low 32 bits of an integer as a signed two's-complement value.

ParameterTypeDefaultDescription
xdynamic—Horizontal map- or screen-space coordinate.

View source

_S32_MAX

const _S32_MAX = 2147483647

Defines the maximum s32 max accepted by the m fixed subsystem.

View source

_S32_MIN

const _S32_MIN = -2147483648

Defines the minimum s32 min accepted by the m fixed subsystem.

View source

_u32

inline function _u32(x)

Normalizes an integer to its unsigned 32-bit representation.

ParameterTypeDefaultDescription
xdynamic—Horizontal map- or screen-space coordinate.

View source

FixedDiv

function FixedDiv(a, b)

Divides two signed 16.16 values, saturating results whose shifted numerator would overflow signed 32-bit range.

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

View source

FixedDiv2

inline function FixedDiv2(a, b)

Scales a signed numerator by FRACUNIT, divides with truncation toward zero, and reports a zero divisor through I_Error.

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

View source

FixedMul

inline function FixedMul(a, b)

Multiplies two 16.16 fixed-point operands with a 64-bit intermediate and returns a signed 32-bit fixed-point result.

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

View source

FRACBITS

const FRACBITS = 16

Defines fracbits for the m fixed subsystem.

View source

FRACUNIT

const FRACUNIT = 1 << FRACBITS

Defines fracunit for the m fixed subsystem.

View source