diff --git a/asm/non_matchings/code_802B0210/func_802B0E14.s b/asm/non_matchings/code_802B0210/func_802B0E14.s deleted file mode 100644 index 521bf01c7..000000000 --- a/asm/non_matchings/code_802B0210/func_802B0E14.s +++ /dev/null @@ -1,42 +0,0 @@ -glabel func_802B0E14 -/* 11A424 802B0E14 AFA40000 */ sw $a0, ($sp) -/* 11A428 802B0E18 00047400 */ sll $t6, $a0, 0x10 -/* 11A42C 802B0E1C 000E2403 */ sra $a0, $t6, 0x10 -/* 11A430 802B0E20 04810003 */ bgez $a0, .L802B0E30 -/* 11A434 802B0E24 0004C0C0 */ sll $t8, $a0, 3 -/* 11A438 802B0E28 03E00008 */ jr $ra -/* 11A43C 802B0E2C 00001025 */ move $v0, $zero - -.L802B0E30: -/* 11A440 802B0E30 0304C023 */ subu $t8, $t8, $a0 -/* 11A444 802B0E34 3C198016 */ lui $t9, %hi(D_8015F9B8) # $t9, 0x8016 -/* 11A448 802B0E38 2739F9B8 */ addiu $t9, %lo(D_8015F9B8) # addiu $t9, $t9, -0x648 -/* 11A44C 802B0E3C 0018C100 */ sll $t8, $t8, 4 -/* 11A450 802B0E40 03191021 */ addu $v0, $t8, $t9 -/* 11A454 802B0E44 84480000 */ lh $t0, ($v0) -/* 11A458 802B0E48 24010007 */ li $at, 7 -/* 11A45C 802B0E4C 5501000A */ bnel $t0, $at, .L802B0E78 -/* 11A460 802B0E50 844A0006 */ lh $t2, 6($v0) -/* 11A464 802B0E54 84490006 */ lh $t1, 6($v0) -/* 11A468 802B0E58 24010004 */ li $at, 4 -/* 11A46C 802B0E5C 15210003 */ bne $t1, $at, .L802B0E6C -/* 11A470 802B0E60 00000000 */ nop -/* 11A474 802B0E64 03E00008 */ jr $ra -/* 11A478 802B0E68 24020001 */ li $v0, 1 - -.L802B0E6C: -/* 11A47C 802B0E6C 03E00008 */ jr $ra -/* 11A480 802B0E70 00001025 */ move $v0, $zero - -/* 11A484 802B0E74 844A0006 */ lh $t2, 6($v0) -.L802B0E78: -/* 11A488 802B0E78 24010006 */ li $at, 6 -/* 11A48C 802B0E7C 00001025 */ move $v0, $zero -/* 11A490 802B0E80 15410003 */ bne $t2, $at, .L802B0E90 -/* 11A494 802B0E84 00000000 */ nop -/* 11A498 802B0E88 03E00008 */ jr $ra -/* 11A49C 802B0E8C 24020001 */ li $v0, 1 - -.L802B0E90: -/* 11A4A0 802B0E90 03E00008 */ jr $ra -/* 11A4A4 802B0E94 00000000 */ nop diff --git a/include/actor_types.h b/include/actor_types.h index 2624689ce..829498b3f 100644 --- a/include/actor_types.h +++ b/include/actor_types.h @@ -28,6 +28,40 @@ struct piranha_plant { /* 0x2A */ s16 unk2A; }; +struct triple_shell_parent { + /* 0x00 */ s16 type; + /* 0x02 */ s16 unk_02; + /* 0x04 */ s16 shellsAvailable; + /* 0x06 */ s16 state; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ s16 rotVelocity; + /* 0x12 */ s16 rotAngle; + /* 0x14 */ s16 playerId; // Id of the player that "owns" the shells + /* 0x16 */ s16 unk_16; + /* 0x18 */ Vec3f unk_18; + /* 0x24 */ Vec3f shellIndices; // Indices in D_8015F9B8 for the shells "owned" by this parent + /* 0x30 */ UnkActorInner unk30; +}; // size = 0x70 + +struct shell_actor { + /* 0x00 */ s16 type; + /* 0x02 */ s16 unk_02; + // Index in D_8015F9B8 for the parent actor of this shell + // Seems to pull double duty as a timer + /* 0x04 */ s16 parentIndex; + /* 0x06 */ s16 state; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ s16 rotVelocity; // Change in rotAngle on a per-update basis + /* 0x12 */ s16 rotAngle; // Angle of rotation around player (or parent?), not the rotation of the shell itself + /* 0x14 */ s16 playerId; // Id of the player that "owns" the shell + /* 0x16 */ s16 unk_16; + /* 0x18 */ Vec3f pos; + /* 0x24 */ Vec3f velocity; // All 0 until the shell is fired + /* 0x30 */ UnkActorInner unk30; +}; // size = 0x70 + struct Actor { /* 0x00 */ s16 unk0; // 0xC, 0xD, or 0x2B #ifdef AVOID_UB diff --git a/src/code_802B0210.c b/src/code_802B0210.c index 5b7721ffd..f7cf6cbaa 100644 --- a/src/code_802B0210.c +++ b/src/code_802B0210.c @@ -499,263 +499,254 @@ void update_obj_banana_bunch(void *arg0) { GLOBAL_ASM("asm/non_matchings/code_802B0210/update_obj_banana_bunch.s") #endif -#ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -extern ? D_8015F9B8; - -? func_802B0E14(s16 arg0) { - void *temp_v0; - +s32 func_802B0E14(s16 arg0) { + struct shell_actor *temp; if (arg0 < 0) { return 0; } - temp_v0 = (arg0 * 0x70) + &D_8015F9B8; - if (temp_v0->unk0 == 7) { - if (temp_v0->unk6 == 4) { + temp = (struct shell_actor*) &D_8015F9B8[arg0]; + if (temp->type == 7) { + if (temp->state == 4) { return 1; } return 0; } - if (temp_v0->unk6 == 6) { + if (temp->state == 6) { return 1; } return 0; } -#else -GLOBAL_ASM("asm/non_matchings/code_802B0210/func_802B0E14.s") -#endif #ifdef MIPS_TO_C -//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 +//generated by m2c commit 685418adfeb3794409e47b45ac5cab60b17d23fd ? func_8000ED80(s32); /* extern */ ? func_8000EDC8(s32); /* extern */ ? func_800C9060(u8, ?); /* extern */ ? func_800C90F4(u8, s32); /* extern */ -? func_8029E854(void *); /* extern */ -s32 func_802B19EC(void *, Player *, s16, ?); /* extern */ +? func_8029E854(struct triple_shell_parent *); /* extern */ +s32 func_802B0E14(s16, s16); /* extern */ +s32 func_802B19EC(struct triple_shell_parent *, Player *, s16, ?); /* extern */ ? func_802B64C4(f32 *, s16); /* extern */ -extern ? D_8015F9B8; -void update_obj_triple_shell(void *arg0, s16 arg1) { +void update_obj_triple_shell(struct triple_shell_parent *actor, s16 arg1) { s16 sp4E; - void *sp44; + struct shell_actor *sp44; f32 sp40; f32 sp3C; f32 sp38; s16 sp32; - void *sp28; + Player *sp28; + Player *temp_v1_3; + Player *temp_v1_5; + Player *temp_v1_7; f32 *temp_a0; f32 *temp_a0_2; f32 temp_f0; f32 temp_f0_2; f32 temp_f0_3; s16 temp_t0; - s16 temp_t7; s16 temp_t8; s16 temp_v0; s16 temp_v1_2; - s16 temp_v1_3; s16 temp_v1_4; + s16 temp_v1_6; s32 temp_v1; + struct Controller *temp_v0_5; + struct shell_actor *temp_v0_2; + struct shell_actor *temp_v0_3; + struct shell_actor *temp_v0_4; + struct shell_actor *temp_v0_6; + struct shell_actor *temp_v0_7; + struct shell_actor *temp_v0_8; u16 temp_t9; - void *temp_v0_2; - void *temp_v0_3; - void *temp_v0_4; - void *temp_v0_5; - void *temp_v0_6; - void *temp_v0_7; s16 phi_v1; s16 phi_v1_2; s16 phi_v1_3; - temp_v0 = arg0->unk10; - temp_t9 = arg0->unk6; - temp_t8 = arg0->unk12 + temp_v0; - temp_t0 = arg0->unk14; - arg0->unk12 = temp_t8; + temp_v0 = actor->rotVelocity; + temp_t9 = (u16) actor->state; + temp_t8 = actor->rotAngle + temp_v0; + temp_t0 = actor->playerId; + actor->rotAngle = temp_t8; temp_v1 = temp_t8 & 0xFFFF; switch (temp_t9) { case 0: sp4E = temp_t0; - if (func_802B19EC(arg0, &gPlayers[temp_t0], arg1, 0) != -1) { + if (func_802B19EC(actor, &gPlayers[temp_t0], arg1, 0) != -1) { func_800C9060(temp_t0 & 0xFF, 0x19008012); - arg0->unk4 = arg0->unk4 + 1; + actor->shellsAvailable += 1; } - arg0->unk6 = 1; + actor->state = 1; return; case 1: if (temp_v0 > 0) { if (temp_v1 >= 0xD556) { sp4E = temp_t0; - if (func_802B19EC(arg0, &gPlayers[temp_t0], arg1, 1) != -1) { + if (func_802B19EC(actor, &gPlayers[temp_t0], arg1, 1) != -1) { func_800C9060(temp_t0 & 0xFF, 0x19008012); - arg0->unk4 = arg0->unk4 + 1; + actor->shellsAvailable += 1; } - arg0->unk6 = 2; + actor->state = 2; return; } - /* Duplicate return node #61. Try simplifying control flow for better match */ - return; - } - if (temp_v1 < 0x2AAA) { - sp4E = temp_t0; - if (func_802B19EC(arg0, &gPlayers[temp_t0], arg1, 1) != -1) { - func_800C9060(temp_t0 & 0xFF, 0x19008012); - arg0->unk4 = arg0->unk4 + 1; + } else { + if (temp_v1 < 0x2AAA) { + sp4E = temp_t0; + if (func_802B19EC(actor, &gPlayers[temp_t0], arg1, 1) != -1) { + func_800C9060(temp_t0 & 0xFF, 0x19008012); + actor->shellsAvailable += 1; + } + actor->state = 2; + return; } - arg0->unk6 = 2; + default: return; } - default: - return; + break; case 2: if (temp_v0 > 0) { if ((temp_v1 >= 0x2AAB) && (temp_v1 < 0x31C7)) { sp4E = temp_t0; - if (func_802B19EC(arg0, &gPlayers[temp_t0], arg1, 2) != -1) { + if (func_802B19EC(actor, &gPlayers[temp_t0], arg1, 2) != -1) { func_800C9060(temp_t0 & 0xFF, 0x19008012); - arg0->unk4 = arg0->unk4 + 1; + actor->shellsAvailable += 1; } - arg0->unk6 = 3; + actor->state = 3; return; } - /* Duplicate return node #61. Try simplifying control flow for better match */ - return; - } - if ((temp_v1 < 0xD555) && (temp_v1 >= 0xCE39)) { + } else if ((temp_v1 < 0xD555) && (temp_v1 >= 0xCE39)) { sp4E = temp_t0; - if (func_802B19EC(arg0, &gPlayers[temp_t0], arg1, 2) != -1) { + if (func_802B19EC(actor, &gPlayers[temp_t0], arg1, 2) != -1) { func_800C9060(temp_t0 & 0xFF, 0x19008012); - arg0->unk4 = arg0->unk4 + 1; + actor->shellsAvailable += 1; } - arg0->unk6 = 3; + actor->state = 3; return; } - /* Duplicate return node #61. Try simplifying control flow for better match */ - return; + break; case 3: - arg0->unk6 = 4; - temp_v0_2 = &D_8015F9B8 + (arg0->unk24 * 0x70); - temp_v0_2->unk2 = temp_v0_2->unk2 | 0x4000; - temp_v0_3 = &D_8015F9B8 + (arg0->unk28 * 0x70); - temp_v0_3->unk2 = temp_v0_3->unk2 | 0x4000; - temp_v0_4 = &D_8015F9B8 + (arg0->unk2C * 0x70); - temp_v0_4->unk2 = temp_v0_4->unk2 | 0x4000; + actor->state = 4; + temp_v0_2 = &D_8015F9B8[(s16) (s32) actor->shellIndices[0]]; + temp_v0_2->unk_02 |= 0x4000; + temp_v0_3 = &D_8015F9B8[(s16) (s32) actor->shellIndices[1]]; + temp_v0_3->unk_02 |= 0x4000; + temp_v0_4 = &D_8015F9B8[(s16) (s32) actor->shellIndices[2]]; + temp_v0_4->unk_02 |= 0x4000; return; case 4: sp4E = temp_t0; sp32 = 0; phi_v1 = sp32; - if (func_802B0E14(arg0->unk24, arg1) == 1) { + if (func_802B0E14((s16) (s32) actor->shellIndices[0], arg1) == 1) { phi_v1 = 1; } else { - arg0->unk24 = -1.0f; + actor->shellIndices[0] = -1.0f; } sp4E = temp_t0; sp32 = phi_v1; phi_v1_2 = phi_v1; - if (func_802B0E14(arg0->unk28, MIPS2C_ERROR(Read from unset register $a1)) == 1) { - phi_v1_2 = phi_v1 + 1; + if (func_802B0E14((s16) (s32) actor->shellIndices[1]) == 1) { + phi_v1_2 = (s16) (phi_v1 + 1); } else { - arg0->unk28 = -1.0f; + actor->shellIndices[1] = -1.0f; } sp4E = temp_t0; sp32 = phi_v1_2; phi_v1_3 = phi_v1_2; - if (func_802B0E14(arg0->unk2C, MIPS2C_ERROR(Read from unset register $a1)) == 1) { - phi_v1_3 = phi_v1_2 + 1; + if (func_802B0E14((s16) (s32) actor->shellIndices[2]) == 1) { + phi_v1_3 = (s16) (phi_v1_2 + 1); } else { - arg0->unk2C = -1.0f; + actor->shellIndices[2] = -1.0f; } if (phi_v1_3 == 0) { - func_8029E854(arg0); + func_8029E854(actor); return; } - temp_t7 = arg0->unk14; - if ((gControllers[temp_t7].buttonPressed & 0x2000) != 0) { - arg0->unk8 = arg0->unk8 + 1.0f; - gControllers[temp_t7].buttonPressed &= 0xDFFF; + temp_v0_5 = &gControllers[actor->playerId]; + if ((temp_v0_5->buttonPressed & 0x2000) != 0) { + actor->unk_08 += 1.0f; + temp_v0_5->buttonPressed &= 0xDFFF; } - if (arg0->unk8 > 0.0f) { - temp_f0 = arg0->unk24; - if ((temp_f0 > 0.0f) && ((temp_v0_5 = &D_8015F9B8 + (temp_f0 * 0x70), temp_v1_2 = temp_v0_5->unk12, temp_a0 = &sp38, ((temp_v1_2 < 0x38E) != 0)) || (temp_v1_2 >= -0x38D))) { + if (actor->unk_08 > 0.0f) { + temp_f0 = actor->shellIndices[0]; + if ((temp_f0 > 0.0f) && ((temp_v0_6 = &D_8015F9B8[(s16) (s32) temp_f0], temp_v1_2 = temp_v0_6->rotAngle, temp_a0 = &sp38, ((temp_v1_2 < 0x38E) != 0)) || (temp_v1_2 >= -0x38D))) { + temp_v1_3 = &gPlayers[temp_t0]; sp38 = 0.0f; sp3C = 0.0f; sp40 = 8.0f; - sp28 = &gPlayers[temp_t0]; - sp44 = temp_v0_5; - func_802B64C4(temp_a0, gPlayers[temp_t0].unk_02E + gPlayers[temp_t0].unk_0C0); - temp_v0_5->unk24 = sp38; - temp_v0_5->unk28 = sp3C; - temp_v0_5->unk6 = 2; - temp_v0_5->unk4 = 0x1E; - temp_v0_5->unk2C = sp40; - func_800C9060(arg0->unk15, 0x19008004); - func_800C90F4(arg0->unk15, (gPlayers[temp_t0].characterId * 0x10) + 0x29008000); - if (arg0->unk0 == 0x16) { - func_8000ED80(arg0->unk24); - } else { - func_8000EDC8(arg0->unk24); - } - arg0->unk24 = -1.0f; - arg0->unk4 = arg0->unk4 - 1; - arg0->unk8 = arg0->unk8 - 1.0f; - return; - } - temp_f0_2 = arg0->unk28; - if ((temp_f0_2 > 0.0f) && ((temp_v0_6 = &D_8015F9B8 + (temp_f0_2 * 0x70), temp_v1_3 = temp_v0_6->unk12, ((temp_v1_3 < 0xAA1) != 0)) || (temp_v1_3 >= 0x38F))) { - sp38 = 0.0f; - sp3C = 0.0f; - sp40 = 8.0f; - sp28 = &gPlayers[temp_t0]; + sp28 = temp_v1_3; sp44 = temp_v0_6; - func_802B64C4(&sp38, gPlayers[temp_t0].unk_02E + gPlayers[temp_t0].unk_0C0); - temp_v0_6->unk24 = sp38; - temp_v0_6->unk28 = sp3C; - temp_v0_6->unk6 = 2; - temp_v0_6->unk4 = 0x1E; - temp_v0_6->unk2C = sp40; - func_800C90F4(arg0->unk15, (gPlayers[temp_t0].characterId * 0x10) + 0x29008000); - func_800C9060(arg0->unk15, 0x19008004); - if (arg0->unk0 == 0x16) { - func_8000ED80(arg0->unk28); + func_802B64C4(temp_a0, (s16) (temp_v1_3->unk_02E + temp_v1_3->unk_0C0)); + temp_v0_6->velocity[0] = sp38; + temp_v0_6->velocity[1] = sp3C; + temp_v0_6->state = 2; + temp_v0_6->parentIndex = 0x001E; + temp_v0_6->velocity[2] = sp40; + func_800C9060(actor->unk15, 0x19008004); + func_800C90F4(actor->unk15, (temp_v1_3->characterId * 0x10) + 0x29008000); + if (actor->type == 0x0016) { + func_8000ED80((s32) actor->shellIndices[0]); } else { - func_8000EDC8(arg0->unk28); + func_8000EDC8((s32) actor->shellIndices[0]); } - arg0->unk28 = -1.0f; - arg0->unk4 = arg0->unk4 - 1; - arg0->unk8 = arg0->unk8 - 1.0f; + actor->shellIndices[0] = -1.0f; + actor->shellsAvailable += -1; + actor->unk_08 -= 1.0f; return; } - temp_f0_3 = arg0->unk2C; - if ((temp_f0_3 > 0.0f) && ((temp_v0_7 = &D_8015F9B8 + (temp_f0_3 * 0x70), temp_v1_4 = temp_v0_7->unk12, temp_a0_2 = &sp38, ((temp_v1_4 < -0x38E) != 0)) || (temp_v1_4 >= -0x71B))) { + temp_f0_2 = actor->shellIndices[1]; + if ((temp_f0_2 > 0.0f) && ((temp_v0_7 = &D_8015F9B8[(s16) (s32) temp_f0_2], temp_v1_4 = temp_v0_7->rotAngle, ((temp_v1_4 < 0xAA1) != 0)) || (temp_v1_4 >= 0x38F))) { + temp_v1_5 = &gPlayers[temp_t0]; sp38 = 0.0f; sp3C = 0.0f; sp40 = 8.0f; - sp28 = &gPlayers[temp_t0]; + sp28 = temp_v1_5; sp44 = temp_v0_7; - func_802B64C4(temp_a0_2, gPlayers[temp_t0].unk_02E + gPlayers[temp_t0].unk_0C0); - temp_v0_7->unk24 = sp38; - temp_v0_7->unk28 = sp3C; - temp_v0_7->unk6 = 2; - temp_v0_7->unk4 = 0x1E; - temp_v0_7->unk2C = sp40; - func_800C9060(arg0->unk15, 0x19008004); - func_800C90F4(arg0->unk15, (gPlayers[temp_t0].characterId * 0x10) + 0x29008000); - if (arg0->unk0 == 0x16) { - func_8000ED80(arg0->unk2C); + func_802B64C4(&sp38, (s16) (temp_v1_5->unk_02E + temp_v1_5->unk_0C0)); + sp44->velocity[0] = sp38; + sp44->velocity[1] = sp3C; + sp44->state = 2; + sp44->parentIndex = 0x001E; + sp44->velocity[2] = sp40; + func_800C90F4(actor->unk15, (sp28->characterId * 0x10) + 0x29008000); + func_800C9060(actor->unk15, 0x19008004); + if (actor->type == 0x0016) { + func_8000ED80((s32) actor->shellIndices[1]); } else { - func_8000EDC8(arg0->unk2C); + func_8000EDC8((s32) actor->shellIndices[1]); } - arg0->unk2C = -1.0f; - arg0->unk4 = arg0->unk4 - 1; - arg0->unk8 = arg0->unk8 - 1.0f; + actor->shellIndices[1] = -1.0f; + actor->shellsAvailable += -1; + actor->unk_08 -= 1.0f; + return; + } + temp_f0_3 = actor->shellIndices[2]; + if ((temp_f0_3 > 0.0f) && ((temp_v0_8 = &D_8015F9B8[(s16) (s32) temp_f0_3], temp_v1_6 = temp_v0_8->rotAngle, temp_a0_2 = &sp38, ((temp_v1_6 < -0x38E) != 0)) || (temp_v1_6 >= -0x71B))) { + temp_v1_7 = &gPlayers[temp_t0]; + sp38 = 0.0f; + sp3C = 0.0f; + sp40 = 8.0f; + sp28 = temp_v1_7; + sp44 = temp_v0_8; + func_802B64C4(temp_a0_2, (s16) (temp_v1_7->unk_02E + temp_v1_7->unk_0C0)); + temp_v0_8->velocity[0] = sp38; + temp_v0_8->velocity[1] = sp3C; + temp_v0_8->state = 2; + temp_v0_8->parentIndex = 0x001E; + temp_v0_8->velocity[2] = sp40; + func_800C9060(actor->unk15, 0x19008004); + func_800C90F4(actor->unk15, (temp_v1_7->characterId * 0x10) + 0x29008000); + if (actor->type == 0x0016) { + func_8000ED80((s32) actor->shellIndices[2]); + } else { + func_8000EDC8((s32) actor->shellIndices[2]); + } + actor->shellIndices[2] = -1.0f; + actor->shellsAvailable += -1; + actor->unk_08 -= 1.0f; } - /* Duplicate return node #61. Try simplifying control flow for better match */ - return; } - /* Duplicate return node #61. Try simplifying control flow for better match */ - return; + break; } } #else @@ -840,16 +831,15 @@ GLOBAL_ASM("asm/non_matchings/code_802B0210/func_802B18E4.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -s16 func_8029EC88(f32 *, ? *, ? *, s16); // extern -? func_802AD950(void *, f32, s32, s32, f32, f32, f32, f32); // extern -? func_802B4E30(void *); // extern -? func_802B63B8(f32 *, void *); // extern -extern ? D_8015F9B8; -extern ? D_802B9180; -extern ? D_802B918C; +//generated by m2c commit 685418adfeb3794409e47b45ac5cab60b17d23fd +s16 func_8029EC88(f32 *, ? *, ? *, s16); /* extern */ +? func_802AD950(void *, f32, s32, s32, f32, f32, f32, f32); /* extern */ +? func_802B4E30(void *); /* extern */ +? func_802B63B8(f32 *, f32 *); /* extern */ +static ? D_802B9180; /* unable to generate initializer */ +static ? D_802B918C; /* unable to generate initializer */ -? func_802B19EC(s32 arg0, void *arg1, s16 arg2, u16 arg3) { +s32 func_802B19EC(struct triple_shell_parent *arg0, Player *player, s16 arg2, u16 arg3) { ? sp54; ? sp4C; f32 sp48; @@ -857,54 +847,53 @@ extern ? D_802B918C; f32 sp40; f32 *temp_a0; f32 *temp_a0_2; + f32 *temp_a1; s16 temp_v0; s32 temp_t3; - void *temp_a1; void *temp_s0; - sp54.unk0 = D_802B9180.unk0; - sp54.unk4 = D_802B9180.unk4; - sp54.unk8 = D_802B9180.unk8; - temp_a1 = arg1 + 0x174; + sp54.unk0 = (s32) D_802B9180.unk0; + sp54.unk4 = (s32) D_802B9180.unk4; + sp54.unk8 = (s32) D_802B9180.unk8; + temp_a1 = player->unk_174; temp_a0 = &sp40; - sp4C.unk0 = D_802B918C.unk0; - sp4C.unk4 = D_802B918C.unk4; + sp4C.unk0 = (s32) D_802B918C.unk0; + sp4C.unk4 = (u16) D_802B918C.unk4; sp40 = 0.0f; sp44 = -temp_a1->unk-104; sp48 = temp_a1->unk-104 - 4.0f; func_802B63B8(temp_a0, temp_a1); temp_a0_2 = &sp40; - sp40 = 0.0f + arg1->unk14; - sp44 += arg1->unk18; - sp48 += arg1->unk1C; + sp40 = 0.0f + player->pos[0]; + sp44 += player->pos[1]; + sp48 += player->pos[2]; temp_v0 = func_8029EC88(temp_a0_2, &sp4C, &sp54, arg2); if (temp_v0 < 0) { - (arg0 + (arg3 * 4))->unk24 = -1.0f; + arg0->shellIndices[arg3] = -1.0f; return -1; } temp_t3 = temp_v0 * 7; - sp40 = arg1->unk14; - temp_s0 = (temp_t3 * 0x10) + &D_8015F9B8; - sp44 = arg1->unk18; - sp48 = arg1->unk1C; + sp40 = player->pos[0]; + temp_s0 = (temp_t3 * 0x10) + D_8015F9B8; + sp44 = player->pos[1]; + sp48 = player->pos[2]; func_802AD950(temp_s0 + 0x30, temp_s0->unkC + 1.0f, temp_s0->unk18, temp_s0->unk1C, temp_s0->unk20, sp40, sp44, sp48); func_802B4E30(temp_s0); temp_s0->unk2 = -0x7000; - if (arg2 != 7) { - if (arg2 != 8) { - - } else { - temp_s0->unk6 = 6; - } - } else { + switch (arg2) { /* irregular */ + case 7: temp_s0->unk6 = 4; + break; + case 8: + temp_s0->unk6 = 6; + break; } temp_s0->unk10 = 0; temp_s0->unk12 = -0x8000; - temp_s0->unk14 = (arg1 - gPlayerOne) / 0xDD8; - temp_s0->unk4 = (arg0 - &D_8015F9B8) / 0x70; - temp_s0->unk8 = arg3; - (arg0 + (arg3 * 4))->unk24 = (temp_s0 - &D_8015F9B8) / 0x70; + temp_s0->unk14 = (s16) ((s32) (player - gPlayerOne) / 3544); + temp_s0->unk4 = (s16) ((s32) (arg0 - D_8015F9B8) / 112); + temp_s0->unk8 = (f32) arg3; + arg0->shellIndices[arg3] = (f32) ((s32) (temp_s0 - D_8015F9B8) / 112); return 1; } #else @@ -1692,22 +1681,30 @@ GLOBAL_ASM("asm/non_matchings/code_802B0210/func_802B30EC.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 +//generated by m2c commit 685418adfeb3794409e47b45ac5cab60b17d23fd ? func_8000EDC8(s32); /* extern */ ? func_800C9060(u8, ?); /* extern */ ? func_800C90F4(u8, s32); /* extern */ -? func_800C98B8(void *, void *, ?); /* extern */ -? func_8029E854(f32, void *); /* extern */ -? func_8029FDC8(f32, void *); /* extern */ -? func_802AC098(void *, void *); /* extern */ -? func_802AD950(void *, ?, f32, f32, f32, f32, f32, f32); /* extern */ -? func_802B0210(s16 *, void *); /* extern */ -? func_802B4E30(void *); /* extern */ +? func_800C98B8(f32 *, f32 *, ?); /* extern */ +? func_8029E854(f32, struct shell_actor *); /* extern */ +? func_8029FDC8(f32, struct shell_actor *); /* extern */ +f32 func_802ABE30(f32, f32, f32, u16); /* extern */ +? func_802AC098(UnkActorInner *, f32 *); /* extern */ +? func_802AD950(UnkActorInner *, ?, f32, f32, f32, f32, f32, f32); /* extern */ +? func_802B0210(UnkActorInner *, UnkActorInner *); /* extern */ +? func_802B4E30(struct shell_actor *); /* extern */ ? func_802B63B8(f32 *, f32 *, f32 *); /* extern */ ? func_802B64C4(f32 *, s16); /* extern */ -extern ? D_8015F9B8; +extern s16 D_8015F6E8; +extern s16 D_8015F6EA; +extern s16 D_8015F6EE; +extern s16 D_8015F6F0; +extern s16 D_8015F6F2; +static f32 D_802B9F5C = 1.2f; +static f32 D_802B9F60 = 1.2f; +static f32 D_802B9F64 = 0.3f; -void update_obj_green_shell(struct Actor *arg0) { +void update_obj_green_shell(struct shell_actor *shell) { f32 sp80; f32 sp7C; f32 sp78; @@ -1715,112 +1712,115 @@ void update_obj_green_shell(struct Actor *arg0) { f32 sp70; f32 sp6C; f32 sp54; - void *sp34; + UnkActorInner *sp34; Player *temp_s1; Player *temp_s1_2; Player *temp_s1_4; + UnkActorInner *temp_a0; + f32 *temp_s1_3; f32 temp_f0; f32 temp_f0_2; f32 temp_f0_3; f32 temp_f0_4; f32 temp_f12; f32 temp_f14; - f32 temp_f18; f32 temp_f2; f32 temp_f2_2; s16 temp_t4; - s16 temp_t9; - s16 temp_v0; s16 temp_v0_2; + s16 temp_v0_3; + struct Controller *temp_v0; + struct shell_actor *temp_v0_4; u16 temp_t3; u16 temp_v1; - void *temp_a0; - void *temp_s1_3; - void *temp_v0_3; f32 phi_f2; f32 phi_f2_2; - temp_f2 = arg0->unk20; - temp_f0 = arg0->unk18; - temp_f12 = arg0->unk1C; - if ((temp_f2 < D_8015F6F2) || (D_8015F6F0 < temp_f2) || (temp_f0 < D_8015F6EA) || (D_8015F6E8 < temp_f0) || (temp_f12 < D_8015F6EE)) { - func_8029FDC8(temp_f12, arg0); + temp_f2 = shell->pos[2]; + temp_f0 = shell->pos[0]; + temp_f12 = shell->pos[1]; + if ((temp_f2 < (f32) D_8015F6F2) || ((f32) D_8015F6F0 < temp_f2) || (temp_f0 < (f32) D_8015F6EA) || ((f32) D_8015F6E8 < temp_f0) || (temp_f12 < (f32) D_8015F6EE)) { + func_8029FDC8(temp_f12, shell); } - temp_t3 = arg0->unk6; - arg0->unk10 = arg0->unk10 + 0x71C; + temp_t3 = (u16) shell->state; + shell->rotVelocity += 0x71C; switch (temp_t3) { case 0: - temp_s1 = &gPlayers[arg0->unk10[2]]; - func_802B0210(&temp_s1->unk_110, arg0 + 0x30); + temp_s1 = &gPlayers[shell->playerId]; + func_802B0210(&temp_s1->unk_110, &shell->unk30); sp6C = 0.0f; sp70 = temp_s1->unk_070; - sp74 = -(temp_s1->unk_070 + arg0->unkC + 2.0f); + sp74 = -(temp_s1->unk_070 + shell->unk_0C + 2.0f); func_802B63B8(&sp6C, temp_s1->unk_174); - arg0->unk18 = sp6C + temp_s1->pos[0]; - temp_f14 = temp_s1->posY - sp70; - arg0->unk20 = sp74 + temp_s1->pos[2]; + shell->pos[0] = sp6C + temp_s1->pos[0]; + temp_f14 = temp_s1->pos[1] - sp70; + shell->pos[2] = sp74 + temp_s1->pos[2]; sp54 = temp_f14; - temp_f0_2 = func_802ABE30(arg0->unk18, temp_f14, arg0->unk20, temp_s1->unk_11A); + temp_f0_2 = func_802ABE30(shell->pos[0], temp_f14, shell->pos[2], temp_s1->unk_110.unk3A); temp_f2_2 = temp_f14 - temp_f0_2; if ((temp_f2_2 < 5.0f) && (temp_f2_2 > -5.0f)) { - arg0->unk1C = arg0->unkC + temp_f0_2; + shell->pos[1] = shell->unk_0C + temp_f0_2; } else { - arg0->unk1C = temp_f14; + shell->pos[1] = temp_f14; } - if (((temp_s1->unk_000 & PLAYER_HUMAN) != 0) && (temp_t9 = arg0->unk14, temp_v1 = gControllers[temp_t9].buttonDepressed, ((temp_v1 & 0x2000) != 0))) { - gControllers[temp_t9].buttonDepressed = temp_v1 & 0xDFFF; - if (gControllers[temp_t9].rawStickY < -0x2D) { - temp_f0_3 = temp_s1->unk_094; - phi_f2 = 8.0f; - if (temp_f0_3 > 8.0f) { - phi_f2 = temp_f0_3 * D_802B9F5C; + if ((temp_s1->unk_000 & 0x4000) != 0) { + temp_v0 = &gControllers[shell->playerId]; + temp_v1 = temp_v0->buttonDepressed; + if ((temp_v1 & 0x2000) != 0) { + temp_v0->buttonDepressed = temp_v1 & 0xDFFF; + if (temp_v0->rawStickY < -0x2D) { + temp_f0_3 = temp_s1->unk_094; + phi_f2 = 8.0f; + if (temp_f0_3 > 8.0f) { + phi_f2 = temp_f0_3 * D_802B9F5C; + } + sp6C = 0.0f; + sp70 = 0.0f; + sp74 = -phi_f2; + func_802B64C4(&sp6C, (s16) (temp_s1->unk_02E + temp_s1->unk_0C0)); + shell->velocity[0] = sp6C; + shell->velocity[1] = sp70; + shell->state = 2; + shell->velocity[2] = sp74; + func_800C9060(shell->unk15, 0x19008004); + func_800C90F4(shell->unk15, (temp_s1->characterId * 0x10) + 0x29008000); + func_8000EDC8((s32) (shell - D_8015F9B8) / 112); + return; } - sp6C = 0.0f; - sp70 = 0.0f; - sp74 = -phi_f2; - func_802B64C4(&sp6C, temp_s1->unk_02E + temp_s1->unk_0C0); - arg0->unk24 = sp6C; - arg0->unk28 = sp70; - arg0->unk6 = 2; - arg0->unk2C = sp74; - func_800C9060(arg0->unk15, 0x19008004); - func_800C90F4(arg0->unk15, (temp_s1->characterId * 0x10) + 0x29008000); - func_8000EDC8((arg0 - &D_8015F9B8) / 112); + shell->state = 1; + if (temp_s1->unk_0C0 > 0) { + shell->rotAngle = 0x78E3; + return; + } + shell->rotAngle = -0x78E4; return; } - arg0->unk6 = 1; - if (temp_s1->unk_0C0 > 0) { - arg0->unk12 = 0x78E3; - return; - } - arg0->unk12 = -0x78E4; - return; } default: return; case 1: - temp_v0 = arg0->unk12; - temp_s1_2 = &gPlayers[arg0->unk14]; - if (temp_v0 > 0) { - arg0->unk12 = temp_v0 - 0xE38; - if (arg0->unk12 < 0) { - arg0->unk6 = 2; - arg0->unk4 = 0x1E; - func_800C9060(arg0->unk15, 0x19008004); - func_800C90F4(arg0->unk15, (temp_s1_2->characterId * 0x10) + 0x29008000); - func_8000EDC8((arg0 - &D_8015F9B8) / 112); + temp_v0_2 = shell->rotAngle; + temp_s1_2 = &gPlayers[shell->playerId]; + if (temp_v0_2 > 0) { + shell->rotAngle = temp_v0_2 - 0xE38; + if (shell->rotAngle < 0) { + shell->state = 2; + shell->parentIndex = 0x001E; + func_800C9060(shell->unk15, 0x19008004); + func_800C90F4(shell->unk15, (temp_s1_2->characterId * 0x10) + 0x29008000); + func_8000EDC8((s32) (shell - D_8015F9B8) / 112); } } else { - arg0->unk12 = temp_v0 + 0xE38; - if (arg0->unk12 > 0) { - arg0->unk6 = 2; - arg0->unk4 = 0x1E; - func_800C9060(arg0->unk15, 0x19008004); - func_800C90F4(arg0->unk15, (temp_s1_2->characterId * 0x10) + 0x29008000); - func_8000EDC8((arg0 - &D_8015F9B8) / 112); + shell->rotAngle = temp_v0_2 + 0xE38; + if (shell->rotAngle > 0) { + shell->state = 2; + shell->parentIndex = 0x001E; + func_800C9060(shell->unk15, 0x19008004); + func_800C90F4(shell->unk15, (temp_s1_2->characterId * 0x10) + 0x29008000); + func_8000EDC8((s32) (shell - D_8015F9B8) / 112); } } - if (arg0->unk6 == 2) { + if (shell->state == 2) { temp_f0_4 = temp_s1_2->unk_094; phi_f2_2 = 8.0f; if (temp_f0_4 > 8.0f) { @@ -1829,87 +1829,84 @@ void update_obj_green_shell(struct Actor *arg0) { sp6C = 0.0f; sp70 = 0.0f; sp74 = phi_f2_2; - func_802B64C4(&sp6C, temp_s1_2->unk_02E + temp_s1_2->unk_0C0); - arg0->unk24 = sp6C; - arg0->unk28 = sp70; - arg0->unk2C = sp74; + func_802B64C4(&sp6C, (s16) (temp_s1_2->unk_02E + temp_s1_2->unk_0C0)); + shell->velocity[0] = sp6C; + shell->velocity[1] = sp70; + shell->velocity[2] = sp74; return; } - sp6C = sins(arg0->unk12) * 6.0f; - sp70 = arg0->unkC - temp_s1_2->unk_070; - sp74 = coss(arg0->unk12, MIPS2C_ERROR(Read from unset register $a1)) * 6.0f; + sp6C = sins((u16) shell->rotAngle) * 6.0f; + sp70 = shell->unk_0C - temp_s1_2->unk_070; + sp74 = coss((u16) shell->rotAngle) * 6.0f; func_802B63B8(&sp6C, temp_s1_2->unk_174); - arg0->unk18 = sp6C + temp_s1_2->posX; - arg0->unk1C = sp70 + temp_s1_2->posY; - arg0->unk20 = sp74 + temp_s1_2->posZ; + shell->pos[0] = sp6C + temp_s1_2->pos[0]; + shell->pos[1] = sp70 + temp_s1_2->pos[1]; + shell->pos[2] = sp74 + temp_s1_2->pos[2]; return; case 2: - temp_v0_2 = arg0->unk4; - if (temp_v0_2 > 0) { - arg0->unk4 = temp_v0_2 - 1; - if (arg0->unk4 == 0) { - arg0->unk2 = arg0->unk2 & 0xEFFF; + temp_v0_3 = shell->parentIndex; + if (temp_v0_3 > 0) { + shell->parentIndex = temp_v0_3 - 1; + if (shell->parentIndex == 0) { + shell->unk_02 &= 0xEFFF; } } - arg0->unk28 = arg0->unk28 - 0.5f; - if (arg0->unk28 < -2.0f) { - arg0->unk28 = -2.0f; + shell->velocity[1] -= 0.5f; + if (shell->velocity[1] < -2.0f) { + shell->velocity[1] = -2.0f; } - temp_a0 = arg0 + 0x30; - sp78 = arg0->unk18; - sp7C = arg0->unk1C; - sp80 = arg0->unk20; - arg0->unk18 = arg0->unk18 + arg0->unk24; - arg0->unk1C = arg0->unk1C + arg0->unk28; - arg0->unk20 = arg0->unk20 + arg0->unk2C; + temp_a0 = &shell->unk30; + sp78 = shell->pos[0]; + sp7C = shell->pos[1]; + sp80 = shell->pos[2]; + shell->pos[0] += shell->velocity[0]; + shell->pos[1] += shell->velocity[1]; + shell->pos[2] += shell->velocity[2]; sp34 = temp_a0; - func_802AD950(temp_a0, 0x40800000, arg0->unk18, arg0->unk1C, arg0->unk20, sp78, sp7C, sp80); - func_802B4E30(arg0); - temp_s1_3 = arg0 + 0x24; - if ((arg0->unk3C < 0.0f) || (arg0->unk40 < 0.0f)) { + func_802AD950(temp_a0, 0x40800000, shell->pos[0], shell->pos[1], shell->pos[2], sp78, sp7C, sp80); + func_802B4E30(shell); + temp_s1_3 = shell->velocity; + if ((shell->unk30.unk3C < 0.0f) || (shell->unk30.unk40 < 0.0f)) { func_802AC098(temp_a0, temp_s1_3); - func_800C98B8(arg0 + 0x18, temp_s1_3, 0x19008054); - arg0->unk2 = arg0->unk2 | 0x80; + func_800C98B8(shell->pos, temp_s1_3, 0x19008054); + shell->unk_02 |= 0x80; return; } - /* Duplicate return node #46. Try simplifying control flow for better match */ - return; + break; case 4: - temp_v0_3 = (arg0->unk4 * 0x70) + &D_8015F9B8; - temp_s1_4 = &gPlayers[arg0->unk14]; - if (temp_v0_3->unk0 != 0x15) { - func_8029FDC8((bitwise f32) arg0); + temp_v0_4 = &D_8015F9B8[shell->parentIndex]; + temp_s1_4 = &gPlayers[shell->playerId]; + if (temp_v0_4->type != 0x0015) { + func_8029FDC8((bitwise f32) shell); return; } - temp_t4 = arg0->unk12 + temp_v0_3->unk10; - arg0->unk12 = temp_t4; + temp_t4 = shell->rotAngle + temp_v0_4->rotVelocity; + shell->rotAngle = temp_t4; sp6C = sins(temp_t4 & 0xFFFF) * 8.0f; - sp70 = arg0->unkC - temp_s1_4->unk_070; - temp_f18 = coss(arg0->unk12, MIPS2C_ERROR(Read from unset register $a1)) * 8.0f; - sp74 = temp_f18; + sp70 = shell->unk_0C - temp_s1_4->unk_070; + sp74 = coss((u16) shell->rotAngle) * 8.0f; func_802B63B8((bitwise f32 *) 8.0f, &sp6C, temp_s1_4->unk_174); - sp78 = arg0->unk18; - sp7C = arg0->unk1C; - sp80 = arg0->unk20; - arg0->unk18 = sp6C + temp_s1_4->posX; - arg0->unk1C = sp70 + temp_s1_4->posY; - arg0->unk20 = temp_f18 + temp_s1_4->posZ; - func_802AD950(arg0 + 0x30, 0x40800000, arg0->unk18, arg0->unk1C, arg0->unk20, sp78, sp7C, sp80); - func_802B4E30(arg0); + sp78 = shell->pos[0]; + sp7C = shell->pos[1]; + sp80 = shell->pos[2]; + shell->pos[0] = sp6C + temp_s1_4->pos[0]; + shell->pos[1] = sp70 + temp_s1_4->pos[1]; + shell->pos[2] = sp74 + temp_s1_4->pos[2]; + func_802AD950(&shell->unk30, 0x40800000, shell->pos[0], shell->pos[1], shell->pos[2], sp78, sp7C, sp80); + func_802B4E30(shell); return; case 5: - arg0->unk28 = arg0->unk28 - D_802B9F64; - if (arg0->unk28 < -5.0f) { - arg0->unk28 = -5.0f; + shell->velocity[1] -= D_802B9F64; + if (shell->velocity[1] < -5.0f) { + shell->velocity[1] = -5.0f; } - arg0->unk4 = arg0->unk4 - 1; - arg0->unk12 = arg0->unk12 + 0x5B0; - arg0->unk1C = arg0->unk1C + arg0->unk28; - if (arg0->unk4 == 0) { - func_8029E854(-5.0f, arg0); + shell->parentIndex += -1; + shell->rotAngle += 0x5B0; + shell->pos[1] += shell->velocity[1]; + if (shell->parentIndex == 0) { + func_8029E854(-5.0f, shell); } - /* Duplicate return node #46. Try simplifying control flow for better match */ - return; + break; } } #else @@ -1917,13 +1914,13 @@ GLOBAL_ASM("asm/non_matchings/code_802B0210/update_obj_green_shell.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_802AD950(void *, f32, f32, f32, f32, f32, f32, f32); // extern -? func_802B4E30(void *); // extern +//generated by m2c commit 685418adfeb3794409e47b45ac5cab60b17d23fd +? func_802AD950(UnkActorInner *, f32, f32, f32, f32, f32, f32, f32); /* extern */ +? func_802B4E30(struct shell_actor *); /* extern */ extern u16 D_80164430; extern s32 D_80164490; -void func_802B3B44(void *arg0) { +void func_802B3B44(struct shell_actor *shell) { f32 spAC; f32 spA8; f32 spA4; @@ -1965,27 +1962,27 @@ void func_802B3B44(void *arg0) { void *temp_v0; void *temp_v0_2; void *temp_v0_3; - u16 phi_a2; + s16 phi_a2; f32 phi_f2; f32 phi_f14; f32 phi_f16; - temp_v1 = arg0->unk12; + temp_v1 = (u16) shell->rotAngle; temp_t1 = D_80164490; temp_v0 = temp_t1 + (temp_v1 * 8); temp_t0 = D_80164430; temp_a1 = temp_v1 + 1; temp_a3 = temp_a1 & 0xFFFF; - temp_f2 = temp_v0->unk0; - temp_f12 = temp_v0->unk2; - temp_f28 = temp_v0->unk4; + temp_f2 = (f32) temp_v0->unk0; + temp_f12 = (f32) temp_v0->unk2; + temp_f28 = (f32) temp_v0->unk4; phi_a2 = temp_a1 & 0xFFFF; - if (temp_a3 >= temp_t0) { + if (temp_a3 >= (s32) temp_t0) { phi_a2 = (temp_a3 - temp_t0) & 0xFFFF; } - temp_f0 = arg0->unk18; - temp_f16 = arg0->unk1C; - temp_f18 = arg0->unk20; + temp_f0 = shell->pos[0]; + temp_f16 = shell->pos[1]; + temp_f18 = shell->pos[2]; temp_f20 = temp_f2 - temp_f0; temp_f22 = temp_f12 - temp_f16; temp_v0_2 = temp_t1 + (phi_a2 * 8); @@ -1995,21 +1992,21 @@ void func_802B3B44(void *arg0) { sp58 = temp_f18; temp_f14 = (temp_f20 * temp_f20) + (temp_f22 * temp_f22) + (temp_f24 * temp_f24); if (temp_f14 > 400.0f) { - temp_f0_2 = temp_v0_2->unk0 - sp60; - temp_f2_2 = temp_v0_2->unk2 - sp5C; - temp_f12_2 = temp_v0_2->unk4 - sp58; + temp_f0_2 = (f32) temp_v0_2->unk0 - sp60; + temp_f2_2 = (f32) temp_v0_2->unk2 - sp5C; + temp_f12_2 = (f32) temp_v0_2->unk4 - sp58; if (((temp_f0_2 * temp_f0_2) + (temp_f2_2 * temp_f2_2) + (temp_f12_2 * temp_f12_2)) < temp_f14) { - arg0->unk12 = phi_a2; + shell->rotAngle = phi_a2; return; } temp_f18_2 = sqrtf(temp_f14) * 4.0f; temp_f22_2 = temp_f22 / temp_f18_2; - temp_f2_3 = arg0->unk24 + (temp_f20 / temp_f18_2); + temp_f2_3 = shell->velocity[0] + (temp_f20 / temp_f18_2); temp_f10 = temp_f2_3 * temp_f2_3; spAC = temp_f2_3; - temp_f14_2 = arg0->unk28 + temp_f22_2; + temp_f14_2 = shell->velocity[1] + temp_f22_2; spA8 = temp_f14_2; - temp_f16_2 = arg0->unk2C + (temp_f24 / temp_f18_2); + temp_f16_2 = shell->velocity[2] + (temp_f24 / temp_f18_2); spA4 = temp_f16_2; temp_f0_3 = sqrtf(temp_f10 + (temp_f14_2 * temp_f14_2) + (temp_f16_2 * temp_f16_2)); phi_f2 = temp_f2_3; @@ -2021,49 +2018,49 @@ void func_802B3B44(void *arg0) { phi_f14 = temp_f14_2 / temp_f12_3; phi_f16 = temp_f16_2 / temp_f12_3; } - arg0->unk24 = phi_f2; - arg0->unk28 = phi_f14; - arg0->unk2C = phi_f16; - sp68 = arg0->unk18; - sp6C = arg0->unk1C; - sp70 = arg0->unk20; - arg0->unk18 = arg0->unk18 + phi_f2; - arg0->unk1C = arg0->unk1C + phi_f14; - arg0->unk20 = arg0->unk20 + phi_f16; - func_802AD950(arg0 + 0x30, 4.0f, arg0->unk18, arg0->unk1C, arg0->unk20, sp68, sp6C, sp70); - func_802B4E30(arg0); + shell->velocity[0] = phi_f2; + shell->velocity[1] = phi_f14; + shell->velocity[2] = phi_f16; + sp68 = shell->pos[0]; + sp6C = shell->pos[1]; + sp70 = shell->pos[2]; + shell->pos[0] += phi_f2; + shell->pos[1] += phi_f14; + shell->pos[2] += phi_f16; + func_802AD950(&shell->unk30, 4.0f, shell->pos[0], shell->pos[1], shell->pos[2], sp68, sp6C, sp70); + func_802B4E30(shell); return; } temp_v0_3 = temp_t1 + (phi_a2 * 8); if (temp_f14 > 5.0f) { - arg0->unk18 = temp_f2; - arg0->unk20 = temp_f28; - arg0->unk12 = phi_a2; - arg0->unk1C = arg0->unkC + temp_f12; + shell->pos[0] = temp_f2; + shell->pos[2] = temp_f28; + shell->rotAngle = phi_a2; + shell->pos[1] = shell->unk_0C + temp_f12; return; } - temp_f16_3 = temp_v0_3->unk0; - temp_f18_3 = temp_v0_3->unk2; - temp_f26 = temp_v0_3->unk4; - arg0->unk18 = (temp_f2 + temp_f16_3) * 0.5f; - arg0->unk1C = ((temp_f12 + temp_f18_3) * 0.5f) + arg0->unkC; - arg0->unk20 = (temp_f28 + temp_f26) * 0.5f; - arg0->unk24 = (temp_f16_3 - temp_f2) * 0.5f; - arg0->unk28 = (temp_f18_3 - temp_f12) * 0.5f; - arg0->unk2C = (temp_f26 - temp_f28) * 0.5f; + temp_f16_3 = (f32) temp_v0_3->unk0; + temp_f18_3 = (f32) temp_v0_3->unk2; + temp_f26 = (f32) temp_v0_3->unk4; + shell->pos[0] = (temp_f2 + temp_f16_3) * 0.5f; + shell->pos[1] = ((temp_f12 + temp_f18_3) * 0.5f) + shell->unk_0C; + shell->pos[2] = (temp_f28 + temp_f26) * 0.5f; + shell->velocity[0] = (temp_f16_3 - temp_f2) * 0.5f; + shell->velocity[1] = (temp_f18_3 - temp_f12) * 0.5f; + shell->velocity[2] = (temp_f26 - temp_f28) * 0.5f; } #else GLOBAL_ASM("asm/non_matchings/code_802B0210/func_802B3B44.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_8029FDC8(f32, f32, void *, ?); // extern -? func_802AD950(f32, f32, void *, ?, f32, f32, f32, f32, f32, f32); // extern -? func_802B4104(void *); // extern -? func_802B4E30(void *); // extern +//generated by m2c commit 685418adfeb3794409e47b45ac5cab60b17d23fd +? func_8029FDC8(f32, f32, struct shell_actor *, ?); /* extern */ +? func_802AD950(f32, f32, UnkActorInner *, ?, f32, f32, f32, f32, f32, f32); /* extern */ +? func_802B4104(struct shell_actor *); /* extern */ +? func_802B4E30(struct shell_actor *); /* extern */ -void func_802B3E7C(void *arg0, void *arg1) { +void func_802B3E7C(struct shell_actor *shell, Player *player) { f32 sp44; f32 sp40; f32 sp38; @@ -2075,8 +2072,8 @@ void func_802B3E7C(void *arg0, void *arg1) { f32 phi_f2; f32 phi_f14; - temp_f2 = arg1->unk14 - arg0->unk18; - temp_f14 = arg1->unk1C - arg0->unk20; + temp_f2 = player->pos[0] - shell->pos[0]; + temp_f14 = player->pos[2] - shell->pos[2]; sp44 = temp_f2; sp40 = temp_f14; temp_f12 = sqrtf((temp_f2 * temp_f2) + (temp_f14 * temp_f14)) / 8.0f; @@ -2087,51 +2084,50 @@ void func_802B3E7C(void *arg0, void *arg1) { phi_f2 = temp_f2 / temp_f12; phi_f14 = temp_f14 / temp_f12; } - sp30 = arg0->unk18; - sp34 = arg0->unk1C; - sp38 = arg0->unk20; - arg0->unk24 = phi_f2; - arg0->unk2C = phi_f14; - arg0->unk18 = arg0->unk18 + phi_f2; - arg0->unk1C = arg0->unk1C - 2.0f; - arg0->unk28 = -2.0f; - arg0->unk20 = arg0->unk20 + phi_f14; - if (arg1->unkBC & 0x80000000) { - func_8029FDC8(temp_f12, phi_f14, arg0, 0x40800000); + sp30 = shell->pos[0]; + sp34 = shell->pos[1]; + sp38 = shell->pos[2]; + shell->velocity[0] = phi_f2; + shell->velocity[2] = phi_f14; + shell->pos[0] += phi_f2; + shell->pos[1] -= 2.0f; + shell->velocity[1] = -2.0f; + shell->pos[2] += phi_f14; + if (player->unk_0BC & 0x80000000) { + func_8029FDC8(temp_f12, phi_f14, shell, 0x40800000); return; } - func_802AD950(temp_f12, phi_f14, arg0 + 0x30, 0x40800000, arg0->unk18, arg0->unk1C, arg0->unk20, sp30, sp34, sp38); - func_802B4E30(arg0); - func_802B4104(arg0); + func_802AD950(temp_f12, phi_f14, &shell->unk30, 0x40800000, shell->pos[0], shell->pos[1], shell->pos[2], sp30, sp34, sp38); + func_802B4E30(shell); + func_802B4104(shell); } #else GLOBAL_ASM("asm/non_matchings/code_802B0210/func_802B3E7C.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -f32 func_802B51E8(void *, s32); // extern +//generated by m2c commit 685418adfeb3794409e47b45ac5cab60b17d23fd +f32 func_802B51E8(void *, f32 *); /* extern */ extern ? gPlayerBalloonCount; -extern f32 D_802B9F68; -extern u16 gPlayers; +static f32 D_802B9F68 = 2.5e7f; -s16 func_802B3FD0(s32 arg0, s32 arg1) { +s16 func_802B3FD0(Player *player, struct shell_actor *shell) { f32 temp_f0; s32 temp_s1; - u16 *phi_s0; + Player *phi_s0; s32 phi_s1; f32 phi_f20; s16 phi_fp; - phi_s0 = &gPlayers; + phi_s0 = gPlayers; phi_s1 = 0; phi_f20 = D_802B9F68; phi_fp = -1; do { - if (((*phi_s0 & 0x8000) != 0) && (phi_s0 != arg0) && (*(&gPlayerBalloonCount + (phi_s1 * 2)) >= 0)) { - temp_f0 = func_802B51E8(phi_s0 + 0x14, arg1 + 0x18); + if (((phi_s0->unk_000 & 0x8000) != 0) && (phi_s0 != player) && (*(&gPlayerBalloonCount + (phi_s1 * 2)) >= 0)) { + temp_f0 = func_802B51E8(phi_s0 + 0x14, shell->pos); if (temp_f0 < phi_f20) { - phi_fp = (phi_s0 - gPlayerOne) / 0xDD8; + phi_fp = (s16) ((s32) (phi_s0 - gPlayerOne) / 3544); phi_f20 = temp_f0; } } @@ -2171,26 +2167,39 @@ GLOBAL_ASM("asm/non_matchings/code_802B0210/func_802B4104.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 +//generated by m2c commit 685418adfeb3794409e47b45ac5cab60b17d23fd ? func_8000ED80(s32); /* extern */ ? func_8000EE10(s32); /* extern */ ? func_800C9060(u8, ?); /* extern */ ? func_800C90F4(u8, s32); /* extern */ -? func_800C9D80(void *, void *, ?); /* extern */ -? func_8029E854(f32, void *); /* extern */ -? func_8029FDC8(f32, void *); /* extern */ -? func_802AD950(void *, ?, f32, f32, f32, f32, f32, f32); /* extern */ -? func_802B0210(s16 *, void *); /* extern */ -? func_802B3B44(void *); /* extern */ -? func_802B3E7C(void *, Player *); /* extern */ -? func_802B4104(void *); /* extern */ -? func_802B4E30(void *); /* extern */ +? func_800C9D80(f32 *, f32 *, ?); /* extern */ +? func_8029E854(f32, struct shell_actor *); /* extern */ +? func_8029FDC8(f32, struct shell_actor *); /* extern */ +f32 func_802ABE30(f32, f32, f32, u16); /* extern */ +? func_802AD950(UnkActorInner *, ?, f32, f32, f32, f32, f32, f32); /* extern */ +? func_802B0210(UnkActorInner *, UnkActorInner *); /* extern */ +? func_802B3B44(struct shell_actor *); /* extern */ +? func_802B3E7C(struct shell_actor *, Player *); /* extern */ +s16 func_802B3FD0(Player *, struct shell_actor *); /* extern */ +? func_802B4104(struct shell_actor *); /* extern */ +? func_802B4E30(struct shell_actor *); /* extern */ ? func_802B63B8(f32 *, f32 *); /* extern */ ? func_802B64C4(f32 *, s16); /* extern */ -extern ? D_8015F9B8; +extern s16 D_8015F6E8; +extern s16 D_8015F6EA; +extern s16 D_8015F6EE; +extern s16 D_8015F6F0; +extern s16 D_8015F6F2; +extern u16 D_80164430; extern ? D_80164438; +extern struct Controller *gControllerOne; +extern s16 gPlayerPositionLUT; +static f32 D_802B9F94 = 1.2f; +static f32 D_802B9F98 = 40000.0f; +static f32 D_802B9F9C = 0.3f; +static f32 D_802B9FA0 = 40000.0f; -void update_obj_red_blue_shell(void *arg0) { +void update_obj_red_blue_shell(struct shell_actor *shell) { f32 sp94; f32 sp90; f32 sp8C; @@ -2202,77 +2211,73 @@ void update_obj_red_blue_shell(void *arg0) { Player *temp_s1; Player *temp_s1_2; Player *temp_s1_3; + Player *temp_s1_4; + Player *temp_s1_5; + Player *temp_s1_6; f32 *temp_a0; f32 temp_f0; f32 temp_f0_2; f32 temp_f0_3; f32 temp_f0_4; - f32 temp_f10; f32 temp_f12; f32 temp_f14; - f32 temp_f16; f32 temp_f2; f32 temp_f2_2; f32 temp_f2_3; f32 temp_f2_4; f32 temp_f2_5; - f32 temp_f4; - s16 temp_t3; - s16 temp_t4_2; s16 temp_t6; - s16 temp_t7; s16 temp_v0; s16 temp_v0_2; s16 temp_v0_3; s16 temp_v0_4; s16 temp_v0_5; s16 temp_v0_6; + struct triple_shell_parent *temp_v0_7; u16 temp_t4; u16 temp_v1; u16 temp_v1_2; u16 temp_v1_3; u16 temp_v1_4; - void *temp_v0_7; struct Controller *phi_v0; f32 phi_f0; s16 phi_v0_2; s16 phi_v0_3; s16 phi_v0_4; - temp_f2 = arg0->unk20; - temp_f0 = arg0->unk18; - temp_f12 = arg0->unk1C; - sp56 = arg0->unk0; - if ((temp_f2 < D_8015F6F2) || (D_8015F6F0 < temp_f2) || (temp_f0 < D_8015F6EA) || (D_8015F6E8 < temp_f0) || (temp_f12 < D_8015F6EE)) { - func_8029FDC8(temp_f12, arg0); + temp_f2 = shell->pos[2]; + temp_f0 = shell->pos[0]; + temp_f12 = shell->pos[1]; + sp56 = shell->type; + if ((temp_f2 < (f32) D_8015F6F2) || ((f32) D_8015F6F0 < temp_f2) || (temp_f0 < (f32) D_8015F6EA) || ((f32) D_8015F6E8 < temp_f0) || (temp_f12 < (f32) D_8015F6EE)) { + func_8029FDC8(temp_f12, shell); } - temp_t4 = arg0->unk6; - arg0->unk10 = arg0->unk10 + 0x71C; + temp_t4 = (u16) shell->state; + shell->rotVelocity += 0x71C; switch (temp_t4) { case 0: - temp_s1 = &gPlayers[arg0->unk14]; - func_802B0210(&temp_s1->unk_110, arg0 + 0x30); + temp_s1 = &gPlayers[shell->playerId]; + func_802B0210(&temp_s1->unk_110, &shell->unk30); sp8C = 0.0f; sp90 = temp_s1->unk_070; - temp_f16 = -(temp_s1->unk_070 + arg0->unkC + 2.0f); - sp94 = temp_f16; + sp94 = -(temp_s1->unk_070 + shell->unk_0C + 2.0f); func_802B63B8(&sp8C, temp_s1->unk_174); - arg0->unk18 = sp8C + temp_s1->posX; - temp_f14 = temp_s1->posY - sp90; - arg0->unk20 = temp_f16 + temp_s1->posZ; + shell->pos[0] = sp8C + temp_s1->pos[0]; + temp_f14 = temp_s1->pos[1] - sp90; + shell->pos[2] = sp94 + temp_s1->pos[2]; sp68 = temp_f14; - temp_f0_2 = func_802ABE30(arg0->unk18, temp_f14, arg0->unk20, temp_s1->unk_11A); + temp_f0_2 = func_802ABE30(shell->pos[0], temp_f14, shell->pos[2], temp_s1->unk_110.unk3A); temp_f2_2 = temp_f14 - temp_f0_2; if ((temp_f2_2 < 5.0f) && (temp_f2_2 > -5.0f)) { - arg0->unk1C = arg0->unkC + temp_f0_2; + shell->pos[1] = shell->unk_0C + temp_f0_2; } else { - arg0->unk1C = temp_f14; + shell->pos[1] = temp_f14; } - if ((temp_s1->unk_000 & PLAYER_HUMAN) != 0) { + if ((temp_s1->unk_000 & 0x4000) != 0) { if (D_800DC51C != 0) { goto block_16; } - phi_v0 = &gControllers[arg0->unk14]; + phi_v0 = &gControllers[shell->playerId]; } else { block_16: phi_v0 = gControllerOne; @@ -2280,48 +2285,48 @@ block_16: temp_v1 = phi_v0->buttonDepressed; if ((temp_v1 & 0x2000) != 0) { phi_v0->buttonDepressed = temp_v1 & 0xDFFF; - arg0->unk6 = 1; + shell->state = 1; if (temp_s1->unk_0C0 > 0) { - arg0->unk12 = 0x78E3; + shell->rotAngle = 0x78E3; return; } - arg0->unk12 = -0x78E4; + shell->rotAngle = -0x78E4; return; } default: return; case 1: - temp_v0 = arg0->unk12; - temp_s1_2 = &gPlayers[arg0->unk14]; + temp_v0 = shell->rotAngle; + temp_s1_2 = &gPlayers[shell->playerId]; if (temp_v0 > 0) { - arg0->unk12 = temp_v0 - 0x71C; - if (arg0->unk12 < 0) { - arg0->unk6 = 2; - func_800C9060(arg0->unk15, 0x19008004); - func_800C90F4(arg0->unk15, (temp_s1_2->characterId * 0x10) + 0x29008000); + shell->rotAngle = temp_v0 - 0x71C; + if (shell->rotAngle < 0) { + shell->state = 2; + func_800C9060(shell->unk15, 0x19008004); + func_800C90F4(shell->unk15, (temp_s1_2->characterId * 0x10) + 0x29008000); if (sp56 == 8) { - func_8000ED80((arg0 - &D_8015F9B8) / 112); + func_8000ED80((s32) (shell - D_8015F9B8) / 112); } else { - func_8000EE10((arg0 - &D_8015F9B8) / 112); - func_800C9D80(arg0 + 0x18, arg0 + 0x24, 0x51018008); + func_8000EE10((s32) (shell - D_8015F9B8) / 112); + func_800C9D80(shell->pos, shell->velocity, 0x51018008); } } } else { - arg0->unk12 = temp_v0 + 0x71C; - if (arg0->unk12 > 0) { - arg0->unk6 = 2; - func_800C9060(arg0->unk15, 0x19008004); - func_800C90F4(arg0->unk15, (temp_s1_2->characterId * 0x10) + 0x29008000); + shell->rotAngle = temp_v0 + 0x71C; + if (shell->rotAngle > 0) { + shell->state = 2; + func_800C9060(shell->unk15, 0x19008004); + func_800C90F4(shell->unk15, (temp_s1_2->characterId * 0x10) + 0x29008000); if (sp56 == 8) { - func_8000ED80((arg0 - &D_8015F9B8) / 112); + func_8000ED80((s32) (shell - D_8015F9B8) / 112); } else { - func_8000EE10((arg0 - &D_8015F9B8) / 112); - func_800C9D80(arg0 + 0x18, arg0 + 0x24, 0x51018008); + func_8000EE10((s32) (shell - D_8015F9B8) / 112); + func_800C9D80(shell->pos, shell->velocity, 0x51018008); } } } - if (arg0->unk6 == 2) { - arg0->unk4 = 0x1E; + if (shell->state == 2) { + shell->parentIndex = 0x001E; temp_f2_3 = temp_s1_2->unk_094; phi_f0 = 8.0f; if (temp_f2_3 > 8.0f) { @@ -2331,173 +2336,166 @@ block_16: temp_a0 = &sp8C; sp8C = 0.0f; sp90 = 0.0f; - func_802B64C4(temp_a0, temp_s1_2->unk_02E + temp_s1_2->unk_0C0); - arg0->unk24 = sp8C; - arg0->unk28 = sp90; - arg0->unk2C = sp94; + func_802B64C4(temp_a0, (s16) (temp_s1_2->unk_02E + temp_s1_2->unk_0C0)); + shell->velocity[0] = sp8C; + shell->velocity[1] = sp90; + shell->velocity[2] = sp94; return; } - temp_f10 = sins(arg0->unk12) * 8.0f; - sp8C = temp_f10; - temp_f4 = arg0->unkC - temp_s1_2->unk_070; - sp90 = temp_f4; - sp94 = coss(arg0->unk12) * 8.0f; + sp8C = sins((u16) shell->rotAngle) * 8.0f; + sp90 = shell->unk_0C - temp_s1_2->unk_070; + sp94 = coss((u16) shell->rotAngle) * 8.0f; func_802B63B8(&sp8C, temp_s1_2->unk_174); - arg0->unk18 = temp_f10 + temp_s1_2->posX; - arg0->unk1C = temp_f4 + temp_s1_2->posY; - arg0->unk20 = sp94 + temp_s1_2->posZ; + shell->pos[0] = sp8C + temp_s1_2->pos[0]; + shell->pos[1] = sp90 + temp_s1_2->pos[1]; + shell->pos[2] = sp94 + temp_s1_2->pos[2]; return; case 2: - temp_t7 = arg0->unk14; - arg0->unk4 = arg0->unk4 - 1; - if (arg0->unk4 == 0) { - arg0->unk2 = arg0->unk2 & 0xEFFF; - if (arg0->unk0 == 0x2A) { - arg0->unk6 = 8; - arg0->unk4 = gPlayerPositionLUT; - arg0->unk8 = 1000.0f; + shell->parentIndex += -1; + temp_s1_3 = &gPlayers[shell->playerId]; + if (shell->parentIndex == 0) { + shell->unk_02 &= 0xEFFF; + if (shell->type == 0x002A) { + shell->state = 8; + shell->parentIndex = gPlayerPositionLUT; + shell->unk_08 = 1000.0f; temp_v1_2 = D_80164430; - temp_v0_2 = *(&D_80164438 + (((&gPlayers[temp_t7] - gPlayerOne) / 3544) * 2)) + 8; + temp_v0_2 = *(&D_80164438 + (((s32) (temp_s1_3 - gPlayerOne) / 3544) * 2)) + 8; phi_v0_2 = temp_v0_2; - if (temp_v1_2 < temp_v0_2) { - phi_v0_2 = temp_v0_2 - temp_v1_2; + if ((s32) temp_v1_2 < temp_v0_2) { + phi_v0_2 = (s16) (temp_v0_2 - temp_v1_2); } - arg0->unk12 = phi_v0_2; - } else if (gModeSelection == BATTLE) { - arg0->unk8 = 1000.0f; - arg0->unk4 = func_802B3FD0(&gPlayers[temp_t7], arg0); - if (arg0->unk4 < 0) { - arg0->unk2 = -0x8000; - arg0->unk12 = 0; - arg0->unk4 = 0x3C; - arg0->unk6 = 7; - arg0->unk28 = 3.0f; + shell->rotAngle = phi_v0_2; + } else if (gModeSelection == (s32) 3) { + shell->unk_08 = 1000.0f; + shell->parentIndex = func_802B3FD0(temp_s1_3, shell); + if (shell->parentIndex < 0) { + shell->unk_02 = -0x8000; + shell->rotAngle = 0; + shell->parentIndex = 0x003C; + shell->state = 7; + shell->velocity[1] = 3.0f; } else { - arg0->unk6 = 3; + shell->state = 3; } } else { - temp_v0_3 = gPlayers[temp_t7].unk_004; + temp_v0_3 = temp_s1_3->currentRank; if (temp_v0_3 == 0) { - arg0->unk6 = 4; - arg0->unk4 = 0x258; + shell->state = 4; + shell->parentIndex = 0x0258; temp_v1_3 = D_80164430; - temp_v0_4 = *(&D_80164438 + (((&gPlayers[temp_t7] - gPlayerOne) / 3544) * 2)) + 8; + temp_v0_4 = *(&D_80164438 + (((s32) (temp_s1_3 - gPlayerOne) / 3544) * 2)) + 8; phi_v0_3 = temp_v0_4; - if (temp_v1_3 < temp_v0_4) { - phi_v0_3 = temp_v0_4 - temp_v1_3; + if ((s32) temp_v1_3 < temp_v0_4) { + phi_v0_3 = (s16) (temp_v0_4 - temp_v1_3); } - arg0->unk12 = phi_v0_3; + shell->rotAngle = phi_v0_3; } else if (temp_v0_3 >= 5) { - arg0->unk6 = 5; - arg0->unk8 = 1000.0f; + shell->state = 5; + shell->unk_08 = 1000.0f; temp_v1_4 = D_80164430; - temp_v0_5 = *(&D_80164438 + (((&gPlayers[temp_t7] - gPlayerOne) / 3544) * 2)) + 8; + temp_v0_5 = *(&D_80164438 + (((s32) (temp_s1_3 - gPlayerOne) / 3544) * 2)) + 8; phi_v0_4 = temp_v0_5; - if (temp_v1_4 < temp_v0_5) { - phi_v0_4 = temp_v0_5 - temp_v1_4; + if ((s32) temp_v1_4 < temp_v0_5) { + phi_v0_4 = (s16) (temp_v0_5 - temp_v1_4); } - arg0->unk12 = phi_v0_4; - arg0->unk4 = (&gPlayerPositionLUT)[gPlayers[temp_t7].unk_004].unk-2; + shell->rotAngle = phi_v0_4; + shell->parentIndex = (&gPlayerPositionLUT)[temp_s1_3->currentRank].unk-2; } else { - arg0->unk6 = 3; - arg0->unk8 = 1000.0f; - arg0->unk4 = (&gPlayerPositionLUT)[gPlayers[temp_t7].unk_004].unk-2; + shell->state = 3; + shell->unk_08 = 1000.0f; + shell->parentIndex = (&gPlayerPositionLUT)[temp_s1_3->currentRank].unk-2; } } } - arg0->unk28 = arg0->unk28 - 0.5; - if (arg0->unk28 < -2.0f) { - arg0->unk28 = -2.0f; + shell->velocity[1] = (f32) ((f64) shell->velocity[1] - 0.5); + if (shell->velocity[1] < -2.0f) { + shell->velocity[1] = -2.0f; } - sp38 = arg0->unk18; - sp3C = arg0->unk1C; - sp40 = arg0->unk20; - arg0->unk18 = arg0->unk18 + arg0->unk24; - arg0->unk1C = arg0->unk1C + arg0->unk28; - arg0->unk20 = arg0->unk20 + arg0->unk2C; - func_802AD950(arg0 + 0x30, 0x40800000, arg0->unk18, arg0->unk1C, arg0->unk20, sp38, sp3C, sp40); - func_802B4E30(arg0); - func_802B4104(arg0); + sp38 = shell->pos[0]; + sp3C = shell->pos[1]; + sp40 = shell->pos[2]; + shell->pos[0] += shell->velocity[0]; + shell->pos[1] += shell->velocity[1]; + shell->pos[2] += shell->velocity[2]; + func_802AD950(&shell->unk30, 0x40800000, shell->pos[0], shell->pos[1], shell->pos[2], sp38, sp3C, sp40); + func_802B4E30(shell); + func_802B4104(shell); return; case 3: - func_802B3E7C(arg0, &gPlayers[arg0->unk4]); + func_802B3E7C(shell, &gPlayers[shell->parentIndex]); return; case 4: - func_802B3B44(arg0); - temp_v0_6 = arg0->unk4; + func_802B3B44(shell); + temp_v0_6 = shell->parentIndex; if (temp_v0_6 == 0) { - if ((arg0->unk2 & 0xF) == 0) { - func_8029FDC8((bitwise f32) arg0); + if ((shell->unk_02 & 0xF) == 0) { + func_8029FDC8((bitwise f32) shell); return; } - arg0->unk4 = temp_v0_6 - 1; + shell->parentIndex = temp_v0_6 - 1; return; } - /* Duplicate return node #73. Try simplifying control flow for better match */ - return; + break; case 5: - func_802B3B44(arg0); - temp_t4_2 = arg0->unk4; - temp_f0_3 = gPlayers[temp_t4_2].posX - arg0->unk18; - temp_f2_4 = gPlayers[temp_t4_2].posZ - arg0->unk20; + func_802B3B44(shell); + temp_s1_4 = &gPlayers[shell->parentIndex]; + temp_f0_3 = temp_s1_4->pos[0] - shell->pos[0]; + temp_f2_4 = temp_s1_4->pos[2] - shell->pos[2]; if (((temp_f0_3 * temp_f0_3) + (temp_f2_4 * temp_f2_4)) < D_802B9F98) { - arg0->unk6 = 3; + shell->state = 3; return; } - /* Duplicate return node #73. Try simplifying control flow for better match */ - return; + break; case 6: - temp_v0_7 = (arg0->unk4 * 0x70) + &D_8015F9B8; - temp_s1_3 = &gPlayers[arg0->unk14]; - if (temp_v0_7->unk0 != 0x16) { - func_8029FDC8((bitwise f32) arg0); + temp_v0_7 = &D_8015F9B8[shell->parentIndex]; + temp_s1_5 = &gPlayers[shell->playerId]; + if (temp_v0_7->type != 0x0016) { + func_8029FDC8((bitwise f32) shell); return; } - temp_t6 = arg0->unk12 + temp_v0_7->unk10; - arg0->unk12 = temp_t6; + temp_t6 = shell->rotAngle + temp_v0_7->rotVelocity; + shell->rotAngle = temp_t6; sp8C = sins(temp_t6 & 0xFFFF) * 8.0f; - sp90 = arg0->unkC - temp_s1_3->unk_070; - sp94 = coss(arg0->unk12) * 8.0f; - func_802B63B8(&sp8C, temp_s1_3->unk_174); - sp38 = arg0->unk18; - sp3C = arg0->unk1C; - sp40 = arg0->unk20; - arg0->unk18 = sp8C + temp_s1_3->posX; - arg0->unk1C = sp90 + temp_s1_3->posY; - arg0->unk20 = sp94 + temp_s1_3->posZ; - func_802AD950(arg0 + 0x30, 0x40800000, arg0->unk18, arg0->unk1C, arg0->unk20, sp38, sp3C, sp40); - func_802B4E30(arg0); + sp90 = shell->unk_0C - temp_s1_5->unk_070; + sp94 = coss((u16) shell->rotAngle) * 8.0f; + func_802B63B8(&sp8C, temp_s1_5->unk_174); + sp38 = shell->pos[0]; + sp3C = shell->pos[1]; + sp40 = shell->pos[2]; + shell->pos[0] = sp8C + temp_s1_5->pos[0]; + shell->pos[1] = sp90 + temp_s1_5->pos[1]; + shell->pos[2] = sp94 + temp_s1_5->pos[2]; + func_802AD950(&shell->unk30, 0x40800000, shell->pos[0], shell->pos[1], shell->pos[2], sp38, sp3C, sp40); + func_802B4E30(shell); return; case 7: - arg0->unk28 = arg0->unk28 - D_802B9F9C; - if (arg0->unk28 < -5.0f) { - arg0->unk28 = -5.0f; + shell->velocity[1] -= D_802B9F9C; + if (shell->velocity[1] < -5.0f) { + shell->velocity[1] = -5.0f; } - arg0->unk4 = arg0->unk4 - 1; - arg0->unk12 = arg0->unk12 + 0x5B0; - arg0->unk1C = arg0->unk1C + arg0->unk28; - if (arg0->unk4 == 0) { - func_8029E854(-5.0f, arg0); + shell->parentIndex += -1; + shell->rotAngle += 0x5B0; + shell->pos[1] += shell->velocity[1]; + if (shell->parentIndex == 0) { + func_8029E854(-5.0f, shell); return; } - /* Duplicate return node #73. Try simplifying control flow for better match */ - return; + break; case 8: - func_802B3B44(arg0); - arg0->unk4 = gPlayerPositionLUT; - temp_t3 = gPlayerPositionLUT; - temp_f0_4 = gPlayers[temp_t3].posX - arg0->unk18; - temp_f2_5 = gPlayers[temp_t3].posZ - arg0->unk20; + func_802B3B44(shell); + shell->parentIndex = gPlayerPositionLUT; + temp_s1_6 = &gPlayers[gPlayerPositionLUT]; + temp_f0_4 = temp_s1_6->pos[0] - shell->pos[0]; + temp_f2_5 = temp_s1_6->pos[2] - shell->pos[2]; if (((temp_f0_4 * temp_f0_4) + (temp_f2_5 * temp_f2_5)) < D_802B9FA0) { - arg0->unk6 = 9; + shell->state = 9; return; } - /* Duplicate return node #73. Try simplifying control flow for better match */ - return; + break; case 9: - func_802B3E7C(arg0, &gPlayers[arg0->unk4]); - /* Duplicate return node #73. Try simplifying control flow for better match */ - return; + func_802B3E7C(shell, &gPlayers[shell->parentIndex]); + break; } } #else