e_hzelda mostly done (#2258)

This commit is contained in:
TakaRikka 2024-12-06 06:47:30 -08:00 committed by GitHub
parent eebbf9a645
commit ee09fdf915
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 1932 additions and 1320 deletions

View File

@ -2,6 +2,7 @@
#define J3DMODELDATA_H
#include "JSystem/J3DGraphAnimator/J3DJointTree.h"
#include "JSystem/J3DGraphBase/J3DMaterial.h"
#include "JSystem/J3DGraphAnimator/J3DMaterialAttach.h"
#include "JSystem/J3DGraphAnimator/J3DShapeTable.h"
#include "JSystem/J3DGraphBase/J3DSys.h"

View File

@ -1,6 +1,10 @@
#ifndef D_A_E_HZELDA_H
#define D_A_E_HZELDA_H
#include "f_op/f_op_actor_mng.h"
#include "d/d_cc_d.h"
#include "d/d_cc_uty.h"
#include "d/d_bg_s_acch.h"
/**
* @ingroup actors-enemies
@ -11,16 +15,98 @@
*
*/
class e_hzelda_class : public fopEn_enemy_c {
/* 806F4E48 */ e_hzelda_class();
private:
/* 0x5ac */ u8 field_0x5ac[0x1460 - 0x5ac];
public:
/* 0x05AC */ request_of_phase_process_class mPhase;
/* 0x05B4 */ u8 mPrm0;
/* 0x05B8 */ cXyz mTargetMovePos;
/* 0x05C4 */ cXyz field_0x5c4;
/* 0x05D0 */ s16 field_0x5d0;
/* 0x05D4 */ mDoExt_McaMorfSO* mpModelMorf;
/* 0x05D8 */ Z2CreatureEnemy mSound;
/* 0x067C */ u8 field_0x67C[0x0684 - 0x067C];
/* 0x0684 */ int mAnm;
/* 0x0688 */ J3DModel* mpSwordModel;
/* 0x068C */ int field_0x68c;
/* 0x0690 */ f32 mSwordColorIntensity;
/* 0x0694 */ s16 mCounter;
/* 0x0696 */ s16 mAction;
/* 0x0698 */ s16 mMode;
/* 0x069C */ f32 mMoveStep;
/* 0x06A0 */ f32 mDistToPlayer;
/* 0x06A4 */ s16 mAngleToPlayer;
/* 0x06A8 */ u32 mShadowKey;
/* 0x06AC */ s16 mTimers[4];
/* 0x06B4 */ s16 field_0x6b4;
/* 0x06B6 */ u8 field_0x6B6[0x06B8 - 0x06B6];
/* 0x06B8 */ s8 field_0x6b8;
/* 0x06B9 */ u8 field_0x6b9;
/* 0x06BA */ u8 field_0x6ba;
/* 0x06BB */ s8 mIsLookatPlayer;
/* 0x06BC */ s16 mHeadRotX;
/* 0x06BE */ s16 mHeadRotZ;
/* 0x06C0 */ f32 mArmRRotY;
/* 0x06C4 */ f32 field_0x6c4;
/* 0x06C8 */ f32 mArmLRotY;
/* 0x06CC */ f32 field_0x6cc;
/* 0x06D0 */ f32 mBodyRotY;
/* 0x06D4 */ f32 mBodyRotZ;
/* 0x06D8 */ f32 mDodgeMove;
/* 0x06DC */ s16 field_0x6dc;
/* 0x06DE */ u8 field_0x6DE[0x06E4 - 0x06DE];
/* 0x06E4 */ s8 field_0x6e4;
/* 0x06E8 */ f32 field_0x6e8;
/* 0x06EC */ cXyz mOldBallPos;
/* 0x06F8 */ cXyz mBallPos;
/* 0x0704 */ cXyz mBallMove;
/* 0x0710 */ f32 mBallMoveStep;
/* 0x0714 */ J3DModel* mpTriangleAtModel;
/* 0x0718 */ s16 field_0x718;
/* 0x071A */ s16 mDrawTriangleAt;
/* 0x071C */ s16 mTriangleRotY;
/* 0x0720 */ int mTriangleAnmFrame;
/* 0x0724 */ f32 mTriangleSize;
/* 0x0728 */ cXyz mTrianglePos;
/* 0x0734 */ mDoExt_brkAnm* mpTriangleAtBrk;
/* 0x0738 */ mDoExt_btkAnm* mpTriangleAtBtk;
/* 0x073C */ u8 field_0x73C[0x0740 - 0x073C];
/* 0x0740 */ dBgS_AcchCir mAcchCir;
/* 0x0780 */ dBgS_ObjAcch mAcch;
/* 0x0958 */ dCcD_Stts field_0x958;
/* 0x0994 */ dCcD_Sph mSphCc[3];
/* 0x0D3C */ dCcD_Stts field_0xd3c;
/* 0x0D78 */ dCcD_Sph mSphAt;
/* 0x0EB0 */ dCcU_AtInfo mAtInfo;
/* 0x0ED4 */ dCcD_Sph mBallTgSph;
/* 0x100C */ dCcD_Sph mBallSphAt;
/* 0x1144 */ dCcD_Sph mTriAtSph;
/* 0x127C */ dCcD_Stts field_0x127c;
/* 0x12B8 */ dCcD_Sph mPlAtSph;
/* 0x13F0 */ Z2SoundObjSimple mBallSound;
/* 0x1410 */ u8 mMissedBallCount;
/* 0x1411 */ u8 mBottleSwingAtTimer;
/* 0x1412 */ u8 mSwordAtTimer;
/* 0x1413 */ u8 mNoBallCount;
/* 0x1414 */ u8 mMsgSetTimer;
/* 0x1415 */ u8 mInitHIO;
/* 0x1418 */ u32 field_0x1418;
/* 0x141C */ u32 field_0x141c[3];
/* 0x1428 */ u32 field_0x1428[6];
/* 0x1440 */ s16 mDemoMode;
/* 0x1442 */ s16 mDemoTimer;
/* 0x1444 */ cXyz mDemoCamEye;
/* 0x1450 */ cXyz mDemoCamCenter;
/* 0x145C */ f32 mDemoCamFovy;
};
STATIC_ASSERT(sizeof(e_hzelda_class) == 0x1460);
class daE_HZELDA_HIO_c {
public:
/* 806F0D4C */ daE_HZELDA_HIO_c();
/* 806F546C */ ~daE_HZELDA_HIO_c();
/* 806F546C */ virtual ~daE_HZELDA_HIO_c() {}
/* 0x4 */ s8 field_0x4;
/* 0x8 */ f32 mModelSize;
};

View File

@ -9,6 +9,39 @@ struct vib_pattern {
/* 0x4 */ u32 bits;
};
enum VIBMODE_SHOCK {
VIBMODE_S_NONE = -1,
VIBMODE_S_CUSTOM,
VIBMODE_S_POWER1,
VIBMODE_S_POWER2,
VIBMODE_S_POWER3,
VIBMODE_S_POWER4,
VIBMODE_S_POWER5,
VIBMODE_S_POWER6,
VIBMODE_S_POWER7,
VIBMODE_S_POWER8,
VIBMODE_S_DOKUTT,
VIBMODE_S_FOR2D,
VIBMODE_S_MAX
};
enum VIBMODE_QUAKE {
VIBMODE_Q_NONE = -1,
VIBMODE_Q_CUSTOM,
VIBMODE_Q_POWER1,
VIBMODE_Q_POWER2,
VIBMODE_Q_POWER3,
VIBMODE_Q_POWER4,
VIBMODE_Q_POWER5,
VIBMODE_Q_POWER6,
VIBMODE_Q_POWER7,
VIBMODE_Q_POWER8,
VIBMODE_Q_HORSE,
VIBMODE_Q_MAX
};
class dVibration_c {
public:
enum {
@ -17,39 +50,6 @@ public:
MODE_RUN,
};
enum VIBMODE_SHOCK {
VIBMODE_S_NONE = -1,
VIBMODE_S_CUSTOM,
VIBMODE_S_POWER1,
VIBMODE_S_POWER2,
VIBMODE_S_POWER3,
VIBMODE_S_POWER4,
VIBMODE_S_POWER5,
VIBMODE_S_POWER6,
VIBMODE_S_POWER7,
VIBMODE_S_POWER8,
VIBMODE_S_DOKUTT,
VIBMODE_S_FOR2D,
VIBMODE_S_MAX
};
enum VIBMODE_QUAKE {
VIBMODE_Q_NONE = -1,
VIBMODE_Q_CUSTOM,
VIBMODE_Q_POWER1,
VIBMODE_Q_POWER2,
VIBMODE_Q_POWER3,
VIBMODE_Q_POWER4,
VIBMODE_Q_POWER5,
VIBMODE_Q_POWER6,
VIBMODE_Q_POWER7,
VIBMODE_Q_POWER8,
VIBMODE_Q_HORSE,
VIBMODE_Q_MAX
};
/* 8006F268 */ int Run();
/* 8006FA24 */ bool StartShock(int i_vibmode, int i_flags, cXyz i_pos);
/* 8006FC0C */ bool StartQuake(const u8* i_pattern, int i_rounds, int i_flags, cXyz i_pos);

View File

@ -8,19 +8,41 @@
#include "SSystem/SComponent/c_math.h"
/* 8026F93C-8026F95C 26A27C 0020+00 0/0 3/3 0/0 .text cLib_memCpy__FPvPCvUl */
void cLib_memCpy(void* dst, const void* src, unsigned long size) {
memcpy(dst, src, size);
/**
* Copies a source block of memory to a destination block of memory
* @param dst Pointer to destination memory
* @param src Pointer to source data to be copied
* @param num Number of bytes to copy
*/
void cLib_memCpy(void* dst, const void* src, unsigned long num) {
memcpy(dst, src, num);
}
/* 8026F95C-8026F97C 26A29C 0020+00 0/0 4/4 0/0 .text cLib_memSet__FPviUl */
void cLib_memSet(void* dst, int value, unsigned long size) {
memset(dst, value, size);
/**
* Sets the first num bytes of given block of memory to specified value
* @param ptr Pointer to block of memory
* @param value Value to be set
* @param num Number of bytes to set
*/
void cLib_memSet(void* ptr, int value, unsigned long num) {
memset(ptr, value, num);
}
/* 8026F97C-8026FA3C 26A2BC 00C0+00 0/0 50/50 178/178 .text cLib_addCalc__FPfffff */
f32 cLib_addCalc(f32* pValue, f32 target, f32 scale, f32 maxStep, f32 minStep) {
if (*pValue != target) {
f32 step = scale * (target - *pValue);
/**
* Changes value by step towards target. Step amount is clamped between a min and max, and
* scaled as a fraction of the remaining distance.
* @param pvalue Pointer to value to change
* @param target Target to move value towards
* @param scale Fraction of remaining distance to scale step by
* @param maxStep Maximum step amount
* @param minStep Minimum step amount
* @return The absolute value of remaining distance to target
*/
f32 cLib_addCalc(f32* pvalue, f32 target, f32 scale, f32 maxStep, f32 minStep) {
if (*pvalue != target) {
f32 step = scale * (target - *pvalue);
if (step >= minStep || step <= -minStep) {
if (step > maxStep) {
step = maxStep;
@ -28,60 +50,85 @@ f32 cLib_addCalc(f32* pValue, f32 target, f32 scale, f32 maxStep, f32 minStep) {
if (step < -maxStep) {
step = -maxStep;
}
*pValue += step;
*pvalue += step;
} else {
if (step > 0) {
if (step < minStep) {
*pValue += minStep;
if (*pValue > target) {
*pValue = target;
*pvalue += minStep;
if (*pvalue > target) {
*pvalue = target;
}
}
} else {
minStep = -minStep;
if (step > minStep) {
*pValue += minStep;
if (*pValue < target) {
*pValue = target;
*pvalue += minStep;
if (*pvalue < target) {
*pvalue = target;
}
}
}
}
}
return fabsf(target - *pValue);
return fabsf(target - *pvalue);
}
/* 8026FA3C-8026FA80 26A37C 0044+00 0/0 20/20 701/701 .text cLib_addCalc2__FPffff */
void cLib_addCalc2(f32* pValue, f32 target, f32 scale, f32 maxStep) {
if (*pValue != target) {
f32 step = scale * (target - *pValue);
/**
* Changes value by step towards target. Step amount is clamped between a max and -max, and
* scaled as a fraction of the remaining distance.
* @param pvalue Pointer to value to change
* @param target Target to move value towards
* @param scale Fraction of remaining distance to scale step by
* @param maxStep Maximum (+/-) step amount
*/
void cLib_addCalc2(f32* pvalue, f32 target, f32 scale, f32 maxStep) {
if (*pvalue != target) {
f32 step = scale * (target - *pvalue);
if (step > maxStep) {
step = maxStep;
} else if (step < -maxStep) {
step = -maxStep;
}
*pValue += step;
*pvalue += step;
}
}
/* 8026FA80-8026FAB8 26A3C0 0038+00 0/0 2/2 322/322 .text cLib_addCalc0__FPfff */
void cLib_addCalc0(f32* pValue, f32 scale, f32 maxStep) {
f32 step = *pValue * scale;
/**
* Changes value by step towards zero. Step amount is clamped between a max and -max, and
* scaled as a fraction of the remaining distance.
* @param pvalue Pointer to value to change
* @param scale Fraction of remaining distance to scale step by
* @param maxStep Maximum (+/-) step amount
*/
void cLib_addCalc0(f32* pvalue, f32 scale, f32 maxStep) {
f32 step = *pvalue * scale;
if (step > maxStep) {
step = maxStep;
} else if (step < -maxStep) {
step = -maxStep;
}
*pValue -= step;
*pvalue -= step;
}
/* 8026FAB8-8026FDF4 26A3F8 033C+00 0/0 3/3 78/78 .text cLib_addCalcPos__FP4cXyzRC4cXyzfff */
f32 cLib_addCalcPos(cXyz* pValue, cXyz const& target, f32 scale, f32 maxStep, f32 minStep) {
if (*pValue != target) {
cXyz diff = (*pValue - target);
/**
* 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.
* @param ppos Pointer to position to change
* @param target Target position to move towards
* @param scale Fraction of remaining distance to scale step by
* @param maxStep Maximum step amount
* @param minStep Minimum step amount
* @return The absolute value of remaining distance to target
*/
f32 cLib_addCalcPos(cXyz* ppos, const cXyz& target, f32 scale, f32 maxStep, f32 minStep) {
if (*ppos != target) {
cXyz diff = (*ppos - target);
f32 step = diff.abs();
if (step < minStep) {
*pValue = target;
*ppos = target;
} else {
step *= scale;
diff *= scale;
@ -91,23 +138,33 @@ f32 cLib_addCalcPos(cXyz* pValue, cXyz const& target, f32 scale, f32 maxStep, f3
} else if (step < minStep) {
diff *= (minStep / step);
}
*pValue -= diff;
*ppos -= diff;
} else {
*pValue = target;
*ppos = target;
}
}
}
return pValue->abs(target);
return ppos->abs(target);
}
/* 8026FDF4-80270178 26A734 0384+00 0/0 1/1 4/4 .text cLib_addCalcPosXZ__FP4cXyzRC4cXyzfff */
f32 cLib_addCalcPosXZ(cXyz* pValue, cXyz const& target, f32 scale, f32 maxStep, f32 minStep) {
if (pValue->x != target.x || pValue->z != target.z) {
cXyz diff = (*pValue - target);
/**
* 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.
* @param ppos Pointer to position to change
* @param target Target position to move towards
* @param scale Fraction of remaining distance to scale step by
* @param maxStep Maximum step amount
* @param minStep Minimum step amount
* @return The absolute value of remaining distance to target
*/
f32 cLib_addCalcPosXZ(cXyz* ppos, const cXyz& target, f32 scale, f32 maxStep, f32 minStep) {
if (ppos->x != target.x || ppos->z != target.z) {
cXyz diff = (*ppos - target);
f32 step = diff.absXZ();
if (step < minStep) {
pValue->x = target.x;
pValue->z = target.z;
ppos->x = target.x;
ppos->z = target.z;
} else {
step *= scale;
diff *= scale;
@ -117,49 +174,75 @@ f32 cLib_addCalcPosXZ(cXyz* pValue, cXyz const& target, f32 scale, f32 maxStep,
} else if (step < minStep) {
diff *= (minStep / step);
}
pValue->x -= diff.x;
pValue->z -= diff.z;
ppos->x -= diff.x;
ppos->z -= diff.z;
} else {
pValue->x = target.x;
pValue->z = target.z;
ppos->x = target.x;
ppos->z = target.z;
}
}
}
return (*pValue - target).absXZ();
return (*ppos - target).absXZ();
}
/* 80270178-80270350 26AAB8 01D8+00 0/0 2/2 33/33 .text cLib_addCalcPos2__FP4cXyzRC4cXyzff */
void cLib_addCalcPos2(cXyz* pValue, cXyz const& target, f32 scale, f32 maxStep) {
if (*pValue != target) {
cXyz diff = (*pValue - target) * scale;
/**
* 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.
* @param ppos Pointer to position to change
* @param target Target position to move value towards
* @param scale Fraction of remaining distance to scale step by
* @param maxStep Maximum (+/-) step amount
*/
void cLib_addCalcPos2(cXyz* ppos, const cXyz& target, f32 scale, f32 maxStep) {
if (*ppos != target) {
cXyz diff = (*ppos - target) * scale;
if (diff.abs() > maxStep) {
diff = diff.normZP();
diff *= maxStep;
}
*pValue -= diff;
*ppos -= diff;
}
}
/* 80270350-80270540 26AC90 01F0+00 0/0 0/0 4/4 .text cLib_addCalcPosXZ2__FP4cXyzRC4cXyzff */
void cLib_addCalcPosXZ2(cXyz* pValue, cXyz const& target, f32 scale, f32 maxStep) {
if (pValue->x != target.x || pValue->z != target.z) {
cXyz diff = (*pValue - target) * scale;
/**
* 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.
* @param ppos Pointer to position to change
* @param target Target position to move value towards
* @param scale Fraction of remaining distance to scale step by
* @param maxStep Maximum (+/-) step amount
*/
void cLib_addCalcPosXZ2(cXyz* ppos, const cXyz& target, f32 scale, f32 maxStep) {
if (ppos->x != target.x || ppos->z != target.z) {
cXyz diff = (*ppos - target) * scale;
f32 step = diff.absXZ();
if (!cLib_IsZero(step)) {
if (step > maxStep) {
diff *= (maxStep / step);
}
pValue->x -= diff.x;
pValue->z -= diff.z;
ppos->x -= diff.x;
ppos->z -= diff.z;
}
}
}
/* 80270540-80270608 26AE80 00C8+00 0/0 81/81 244/244 .text cLib_addCalcAngleS__FPsssss
*/
s16 cLib_addCalcAngleS(s16* pValue, s16 target, s16 scale, s16 maxStep, s16 minStep) {
s16 diff = target - *pValue;
if (*pValue != target) {
/**
* 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.
* @param pvalue Pointer to angle value to change
* @param target Target angle to move value towards
* @param scale Fraction of remaining distance to scale step by
* @param maxStep Maximum step amount
* @param minStep Minimum step amount
* @return The remaining distance to target
*/
s16 cLib_addCalcAngleS(s16* pvalue, s16 target, s16 scale, s16 maxStep, s16 minStep) {
s16 diff = target - *pvalue;
if (*pvalue != target) {
s16 step = (diff) / scale;
if (step > minStep || step < -minStep) {
if (step > maxStep) {
@ -168,43 +251,58 @@ s16 cLib_addCalcAngleS(s16* pValue, s16 target, s16 scale, s16 maxStep, s16 minS
if (step < -maxStep) {
step = -maxStep;
}
*pValue += step;
*pvalue += step;
} else {
if (0 <= diff) {
*pValue += minStep;
diff = target - *pValue;
*pvalue += minStep;
diff = target - *pvalue;
if (0 >= diff) {
*pValue = target;
*pvalue = target;
}
} else {
*pValue -= minStep;
diff = target - *pValue;
*pvalue -= minStep;
diff = target - *pvalue;
if (0 <= diff) {
*pValue = target;
*pvalue = target;
}
}
}
}
return target - *pValue;
return target - *pvalue;
}
/* 80270608-8027065C 26AF48 0054+00 0/0 2/2 849/849 .text cLib_addCalcAngleS2__FPssss */
void cLib_addCalcAngleS2(s16* pValue, s16 target, s16 scale, s16 maxStep) {
s16 diff = target - *pValue;
/**
* 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.
* @param pvalue Pointer to angle value to change
* @param target Target angle to move value towards
* @param scale Fraction of remaining distance to scale step by
* @param maxStep Maximum (+/-) step amount
*/
void cLib_addCalcAngleS2(s16* pvalue, s16 target, s16 scale, s16 maxStep) {
s16 diff = target - *pvalue;
s16 step = diff / scale;
if (step > maxStep) {
*pValue += maxStep;
*pvalue += maxStep;
} else if (step < -maxStep) {
*pValue -= maxStep;
*pvalue -= maxStep;
} else {
*pValue += step;
*pvalue += step;
}
}
/* 8027065C-802706D0 26AF9C 0074+00 0/0 3/3 14/14 .text cLib_chaseUC__FPUcUcUc */
int cLib_chaseUC(u8* pValue, u8 target, u8 step) {
/**
* Changes unsigned char value by step towards target
* @param pvalue Pointer to value to change
* @param target Target to move value towards
* @param step Step amount
* @return TRUE when target is reached, FALSE otherwise
*/
int cLib_chaseUC(u8* pvalue, u8 target, u8 step) {
if (step) {
s16 wideValue = *pValue;
s16 wideValue = *pvalue;
s16 wideTarget = target;
s16 wideStep;
if (wideValue > wideTarget) {
@ -214,62 +312,83 @@ int cLib_chaseUC(u8* pValue, u8 target, u8 step) {
}
wideValue += wideStep;
if (wideStep * (wideValue - wideTarget) >= 0) {
*pValue = target;
*pvalue = target;
return 1;
} else {
*pValue = wideValue;
*pvalue = wideValue;
}
} else if (*pValue == target) {
} else if (*pvalue == target) {
return 1;
}
return 0;
}
/* 802706D0-80270740 26B010 0070+00 0/0 4/4 49/49 .text cLib_chaseS__FPsss */
int cLib_chaseS(s16* pValue, s16 target, s16 step) {
/**
* Changes signed short value by step towards target
* @param pvalue Pointer to value to change
* @param target Target to move value towards
* @param step Step amount
* @return TRUE when target is reached, FALSE otherwise
*/
int cLib_chaseS(s16* pvalue, s16 target, s16 step) {
if (step) {
if (*pValue > target) {
if (*pvalue > target) {
step = -step;
}
*pValue += step;
if (step * (*pValue - target) >= 0) {
*pValue = target;
*pvalue += step;
if (step * (*pvalue - target) >= 0) {
*pvalue = target;
return 1;
}
} else if (*pValue == target) {
} else if (*pvalue == target) {
return 1;
}
return 0;
}
/* 80270740-802707AC 26B080 006C+00 0/0 70/70 448/448 .text cLib_chaseF__FPfff */
int cLib_chaseF(f32* pValue, f32 target, f32 step) {
/**
* Changes float value by step towards target
* @param pvalue Pointer to value to change
* @param target Target to move value towards
* @param step Step amount
* @return TRUE when target is reached, FALSE otherwise
*/
int cLib_chaseF(f32* pvalue, f32 target, f32 step) {
if (step) {
if (*pValue > target) {
if (*pvalue > target) {
step = -step;
}
*pValue += step;
if (step * (*pValue - target) >= 0) {
*pValue = target;
*pvalue += step;
if (step * (*pvalue - target) >= 0) {
*pvalue = target;
return 1;
}
} else if (*pValue == target) {
} else if (*pvalue == target) {
return 1;
}
return 0;
}
/* 802707AC-80270990 26B0EC 01E4+00 0/0 3/3 60/60 .text cLib_chasePos__FP4cXyzRC4cXyzf */
int cLib_chasePos(cXyz* pValue, cXyz const& target, f32 step) {
/**
* Changes position by step towards target
* @param pvalue Pointer to position to change
* @param target Target position to move towards
* @param step Step amount
* @return TRUE when target is reached, FALSE otherwise
*/
int cLib_chasePos(cXyz* pvalue, const cXyz& target, f32 step) {
if (step) {
cXyz diff = *pValue - target;
cXyz diff = *pvalue - target;
f32 diffF = diff.abs();
if (cLib_IsZero(diffF) || diffF <= step) {
*pValue = target;
*pvalue = target;
return 1;
}
*pValue -= diff * (step / diffF);
} else if (*pValue == target) {
*pvalue -= diff * (step / diffF);
} else if (*pvalue == target) {
return 1;
}
return 0;
@ -277,16 +396,23 @@ int cLib_chasePos(cXyz* pValue, cXyz const& target, f32 step) {
/* 80270990-80270B90 26B2D0 0200+00 0/0 1/0 19/19 .text cLib_chasePosXZ__FP4cXyzRC4cXyzf
*/
int cLib_chasePosXZ(cXyz* pValue, cXyz const& target, f32 step) {
cXyz diff = *pValue - target;
/**
* Changes position's X/Z components by step towards target
* @param pvalue Pointer to position to change
* @param target Target position to move towards
* @param step Step amount
* @return TRUE when target is reached, FALSE otherwise
*/
int cLib_chasePosXZ(cXyz* pvalue, const cXyz& target, f32 step) {
cXyz diff = *pvalue - target;
diff.y = 0;
f32 diffF = diff.absXZ();
if (step) {
if (cLib_IsZero(diffF) || diffF <= step) {
*pValue = target;
*pvalue = target;
return 1;
}
*pValue -= diff * (step / diffF);
*pvalue -= diff * (step / diffF);
} else if (cLib_IsZero(diffF)) {
return 1;
}
@ -294,55 +420,92 @@ int cLib_chasePosXZ(cXyz* pValue, cXyz const& target, f32 step) {
}
/* 80270B90-80270C04 26B4D0 0074+00 0/0 4/4 213/213 .text cLib_chaseAngleS__FPsss */
int cLib_chaseAngleS(s16* pValue, s16 target, s16 step) {
/**
* Changes angle value by step towards target
* @param pvalue Pointer to value to change
* @param target Target to move value towards
* @param step Step amount
* @return TRUE when target is reached, FALSE otherwise
*/
int cLib_chaseAngleS(s16* pvalue, s16 target, s16 step) {
if (step) {
if ((s16)(*pValue - target) > 0) {
if ((s16)(*pvalue - target) > 0) {
step = -step;
}
*pValue += step;
if (step * (s16)(*pValue - target) >= 0) {
*pValue = target;
*pvalue += step;
if (step * (s16)(*pvalue - target) >= 0) {
*pvalue = target;
return 1;
}
} else if (*pValue == target) {
} else if (*pvalue == target) {
return 1;
}
return 0;
}
/* 80270C04-80270C3C 26B544 0038+00 0/0 39/39 454/454 .text cLib_targetAngleY__FPC3VecPC3Vec */
/**
* Gets the target y-angle from position A to position B
* @param lhs Pointer to position A
* @param rhs Pointer to position B
* @return Y-angle from position A to position B
*/
s16 cLib_targetAngleY(const Vec* lhs, const Vec* rhs) {
return cM_atan2s(rhs->x - lhs->x, rhs->z - lhs->z);
}
/* 80270C3C-80270C74 26B57C 0038+00 0/0 0/0 7/7 .text cLib_targetAngleY__FRC3VecRC3Vec */
/**
* Gets the target y-angle from position A to position B
* @param lhs Reference to position A
* @param rhs Reference to position B
* @return Y-angle from position A to position B
*/
s16 cLib_targetAngleY(const Vec& lhs, const Vec& rhs) {
return cM_atan2s(rhs.x - lhs.x, rhs.z - lhs.z);
}
/* 80270C74-80270DC0 26B5B4 014C+00 0/0 2/2 109/109 .text cLib_targetAngleX__FPC4cXyzPC4cXyz */
s16 cLib_targetAngleX(cXyz const* param_0, cXyz const* param_1) {
cXyz diff = *param_1 - *param_0;
/**
* Gets the target x-angle from position A to position B
* @param lhs Pointer to position A
* @param rhs Pointer to position B
* @return X-Angle from position A to position B
*/
s16 cLib_targetAngleX(cXyz const* lhs, cXyz const* rhs) {
cXyz diff = *rhs - *lhs;
f32 f1 = sqrtf(diff.getMagXZ());
return cM_atan2s(diff.y, f1);
}
/* 80270DC0-80270E24 26B700 0064+00 0/0 2/2 118/118 .text cLib_offsetPos__FP4cXyzPC4cXyzsPC4cXyz
*/
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
* @param pdest The resulting position
* @param psrc The source position
* @param angle The direction to offset psrc in
* @param vec The offset cXyz to add to psrc
*/
void cLib_offsetPos(cXyz* pdest, cXyz const* psrc, s16 angle, cXyz const* vec) {
f32 cos = cM_scos(angle);
f32 sin = cM_ssin(angle);
pDest->x = pSrc->x + (vec->x * cos + vec->z * sin);
pDest->y = pSrc->y + vec->y;
pDest->z = pSrc->z + (vec->z * cos - vec->x * sin);
pdest->x = psrc->x + (vec->x * cos + vec->z * sin);
pdest->y = psrc->y + vec->y;
pdest->z = psrc->z + (vec->z * cos - vec->x * sin);
}
/* 80270E24-80270E4C 26B764 0028+00 0/0 48/48 71/71 .text cLib_distanceAngleS__Fss */
/**
* Gets the target x-angle from position A to position B
* @param lhs Pointer to position A
* @param rhs Pointer to position B
* @return X-Angle from position A to position B
*/
s32 cLib_distanceAngleS(s16 x, s16 y) {
return abs(static_cast<s16>(x - y));
}
/* ############################################################################################## */
/* 80430DB8-80430F98 05DAD8 01E0+00 2/1 0/0 0/0 .bss mtx */
static Mtx mtx[10];
@ -350,6 +513,9 @@ static Mtx mtx[10];
Mtx* calc_mtx = mtx;
/* 80270E4C-80270E5C 26B78C 0010+00 0/0 1/1 0/0 .text MtxInit__Fv */
/**
* Initializes calc_mtx to mtx stack
*/
void MtxInit() {
calc_mtx = mtx;
}
@ -377,6 +543,11 @@ void MtxScale(f32 x_trans, f32 y_trans, f32 z_trans, u8 param_3) {
}
/* 80270EEC-80270F1C 26B82C 0030+00 0/0 2/2 615/615 .text MtxPosition__FP4cXyzP4cXyz */
/**
* Multiplies a src position by the calc_mtx and puts the result in dest
* @param src The src position to be multiplied
* @param dest The resulting multiplied position
*/
void MtxPosition(cXyz* src, cXyz* dest) {
MTXMultVec(*calc_mtx, src, dest);
}
@ -392,4 +563,4 @@ void MtxPush() {
/* 80270F58-80270F68 26B898 0010+00 0/0 0/0 20/20 .text MtxPull__Fv */
Mtx* MtxPull() {
return calc_mtx--;
}
}

File diff suppressed because it is too large Load Diff