Decompile mtx4GetRotation

This commit is contained in:
Ryan Dwyer
2021-11-06 14:29:06 +10:00
parent 1f2e759fab
commit 0db6c2ef08
11 changed files with 83 additions and 119 deletions
+9 -9
View File
@@ -744,7 +744,7 @@ void model0001b400(struct objticksp476 *arg0, struct model *model, struct modeln
}
if (g_Anims[anim->animnum].flags & ANIMFLAG_02) {
mtx000166dc(sp254, &sp198);
mtx4LoadTranslation(sp254, &sp198);
} else {
if (rwdata->chrinfo.unk18 != 0.0f) {
sp250 = model0001afe8(sp250, rwdata->chrinfo.unk1c, rwdata->chrinfo.unk18);
@@ -817,7 +817,7 @@ glabel var70054308
/* 1b884: 8fae0058 */ lw $t6,0x58($sp)
/* 1b888: 8fa400c8 */ lw $a0,0xc8($sp)
/* 1b88c: 8fa500c4 */ lw $a1,0xc4($sp)
/* 1b890: 0c0059a9 */ jal mtx000166a4
/* 1b890: 0c0059a9 */ jal mtx4LoadRotationAndTranslation
/* 1b894: 27a60068 */ addiu $a2,$sp,0x68
/* 1b898: 8fae00cc */ lw $t6,0xcc($sp)
/* 1b89c: 8faf00bc */ lw $t7,0xbc($sp)
@@ -888,7 +888,7 @@ glabel var70054308
/* 1b98c: 000c6980 */ sll $t5,$t4,0x6
/* 1b990: 01ae3021 */ addu $a2,$t5,$t6
/* 1b994: afa6001c */ sw $a2,0x1c($sp)
/* 1b998: 0c0059a9 */ jal mtx000166a4
/* 1b998: 0c0059a9 */ jal mtx4LoadRotationAndTranslation
/* 1b99c: 8fa500c4 */ lw $a1,0xc4($sp)
/* 1b9a0: 8faf00cc */ lw $t7,0xcc($sp)
/* 1b9a4: 8fb800bc */ lw $t8,0xbc($sp)
@@ -1729,7 +1729,7 @@ glabel var70053fc0pf
/* 1c308: 1200000f */ beqz $s0,.PF0001c348
/* 1c30c: 8fa40158 */ lw $a0,0x158($sp)
/* 1c310: 8fa40158 */ lw $a0,0x158($sp)
/* 1c314: 0c00591b */ jal mtx000166dc
/* 1c314: 0c00591b */ jal mtx4LoadTranslation
/* 1c318: 27a500e8 */ addiu $a1,$sp,0xe8
/* 1c31c: 8fa80158 */ lw $t0,0x158($sp)
/* 1c320: 8faa0164 */ lw $t2,0x164($sp)
@@ -1747,7 +1747,7 @@ glabel var70053fc0pf
/* 1c34c: 848f000e */ lh $t7,0xe($a0)
/* 1c350: 8dae000c */ lw $t6,0xc($t5)
/* 1c354: 000fc980 */ sll $t9,$t7,0x6
/* 1c358: 0c00591b */ jal mtx000166dc
/* 1c358: 0c00591b */ jal mtx4LoadTranslation
/* 1c35c: 01d92821 */ addu $a1,$t6,$t9
/* 1c360: 8fbf002c */ lw $ra,0x2c($sp)
.PF0001c364:
@@ -2143,7 +2143,7 @@ glabel model0001bfa8
/* 1c548: 1200000f */ beqz $s0,.L0001c588
/* 1c54c: 8fa40158 */ lw $a0,0x158($sp)
/* 1c550: 8fa40158 */ lw $a0,0x158($sp)
/* 1c554: 0c0059b7 */ jal mtx000166dc
/* 1c554: 0c0059b7 */ jal mtx4LoadTranslation
/* 1c558: 27a500e8 */ addiu $a1,$sp,0xe8
/* 1c55c: 8fb80158 */ lw $t8,0x158($sp)
/* 1c560: 8fa90164 */ lw $t1,0x164($sp)
@@ -2161,7 +2161,7 @@ glabel model0001bfa8
/* 1c58c: 848e000e */ lh $t6,0xe($a0)
/* 1c590: 8d8d000c */ lw $t5,0xc($t4)
/* 1c594: 000e7980 */ sll $t7,$t6,0x6
/* 1c598: 0c0059b7 */ jal mtx000166dc
/* 1c598: 0c0059b7 */ jal mtx4LoadTranslation
/* 1c59c: 01af2821 */ addu $a1,$t5,$t7
/* 1c5a0: 8fbf002c */ lw $ra,0x2c($sp)
.L0001c5a4:
@@ -2187,10 +2187,10 @@ void model0001c5b4(struct objticksp476 *arg0, struct model *model, struct modeln
}
if (sp68) {
mtx000166dc(&rodata->positionheld.pos, &sp28);
mtx4LoadTranslation(&rodata->positionheld.pos, &sp28);
mtx00015be4(sp68, &sp28, &matrices[mtxindex]);
} else {
mtx000166dc(&rodata->positionheld.pos, &matrices[mtxindex]);
mtx4LoadTranslation(&rodata->positionheld.pos, &matrices[mtxindex]);
}
}
+27 -63
View File
@@ -174,7 +174,7 @@ void mtx4LoadYRotation(f32 angle, Mtxf *matrix)
void mtx4LoadZRotation(f32 angle, Mtxf *matrix)
{
f32 cos = cosf(angle);
f32 sin = (float)sinf(angle);
f32 sin = sinf(angle);
matrix->m[0][0] = cos;
matrix->m[0][1] = sin;
@@ -231,73 +231,37 @@ void mtx4LoadRotation(struct coord *src, Mtxf *dest)
dest->m[3][3] = 1;
}
GLOBAL_ASM(
glabel mtx000165d8
/* 165d8: 27bdffd8 */ addiu $sp,$sp,-40
/* 165dc: afbf001c */ sw $ra,0x1c($sp)
/* 165e0: afb10018 */ sw $s1,0x18($sp)
/* 165e4: afb00014 */ sw $s0,0x14($sp)
/* 165e8: c4800018 */ lwc1 $f0,0x18($a0)
/* 165ec: c4820028 */ lwc1 $f2,0x28($a0)
/* 165f0: 00808025 */ or $s0,$a0,$zero
/* 165f4: 46000102 */ mul.s $f4,$f0,$f0
/* 165f8: 00a08825 */ or $s1,$a1,$zero
/* 165fc: 46021182 */ mul.s $f6,$f2,$f2
/* 16600: 0c012974 */ jal sqrtf
/* 16604: 46062300 */ add.s $f12,$f4,$f6
/* 16608: 3c013600 */ lui $at,0x3600
/* 1660c: 44814000 */ mtc1 $at,$f8
/* 16610: e7a00024 */ swc1 $f0,0x24($sp)
/* 16614: 4600403c */ c.lt.s $f8,$f0
/* 16618: 00000000 */ nop
/* 1661c: 45020010 */ bc1fl .L00016660
/* 16620: 44805000 */ mtc1 $zero,$f10
/* 16624: c60c0018 */ lwc1 $f12,0x18($s0)
/* 16628: 0fc259d4 */ jal atan2f
/* 1662c: c60e0028 */ lwc1 $f14,0x28($s0)
/* 16630: e6200000 */ swc1 $f0,0x0($s1)
/* 16634: c60c0008 */ lwc1 $f12,0x8($s0)
/* 16638: c7ae0024 */ lwc1 $f14,0x24($sp)
/* 1663c: 0fc259d4 */ jal atan2f
/* 16640: 46006307 */ neg.s $f12,$f12
/* 16644: e6200004 */ swc1 $f0,0x4($s1)
/* 16648: c60e0000 */ lwc1 $f14,0x0($s0)
/* 1664c: 0fc259d4 */ jal atan2f
/* 16650: c60c0004 */ lwc1 $f12,0x4($s0)
/* 16654: 1000000e */ b .L00016690
/* 16658: e6200008 */ swc1 $f0,0x8($s1)
/* 1665c: 44805000 */ mtc1 $zero,$f10
.L00016660:
/* 16660: 00000000 */ nop
/* 16664: e62a0000 */ swc1 $f10,0x0($s1)
/* 16668: c60c0008 */ lwc1 $f12,0x8($s0)
/* 1666c: c7ae0024 */ lwc1 $f14,0x24($sp)
/* 16670: 0fc259d4 */ jal atan2f
/* 16674: 46006307 */ neg.s $f12,$f12
/* 16678: e6200004 */ swc1 $f0,0x4($s1)
/* 1667c: c60c0010 */ lwc1 $f12,0x10($s0)
/* 16680: c60e0014 */ lwc1 $f14,0x14($s0)
/* 16684: 0fc259d4 */ jal atan2f
/* 16688: 46006307 */ neg.s $f12,$f12
/* 1668c: e6200008 */ swc1 $f0,0x8($s1)
.L00016690:
/* 16690: 8fbf001c */ lw $ra,0x1c($sp)
/* 16694: 8fb00014 */ lw $s0,0x14($sp)
/* 16698: 8fb10018 */ lw $s1,0x18($sp)
/* 1669c: 03e00008 */ jr $ra
/* 166a0: 27bd0028 */ addiu $sp,$sp,0x28
);
#define EPSILON 0.0000019073486f
void mtx000166a4(struct coord *pos, struct coord *rot, Mtxf *matrix)
void mtx4GetRotation(f32 mtx[4][4], struct coord *dst)
{
mtx4LoadRotation(rot, matrix);
mtx4SetTranslation(pos, matrix);
f32 norm;
f32 sin_x_cos_y = mtx[1][2];
f32 cos_x_cos_y = mtx[2][2];
norm = sqrtf(sin_x_cos_y * sin_x_cos_y + cos_x_cos_y * cos_x_cos_y);
if (EPSILON < norm) {
dst->x = atan2f(mtx[1][2], mtx[2][2]);
dst->y = atan2f(-mtx[0][2], norm);
dst->z = atan2f(mtx[0][1], mtx[0][0]);
} else {
dst->x = 0;
dst->y = atan2f(-mtx[0][2], norm);
dst->z = atan2f(-mtx[1][0], mtx[1][1]);
}
}
void mtx000166dc(struct coord *pos, Mtxf *matrix)
void mtx4LoadRotationAndTranslation(struct coord *pos, struct coord *rot, Mtxf *mtx)
{
mtx4LoadIdentity(matrix);
mtx4SetTranslation(pos, matrix);
mtx4LoadRotation(rot, mtx);
mtx4SetTranslation(pos, mtx);
}
void mtx4LoadTranslation(struct coord *pos, Mtxf *mtx)
{
mtx4LoadIdentity(mtx);
mtx4SetTranslation(pos, mtx);
}
void mtx00016710(f32 mult, f32 mtx[4][4])