Files
tp/include/SSystem/SComponent/c_lib.h
T

82 lines
2.4 KiB
C++
Raw Normal View History

2021-04-08 18:43:16 +02:00
#ifndef C_LIB_H_
#define C_LIB_H_
2021-03-28 22:49:05 +02:00
2022-03-26 10:17:17 -07:00
#include "MSL_C/math.h"
2021-04-08 18:43:16 +02:00
#include "SSystem/SComponent/c_xyz.h"
2021-05-03 02:03:24 +02:00
#include "dolphin/mtx/mtx.h"
2021-11-09 21:09:33 +01:00
2022-12-19 11:06:32 -08:00
inline bool cLib_IsZero(f32 value) {
return fabsf(value) < 8e-11f;
2021-11-09 21:09:33 +01:00
}
2021-03-28 22:49:05 +02:00
2021-04-08 18:43:16 +02:00
void cLib_memCpy(void* dst, const void* src, unsigned long size);
void cLib_memSet(void* ptr, int value, unsigned long size);
2022-12-19 11:06:32 -08:00
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);
2021-04-08 18:43:16 +02:00
2022-12-19 11:06:32 -08:00
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);
2021-04-08 18:43:16 +02:00
s16 cLib_targetAngleY(const Vec* lhs, const Vec* rhs);
s16 cLib_targetAngleY(const Vec& lhs, const Vec& rhs);
2022-12-19 11:06:32 -08:00
s16 cLib_targetAngleX(const cXyz*, const cXyz*);
2021-04-08 18:43:16 +02:00
2022-12-19 11:06:32 -08:00
void cLib_offsetPos(cXyz* pDest, cXyz const* pSrc, s16 angle, cXyz const* vec);
2021-04-08 18:43:16 +02:00
s32 cLib_distanceAngleS(s16 x, s16 y);
2022-12-26 10:55:53 -07:00
template <typename T>
inline void cLib_offBit(T& value, u8 bit) {
2022-12-19 11:06:32 -08:00
value &= ~bit;
2021-04-08 18:43:16 +02:00
}
2022-12-26 10:55:53 -07:00
template <typename T>
inline void cLib_onBit(T& value, u8 bit) {
2022-12-19 11:06:32 -08:00
value |= bit;
2021-04-08 18:43:16 +02:00
}
2022-12-26 10:55:53 -07:00
template <typename T>
inline T cLib_checkBit(T& value, u8 bit) {
2022-12-19 11:06:32 -08:00
return value & bit;
2021-04-08 18:43:16 +02:00
}
2021-12-04 05:57:01 -08:00
template <typename T>
2022-01-25 12:24:14 -08:00
inline T cLib_minMaxLimit(T val, T min, T max) {
T ret;
if (val < min) {
ret = min;
} else {
2022-12-19 11:06:32 -08:00
if (val > max) {
val = max;
2022-01-25 12:24:14 -08:00
}
2022-12-19 11:06:32 -08:00
ret = val;
2021-11-10 23:54:31 -08:00
}
2022-12-19 11:06:32 -08:00
2022-01-25 12:24:14 -08:00
return ret;
2021-11-10 23:54:31 -08:00
}
template <typename T>
T cLib_calcTimer(T* val);
2021-04-08 18:43:16 +02:00
void MtxInit(void);
2022-12-19 11:06:32 -08:00
void MtxTrans(f32, f32, f32, u8);
void MtxScale(f32, f32, f32, u8);
2021-04-08 18:43:16 +02:00
void MtxPosition(cXyz*, cXyz*);
void MtxPush(void);
Mtx* MtxPull(void);
extern Mtx* calc_mtx;
#endif