dquakeplus/source/libpspmath/vfpu_quaternion_normalize.c

12 lines
422 B
C
Raw Normal View History

2022-02-08 21:49:56 +00:00
#include "pspmath.h"
void vfpu_quaternion_normalize(ScePspQuatMatrix *res) {
__asm__ volatile (
"lv.q C000, %0\n" // load quaternion into C000
"vdot.q S010, C000, C000\n" // S010 = x^2 + y^2 + z^2 + w^2
"vrsq.s S010, S010\n" // S020 = 1.0 / sqrt(S100)
"vscl.q C000, C000, S010\n" // C000 = C000 * S010 (normalized quaternion)
"sv.q C000, %0\n" // store into quaternion result
: "+m"(*res));
}