From 24babfa95a4c296b3895ae1c937ef6bdb80ed34d Mon Sep 17 00:00:00 2001 From: KrimtonZ Date: Mon, 30 Mar 2020 17:53:26 -0500 Subject: [PATCH] skelanime update wip --- .../SkelAnime_LinkChangeAnimation.s | 2 +- .../code/z_skelanime/func_800A2E70.s | 297 ------------------ .../code/z_skelanime/func_800A4AD8.s | 10 +- .../code/z_skelanime/func_800A4C58.s | 4 +- .../actors/ovl_En_Test/EnTest_Update.s | 2 +- include/functions.h | 6 +- include/z64animation.h | 2 +- src/code/sys_matrix.c | 4 +- src/code/z_skelanime.c | 254 +++++++-------- 9 files changed, 122 insertions(+), 459 deletions(-) delete mode 100644 asm/non_matchings/code/z_skelanime/func_800A2E70.s diff --git a/asm/non_matchings/code/z_skelanime/SkelAnime_LinkChangeAnimation.s b/asm/non_matchings/code/z_skelanime/SkelAnime_LinkChangeAnimation.s index 3fec499471..572676843c 100644 --- a/asm/non_matchings/code/z_skelanime/SkelAnime_LinkChangeAnimation.s +++ b/asm/non_matchings/code/z_skelanime/SkelAnime_LinkChangeAnimation.s @@ -84,7 +84,7 @@ glabel SkelAnime_LinkChangeAnimation /* B1B1DC 800A403C C7B20038 */ lwc1 $f18, 0x38($sp) /* B1B1E0 800A4040 E6120018 */ swc1 $f18, 0x18($s0) /* B1B1E4 800A4044 C7A4003C */ lwc1 $f4, 0x3c($sp) -/* B1B1E8 800A4048 0C0287F2 */ jal func_800A1FC8 +/* B1B1E8 800A4048 0C0287F2 */ jal SkelAnime_GetTotalFrames /* B1B1EC 800A404C E6040010 */ swc1 $f4, 0x10($s0) /* B1B1F0 800A4050 44823000 */ mtc1 $v0, $f6 /* B1B1F4 800A4054 00000000 */ nop diff --git a/asm/non_matchings/code/z_skelanime/func_800A2E70.s b/asm/non_matchings/code/z_skelanime/func_800A2E70.s deleted file mode 100644 index 9eeadbd18a..0000000000 --- a/asm/non_matchings/code/z_skelanime/func_800A2E70.s +++ /dev/null @@ -1,297 +0,0 @@ -glabel func_800A2E70 -/* B1A010 800A2E70 27BDFFF8 */ addiu $sp, $sp, -8 -/* B1A014 800A2E74 3C013F80 */ li $at, 0x3F800000 # 0.000000 -/* B1A018 800A2E78 C7AC0018 */ lwc1 $f12, 0x18($sp) -/* B1A01C 800A2E7C 44812000 */ mtc1 $at, $f4 -/* B1A020 800A2E80 AFB00004 */ sw $s0, 4($sp) -/* B1A024 800A2E84 00A08025 */ move $s0, $a1 -/* B1A028 800A2E88 4604603C */ c.lt.s $f12, $f4 -/* B1A02C 800A2E8C 00000000 */ nop -/* B1A030 800A2E90 450000E6 */ bc1f .L800A322C -/* B1A034 800A2E94 00000000 */ nop -/* B1A038 800A2E98 18800111 */ blez $a0, .L800A32E0 -/* B1A03C 800A2E9C 00001025 */ move $v0, $zero -/* B1A040 800A2EA0 30830001 */ andi $v1, $a0, 1 -/* B1A044 800A2EA4 50600030 */ beql $v1, $zero, .L800A2F68 -/* B1A048 800A2EA8 24420002 */ addiu $v0, $v0, 2 -/* B1A04C 800A2EAC 84C30000 */ lh $v1, ($a2) -/* B1A050 800A2EB0 84EE0000 */ lh $t6, ($a3) -/* B1A054 800A2EB4 24020001 */ li $v0, 1 -/* B1A058 800A2EB8 26100006 */ addiu $s0, $s0, 6 -/* B1A05C 800A2EBC 01C32823 */ subu $a1, $t6, $v1 -/* B1A060 800A2EC0 00052C00 */ sll $a1, $a1, 0x10 -/* B1A064 800A2EC4 00052C03 */ sra $a1, $a1, 0x10 -/* B1A068 800A2EC8 44853000 */ mtc1 $a1, $f6 -/* B1A06C 800A2ECC 24C60006 */ addiu $a2, $a2, 6 -/* B1A070 800A2ED0 24E70006 */ addiu $a3, $a3, 6 -/* B1A074 800A2ED4 46803220 */ cvt.s.w $f8, $f6 -/* B1A078 800A2ED8 460C4282 */ mul.s $f10, $f8, $f12 -/* B1A07C 800A2EDC 4600540D */ trunc.w.s $f16, $f10 -/* B1A080 800A2EE0 44088000 */ mfc1 $t0, $f16 -/* B1A084 800A2EE4 00000000 */ nop -/* B1A088 800A2EE8 01034821 */ addu $t1, $t0, $v1 -/* B1A08C 800A2EEC A609FFFA */ sh $t1, -6($s0) -/* B1A090 800A2EF0 84EAFFFC */ lh $t2, -4($a3) -/* B1A094 800A2EF4 84C3FFFC */ lh $v1, -4($a2) -/* B1A098 800A2EF8 01432823 */ subu $a1, $t2, $v1 -/* B1A09C 800A2EFC 00052C00 */ sll $a1, $a1, 0x10 -/* B1A0A0 800A2F00 00052C03 */ sra $a1, $a1, 0x10 -/* B1A0A4 800A2F04 44859000 */ mtc1 $a1, $f18 -/* B1A0A8 800A2F08 00000000 */ nop -/* B1A0AC 800A2F0C 46809120 */ cvt.s.w $f4, $f18 -/* B1A0B0 800A2F10 460C2182 */ mul.s $f6, $f4, $f12 -/* B1A0B4 800A2F14 4600320D */ trunc.w.s $f8, $f6 -/* B1A0B8 800A2F18 440E4000 */ mfc1 $t6, $f8 -/* B1A0BC 800A2F1C 00000000 */ nop -/* B1A0C0 800A2F20 01C37821 */ addu $t7, $t6, $v1 -/* B1A0C4 800A2F24 A60FFFFC */ sh $t7, -4($s0) -/* B1A0C8 800A2F28 84F8FFFE */ lh $t8, -2($a3) -/* B1A0CC 800A2F2C 84C3FFFE */ lh $v1, -2($a2) -/* B1A0D0 800A2F30 03032823 */ subu $a1, $t8, $v1 -/* B1A0D4 800A2F34 00052C00 */ sll $a1, $a1, 0x10 -/* B1A0D8 800A2F38 00052C03 */ sra $a1, $a1, 0x10 -/* B1A0DC 800A2F3C 44855000 */ mtc1 $a1, $f10 -/* B1A0E0 800A2F40 00000000 */ nop -/* B1A0E4 800A2F44 46805420 */ cvt.s.w $f16, $f10 -/* B1A0E8 800A2F48 460C8482 */ mul.s $f18, $f16, $f12 -/* B1A0EC 800A2F4C 4600910D */ trunc.w.s $f4, $f18 -/* B1A0F0 800A2F50 440A2000 */ mfc1 $t2, $f4 -/* B1A0F4 800A2F54 00000000 */ nop -/* B1A0F8 800A2F58 01435821 */ addu $t3, $t2, $v1 -/* B1A0FC 800A2F5C 104400E0 */ beq $v0, $a0, .L800A32E0 -/* B1A100 800A2F60 A60BFFFE */ sh $t3, -2($s0) -/* B1A104 800A2F64 24420002 */ addiu $v0, $v0, 2 -.L800A2F68: -/* B1A108 800A2F68 84C30000 */ lh $v1, ($a2) -/* B1A10C 800A2F6C 10440059 */ beq $v0, $a0, .L800A30D4 -/* B1A110 800A2F70 84EC0000 */ lh $t4, ($a3) -.L800A2F74: -/* B1A114 800A2F74 01832823 */ subu $a1, $t4, $v1 -/* B1A118 800A2F78 00052C00 */ sll $a1, $a1, 0x10 -/* B1A11C 800A2F7C 00052C03 */ sra $a1, $a1, 0x10 -/* B1A120 800A2F80 44859000 */ mtc1 $a1, $f18 -/* B1A124 800A2F84 24420002 */ addiu $v0, $v0, 2 -/* B1A128 800A2F88 2610000C */ addiu $s0, $s0, 0xc -/* B1A12C 800A2F8C 468094A0 */ cvt.s.w $f18, $f18 -/* B1A130 800A2F90 24C6000C */ addiu $a2, $a2, 0xc -/* B1A134 800A2F94 24E7000C */ addiu $a3, $a3, 0xc -/* B1A138 800A2F98 460C9482 */ mul.s $f18, $f18, $f12 -/* B1A13C 800A2F9C 4600948D */ trunc.w.s $f18, $f18 -/* B1A140 800A2FA0 44189000 */ mfc1 $t8, $f18 -/* B1A144 800A2FA4 00000000 */ nop -/* B1A148 800A2FA8 0303C821 */ addu $t9, $t8, $v1 -/* B1A14C 800A2FAC A619FFF4 */ sh $t9, -0xc($s0) -/* B1A150 800A2FB0 84C3FFF6 */ lh $v1, -0xa($a2) -/* B1A154 800A2FB4 84E8FFF6 */ lh $t0, -0xa($a3) -/* B1A158 800A2FB8 01032823 */ subu $a1, $t0, $v1 -/* B1A15C 800A2FBC 00052C00 */ sll $a1, $a1, 0x10 -/* B1A160 800A2FC0 00052C03 */ sra $a1, $a1, 0x10 -/* B1A164 800A2FC4 44859000 */ mtc1 $a1, $f18 -/* B1A168 800A2FC8 00000000 */ nop -/* B1A16C 800A2FCC 468094A0 */ cvt.s.w $f18, $f18 -/* B1A170 800A2FD0 460C9482 */ mul.s $f18, $f18, $f12 -/* B1A174 800A2FD4 4600948D */ trunc.w.s $f18, $f18 -/* B1A178 800A2FD8 440C9000 */ mfc1 $t4, $f18 -/* B1A17C 800A2FDC 00000000 */ nop -/* B1A180 800A2FE0 01836821 */ addu $t5, $t4, $v1 -/* B1A184 800A2FE4 A60DFFF6 */ sh $t5, -0xa($s0) -/* B1A188 800A2FE8 84C3FFF8 */ lh $v1, -8($a2) -/* B1A18C 800A2FEC 84EEFFF8 */ lh $t6, -8($a3) -/* B1A190 800A2FF0 01C32823 */ subu $a1, $t6, $v1 -/* B1A194 800A2FF4 00052C00 */ sll $a1, $a1, 0x10 -/* B1A198 800A2FF8 00052C03 */ sra $a1, $a1, 0x10 -/* B1A19C 800A2FFC 44859000 */ mtc1 $a1, $f18 -/* B1A1A0 800A3000 00000000 */ nop -/* B1A1A4 800A3004 468094A0 */ cvt.s.w $f18, $f18 -/* B1A1A8 800A3008 460C9482 */ mul.s $f18, $f18, $f12 -/* B1A1AC 800A300C 4600948D */ trunc.w.s $f18, $f18 -/* B1A1B0 800A3010 44089000 */ mfc1 $t0, $f18 -/* B1A1B4 800A3014 00000000 */ nop -/* B1A1B8 800A3018 01034821 */ addu $t1, $t0, $v1 -/* B1A1BC 800A301C A609FFF8 */ sh $t1, -8($s0) -/* B1A1C0 800A3020 84C3FFFA */ lh $v1, -6($a2) -/* B1A1C4 800A3024 84EAFFFA */ lh $t2, -6($a3) -/* B1A1C8 800A3028 01432823 */ subu $a1, $t2, $v1 -/* B1A1CC 800A302C 00052C00 */ sll $a1, $a1, 0x10 -/* B1A1D0 800A3030 00052C03 */ sra $a1, $a1, 0x10 -/* B1A1D4 800A3034 44859000 */ mtc1 $a1, $f18 -/* B1A1D8 800A3038 00000000 */ nop -/* B1A1DC 800A303C 468094A0 */ cvt.s.w $f18, $f18 -/* B1A1E0 800A3040 460C9482 */ mul.s $f18, $f18, $f12 -/* B1A1E4 800A3044 4600948D */ trunc.w.s $f18, $f18 -/* B1A1E8 800A3048 440E9000 */ mfc1 $t6, $f18 -/* B1A1EC 800A304C 00000000 */ nop -/* B1A1F0 800A3050 01C37821 */ addu $t7, $t6, $v1 -/* B1A1F4 800A3054 A60FFFFA */ sh $t7, -6($s0) -/* B1A1F8 800A3058 84C3FFFC */ lh $v1, -4($a2) -/* B1A1FC 800A305C 84F8FFFC */ lh $t8, -4($a3) -/* B1A200 800A3060 03032823 */ subu $a1, $t8, $v1 -/* B1A204 800A3064 00052C00 */ sll $a1, $a1, 0x10 -/* B1A208 800A3068 00052C03 */ sra $a1, $a1, 0x10 -/* B1A20C 800A306C 44859000 */ mtc1 $a1, $f18 -/* B1A210 800A3070 00000000 */ nop -/* B1A214 800A3074 468094A0 */ cvt.s.w $f18, $f18 -/* B1A218 800A3078 460C9482 */ mul.s $f18, $f18, $f12 -/* B1A21C 800A307C 4600948D */ trunc.w.s $f18, $f18 -/* B1A220 800A3080 440A9000 */ mfc1 $t2, $f18 -/* B1A224 800A3084 00000000 */ nop -/* B1A228 800A3088 01435821 */ addu $t3, $t2, $v1 -/* B1A22C 800A308C A60BFFFC */ sh $t3, -4($s0) -/* B1A230 800A3090 84C3FFFE */ lh $v1, -2($a2) -/* B1A234 800A3094 84ECFFFE */ lh $t4, -2($a3) -/* B1A238 800A3098 01832823 */ subu $a1, $t4, $v1 -/* B1A23C 800A309C 00052C00 */ sll $a1, $a1, 0x10 -/* B1A240 800A30A0 00052C03 */ sra $a1, $a1, 0x10 -/* B1A244 800A30A4 44859000 */ mtc1 $a1, $f18 -/* B1A248 800A30A8 00000000 */ nop -/* B1A24C 800A30AC 468094A0 */ cvt.s.w $f18, $f18 -/* B1A250 800A30B0 460C9482 */ mul.s $f18, $f18, $f12 -/* B1A254 800A30B4 4600948D */ trunc.w.s $f18, $f18 -/* B1A258 800A30B8 44189000 */ mfc1 $t8, $f18 -/* B1A25C 800A30BC 00000000 */ nop -/* B1A260 800A30C0 0303C821 */ addu $t9, $t8, $v1 -/* B1A264 800A30C4 A619FFFE */ sh $t9, -2($s0) -/* B1A268 800A30C8 84C30000 */ lh $v1, ($a2) -/* B1A26C 800A30CC 1444FFA9 */ bne $v0, $a0, .L800A2F74 -/* B1A270 800A30D0 84EC0000 */ lh $t4, ($a3) -.L800A30D4: -/* B1A274 800A30D4 01832823 */ subu $a1, $t4, $v1 -/* B1A278 800A30D8 00052C00 */ sll $a1, $a1, 0x10 -/* B1A27C 800A30DC 00052C03 */ sra $a1, $a1, 0x10 -/* B1A280 800A30E0 44859000 */ mtc1 $a1, $f18 -/* B1A284 800A30E4 2610000C */ addiu $s0, $s0, 0xc -/* B1A288 800A30E8 24C6000C */ addiu $a2, $a2, 0xc -/* B1A28C 800A30EC 468094A0 */ cvt.s.w $f18, $f18 -/* B1A290 800A30F0 24E7000C */ addiu $a3, $a3, 0xc -/* B1A294 800A30F4 460C9482 */ mul.s $f18, $f18, $f12 -/* B1A298 800A30F8 4600948D */ trunc.w.s $f18, $f18 -/* B1A29C 800A30FC 44189000 */ mfc1 $t8, $f18 -/* B1A2A0 800A3100 00000000 */ nop -/* B1A2A4 800A3104 0303C821 */ addu $t9, $t8, $v1 -/* B1A2A8 800A3108 A619FFF4 */ sh $t9, -0xc($s0) -/* B1A2AC 800A310C 84C3FFF6 */ lh $v1, -0xa($a2) -/* B1A2B0 800A3110 84E8FFF6 */ lh $t0, -0xa($a3) -/* B1A2B4 800A3114 01032823 */ subu $a1, $t0, $v1 -/* B1A2B8 800A3118 00052C00 */ sll $a1, $a1, 0x10 -/* B1A2BC 800A311C 00052C03 */ sra $a1, $a1, 0x10 -/* B1A2C0 800A3120 44859000 */ mtc1 $a1, $f18 -/* B1A2C4 800A3124 00000000 */ nop -/* B1A2C8 800A3128 468094A0 */ cvt.s.w $f18, $f18 -/* B1A2CC 800A312C 460C9482 */ mul.s $f18, $f18, $f12 -/* B1A2D0 800A3130 4600948D */ trunc.w.s $f18, $f18 -/* B1A2D4 800A3134 440C9000 */ mfc1 $t4, $f18 -/* B1A2D8 800A3138 00000000 */ nop -/* B1A2DC 800A313C 01836821 */ addu $t5, $t4, $v1 -/* B1A2E0 800A3140 A60DFFF6 */ sh $t5, -0xa($s0) -/* B1A2E4 800A3144 84C3FFF8 */ lh $v1, -8($a2) -/* B1A2E8 800A3148 84EEFFF8 */ lh $t6, -8($a3) -/* B1A2EC 800A314C 01C32823 */ subu $a1, $t6, $v1 -/* B1A2F0 800A3150 00052C00 */ sll $a1, $a1, 0x10 -/* B1A2F4 800A3154 00052C03 */ sra $a1, $a1, 0x10 -/* B1A2F8 800A3158 44859000 */ mtc1 $a1, $f18 -/* B1A2FC 800A315C 00000000 */ nop -/* B1A300 800A3160 468094A0 */ cvt.s.w $f18, $f18 -/* B1A304 800A3164 460C9482 */ mul.s $f18, $f18, $f12 -/* B1A308 800A3168 4600948D */ trunc.w.s $f18, $f18 -/* B1A30C 800A316C 44089000 */ mfc1 $t0, $f18 -/* B1A310 800A3170 00000000 */ nop -/* B1A314 800A3174 01034821 */ addu $t1, $t0, $v1 -/* B1A318 800A3178 A609FFF8 */ sh $t1, -8($s0) -/* B1A31C 800A317C 84EAFFFA */ lh $t2, -6($a3) -/* B1A320 800A3180 84C3FFFA */ lh $v1, -6($a2) -/* B1A324 800A3184 01432823 */ subu $a1, $t2, $v1 -/* B1A328 800A3188 00052C00 */ sll $a1, $a1, 0x10 -/* B1A32C 800A318C 00052C03 */ sra $a1, $a1, 0x10 -/* B1A330 800A3190 44859000 */ mtc1 $a1, $f18 -/* B1A334 800A3194 00000000 */ nop -/* B1A338 800A3198 468094A0 */ cvt.s.w $f18, $f18 -/* B1A33C 800A319C 460C9482 */ mul.s $f18, $f18, $f12 -/* B1A340 800A31A0 4600948D */ trunc.w.s $f18, $f18 -/* B1A344 800A31A4 440E9000 */ mfc1 $t6, $f18 -/* B1A348 800A31A8 00000000 */ nop -/* B1A34C 800A31AC 01C37821 */ addu $t7, $t6, $v1 -/* B1A350 800A31B0 A60FFFFA */ sh $t7, -6($s0) -/* B1A354 800A31B4 84F8FFFC */ lh $t8, -4($a3) -/* B1A358 800A31B8 84C3FFFC */ lh $v1, -4($a2) -/* B1A35C 800A31BC 03032823 */ subu $a1, $t8, $v1 -/* B1A360 800A31C0 00052C00 */ sll $a1, $a1, 0x10 -/* B1A364 800A31C4 00052C03 */ sra $a1, $a1, 0x10 -/* B1A368 800A31C8 44859000 */ mtc1 $a1, $f18 -/* B1A36C 800A31CC 00000000 */ nop -/* B1A370 800A31D0 468094A0 */ cvt.s.w $f18, $f18 -/* B1A374 800A31D4 460C9482 */ mul.s $f18, $f18, $f12 -/* B1A378 800A31D8 4600948D */ trunc.w.s $f18, $f18 -/* B1A37C 800A31DC 440A9000 */ mfc1 $t2, $f18 -/* B1A380 800A31E0 00000000 */ nop -/* B1A384 800A31E4 01435821 */ addu $t3, $t2, $v1 -/* B1A388 800A31E8 A60BFFFC */ sh $t3, -4($s0) -/* B1A38C 800A31EC 84ECFFFE */ lh $t4, -2($a3) -/* B1A390 800A31F0 84C3FFFE */ lh $v1, -2($a2) -/* B1A394 800A31F4 01832823 */ subu $a1, $t4, $v1 -/* B1A398 800A31F8 00052C00 */ sll $a1, $a1, 0x10 -/* B1A39C 800A31FC 00052C03 */ sra $a1, $a1, 0x10 -/* B1A3A0 800A3200 44859000 */ mtc1 $a1, $f18 -/* B1A3A4 800A3204 00000000 */ nop -/* B1A3A8 800A3208 468094A0 */ cvt.s.w $f18, $f18 -/* B1A3AC 800A320C 460C9482 */ mul.s $f18, $f18, $f12 -/* B1A3B0 800A3210 4600948D */ trunc.w.s $f18, $f18 -/* B1A3B4 800A3214 44189000 */ mfc1 $t8, $f18 -/* B1A3B8 800A3218 00000000 */ nop -/* B1A3BC 800A321C 0303C821 */ addu $t9, $t8, $v1 -/* B1A3C0 800A3220 A619FFFE */ sh $t9, -2($s0) -/* B1A3C4 800A3224 1000002F */ b .L800A32E4 -/* B1A3C8 800A3228 8FB00004 */ lw $s0, 4($sp) -.L800A322C: -/* B1A3CC 800A322C 1880002C */ blez $a0, .L800A32E0 -/* B1A3D0 800A3230 00001025 */ move $v0, $zero -/* B1A3D4 800A3234 30850003 */ andi $a1, $a0, 3 -/* B1A3D8 800A3238 10A0000D */ beqz $a1, .L800A3270 -/* B1A3DC 800A323C 00A01825 */ move $v1, $a1 -.L800A3240: -/* B1A3E0 800A3240 84E80000 */ lh $t0, ($a3) -/* B1A3E4 800A3244 24420001 */ addiu $v0, $v0, 1 -/* B1A3E8 800A3248 26100006 */ addiu $s0, $s0, 6 -/* B1A3EC 800A324C A608FFFA */ sh $t0, -6($s0) -/* B1A3F0 800A3250 84E90002 */ lh $t1, 2($a3) -/* B1A3F4 800A3254 24E70006 */ addiu $a3, $a3, 6 -/* B1A3F8 800A3258 A609FFFC */ sh $t1, -4($s0) -/* B1A3FC 800A325C 84EAFFFE */ lh $t2, -2($a3) -/* B1A400 800A3260 1462FFF7 */ bne $v1, $v0, .L800A3240 -/* B1A404 800A3264 A60AFFFE */ sh $t2, -2($s0) -/* B1A408 800A3268 5044001E */ beql $v0, $a0, .L800A32E4 -/* B1A40C 800A326C 8FB00004 */ lw $s0, 4($sp) -.L800A3270: -/* B1A410 800A3270 84EB0000 */ lh $t3, ($a3) -/* B1A414 800A3274 24420004 */ addiu $v0, $v0, 4 -/* B1A418 800A3278 26100018 */ addiu $s0, $s0, 0x18 -/* B1A41C 800A327C A60BFFE8 */ sh $t3, -0x18($s0) -/* B1A420 800A3280 84EC0002 */ lh $t4, 2($a3) -/* B1A424 800A3284 24E70018 */ addiu $a3, $a3, 0x18 -/* B1A428 800A3288 A60CFFEA */ sh $t4, -0x16($s0) -/* B1A42C 800A328C 84EDFFEC */ lh $t5, -0x14($a3) -/* B1A430 800A3290 A60DFFEC */ sh $t5, -0x14($s0) -/* B1A434 800A3294 84EEFFEE */ lh $t6, -0x12($a3) -/* B1A438 800A3298 A60EFFEE */ sh $t6, -0x12($s0) -/* B1A43C 800A329C 84EFFFF0 */ lh $t7, -0x10($a3) -/* B1A440 800A32A0 A60FFFF0 */ sh $t7, -0x10($s0) -/* B1A444 800A32A4 84F8FFF2 */ lh $t8, -0xe($a3) -/* B1A448 800A32A8 A618FFF2 */ sh $t8, -0xe($s0) -/* B1A44C 800A32AC 84F9FFF4 */ lh $t9, -0xc($a3) -/* B1A450 800A32B0 A619FFF4 */ sh $t9, -0xc($s0) -/* B1A454 800A32B4 84E8FFF6 */ lh $t0, -0xa($a3) -/* B1A458 800A32B8 A608FFF6 */ sh $t0, -0xa($s0) -/* B1A45C 800A32BC 84E9FFF8 */ lh $t1, -8($a3) -/* B1A460 800A32C0 A609FFF8 */ sh $t1, -8($s0) -/* B1A464 800A32C4 84EAFFFA */ lh $t2, -6($a3) -/* B1A468 800A32C8 A60AFFFA */ sh $t2, -6($s0) -/* B1A46C 800A32CC 84EBFFFC */ lh $t3, -4($a3) -/* B1A470 800A32D0 A60BFFFC */ sh $t3, -4($s0) -/* B1A474 800A32D4 84ECFFFE */ lh $t4, -2($a3) -/* B1A478 800A32D8 1444FFE5 */ bne $v0, $a0, .L800A3270 -/* B1A47C 800A32DC A60CFFFE */ sh $t4, -2($s0) -.L800A32E0: -/* B1A480 800A32E0 8FB00004 */ lw $s0, 4($sp) -.L800A32E4: -/* B1A484 800A32E4 03E00008 */ jr $ra -/* B1A488 800A32E8 27BD0008 */ addiu $sp, $sp, 8 - diff --git a/asm/non_matchings/code/z_skelanime/func_800A4AD8.s b/asm/non_matchings/code/z_skelanime/func_800A4AD8.s index d6fdfc52d1..0ad8d2372b 100644 --- a/asm/non_matchings/code/z_skelanime/func_800A4AD8.s +++ b/asm/non_matchings/code/z_skelanime/func_800A4AD8.s @@ -25,14 +25,14 @@ glabel func_800A4AD8 /* B1BCC0 800A4B20 4600320D */ trunc.w.s $f8, $f6 /* B1BCC4 800A4B24 46022182 */ mul.s $f6, $f4, $f2 /* B1BCC8 800A4B28 44064000 */ mfc1 $a2, $f8 -/* B1BCCC 800A4B2C 00000000 */ nop +/* B1BCCC 800A4B2C 00000000 */ nop /* B1BCD0 800A4B30 00063400 */ sll $a2, $a2, 0x10 /* B1BCD4 800A4B34 46060201 */ sub.s $f8, $f0, $f6 /* B1BCD8 800A4B38 00063403 */ sra $a2, $a2, 0x10 /* B1BCDC 800A4B3C E4880028 */ swc1 $f8, 0x28($a0) /* B1BCE0 800A4B40 C4800028 */ lwc1 $f0, 0x28($a0) /* B1BCE4 800A4B44 460A003E */ c.le.s $f0, $f10 -/* B1BCE8 800A4B48 00000000 */ nop +/* B1BCE8 800A4B48 00000000 */ nop /* B1BCEC 800A4B4C 45020008 */ bc1fl .L800A4B70 /* B1BCF0 800A4B50 3C014680 */ li $at, 0x46800000 # 0.000000 /* B1BCF4 800A4B54 0C02926C */ jal func_800A49B0 @@ -50,7 +50,7 @@ glabel func_800A4AD8 /* B1BD20 800A4B80 00042403 */ sra $a0, $a0, 0x10 /* B1BD24 800A4B84 4600218D */ trunc.w.s $f6, $f4 /* B1BD28 800A4B88 44053000 */ mfc1 $a1, $f6 -/* B1BD2C 800A4B8C 00000000 */ nop +/* B1BD2C 800A4B8C 00000000 */ nop /* B1BD30 800A4B90 00052C00 */ sll $a1, $a1, 0x10 /* B1BD34 800A4B94 05010011 */ bgez $t0, .L800A4BDC /* B1BD38 800A4B98 00052C03 */ sra $a1, $a1, 0x10 @@ -91,14 +91,14 @@ glabel func_800A4AD8 /* B1BDBC 800A4C1C 46041083 */ div.s $f2, $f2, $f4 /* B1BDC0 800A4C20 44801000 */ mtc1 $zero, $f2 .L800A4C24: -/* B1BDC4 800A4C24 00000000 */ nop +/* B1BDC4 800A4C24 00000000 */ nop .L800A4C28: /* B1BDC8 800A4C28 46023201 */ sub.s $f8, $f6, $f2 /* B1BDCC 800A4C2C 8E050020 */ lw $a1, 0x20($s0) /* B1BDD0 800A4C30 92040000 */ lbu $a0, ($s0) /* B1BDD4 800A4C34 8E070024 */ lw $a3, 0x24($s0) /* B1BDD8 800A4C38 E7A80010 */ swc1 $f8, 0x10($sp) -/* B1BDDC 800A4C3C 0C028B9C */ jal func_800A2E70 +/* B1BDDC 800A4C3C 0C028B9C */ jal SkelAnime_InterpolateRotation /* B1BDE0 800A4C40 00A03025 */ move $a2, $a1 /* B1BDE4 800A4C44 8FBF0024 */ lw $ra, 0x24($sp) /* B1BDE8 800A4C48 8FB00020 */ lw $s0, 0x20($sp) diff --git a/asm/non_matchings/code/z_skelanime/func_800A4C58.s b/asm/non_matchings/code/z_skelanime/func_800A4C58.s index a3d3e672da..febab2e59c 100644 --- a/asm/non_matchings/code/z_skelanime/func_800A4C58.s +++ b/asm/non_matchings/code/z_skelanime/func_800A4C58.s @@ -45,7 +45,7 @@ glabel func_800A4C58 /* B1BE8C 800A4CEC 92040000 */ lbu $a0, ($s0) /* B1BE90 800A4CF0 27A70038 */ addiu $a3, $sp, 0x38 /* B1BE94 800A4CF4 E7A20010 */ swc1 $f2, 0x10($sp) -/* B1BE98 800A4CF8 0C028B9C */ jal func_800A2E70 +/* B1BE98 800A4CF8 0C028B9C */ jal SkelAnime_InterpolateRotation /* B1BE9C 800A4CFC 00A03025 */ move $a2, $a1 /* B1BEA0 800A4D00 C6000028 */ lwc1 $f0, 0x28($s0) .L800A4D04: @@ -81,7 +81,7 @@ glabel func_800A4C58 /* B1BF14 800A4D74 92040000 */ lbu $a0, ($s0) /* B1BF18 800A4D78 8E070024 */ lw $a3, 0x24($s0) /* B1BF1C 800A4D7C E7A00010 */ swc1 $f0, 0x10($sp) -/* B1BF20 800A4D80 0C028B9C */ jal func_800A2E70 +/* B1BF20 800A4D80 0C028B9C */ jal SkelAnime_InterpolateRotation /* B1BF24 800A4D84 00A03025 */ move $a2, $a1 .L800A4D88: /* B1BF28 800A4D88 8FBF0024 */ lw $ra, 0x24($sp) diff --git a/asm/non_matchings/overlays/actors/ovl_En_Test/EnTest_Update.s b/asm/non_matchings/overlays/actors/ovl_En_Test/EnTest_Update.s index 2171f44ba3..7df8988a13 100644 --- a/asm/non_matchings/overlays/actors/ovl_En_Test/EnTest_Update.s +++ b/asm/non_matchings/overlays/actors/ovl_En_Test/EnTest_Update.s @@ -158,7 +158,7 @@ glabel L80863884 /* 04278 808638C8 8E0701A8 */ lw $a3, 0x01A8($s0) ## 000001A8 /* 0427C 808638CC 00A03025 */ or $a2, $a1, $zero ## $a2 = 00000000 /* 04280 808638D0 46086281 */ sub.s $f10, $f12, $f8 -/* 04284 808638D4 0C028B9C */ jal func_800A2E70 +/* 04284 808638D4 0C028B9C */ jal SkelAnime_InterpolateRotation /* 04288 808638D8 E7AA0010 */ swc1 $f10, 0x0010($sp) /* 0428C 808638DC 3C078086 */ lui $a3, %hi(D_80864510) ## $a3 = 80860000 /* 04290 808638E0 24E74510 */ addiu $a3, $a3, %lo(D_80864510) ## $a3 = 80864510 diff --git a/include/functions.h b/include/functions.h index 418c6b577e..eca8e85b66 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1144,12 +1144,12 @@ void Scene_Draw(GlobalContext* globalCtx); void SkelAnime_LodDraw(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex); -void SkelAnime_LodDrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, s32 limbCount, +void SkelAnime_LodDrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, s32 dListCount, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex); void SkelAnime_Draw(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor); -void SkelAnime_DrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, s32 limbCount, +void SkelAnime_DrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, s32 dListCount, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor); s16 SkelAnime_GetFrameCount(GenericAnimationHeader* animationSeg); @@ -1159,7 +1159,7 @@ Gfx* SkelAnime_Draw2(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorD Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, s32 dListCount, SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, Actor* actor, Gfx* gfx); -void func_800A2E70(s32, Vec3s*, Vec3s*, Vec3s*, f32); +void SkelAnime_InterpolateRotation(s32, Vec3s*, Vec3s*, Vec3s*, f32); void SkelAnime_AnimationCtxReset(AnimationContext* animationCtx); void func_800A32F4(GlobalContext* globalCtx); void func_800A3310(GlobalContext* globalCtx); diff --git a/include/z64animation.h b/include/z64animation.h index da41830df2..c89925c9be 100755 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -152,7 +152,7 @@ struct SkelAnime { }; /* 0x0C */ f32 initialFrame; /* 0x10 */ f32 animFrameCount; // ending frame? - /* 0x14 */ f32 unk_14; // Loop frame? + /* 0x14 */ f32 totalFrames; // Loop frame? /* 0x18 */ f32 animCurrentFrame; /* 0x1C */ f32 animPlaybackSpeed; /* 0x20 */ Vec3s* actorDrawTbl; // now_joint diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index 24c5768d01..c320a32862 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -298,7 +298,7 @@ void Matrix_RotateZ(f32 z, u8 mode) { /* * Rotates the top of the matrix stack by `z` degrees, then * rotates that matrix by `y` degrees, then rotates that matrix - * by `x` degrees. + * by `x` degrees. (roll-pitch-yaw) * Original Name: Matrix_RotateXYZ, changed to reflect rotation order. */ void Matrix_RotateZYX(s16 x, s16 y, s16 z, u8 mode) { @@ -388,7 +388,7 @@ void Matrix_RotateZYX(s16 x, s16 y, s16 z, u8 mode) { /* * Translates the top of the matrix stack by `translation` units, - * then rotates that matrix by `rotation` in Z-Y-X order + * then rotates that matrix by `rotation` in Z-Y-X order (roll-pitch-yaw) */ void Matrix_TranslateThenRotateZYX(Vec3f* translation, Vec3s* rotation) { MtxF* cmf = sCurrentMatrix; diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 07dd85ddc3..3f3220ee9c 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -15,7 +15,7 @@ void SkelAnime_AnimationType2Loaded(GlobalContext* globalCtx, AnimationEntryType void SkelAnime_AnimationType3Loaded(GlobalContext* globalCtx, AnimationEntryType3* entry); void SkelAnime_AnimationType4Loaded(GlobalContext* globalCtx, AnimationEntryType4* entry); void SkelAnime_AnimationType5Loaded(GlobalContext* globalCtx, AnimationEntryType5* entry); - +#define NON_MATCHING //.data u32 D_8012A480 = 0; static AnimationEntryCallback sAnimationLoadDone[] = { @@ -26,6 +26,9 @@ static AnimationEntryCallback sAnimationLoadDone[] = { //.bss u32 D_801600B0; +/* + * Draws the limb at `limbIndex` with a level of detail display lists index by `dListIndex` +*/ void SkelAnime_LodDrawLimb(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skeleton, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) { @@ -81,6 +84,9 @@ void SkelAnime_LodDrawLimb(GlobalContext* globalCtx, s32 limbIndex, Skeleton* sk func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 821); } +/* + * Draws the Skeleton described by `skeleton` with a level of detail display list indexed by `dListIndex` +*/ void SkelAnime_LodDraw(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) { @@ -131,8 +137,10 @@ void SkelAnime_LodDraw(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* acto func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 894); } -#ifdef NON_MATCHING -// regalloc +/* + * Draws the limb at `limbIndex` with a level of detail display lists index by `dListIndex`, Limb matrices come + * from a dynamic allocation from the graph arena. +*/ void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skeleton, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex, Mtx** mtx) { @@ -153,7 +161,9 @@ void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, Skeleton* pos.x = limbEntry->translation.x; pos.y = limbEntry->translation.y; pos.z = limbEntry->translation.z; - dList[1] = dList[0] = limbEntry->displayLists[dListIndex]; + // Double assignment here would not work. + dList[0] = limbEntry->displayLists[dListIndex]; + dList[1] = dList[0]; if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList[1], &pos, &rot, actor) == 0)) { Matrix_TranslateThenRotateZYX(&pos, &rot); @@ -185,16 +195,17 @@ void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, Skeleton* appendDlistFunc, actor, dListIndex, mtx); } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_LodDrawLimbSV.s") -#endif -#ifdef NON_MATCHING -// regalloc -void SkelAnime_LodDrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, s32 limbCount, +/* + * Draws the Skeleton described by `skeleton` with a level of detail display list indexed by `dListIndex` + * Matricies for the limbs are dynamically allocted from the graph arena. The dynamic allocation occurs + * because the Skeleton is too large to be supported by the normal matrix stack. +*/ +void SkelAnime_LodDrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, s32 dListCount, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) { SkelLimbEntry* limbEntry; + char pad[4]; Gfx* dList[2]; Vec3f pos; Vec3s rot; @@ -202,7 +213,7 @@ void SkelAnime_LodDrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* ac GraphicsContext* gfxCtx; Gfx* gfx[4]; - mtx = Graph_Alloc(globalCtx->state.gfxCtx, limbCount * sizeof(Mtx)); + mtx = Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(Mtx)); if (skeleton == NULL) { osSyncPrintf(VT_FGCOL(RED)); @@ -216,14 +227,14 @@ void SkelAnime_LodDrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* ac Matrix_Push(); limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[0]); - if (limbEntry) {} pos.x = actorDrawTable->x; pos.y = actorDrawTable->y; pos.z = actorDrawTable->z; rot = actorDrawTable[1]; - dList[0] = dList[1] = limbEntry->displayLists[dListIndex]; + dList[0] = limbEntry->displayLists[dListIndex]; + dList[1] = dList[0]; if ((updateMtxFunc == 0) || (updateMtxFunc(globalCtx, 1, &dList[1], &pos, &rot, actor) == 0)) { Matrix_TranslateThenRotateZYX(&pos, &rot); @@ -250,10 +261,10 @@ void SkelAnime_LodDrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* ac func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1053); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_LodDrawSV.s") -#endif +/* + * Draws the limb of the Skeleton `skeleton` at `limbIndex` +*/ void SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skeleton, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) { @@ -362,8 +373,6 @@ void SkelAnime_Draw(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDr func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1190); } -#ifdef NON_MATCHING -// close, needs a bit bmore work. Mainly seems centered around SEGMENTED_TO_VIRTUAL void SkelAnime_DrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skeleton, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, Mtx** limbMatricies) { @@ -386,7 +395,8 @@ void SkelAnime_DrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, Skeleton* ske pos.y = limbEntry->translation.y; pos.z = limbEntry->translation.z; - dList[0] = dList[1] = limbEntry->displayLists[0]; + dList[0] = limbEntry->displayLists[0]; + dList[1] = dList[0]; if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList[1], &pos, &rot, actor) == 0)) { Matrix_TranslateThenRotateZYX(&pos, &rot); @@ -419,13 +429,8 @@ void SkelAnime_DrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, Skeleton* ske func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1265); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_DrawLimbSV.s") -#endif -#ifdef NON_MATCHING -// Regalloc, pretty much same as SkelAnime_LodDrawSV -void SkelAnime_DrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, s32 limbCount, +void SkelAnime_DrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, s32 dListCount, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) { SkelLimbEntry* limbEntry; @@ -437,7 +442,7 @@ void SkelAnime_DrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actor GraphicsContext* gfxCtx; Gfx* gfx[4]; - mtx = Graph_Alloc(globalCtx->state.gfxCtx, limbCount * sizeof(Mtx)); + mtx = Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(Mtx)); if (skeleton == NULL) { osSyncPrintf(VT_FGCOL(RED)); @@ -457,12 +462,13 @@ void SkelAnime_DrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actor limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[0]); pos.x = actorDrawTable->x; - pos.y = actorDrawTable->x; + pos.y = actorDrawTable->y; pos.z = actorDrawTable->z; rot = actorDrawTable[1]; - dList[0] = dList[1] = limbEntry->displayLists[0]; + dList[0] = limbEntry->displayLists[0]; + dList[1] = dList[0]; if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList[1], &pos, &rot, actor) == 0)) { Matrix_TranslateThenRotateZYX(&pos, &rot); @@ -491,9 +497,6 @@ void SkelAnime_DrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actor Matrix_Pull(); func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1347); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_DrawSV.s") -#endif /* * Copies the rotation values from the rotation value table, indexed by the rotation index table @@ -534,17 +537,22 @@ void SkelAnime_AnimateFrame(AnimationHeader* animationSeg, s32 currentFrame, s32 } } -s16 func_800A1FC8(GenericAnimationHeader* animationSeg) { +s16 SkelAnime_GetTotalFrames(GenericAnimationHeader* animationSeg) { GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); return animation->frameCount; } + s16 SkelAnime_GetFrameCount(GenericAnimationHeader* animationSeg) { GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); - + // Loads an unsigned half for some reason. return (u16)animation->frameCount - 1; } +/* + * Draws the Skeleton `skeleton`'s limb at index `limbIndex`. Appends all generated graphics commands to + * `gfx`. Returns a pointer to the next gfx to be appended to. +*/ Gfx* SkelAnime_Draw2Limb(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skeleton, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, Actor* actor, Gfx* gfx) { @@ -593,6 +601,10 @@ Gfx* SkelAnime_Draw2Limb(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skel return gfx; } +/* + * Draws the Skeleton `skeleton` Appends all generated graphics to `gfx`, and returns a pointer to the + * next gfx to be appended to. +*/ Gfx* SkelAnime_Draw2(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, Actor* actor, Gfx* gfx) { @@ -754,57 +766,7 @@ Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* acto return gfx; } -#ifdef NON_MATCHING -/* - * Seems to be completely unused by the game, doesn't really make much sense with the - * rest of SkelAnime animation types. This does not match due to loop unrolling, but - * is functionally equal. -*/ - -typedef struct { - s16 limitx; - s16 indexx; - s16 limity; - s16 indexy; - s16 limitz; - s16 indexz; -} unk_struct; -s16 func_800A29BC(AnimationHeader* animationSeg, s32 arg1, Vec3s *arg2) -{ - AnimationRotationValue* temp_t1; - unk_struct *temp_a3; - AnimationHeader *temp_v0; - s32 i; - - temp_v0 = SEGMENTED_TO_VIRTUAL(animationSeg); - temp_a3 = SEGMENTED_TO_VIRTUAL(temp_v0->rotationIndexSeg); - temp_t1 = SEGMENTED_TO_VIRTUAL(temp_v0->rotationValueSeg); - - - arg2->x = arg1 < temp_a3->limitx ? (&temp_t1[arg1])[temp_a3->indexx] : temp_t1[temp_a3->indexx]; - arg2->y = arg1 < temp_a3->limity ? (&temp_t1[arg1])[temp_a3->indexy] : temp_t1[temp_a3->indexy]; - arg2->z = arg1 < temp_a3->limitz ? (&temp_t1[arg1])[temp_a3->indexz] : temp_t1[temp_a3->indexz]; - - arg2++; - temp_a3++; - i = 1; - if(temp_v0->genericHeader.unk_02 > 0){ - do { - - arg2->x = arg1 < temp_a3->limitx ? (&temp_t1[arg1])[temp_a3->indexx] : temp_t1[temp_a3->indexx]; - arg2->y = arg1 < temp_a3->limity ? (&temp_t1[arg1])[temp_a3->indexy] : temp_t1[temp_a3->indexy]; - arg2->z = arg1 < temp_a3->limitz ? (&temp_t1[arg1])[temp_a3->indexz] : temp_t1[temp_a3->indexz]; - - temp_a3++; - arg2++; - i++; - } while ((temp_v0->genericHeader.unk_02 + 1) != i); - } - return temp_v0->genericHeader.unk_02; -} -#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A29BC.s") -#endif s16 func_800A2DBC(GenericAnimationHeader* animationSeg) { GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); @@ -812,46 +774,52 @@ s16 func_800A2DBC(GenericAnimationHeader* animationSeg) { return animation->unk_02; } -s16 func_800A2DF4(GenericAnimationHeader* animationSeg) { +/* + * Appears to be unused anywhere in the game. Appears to be a clone of + * SkelAnime_GetTotalFrames +*/ +s16 SkelAnime_GetTotalFrames2(GenericAnimationHeader* animationSeg) { GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); return animation->frameCount; } -s16 func_800A2E2C(GenericAnimationHeader* animationSeg) { +/* + * Appears to be unused anywhere in the game. Appears to be a clone of + * SkelAnime_GetFrameCount +*/ +s16 SkelAnime_GetFrameCount2(GenericAnimationHeader* animationSeg) { GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); return animation->frameCount - 1; } -#ifdef NON_MATCHING -// Functionally equal, but loop unrolling is way off. -void func_800A2E70(s32 limbCount, Vec3s* vec1, Vec3s* vec2, Vec3s* vec3, f32 unkf) { - Vec3s* pvec1; - Vec3s* pvec2; - Vec3s* pvec3; - s32 iVar3; +void SkelAnime_InterpolateRotation(s32 limbCount, Vec3s* dst, Vec3s* vec2, Vec3s* vec3, f32 unkf) { + s32 i; + s16 dist; + s16 temp2; - if (unkf < 1.0f) { - for (iVar3 = 0, pvec1 = vec1, pvec2 = vec2, pvec3 = vec3; iVar3 < limbCount; - iVar3++, pvec1++, pvec2++, pvec3++) { - pvec1->x = pvec2->x + ((s16)(pvec3->x - pvec2->x) * unkf); - pvec1->y = pvec2->y + ((s16)(pvec3->y - pvec2->y) * unkf); - pvec1->z = pvec2->z + ((s16)(pvec3->z - pvec2->z) * unkf); + if(unkf < 1.0f){ + for(i = 0; i < limbCount;i++, dst++, vec2++, vec3++){ + temp2 = vec2->x; + dist = vec3->x - temp2; + dst->x = (s16)(dist * unkf) + temp2; + temp2 = vec2->y; + dist = vec3->y - temp2; + dst->y = (s16)(dist * unkf) + temp2; + temp2 = vec2->z; + dist = vec3->z - temp2; + dst->z = (s16)(dist * unkf) + temp2; } - } else { - for (iVar3 = 0; iVar3 < limbCount; iVar3++) { - pvec1 = &vec1[iVar3]; - pvec3 = &vec3[iVar3]; - pvec1->x = pvec3->x; - pvec1->y = pvec3->y; - pvec1->z = pvec3->z; + } + else { + for (i = 0;i < limbCount; i++, dst++, vec3++) { + dst->x = vec3->x; + dst->y = vec3->y; + dst->z = vec3->z; } } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A2E70.s") -#endif void SkelAnime_AnimationCtxReset(AnimationContext* animationCtx) { animationCtx->animationCount = 0; @@ -977,7 +945,7 @@ void SkelAnime_AnimationType1Loaded(GlobalContext* globalCtx, AnimationEntryType void SkelAnime_AnimationType2Loaded(GlobalContext* globalCtx, AnimationEntryType2* entry) { if ((entry->unk_00 & D_8012A480) == 0) { - func_800A2E70(entry->limbCount, entry->unk_04, entry->unk_04, entry->unk_08, entry->unk_0C); + SkelAnime_InterpolateRotation(entry->limbCount, entry->unk_04, entry->unk_04, entry->unk_08, entry->unk_0C); } } @@ -1138,9 +1106,9 @@ s32 func_800A3D70(GlobalContext* globalCtx, SkelAnime* skelAnime) { skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate; if (skelAnime->animCurrentFrame < 0.0f) { - skelAnime->animCurrentFrame += skelAnime->unk_14; - } else if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) { - skelAnime->animCurrentFrame -= skelAnime->unk_14; + skelAnime->animCurrentFrame += skelAnime->totalFrames; + } else if (skelAnime->totalFrames <= skelAnime->animCurrentFrame) { + skelAnime->animCurrentFrame -= skelAnime->totalFrames; } func_800A3C9C(globalCtx, skelAnime); return 0; @@ -1158,9 +1126,9 @@ s32 func_800A3E0C(GlobalContext* globalCtx, SkelAnime* skelAnime) { skelAnime->animCurrentFrame = skelAnime->animFrameCount; } else { if (skelAnime->animCurrentFrame < 0.0f) { - skelAnime->animCurrentFrame += skelAnime->unk_14; - } else if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) { - skelAnime->animCurrentFrame -= skelAnime->unk_14; + skelAnime->animCurrentFrame += skelAnime->totalFrames; + } else if (skelAnime->totalFrames <= skelAnime->animCurrentFrame) { + skelAnime->animCurrentFrame -= skelAnime->totalFrames; } } func_800A3C9C(globalCtx, skelAnime); @@ -1172,15 +1140,14 @@ void func_800A3EE8(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 transitio skelAnime->transitionStep = 1.0f / transitionRate; } -#ifdef NON_MATCHING void SkelAnime_LinkChangeAnimation(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, f32 playbackSpeed, f32 frame, f32 frameCount, u8 arg6, f32 transitionRate) { skelAnime->unk_01 = arg6; if ((transitionRate != 0.0f) && - ((linkAnimetionEntrySeg == skelAnime->linkAnimetionSeg) || (frame != skelAnime->animCurrentFrame))) { - if (transitionRate < 0.0f) { + ((linkAnimetionEntrySeg != skelAnime->linkAnimetionSeg) || (frame != skelAnime->animCurrentFrame))) { + if (transitionRate < 0) { func_800A3B8C(skelAnime); SkelAnime_CopyVec3s(skelAnime, skelAnime->transitionDrawTbl, skelAnime->actorDrawTbl); transitionRate = -transitionRate; @@ -1198,16 +1165,14 @@ void SkelAnime_LinkChangeAnimation(GlobalContext* globalCtx, SkelAnime* skelAnim skelAnime->transCurrentFrame = 0.0f; } + skelAnime->linkAnimetionSeg = linkAnimetionEntrySeg; skelAnime->animCurrentFrame = 0.0f; skelAnime->initialFrame = frame; skelAnime->animCurrentFrame = frame; skelAnime->animFrameCount = frameCount; - skelAnime->unk_14 = func_800A1FC8(&linkAnimetionEntrySeg->genericHeader); + skelAnime->totalFrames = SkelAnime_GetTotalFrames(linkAnimetionEntrySeg); skelAnime->animPlaybackSpeed = playbackSpeed; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_LinkChangeAnimation.s") -#endif void func_800A407C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg) { SkelAnime_LinkChangeAnimation(globalCtx, skelAnime, linkAnimetionEntrySeg, 1.0f, 0.0f, @@ -1291,15 +1256,15 @@ s32 func_800A4478(SkelAnime* skelAnime, f32 arg1, f32 updateRate) { updateSpeed = skelAnime->animPlaybackSpeed * updateRate; nextFrame = skelAnime->animCurrentFrame - updateSpeed; if (nextFrame < 0.0f) { - nextFrame += skelAnime->unk_14; + nextFrame += skelAnime->totalFrames; } else { - if (skelAnime->unk_14 <= nextFrame) { - nextFrame -= skelAnime->unk_14; + if (skelAnime->totalFrames <= nextFrame) { + nextFrame -= skelAnime->totalFrames; } } if (arg1 == 0.0f) { if (0.0f < updateSpeed) { - arg1 = skelAnime->unk_14; + arg1 = skelAnime->totalFrames; } } temp_f12 = (nextFrame + updateSpeed) - arg1; @@ -1429,16 +1394,14 @@ s32 func_800A4A20(SkelAnime* skelAnime) { func_800A49B0(skelAnime); skelAnime->transCurrentFrame = 0.0f; } - func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, skelAnime->transitionDrawTbl, + SkelAnime_InterpolateRotation(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, skelAnime->transitionDrawTbl, 1.0f - (skelAnime->transCurrentFrame / prevUnk28)); return 0; } -#ifdef NON_MATCHING -// small stack alloc s32 func_800A4AD8(SkelAnime* skelAnime) { - s16 temp_a1; s16 temp_a2; + s16 temp_a1; f32 sp28; f32 phi_f2; f32 updateRate; @@ -1463,13 +1426,10 @@ s32 func_800A4AD8(SkelAnime* skelAnime) { } else { phi_f2 = 0.0f; } - func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, skelAnime->transitionDrawTbl, + SkelAnime_InterpolateRotation(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, skelAnime->transitionDrawTbl, 1.0f - phi_f2); return 0; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4AD8.s") -#endif #ifdef NON_MATCHING // regalloc @@ -1483,16 +1443,16 @@ void func_800A4C58(SkelAnime* skelAnime) { SkelAnime_AnimateFrame(skelAnime->animCurrentSeg, skelAnime->animCurrentFrame, skelAnime->limbCount, skelAnime->actorDrawTbl); - if (skelAnime->unk_01) { + if (skelAnime->unk_01 & 0x1) { temp_f8 = (s32)skelAnime->animCurrentFrame; temp_f10 = temp_f8; temp_f8++; temp_f2 = skelAnime->animCurrentFrame - temp_f10; - if (temp_f8 >= (s32)skelAnime->unk_14) { + if (temp_f8 >= (s32)skelAnime->totalFrames) { temp_f8 = 0; } SkelAnime_AnimateFrame(skelAnime->animCurrentSeg, temp_f8, skelAnime->limbCount, sp38); - func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, sp38, temp_f2); + SkelAnime_InterpolateRotation(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, sp38, temp_f2); } if (skelAnime->transCurrentFrame != 0) { skelAnime->transCurrentFrame -= skelAnime->transitionStep * (R_UPDATE_RATE * 0.33333334f); @@ -1501,7 +1461,7 @@ void func_800A4C58(SkelAnime* skelAnime) { skelAnime->transCurrentFrame = 0.0f; return; } - func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, skelAnime->transitionDrawTbl, + SkelAnime_InterpolateRotation(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, skelAnime->transitionDrawTbl, skelAnime->transCurrentFrame); } } @@ -1513,9 +1473,9 @@ s32 func_800A4D9C(SkelAnime* skelAnime) { f32 updateRate = R_UPDATE_RATE * 0.33333334f; skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate; if (skelAnime->animCurrentFrame < 0.0f) { - skelAnime->animCurrentFrame += skelAnime->unk_14; - } else if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) { - skelAnime->animCurrentFrame -= skelAnime->unk_14; + skelAnime->animCurrentFrame += skelAnime->totalFrames; + } else if (skelAnime->totalFrames <= skelAnime->animCurrentFrame) { + skelAnime->animCurrentFrame -= skelAnime->totalFrames; } func_800A4C58(skelAnime); return 0; @@ -1550,10 +1510,10 @@ s32 func_800A4EE0(SkelAnime* skelAnime) { skelAnime->animCurrentFrame = skelAnime->animFrameCount; } else { if (skelAnime->animCurrentFrame < 0.0f) { - skelAnime->animCurrentFrame += skelAnime->unk_14; + skelAnime->animCurrentFrame += skelAnime->totalFrames; } else { - if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) { - skelAnime->animCurrentFrame -= skelAnime->unk_14; + if (skelAnime->totalFrames <= skelAnime->animCurrentFrame) { + skelAnime->animCurrentFrame -= skelAnime->totalFrames; } } } @@ -1590,13 +1550,13 @@ void SkelAnime_ChangeAnimationImpl(SkelAnime* skelAnime, AnimationHeader* animat skelAnime->animCurrentSeg = animationSeg; skelAnime->initialFrame = frame; skelAnime->animFrameCount = frameCount; - skelAnime->unk_14 = func_800A1FC8(&animationSeg->genericHeader); + skelAnime->totalFrames = SkelAnime_GetTotalFrames(&animationSeg->genericHeader); if (skelAnime->unk_01 >= 4) { skelAnime->animCurrentFrame = 0.0f; } else { skelAnime->animCurrentFrame = frame; if (skelAnime->unk_01 < 2) { - skelAnime->animFrameCount = skelAnime->unk_14 - 1.0f; + skelAnime->animFrameCount = skelAnime->totalFrames - 1.0f; } } skelAnime->animPlaybackSpeed = playbackSpeed; @@ -1638,7 +1598,7 @@ void SkelAnime_ChangeAnimationPlaybackSpeed(SkelAnime* skelAnime, AnimationHeade void func_800A53DC(SkelAnime* skelAnime) { skelAnime->unk_01 = 2; - skelAnime->animFrameCount = skelAnime->unk_14; + skelAnime->animFrameCount = skelAnime->totalFrames; func_800A49B0(skelAnime); }