summaryrefslogtreecommitdiff
path: root/arm9/lib
diff options
context:
space:
mode:
Diffstat (limited to 'arm9/lib')
-rw-r--r--arm9/lib/include/NNS_g3d.h12
-rw-r--r--arm9/lib/include/fx.h16
-rw-r--r--arm9/lib/src/FX_vec.c6
3 files changed, 28 insertions, 6 deletions
diff --git a/arm9/lib/include/NNS_g3d.h b/arm9/lib/include/NNS_g3d.h
index b927ecfb..f9a3a1b8 100644
--- a/arm9/lib/include/NNS_g3d.h
+++ b/arm9/lib/include/NNS_g3d.h
@@ -74,4 +74,16 @@ static inline void NNS_G3dGlbLookAt(const VecFx32 * camPos, const VecFx32 * camU
NNS_G3dGlb.flag &= ~(NNS_G3D_GLB_FLAG_INVCAMERA_UPTODATE | NNS_G3D_GLB_FLAG_INVBASECAMERA_UPTODATE | NNS_G3D_GLB_FLAG_INVCAMERAPROJ_UPTODATE | NNS_G3D_GLB_FLAG_BASECAMERA_UPTODATE);
}
+static inline void NNS_G3dGlbPerspective(fx32 fovySin, fx32 fovyCos, fx32 aspect, fx32 n, fx32 f)
+{
+ MTX_Perspective(fovySin, fovyCos, aspect, n, f, &NNS_G3dGlb.projMtx);
+ NNS_G3dGlb.flag &= ~(NNS_G3D_GLB_FLAG_INVPROJ_UPTODATE | NNS_G3D_GLB_FLAG_INVCAMERAPROJ_UPTODATE);
+}
+
+static inline void NNS_G3dGlbOrtho(fx32 t, fx32 b, fx32 l, fx32 r, fx32 n, fx32 f)
+{
+ MTX_Ortho(t, b, l, r, n, f, &NNS_G3dGlb.projMtx);
+ NNS_G3dGlb.flag &= ~(NNS_G3D_GLB_FLAG_INVPROJ_UPTODATE | NNS_G3D_GLB_FLAG_INVCAMERAPROJ_UPTODATE);
+}
+
#endif //GUARD_NNS_G3D_H
diff --git a/arm9/lib/include/fx.h b/arm9/lib/include/fx.h
index 5e8b5dca..de851f62 100644
--- a/arm9/lib/include/fx.h
+++ b/arm9/lib/include/fx.h
@@ -13,15 +13,15 @@ u16 FX_Atan(fx32 x);
u16 FX_Atan2(fx32 x, fx32 y);
//Vec
-void VEC_Add(struct Vecx32 *x, struct Vecx32 *y, struct Vecx32 *dst);
-void VEC_Subtract(struct Vecx32 *x, struct Vecx32 *y, struct Vecx32 *dst);
+void VEC_Add(const struct Vecx32 *a, const struct Vecx32 *b, struct Vecx32 *dst);
+void VEC_Subtract(const struct Vecx32 *a, const struct Vecx32 *b, struct Vecx32 *dst);
void VEC_Fx16Add(struct Vecx16 *x, struct Vecx16 *y, struct Vecx16 *dst);
fx32 VEC_DotProduct(const struct Vecx32 *a, const struct Vecx32 *b);
fx32 VEC_Fx16DotProduct(struct Vecx16 *a, struct Vecx16 *b);
void VEC_CrossProduct(const struct Vecx32 *a, const struct Vecx32 *b, struct Vecx32 *dst);
void VEC_Fx16CrossProduct(struct Vecx16 *a, struct Vecx16 *b, struct Vecx16 *dst);
fx32 VEC_Mag(struct Vecx32 *a);
-void VEC_Normalize(struct Vecx32 *a, struct Vecx32 *dst);
+void VEC_Normalize(const struct Vecx32 *a, struct Vecx32 *dst);
void VEC_Fx16Normalize(struct Vecx16 *a, struct Vecx16 *dst);
void VEC_MultAdd(fx32 factor, struct Vecx32 *a, struct Vecx32 *b, struct Vecx32 *dst);
@@ -110,4 +110,14 @@ static inline void MTX_LookAt(const VecFx32 * camPos, const VecFx32 * camUp, con
G3i_LookAt_(camPos, camUp, target, FALSE, mtx);
}
+static inline void MTX_Perspective(fx32 fovySin, fx32 fovyCos, fx32 aspect, fx32 n, fx32 f, MtxFx44 * mtx)
+{
+ G3i_PerspectiveW_(fovySin, fovyCos, aspect, n, f, FX32_ONE, FALSE, mtx);
+}
+
+static inline void MTX_Ortho(fx32 t, fx32 b, fx32 l, fx32 r, fx32 n, fx32 f, MtxFx44 * mtx)
+{
+ G3i_OrthoW_(t, b, l, r, n, f, FX32_ONE, FALSE, mtx);
+}
+
#endif //GUARD_FX_H
diff --git a/arm9/lib/src/FX_vec.c b/arm9/lib/src/FX_vec.c
index 4ea65e96..8550b54a 100644
--- a/arm9/lib/src/FX_vec.c
+++ b/arm9/lib/src/FX_vec.c
@@ -1,13 +1,13 @@
#include "global.h"
#include "fx.h"
-ARM_FUNC void VEC_Add(struct Vecx32 *a, struct Vecx32 *b, struct Vecx32 *dst){
+ARM_FUNC void VEC_Add(const struct Vecx32 *a, const struct Vecx32 *b, struct Vecx32 *dst){
dst->x = a->x + b->x;
dst->y = a->y + b->y;
dst->z = a->z + b->z;
}
-ARM_FUNC void VEC_Subtract(struct Vecx32 *a, struct Vecx32 *b, struct Vecx32 *dst){
+ARM_FUNC void VEC_Subtract(const struct Vecx32 *a, const struct Vecx32 *b, struct Vecx32 *dst){
dst->x = a->x - b->x;
dst->y = a->y - b->y;
dst->z = a->z - b->z;
@@ -60,7 +60,7 @@ ARM_FUNC fx32 VEC_Mag(struct Vecx32 *a){
return ((fx32)reg_CP_SQRT_RESULT + 1) >> 1;
}
-ARM_FUNC void VEC_Normalize(struct Vecx32 *a, struct Vecx32 *dst){
+ARM_FUNC void VEC_Normalize(const struct Vecx32 *a, struct Vecx32 *dst){
fx64 l2 = (fx64)a->x * a->x;
l2 += (fx64)a->y * a->y;
l2 += (fx64)a->z * a->z;