From 83fc21fea6f28bf9e5efd4feb5d669938b245732 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Mon, 28 Sep 2020 01:18:47 -0400 Subject: [PATCH] Match and fully document bg_ddan_jd (#386) * match and fully document bg_ddan_jd * fix comment * implemented suggested changes, minor fixes * more changes * implement requested changes, tweak wording on ySpeed comments * more minor tweaks --- .../actors/ovl_Bg_Ddan_Jd/BgDdanJd_Destroy.s | 14 -- .../actors/ovl_Bg_Ddan_Jd/BgDdanJd_Draw.s | 16 -- .../actors/ovl_Bg_Ddan_Jd/BgDdanJd_Init.s | 50 ------ .../actors/ovl_Bg_Ddan_Jd/BgDdanJd_Update.s | 10 -- .../actors/ovl_Bg_Ddan_Jd/func_80870B88.s | 117 ------------- .../actors/ovl_Bg_Ddan_Jd/func_80870D2C.s | 125 -------------- .../actors/ovl_Bg_Ddan_Jd/func_80870F00.s | 74 -------- data/overlays/actors/z_bg_ddan_jd.data.s | 20 --- data/overlays/actors/z_bg_ddan_jd.reloc.s | 13 -- spec | 3 +- .../actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.c | 160 ++++++++++++++++-- .../actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.h | 5 +- undefined_syms.txt | 4 + 13 files changed, 157 insertions(+), 454 deletions(-) delete mode 100644 asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Destroy.s delete mode 100644 asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Draw.s delete mode 100644 asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Init.s delete mode 100644 asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Update.s delete mode 100644 asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/func_80870B88.s delete mode 100644 asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/func_80870D2C.s delete mode 100644 asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/func_80870F00.s delete mode 100644 data/overlays/actors/z_bg_ddan_jd.data.s delete mode 100644 data/overlays/actors/z_bg_ddan_jd.reloc.s diff --git a/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Destroy.s b/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Destroy.s deleted file mode 100644 index 5b15588a33..0000000000 --- a/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Destroy.s +++ /dev/null @@ -1,14 +0,0 @@ -glabel BgDdanJd_Destroy -/* 000A8 80870B58 27BDFFE8 */ addiu $sp, $sp, 0xFFE8 ## $sp = FFFFFFE8 -/* 000AC 80870B5C AFA40018 */ sw $a0, 0x0018($sp) -/* 000B0 80870B60 8FAE0018 */ lw $t6, 0x0018($sp) -/* 000B4 80870B64 AFBF0014 */ sw $ra, 0x0014($sp) -/* 000B8 80870B68 00A02025 */ or $a0, $a1, $zero ## $a0 = 00000000 -/* 000BC 80870B6C 24A50810 */ addiu $a1, $a1, 0x0810 ## $a1 = 00000810 -/* 000C0 80870B70 0C00FB56 */ jal DynaPolyInfo_Free - ## DynaPolyInfo_delReserve -/* 000C4 80870B74 8DC6014C */ lw $a2, 0x014C($t6) ## 0000014C -/* 000C8 80870B78 8FBF0014 */ lw $ra, 0x0014($sp) -/* 000CC 80870B7C 27BD0018 */ addiu $sp, $sp, 0x0018 ## $sp = 00000000 -/* 000D0 80870B80 03E00008 */ jr $ra -/* 000D4 80870B84 00000000 */ nop diff --git a/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Draw.s b/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Draw.s deleted file mode 100644 index 983cc4395d..0000000000 --- a/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Draw.s +++ /dev/null @@ -1,16 +0,0 @@ -glabel BgDdanJd_Draw -/* 00578 80871028 27BDFFE8 */ addiu $sp, $sp, 0xFFE8 ## $sp = FFFFFFE8 -/* 0057C 8087102C AFA40018 */ sw $a0, 0x0018($sp) -/* 00580 80871030 00A02025 */ or $a0, $a1, $zero ## $a0 = 00000000 -/* 00584 80871034 AFBF0014 */ sw $ra, 0x0014($sp) -/* 00588 80871038 3C050600 */ lui $a1, 0x0600 ## $a1 = 06000000 -/* 0058C 8087103C 0C00D498 */ jal Gfx_DrawDListOpa - -/* 00590 80871040 24A537B8 */ addiu $a1, $a1, 0x37B8 ## $a1 = 060037B8 -/* 00594 80871044 8FBF0014 */ lw $ra, 0x0014($sp) -/* 00598 80871048 27BD0018 */ addiu $sp, $sp, 0x0018 ## $sp = 00000000 -/* 0059C 8087104C 03E00008 */ jr $ra -/* 005A0 80871050 00000000 */ nop -/* 005A4 80871054 00000000 */ nop -/* 005A8 80871058 00000000 */ nop -/* 005AC 8087105C 00000000 */ nop diff --git a/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Init.s b/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Init.s deleted file mode 100644 index 3f74a3ceb0..0000000000 --- a/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Init.s +++ /dev/null @@ -1,50 +0,0 @@ -glabel BgDdanJd_Init -/* 00000 80870AB0 27BDFFD0 */ addiu $sp, $sp, 0xFFD0 ## $sp = FFFFFFD0 -/* 00004 80870AB4 AFA50034 */ sw $a1, 0x0034($sp) -/* 00008 80870AB8 AFBF001C */ sw $ra, 0x001C($sp) -/* 0000C 80870ABC AFB00018 */ sw $s0, 0x0018($sp) -/* 00010 80870AC0 3C058087 */ lui $a1, %hi(D_80871080) ## $a1 = 80870000 -/* 00014 80870AC4 00808025 */ or $s0, $a0, $zero ## $s0 = 00000000 -/* 00018 80870AC8 AFA00024 */ sw $zero, 0x0024($sp) -/* 0001C 80870ACC 0C01E037 */ jal Actor_ProcessInitChain - -/* 00020 80870AD0 24A51080 */ addiu $a1, $a1, %lo(D_80871080) ## $a1 = 80871080 -/* 00024 80870AD4 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -/* 00028 80870AD8 0C010D20 */ jal DynaPolyInfo_SetActorMove - -/* 0002C 80870ADC 24050001 */ addiu $a1, $zero, 0x0001 ## $a1 = 00000001 -/* 00030 80870AE0 3C040600 */ lui $a0, 0x0600 ## $a0 = 06000000 -/* 00034 80870AE4 24843CE0 */ addiu $a0, $a0, 0x3CE0 ## $a0 = 06003CE0 -/* 00038 80870AE8 0C010620 */ jal DynaPolyInfo_Alloc - -/* 0003C 80870AEC 27A50024 */ addiu $a1, $sp, 0x0024 ## $a1 = FFFFFFF4 -/* 00040 80870AF0 8FA40034 */ lw $a0, 0x0034($sp) -/* 00044 80870AF4 02003025 */ or $a2, $s0, $zero ## $a2 = 00000000 -/* 00048 80870AF8 8FA70024 */ lw $a3, 0x0024($sp) -/* 0004C 80870AFC 0C00FA9D */ jal DynaPolyInfo_RegisterActor - ## DynaPolyInfo_setActor -/* 00050 80870B00 24850810 */ addiu $a1, $a0, 0x0810 ## $a1 = 00000810 -/* 00054 80870B04 240E0064 */ addiu $t6, $zero, 0x0064 ## $t6 = 00000064 -/* 00058 80870B08 AE02014C */ sw $v0, 0x014C($s0) ## 0000014C -/* 0005C 80870B0C A60E016A */ sh $t6, 0x016A($s0) ## 0000016A -/* 00060 80870B10 A2000168 */ sb $zero, 0x0168($s0) ## 00000168 -/* 00064 80870B14 8FA40034 */ lw $a0, 0x0034($sp) -/* 00068 80870B18 0C00B2D0 */ jal Flags_GetSwitch - -/* 0006C 80870B1C 8605001C */ lh $a1, 0x001C($s0) ## 0000001C -/* 00070 80870B20 10400004 */ beq $v0, $zero, .L80870B34 -/* 00074 80870B24 3C198087 */ lui $t9, %hi(func_80870B88) ## $t9 = 80870000 -/* 00078 80870B28 240F0005 */ addiu $t7, $zero, 0x0005 ## $t7 = 00000005 -/* 0007C 80870B2C 10000003 */ beq $zero, $zero, .L80870B3C -/* 00080 80870B30 A20F0169 */ sb $t7, 0x0169($s0) ## 00000169 -.L80870B34: -/* 00084 80870B34 24180001 */ addiu $t8, $zero, 0x0001 ## $t8 = 00000001 -/* 00088 80870B38 A2180169 */ sb $t8, 0x0169($s0) ## 00000169 -.L80870B3C: -/* 0008C 80870B3C 27390B88 */ addiu $t9, $t9, %lo(func_80870B88) ## $t9 = 80870B88 -/* 00090 80870B40 AE190164 */ sw $t9, 0x0164($s0) ## 00000164 -/* 00094 80870B44 8FBF001C */ lw $ra, 0x001C($sp) -/* 00098 80870B48 8FB00018 */ lw $s0, 0x0018($sp) -/* 0009C 80870B4C 27BD0030 */ addiu $sp, $sp, 0x0030 ## $sp = 00000000 -/* 000A0 80870B50 03E00008 */ jr $ra -/* 000A4 80870B54 00000000 */ nop diff --git a/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Update.s b/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Update.s deleted file mode 100644 index a546d766c1..0000000000 --- a/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Update.s +++ /dev/null @@ -1,10 +0,0 @@ -glabel BgDdanJd_Update -/* 00554 80871004 27BDFFE8 */ addiu $sp, $sp, 0xFFE8 ## $sp = FFFFFFE8 -/* 00558 80871008 AFBF0014 */ sw $ra, 0x0014($sp) -/* 0055C 8087100C 8C990164 */ lw $t9, 0x0164($a0) ## 00000164 -/* 00560 80871010 0320F809 */ jalr $ra, $t9 -/* 00564 80871014 00000000 */ nop -/* 00568 80871018 8FBF0014 */ lw $ra, 0x0014($sp) -/* 0056C 8087101C 27BD0018 */ addiu $sp, $sp, 0x0018 ## $sp = 00000000 -/* 00570 80871020 03E00008 */ jr $ra -/* 00574 80871024 00000000 */ nop diff --git a/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/func_80870B88.s b/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/func_80870B88.s deleted file mode 100644 index a0a0d0f21d..0000000000 --- a/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/func_80870B88.s +++ /dev/null @@ -1,117 +0,0 @@ -glabel func_80870B88 -/* 000D8 80870B88 27BDFFE0 */ addiu $sp, $sp, 0xFFE0 ## $sp = FFFFFFE0 -/* 000DC 80870B8C AFBF001C */ sw $ra, 0x001C($sp) -/* 000E0 80870B90 AFA50024 */ sw $a1, 0x0024($sp) -/* 000E4 80870B94 8482016A */ lh $v0, 0x016A($a0) ## 0000016A -/* 000E8 80870B98 00803825 */ or $a3, $a0, $zero ## $a3 = 00000000 -/* 000EC 80870B9C 10400002 */ beq $v0, $zero, .L80870BA8 -/* 000F0 80870BA0 244EFFFF */ addiu $t6, $v0, 0xFFFF ## $t6 = FFFFFFFF -/* 000F4 80870BA4 A48E016A */ sh $t6, 0x016A($a0) ## 0000016A -.L80870BA8: -/* 000F8 80870BA8 90EF0169 */ lbu $t7, 0x0169($a3) ## 00000169 -/* 000FC 80870BAC 24030001 */ addiu $v1, $zero, 0x0001 ## $v1 = 00000001 -/* 00100 80870BB0 546F001E */ bnel $v1, $t7, .L80870C2C -/* 00104 80870BB4 84E8016A */ lh $t0, 0x016A($a3) ## 0000016A -/* 00108 80870BB8 84E5001C */ lh $a1, 0x001C($a3) ## 0000001C -/* 0010C 80870BBC 8FA40024 */ lw $a0, 0x0024($sp) -/* 00110 80870BC0 28A10040 */ slti $at, $a1, 0x0040 -/* 00114 80870BC4 50200019 */ beql $at, $zero, .L80870C2C -/* 00118 80870BC8 84E8016A */ lh $t0, 0x016A($a3) ## 0000016A -/* 0011C 80870BCC 0C00B2D0 */ jal Flags_GetSwitch - -/* 00120 80870BD0 AFA70020 */ sw $a3, 0x0020($sp) -/* 00124 80870BD4 24030001 */ addiu $v1, $zero, 0x0001 ## $v1 = 00000001 -/* 00128 80870BD8 10400013 */ beq $v0, $zero, .L80870C28 -/* 0012C 80870BDC 8FA70020 */ lw $a3, 0x0020($sp) -/* 00130 80870BE0 3C01430C */ lui $at, 0x430C ## $at = 430C0000 -/* 00134 80870BE4 44813000 */ mtc1 $at, $f6 ## $f6 = 140.00 -/* 00138 80870BE8 C4E4000C */ lwc1 $f4, 0x000C($a3) ## 0000000C -/* 0013C 80870BEC 24180005 */ addiu $t8, $zero, 0x0005 ## $t8 = 00000005 -/* 00140 80870BF0 24190001 */ addiu $t9, $zero, 0x0001 ## $t9 = 00000001 -/* 00144 80870BF4 46062200 */ add.s $f8, $f4, $f6 -/* 00148 80870BF8 A0F80169 */ sb $t8, 0x0169($a3) ## 00000169 -/* 0014C 80870BFC A0F90168 */ sb $t9, 0x0168($a3) ## 00000168 -/* 00150 80870C00 A4E0016A */ sh $zero, 0x016A($a3) ## 0000016A -/* 00154 80870C04 E4E80028 */ swc1 $f8, 0x0028($a3) ## 00000028 -/* 00158 80870C08 AFA70020 */ sw $a3, 0x0020($sp) -/* 0015C 80870C0C AFA00010 */ sw $zero, 0x0010($sp) -/* 00160 80870C10 8FA40024 */ lw $a0, 0x0024($sp) -/* 00164 80870C14 24050BF4 */ addiu $a1, $zero, 0x0BF4 ## $a1 = 00000BF4 -/* 00168 80870C18 0C02003E */ jal func_800800F8 -/* 0016C 80870C1C 2406FF9D */ addiu $a2, $zero, 0xFF9D ## $a2 = FFFFFF9D -/* 00170 80870C20 24030001 */ addiu $v1, $zero, 0x0001 ## $v1 = 00000001 -/* 00174 80870C24 8FA70020 */ lw $a3, 0x0020($sp) -.L80870C28: -/* 00178 80870C28 84E8016A */ lh $t0, 0x016A($a3) ## 0000016A -.L80870C2C: -/* 0017C 80870C2C 3C188087 */ lui $t8, %hi(func_80870F00) ## $t8 = 80870000 -/* 00180 80870C30 27180F00 */ addiu $t8, $t8, %lo(func_80870F00) ## $t8 = 80870F00 -/* 00184 80870C34 5500003A */ bnel $t0, $zero, .L80870D20 -/* 00188 80870C38 8FBF001C */ lw $ra, 0x001C($sp) -/* 0018C 80870C3C 90E20168 */ lbu $v0, 0x0168($a3) ## 00000168 -/* 00190 80870C40 24090064 */ addiu $t1, $zero, 0x0064 ## $t1 = 00000064 -/* 00194 80870C44 A4E9016A */ sh $t1, 0x016A($a3) ## 0000016A -/* 00198 80870C48 14400008 */ bne $v0, $zero, .L80870C6C -/* 0019C 80870C4C 3C01430C */ lui $at, 0x430C ## $at = 430C0000 -/* 001A0 80870C50 C4EA000C */ lwc1 $f10, 0x000C($a3) ## 0000000C -/* 001A4 80870C54 44818000 */ mtc1 $at, $f16 ## $f16 = 140.00 -/* 001A8 80870C58 240A0001 */ addiu $t2, $zero, 0x0001 ## $t2 = 00000001 -/* 001AC 80870C5C A0EA0168 */ sb $t2, 0x0168($a3) ## 00000168 -/* 001B0 80870C60 46105480 */ add.s $f18, $f10, $f16 -/* 001B4 80870C64 1000002C */ beq $zero, $zero, .L80870D18 -/* 001B8 80870C68 E4F2016C */ swc1 $f18, 0x016C($a3) ## 0000016C -.L80870C6C: -/* 001BC 80870C6C 14620010 */ bne $v1, $v0, .L80870CB0 -/* 001C0 80870C70 24010002 */ addiu $at, $zero, 0x0002 ## $at = 00000002 -/* 001C4 80870C74 90EB0169 */ lbu $t3, 0x0169($a3) ## 00000169 -/* 001C8 80870C78 3C01442F */ lui $at, 0x442F ## $at = 442F0000 -/* 001CC 80870C7C 506B0009 */ beql $v1, $t3, .L80870CA4 -/* 001D0 80870C80 C4EA000C */ lwc1 $f10, 0x000C($a3) ## 0000000C -/* 001D4 80870C84 C4E4000C */ lwc1 $f4, 0x000C($a3) ## 0000000C -/* 001D8 80870C88 44813000 */ mtc1 $at, $f6 ## $f6 = 700.00 -/* 001DC 80870C8C 240C0003 */ addiu $t4, $zero, 0x0003 ## $t4 = 00000003 -/* 001E0 80870C90 A0EC0168 */ sb $t4, 0x0168($a3) ## 00000168 -/* 001E4 80870C94 46062200 */ add.s $f8, $f4, $f6 -/* 001E8 80870C98 1000001F */ beq $zero, $zero, .L80870D18 -/* 001EC 80870C9C E4E8016C */ swc1 $f8, 0x016C($a3) ## 0000016C -/* 001F0 80870CA0 C4EA000C */ lwc1 $f10, 0x000C($a3) ## 0000000C -.L80870CA4: -/* 001F4 80870CA4 A0E00168 */ sb $zero, 0x0168($a3) ## 00000168 -/* 001F8 80870CA8 1000001B */ beq $zero, $zero, .L80870D18 -/* 001FC 80870CAC E4EA016C */ swc1 $f10, 0x016C($a3) ## 0000016C -.L80870CB0: -/* 00200 80870CB0 54410011 */ bnel $v0, $at, .L80870CF8 -/* 00204 80870CB4 24010003 */ addiu $at, $zero, 0x0003 ## $at = 00000003 -/* 00208 80870CB8 90ED0169 */ lbu $t5, 0x0169($a3) ## 00000169 -/* 0020C 80870CBC 3C01442F */ lui $at, 0x442F ## $at = 442F0000 -/* 00210 80870CC0 506D0009 */ beql $v1, $t5, .L80870CE8 -/* 00214 80870CC4 C4E6000C */ lwc1 $f6, 0x000C($a3) ## 0000000C -/* 00218 80870CC8 C4F0000C */ lwc1 $f16, 0x000C($a3) ## 0000000C -/* 0021C 80870CCC 44819000 */ mtc1 $at, $f18 ## $f18 = 700.00 -/* 00220 80870CD0 240E0003 */ addiu $t6, $zero, 0x0003 ## $t6 = 00000003 -/* 00224 80870CD4 A0EE0168 */ sb $t6, 0x0168($a3) ## 00000168 -/* 00228 80870CD8 46128100 */ add.s $f4, $f16, $f18 -/* 0022C 80870CDC 1000000E */ beq $zero, $zero, .L80870D18 -/* 00230 80870CE0 E4E4016C */ swc1 $f4, 0x016C($a3) ## 0000016C -/* 00234 80870CE4 C4E6000C */ lwc1 $f6, 0x000C($a3) ## 0000000C -.L80870CE8: -/* 00238 80870CE8 A0E00168 */ sb $zero, 0x0168($a3) ## 00000168 -/* 0023C 80870CEC 1000000A */ beq $zero, $zero, .L80870D18 -/* 00240 80870CF0 E4E6016C */ swc1 $f6, 0x016C($a3) ## 0000016C -/* 00244 80870CF4 24010003 */ addiu $at, $zero, 0x0003 ## $at = 00000003 -.L80870CF8: -/* 00248 80870CF8 14410007 */ bne $v0, $at, .L80870D18 -/* 0024C 80870CFC 3C01430C */ lui $at, 0x430C ## $at = 430C0000 -/* 00250 80870D00 44815000 */ mtc1 $at, $f10 ## $f10 = 140.00 -/* 00254 80870D04 C4E8000C */ lwc1 $f8, 0x000C($a3) ## 0000000C -/* 00258 80870D08 240F0002 */ addiu $t7, $zero, 0x0002 ## $t7 = 00000002 -/* 0025C 80870D0C A0EF0168 */ sb $t7, 0x0168($a3) ## 00000168 -/* 00260 80870D10 460A4400 */ add.s $f16, $f8, $f10 -/* 00264 80870D14 E4F0016C */ swc1 $f16, 0x016C($a3) ## 0000016C -.L80870D18: -/* 00268 80870D18 ACF80164 */ sw $t8, 0x0164($a3) ## 00000164 -/* 0026C 80870D1C 8FBF001C */ lw $ra, 0x001C($sp) -.L80870D20: -/* 00270 80870D20 27BD0020 */ addiu $sp, $sp, 0x0020 ## $sp = 00000000 -/* 00274 80870D24 03E00008 */ jr $ra -/* 00278 80870D28 00000000 */ nop diff --git a/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/func_80870D2C.s b/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/func_80870D2C.s deleted file mode 100644 index be2925fdea..0000000000 --- a/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/func_80870D2C.s +++ /dev/null @@ -1,125 +0,0 @@ -glabel func_80870D2C -/* 0027C 80870D2C 27BDFFC0 */ addiu $sp, $sp, 0xFFC0 ## $sp = FFFFFFC0 -/* 00280 80870D30 AFBF002C */ sw $ra, 0x002C($sp) -/* 00284 80870D34 AFB10028 */ sw $s1, 0x0028($sp) -/* 00288 80870D38 AFB00024 */ sw $s0, 0x0024($sp) -/* 0028C 80870D3C C484000C */ lwc1 $f4, 0x000C($a0) ## 0000000C -/* 00290 80870D40 3C0E0001 */ lui $t6, 0x0001 ## $t6 = 00010000 -/* 00294 80870D44 01C57021 */ addu $t6, $t6, $a1 -/* 00298 80870D48 E7A40038 */ swc1 $f4, 0x0038($sp) -/* 0029C 80870D4C 8DCE1DE4 */ lw $t6, 0x1DE4($t6) ## 00011DE4 -/* 002A0 80870D50 00808025 */ or $s0, $a0, $zero ## $s0 = 00000000 -/* 002A4 80870D54 00A08825 */ or $s1, $a1, $zero ## $s1 = 00000000 -/* 002A8 80870D58 31CF0001 */ andi $t7, $t6, 0x0001 ## $t7 = 00000000 -/* 002AC 80870D5C 11E0002F */ beq $t7, $zero, .L80870E1C -/* 002B0 80870D60 3C0142DC */ lui $at, 0x42DC ## $at = 42DC0000 -/* 002B4 80870D64 3C014282 */ lui $at, 0x4282 ## $at = 42820000 -/* 002B8 80870D68 44814000 */ mtc1 $at, $f8 ## $f8 = 65.00 -/* 002BC 80870D6C C4860024 */ lwc1 $f6, 0x0024($a0) ## 00000024 -/* 002C0 80870D70 3C0142DC */ lui $at, 0x42DC ## $at = 42DC0000 -/* 002C4 80870D74 44816000 */ mtc1 $at, $f12 ## $f12 = 110.00 -/* 002C8 80870D78 46083280 */ add.s $f10, $f6, $f8 -/* 002CC 80870D7C 0C00CFC8 */ jal Math_Rand_CenteredFloat - -/* 002D0 80870D80 E7AA0034 */ swc1 $f10, 0x0034($sp) -/* 002D4 80870D84 C610002C */ lwc1 $f16, 0x002C($s0) ## 0000002C -/* 002D8 80870D88 24180014 */ addiu $t8, $zero, 0x0014 ## $t8 = 00000014 -/* 002DC 80870D8C 2419003C */ addiu $t9, $zero, 0x003C ## $t9 = 0000003C -/* 002E0 80870D90 46100480 */ add.s $f18, $f0, $f16 -/* 002E4 80870D94 24080001 */ addiu $t0, $zero, 0x0001 ## $t0 = 00000001 -/* 002E8 80870D98 AFA80018 */ sw $t0, 0x0018($sp) -/* 002EC 80870D9C AFB90014 */ sw $t9, 0x0014($sp) -/* 002F0 80870DA0 E7B2003C */ swc1 $f18, 0x003C($sp) -/* 002F4 80870DA4 AFB80010 */ sw $t8, 0x0010($sp) -/* 002F8 80870DA8 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000 -/* 002FC 80870DAC 27A50034 */ addiu $a1, $sp, 0x0034 ## $a1 = FFFFFFF4 -/* 00300 80870DB0 3C0640A0 */ lui $a2, 0x40A0 ## $a2 = 40A00000 -/* 00304 80870DB4 0C00CD20 */ jal func_80033480 -/* 00308 80870DB8 24070001 */ addiu $a3, $zero, 0x0001 ## $a3 = 00000001 -/* 0030C 80870DBC 3C014282 */ lui $at, 0x4282 ## $at = 42820000 -/* 00310 80870DC0 44813000 */ mtc1 $at, $f6 ## $f6 = 65.00 -/* 00314 80870DC4 C6040024 */ lwc1 $f4, 0x0024($s0) ## 00000024 -/* 00318 80870DC8 3C0142DC */ lui $at, 0x42DC ## $at = 42DC0000 -/* 0031C 80870DCC 44816000 */ mtc1 $at, $f12 ## $f12 = 110.00 -/* 00320 80870DD0 46062201 */ sub.s $f8, $f4, $f6 -/* 00324 80870DD4 0C00CFC8 */ jal Math_Rand_CenteredFloat - -/* 00328 80870DD8 E7A80034 */ swc1 $f8, 0x0034($sp) -/* 0032C 80870DDC C60A002C */ lwc1 $f10, 0x002C($s0) ## 0000002C -/* 00330 80870DE0 24090014 */ addiu $t1, $zero, 0x0014 ## $t1 = 00000014 -/* 00334 80870DE4 240A003C */ addiu $t2, $zero, 0x003C ## $t2 = 0000003C -/* 00338 80870DE8 460A0400 */ add.s $f16, $f0, $f10 -/* 0033C 80870DEC 240B0001 */ addiu $t3, $zero, 0x0001 ## $t3 = 00000001 -/* 00340 80870DF0 AFAB0018 */ sw $t3, 0x0018($sp) -/* 00344 80870DF4 AFAA0014 */ sw $t2, 0x0014($sp) -/* 00348 80870DF8 E7B0003C */ swc1 $f16, 0x003C($sp) -/* 0034C 80870DFC AFA90010 */ sw $t1, 0x0010($sp) -/* 00350 80870E00 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000 -/* 00354 80870E04 27A50034 */ addiu $a1, $sp, 0x0034 ## $a1 = FFFFFFF4 -/* 00358 80870E08 3C0640A0 */ lui $a2, 0x40A0 ## $a2 = 40A00000 -/* 0035C 80870E0C 0C00CD20 */ jal func_80033480 -/* 00360 80870E10 24070001 */ addiu $a3, $zero, 0x0001 ## $a3 = 00000001 -/* 00364 80870E14 1000002F */ beq $zero, $zero, .L80870ED4 -/* 00368 80870E18 92080169 */ lbu $t0, 0x0169($s0) ## 00000169 -.L80870E1C: -/* 0036C 80870E1C 44816000 */ mtc1 $at, $f12 ## $f12 = 0.00 -/* 00370 80870E20 0C00CFC8 */ jal Math_Rand_CenteredFloat - -/* 00374 80870E24 00000000 */ nop -/* 00378 80870E28 C6120024 */ lwc1 $f18, 0x0024($s0) ## 00000024 -/* 0037C 80870E2C 3C014282 */ lui $at, 0x4282 ## $at = 42820000 -/* 00380 80870E30 44814000 */ mtc1 $at, $f8 ## $f8 = 65.00 -/* 00384 80870E34 46120100 */ add.s $f4, $f0, $f18 -/* 00388 80870E38 240C0014 */ addiu $t4, $zero, 0x0014 ## $t4 = 00000014 -/* 0038C 80870E3C 240D003C */ addiu $t5, $zero, 0x003C ## $t5 = 0000003C -/* 00390 80870E40 240E0001 */ addiu $t6, $zero, 0x0001 ## $t6 = 00000001 -/* 00394 80870E44 E7A40034 */ swc1 $f4, 0x0034($sp) -/* 00398 80870E48 C606002C */ lwc1 $f6, 0x002C($s0) ## 0000002C -/* 0039C 80870E4C AFAE0018 */ sw $t6, 0x0018($sp) -/* 003A0 80870E50 AFAD0014 */ sw $t5, 0x0014($sp) -/* 003A4 80870E54 46083280 */ add.s $f10, $f6, $f8 -/* 003A8 80870E58 AFAC0010 */ sw $t4, 0x0010($sp) -/* 003AC 80870E5C 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000 -/* 003B0 80870E60 27A50034 */ addiu $a1, $sp, 0x0034 ## $a1 = FFFFFFF4 -/* 003B4 80870E64 E7AA003C */ swc1 $f10, 0x003C($sp) -/* 003B8 80870E68 3C0640A0 */ lui $a2, 0x40A0 ## $a2 = 40A00000 -/* 003BC 80870E6C 0C00CD20 */ jal func_80033480 -/* 003C0 80870E70 24070001 */ addiu $a3, $zero, 0x0001 ## $a3 = 00000001 -/* 003C4 80870E74 3C0142DC */ lui $at, 0x42DC ## $at = 42DC0000 -/* 003C8 80870E78 44816000 */ mtc1 $at, $f12 ## $f12 = 110.00 -/* 003CC 80870E7C 0C00CFC8 */ jal Math_Rand_CenteredFloat - -/* 003D0 80870E80 00000000 */ nop -/* 003D4 80870E84 C6100024 */ lwc1 $f16, 0x0024($s0) ## 00000024 -/* 003D8 80870E88 3C014282 */ lui $at, 0x4282 ## $at = 42820000 -/* 003DC 80870E8C 44813000 */ mtc1 $at, $f6 ## $f6 = 65.00 -/* 003E0 80870E90 46100480 */ add.s $f18, $f0, $f16 -/* 003E4 80870E94 240F0014 */ addiu $t7, $zero, 0x0014 ## $t7 = 00000014 -/* 003E8 80870E98 2418003C */ addiu $t8, $zero, 0x003C ## $t8 = 0000003C -/* 003EC 80870E9C 24190001 */ addiu $t9, $zero, 0x0001 ## $t9 = 00000001 -/* 003F0 80870EA0 E7B20034 */ swc1 $f18, 0x0034($sp) -/* 003F4 80870EA4 C604002C */ lwc1 $f4, 0x002C($s0) ## 0000002C -/* 003F8 80870EA8 AFB90018 */ sw $t9, 0x0018($sp) -/* 003FC 80870EAC AFB80014 */ sw $t8, 0x0014($sp) -/* 00400 80870EB0 46062201 */ sub.s $f8, $f4, $f6 -/* 00404 80870EB4 AFAF0010 */ sw $t7, 0x0010($sp) -/* 00408 80870EB8 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000 -/* 0040C 80870EBC 27A50034 */ addiu $a1, $sp, 0x0034 ## $a1 = FFFFFFF4 -/* 00410 80870EC0 E7A8003C */ swc1 $f8, 0x003C($sp) -/* 00414 80870EC4 3C0640A0 */ lui $a2, 0x40A0 ## $a2 = 40A00000 -/* 00418 80870EC8 0C00CD20 */ jal func_80033480 -/* 0041C 80870ECC 24070001 */ addiu $a3, $zero, 0x0001 ## $a3 = 00000001 -/* 00420 80870ED0 92080169 */ lbu $t0, 0x0169($s0) ## 00000169 -.L80870ED4: -/* 00424 80870ED4 24010005 */ addiu $at, $zero, 0x0005 ## $at = 00000005 -/* 00428 80870ED8 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -/* 0042C 80870EDC 55010004 */ bnel $t0, $at, .L80870EF0 -/* 00430 80870EE0 8FBF002C */ lw $ra, 0x002C($sp) -/* 00434 80870EE4 0C00BE5D */ jal func_8002F974 -/* 00438 80870EE8 24052024 */ addiu $a1, $zero, 0x2024 ## $a1 = 00002024 -/* 0043C 80870EEC 8FBF002C */ lw $ra, 0x002C($sp) -.L80870EF0: -/* 00440 80870EF0 8FB00024 */ lw $s0, 0x0024($sp) -/* 00444 80870EF4 8FB10028 */ lw $s1, 0x0028($sp) -/* 00448 80870EF8 03E00008 */ jr $ra -/* 0044C 80870EFC 27BD0040 */ addiu $sp, $sp, 0x0040 ## $sp = 00000000 diff --git a/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/func_80870F00.s b/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/func_80870F00.s deleted file mode 100644 index a6301bfd9c..0000000000 --- a/asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/func_80870F00.s +++ /dev/null @@ -1,74 +0,0 @@ -glabel func_80870F00 -/* 00450 80870F00 27BDFFD8 */ addiu $sp, $sp, 0xFFD8 ## $sp = FFFFFFD8 -/* 00454 80870F04 AFBF0024 */ sw $ra, 0x0024($sp) -/* 00458 80870F08 AFB00020 */ sw $s0, 0x0020($sp) -/* 0045C 80870F0C AFA5002C */ sw $a1, 0x002C($sp) -/* 00460 80870F10 908E0169 */ lbu $t6, 0x0169($a0) ## 00000169 -/* 00464 80870F14 24010001 */ addiu $at, $zero, 0x0001 ## $at = 00000001 -/* 00468 80870F18 00808025 */ or $s0, $a0, $zero ## $s0 = 00000000 -/* 0046C 80870F1C 55C1001E */ bnel $t6, $at, .L80870F98 -/* 00470 80870F20 92080169 */ lbu $t0, 0x0169($s0) ## 00000169 -/* 00474 80870F24 8485001C */ lh $a1, 0x001C($a0) ## 0000001C -/* 00478 80870F28 28A10040 */ slti $at, $a1, 0x0040 -/* 0047C 80870F2C 5020001A */ beql $at, $zero, .L80870F98 -/* 00480 80870F30 92080169 */ lbu $t0, 0x0169($s0) ## 00000169 -/* 00484 80870F34 0C00B2D0 */ jal Flags_GetSwitch - -/* 00488 80870F38 8FA4002C */ lw $a0, 0x002C($sp) -/* 0048C 80870F3C 10400015 */ beq $v0, $zero, .L80870F94 -/* 00490 80870F40 240F0005 */ addiu $t7, $zero, 0x0005 ## $t7 = 00000005 -/* 00494 80870F44 3C01430C */ lui $at, 0x430C ## $at = 430C0000 -/* 00498 80870F48 44813000 */ mtc1 $at, $f6 ## $f6 = 140.00 -/* 0049C 80870F4C C604000C */ lwc1 $f4, 0x000C($s0) ## 0000000C -/* 004A0 80870F50 3C198087 */ lui $t9, %hi(func_80870B88) ## $t9 = 80870000 -/* 004A4 80870F54 24180001 */ addiu $t8, $zero, 0x0001 ## $t8 = 00000001 -/* 004A8 80870F58 46062200 */ add.s $f8, $f4, $f6 -/* 004AC 80870F5C 27390B88 */ addiu $t9, $t9, %lo(func_80870B88) ## $t9 = 80870B88 -/* 004B0 80870F60 A20F0169 */ sb $t7, 0x0169($s0) ## 00000169 -/* 004B4 80870F64 A2180168 */ sb $t8, 0x0168($s0) ## 00000168 -/* 004B8 80870F68 E6080028 */ swc1 $f8, 0x0028($s0) ## 00000028 -/* 004BC 80870F6C A600016A */ sh $zero, 0x016A($s0) ## 0000016A -/* 004C0 80870F70 AE190164 */ sw $t9, 0x0164($s0) ## 00000164 -/* 004C4 80870F74 AFA00010 */ sw $zero, 0x0010($sp) -/* 004C8 80870F78 8FA4002C */ lw $a0, 0x002C($sp) -/* 004CC 80870F7C 24050BF4 */ addiu $a1, $zero, 0x0BF4 ## $a1 = 00000BF4 -/* 004D0 80870F80 2406FF9D */ addiu $a2, $zero, 0xFF9D ## $a2 = FFFFFF9D -/* 004D4 80870F84 0C02003E */ jal func_800800F8 -/* 004D8 80870F88 02003825 */ or $a3, $s0, $zero ## $a3 = 00000000 -/* 004DC 80870F8C 10000016 */ beq $zero, $zero, .L80870FE8 -/* 004E0 80870F90 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -.L80870F94: -/* 004E4 80870F94 92080169 */ lbu $t0, 0x0169($s0) ## 00000169 -.L80870F98: -/* 004E8 80870F98 26040028 */ addiu $a0, $s0, 0x0028 ## $a0 = 00000028 -/* 004EC 80870F9C 8E05016C */ lw $a1, 0x016C($s0) ## 0000016C -/* 004F0 80870FA0 44885000 */ mtc1 $t0, $f10 ## $f10 = 0.00 -/* 004F4 80870FA4 3C014F80 */ lui $at, 0x4F80 ## $at = 4F800000 -/* 004F8 80870FA8 05010004 */ bgez $t0, .L80870FBC -/* 004FC 80870FAC 468052A0 */ cvt.s.w $f10, $f10 -/* 00500 80870FB0 44818000 */ mtc1 $at, $f16 ## $f16 = 4294967296.00 -/* 00504 80870FB4 00000000 */ nop -/* 00508 80870FB8 46105280 */ add.s $f10, $f10, $f16 -.L80870FBC: -/* 0050C 80870FBC 44065000 */ mfc1 $a2, $f10 -/* 00510 80870FC0 0C01DE80 */ jal Math_ApproxF - -/* 00514 80870FC4 00000000 */ nop -/* 00518 80870FC8 10400006 */ beq $v0, $zero, .L80870FE4 -/* 0051C 80870FCC 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -/* 00520 80870FD0 0C00BE0A */ jal Audio_PlayActorSound2 - -/* 00524 80870FD4 240528F1 */ addiu $a1, $zero, 0x28F1 ## $a1 = 000028F1 -/* 00528 80870FD8 3C098087 */ lui $t1, %hi(func_80870B88) ## $t1 = 80870000 -/* 0052C 80870FDC 25290B88 */ addiu $t1, $t1, %lo(func_80870B88) ## $t1 = 80870B88 -/* 00530 80870FE0 AE090164 */ sw $t1, 0x0164($s0) ## 00000164 -.L80870FE4: -/* 00534 80870FE4 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000 -.L80870FE8: -/* 00538 80870FE8 0C21C34B */ jal func_80870D2C -/* 0053C 80870FEC 8FA5002C */ lw $a1, 0x002C($sp) -/* 00540 80870FF0 8FBF0024 */ lw $ra, 0x0024($sp) -/* 00544 80870FF4 8FB00020 */ lw $s0, 0x0020($sp) -/* 00548 80870FF8 27BD0028 */ addiu $sp, $sp, 0x0028 ## $sp = 00000000 -/* 0054C 80870FFC 03E00008 */ jr $ra -/* 00550 80871000 00000000 */ nop diff --git a/data/overlays/actors/z_bg_ddan_jd.data.s b/data/overlays/actors/z_bg_ddan_jd.data.s deleted file mode 100644 index f2367896cc..0000000000 --- a/data/overlays/actors/z_bg_ddan_jd.data.s +++ /dev/null @@ -1,20 +0,0 @@ -.include "macro.inc" - - # assembler directives - .set noat # allow manual use of $at - .set noreorder # don't insert nops after branches - .set gp=64 # allow use of 64-bit general purpose registers - -.section .data - -.balign 16 - -glabel Bg_Ddan_Jd_InitVars - .word 0x00580100, 0x00000030, 0x002B0000, 0x00000170 -.word BgDdanJd_Init -.word BgDdanJd_Destroy -.word BgDdanJd_Update -.word BgDdanJd_Draw -glabel D_80871080 - .word 0x48500064, 0x00000000, 0x00000000, 0x00000000 - diff --git a/data/overlays/actors/z_bg_ddan_jd.reloc.s b/data/overlays/actors/z_bg_ddan_jd.reloc.s deleted file mode 100644 index 22bc0ce77f..0000000000 --- a/data/overlays/actors/z_bg_ddan_jd.reloc.s +++ /dev/null @@ -1,13 +0,0 @@ -.include "macro.inc" - - # assembler directives - .set noat # allow manual use of $at - .set noreorder # don't insert nops after branches - .set gp=64 # allow use of 64-bit general purpose registers - -.section .rodata - -.balign 16 - -glabel D_80871090 - .incbin "baserom/ovl_Bg_Ddan_Jd", 0x5E0, 0x00000060 diff --git a/spec b/spec index 49ee68c9ed..b6993f310a 100644 --- a/spec +++ b/spec @@ -667,8 +667,7 @@ endseg beginseg name "ovl_Bg_Ddan_Jd" include "build/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.o" - include "build/data/overlays/actors/z_bg_ddan_jd.data.o" - include "build/data/overlays/actors/z_bg_ddan_jd.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Ddan_Jd/ovl_Bg_Ddan_Jd_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.c b/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.c index 05197584ce..c62f0b6a3f 100644 --- a/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.c +++ b/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.c @@ -15,11 +15,12 @@ void BgDdanJd_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgDdanJd_Update(Actor* thisx, GlobalContext* globalCtx); void BgDdanJd_Draw(Actor* thisx, GlobalContext* globalCtx); -void func_80870B88(BgDdanJd* this, GlobalContext* globalCtx); -void func_80870D2C(BgDdanJd* this, GlobalContext* globalCtx); -void func_80870F00(BgDdanJd* this, GlobalContext* globalCtx); +void BgDdanJd_Idle(BgDdanJd* this, GlobalContext* globalCtx); +void BgDdanJd_Move(BgDdanJd* this, GlobalContext* globalCtx); + +extern Gfx D_060037B8[]; +extern ColHeader D_06003CE0; -/* const ActorInit Bg_Ddan_Jd_InitVars = { ACTOR_BG_DDAN_JD, ACTORTYPE_BG, @@ -31,17 +32,152 @@ const ActorInit Bg_Ddan_Jd_InitVars = { (ActorFunc)BgDdanJd_Update, (ActorFunc)BgDdanJd_Draw, }; -*/ -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Init.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Destroy.s") +static InitChainEntry sInitChain[] = { + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/func_80870B88.s") +typedef enum { + STATE_GO_BOTTOM, + STATE_GO_MIDDLE_FROM_BOTTOM, + STATE_GO_MIDDLE_FROM_TOP, + STATE_GO_TOP, +} BgDdanJdState; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/func_80870D2C.s") +#define MOVE_HEIGHT_MIDDLE 140.0f +#define MOVE_HEIGHT_TOP 700.0f -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/func_80870F00.s") +#define IDLE_FRAMES 100 -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Update.s") +// Since ySpeed is used to determine if the platform should rise to the top of the dungeon, these must be assigned +// different values in order for the shortcut to work correctly +#define DEFAULT_Y_SPEED 1 +#define SHORTCUT_Y_SPEED 5 -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Ddan_Jd/BgDdanJd_Draw.s") +void BgDdanJd_Init(Actor* thisx, GlobalContext* globalCtx) { + BgDdanJd* this = THIS; + s32 pad; + ColHeader* colHeader = NULL; + + Actor_ProcessInitChain(thisx, sInitChain); + DynaPolyInfo_SetActorMove(thisx, DPM_PLAYER); + DynaPolyInfo_Alloc(&D_06003CE0, &colHeader); + this->dyna.dynaPolyId = DynaPolyInfo_RegisterActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + this->idleTimer = IDLE_FRAMES; + this->state = STATE_GO_BOTTOM; + + // Missing check for actor.params < 0x40. This will cause inconsistent behavior if params >= 0x40 and the bound + // switch state is turned on while in the same room, as the shortcut behavior won't become enabled until the actor + // is reloaded. + if (Flags_GetSwitch(globalCtx, this->dyna.actor.params)) { + this->ySpeed = SHORTCUT_Y_SPEED; + } else { + this->ySpeed = DEFAULT_Y_SPEED; + } + this->actionFunc = BgDdanJd_Idle; +} + +void BgDdanJd_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgDdanJd* this = THIS; + + DynaPolyInfo_Free(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId); +} + +void BgDdanJd_Idle(BgDdanJd* this, GlobalContext* globalCtx) { + if (this->idleTimer != 0) { + this->idleTimer--; + } + + // if this is the platform that rises all the way to the top, and the switch state has just changed to on + if (this->ySpeed == DEFAULT_Y_SPEED && this->dyna.actor.params < 0x40 && + Flags_GetSwitch(globalCtx, this->dyna.actor.params)) { + this->ySpeed = SHORTCUT_Y_SPEED; + this->state = STATE_GO_MIDDLE_FROM_BOTTOM; + this->idleTimer = 0; + this->dyna.actor.posRot.pos.y = this->dyna.actor.initPosRot.pos.y + MOVE_HEIGHT_MIDDLE; + func_800800F8(globalCtx, 0xBF4, -0x63, &this->dyna.actor, 0); + } + if (this->idleTimer == 0) { + this->idleTimer = IDLE_FRAMES; + if (this->state == STATE_GO_BOTTOM) { + this->state = STATE_GO_MIDDLE_FROM_BOTTOM; + this->targetY = this->dyna.actor.initPosRot.pos.y + MOVE_HEIGHT_MIDDLE; + } else if (this->state == STATE_GO_MIDDLE_FROM_BOTTOM) { + // If the platform has been activated as a shortcut + if (this->ySpeed != DEFAULT_Y_SPEED) { + this->state = STATE_GO_TOP; + this->targetY = this->dyna.actor.initPosRot.pos.y + MOVE_HEIGHT_TOP; + } else { + this->state = STATE_GO_BOTTOM; + this->targetY = this->dyna.actor.initPosRot.pos.y; + } + } else if (this->state == STATE_GO_MIDDLE_FROM_TOP) { + // If the platform has been activated as a shortcut + if (this->ySpeed != DEFAULT_Y_SPEED) { + this->state = STATE_GO_TOP; + this->targetY = this->dyna.actor.initPosRot.pos.y + MOVE_HEIGHT_TOP; + } else { + this->state = STATE_GO_BOTTOM; + this->targetY = this->dyna.actor.initPosRot.pos.y; + } + } else if (this->state == STATE_GO_TOP) { + this->state = STATE_GO_MIDDLE_FROM_TOP; + this->targetY = this->dyna.actor.initPosRot.pos.y + MOVE_HEIGHT_MIDDLE; + } + this->actionFunc = BgDdanJd_Move; + } +} + +// Handles dust particles and sfx when moving +void BgDdanJd_MoveEffects(BgDdanJd* this, GlobalContext* globalCtx) { + Vec3f dustPos; + + // Generate random dust particles at the platform's base. + dustPos.y = this->dyna.actor.initPosRot.pos.y; + if (globalCtx->gameplayFrames & 1) { + dustPos.x = this->dyna.actor.posRot.pos.x + 65.0f; + dustPos.z = Math_Rand_CenteredFloat(110.0f) + this->dyna.actor.posRot.pos.z; + func_80033480(globalCtx, &dustPos, 5.0f, 1, 20, 60, 1); + dustPos.x = this->dyna.actor.posRot.pos.x - 65.0f; + dustPos.z = Math_Rand_CenteredFloat(110.0f) + this->dyna.actor.posRot.pos.z; + func_80033480(globalCtx, &dustPos, 5.0f, 1, 20, 60, 1); + } else { + dustPos.x = Math_Rand_CenteredFloat(110.0f) + this->dyna.actor.posRot.pos.x; + dustPos.z = this->dyna.actor.posRot.pos.z + 65.0f; + func_80033480(globalCtx, &dustPos, 5.0f, 1, 20, 60, 1); + dustPos.x = Math_Rand_CenteredFloat(110.0f) + this->dyna.actor.posRot.pos.x; + dustPos.z = this->dyna.actor.posRot.pos.z - 65.0f; + func_80033480(globalCtx, &dustPos, 5.0f, 1, 20, 60, 1); + } + if (this->ySpeed == SHORTCUT_Y_SPEED) { + func_8002F974(&this->dyna.actor, NA_SE_EV_ELEVATOR_MOVE - SFX_FLAG); + } +} + +// Implements the platform's movement state +void BgDdanJd_Move(BgDdanJd* this, GlobalContext* globalCtx) { + // if this is the platform that rises all the way to the top, and the switch state has just changed to on + if (this->ySpeed == DEFAULT_Y_SPEED && this->dyna.actor.params < 0x40 && + Flags_GetSwitch(globalCtx, this->dyna.actor.params)) { + this->ySpeed = SHORTCUT_Y_SPEED; + this->state = STATE_GO_MIDDLE_FROM_BOTTOM; + this->dyna.actor.posRot.pos.y = this->dyna.actor.initPosRot.pos.y + MOVE_HEIGHT_MIDDLE; + this->idleTimer = 0; + this->actionFunc = BgDdanJd_Idle; + func_800800F8(globalCtx, 0xBF4, -0x63, &this->dyna.actor, 0); + } else if (Math_ApproxF(&this->dyna.actor.posRot.pos.y, this->targetY, this->ySpeed)) { + Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_PILLAR_MOVE_STOP); + this->actionFunc = BgDdanJd_Idle; + } + BgDdanJd_MoveEffects(this, globalCtx); +} + +void BgDdanJd_Update(Actor* thisx, GlobalContext* globalCtx) { + BgDdanJd* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void BgDdanJd_Draw(Actor* thisx, GlobalContext* globalCtx) { + Gfx_DrawDListOpa(globalCtx, D_060037B8); +} diff --git a/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.h b/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.h index 4a90057055..4da8716eaa 100644 --- a/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.h +++ b/src/overlays/actors/ovl_Bg_Ddan_Jd/z_bg_ddan_jd.h @@ -11,7 +11,10 @@ typedef void (*BgDdanJdActionFunc)(struct BgDdanJd*, GlobalContext*); typedef struct BgDdanJd { /* 0x0000 */ DynaPolyActor dyna; /* 0x0164 */ BgDdanJdActionFunc actionFunc; - /* 0x0168 */ char unk_168[0x8]; + /* 0x0168 */ u8 state; + /* 0x0169 */ u8 ySpeed; // also differentiates between normal and shortcut platform behavior + /* 0x016A */ s16 idleTimer; + /* 0x016C */ f32 targetY; } BgDdanJd; // size = 0x0170 extern const ActorInit Bg_Ddan_Jd_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index fc18e55e52..4235bef33d 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1135,3 +1135,7 @@ D_06001E50 = 0x06001E50; // z_bg_mori_hashira4 D_06001AF8 = 0x06001AF8; D_060089E0 = 0x060089E0; + +// z_bg_ddan_jd +D_06003CE0 = 0x06003CE0; +D_060037B8 = 0x060037B8;