Loading [MathJax]/extensions/MathZoom.js
Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
c_lib.h File Reference

Go to the source code of this file.

Functions

bool cLib_IsZero (f32 value)
 
void cLib_memCpy (void *dst, const void *src, unsigned long size)
 
void cLib_memSet (void *ptr, int value, unsigned long size)
 
f32 cLib_addCalc (f32 *o_value, f32 target, f32 scale, f32 maxStep, f32 minStep)
 
void cLib_addCalc2 (f32 *o_value, f32 target, f32 scale, f32 maxStep)
 
void cLib_addCalc0 (f32 *o_value, f32 scale, f32 maxStep)
 
f32 cLib_addCalcPos (cXyz *o_value, cXyz const &target, f32 scale, f32 maxStep, f32 minStep)
 
f32 cLib_addCalcPosXZ (cXyz *o_value, cXyz const &target, f32 scale, f32 maxStep, f32 minStep)
 
void cLib_addCalcPos2 (cXyz *o_value, cXyz const &target, f32 scale, f32 maxStep)
 
void cLib_addCalcPosXZ2 (cXyz *o_value, cXyz const &target, f32 scale, f32 maxStep)
 
s16 cLib_addCalcAngleS (s16 *o_value, s16 target, s16 scale, s16 maxStep, s16 minStep)
 
void cLib_addCalcAngleS2 (s16 *o_value, s16 target, s16 scale, s16 maxStep)
 
int cLib_chaseUC (u8 *o_value, u8 target, u8 step)
 
int cLib_chaseS (s16 *o_value, s16 target, s16 step)
 
int cLib_chaseF (f32 *o_value, f32 target, f32 step)
 
int cLib_chasePos (cXyz *o_value, cXyz const &target, f32 step)
 
int cLib_chasePosXZ (cXyz *o_value, cXyz const &target, f32 step)
 
int cLib_chaseAngleS (s16 *o_value, s16 target, s16 step)
 
s16 cLib_targetAngleY (const Vec *lhs, const Vec *rhs)
 
s16 cLib_targetAngleY (const Vec &lhs, const Vec &rhs)
 
s16 cLib_targetAngleX (const cXyz *, const cXyz *)
 
void cLib_offsetPos (cXyz *pDest, cXyz const *pSrc, s16 angle, cXyz const *vec)
 
s32 cLib_distanceAngleS (s16 x, s16 y)
 
template<typename T >
void cLib_offBit (T &value, T bit)
 
template<typename T >
void cLib_onBit (T &value, T bit)
 
template<typename T >
T cLib_checkBit (T value, T bit)
 
template<typename T >
T cLib_minMaxLimit (T val, T min, T max)
 
template<typename T >
T cLib_maxLimit (T val, T max)
 
template<typename T >
T cLib_getRndValue (T min, T range)
 
template<typename T >
T cLib_calcTimer (T *value)
 
void MtxInit (void)
 
void MtxTrans (f32, f32, f32, u8)
 
void MtxScale (f32, f32, f32, u8)
 
void MtxPosition (cXyz *, cXyz *)
 
void MtxPush (void)
 
MtxMtxPull (void)
 

Variables

Mtxcalc_mtx
 

Function Documentation

◆ cLib_addCalc()

f32 cLib_addCalc ( f32 * pvalue,
f32 target,
f32 scale,
f32 maxStep,
f32 minStep )

Changes value by step towards target. Step amount is clamped between a min and max, and scaled as a fraction of the remaining distance.

Parameters
pvaluePointer to value to change
targetTarget to move value towards
scaleFraction of remaining distance to scale step by
maxStepMaximum step amount
minStepMinimum step amount
Returns
The absolute value of remaining distance to target

◆ cLib_addCalc0()

void cLib_addCalc0 ( f32 * pvalue,
f32 scale,
f32 maxStep )

Changes value by step towards zero. Step amount is clamped between a max and -max, and scaled as a fraction of the remaining distance.

Parameters
pvaluePointer to value to change
scaleFraction of remaining distance to scale step by
maxStepMaximum (+/-) step amount

◆ cLib_addCalc2()

void cLib_addCalc2 ( f32 * pvalue,
f32 target,
f32 scale,
f32 maxStep )

Changes value by step towards target. Step amount is clamped between a max and -max, and scaled as a fraction of the remaining distance.

Parameters
pvaluePointer to value to change
targetTarget to move value towards
scaleFraction of remaining distance to scale step by
maxStepMaximum (+/-) step amount

◆ cLib_addCalcAngleS()

s16 cLib_addCalcAngleS ( s16 * pvalue,
s16 target,
s16 scale,
s16 maxStep,
s16 minStep )

Changes angle value by step towards target. Step amount is clamped between a min and max, and scaled as a fraction of the remaining distance.

Parameters
pvaluePointer to angle value to change
targetTarget angle to move value towards
scaleFraction of remaining distance to scale step by
maxStepMaximum step amount
minStepMinimum step amount
Returns
The remaining distance to target

◆ cLib_addCalcAngleS2()

void cLib_addCalcAngleS2 ( s16 * pvalue,
s16 target,
s16 scale,
s16 maxStep )

Changes angle value by step towards target angle. Step amount is clamped between a max and -max and scaled as a fraction of the remaining distance.

Parameters
pvaluePointer to angle value to change
targetTarget angle to move value towards
scaleFraction of remaining distance to scale step by
maxStepMaximum (+/-) step amount

◆ cLib_addCalcPos()

f32 cLib_addCalcPos ( cXyz * ppos,
const cXyz & target,
f32 scale,
f32 maxStep,
f32 minStep )

Changes position by step towards target position. Step amount is clamped between a min and max, and scaled as a fraction of the remaining distance.

Parameters
pposPointer to position to change
targetTarget position to move towards
scaleFraction of remaining distance to scale step by
maxStepMaximum step amount
minStepMinimum step amount
Returns
The absolute value of remaining distance to target

◆ cLib_addCalcPos2()

void cLib_addCalcPos2 ( cXyz * ppos,
const cXyz & target,
f32 scale,
f32 maxStep )

Changes position by step towards target position. Step amount is clamped between a max and -max and scaled as a fraction of the remaining distance.

Parameters
pposPointer to position to change
targetTarget position to move value towards
scaleFraction of remaining distance to scale step by
maxStepMaximum (+/-) step amount

◆ cLib_addCalcPosXZ()

f32 cLib_addCalcPosXZ ( cXyz * ppos,
const cXyz & target,
f32 scale,
f32 maxStep,
f32 minStep )

Changes position's X/Z components by step towards target position. Step amount is clamped between a min and max, and scaled as a fraction of the remaining distance.

Parameters
pposPointer to position to change
targetTarget position to move towards
scaleFraction of remaining distance to scale step by
maxStepMaximum step amount
minStepMinimum step amount
Returns
The absolute value of remaining distance to target

◆ cLib_addCalcPosXZ2()

void cLib_addCalcPosXZ2 ( cXyz * ppos,
const cXyz & target,
f32 scale,
f32 maxStep )

Changes position's X/Z components by step towards target position. Step amount is clamped between a max and -max and scaled as a fraction of the remaining distance.

Parameters
pposPointer to position to change
targetTarget position to move value towards
scaleFraction of remaining distance to scale step by
maxStepMaximum (+/-) step amount

◆ cLib_calcTimer()

template<typename T >
T cLib_calcTimer ( T * value)

◆ cLib_chaseAngleS()

int cLib_chaseAngleS ( s16 * pvalue,
s16 target,
s16 step )

Changes angle value by step towards target

Parameters
pvaluePointer to value to change
targetTarget to move value towards
stepStep amount
Returns
TRUE when target is reached, FALSE otherwise

◆ cLib_chaseF()

int cLib_chaseF ( f32 * pvalue,
f32 target,
f32 step )

Changes float value by step towards target

Parameters
pvaluePointer to value to change
targetTarget to move value towards
stepStep amount
Returns
TRUE when target is reached, FALSE otherwise

◆ cLib_chasePos()

int cLib_chasePos ( cXyz * pvalue,
const cXyz & target,
f32 step )

Changes position by step towards target

Parameters
pvaluePointer to position to change
targetTarget position to move towards
stepStep amount
Returns
TRUE when target is reached, FALSE otherwise

◆ cLib_chasePosXZ()

int cLib_chasePosXZ ( cXyz * pvalue,
const cXyz & target,
f32 step )

Changes position's X/Z components by step towards target

Parameters
pvaluePointer to position to change
targetTarget position to move towards
stepStep amount
Returns
TRUE when target is reached, FALSE otherwise

◆ cLib_chaseS()

int cLib_chaseS ( s16 * pvalue,
s16 target,
s16 step )

Changes signed short value by step towards target

Parameters
pvaluePointer to value to change
targetTarget to move value towards
stepStep amount
Returns
TRUE when target is reached, FALSE otherwise

◆ cLib_chaseUC()

int cLib_chaseUC ( u8 * pvalue,
u8 target,
u8 step )

Changes unsigned char value by step towards target

Parameters
pvaluePointer to value to change
targetTarget to move value towards
stepStep amount
Returns
TRUE when target is reached, FALSE otherwise

◆ cLib_checkBit()

template<typename T >
T cLib_checkBit ( T value,
T bit )
inline

◆ cLib_distanceAngleS()

s32 cLib_distanceAngleS ( s16 x,
s16 y )

Gets the target x-angle from position A to position B

Parameters
lhsPointer to position A
rhsPointer to position B
Returns
X-Angle from position A to position B

◆ cLib_getRndValue()

template<typename T >
T cLib_getRndValue ( T min,
T range )

◆ cLib_IsZero()

bool cLib_IsZero ( f32 value)
inline

◆ cLib_maxLimit()

template<typename T >
T cLib_maxLimit ( T val,
T max )
inline

◆ cLib_memCpy()

void cLib_memCpy ( void * dst,
const void * src,
unsigned long num )

c_lib.cpp Copies a source block of memory to a destination block of memory

Parameters
dstPointer to destination memory
srcPointer to source data to be copied
numNumber of bytes to copy

◆ cLib_memSet()

void cLib_memSet ( void * ptr,
int value,
unsigned long num )

Sets the first num bytes of given block of memory to specified value

Parameters
ptrPointer to block of memory
valueValue to be set
numNumber of bytes to set

◆ cLib_minMaxLimit()

template<typename T >
T cLib_minMaxLimit ( T val,
T min,
T max )
inline

◆ cLib_offBit()

template<typename T >
void cLib_offBit ( T & value,
T bit )
inline

◆ cLib_offsetPos()

void cLib_offsetPos ( cXyz * pdest,
cXyz const * psrc,
s16 angle,
cXyz const * vec )

Adds an offset to a source position in a given angle direction and places the result in pdest

Parameters
pdestThe resulting position
psrcThe source position
angleThe direction to offset psrc in
vecThe offset cXyz to add to psrc

◆ cLib_onBit()

template<typename T >
void cLib_onBit ( T & value,
T bit )
inline

◆ cLib_targetAngleX()

s16 cLib_targetAngleX ( cXyz const * lhs,
cXyz const * rhs )

Gets the target x-angle from position A to position B

Parameters
lhsPointer to position A
rhsPointer to position B
Returns
X-Angle from position A to position B

◆ cLib_targetAngleY() [1/2]

s16 cLib_targetAngleY ( const Vec & lhs,
const Vec & rhs )

Gets the target y-angle from position A to position B

Parameters
lhsReference to position A
rhsReference to position B
Returns
Y-angle from position A to position B

◆ cLib_targetAngleY() [2/2]

s16 cLib_targetAngleY ( const Vec * lhs,
const Vec * rhs )

Gets the target y-angle from position A to position B

Parameters
lhsPointer to position A
rhsPointer to position B
Returns
Y-angle from position A to position B

◆ MtxInit()

void MtxInit ( void )

Initializes calc_mtx to mtx stack

◆ MtxPosition()

void MtxPosition ( cXyz * src,
cXyz * dest )

Multiplies a src position by the calc_mtx and puts the result in dest

Parameters
srcThe src position to be multiplied
destThe resulting multiplied position

◆ MtxPull()

Mtx * MtxPull ( void )

◆ MtxPush()

void MtxPush ( void )

◆ MtxScale()

void MtxScale ( f32 x_trans,
f32 y_trans,
f32 z_trans,
u8 param_3 )

◆ MtxTrans()

void MtxTrans ( f32 x_trans,
f32 y_trans,
f32 z_trans,
u8 param_3 )

Variable Documentation

◆ calc_mtx

Mtx* calc_mtx
extern