Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
c_lib.h
Go to the documentation of this file.
1#ifndef C_LIB_H_
2#define C_LIB_H_
3
5#include "dolphin/mtx.h"
6
7inline bool cLib_IsZero(f32 value) {
8 return fabsf(value) < 8e-11f;
9}
10
11void cLib_memCpy(void* dst, const void* src, unsigned long size);
12void cLib_memSet(void* ptr, int value, unsigned long size);
13
16void cLib_addCalc0(f32* o_value, f32 scale, f32 maxStep);
19void cLib_addCalcPos2(cXyz* o_value, cXyz const& target, f32 scale, f32 maxStep);
23
24int cLib_chaseUC(u8* o_value, u8 target, u8 step);
25int cLib_chaseS(s16* o_value, s16 target, s16 step);
26int cLib_chaseF(f32* o_value, f32 target, f32 step);
27int cLib_chasePos(cXyz* o_value, cXyz const& target, f32 step);
28int cLib_chasePosXZ(cXyz* o_value, cXyz const& target, f32 step);
30
31s16 cLib_targetAngleY(const Vec* lhs, const Vec* rhs);
32s16 cLib_targetAngleY(const Vec& lhs, const Vec& rhs);
33s16 cLib_targetAngleX(const cXyz*, const cXyz*);
34
35void cLib_offsetPos(cXyz* pDest, cXyz const* pSrc, s16 angle, cXyz const* vec);
37
38template <typename T>
39inline void cLib_offBit(T& value, T bit) {
40 value = (T)(value & ~bit);
41}
42
43template <typename T>
44inline void cLib_onBit(T& value, T bit) {
45 value = (T)(value | bit);
46}
47
48template <typename T>
49inline T cLib_checkBit(T value, T bit) {
50 return (T)(value & bit);
51}
52
53template <typename T>
54inline T cLib_minMaxLimit(T val, T min, T max) {
55 return (T)(val < min ? min : (val > max ? max : val));
56}
57
58template <typename T>
59inline T cLib_maxLimit(T val, T max) {
60 T ret;
61 T var_r30;
62
63 if (val > max) {
64 var_r30 = max;
65 } else {
66 var_r30 = val;
67 }
68
69 ret = var_r30;
70 return (T)ret;
71}
72
73template <typename T>
75 if (*(T*)value != 0) {
76 *value = *value - 1;
77 }
78 return *value;
79}
80
81template <typename T>
83 return (T)(min + cM_rndF((f32)range));
84}
85
86void MtxInit(void);
87void MtxTrans(f32, f32, f32, u8);
88void MtxScale(f32, f32, f32, u8);
89void MtxPosition(cXyz*, cXyz*);
90void MtxPush(void);
91Mtx* MtxPull(void);
92
93extern Mtx* calc_mtx;
94
95#endif
Mtx * MtxPull(void)
Definition c_lib.cpp:393
Mtx * calc_mtx
Definition c_lib.cpp:350
void cLib_memSet(void *ptr, int value, unsigned long size)
Definition c_lib.cpp:16
int cLib_chasePosXZ(cXyz *o_value, cXyz const &target, f32 step)
Definition c_lib.cpp:280
void MtxInit(void)
Definition c_lib.cpp:353
s32 cLib_distanceAngleS(s16 x, s16 y)
Definition c_lib.cpp:341
s16 cLib_addCalcAngleS(s16 *o_value, s16 target, s16 scale, s16 maxStep, s16 minStep)
Definition c_lib.cpp:160
T cLib_checkBit(T value, T bit)
Definition c_lib.h:49
void cLib_memCpy(void *dst, const void *src, unsigned long size)
Definition c_lib.cpp:11
void cLib_addCalcPosXZ2(cXyz *o_value, cXyz const &target, f32 scale, f32 maxStep)
Definition c_lib.cpp:144
void MtxPush(void)
Definition c_lib.cpp:385
int cLib_chaseUC(u8 *o_value, u8 target, u8 step)
Definition c_lib.cpp:205
int cLib_chaseS(s16 *o_value, s16 target, s16 step)
Definition c_lib.cpp:229
void cLib_addCalc2(f32 *o_value, f32 target, f32 scale, f32 maxStep)
Definition c_lib.cpp:55
T cLib_minMaxLimit(T val, T min, T max)
Definition c_lib.h:54
void MtxTrans(f32, f32, f32, u8)
Definition c_lib.cpp:358
void MtxPosition(cXyz *, cXyz *)
Definition c_lib.cpp:380
void cLib_offsetPos(cXyz *pDest, cXyz const *pSrc, s16 angle, cXyz const *vec)
Definition c_lib.cpp:332
void MtxScale(f32, f32, f32, u8)
Definition c_lib.cpp:369
T cLib_calcTimer(T *value)
Definition c_lib.h:74
int cLib_chasePos(cXyz *o_value, cXyz const &target, f32 step)
Definition c_lib.cpp:263
s16 cLib_targetAngleY(const Vec *lhs, const Vec *rhs)
Definition c_lib.cpp:314
f32 cLib_addCalcPosXZ(cXyz *o_value, cXyz const &target, f32 scale, f32 maxStep, f32 minStep)
Definition c_lib.cpp:104
void cLib_onBit(T &value, T bit)
Definition c_lib.h:44
f32 cLib_addCalcPos(cXyz *o_value, cXyz const &target, f32 scale, f32 maxStep, f32 minStep)
Definition c_lib.cpp:79
void cLib_addCalcPos2(cXyz *o_value, cXyz const &target, f32 scale, f32 maxStep)
Definition c_lib.cpp:132
int cLib_chaseAngleS(s16 *o_value, s16 target, s16 step)
Definition c_lib.cpp:297
bool cLib_IsZero(f32 value)
Definition c_lib.h:7
T cLib_getRndValue(T min, T range)
Definition c_lib.h:82
s16 cLib_targetAngleX(const cXyz *, const cXyz *)
Definition c_lib.cpp:324
f32 cLib_addCalc(f32 *o_value, f32 target, f32 scale, f32 maxStep, f32 minStep)
Definition c_lib.cpp:21
T cLib_maxLimit(T val, T max)
Definition c_lib.h:59
void cLib_offBit(T &value, T bit)
Definition c_lib.h:39
void cLib_addCalc0(f32 *o_value, f32 scale, f32 maxStep)
Definition c_lib.cpp:68
void cLib_addCalcAngleS2(s16 *o_value, s16 target, s16 scale, s16 maxStep)
Definition c_lib.cpp:192
int cLib_chaseF(f32 *o_value, f32 target, f32 step)
Definition c_lib.cpp:246
float cM_rndF(float max)
Definition c_math.cpp:203
static void * target
Definition d_a_npc_cd2.cpp:1908
static u8 angle[2+2]
Definition d_a_obj_kago.cpp:845
double x double x
Definition e_atan2.c:58
double x double y
Definition e_atan2.c:58
static u8 max[12]
Definition f_op_actor_mng.cpp:1785
static u8 min[12]
Definition f_op_actor_mng.cpp:1773
static const double T[]
Definition k_tan.c:106
float fabsf(float f)
Definition math.h:38
f32 Mtx[3][4]
Definition mtx.h:15
Definition d_a_hozelda.cpp:18
Definition d_a_hozelda.cpp:20
float f32
Definition types.h:22
signed short s16
Definition types.h:5
signed long s32
Definition types.h:6
unsigned char u8
Definition types.h:8