summaryrefslogtreecommitdiff
path: root/src/libultra/mgu/normalize.s
blob: 99eccb6ae8b17610a1e0badbddb31cb6997a83d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "PR/asm.h"
#include "PR/regdef.h"

.text
.align 5

LEAF(guNormalize)
    lwc1    ft0, (a0)
    lwc1    ft1, (a1)
    lwc1    ft2, (a2)
.set noreorder
    mul.s   ft3, ft0, ft0
    li.s    t0, 1.0
    mul.s   ft4, ft1, ft1
    add.s   ft5, ft3, ft4
    mul.s   ft4, ft2, ft2
.set reorder
    add.s   ft3, ft4, ft5
    mtc1    t0, ft5
    sqrt.s  ft4, ft3
    div.s   ft3, ft5, ft4
.set noreorder
    mul.s   ft4, ft0, ft3
    nop
    mul.s   ft5, ft1, ft3
    nop
    mul.s   ft0, ft2, ft3
.set reorder
    swc1    ft4, (a0)
    swc1    ft5, (a1)
    swc1    ft0, (a2)
    jr      ra
END(guNormalize)