mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-12 05:28:43 -04:00
Add C versions of all ASM blocks (except THP)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "JSystem/J3DGraphAnimator/J3DCluster.h"
|
||||
#include "JSystem/J3DGraphAnimator/J3DMtxBuffer.h"
|
||||
#include <dolphin/types.h>
|
||||
#include <cstring>
|
||||
|
||||
class J3DModel;
|
||||
class J3DAnmCluster;
|
||||
@@ -115,6 +116,8 @@ inline void J3DFillZero32B(__REGISTER void* param_0, __REGISTER u32 param_1) {
|
||||
addi param_0, param_0, 0x20
|
||||
bdnz lbl_8032D948
|
||||
}
|
||||
#else
|
||||
memset(param_0, 0, param_1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ struct J3DTextureSRTInfo {
|
||||
/* 0x10 */ f32 mTranslationY;
|
||||
|
||||
bool operator==(J3DTextureSRTInfo&) const;
|
||||
inline void operator=(J3DTextureSRTInfo const& other) {
|
||||
#ifdef __MWERKS__
|
||||
inline void operator=(J3DTextureSRTInfo const& other) {
|
||||
__REGISTER const f32* src = &other.mScaleX;
|
||||
__REGISTER f32* dst = &mScaleX;
|
||||
__REGISTER f32 xy;
|
||||
@@ -58,8 +58,8 @@ struct J3DTextureSRTInfo {
|
||||
psq_l xy, 0(src), 0, 0
|
||||
psq_st xy, 0(dst), 0, 0
|
||||
};
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}; // Size: 0x14
|
||||
|
||||
enum J3DTexMtxMode {
|
||||
|
||||
@@ -85,6 +85,12 @@ inline void J3DPSMtx33Copy(__REGISTER Mtx3P src, __REGISTER Mtx3P dst) {
|
||||
psq_st fr1, 0x18(dst), 0, 0
|
||||
stfs fr0, 0x20(dst)
|
||||
}
|
||||
#else
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
dst[i][j] = src[i][j];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -110,6 +116,12 @@ inline void J3DPSMtx33CopyFrom34(__REGISTER MtxP src, __REGISTER Mtx3P dst) {
|
||||
psq_st x_y3, 24(dst), 0, 0
|
||||
stfs z3, 0x20(dst)
|
||||
}
|
||||
#else
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
dst[i][j] = src[i][j];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -137,6 +149,12 @@ inline void J3DPSMulMtxVec(__REGISTER MtxP mtx, __REGISTER Vec* vec, __REGISTER
|
||||
ps_sum0 f6, f5, f6, f5
|
||||
psq_st f6, 8(dst), 1, 0
|
||||
}
|
||||
#else
|
||||
Vec tmp;
|
||||
tmp.x = mtx[0][0] * vec->x + mtx[0][1] * vec->y + mtx[0][2] * vec->z + mtx[0][3];
|
||||
tmp.y = mtx[1][0] * vec->x + mtx[1][1] * vec->y + mtx[1][2] * vec->z + mtx[1][3];
|
||||
tmp.z = mtx[2][0] * vec->x + mtx[2][1] * vec->y + mtx[2][2] * vec->z + mtx[2][3];
|
||||
*dst = tmp;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -164,6 +182,12 @@ inline void J3DPSMulMtxVec(__REGISTER MtxP mtx, __REGISTER S16Vec* vec, __REGIST
|
||||
ps_sum0 f6, f5, f6, f5
|
||||
psq_st f6, 4(dst), 1, 7
|
||||
}
|
||||
#else
|
||||
S16Vec tmp;
|
||||
tmp.x = (s16)(mtx[0][0] * vec->x + mtx[0][1] * vec->y + mtx[0][2] * vec->z + mtx[0][3]);
|
||||
tmp.y = (s16)(mtx[1][0] * vec->x + mtx[1][1] * vec->y + mtx[1][2] * vec->z + mtx[1][3]);
|
||||
tmp.z = (s16)(mtx[2][0] * vec->x + mtx[2][1] * vec->y + mtx[2][2] * vec->z + mtx[2][3]);
|
||||
*dst = tmp;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -195,6 +219,12 @@ inline void J3DPSMulMtxVec(__REGISTER Mtx3P mtx, __REGISTER Vec* vec, __REGISTER
|
||||
ps_sum0 f6, f5, f6, f5
|
||||
psq_st f6, 8(dst), 1, 0
|
||||
}
|
||||
#else
|
||||
Vec tmp;
|
||||
tmp.x = mtx[0][0] * vec->x + mtx[0][1] * vec->y + mtx[0][2] * vec->z;
|
||||
tmp.y = mtx[1][0] * vec->x + mtx[1][1] * vec->y + mtx[1][2] * vec->z;
|
||||
tmp.z = mtx[2][0] * vec->x + mtx[2][1] * vec->y + mtx[2][2] * vec->z;
|
||||
*dst = tmp;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -226,6 +256,12 @@ inline void J3DPSMulMtxVec(__REGISTER Mtx3P mtx, __REGISTER S16Vec* vec, __REGIS
|
||||
ps_sum0 f6, f5, f6, f5
|
||||
psq_st f6, 4(dst), 1, 7
|
||||
}
|
||||
#else
|
||||
S16Vec tmp;
|
||||
tmp.x = (s16)(mtx[0][0] * vec->x + mtx[0][1] * vec->y + mtx[0][2] * vec->z);
|
||||
tmp.y = (s16)(mtx[1][0] * vec->x + mtx[1][1] * vec->y + mtx[1][2] * vec->z);
|
||||
tmp.z = (s16)(mtx[2][0] * vec->x + mtx[2][1] * vec->y + mtx[2][2] * vec->z);
|
||||
*dst = tmp;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -151,6 +151,10 @@ inline void setTVec3f(const __REGISTER f32* vec_a, __REGISTER f32* vec_b) {
|
||||
psq_st a_x, 0(vec_b), 0, 0
|
||||
stfs b_x, 8(vec_b)
|
||||
};
|
||||
#else
|
||||
vec_b[0] = vec_a[0];
|
||||
vec_b[1] = vec_a[1];
|
||||
vec_b[2] = vec_a[2];
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -163,6 +167,8 @@ inline float fsqrt_step(float mag) {
|
||||
#ifdef __MWERKS__
|
||||
f32 root = __frsqrte(mag);
|
||||
return 0.5f * root * (3.0f - mag * (root * root));
|
||||
#else
|
||||
return 1.0f / sqrtf(mag);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -182,6 +188,10 @@ inline void mulInternal(__REGISTER const f32* a, __REGISTER const f32* b, __REGI
|
||||
psq_st x_y, 0(dst), 0, 0
|
||||
};
|
||||
dst[2] = a[2] * b[2];
|
||||
#else
|
||||
dst[0] = a[0] * b[0];
|
||||
dst[1] = a[1] * b[1];
|
||||
dst[2] = a[2] * b[2];
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -359,6 +369,10 @@ struct TVec3<f32> : public Vec {
|
||||
fneg z, z
|
||||
stfs z, 8(rdst)
|
||||
};
|
||||
#else
|
||||
dst->x = -x;
|
||||
dst->y = -y;
|
||||
dst->z = -z;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user