Create functionally equivalent C for handwritten modelasm functions

This commit is contained in:
Ryan Dwyer
2023-04-30 22:50:56 +10:00
parent 63c57f9075
commit 7349c3b172
6 changed files with 1729 additions and 86 deletions
+1 -1
View File
@@ -97,7 +97,7 @@ void bheadReset(void)
struct modelrenderdata renderdata = {NULL, 1, 3};
Mtxf sp48;
modelSetAnimation(&g_Vars.currentplayer->model, 1, 0, 0, 0.5f, 0);
modelSetAnimation(&g_Vars.currentplayer->model, ANIM_TWO_GUN_HOLD, 0, 0, 0.5f, 0);
modelUpdateInfo(&g_Vars.currentplayer->model);
mtx4LoadIdentity(&sp48);
-4
View File
@@ -42,10 +42,6 @@ extern bool var8005eedc;
extern f32 var8005ef10[2];
extern s32 g_NumGlobalAilists;
extern s32 g_NumLvAilists;
extern u32 var8005ef40;
extern u32 var8005ef5c;
extern u32 var8005ef7c;
extern u32 var8005ef90;
extern bool g_ModelDistanceDisabled;
extern f32 g_ModelDistanceScale;
extern bool var8005efbc;
+1 -1
View File
@@ -8,7 +8,7 @@ extern bool (*var8005efc4)(struct model *model, struct modelnode *node);
extern struct gfxvtx *(*g_ModelVtxAllocatorFunc)(s32 numvertices);
extern void (*g_ModelJointPositionedFunc)(s32 mtxindex, Mtxf *mtx);
bool model00018680(struct modelrenderdata *renderdata, struct model *model);
bool modelasm00018680(struct modelrenderdata *renderdata, struct model *model);
void modelSetDistanceScale(f32 value);
void modelSetVtxAllocatorFunc(struct gfxvtx *(*fn)(s32 numvertices));
s32 modelFindNodeMtxIndex(struct modelnode *node, s32 arg1);
+2 -2
View File
@@ -1555,11 +1555,11 @@ void modelSetMatrices(struct modelrenderdata *renderdata, struct model *model)
renderdata->unk10 += model->definition->nummatrices;
#if VERSION >= VERSION_PAL_BETA
if (var8005efb0_2 || !model00018680(renderdata, model)) {
if (var8005efb0_2 || !modelasm00018680(renderdata, model)) {
modelUpdateMatrices(renderdata, model);
}
#else
if (!model00018680(renderdata, model)) {
if (!modelasm00018680(renderdata, model)) {
modelUpdateMatrices(renderdata, model);
}
#endif
+78 -78
View File
@@ -15,23 +15,23 @@ glabel var8005ef40
.word 0x00000000
glabel var8005ef5c
.word model00018680+0xef4
.word model00018680+0xa3c
.word model00018680+0x3a8
.word model00018680+0x990
.word model00018680+0xecc
.word model00018680+0xed4
.word model00018680+0xe60
.word model00018680+0xe24
.word modelasm00018680+0xef4
.word modelasm00018680+0xa3c
.word modelasm00018680+0x3a8
.word modelasm00018680+0x990
.word modelasm00018680+0xecc
.word modelasm00018680+0xed4
.word modelasm00018680+0xe60
.word modelasm00018680+0xe24
glabel var8005ef7c
.word 0x00000000
glabel var8005ef80
.word model00019be0+0x84
.word model00019be0+0x90
.word model00019be0+0xa8
.word model00019be0+0xcc
.word modelasmReadFrameData+0x84
.word modelasmReadFrameData+0x90
.word modelasmReadFrameData+0xa8
.word modelasmReadFrameData+0xcc
glabel var8005ef90
.word 0xff08ffff
@@ -121,7 +121,7 @@ glabel var70054270
.text
glabel model00018680
glabel modelasm00018680
addiu $sp, $sp, -2048
sw $s0, 0x780($sp)
sw $s1, 0x784($sp)
@@ -194,7 +194,7 @@ glabel model00018680
sll $t6, $t6, 0x2
add $t6, $t5, $t6
lw $t6, 0x0($t6)
jal model00019634
jal modelasmIterateThings1
addi $gp, $zero, 0x0
mtc1 $zero, $f1
lwc1 $f0, 0x10($a2)
@@ -247,7 +247,7 @@ glabel model00018680
sll $t6, $t6, 0x2
add $t6, $t5, $t6
lw $t6, 0x0($t6)
jal model000198dc
jal modelasmIterateThings2
addi $gp, $zero, 0x0
.L00018874:
mtc1 $zero, $f1
@@ -289,7 +289,7 @@ glabel model00018680
sll $t6, $t6, 0x2
add $t6, $t5, $t6
lw $t6, 0x0($t6)
jal model00019634
jal modelasmIterateThings1
addi $gp, $zero, 0x0
mtc1 $zero, $f1
lwc1 $f0, 0x34($a2)
@@ -334,7 +334,7 @@ glabel model00018680
sll $t6, $t6, 0x2
add $t6, $t5, $t6
lw $t6, 0x0($t6)
jal model000198dc
jal modelasmIterateThings2
addi $gp, $zero, 0x0
.L000189cc:
lw $a3, 0x8($a1)
@@ -438,9 +438,9 @@ glabel model00018680
lhu $s3, 0x3c4($t0)
lhu $s4, 0x3c6($t0)
.L00018b3c:
jal model0001a024
jal modelasmPrepareRotMtx360
sw $t0, 0x7e8($sp)
jal model00019f2c
jal modelasmMathPain2
nop
mov.s $f16, $f0
mov.s $f17, $f1
@@ -448,11 +448,11 @@ glabel model00018680
mov.s $f19, $f3
or $t2, $s2, $zero
or $t3, $s3, $zero
jal model0001a024
jal modelasmPrepareRotMtx360
or $t4, $s4, $zero
jal model00019f2c
jal modelasmMathPain2
nop
jal model00019ddc
jal modelasmMathPain1
lwc1 $f30, 0x7e0($sp)
addiu $t0, $zero, 0x1
sw $t0, 0x7e4($sp)
@@ -461,7 +461,7 @@ glabel model00018680
swc1 $f1, 0x7ec($sp)
swc1 $f2, 0x7f0($sp)
swc1 $f3, 0x7f4($sp)
jal model0001a110
jal modelasmMathPain4
nop
j .L00018c6c
nop
@@ -516,9 +516,9 @@ glabel model00018680
add $s0, $zero, $t2
add $s1, $zero, $t3
add $s2, $zero, $t4
jal model00019f98
jal modelasmPrepareRotMtx180
add $s3, $zero, $t0
jal model0001a0ac
jal modelasmMathPain3
add $t0, $zero, $s3
.L00018c6c:
andi $t2, $s8, 0x2
@@ -576,7 +576,7 @@ glabel model00018680
lw $t0, 0x8($gp)
beqz $t0, .L00018d48
nop
jal model0001a25c
jal modelasmFindNodeMtx
nop
b .L00018d4c
nop
@@ -587,7 +587,7 @@ glabel model00018680
lhu $t2, 0xe($t1)
sll $t2, $t2, 0x6
lw $t1, 0xc($a1)
jal model0001a1c0
jal modelasmMtxMultiply
add $t1, $t1, $t2
lui $t3, %hi(g_ModelJointPositionedFunc)
addiu $t3, $t3, %lo(g_ModelJointPositionedFunc)
@@ -677,9 +677,9 @@ glabel model00018680
add $t2, $zero, $s0
add $t3, $zero, $s1
add $t4, $zero, $s2
jal model0001a024
jal modelasmPrepareRotMtx360
add $s0, $zero, $t0
jal model00019f2c
jal modelasmMathPain2
add $t0, $zero, $s0
.L00018ecc:
lui $at, 0x3f00
@@ -714,7 +714,7 @@ glabel model00018680
c.le.s $f6, $f7
bc1f .L00018f8c
nop
jal model0001a2dc
jal modelasmAcosOrAsin
nop
mov.s $f17, $f0
mul.s $f12, $f6, $f8
@@ -744,12 +744,12 @@ glabel model00018680
mul.s $f3, $f3, $f8
add.s $f0, $f0, $f4
.L00018fb4:
jal model0001a110
jal modelasmMathPain4
lw $t1, 0x4($gp)
lhu $t2, 0x10($t1)
sll $t2, $t2, 0x6
lw $t1, 0xc($a1)
jal model0001a1c0
jal modelasmMtxMultiply
add $t1, $t1, $t2
j .L00019574
nop
@@ -769,11 +769,11 @@ glabel model00018680
lhu $s8, 0x0($t0)
.L0001900c:
syscall
jal model0001a25c
jal modelasmFindNodeMtx
add $t0, $zero, $gp
lui $t2, %hi(g_ModelDistanceDisabled)
addiu $t2, $t2, %lo(g_ModelDistanceDisabled)
jal model00019d1c
jal modelasmGetNodeRwData
lw $t1, 0x4($gp)
lw $t2, 0x0($t2)
bnez $t2, .L00019068
@@ -891,9 +891,9 @@ glabel model00018680
lhu $s3, 0x3c4($t0)
lhu $s4, 0x3c6($t0)
.L000191cc:
jal model0001a024
jal modelasmPrepareRotMtx360
sw $t0, 0x7e8($sp)
jal model00019f2c
jal modelasmMathPain2
nop
mov.s $f16, $f0
mov.s $f17, $f1
@@ -901,14 +901,14 @@ glabel model00018680
mov.s $f19, $f3
or $t2, $s2, $zero
or $t3, $s3, $zero
jal model0001a024
jal modelasmPrepareRotMtx360
or $t4, $s4, $zero
jal model00019f2c
jal modelasmMathPain2
nop
jal model00019ddc
jal modelasmMathPain1
lwc1 $f30, 0x7e0($sp)
lw $t0, 0x7e8($sp)
jal model0001a110
jal modelasmMathPain4
nop
j .L000192a8
nop
@@ -936,7 +936,7 @@ glabel model00018680
.L0001926c:
andi $t3, $t3, 0xffff
andi $t4, $t4, 0xffff
jal model00019f98
jal modelasmPrepareRotMtx180
lhu $t2, 0x2($t0)
b .L000192a0
nop
@@ -946,13 +946,13 @@ glabel model00018680
lhu $s8, 0x0($t0)
lhu $t4, 0x6($t0)
lhu $t3, 0x4($t0)
jal model00019f98
jal modelasmPrepareRotMtx180
lhu $t2, 0x2($t0)
.L000192a0:
jal model0001a0ac
jal modelasmMathPain3
nop
.L000192a8:
jal model00019d1c
jal modelasmGetNodeRwData
mtc1 $zero, $f0
mov.s $f27, $f12
mov.s $f28, $f13
@@ -1066,7 +1066,7 @@ glabel model00018680
lhu $t2, 0x2($t1)
sll $t2, $t2, 0x6
lw $t1, 0xc($a1)
jal model0001a1c0
jal modelasmMtxMultiply
add $t1, $t1, $t2
j .L00019574
nop
@@ -1086,7 +1086,7 @@ glabel model00018680
lhu $s8, 0x0($t0)
.L000194a0:
syscall
jal model00019d1c
jal modelasmGetNodeRwData
nop
lw $t1, 0x0($v0)
beqz $t1, .L00019574
@@ -1108,7 +1108,7 @@ glabel model00018680
j .L000194fc
lw $t0, 0x0($a0)
.L000194f4:
jal model0001a25c
jal modelasmFindNodeMtx
nop
.L000194fc:
lw $t1, 0x4($gp)
@@ -1127,13 +1127,13 @@ glabel model00018680
lhu $t2, 0xc($t1)
sll $t2, $t2, 0x6
lw $t1, 0xc($a1)
jal model0001a1c0
jal modelasmMtxMultiply
add $t1, $t1, $t2
j .L00019574
nop
j .L00019574
nop
jal model00019d1c
jal modelasmGetNodeRwData
lw $t0, 0x4($gp)
lw $t1, 0x0($v0)
beqz $t1, .L00019570
@@ -1196,7 +1196,7 @@ glabel model00018680
addiu $sp, $sp, 0x800
syscall
glabel model00019634
glabel modelasmIterateThings1
sw $ra, 0x7ac($sp)
.L00019638:
lbu $t7, 0x0($t2)
@@ -1238,7 +1238,7 @@ glabel model00019634
j .L00019808
addi $t2, $t2, 0xc
.L000196cc:
jal model00019be0
jal modelasmReadFrameData
lbu $v1, 0x2($t2)
add $s0, $zero, $v0
lbu $v1, 0x2($t2)
@@ -1264,7 +1264,7 @@ glabel model00019634
addu $s3, $s3, $s4
addu $s0, $s0, $s3
andi $s0, $s0, 0xffff
jal model00019be0
jal modelasmReadFrameData
lbu $v1, 0x5($t2)
add $s1, $zero, $v0
lbu $v1, 0x5($t2)
@@ -1290,7 +1290,7 @@ glabel model00019634
addu $s3, $s3, $s4
addu $s1, $s1, $s3
andi $s1, $s1, 0xffff
jal model00019be0
jal modelasmReadFrameData
lbu $v1, 0x8($t2)
add $s2, $zero, $v0
lbu $v1, 0x8($t2)
@@ -1328,7 +1328,7 @@ glabel model00019634
j .L000198b4
addi $s2, $zero, 0x0
.L00019820:
jal model00019be0
jal modelasmReadFrameData
lbu $v1, 0x2($t2)
add $s0, $zero, $v0
lbu $v1, 0x0($t2)
@@ -1340,7 +1340,7 @@ glabel model00019634
sub $v0, $v0, $t4
sllv $s0, $s0, $v0
andi $s0, $s0, 0xffff
jal model00019be0
jal modelasmReadFrameData
lbu $v1, 0x5($t2)
add $s1, $zero, $v0
lbu $v1, 0x3($t2)
@@ -1352,7 +1352,7 @@ glabel model00019634
sub $v0, $v0, $t4
sllv $s1, $s1, $v0
andi $s1, $s1, 0xffff
jal model00019be0
jal modelasmReadFrameData
lbu $v1, 0x8($t2)
add $s2, $zero, $v0
lbu $v1, 0x6($t2)
@@ -1377,7 +1377,7 @@ glabel model00019634
jr $ra
nop
glabel model000198dc
glabel modelasmIterateThings2
sw $ra, 0x7ac($sp)
.L000198e0:
lbu $t7, 0x0($t2)
@@ -1445,7 +1445,7 @@ glabel model000198dc
j .L00019a64
addi $s2, $zero, 0x0
.L000199d0:
jal model00019be0
jal modelasmReadFrameData
lbu $v1, 0x2($t2)
add $s0, $zero, $v0
lbu $v1, 0x0($t2)
@@ -1457,7 +1457,7 @@ glabel model000198dc
sub $v0, $v0, $t4
sllv $s0, $s0, $v0
andi $s0, $s0, 0xffff
jal model00019be0
jal modelasmReadFrameData
lbu $v1, 0x5($t2)
add $s1, $zero, $v0
lbu $v1, 0x3($t2)
@@ -1469,7 +1469,7 @@ glabel model000198dc
sub $v0, $v0, $t4
sllv $s1, $s1, $v0
andi $s1, $s1, 0xffff
jal model00019be0
jal modelasmReadFrameData
lbu $v1, 0x8($t2)
add $s2, $zero, $v0
lbu $v1, 0x6($t2)
@@ -1588,7 +1588,7 @@ glabel model000198dc
jr $ra
nop
glabel model00019be0
glabel modelasmReadFrameData
beqz $v1, .L00019d14
addi $v0, $zero, 0x0
.L00019be8:
@@ -1675,7 +1675,7 @@ glabel model00019be0
jr $ra
nop
glabel model00019d1c
glabel modelasmGetNodeRwData
addiu $sp, $sp, -32
sw $gp, 0x0($sp)
sw $t0, 0x4($sp)
@@ -1712,7 +1712,7 @@ glabel model00019d1c
addiu $at, $zero, 0x17
bne $t1, $at, .L00019d84
nop
jal model00019d1c
jal modelasmGetNodeRwData
nop
lw $t3, 0x4($v0)
.L00019db0:
@@ -1781,7 +1781,7 @@ glabel modelGetNodeRwData
addiu $sp, $sp, 0x10
#endif
glabel model00019ddc
glabel modelasmMathPain1
sw $ra, 0x7ac($sp)
.L00019de0:
mul.s $f5, $f16, $f0
@@ -1831,7 +1831,7 @@ glabel model00019ddc
c.le.s $f6, $f7
bc1f .L00019f20
nop
jal model0001a2dc
jal modelasmAcosOrAsin
nop
mov.s $f20, $f0
jal sinf
@@ -1872,7 +1872,7 @@ glabel model00019ddc
j .L00019ed8
sub.s $f5, $f5, $f30
glabel model00019f2c
glabel modelasmMathPain2
mul.s $f6, $f0, $f2
nop
mul.s $f7, $f0, $f3
@@ -1901,7 +1901,7 @@ glabel model00019f2c
jr $ra
sub.s $f3, $f26, $f10
glabel model00019f98
glabel modelasmPrepareRotMtx180
add $t5, $zero, $ra
lui $at, %hi(var7005422c)
lwc1 $f29, %lo(var7005422c)($at)
@@ -1938,7 +1938,7 @@ glabel model00019f98
jr $ra
nop
glabel model0001a024
glabel modelasmPrepareRotMtx360
add $t5, $zero, $ra
lui $at, %hi(var70054234)
lwc1 $f29, %lo(var70054234)($at)
@@ -1974,7 +1974,7 @@ glabel model0001a024
jr $ra
nop
glabel model0001a0ac
glabel modelasmMathPain3
mul.s $f6, $f1, $f5
nop
mul.s $f7, $f0, $f5
@@ -2001,7 +2001,7 @@ glabel model0001a0ac
jr $ra
sub.s $f19, $f19, $f8
glabel model0001a110
glabel modelasmMathPain4
mul.s $f4, $f0, $f0
nop
mul.s $f5, $f1, $f1
@@ -2047,7 +2047,7 @@ glabel model0001a110
jr $ra
sub.s $f20, $f20, $f26
glabel model0001a1c0
glabel modelasmMtxMultiply
addiu $t2, $zero, 0x3
.L0001a1c4:
lwc1 $f0, 0x0($t0)
@@ -2089,7 +2089,7 @@ glabel model0001a1c0
jr $ra
swc1 $f31, 0x30($t1)
glabel model0001a25c
glabel modelasmFindNodeMtx
.L0001a25c:
lh $t1, 0x0($t0)
andi $t1, $t1, 0xff
@@ -2127,7 +2127,7 @@ glabel model0001a25c
jr $ra
add $t0, $zero, $zero
glabel model0001a2dc
glabel modelasmAcosOrAsin
lui $at, %hi(var7005423c)
lwc1 $f7, %lo(var7005423c)($at)
mul.s $f7, $f6, $f7
@@ -2204,12 +2204,12 @@ glabel cosf
glabel sinf
mfc1 $t0, $f12
nop
nop
sra $t0, $t0, 22
andi $t0, $t0, 0x1ff
slti $at, $t0, 255
beqz $at, .L0001a454
nop
nop
slti $at, $t0, 230
bnez $at, .L0001a4f0
mov.s $f0, $f12
@@ -2229,7 +2229,7 @@ glabel sinf
mul.s $f15, $f15, $f14
add.s $f15, $f13, $f15
mul.s $f15, $f15, $f14
nop
nop
mul.s $f15, $f15, $f12
jr $ra
add.s $f0, $f15, $f12
@@ -2267,7 +2267,7 @@ glabel sinf
mul.s $f15, $f15, $f14
add.s $f15, $f13, $f15
mul.s $f15, $f15, $f14
nop
nop
mul.s $f15, $f15, $f12
andi $t1, $t1, 1
add.s $f0, $f15, $f12
@@ -2275,4 +2275,4 @@ glabel sinf
neg.s $f0, $f0
.L0001a4f0:
jr $ra
nop
nop
+1647
View File
File diff suppressed because it is too large Load Diff