Decompile func0f1577f0

This commit is contained in:
Ryan Dwyer 2022-08-01 08:15:58 +10:00
parent 1d7c045417
commit 2b1c7d427e
1 changed files with 19 additions and 61 deletions

View File

@ -12,67 +12,25 @@
#include "data.h"
#include "types.h"
GLOBAL_ASM(
glabel func0f1577f0
/* f1577f0: c4ce0000 */ lwc1 $f14,0x0($a2)
/* f1577f4: c4e60000 */ lwc1 $f6,0x0($a3)
/* f1577f8: c4880004 */ lwc1 $f8,0x4($a0)
/* f1577fc: c4c20004 */ lwc1 $f2,0x4($a2)
/* f157800: c4e40004 */ lwc1 $f4,0x4($a3)
/* f157804: c4920000 */ lwc1 $f18,0x0($a0)
/* f157808: 27bdffe0 */ addiu $sp,$sp,-32
/* f15780c: 460e3301 */ sub.s $f12,$f6,$f14
/* f157810: e7a80000 */ swc1 $f8,0x0($sp)
/* f157814: c7a60000 */ lwc1 $f6,0x0($sp)
/* f157818: 46041001 */ sub.s $f0,$f2,$f4
/* f15781c: 3c013f80 */ lui $at,0x3f80
/* f157820: 46127281 */ sub.s $f10,$f14,$f18
/* f157824: 46061201 */ sub.s $f8,$f2,$f6
/* f157828: 46005102 */ mul.s $f4,$f10,$f0
/* f15782c: 00000000 */ nop
/* f157830: 460c4282 */ mul.s $f10,$f8,$f12
/* f157834: c4a80004 */ lwc1 $f8,0x4($a1)
/* f157838: 460a2400 */ add.s $f16,$f4,$f10
/* f15783c: 46064101 */ sub.s $f4,$f8,$f6
/* f157840: c4a80000 */ lwc1 $f8,0x0($a1)
/* f157844: 46124181 */ sub.s $f6,$f8,$f18
/* f157848: 460c2282 */ mul.s $f10,$f4,$f12
/* f15784c: 00000000 */ nop
/* f157850: 46003102 */ mul.s $f4,$f6,$f0
/* f157854: 44803000 */ mtc1 $zero,$f6
/* f157858: 460a2200 */ add.s $f8,$f4,$f10
/* f15785c: 46064032 */ c.eq.s $f8,$f6
/* f157860: e7a80010 */ swc1 $f8,0x10($sp)
/* f157864: c7a40010 */ lwc1 $f4,0x10($sp)
/* f157868: 45000004 */ bc1f .L0f15787c
/* f15786c: 00000000 */ nop
/* f157870: 44810000 */ mtc1 $at,$f0
/* f157874: 10000012 */ b .L0f1578c0
/* f157878: 00000000 */ nop
.L0f15787c:
/* f15787c: 46048403 */ div.s $f16,$f16,$f4
/* f157880: 44805000 */ mtc1 $zero,$f10
/* f157884: 3c013f80 */ lui $at,0x3f80
/* f157888: 460a803c */ c.lt.s $f16,$f10
/* f15788c: 00000000 */ nop
/* f157890: 45030007 */ bc1tl .L0f1578b0
/* f157894: 3c013f80 */ lui $at,0x3f80
/* f157898: 44814000 */ mtc1 $at,$f8
/* f15789c: 00000000 */ nop
/* f1578a0: 4610403c */ c.lt.s $f8,$f16
/* f1578a4: 00000000 */ nop
/* f1578a8: 45000004 */ bc1f .L0f1578bc
/* f1578ac: 3c013f80 */ lui $at,0x3f80
.L0f1578b0:
/* f1578b0: 44810000 */ mtc1 $at,$f0
/* f1578b4: 10000002 */ b .L0f1578c0
/* f1578b8: 00000000 */ nop
.L0f1578bc:
/* f1578bc: 46008006 */ mov.s $f0,$f16
.L0f1578c0:
/* f1578c0: 03e00008 */ jr $ra
/* f1578c4: 27bd0020 */ addiu $sp,$sp,0x20
);
f32 func0f1577f0(f32 arg0[2], f32 arg1[2], f32 arg2[2], f32 arg3[2])
{
f32 mult1 = arg2[1] - arg3[1];
f32 mult2 = arg3[0] - arg2[0];
f32 a = (arg2[1] - arg0[1]) * mult2 + (arg2[0] - arg0[0]) * mult1;
f32 b = (arg1[1] - arg0[1]) * mult2 + (arg1[0] - arg0[0]) * mult1;
if (b == 0.0f) {
return 1.0f;
}
a /= b;
if (a < 0.0f || a > 1.0f) {
return 1.0f;
}
return a;
}
f32 func0f1578c8(struct coord *arg0, struct coord *arg1, struct coord *arg2)
{