From 85237605e20a1aa32bf7bc3e729a78b0e25258c7 Mon Sep 17 00:00:00 2001 From: Roman971 Date: Wed, 18 Mar 2020 21:22:00 +0100 Subject: [PATCH] Fix and cleanup ovl_En_Tubo_Trap (4/7 matched) --- .../actors/ovl_En_Tubo_Trap/EnTuboTrap_Fly.s | 57 --- ...stCollider.s => EnTuboTrap_HandleImpact.s} | 12 +- .../EnTuboTrap_InitializeAttack.s | 40 -- ...ragments.s => EnTuboTrap_SpawnFragments.s} | 13 +- ...ter.s => EnTuboTrap_SpawnWaterFragments.s} | 9 +- .../EnTuboTrap_TestLevitate.s | 119 ------ .../ovl_En_Tubo_Trap/EnTuboTrap_Update.s | 47 --- include/z64.h | 16 +- .../actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c | 386 ++++++++---------- .../actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h | 18 + undefined_syms.txt | 4 +- 11 files changed, 207 insertions(+), 514 deletions(-) delete mode 100644 asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fly.s rename asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/{EnTuboTrap_TestCollider.s => EnTuboTrap_HandleImpact.s} (96%) delete mode 100644 asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_InitializeAttack.s rename asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/{EnTuboTrap_Fragments.s => EnTuboTrap_SpawnFragments.s} (98%) rename asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/{EnTuboTrap_FragmentsWater.s => EnTuboTrap_SpawnWaterFragments.s} (99%) delete mode 100644 asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestLevitate.s delete mode 100644 asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Update.s create mode 100644 src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h diff --git a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fly.s b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fly.s deleted file mode 100644 index ed18906778..0000000000 --- a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fly.s +++ /dev/null @@ -1,57 +0,0 @@ -glabel EnTuboTrap_Fly -/* 00A38 80B26328 27BDFFD0 */ addiu $sp, $sp, 0xFFD0 ## $sp = FFFFFFD0 -/* 00A3C 80B2632C AFBF001C */ sw $ra, 0x001C($sp) -/* 00A40 80B26330 AFB00018 */ sw $s0, 0x0018($sp) -/* 00A44 80B26334 AFA50034 */ sw $a1, 0x0034($sp) -/* 00A48 80B26338 C4920154 */ lwc1 $f18, 0x0154($a0) ## 00000154 -/* 00A4C 80B2633C C4900024 */ lwc1 $f16, 0x0024($a0) ## 00000024 -/* 00A50 80B26340 C48E0158 */ lwc1 $f14, 0x0158($a0) ## 00000158 -/* 00A54 80B26344 C48C0028 */ lwc1 $f12, 0x0028($a0) ## 00000028 -/* 00A58 80B26348 46109401 */ sub.s $f16, $f18, $f16 -/* 00A5C 80B2634C C492015C */ lwc1 $f18, 0x015C($a0) ## 0000015C -/* 00A60 80B26350 C48A002C */ lwc1 $f10, 0x002C($a0) ## 0000002C -/* 00A64 80B26354 460C7301 */ sub.s $f12, $f14, $f12 -/* 00A68 80B26358 00808025 */ or $s0, $a0, $zero ## $s0 = 00000000 -/* 00A6C 80B2635C E7B0002C */ swc1 $f16, 0x002C($sp) -/* 00A70 80B26360 460A9281 */ sub.s $f10, $f18, $f10 -/* 00A74 80B26364 E7AC0028 */ swc1 $f12, 0x0028($sp) -/* 00A78 80B26368 24053037 */ addiu $a1, $zero, 0x3037 ## $a1 = 00003037 -/* 00A7C 80B2636C 0C00BE0A */ jal Audio_PlayActorSound2 - -/* 00A80 80B26370 E7AA0024 */ swc1 $f10, 0x0024($sp) -/* 00A84 80B26374 C7A2002C */ lwc1 $f2, 0x002C($sp) -/* 00A88 80B26378 C7AC0028 */ lwc1 $f12, 0x0028($sp) -/* 00A8C 80B2637C C7AE0024 */ lwc1 $f14, 0x0024($sp) -/* 00A90 80B26380 46021102 */ mul.s $f4, $f2, $f2 -/* 00A94 80B26384 3C014370 */ lui $at, 0x4370 ## $at = 43700000 -/* 00A98 80B26388 44818000 */ mtc1 $at, $f16 ## $f16 = 240.00 -/* 00A9C 80B2638C 460C6182 */ mul.s $f6, $f12, $f12 -/* 00AA0 80B26390 3C063E4C */ lui $a2, 0x3E4C ## $a2 = 3E4C0000 -/* 00AA4 80B26394 34C6CCCD */ ori $a2, $a2, 0xCCCD ## $a2 = 3E4CCCCD -/* 00AA8 80B26398 460E7282 */ mul.s $f10, $f14, $f14 -/* 00AAC 80B2639C 2604006C */ addiu $a0, $s0, 0x006C ## $a0 = 0000006C -/* 00AB0 80B263A0 3C05C040 */ lui $a1, 0xC040 ## $a1 = C0400000 -/* 00AB4 80B263A4 46062200 */ add.s $f8, $f4, $f6 -/* 00AB8 80B263A8 460A4000 */ add.s $f0, $f8, $f10 -/* 00ABC 80B263AC 46000004 */ sqrt.s $f0, $f0 -/* 00AC0 80B263B0 4600803C */ c.lt.s $f16, $f0 -/* 00AC4 80B263B4 00000000 */ nop -/* 00AC8 80B263B8 45020004 */ bc1fl .L80B263CC -/* 00ACC 80B263BC 860E00B6 */ lh $t6, 0x00B6($s0) ## 000000B6 -/* 00AD0 80B263C0 0C01E107 */ jal Math_SmoothScaleMaxF - -/* 00AD4 80B263C4 3C073F00 */ lui $a3, 0x3F00 ## $a3 = 3F000000 -/* 00AD8 80B263C8 860E00B6 */ lh $t6, 0x00B6($s0) ## 000000B6 -.L80B263CC: -/* 00ADC 80B263CC 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -/* 00AE0 80B263D0 25CF1388 */ addiu $t7, $t6, 0x1388 ## $t7 = 00001388 -/* 00AE4 80B263D4 A60F00B6 */ sh $t7, 0x00B6($s0) ## 000000B6 -/* 00AE8 80B263D8 0C2C97C2 */ jal EnTuboTrap_TestCollider -/* 00AEC 80B263DC 8FA50034 */ lw $a1, 0x0034($sp) -/* 00AF0 80B263E0 8FBF001C */ lw $ra, 0x001C($sp) -/* 00AF4 80B263E4 8FB00018 */ lw $s0, 0x0018($sp) -/* 00AF8 80B263E8 27BD0030 */ addiu $sp, $sp, 0x0030 ## $sp = 00000000 -/* 00AFC 80B263EC 03E00008 */ jr $ra -/* 00B00 80B263F0 00000000 */ nop - - diff --git a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestCollider.s b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_HandleImpact.s similarity index 96% rename from asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestCollider.s rename to asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_HandleImpact.s index 1c28df5022..fe7f9d108c 100644 --- a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestCollider.s +++ b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_HandleImpact.s @@ -1,4 +1,4 @@ -glabel EnTuboTrap_TestCollider +glabel EnTuboTrap_HandleImpact /* 00618 80B25F08 27BDFFD0 */ addiu $sp, $sp, 0xFFD0 ## $sp = FFFFFFD0 /* 0061C 80B25F0C AFBF001C */ sw $ra, 0x001C($sp) /* 00620 80B25F10 AFB10018 */ sw $s1, 0x0018($sp) @@ -18,7 +18,7 @@ glabel EnTuboTrap_TestCollider /* 00658 80B25F48 00000000 */ nop /* 0065C 80B25F4C 45020010 */ bc1fl .L80B25F90 /* 00660 80B25F50 92020170 */ lbu $v0, 0x0170($s0) ## 00000170 -/* 00664 80B25F54 0C2C9723 */ jal EnTuboTrap_FragmentsWater +/* 00664 80B25F54 0C2C9723 */ jal EnTuboTrap_SpawnWaterFragments /* 00668 80B25F58 00000000 */ nop /* 0066C 80B25F5C 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000 /* 00670 80B25F60 26050024 */ addiu $a1, $s0, 0x0024 ## $a1 = 00000024 @@ -41,7 +41,7 @@ glabel EnTuboTrap_TestCollider /* 006A8 80B25F98 30580004 */ andi $t8, $v0, 0x0004 ## $t8 = 00000000 /* 006AC 80B25F9C 13000015 */ beq $t8, $zero, .L80B25FF4 /* 006B0 80B25FA0 3059FFFB */ andi $t9, $v0, 0xFFFB ## $t9 = 00000000 -/* 006B4 80B25FA4 0C2C9686 */ jal EnTuboTrap_Fragments +/* 006B4 80B25FA4 0C2C9686 */ jal EnTuboTrap_SpawnFragments /* 006B8 80B25FA8 A2190170 */ sb $t9, 0x0170($s0) ## 00000170 /* 006BC 80B25FAC 26050024 */ addiu $a1, $s0, 0x0024 ## $a1 = 00000024 /* 006C0 80B25FB0 AFA50024 */ sw $a1, 0x0024($sp) @@ -72,7 +72,7 @@ glabel EnTuboTrap_TestCollider /* 00714 80B26004 11000016 */ beq $t0, $zero, .L80B26060 /* 00718 80B26008 3069FFFD */ andi $t1, $v1, 0xFFFD ## $t1 = 00000000 /* 0071C 80B2600C A2090171 */ sb $t1, 0x0171($s0) ## 00000171 -/* 00720 80B26010 0C2C9686 */ jal EnTuboTrap_Fragments +/* 00720 80B26010 0C2C9686 */ jal EnTuboTrap_SpawnFragments /* 00724 80B26014 02202825 */ or $a1, $s1, $zero ## $a1 = 00000000 /* 00728 80B26018 26050024 */ addiu $a1, $s0, 0x0024 ## $a1 = 00000024 /* 0072C 80B2601C AFA50024 */ sw $a1, 0x0024($sp) @@ -103,7 +103,7 @@ glabel EnTuboTrap_TestCollider /* 00780 80B26070 A20B0170 */ sb $t3, 0x0170($s0) ## 00000170 /* 00784 80B26074 14CC0015 */ bne $a2, $t4, .L80B260CC /* 00788 80B26078 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -/* 0078C 80B2607C 0C2C9686 */ jal EnTuboTrap_Fragments +/* 0078C 80B2607C 0C2C9686 */ jal EnTuboTrap_SpawnFragments /* 00790 80B26080 02202825 */ or $a1, $s1, $zero ## $a1 = 00000000 /* 00794 80B26084 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000 /* 00798 80B26088 26050024 */ addiu $a1, $s0, 0x0024 ## $a1 = 00000024 @@ -136,7 +136,7 @@ glabel EnTuboTrap_TestCollider /* 007F0 80B260E0 51C0000E */ beql $t6, $zero, .L80B2611C /* 007F4 80B260E4 8FBF001C */ lw $ra, 0x001C($sp) .L80B260E8: -/* 007F8 80B260E8 0C2C9686 */ jal EnTuboTrap_Fragments +/* 007F8 80B260E8 0C2C9686 */ jal EnTuboTrap_SpawnFragments /* 007FC 80B260EC 02202825 */ or $a1, $s1, $zero ## $a1 = 00000000 /* 00800 80B260F0 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000 /* 00804 80B260F4 26050024 */ addiu $a1, $s0, 0x0024 ## $a1 = 00000024 diff --git a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_InitializeAttack.s b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_InitializeAttack.s deleted file mode 100644 index d71bf919a1..0000000000 --- a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_InitializeAttack.s +++ /dev/null @@ -1,40 +0,0 @@ -glabel EnTuboTrap_InitializeAttack -/* 009AC 80B2629C 27BDFFE0 */ addiu $sp, $sp, 0xFFE0 ## $sp = FFFFFFE0 -/* 009B0 80B262A0 AFBF001C */ sw $ra, 0x001C($sp) -/* 009B4 80B262A4 AFB00018 */ sw $s0, 0x0018($sp) -/* 009B8 80B262A8 AFA50024 */ sw $a1, 0x0024($sp) -/* 009BC 80B262AC 848E00B6 */ lh $t6, 0x00B6($a0) ## 000000B6 -/* 009C0 80B262B0 00808025 */ or $s0, $a0, $zero ## $s0 = 00000000 -/* 009C4 80B262B4 3C063F4C */ lui $a2, 0x3F4C ## $a2 = 3F4C0000 -/* 009C8 80B262B8 25CF1388 */ addiu $t7, $t6, 0x1388 ## $t7 = 00001388 -/* 009CC 80B262BC A48F00B6 */ sh $t7, 0x00B6($a0) ## 000000B6 -/* 009D0 80B262C0 8E050150 */ lw $a1, 0x0150($s0) ## 00000150 -/* 009D4 80B262C4 34C6CCCD */ ori $a2, $a2, 0xCCCD ## $a2 = 3F4CCCCD -/* 009D8 80B262C8 24840028 */ addiu $a0, $a0, 0x0028 ## $a0 = 00000028 -/* 009DC 80B262CC 0C01E107 */ jal Math_SmoothScaleMaxF - -/* 009E0 80B262D0 3C074040 */ lui $a3, 0x4040 ## $a3 = 40400000 -/* 009E4 80B262D4 C6040028 */ lwc1 $f4, 0x0028($s0) ## 00000028 -/* 009E8 80B262D8 C6060150 */ lwc1 $f6, 0x0150($s0) ## 00000150 -/* 009EC 80B262DC 3C014120 */ lui $at, 0x4120 ## $at = 41200000 -/* 009F0 80B262E0 44811000 */ mtc1 $at, $f2 ## $f2 = 10.00 -/* 009F4 80B262E4 46062001 */ sub.s $f0, $f4, $f6 -/* 009F8 80B262E8 3C1980B2 */ lui $t9, %hi(EnTuboTrap_Fly) ## $t9 = 80B20000 -/* 009FC 80B262EC 27396328 */ addiu $t9, $t9, %lo(EnTuboTrap_Fly) ## $t9 = 80B26328 -/* 00A00 80B262F0 46000005 */ abs.s $f0, $f0 -/* 00A04 80B262F4 4602003C */ c.lt.s $f0, $f2 -/* 00A08 80B262F8 00000000 */ nop -/* 00A0C 80B262FC 45020006 */ bc1fl .L80B26318 -/* 00A10 80B26300 8FBF001C */ lw $ra, 0x001C($sp) -/* 00A14 80B26304 8618008A */ lh $t8, 0x008A($s0) ## 0000008A -/* 00A18 80B26308 E6020068 */ swc1 $f2, 0x0068($s0) ## 00000068 -/* 00A1C 80B2630C AE19014C */ sw $t9, 0x014C($s0) ## 0000014C -/* 00A20 80B26310 A6180032 */ sh $t8, 0x0032($s0) ## 00000032 -/* 00A24 80B26314 8FBF001C */ lw $ra, 0x001C($sp) -.L80B26318: -/* 00A28 80B26318 8FB00018 */ lw $s0, 0x0018($sp) -/* 00A2C 80B2631C 27BD0020 */ addiu $sp, $sp, 0x0020 ## $sp = 00000000 -/* 00A30 80B26320 03E00008 */ jr $ra -/* 00A34 80B26324 00000000 */ nop - - diff --git a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fragments.s b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnFragments.s similarity index 98% rename from asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fragments.s rename to asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnFragments.s index 26bfc1143e..3366b21942 100644 --- a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fragments.s +++ b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnFragments.s @@ -1,12 +1,15 @@ .late_rodata +glabel D_80B265C0 + .float 0.23 -D_80B265C0: .float 0.23 -D_80B265C4: .float 0.2 -D_80B265C8: .float 0.6 +glabel D_80B265C4 + .float 0.2 + +glabel D_80B265C8 + .float 0.6 .text - -glabel EnTuboTrap_Fragments +glabel EnTuboTrap_SpawnFragments /* 00128 80B25A18 27BDFF20 */ addiu $sp, $sp, 0xFF20 ## $sp = FFFFFF20 /* 0012C 80B25A1C F7BE0070 */ sdc1 $f30, 0x0070($sp) /* 00130 80B25A20 3C0180B2 */ lui $at, %hi(D_80B265C0) ## $at = 80B20000 diff --git a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_FragmentsWater.s b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnWaterFragments.s similarity index 99% rename from asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_FragmentsWater.s rename to asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnWaterFragments.s index c5d727def5..f50a18afcf 100644 --- a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_FragmentsWater.s +++ b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnWaterFragments.s @@ -1,11 +1,12 @@ .late_rodata +glabel D_80B265CC + .float 0.2 -D_80B265CC: .float 0.2 -D_80B265D0: .float 0.2 +glabel D_80B265D0 + .float 0.2 .text - -glabel EnTuboTrap_FragmentsWater +glabel EnTuboTrap_SpawnWaterFragments /* 0039C 80B25C8C 27BDFF20 */ addiu $sp, $sp, 0xFF20 ## $sp = FFFFFF20 /* 003A0 80B25C90 AFB1007C */ sw $s1, 0x007C($sp) /* 003A4 80B25C94 AFBF009C */ sw $ra, 0x009C($sp) diff --git a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestLevitate.s b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestLevitate.s deleted file mode 100644 index 3868ef1ad2..0000000000 --- a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestLevitate.s +++ /dev/null @@ -1,119 +0,0 @@ -.rdata - -D_80B26564: - .asciz "\x1b[32m☆☆☆☆☆ わて ☆☆☆☆☆ %f\n\x1b[m" - .balign 4 - -D_80B26590: - .asciz "\x1b[32m☆☆☆☆☆ おいどん ☆☆☆☆☆ %f\n\x1b[m" - .balign 4 - -D_80B265BC: - .asciz "\n\n" - .balign 4 - -.text - -glabel EnTuboTrap_TestLevitate -/* 0083C 80B2612C 27BDFFD8 */ addiu $sp, $sp, 0xFFD8 ## $sp = FFFFFFD8 -/* 00840 80B26130 AFBF001C */ sw $ra, 0x001C($sp) -/* 00844 80B26134 AFB00018 */ sw $s0, 0x0018($sp) -/* 00848 80B26138 AFA5002C */ sw $a1, 0x002C($sp) -/* 0084C 80B2613C 8CAF1C44 */ lw $t7, 0x1C44($a1) ## 00001C44 -/* 00850 80B26140 3C188016 */ lui $t8, 0x8016 ## $t8 = 80160000 -/* 00854 80B26144 8F18FA90 */ lw $t8, -0x0570($t8) ## 8015FA90 -/* 00858 80B26148 AFAF0024 */ sw $t7, 0x0024($sp) -/* 0085C 80B2614C 00808025 */ or $s0, $a0, $zero ## $s0 = 00000000 -/* 00860 80B26150 871912D8 */ lh $t9, 0x12D8($t8) ## 801612D8 -/* 00864 80B26154 53200016 */ beql $t9, $zero, .L80B261B0 -/* 00868 80B26158 3C014348 */ lui $at, 0x4348 ## $at = 43480000 -/* 0086C 80B2615C C6040028 */ lwc1 $f4, 0x0028($s0) ## 00000028 -/* 00870 80B26160 3C0480B2 */ lui $a0, %hi(D_80B26564) ## $a0 = 80B20000 -/* 00874 80B26164 24846564 */ addiu $a0, $a0, %lo(D_80B26564) ## $a0 = 80B26564 -/* 00878 80B26168 460021A1 */ cvt.d.s $f6, $f4 -/* 0087C 80B2616C 44073000 */ mfc1 $a3, $f6 -/* 00880 80B26170 44063800 */ mfc1 $a2, $f7 -/* 00884 80B26174 0C00084C */ jal osSyncPrintf - -/* 00888 80B26178 00000000 */ nop -/* 0088C 80B2617C 8FA80024 */ lw $t0, 0x0024($sp) -/* 00890 80B26180 3C0480B2 */ lui $a0, %hi(D_80B26590) ## $a0 = 80B20000 -/* 00894 80B26184 24846590 */ addiu $a0, $a0, %lo(D_80B26590) ## $a0 = 80B26590 -/* 00898 80B26188 C5080028 */ lwc1 $f8, 0x0028($t0) ## 00000028 -/* 0089C 80B2618C 460042A1 */ cvt.d.s $f10, $f8 -/* 008A0 80B26190 44075000 */ mfc1 $a3, $f10 -/* 008A4 80B26194 44065800 */ mfc1 $a2, $f11 -/* 008A8 80B26198 0C00084C */ jal osSyncPrintf - -/* 008AC 80B2619C 00000000 */ nop -/* 008B0 80B261A0 3C0480B2 */ lui $a0, %hi(D_80B265BC) ## $a0 = 80B20000 -/* 008B4 80B261A4 0C00084C */ jal osSyncPrintf - -/* 008B8 80B261A8 248465BC */ addiu $a0, $a0, %lo(D_80B265BC) ## $a0 = 80B265BC -/* 008BC 80B261AC 3C014348 */ lui $at, 0x4348 ## $at = 43480000 -.L80B261B0: -/* 008C0 80B261B0 44819000 */ mtc1 $at, $f18 ## $f18 = 200.00 -/* 008C4 80B261B4 C6100090 */ lwc1 $f16, 0x0090($s0) ## 00000090 -/* 008C8 80B261B8 8FA90024 */ lw $t1, 0x0024($sp) -/* 008CC 80B261BC 4612803C */ c.lt.s $f16, $f18 -/* 008D0 80B261C0 00000000 */ nop -/* 008D4 80B261C4 45020031 */ bc1fl .L80B2628C -/* 008D8 80B261C8 8FBF001C */ lw $ra, 0x001C($sp) -/* 008DC 80B261CC C5240028 */ lwc1 $f4, 0x0028($t1) ## 00000028 -/* 008E0 80B261D0 C6060028 */ lwc1 $f6, 0x0028($s0) ## 00000028 -/* 008E4 80B261D4 8FA4002C */ lw $a0, 0x002C($sp) -/* 008E8 80B261D8 02003025 */ or $a2, $s0, $zero ## $a2 = 00000000 -/* 008EC 80B261DC 4604303E */ c.le.s $f6, $f4 -/* 008F0 80B261E0 24851C24 */ addiu $a1, $a0, 0x1C24 ## $a1 = 00001C24 -/* 008F4 80B261E4 45020029 */ bc1fl .L80B2628C -/* 008F8 80B261E8 8FBF001C */ lw $ra, 0x001C($sp) -/* 008FC 80B261EC 0C00CDD2 */ jal Actor_ChangeType - -/* 00900 80B261F0 24070005 */ addiu $a3, $zero, 0x0005 ## $a3 = 00000005 -/* 00904 80B261F4 8E0B0004 */ lw $t3, 0x0004($s0) ## 00000004 -/* 00908 80B261F8 3C0D8016 */ lui $t5, 0x8016 ## $t5 = 80160000 -/* 0090C 80B261FC 3C01C120 */ lui $at, 0xC120 ## $at = C1200000 -/* 00910 80B26200 356C0001 */ ori $t4, $t3, 0x0001 ## $t4 = 00000001 -/* 00914 80B26204 AE0C0004 */ sw $t4, 0x0004($s0) ## 00000004 -/* 00918 80B26208 8DADE664 */ lw $t5, -0x199C($t5) ## 8015E664 -/* 0091C 80B2620C 44818000 */ mtc1 $at, $f16 ## $f16 = -10.00 -/* 00920 80B26210 3C014220 */ lui $at, 0x4220 ## $at = 42200000 -/* 00924 80B26214 448D4000 */ mtc1 $t5, $f8 ## $f8 = -0.00 -/* 00928 80B26218 44812000 */ mtc1 $at, $f4 ## $f4 = 40.00 -/* 0092C 80B2621C 8FAE0024 */ lw $t6, 0x0024($sp) -/* 00930 80B26220 468042A0 */ cvt.s.w $f10, $f8 -/* 00934 80B26224 C6000028 */ lwc1 $f0, 0x0028($s0) ## 00000028 -/* 00938 80B26228 C5C60028 */ lwc1 $f6, 0x0028($t6) ## 00000028 -/* 0093C 80B2622C 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -/* 00940 80B26230 46105482 */ mul.s $f18, $f10, $f16 -/* 00944 80B26234 46049080 */ add.s $f2, $f18, $f4 -/* 00948 80B26238 46023200 */ add.s $f8, $f6, $f2 -/* 0094C 80B2623C E6080150 */ swc1 $f8, 0x0150($s0) ## 00000150 -/* 00950 80B26240 C60A0150 */ lwc1 $f10, 0x0150($s0) ## 00000150 -/* 00954 80B26244 4600503C */ c.lt.s $f10, $f0 -/* 00958 80B26248 00000000 */ nop -/* 0095C 80B2624C 45020004 */ bc1fl .L80B26260 -/* 00960 80B26250 8E180024 */ lw $t8, 0x0024($s0) ## 00000024 -/* 00964 80B26254 46020400 */ add.s $f16, $f0, $f2 -/* 00968 80B26258 E6100150 */ swc1 $f16, 0x0150($s0) ## 00000150 -/* 0096C 80B2625C 8E180024 */ lw $t8, 0x0024($s0) ## 00000024 -.L80B26260: -/* 00970 80B26260 8E0F0028 */ lw $t7, 0x0028($s0) ## 00000028 -/* 00974 80B26264 240528C4 */ addiu $a1, $zero, 0x28C4 ## $a1 = 000028C4 -/* 00978 80B26268 AE180154 */ sw $t8, 0x0154($s0) ## 00000154 -/* 0097C 80B2626C 8E18002C */ lw $t8, 0x002C($s0) ## 0000002C -/* 00980 80B26270 AE0F0158 */ sw $t7, 0x0158($s0) ## 00000158 -/* 00984 80B26274 0C00BE0A */ jal Audio_PlayActorSound2 - -/* 00988 80B26278 AE18015C */ sw $t8, 0x015C($s0) ## 0000015C -/* 0098C 80B2627C 3C1980B2 */ lui $t9, %hi(EnTuboTrap_InitializeAttack) ## $t9 = 80B20000 -/* 00990 80B26280 2739629C */ addiu $t9, $t9, %lo(EnTuboTrap_InitializeAttack) ## $t9 = 80B2629C -/* 00994 80B26284 AE19014C */ sw $t9, 0x014C($s0) ## 0000014C -/* 00998 80B26288 8FBF001C */ lw $ra, 0x001C($sp) -.L80B2628C: -/* 0099C 80B2628C 8FB00018 */ lw $s0, 0x0018($sp) -/* 009A0 80B26290 27BD0028 */ addiu $sp, $sp, 0x0028 ## $sp = 00000000 -/* 009A4 80B26294 03E00008 */ jr $ra -/* 009A8 80B26298 00000000 */ nop - - diff --git a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Update.s b/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Update.s deleted file mode 100644 index f4076e815c..0000000000 --- a/asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Update.s +++ /dev/null @@ -1,47 +0,0 @@ -glabel EnTuboTrap_Update -/* 00B04 80B263F4 27BDFFC8 */ addiu $sp, $sp, 0xFFC8 ## $sp = FFFFFFC8 -/* 00B08 80B263F8 AFB0001C */ sw $s0, 0x001C($sp) -/* 00B0C 80B263FC 00808025 */ or $s0, $a0, $zero ## $s0 = 00000000 -/* 00B10 80B26400 AFBF0024 */ sw $ra, 0x0024($sp) -/* 00B14 80B26404 AFB10020 */ sw $s1, 0x0020($sp) -/* 00B18 80B26408 8E19014C */ lw $t9, 0x014C($s0) ## 0000014C -/* 00B1C 80B2640C 00A08825 */ or $s1, $a1, $zero ## $s1 = 00000000 -/* 00B20 80B26410 0320F809 */ jalr $ra, $t9 -/* 00B24 80B26414 00000000 */ nop -/* 00B28 80B26418 0C00B638 */ jal Actor_MoveForward -/* 00B2C 80B2641C 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -/* 00B30 80B26420 3C014120 */ lui $at, 0x4120 ## $at = 41200000 -/* 00B34 80B26424 44810000 */ mtc1 $at, $f0 ## $f0 = 10.00 -/* 00B38 80B26428 3C0141A0 */ lui $at, 0x41A0 ## $at = 41A00000 -/* 00B3C 80B2642C 44812000 */ mtc1 $at, $f4 ## $f4 = 20.00 -/* 00B40 80B26430 240E001D */ addiu $t6, $zero, 0x001D ## $t6 = 0000001D -/* 00B44 80B26434 44060000 */ mfc1 $a2, $f0 -/* 00B48 80B26438 44070000 */ mfc1 $a3, $f0 -/* 00B4C 80B2643C AFAE0014 */ sw $t6, 0x0014($sp) -/* 00B50 80B26440 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000 -/* 00B54 80B26444 02002825 */ or $a1, $s0, $zero ## $a1 = 00000000 -/* 00B58 80B26448 0C00B92D */ jal func_8002E4B4 -/* 00B5C 80B2644C E7A40010 */ swc1 $f4, 0x0010($sp) -/* 00B60 80B26450 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -/* 00B64 80B26454 0C00B56E */ jal Actor_SetHeight -/* 00B68 80B26458 24050000 */ addiu $a1, $zero, 0x0000 ## $a1 = 00000000 -/* 00B6C 80B2645C 26050160 */ addiu $a1, $s0, 0x0160 ## $a1 = 00000160 -/* 00B70 80B26460 AFA50028 */ sw $a1, 0x0028($sp) -/* 00B74 80B26464 0C0189B7 */ jal ActorCollider_Cylinder_Update -/* 00B78 80B26468 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -/* 00B7C 80B2646C 3C010001 */ lui $at, 0x0001 ## $at = 00010000 -/* 00B80 80B26470 34211E60 */ ori $at, $at, 0x1E60 ## $at = 00011E60 -/* 00B84 80B26474 02212821 */ addu $a1, $s1, $at -/* 00B88 80B26478 AFA5002C */ sw $a1, 0x002C($sp) -/* 00B8C 80B2647C 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000 -/* 00B90 80B26480 0C01767D */ jal Actor_CollisionCheck_SetAC ## CollisionCheck_setAC -/* 00B94 80B26484 8FA60028 */ lw $a2, 0x0028($sp) -/* 00B98 80B26488 8FA5002C */ lw $a1, 0x002C($sp) -/* 00B9C 80B2648C 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000 -/* 00BA0 80B26490 0C0175E7 */ jal Actor_CollisionCheck_SetAT ## CollisionCheck_setAT -/* 00BA4 80B26494 8FA60028 */ lw $a2, 0x0028($sp) -/* 00BA8 80B26498 8FBF0024 */ lw $ra, 0x0024($sp) -/* 00BAC 80B2649C 8FB0001C */ lw $s0, 0x001C($sp) -/* 00BB0 80B264A0 8FB10020 */ lw $s1, 0x0020($sp) -/* 00BB4 80B264A4 03E00008 */ jr $ra -/* 00BB8 80B264A8 27BD0038 */ addiu $sp, $sp, 0x0038 ## $sp = 00000000 diff --git a/include/z64.h b/include/z64.h index bc9035b796..dc0baf5ee5 100644 --- a/include/z64.h +++ b/include/z64.h @@ -1351,21 +1351,7 @@ typedef struct OverlayRelocationSection { /* 0x0C */ u32 bssSize; /* 0x10 */ u32 nRelocations; /* 0x14 */ u32 relocations[1]; -} OverlayRelocationSection; /* size >= 0x18 */ - -#define VEC3_ADD( V3A0, V3A1 ) \ -{ \ - V3A0.x += V3A1.x; \ - V3A0.y += V3A1.y; \ - V3A0.z += V3A1.z; \ -} - -#define VEC3_SUB( V3DST, V3A0, V3A1 ) \ -{ \ - V3DST.x = V3A0.x - V3A1.x; \ - V3DST.y = V3A0.y - V3A1.y; \ - V3DST.z = V3A0.z - V3A1.z; \ -} +} OverlayRelocationSection; // size >= 0x18 typedef struct { diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c index 712272eed5..26431fc665 100644 --- a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c +++ b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.c @@ -4,24 +4,16 @@ * Description: Flying pot enemy */ -#include -#include +#include "z_en_tubo_trap.h" -typedef struct -{ - /* 0x0000 */ Actor actor; - /* 0x014C */ ActorFunc playfunc; - /* 0x0150 */ f32 pos_y_seek; - /* 0x0154 */ Vec3f pos_init; - /* 0x0160 */ ColliderCylinderMain capsule; -} EnTuboTrap; // size = 0x01AC +#include void EnTuboTrap_Init(EnTuboTrap* this, GlobalContext* globalCtx); void EnTuboTrap_Destroy(EnTuboTrap* this, GlobalContext* globalCtx); void EnTuboTrap_Update(EnTuboTrap* this, GlobalContext* globalCtx); void EnTuboTrap_Draw(EnTuboTrap* this, GlobalContext* globalCtx); -void EnTuboTrap_TestLevitate(EnTuboTrap* this, GlobalContext* globalCtx); -void EnTuboTrap_InitializeAttack(EnTuboTrap* this, GlobalContext* globalCtx); +void EnTuboTrap_WaitForProximity(EnTuboTrap* this, GlobalContext* globalCtx); +void EnTuboTrap_Levitate(EnTuboTrap* this, GlobalContext* globalCtx); void EnTuboTrap_Fly(EnTuboTrap* this, GlobalContext* globalCtx); #define ROOM 0x00 @@ -44,7 +36,7 @@ static ColliderCylinderInit cylinderInitData = 0x0000, 0x0000, 0x0000 }; -ActorInit En_Tubo_Trap_InitVars = +const ActorInit En_Tubo_Trap_InitVars = { ACTOR_EN_TUBO_TRAP, ACTORTYPE_PROP, @@ -58,321 +50,277 @@ ActorInit En_Tubo_Trap_InitVars = (ActorFunc)EnTuboTrap_Draw, }; -extern u32 DL_SHARD; -extern u32 DL_TUBO; +extern UNK_TYPE D_05017A60; +extern Gfx D_05017870[]; void EnTuboTrap_Init(EnTuboTrap* this, GlobalContext* globalCtx) { s32 pad; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawFunc_Circle, 2.0f); osSyncPrintf("\n\n"); - osSyncPrintf("\x1b[32m☆☆☆☆☆ 壷トラップ ☆☆☆☆☆ %x\n\x1b[m", this->actor.params); - ActorCollider_AllocCylinder(globalCtx, &this->capsule); - ActorCollider_InitCylinder(globalCtx, &this->capsule, &this->actor, &cylinderInitData); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 壷トラップ ☆☆☆☆☆ %x\n" VT_RST, this->actor.params); // "Urn Trap" + ActorCollider_AllocCylinder(globalCtx, &this->collider); + ActorCollider_InitCylinder(globalCtx, &this->collider, &this->actor, &cylinderInitData); Actor_SetScale(&this->actor, 0.1f); - this->playfunc = (ActorFunc*)EnTuboTrap_TestLevitate; + this->actionFunc = (ActorFunc)EnTuboTrap_WaitForProximity; } void EnTuboTrap_Destroy(EnTuboTrap* this, GlobalContext* globalCtx) { - ColliderCylinderMain* capsule = &this->capsule; - ActorCollider_FreeCylinder(globalCtx, capsule); + ColliderCylinderMain* collider = &this->collider; + ActorCollider_FreeCylinder(globalCtx, collider); } void EnTuboTrap_DropCollectible(EnTuboTrap* this, GlobalContext* globalCtx) { s16 params = this->actor.params; - s16 param1 = (params >> 6) & 0x03FF; - if (param1 >= 0 && param1 < 0x1A) + s16 param3FF = (params >> 6) & 0x3FF; + if (param3FF >= 0 && param3FF < 0x1A) { - Item_DropCollectible(globalCtx, &this->actor.posRot, param1 | ((params & 0x03F) << 8)); + Item_DropCollectible(globalCtx, &this->actor.posRot, param3FF | ((params & 0x3F) << 8)); } } #ifdef NON_MATCHING -void EnTuboTrap_Fragments(EnTuboTrap* this, GlobalContext* globalCtx) +// regalloc and stack usage differences, most likely the same differences as EnTuboTrap_SpawnWaterFragments +void EnTuboTrap_SpawnFragments(EnTuboTrap* this, GlobalContext* globalCtx) { - u32 uVar1; - s32 rando_seed = 0; - s32 shard_count = 0; + Vec3f* actorPos; + f32 rand; + f32 cos; + f32 sin; + u32 addr; + Vec3f spC8; + Vec3f spBC; + s16 var; + s32 temp; + s32 i; - /* spawn fragments */ - do + addr = &D_05017A60; + actorPos = &this->actor.posRot.pos; + + for (i = 0, var = 0; i < 15; i++, var += 20000) { - Vec3f burst_depth[2]; - f32 rng; + sin = Math_Sins(var); + cos = Math_Coss(var); + spC8.x = sin * 8.0f; + spC8.y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f; + spC8.z = cos * 8.0f; - /* burst_depth_x */ - burst_depth[0].x = Math_Sins(rando_seed) * 8.0f; - burst_depth[0].y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f; - burst_depth[0].z = Math_Coss(rando_seed) * 8.0f; + spBC.x = spC8.x * 0.23f; + spBC.y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f; + spBC.z = spC8.z * 0.23f; - /* burst_depth_y */ - burst_depth[1].x = (f32)(burst_depth[0].x * 0.23f); - burst_depth[1].y = (f32)(Math_Rand_ZeroOne() * 5.0f) + 2.0f; - burst_depth[1].z = (f32)(burst_depth[0].z * 0.23f); + spC8.x += actorPos->x; + spC8.y += actorPos->y; + spC8.z += actorPos->z; - VEC3_ADD(burst_depth[0], this->actor.posRot.pos) - - rng = Math_Rand_ZeroOne(); - - if (rng < 0.2f) - { - uVar1 = 0x60; - } + rand = Math_Rand_ZeroOne(); + if (rand < 0.2f) + temp = 96; + else if (rand < 0.6f) + temp = 64; else - { - uVar1 = 0x20; + temp = 32; - if (rng < 0.6f) - { - uVar1 = 0x40; - } - } - - /* The Heavy Lifting */ - Effect_SpawnFragment(globalCtx, &burst_depth[0], &burst_depth[1], &this->actor.posRot.pos, -239, uVar1, 10, 10, 0, - (Math_Rand_ZeroOne() * 65.0f) + 15.0f, 0, 0x20, 0x3C, -1, 3, DL_SHARD); - - shard_count++; - rando_seed = (s32)((rando_seed + 0x4E20) * 0x10000) >> 0x10; + Effect_SpawnFragment(globalCtx, &spC8, &spBC, actorPos, -240, temp, 10, 10, 0, + (Math_Rand_ZeroOne() * 65.0f) + 15.0f, 0, 32, 60, -1, 3, addr); } - while(shard_count != 15); - func_80033480(globalCtx, &this->actor.posRot.pos, 30.0f, 4, 20, 50, 0); + func_80033480(globalCtx, actorPos, 30.0f, 4, 20, 50, 0); } #else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fragments.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnFragments.s") #endif #ifdef NON_MATCHING -void EnTuboTrap_FragmentsWater(EnTuboTrap* this, GlobalContext* globalCtx) +// regalloc and stack usage differences, most likely the same differences as EnTuboTrap_SpawnFragments +void EnTuboTrap_SpawnWaterFragments(EnTuboTrap* this, GlobalContext* globalCtx) { - u32 uVar1; - s32 rando_seed = 0; - s32 shard_count = 0; - Vec3f burst_depth[2]; - f32 rng; + Vec3f* actorPos; + f32 rand; + f32 cos; + f32 sin; + u32 addr; + Vec3f spC8; + Vec3f spBC; + s16 var; + s32 temp; + s32 i; - Math_Vec3f_Copy(&burst_depth[0], &this->actor.posRot.pos); - burst_depth[0].y += this->actor.waterSurfaceDist; + addr = &D_05017A60; + actorPos = &this->actor.posRot.pos; - /* spawn a small splash */ - func_8002949C(globalCtx, &burst_depth[0], 0, 0, 0, 0x190); + spC8 = *actorPos; + spC8.y += this->actor.unk_84; - /* spawn fragments */ - do + func_8002949C(globalCtx, &spC8, 0, 0, 0, 400); + + for (i = 0, var = 0; i < 15; i++, var += 20000) { - /* burst_depth_x */ - burst_depth[0].x = Math_Sins(rando_seed) * 8.0f; - burst_depth[0].y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f; - burst_depth[0].z = Math_Coss(rando_seed) * 8.0f; + sin = Math_Sins(var); + cos = Math_Coss(var); + spC8.x = sin * 8.0f; + spC8.y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f; + spC8.z = cos * 8.0f; - /* burst_depth_y */ - burst_depth[1].x = (f32)(burst_depth[0].x * 0.23f); - burst_depth[1].y = (f32)(Math_Rand_ZeroOne() * 5.0f) + 2.0f; - burst_depth[1].z = (f32)(burst_depth[0].z * 0.23f); + spBC.x = spC8.x * 0.23f; + spBC.y = (Math_Rand_ZeroOne() * 4.0f) + 2.0f; + spBC.z = spC8.z * 0.23f; - VEC3_ADD(burst_depth[0], this->actor.posRot.pos) + spC8.x += actorPos->x; + spC8.y += actorPos->y; + spC8.z += actorPos->z; - rng = Math_Rand_ZeroOne(); - - if (rng < 0.2f) - { - uVar1 = 0x60; - } + rand = Math_Rand_ZeroOne(); + if (rand < 0.2f) + temp = 64; else - { - uVar1 = 0x20; + temp = 32; - if (rng < 0.6f) - { - uVar1 = 0x40; - } - } - - /* The Heavy Lifting */ - Effect_SpawnFragment(globalCtx, &burst_depth[0], &burst_depth[1], &this->actor.posRot.pos, -239, uVar1, - 10, 10, 0, (Math_Rand_ZeroOne() * 65.0f) + 15.0f, 0, 0x20, 0x3C, -1, 3, DL_SHARD); - shard_count++; - rando_seed = (s32)((rando_seed + 0x4E20) * 0x10000) >> 0x10; + Effect_SpawnFragment(globalCtx, &spC8, &spBC, actorPos, -180, temp, 30, 30, 0, + (Math_Rand_ZeroOne() * 65.0f) + 15.0f, 0, 32, 70, -1, 3, addr); } - while(shard_count != 15); - - func_80033480(globalCtx, &this->actor.posRot.pos, 30.0f, 4, 20, 50, 0); } #else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_FragmentsWater.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnWaterFragments.s") #endif #ifdef NON_MATCHING -void EnTuboTrap_TestCollider(EnTuboTrap* this, GlobalContext* globalCtx) +void EnTuboTrap_HandleImpact(EnTuboTrap* this, GlobalContext* globalCtx) { - u8 bVar1, bVar2; - u16 uVar3; - Actor* collided_this; + s32 pad; Player* player = PLAYER; - if (!(this->actor.bgCheckFlags & 20)) + if ((this->actor.bgCheckFlags & 0x20) && (this->actor.unk_84 > 15.0f)) { - bVar1 = this->capsule.base.colliderFlags; + EnTuboTrap_SpawnWaterFragments(this, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_BOMB_DROP_WATER); + EnTuboTrap_DropCollectible(this, globalCtx); + Actor_Kill(&this->actor); + return; } - else + + if (this->collider.base.colliderFlags & 4) { - if (this->actor.waterSurfaceDist > 15.0f) + this->collider.base.colliderFlags &= ~4; + EnTuboTrap_SpawnFragments(this, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_IT_SHIELD_REFLECT_SW); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_POT_BROKEN); + EnTuboTrap_DropCollectible(this, globalCtx); + Actor_Kill(&this->actor); + return; + } + + if (this->collider.base.collideFlags & 2) + { + this->collider.base.collideFlags &= ~2; + EnTuboTrap_SpawnFragments(this, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_EXPLOSION); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_POT_BROKEN); + EnTuboTrap_DropCollectible(this, globalCtx); + Actor_Kill(&this->actor); + return; + } + + if (this->collider.base.colliderFlags & 2) + { + this->collider.base.colliderFlags &= ~2; + if (this->collider.base.at == &player->actor) { - EnTuboTrap_FragmentsWater(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_BOMB_DROP_WATER); + EnTuboTrap_SpawnFragments(this, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_POT_BROKEN); + Audio_PlaySoundAtPosition(globalCtx, &player->actor.posRot.pos, 40, 0x83E); EnTuboTrap_DropCollectible(this, globalCtx); Actor_Kill(&this->actor); return; } - - bVar1 = this->capsule.base.collideFlags; } - if (!(bVar1 & 4)) + if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1)) { - bVar2 = this->capsule.base.collideFlags; - if (!(bVar2 & 2)) - { - if (!(bVar1 & 2)) - { - uVar3 = this->actor.bgCheckFlags; - } - else - { - collided_this = this->capsule.base.actor; - this->capsule.base.colliderFlags = bVar1 & 0xFD; - - if (collided_this == &player->actor) - { - EnTuboTrap_Fragments(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_POT_BROKEN); - Audio_PlaySoundAtPosition(globalCtx, &player->actor.posRot.pos, 0x28, NA_SE_PL_BODY_HIT); - EnTuboTrap_DropCollectible(this, globalCtx); - Actor_Kill(&this->actor); - return; - } - uVar3 = this->actor.bgCheckFlags; - } - - if ((uVar3 & 8) || (uVar3 & 1)) - { - EnTuboTrap_Fragments(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_POT_BROKEN); - EnTuboTrap_DropCollectible(this, globalCtx); - Actor_Kill(&this->actor); - } - } - else - { - this->capsule.base.collideFlags = bVar2 & 0xFD; - EnTuboTrap_Fragments(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_EXPLOSION); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_POT_BROKEN); - EnTuboTrap_DropCollectible(this, globalCtx); - Actor_Kill(&this->actor); - } - } - else - { - this->capsule.base.colliderFlags = bVar1 & 0xFB; - EnTuboTrap_Fragments(this, globalCtx); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_IT_SHIELD_REFLECT_SW); - Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_POT_BROKEN); + EnTuboTrap_SpawnFragments(this, globalCtx); + Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_POT_BROKEN); EnTuboTrap_DropCollectible(this, globalCtx); Actor_Kill(&this->actor); + return; } } #else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestCollider.s") +#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_HandleImpact.s") #endif -#ifdef NON_MATCHING -void EnTuboTrap_TestLevitate(EnTuboTrap* this, GlobalContext* globalCtx) +void EnTuboTrap_WaitForProximity(EnTuboTrap* this, GlobalContext* globalCtx) { Player* player = PLAYER; - f32 seekY; + f32 targetHeight; if (BREG(2) != 0) { - osSyncPrintf("[32m☆☆☆☆☆ わて ☆☆☆☆☆ %f\n", globalCtx, this->actor.posRot.pos.y); - osSyncPrintf("[32m☆☆☆☆☆ おいどん ☆☆☆☆☆ %f\n"); + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ わて ☆☆☆☆☆ %f\n" VT_RST, this->actor.posRot.pos.y); // "You" + osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ おいどん ☆☆☆☆☆ %f\n" VT_RST, player->actor.posRot.pos.y); // "Me" osSyncPrintf("\n\n"); } - if (this->actor.xzDistanceFromLink < 200.00000000 && this->actor.posRot.pos.y <= player->actor.posRot.pos.y) + if (this->actor.xzDistanceFromLink < 200.0f && this->actor.posRot.pos.y <= player->actor.posRot.pos.y) { Actor_ChangeType(globalCtx, &globalCtx->actorCtx, this, ACTORTYPE_ENEMY); this->actor.flags |= 1; - seekY = (f32)gSaveContext.link_age * -10.00000000 + 40.00000000; - this->pos_y_seek = player->actor.posRot.pos.y; + targetHeight = 40.0f + -10.0f * gSaveContext.link_age; - if (this->pos_y_seek < this->actor.posRot.pos.y) - this->pos_y_seek = this->actor.posRot.pos.y + seekY; - - this->actor.initPosRot.pos = this->actor.posRot.pos; + this->targetY = player->actor.posRot.pos.y + targetHeight; + if (this->targetY < this->actor.posRot.pos.y) + this->targetY = this->actor.posRot.pos.y + targetHeight; + this->originPos = this->actor.posRot.pos; Audio_PlayActorSound2(this, NA_SE_EV_POT_MOVE_START); - this->playfunc = (ActorFunc)EnTuboTrap_InitializeAttack; + this->actionFunc = (ActorFunc)EnTuboTrap_Levitate; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestLevitate.s") -#endif -#ifdef NON_MATCHING -void EnTuboTrap_InitializeAttack(EnTuboTrap* this, GlobalContext* globalCtx) +void EnTuboTrap_Levitate(EnTuboTrap* this, GlobalContext* globalCtx) { - this->actor.posRot.rot.y += 5000; - Math_SmoothScaleMaxF(&this->actor.posRot.pos.y, this->pos_y_seek, 0.8f, 3.0f); /* Tween levitation */ + this->actor.shape.rot.y += 5000; + Math_SmoothScaleMaxF(&this->actor.posRot.pos.y, this->targetY, 0.8f, 3.0f); - if (ABS(this->actor.posRot.pos.y - this->pos_y_seek) < 10.0f) + if (fabsf(this->actor.posRot.pos.y - this->targetY) < 10.0f) { this->actor.speedXZ = 10.0f; this->actor.posRot.rot.y = this->actor.rotTowardsLinkY; - this->playfunc = (ActorFunc)EnTuboTrap_Fly; + this->actionFunc = (ActorFunc)EnTuboTrap_Fly; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_InitializeAttack.s") -#endif -#ifdef NON_MATCHING void EnTuboTrap_Fly(EnTuboTrap* this, GlobalContext* globalCtx) { - Vec3f pos_delta; + f32 dx = this->originPos.x - this->actor.posRot.pos.x; + f32 dy = this->originPos.y - this->actor.posRot.pos.y; + f32 dz = this->originPos.z - this->actor.posRot.pos.z; - VEC3_SUB(pos_delta, this->pos_init, this->actor.posRot.pos); - Audio_PlayActorSound2(&this->actor, NA_SE_EN_TUBOOCK_FLY); + Audio_PlayActorSound2(&this->actor, 0x3037); - if (240.0f < sqrtf(SQ(pos_delta.x) + SQ(pos_delta.y) + SQ(pos_delta.z))) - Math_SmoothScaleMaxF(&this->actor.gravity, -3.0f, 0.2f, 0.5f); /* Tween to ground */ + if (240.0f < sqrtf(SQ(dx) + SQ(dy) + SQ(dz))) + Math_SmoothScaleMaxF(&this->actor.gravity, -3.0f, 0.2f, 0.5f); - this->actor.posRot.rot.y += 5000; - EnTuboTrap_TestCollider(this, globalCtx); + this->actor.shape.rot.y += 5000; + EnTuboTrap_HandleImpact(this, globalCtx); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fly.s") -#endif -#ifdef NON_MATCHING void EnTuboTrap_Update(EnTuboTrap* this, GlobalContext* globalCtx) { - this->playfunc(this, globalCtx); - Actor_MoveForward(&this->actor); /* Probably to haul ass towards Link */ - func_8002E4B4(globalCtx, &this->actor, 10.0f, 10.0f, 20.0f, 0x1D); /* Necessary for drawing a shadow */ - Actor_SetHeight(&this->actor, 0.0f); - ActorCollider_Cylinder_Update(&this->actor, &this->capsule); - Actor_CollisionCheck_SetAC(globalCtx, &globalCtx->sub_11E60, &this->capsule); - Actor_CollisionCheck_SetAT(globalCtx, &globalCtx->sub_11E60, &this->capsule); + EnTuboTrap* tuboTrap = this; + SubGlobalContext11E60* sub_11E60 = &globalCtx->sub_11E60; + + tuboTrap->actionFunc(tuboTrap, globalCtx); + Actor_MoveForward(&tuboTrap->actor); + func_8002E4B4(globalCtx, &tuboTrap->actor, 10.0f, 10.0f, 20.0f, 0x1D); + Actor_SetHeight(&tuboTrap->actor, 0.0f); + ActorCollider_Cylinder_Update(&tuboTrap->actor, &tuboTrap->collider); + Actor_CollisionCheck_SetAC(globalCtx, sub_11E60, &tuboTrap->collider); + Actor_CollisionCheck_SetAT(globalCtx, sub_11E60, &tuboTrap->collider); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Update.s") -#endif void EnTuboTrap_Draw(EnTuboTrap* this, GlobalContext* globalCtx) { - Draw_DListOpa(globalCtx, &DL_TUBO); + Draw_DListOpa(globalCtx, D_05017870); } diff --git a/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h new file mode 100644 index 0000000000..55a3a5a937 --- /dev/null +++ b/src/overlays/actors/ovl_En_Tubo_Trap/z_en_tubo_trap.h @@ -0,0 +1,18 @@ +#ifndef _Z_EN_TUBO_TRAP_H_ +#define _Z_EN_TUBO_TRAP_H_ + +#include +#include + +typedef struct +{ + /* 0x0000 */ Actor actor; + /* 0x014C */ ActorFunc actionFunc; + /* 0x0150 */ f32 targetY; + /* 0x0154 */ Vec3f originPos; + /* 0x0160 */ ColliderCylinderMain collider; +} EnTuboTrap; // size = 0x01AC + +extern const ActorInit En_Tubo_Trap_InitVars; + +#endif diff --git a/undefined_syms.txt b/undefined_syms.txt index c2d7779fd5..102b185600 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -140,8 +140,8 @@ D_0703811C = 0x0703811C; D_080895C0 = 0x080895C0; // z_en_tubo_trap -DL_TUBO = 0x05017870; -DL_SHARD = 0x05017A60; +D_05017870 = 0x05017870; +D_05017A60 = 0x05017A60; // z_en_vase DL_VASE = 0x06000000;