From ee4e186def6306944461ef20cfa0f34ce7b1e40e Mon Sep 17 00:00:00 2001 From: petrie911 Date: Mon, 24 Oct 2022 14:33:10 -0500 Subject: [PATCH] some docs. still baffling --- include/macros.h | 4 + src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c | 1040 +++++++++-------- src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h | 91 +- tools/disasm/functions.txt | 84 +- 4 files changed, 624 insertions(+), 595 deletions(-) diff --git a/include/macros.h b/include/macros.h index ad963153f..5dc4ca943 100644 --- a/include/macros.h +++ b/include/macros.h @@ -129,6 +129,7 @@ extern GraphicsContext* __gfxCtx; #define ALIGN256(val) (((val) + 0xFF) & ~0xFF) #define SQ(x) ((x) * (x)) +#define CUBE(x) ((x) * (x) * (x)) #define ABS(x) ((x) >= 0 ? (x) : -(x)) #define ABS_ALT(x) ((x) < 0 ? -(x) : (x)) #define DECR(x) ((x) == 0 ? 0 : --(x)) @@ -137,6 +138,9 @@ extern GraphicsContext* __gfxCtx; #define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x)) #define CLAMP_MIN(x, min) ((x) < (min) ? (min) : (x)) +#define RAND_BITS(n) ((s32)Rand_Next() >> (0x20 - n)) +#define RANDU_BITS(n) (Rand_Next() >> (0x20 - n)) + #define ROUND(x) (s32)(((x) >= 0.0) ? ((x) + 0.5) : ((x) - 0.5)) #define SWAP(type, a, b) \ diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c index 9e894807b..d83a4a04f 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.c @@ -14,28 +14,27 @@ void ObjMine_Init(Actor* thisx, PlayState* play); void ObjMine_Destroy(Actor* thisx, PlayState* play); -void ObjMine_Update(Actor* thisx, PlayState* play); -void ObjMine_Draw(Actor* thisx, PlayState* play); +void ObjMine_Path_Update(Actor* thisx, PlayState* play); +void ObjMine_Path_Draw(Actor* thisx, PlayState* play); -void func_80A82F84(ObjMine* this); -void func_80A82F98(ObjMine* this, PlayState* play); -void func_80A82FA8(ObjMine* this); -void func_80A82FC8(ObjMine* this, PlayState* play); -void func_80A83258(ObjMine* this, PlayState* play); -void func_80A832BC(ObjMine* this); -void func_80A832D0(ObjMine* this, PlayState* play); -void func_80A83A74(ObjMine* this); -void func_80A83A88(ObjMine* this, PlayState* play); -void func_80A83B14(ObjMine* this); -void func_80A83B28(ObjMine* this, PlayState* play); -void func_80A83CEC(ObjMine* this); -void func_80A83D00(ObjMine* this, PlayState* play); -void func_80A83E7C(Actor* thisx, PlayState* play); -void func_80A83FBC(Actor* thisx, PlayState* play); -void func_80A84088(Actor* thisx, PlayState* play); -void func_80A84338(Actor* thisx, PlayState* play); +void ObjMine_Path_SetupStationary(ObjMine* this); +void ObjMine_Path_Stationary(ObjMine* this, PlayState* play); +void ObjMine_Path_SetupMove(ObjMine* this); +void ObjMine_Path_Move(ObjMine* this, PlayState* play); +void ObjMine_Explode(ObjMine* this, PlayState* play); +void ObjMine_Air_SetupChained(ObjMine* this); +void ObjMine_Air_Chained(ObjMine* this, PlayState* play); +void ObjMine_Air_SetupStationary(ObjMine* this); +void ObjMine_Air_Stationary(ObjMine* this, PlayState* play); +void ObjMine_Water_SetupChained(ObjMine* this); +void ObjMine_Water_Chained(ObjMine* this, PlayState* play); +void ObjMine_Water_SetupStationary(ObjMine* this); +void ObjMine_Water_Stationary(ObjMine* this, PlayState* play); -static Vec3f D_80A849D0[0x40]; +void ObjMine_AirWater_Update(Actor* thisx, PlayState* play); +void ObjMine_DrawExplosion(Actor* thisx, PlayState* play); +void ObjMine_Air_Draw(Actor* thisx, PlayState* play); +void ObjMine_Water_Draw(Actor* thisx, PlayState* play); ActorInit Obj_Mine_InitVars = { ACTOR_OBJ_MINE, @@ -45,8 +44,8 @@ ActorInit Obj_Mine_InitVars = { sizeof(ObjMine), (ActorFunc)ObjMine_Init, (ActorFunc)ObjMine_Destroy, - (ActorFunc)ObjMine_Update, - (ActorFunc)ObjMine_Draw, + (ActorFunc)ObjMine_Path_Update, + (ActorFunc)ObjMine_Path_Draw, }; static ColliderJntSphElementInit sJntSphElementsInit[1] = { @@ -76,13 +75,12 @@ static ColliderJntSphInit sJntSphInit = { sJntSphElementsInit, }; -static f32 D_80A845A4[] = { +static f32 sPathSpeeds[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, }; -static Vec3f D_80A845C4 = { 1.0f, 0.0f, 0.0f }; - -static Vec3f D_80A845D0[] = { +static ObjMineMtxF3 sStandardBasis = { + { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f }, }; @@ -94,61 +92,61 @@ static InitChainEntry sInitChain[] = { ICHAIN_VEC3F_DIV1000(scale, 10, ICHAIN_STOP), }; -void func_80A811D0(ObjMine* this, s32 arg1) { - Math_Vec3s_ToVec3f(&this->actor.world.pos, &this->unk_1B4[arg1]); +void ObjMine_Path_MoveToWaypoint(ObjMine* this, s32 index) { + Math_Vec3s_ToVec3f(&this->actor.world.pos, &this->waypoints[index]); } -s32 func_80A8120C(Vec3f* arg0, Vec3f* arg1) { - f32 temp_f0 = Math3D_Vec3fMagnitude(arg0); +s32 ObjMine_GetUnitVec3f(Vec3f* src, Vec3f* dst) { + f32 temp_f0 = Math3D_Vec3fMagnitude(src); if (temp_f0 < 0.001f) { return false; } - arg1->x = arg0->x * (1.0f / temp_f0); - arg1->y = arg0->y * (1.0f / temp_f0); - arg1->z = arg0->z * (1.0f / temp_f0); + dst->x = src->x * (1.0f / temp_f0); + dst->y = src->y * (1.0f / temp_f0); + dst->z = src->z * (1.0f / temp_f0); return true; } -s32 func_80A81288(Vec3f* arg0, Vec3f* arg1, f32* arg2, f32* arg3) { - f32 temp_f0 = Math3D_Vec3fMagnitude(arg0); +s32 ObjMine_GetUnitVec3fNorm(Vec3f* src, Vec3f* dst, f32* norm, f32* invNorm) { + f32 magnitude = Math3D_Vec3fMagnitude(src); - if (temp_f0 < 0.001f) { + if (magnitude < 0.001f) { return false; } - arg1->x = arg0->x * (1.0f / temp_f0); - arg1->y = arg0->y * (1.0f / temp_f0); - arg1->z = arg0->z * (1.0f / temp_f0); - *arg2 = temp_f0; - *arg3 = 1.0f / temp_f0; + dst->x = src->x * (1.0f / magnitude); + dst->y = src->y * (1.0f / magnitude); + dst->z = src->z * (1.0f / magnitude); + *norm = magnitude; + *invNorm = 1.0f / magnitude; return true; } -void func_80A8131C(ObjMine* this, PlayState* play) { +void ObjMine_Path_SpawnBomb(ObjMine* this, PlayState* play) { EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, this->actor.world.pos.x, - this->actor.world.pos.y - 15.0f, this->actor.world.pos.z, 0, 0, 0, 0); + this->actor.world.pos.y - 15.0f, this->actor.world.pos.z, 0, 0, 0, ENBOM_0); if (bomb != NULL) { bomb->timer = 0; } } -void func_80A81384(ObjMine* this, PlayState* play) { +void ObjMine_AirWater_SpawnBomb(ObjMine* this, PlayState* play) { f32 x = this->collider.elements[0].dim.worldSphere.center.x; f32 y = this->collider.elements[0].dim.worldSphere.center.y - 15.0f; f32 z = this->collider.elements[0].dim.worldSphere.center.z; - EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, x, y, z, 0, 0, 0, 0); + EnBom* bomb = (EnBom*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_BOM, x, y, z, 0, 0, 0, ENBOM_0); if (bomb != NULL) { bomb->timer = 0; } } -s32 func_80A8140C(ObjMine* this) { +s32 ObjMine_AirWater_CheckOC(ObjMine* this) { if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { return true; } @@ -164,79 +162,80 @@ s32 func_80A8140C(ObjMine* this) { return false; } -void func_80A8146C(ObjMine* this, s16* arg1, s16* arg2) { - s32 pad2[3]; - Vec3f sp40; +void ObjMine_Air_CheckAC(ObjMine* this, s16* arg1, s16* arg2) { + s32 pad[2]; + Vec3s* centerPos3s = &this->collider.elements[0].dim.worldSphere.center; + Vec3f centerPos; s16 sp3E; - s16 pad; - Actor* temp_s0 = this->collider.base.ac; + Actor* attackActor = this->collider.base.ac; - Math_Vec3s_ToVec3f(&sp40, &this->collider.elements[0].dim.worldSphere.center); - sp3E = Math_Vec3f_Yaw(&temp_s0->world.pos, &sp40); + Math_Vec3s_ToVec3f(¢erPos, centerPos3s); + sp3E = Math_Vec3f_Yaw(&attackActor->world.pos, ¢erPos); + // dmgFlag check is (DMG_DEKU_BUBBLE | DMG_FIRE_ARROW | DMG_ICE_ARROW | DMG_FIRE_ARROW | DMG_NORMAL_ARROW) if (this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x13820) { - *arg1 = temp_s0->shape.rot.y; - *arg2 = temp_s0->shape.rot.y - sp3E; + *arg1 = attackActor->shape.rot.y; + *arg2 = attackActor->shape.rot.y - sp3E; } else { - Vec3f sp2C; - Vec3s* hitPos = &this->collider.elements[0].info.bumper.hitPos; + Vec3f hitPos; + Vec3s* hitPos3s = &this->collider.elements[0].info.bumper.hitPos; - Math_Vec3s_ToVec3f(&sp2C, hitPos); - *arg1 = Actor_YawBetweenActors(temp_s0, &this->actor); - *arg2 = Math_Vec3f_Yaw(&temp_s0->world.pos, &sp2C) - sp3E; + Math_Vec3s_ToVec3f(&hitPos, hitPos3s); + *arg1 = Actor_YawBetweenActors(attackActor, &this->actor); + *arg2 = Math_Vec3f_Yaw(&attackActor->world.pos, &hitPos) - sp3E; } } -void func_80A81544(ObjMine* this, Vec3f* arg1) { - Actor* ac = this->collider.base.ac; +void ObjMine_Water_CheckAC(ObjMine* this, Vec3f* arg1) { + Actor* attackActor = this->collider.base.ac; // dmgFlag check is (DMG_DEKU_BUBBLE | DMG_FIRE_ARROW | DMG_ICE_ARROW | DMG_FIRE_ARROW | DMG_NORMAL_ARROW) if ((this->collider.elements[0].info.acHitInfo->toucher.dmgFlags & 0x13820)) { Matrix_Push(); - Matrix_RotateYS(ac->shape.rot.y, MTXMODE_NEW); - Matrix_RotateXS(ac->shape.rot.x, MTXMODE_APPLY); + Matrix_RotateYS(attackActor->shape.rot.y, MTXMODE_NEW); + Matrix_RotateXS(attackActor->shape.rot.x, MTXMODE_APPLY); Matrix_MultVecZ(1.0f, arg1); Matrix_Pop(); } else { - Vec3f sp20; + Vec3f sp20; Sphere16* sphere = &this->collider.elements[0].dim.worldSphere; - sp20.x = sphere->center.x - ac->world.pos.x; - sp20.y = sphere->center.y - ac->world.pos.y; - sp20.z = sphere->center.z - ac->world.pos.z; - if (!func_80A8120C(&sp20, arg1)) { - Math_Vec3f_Copy(arg1, &D_80A845D0[0]); + sp20.x = sphere->center.x - attackActor->world.pos.x; + sp20.y = sphere->center.y - attackActor->world.pos.y; + sp20.z = sphere->center.z - attackActor->world.pos.z; + if (!ObjMine_GetUnitVec3f(&sp20, arg1)) { + Math_Vec3f_Copy(arg1, &sStandardBasis.y); } } } -void func_80A81640(ObjMine* this) { +void ObjMine_AirWater_Noop(ObjMine* this) { } -void func_80A8164C(Vec3f* arg0) { +void ObjMine_ReplaceTranslation(Vec3f* translation) { MtxF* matrix = Matrix_GetCurrent(); - matrix->mf[3][0] = arg0->x; - matrix->mf[3][1] = arg0->y; - matrix->mf[3][2] = arg0->z; + matrix->mf[3][0] = translation->x; + matrix->mf[3][1] = translation->y; + matrix->mf[3][2] = translation->z; } -void func_80A81684(ObjMineMtxF3* arg0) { +void ObjMine_ReplaceRotation(ObjMineMtxF3* rotation) { MtxF* matrix = Matrix_GetCurrent(); - matrix->mf[0][0] = arg0->x.x; - matrix->mf[0][1] = arg0->x.y; - matrix->mf[0][2] = arg0->x.z; + matrix->mf[0][0] = rotation->x.x; + matrix->mf[0][1] = rotation->x.y; + matrix->mf[0][2] = rotation->x.z; matrix->mf[0][3] = 0.0f; - matrix->mf[1][0] = arg0->y.x; - matrix->mf[1][1] = arg0->y.y; - matrix->mf[1][2] = arg0->y.z; + matrix->mf[1][0] = rotation->y.x; + matrix->mf[1][1] = rotation->y.y; + matrix->mf[1][2] = rotation->y.z; matrix->mf[1][3] = 0.0f; - matrix->mf[2][0] = arg0->z.x; - matrix->mf[2][1] = arg0->z.y; - matrix->mf[2][2] = arg0->z.z; + matrix->mf[2][0] = rotation->z.x; + matrix->mf[2][1] = rotation->z.y; + matrix->mf[2][2] = rotation->z.z; matrix->mf[2][3] = 0.0f; matrix->mf[3][0] = 0.0f; @@ -245,263 +244,267 @@ void func_80A81684(ObjMineMtxF3* arg0) { matrix->mf[3][3] = 1.0f; } -s32 func_80A81714(Vec3f* arg0, Vec3f* arg1, f32 arg2) { +s32 ObjMine_StepUntilParallel(Vec3f* value, Vec3f* target, f32 angleStep) { Vec3f sp3C; Vec3f sp30; Vec3f sp24; - f32 sp20 = Math3D_Parallel(arg0, arg1); + f32 sp20 = Math3D_Parallel(value, target); - if (cos_rad(arg2) <= sp20) { - Math_Vec3f_Copy(arg0, arg1); + if (cos_rad(angleStep) <= sp20) { + Math_Vec3f_Copy(value, target); return true; } Matrix_Push(); - Math_Vec3f_Copy(&sp30, arg0); - Math3D_CrossProduct(arg0, arg1, &sp3C); - if (func_80A8120C(&sp3C, &sp24)) { - Matrix_RotateAxisS(RADF_TO_BINANG(arg2), &sp24, MTXMODE_NEW); - Matrix_MultVec3f(&sp30, arg0); + Math_Vec3f_Copy(&sp30, value); + Math3D_CrossProduct(value, target, &sp3C); + if (ObjMine_GetUnitVec3f(&sp3C, &sp24)) { + Matrix_RotateAxisS(RADF_TO_BINANG(angleStep), &sp24, MTXMODE_NEW); + Matrix_MultVec3f(&sp30, value); } else { - Matrix_RotateXFNew(arg2); - Matrix_MultVec3f(&sp30, arg0); + Matrix_RotateXFNew(angleStep); + Matrix_MultVec3f(&sp30, value); } Matrix_Pop(); return false; } -void func_80A81818(ObjMine* this) { - this->collider.elements->dim.worldSphere.center.x = this->actor.world.pos.x; - this->collider.elements->dim.worldSphere.center.y = this->actor.world.pos.y; - this->collider.elements->dim.worldSphere.center.z = this->actor.world.pos.z; +void ObjMine_UpdateCollider(ObjMine* this) { + this->collider.elements[0].dim.worldSphere.center.x = this->actor.world.pos.x; + this->collider.elements[0].dim.worldSphere.center.y = this->actor.world.pos.y; + this->collider.elements[0].dim.worldSphere.center.z = this->actor.world.pos.z; } -void func_80A81868(ObjMine* this, s32 arg1) { +void ObjMine_Air_InitChain(ObjMine* this, s32 linkCount) { + f32 arg1f = linkCount; + ObjMineAirChain* chain1 = &this->chain.air; + ObjMineAirLink* link1; s32 i; - ObjMineUnkStruct* ptr = &this->chain1; - ObjMineUnkStruct3* unkStruct; - f32 arg = arg1; f32 temp_f12 = this->actor.home.rot.z * 5.0f; - ptr->unk_00.x.x = 1.0f; - ptr->unk_00.y.y = 1.0f; - ptr->unk_00.z.z = 1.0f; - ptr->unk_24.y = 1.0f; + chain1->basis.x.x = 1.0f; + chain1->basis.y.y = 1.0f; + chain1->basis.z.z = 1.0f; + chain1->unk_24.y = 1.0f; - if (arg1 > 0) { - ptr->unk_40 = -sqrtf(0.001984f / arg); // approx 1/504 = 1/8 * 1/63 - ptr->unk_44 = (0.00031746097f * arg) + 0.95f; // approx 1/3150 = 1/50 * 1/63 + if (linkCount > 0) { + chain1->unk_40 = -sqrtf(0.001984f / arg1f); // approx 1/504 = 1/8 * 1/63 + chain1->unk_44 = 0.95f + (0.00031746097f * arg1f); // approx 1/3150 = 1/50 * 1/63 } - ptr->unk_58 = 0.0002f; + chain1->unk_58 = 0.0002f; - for (i = 0, unkStruct = ptr->unk_60; i < arg1; i++, unkStruct++) { - unkStruct->unk_00 = 0x4000; + for (i = 0, link1 = chain1->links; i < linkCount; i++, link1++) { + link1->unk_00 = 0x4000; } if (temp_f12 < 0.0f) { - ptr->unk_5C = -1.0f; + chain1->unk_5C = -1.0f; } else if (temp_f12 <= 21.0f) { - ptr->unk_5C = 0.0f; + chain1->unk_5C = 0.0f; } else { - ptr->unk_5C = SQ(temp_f12 - 20.0f); + chain1->unk_5C = SQ(temp_f12 - 20.0f); } } -void func_80A819A4(ObjMine* this, s32 arg1) { +void ObjMine_Air_SetCollider(ObjMine* this, s32 linkCount) { Matrix_Translate(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); } -void func_80A81A00(ObjMine* this) { - ObjMineUnkStruct* ptr = &this->chain1; +void ObjMine_Air_SetBasis(ObjMine* this) { + ObjMineAirChain* chain1 = &this->chain.air; Vec3f sp28; - sp28.x = -ptr->unk_30; + sp28.x = -chain1->unk_30; sp28.y = 1.0f; - sp28.z = -ptr->unk_34; + sp28.z = -chain1->unk_34; - func_80A8120C(&sp28, &ptr->unk_00.y); - Math3D_CrossProduct(&D_80A845C4, &ptr->unk_00.y, &sp28); - func_80A8120C(&sp28, &ptr->unk_00.z); - Math3D_CrossProduct(&ptr->unk_00.y, &ptr->unk_00.z, &sp28); - func_80A8120C(&sp28, &ptr->unk_00.x); + ObjMine_GetUnitVec3f(&sp28, &chain1->basis.y); + Math3D_CrossProduct(&sStandardBasis.x, &chain1->basis.y, &sp28); + ObjMine_GetUnitVec3f(&sp28, &chain1->basis.z); + Math3D_CrossProduct(&chain1->basis.y, &chain1->basis.z, &sp28); + ObjMine_GetUnitVec3f(&sp28, &chain1->basis.x); } -void func_80A81AA4(ObjMine* this) { - s32 params = OBJMINE_GET_PARAM_003F(&this->actor); - f32 temp_f0 = -((params * 12.0f) + 10.0f); +void ObjMine_Air_SetWorld(ObjMine* this) { + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); + f32 temp_f0 = 10.0f + (linkCount * 12.0f); - this->actor.world.pos.x = (this->chain1.unk_00.y.x * temp_f0) + this->actor.home.pos.x; - this->actor.world.pos.y = (this->chain1.unk_00.y.y * temp_f0) + this->actor.home.pos.y; - this->actor.world.pos.z = (this->chain1.unk_00.y.z * temp_f0) + this->actor.home.pos.z; + this->actor.world.pos.x = (this->chain.air.basis.y.x * -temp_f0) + this->actor.home.pos.x; + this->actor.world.pos.y = (this->chain.air.basis.y.y * -temp_f0) + this->actor.home.pos.y; + this->actor.world.pos.z = (this->chain.air.basis.y.z * -temp_f0) + this->actor.home.pos.z; } -void func_80A81B14(ObjMine* this) { - s32 params = OBJMINE_GET_PARAM_003F(&this->actor); - f32 temp_f0 = 1.0f / ((params * 12.0f) + 10.0f); - f32 x = this->actor.world.pos.x - this->actor.home.pos.x; - f32 z = this->actor.world.pos.z - this->actor.home.pos.z; +void ObjMine_Air_SetChain3034(ObjMine* this) { + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); + f32 temp_f0 = 1.0f / (10.0f + (linkCount * 12.0f)); + f32 dx = this->actor.world.pos.x - this->actor.home.pos.x; + f32 dz = this->actor.world.pos.z - this->actor.home.pos.z; - this->chain1.unk_30 = x * temp_f0; - this->chain1.unk_34 = z * temp_f0; + this->chain.air.unk_30 = dx * temp_f0; + this->chain.air.unk_34 = dz * temp_f0; } -void func_80A81B7C(ObjMine* this, s32 arg1) { - ObjMineTestStruct2* ptr = &this->chain2; - ObjMineUnkStruct2* unkStruct; +void ObjMine_Water_InitChain(ObjMine* this, s32 linkCount) { + ObjMineWaterChain* chain2 = &this->chain.water; + ObjMineWaterLink* link2; s32 i; f32 sp58 = this->actor.home.rot.z * 5.0f; f32 temp_f24; f32 temp_f26; - ptr->unk_00 = 0.9f; - ptr->unk_1C = 0.003f; + chain2->unk_00 = 0.9f; + chain2->unk_1C = 0.003f; - ptr->unk_20 = Rand_Next() >> 0x13; - ptr->unk_24 = -0.0002f; - ptr->unk_30 = -0.0002f; + chain2->unk_20 = RANDU_BITS(13); + chain2->unk_24 = -0.0002f; + chain2->unk_30 = -0.0002f; - temp_f26 = ptr->unk_1C * 6.0f; + temp_f26 = chain2->unk_1C * 6.0f; temp_f24 = this->actor.home.pos.y; - unkStruct = ptr->unk_44; - for (i = 0; i < arg1; i++, unkStruct++) { + for (i = 0, link2 = chain2->links; i < linkCount; i++, link2++) { temp_f24 += 12.0f; - unkStruct->unk_00.x.x = 1.0f; - unkStruct->unk_00.y.y = 1.0f; - unkStruct->unk_00.z.z = 1.0f; - unkStruct->unk_24.x = this->actor.home.pos.x; - unkStruct->unk_24.y = temp_f24; - unkStruct->unk_24.z = this->actor.home.pos.z; - unkStruct->unk_30.x = (Rand_ZeroOne() - 0.5f) * temp_f26; - unkStruct->unk_30.y = (Rand_ZeroOne() - 0.5f) * temp_f26; - unkStruct->unk_30.z = (Rand_ZeroOne() - 0.5f) * temp_f26; + link2->basis.x.x = 1.0f; + link2->basis.y.y = 1.0f; + link2->basis.z.z = 1.0f; + link2->unk_24.x = this->actor.home.pos.x; + link2->unk_24.y = temp_f24; + link2->unk_24.z = this->actor.home.pos.z; + link2->unk_30.x = (Rand_ZeroOne() - 0.5f) * temp_f26; + link2->unk_30.y = (Rand_ZeroOne() - 0.5f) * temp_f26; + link2->unk_30.z = (Rand_ZeroOne() - 0.5f) * temp_f26; } - ptr->unk_28 = temp_f24; - ptr->unk_2C = temp_f24 * 0.97f; + chain2->unk_28 = temp_f24; + chain2->unk_2C = temp_f24 * 0.97f; temp_f24 -= 18.0f; - if (ptr->unk_2C < temp_f24) { - ptr->unk_2C = temp_f24; + if (chain2->unk_2C < temp_f24) { + chain2->unk_2C = temp_f24; } if (sp58 < 0.0f) { - ptr->unk_34 = -1.0f; + chain2->unk_34 = -1.0f; } else if (sp58 <= 37.0f) { - ptr->unk_34 = 0.0f; + chain2->unk_34 = 0.0f; } else { - ptr->unk_34 = SQ(sp58 - 36.0f); + chain2->unk_34 = SQ(sp58 - 36.0f); } } -void func_80A81D70(ObjMine* this, s32 arg1) { - Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y + (arg1 * 12.0f) + 10.0f, +void ObjMine_Water_SetCollider(ObjMine* this, s32 linkCount) { + Matrix_Translate(this->actor.home.pos.x, this->actor.home.pos.y + (linkCount * 12.0f) + 10.0f, this->actor.home.pos.z, MTXMODE_NEW); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); } -void func_80A81DEC(ObjMine* this) { - ObjMineTestStruct2* ptr = &this->chain2; +void ObjMine_Water_SetWorld(ObjMine* this) { s32 pad; - s32 temp_v0 = OBJMINE_GET_PARAM_003F(&this->actor); + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); + ObjMineWaterChain* chain2 = &this->chain.water; - - if (temp_v0 == 0) { + if (linkCount == 0) { this->actor.world.pos.y = this->actor.home.pos.y + 12.0f + 10.0f; } else { - ObjMineUnkStruct2* ptr2 = &ptr->unk_44[temp_v0 - 1]; + ObjMineWaterLink* link2 = &chain2->links[linkCount - 1]; Vec3f sp1C; - Math_Vec3f_ScaleAndStore(&ptr2->unk_00.y, 10.0f, &sp1C); - Math_Vec3f_Sum(&ptr2->unk_24, &sp1C, &this->actor.world.pos); + Math_Vec3f_ScaleAndStore(&link2->basis.y, 10.0f, &sp1C); + Math_Vec3f_Sum(&link2->unk_24, &sp1C, &this->actor.world.pos); } } void func_80A81E7C(ObjMine* this, PlayState* play) { - ObjMineTestStruct2* temp_v1 = &this->chain2; s32 pad; - Vec3f sp7C; - Vec3f sp70; - Vec3f sp64; - Vec3f sp58; - Vec3f sp4C; - CollisionPoly* sp48; - s32 sp44; - f32 sp40; - f32 sp3C; - - temp_v1->unk_40 = 0; - if ((-0.000001f < temp_v1->unk_34) && (temp_v1->unk_34 <= Math3D_XZDistanceSquared(this->actor.home.pos.x, this->actor.home.pos.z, + ObjMineWaterChain* chain2 = &this->chain.water; + + chain2->unk_40 = false; + if ((-0.000001f < chain2->unk_34) && (chain2->unk_34 <= Math3D_XZDistanceSquared(this->actor.home.pos.x, this->actor.home.pos.z, this->actor.world.pos.x, this->actor.world.pos.z))) { - sp58.x = this->actor.world.pos.x - this->actor.home.pos.x; - sp58.y = 0.0f; - sp58.z = this->actor.world.pos.z - this->actor.home.pos.z; - if (func_80A81288(&sp58, &sp4C, &sp40, &sp3C)) { - sp70.x = this->actor.world.pos.x + (sp4C.x * 36.0f); + Vec3f sp7C; + Vec3f sp70; + Vec3f sp64; + Vec3f xzDistFromHome; + Vec3f xzDirFromHome; + CollisionPoly* dummyPoly; + s32 dummyBgId; + f32 dummyNorm; + f32 dummyInvNorm; + + xzDistFromHome.x = this->actor.world.pos.x - this->actor.home.pos.x; + xzDistFromHome.y = 0.0f; + xzDistFromHome.z = this->actor.world.pos.z - this->actor.home.pos.z; + + if (ObjMine_GetUnitVec3fNorm(&xzDistFromHome, &xzDirFromHome, &dummyNorm, &dummyInvNorm)) { + + sp70.x = this->actor.world.pos.x + (xzDirFromHome.x * 36.0f); sp70.y = this->actor.world.pos.y; - sp70.z = this->actor.world.pos.z + (sp4C.z * 36.0f); + sp70.z = this->actor.world.pos.z + (xzDirFromHome.z * 36.0f); + sp7C.x = this->actor.home.pos.x; sp7C.y = this->actor.world.pos.y; sp7C.z = this->actor.home.pos.z; - if (BgCheck_EntityLineTest1(&play->colCtx, &sp7C, &sp70, &sp64, &sp48, 1, 0, 0, 1, &sp44)) { - temp_v1->unk_40 = 1; - temp_v1->unk_38 = sp4C.x * -0.2f; - temp_v1->unk_3C = sp4C.z * -0.2f; + + if (BgCheck_EntityLineTest1(&play->colCtx, &sp7C, &sp70, &sp64, &dummyPoly, 1, 0, 0, 1, &dummyBgId)) { + chain2->unk_40 = true; + chain2->unk_38 = xzDirFromHome.x * -0.2f; + chain2->unk_3C = xzDirFromHome.z * -0.2f; } } } } #ifdef NON_MATCHING -// Probably equivalent, but nightmare loop unrolls. +// Probably equivalent, but nightmare loop unrolls. void func_80A81FFC(ObjMine *this) { + static Vec3f D_80A849D0[0x40]; + ObjMineWaterChain *chain2 = &this->chain.water; + ObjMineWaterLink *link2; s32 i; - ObjMineTestStruct2 *temp_s1 = &this->chain2; - ObjMineUnkStruct2 *var_s0; - s32 temp_s6 = OBJMINE_GET_PARAM_003F(&this->actor); - s16 var_s3 = 0; - f32 temp_fs2 = 1.0f / (f32) temp_s6; + s16 var_s3; + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); + f32 invLinkCount = 1.0f / (f32) linkCount; + f32 temp_fs0 = (chain2->links[linkCount - 1].unk_24.y - chain2->unk_2C) * chain2->unk_30; Vec3f sp90; - f32 temp_fs0 = (temp_s1->unk_44[temp_s6 - 1].unk_24.y - temp_s1->unk_2C) * temp_s1->unk_30; f32 temp_ft4; - - for(i = 0, var_s0 = temp_s1->unk_44; i < temp_s6; i++, var_s0++) { - Math_Vec3f_Copy(&D_80A849D0[i], &var_s0->unk_3C); - if (var_s0->unk_24.y <= this->actor.home.pos.y) { - var_s0->unk_3C.y = temp_s1->unk_30 * -96.0f; + + for(i = 0, link2 = chain2->links, var_s3 = 0; i < linkCount; i++, link2++, var_s3 += chain2->unk_20) { + Math_Vec3f_Copy(&D_80A849D0[i], &link2->unk_3C); + if (link2->unk_24.y <= this->actor.home.pos.y) { + link2->unk_3C.y = chain2->unk_30 * -96.0f; } else if (temp_fs0 > 0.0f) { - var_s0->unk_3C.y = (i + 1) * temp_fs2 * (temp_fs0 / 0.3f); + link2->unk_3C.y = (i + 1) * invLinkCount * (temp_fs0 / 0.3f); } else { - var_s0->unk_3C.y = temp_fs0; + link2->unk_3C.y = temp_fs0; } - var_s0->unk_3C.x = (var_s0->unk_24.x - this->actor.home.pos.x) * temp_s1->unk_24; - var_s0->unk_3C.z = (var_s0->unk_24.z - this->actor.home.pos.z) * temp_s1->unk_24; - var_s0->unk_3C.x += temp_s1->unk_14 * Math_SinS(var_s3); - var_s0->unk_3C.y += temp_s1->unk_18; - var_s0->unk_3C.z += temp_s1->unk_14 * Math_CosS(var_s3); - var_s3 += temp_s1->unk_20; + link2->unk_3C.x = (link2->unk_24.x - this->actor.home.pos.x) * chain2->unk_24; + link2->unk_3C.z = (link2->unk_24.z - this->actor.home.pos.z) * chain2->unk_24; + link2->unk_3C.x += chain2->unk_14 * Math_SinS(var_s3); + link2->unk_3C.y += chain2->unk_18; + link2->unk_3C.z += chain2->unk_14 * Math_CosS(var_s3); } - if (temp_s1->unk_10 > 0.0001f) { - for(i = 0, var_s0 = temp_s1->unk_44; i < temp_s6; i++, var_s0++) { - temp_ft4 = SQ((temp_s6 - i) * temp_fs2); - var_s0->unk_3C.x += temp_s1->unk_04.x * temp_ft4; - var_s0->unk_3C.y += temp_s1->unk_04.y * temp_ft4; - var_s0->unk_3C.z += temp_s1->unk_04.z * temp_ft4; + if (chain2->unk_10 > 0.0001f) { + for(i = 0, link2 = chain2->links; i < linkCount; i++, link2++) { + temp_ft4 = SQ((linkCount - i) * invLinkCount); + + link2->unk_3C.x += chain2->unk_04.x * temp_ft4; + link2->unk_3C.y += chain2->unk_04.y * temp_ft4; + link2->unk_3C.z += chain2->unk_04.z * temp_ft4; } } - if (temp_s1->unk_40) { - for(i = 0, var_s0 = temp_s1->unk_44; i < temp_s6; i++, var_s0++) { - var_s0->unk_3C.x += temp_s1->unk_38; - var_s0->unk_3C.z += temp_s1->unk_3C; + if (chain2->unk_40) { + for(i = 0, link2 = chain2->links; i < linkCount; i++, link2++) { + link2->unk_3C.x += chain2->unk_38; + link2->unk_3C.z += chain2->unk_3C; } } - for(i = 0, var_s0 = temp_s1->unk_44; i < temp_s6; i++, var_s0++) { + for(i = 0, link2 = chain2->links; i < linkCount; i++, link2++) { Math_Vec3f_Copy(&sp90, &gZeroVec3f); if(i - 2 >= 0) { sp90.x += D_80A849D0[i - 2].x * 0.075f; @@ -513,176 +516,186 @@ void func_80A81FFC(ObjMine *this) { sp90.y += D_80A849D0[i - 1].y * 0.15f; sp90.z += D_80A849D0[i - 1].z * 0.15f; } - sp90.x += D_80A849D0[i].x * 0.3f; - sp90.y += D_80A849D0[i].y * 0.3f; - sp90.z += D_80A849D0[i].z * 0.3f; - if(i + 1 < temp_s6) { + sp90.x += D_80A849D0[i].x * 0.3f; + sp90.y += D_80A849D0[i].y * 0.3f; + sp90.z += D_80A849D0[i].z * 0.3f; + if(i + 1 < linkCount) { sp90.x += D_80A849D0[i + 1].x * 0.15f; sp90.y += D_80A849D0[i + 1].y * 0.15f; sp90.z += D_80A849D0[i + 1].z * 0.15f; } - if(i + 2 < temp_s6) { + if(i + 2 < linkCount) { sp90.x += D_80A849D0[i + 2].x * 0.075f; sp90.y += D_80A849D0[i + 2].y * 0.075f; sp90.z += D_80A849D0[i + 2].z * 0.075f; } - var_s0->unk_3C.x += sp90.x; - var_s0->unk_3C.y += sp90.y; - var_s0->unk_3C.z += sp90.z; + link2->unk_3C.x += sp90.x; + link2->unk_3C.y += sp90.y; + link2->unk_3C.z += sp90.z; } } #else +Vec3f D_80A849D0[0x40]; void func_80A81FFC(ObjMine* this); #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Mine/func_80A81FFC.s") #endif void func_80A828A8(ObjMine* this) { - s32 i; + s32 pad; Vec3f spE0; Vec3f spD4; Vec3f spC8; - s32 spC4 = OBJMINE_GET_PARAM_003F(&this->actor); - ObjMineTestStruct2* sp70 = &this->chain2; - ObjMineUnkStruct2* temp_s0; + s32 spC4 = OBJMINE_GET_LINK_COUNT(&this->actor); + ObjMineWaterChain* chain2 = &this->chain.water; + ObjMineWaterLink* link2; + s32 i; Vec3f* phi_s3; - s32 phi_s5; Vec3f spA8; Vec3f sp9C; Vec3f sp90; Vec3f sp84; - s32 pad; + s32 phi_s5; f32 sp7C; f32 sp78; + Vec3f* phi_x; sp84.x = this->actor.home.pos.x; sp84.y = this->actor.home.pos.y + 6.0f; sp84.z = this->actor.home.pos.z; - for (i = 0, phi_s3 = NULL, temp_s0 = sp70->unk_44; i < spC4; i++, phi_s3 = &temp_s0->unk_00.x, temp_s0++) { + for (i = 0, phi_s3 = NULL, link2 = chain2->links; i < spC4; i++, phi_s3 = &link2->basis.x, link2++) { phi_s5 = false; - temp_s0->unk_30.x += temp_s0->unk_3C.x; - temp_s0->unk_30.y += temp_s0->unk_3C.y; - temp_s0->unk_30.z += temp_s0->unk_3C.z; - Math_Vec3f_Scale(&temp_s0->unk_30, sp70->unk_00); - Math_Vec3f_Copy(&sp90, &temp_s0->unk_24); - temp_s0->unk_24.x += temp_s0->unk_30.x; - temp_s0->unk_24.y += temp_s0->unk_30.y; - temp_s0->unk_24.z += temp_s0->unk_30.z; - if ((temp_s0->unk_24.y <= this->actor.home.pos.y) && (temp_s0->unk_30.y < 0.0f)) { - temp_s0->unk_30.y *= 0.1f; + link2->unk_30.x += link2->unk_3C.x; + link2->unk_30.y += link2->unk_3C.y; + link2->unk_30.z += link2->unk_3C.z; + + Math_Vec3f_Scale(&link2->unk_30, chain2->unk_00); + Math_Vec3f_Copy(&sp90, &link2->unk_24); + + link2->unk_24.x += link2->unk_30.x; + link2->unk_24.y += link2->unk_30.y; + link2->unk_24.z += link2->unk_30.z; + + if ((link2->unk_24.y <= this->actor.home.pos.y) && (link2->unk_30.y < 0.0f)) { + link2->unk_30.y *= 0.1f; } - Math_Vec3f_Diff(&temp_s0->unk_24, &sp84, &spA8); + Math_Vec3f_Diff(&link2->unk_24, &sp84, &spA8); - if (func_80A81288(&spA8, &sp9C, &sp7C, &sp78) && (sp7C > 4.0f)) { - Math_Vec3f_Copy(&spD4, &temp_s0->unk_00.y); - func_80A81714(&spD4, &sp9C, 0.10471976f); + if (ObjMine_GetUnitVec3fNorm(&spA8, &sp9C, &sp7C, &sp78) && (sp7C > 4.0f)) { + Math_Vec3f_Copy(&spD4, &link2->basis.y); + ObjMine_StepUntilParallel(&spD4, &sp9C, M_PI / 30); + phi_x = (phi_s3 == NULL) ? &sStandardBasis.x : phi_s3; - Math3D_CrossProduct((phi_s3 == NULL) ? &D_80A845C4 : phi_s3, &spD4, &spA8); + Math3D_CrossProduct(phi_x, &spD4, &spA8); - if (func_80A8120C(&spA8, &spE0)) { + if (ObjMine_GetUnitVec3f(&spA8, &spE0)) { Math3D_CrossProduct(&spD4, &spE0, &spA8); - if (func_80A8120C(&spA8, &spC8)) { + if (ObjMine_GetUnitVec3f(&spA8, &spC8)) { phi_s5 = true; } } } if (phi_s5) { - Math_Vec3f_Copy(&temp_s0->unk_00.x, &spC8); - Math_Vec3f_Copy(&temp_s0->unk_00.y, &spD4); - Math_Vec3f_Copy(&temp_s0->unk_00.z, &spE0); + Math_Vec3f_Copy(&link2->basis.x, &spC8); + Math_Vec3f_Copy(&link2->basis.y, &spD4); + Math_Vec3f_Copy(&link2->basis.z, &spE0); } else { sp7C = 4.0f; } if (sp7C >= 6.0f) { - temp_s0->unk_24.x = sp84.x + (temp_s0->unk_00.y.x * 6.0f); - temp_s0->unk_24.y = sp84.y + (temp_s0->unk_00.y.y * 6.0f); - temp_s0->unk_24.z = sp84.z + (temp_s0->unk_00.y.z * 6.0f); + link2->unk_24.x = sp84.x + (link2->basis.y.x * 6.0f); + link2->unk_24.y = sp84.y + (link2->basis.y.y * 6.0f); + link2->unk_24.z = sp84.z + (link2->basis.y.z * 6.0f); } else { - temp_s0->unk_24.x = sp84.x + (temp_s0->unk_00.y.x * sp7C); - temp_s0->unk_24.y = sp84.y + (temp_s0->unk_00.y.y * sp7C); - temp_s0->unk_24.z = sp84.z + (temp_s0->unk_00.y.z * sp7C); + link2->unk_24.x = sp84.x + (link2->basis.y.x * sp7C); + link2->unk_24.y = sp84.y + (link2->basis.y.y * sp7C); + link2->unk_24.z = sp84.z + (link2->basis.y.z * sp7C); } - sp84.x = temp_s0->unk_24.x + (temp_s0->unk_00.y.x * 6.0f); - sp84.y = temp_s0->unk_24.y + (temp_s0->unk_00.y.y * 6.0f); - sp84.z = temp_s0->unk_24.z + (temp_s0->unk_00.y.z * 6.0f); + sp84.x = link2->unk_24.x + (link2->basis.y.x * 6.0f); + sp84.y = link2->unk_24.y + (link2->basis.y.y * 6.0f); + sp84.z = link2->unk_24.z + (link2->basis.y.z * 6.0f); } } -void func_80A82C28(ObjMine* this, PlayState* play) { +void ObjMine_Water_UpdateChain(ObjMine* this, PlayState* play) { func_80A81E7C(this, play); func_80A81FFC(this); func_80A828A8(this); } void ObjMine_Init(Actor* thisx, PlayState* play) { - ObjMine* this = THIS; s32 pad; - s32 sp44 = OBJMINE_GET_PARAM_00FF(&this->actor); + ObjMine* this = THIS; + s32 pathIndex = OBJMINE_GET_PATH(&this->actor); Path* path; - s32 sp3C; - s32 sp38 = OBJMINE_GET_PARAM_3000(&this->actor); - s32 sp34; + s32 dummyBgId; + s32 type = OBJMINE_GET_TYPE(&this->actor); Actor_ProcessInitChain(&this->actor, sInitChain); + this->actor.shape.rot.z = 0; this->actor.world.rot.z = 0; + Collider_InitJntSph(play, &this->collider); Collider_SetJntSph(play, &this->collider, &this->actor, &sJntSphInit, this->colliderElements); - if (sp38 == 0) { + if (type == OBJMINE_TYPE_PATH) { ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 45.0f); this->actor.shape.shadowAlpha = 140; - this->unk_1A8 = D_80A845A4[OBJMINE_GET_PARAM_0700(&this->actor)]; - if (sp44 == 0xFF) { - func_80A82F84(this); + this->pathSpeed = sPathSpeeds[OBJMINE_GET_PATH_SPEED(&this->actor)]; + if (pathIndex == 0xFF) { + ObjMine_Path_SetupStationary(this); } else { - path = &play->setupPathList[sp44]; - this->unk_1B0 = 0; - this->unk_1AC = path->count - 1; - this->unk_1B4 = (Vec3s*)Lib_SegmentedToVirtual(path->points); - func_80A811D0(this, this->unk_1B0); - func_80A82FA8(this); + path = &play->setupPathList[pathIndex]; + + this->waypointIndex = 0; + this->waypointCount = path->count - 1; + this->waypoints = (Vec3s*)Lib_SegmentedToVirtual(path->points); + + ObjMine_Path_MoveToWaypoint(this, this->waypointIndex); + ObjMine_Path_SetupMove(this); } Matrix_SetTranslateRotateYXZ(this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, &this->actor.shape.rot); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Collider_UpdateSpheres(0, &this->collider); - this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &sp3C, + this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &dummyBgId, &this->actor, &this->actor.world.pos); } else { - sp34 = OBJMINE_GET_PARAM_003F(&this->actor); - this->actor.update = func_80A83E7C; - this->actor.uncullZoneScale = (sp34 * 21.0f) + 150.0f; - this->actor.uncullZoneDownward = (sp34 * 21.0f) + 150.0f; - ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 45.0f); - this->actor.shape.shadowAlpha = 0x8C; + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); - if (sp38 == 1) { - this->actor.draw = func_80A84088; - func_80A81868(this, sp34); - this->actor.world.pos.y = (-10.0f - (sp34 * 12.0f)) + this->actor.home.pos.y; - func_80A819A4(this, sp34); + this->actor.update = ObjMine_AirWater_Update; + this->actor.uncullZoneScale = 150.0f + (linkCount * 21.0f); + this->actor.uncullZoneDownward = 150.0f + (linkCount * 21.0f); + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 45.0f); + this->actor.shape.shadowAlpha = 140; + + if (type == OBJMINE_TYPE_AIR) { + this->actor.draw = ObjMine_Air_Draw; + ObjMine_Air_InitChain(this, linkCount); + this->actor.world.pos.y = -10.0f - (linkCount * 12.0f) + this->actor.home.pos.y; + ObjMine_Air_SetCollider(this, linkCount); func_800B4AEC(play, &this->actor, 0.0f); - if (sp34 == 0) { - func_80A83A74(this); + if (linkCount == 0) { + ObjMine_Air_SetupStationary(this); } else { - func_80A832BC(this); + ObjMine_Air_SetupChained(this); } } else { - this->actor.draw = func_80A84338; - func_80A81B7C(this, sp34); - this->actor.world.pos.y = (sp34 * 12.0f) + 10.0f + this->actor.home.pos.y; - func_80A81D70(this, sp34); - if (sp34 == 0) { - func_80A83CEC(this); + this->actor.draw = ObjMine_Water_Draw; + ObjMine_Water_InitChain(this, linkCount); + this->actor.world.pos.y = 10.0f + (linkCount * 12.0f) + this->actor.home.pos.y; + ObjMine_Water_SetCollider(this, linkCount); + if (linkCount == 0) { + ObjMine_Water_SetupStationary(this); } else { - func_80A83B14(this); + ObjMine_Water_SetupChained(this); } } } @@ -694,217 +707,223 @@ void ObjMine_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyJntSph(play, &this->collider); } -void func_80A82F84(ObjMine* this) { - this->actionFunc = func_80A82F98; +void ObjMine_Path_SetupStationary(ObjMine* this) { + this->actionFunc = ObjMine_Path_Stationary; } -void func_80A82F98(ObjMine* this, PlayState* play) { +void ObjMine_Path_Stationary(ObjMine* this, PlayState* play) { } -void func_80A82FA8(ObjMine* this) { +void ObjMine_Path_SetupMove(ObjMine* this) { this->actor.flags |= ACTOR_FLAG_10; - this->actionFunc = func_80A82FC8; + this->actionFunc = ObjMine_Path_Move; } -void func_80A82FC8(ObjMine* this, PlayState* play) { - Actor* thisx = &this->actor; - Vec3f spA0; +void ObjMine_Path_Move(ObjMine* this, PlayState* play) { + Actor* thisx = &this->actor; // pos and velocity need this, though it can replace all `this->actor`s and match + Vec3f nextWaypoint; f32 speed; f32 step; f32 target; - s32 sp90; - Vec3f sp84; - Vec3f sp78; - MtxF sp38; + s32 dummyBgVec; - Math_Vec3s_ToVec3f(&spA0, &this->unk_1B4[this->unk_1B0 + 1]); - Math_Vec3f_Diff(&spA0, &thisx->world.pos, &thisx->velocity); + Math_Vec3s_ToVec3f(&nextWaypoint, &this->waypoints[this->waypointIndex + 1]); + Math_Vec3f_Diff(&nextWaypoint, &thisx->world.pos, &thisx->velocity); speed = Math3D_Vec3fMagnitude(&thisx->velocity); - if ((speed < (this->unk_1A8 * 8.0f)) && (this->unk_1A8 > 2.0f)) { - target = ((this->unk_1A8 - 2.0f) * 0.1f) + 2.0f; - step = this->unk_1A8 * 0.03f; + if ((speed < (this->pathSpeed * 8.0f)) && (this->pathSpeed > 2.0f)) { + target = 2.0f + ((this->pathSpeed - 2.0f) * 0.1f); + step = this->pathSpeed * 0.03f; } else { - target = this->unk_1A8; - step = this->unk_1A8 * 0.16f; + target = this->pathSpeed; + step = this->pathSpeed * 0.16f; } - Math_StepToF(&thisx->speedXZ, target, step); - if ((thisx->speedXZ + 0.05f) < speed) { - Math_Vec3f_Scale(&thisx->velocity, thisx->speedXZ / speed); - thisx->world.pos.x += thisx->velocity.x; - thisx->world.pos.y += thisx->velocity.y; - thisx->world.pos.z += thisx->velocity.z; + Math_StepToF(&this->actor.speedXZ, target, step); + if ((this->actor.speedXZ + 0.05f) < speed) { + Math_Vec3f_Scale(&thisx->velocity, this->actor.speedXZ / speed); + this->actor.world.pos.x += thisx->velocity.x; + this->actor.world.pos.y += thisx->velocity.y; + this->actor.world.pos.z += thisx->velocity.z; } else { - thisx->speedXZ *= 0.4f; - this->unk_1B0++; - if (this->unk_1B0 >= this->unk_1AC) { - this->unk_1B0 = 0; + this->actor.speedXZ *= 0.4f; + this->waypointIndex++; + if (this->waypointIndex >= this->waypointCount) { + this->waypointIndex = 0; } - func_80A811D0(this, this->unk_1B0); + ObjMine_Path_MoveToWaypoint(this, this->waypointIndex); } - thisx->floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &thisx->floorPoly, &sp90, thisx, &thisx->world.pos); - if (thisx->flags & 0x40) { - Math3D_CrossProduct(&D_80A845D0[0], &thisx->velocity, &sp78); - if (func_80A8120C(&sp78, &sp84)) { - Matrix_RotateAxisF(thisx->speedXZ * 0.03125f, &sp84, MTXMODE_NEW); - Matrix_RotateYS(thisx->shape.rot.y, MTXMODE_APPLY); - Matrix_RotateXS(thisx->shape.rot.x, MTXMODE_APPLY); - Matrix_RotateZS(thisx->shape.rot.z, MTXMODE_APPLY); - Matrix_Get(&sp38); - Matrix_MtxFToYXZRot(&sp38, &thisx->shape.rot, false); + this->actor.floorHeight = BgCheck_EntityRaycastFloor5(&play->colCtx, &this->actor.floorPoly, &dummyBgVec, &this->actor, &thisx->world.pos); + if (this->actor.flags & ACTOR_FLAG_40) { + Vec3f rotAxis; + Vec3f yhatCrossV; + MtxF rotMtxF; + + Math3D_CrossProduct(&sStandardBasis.y, &thisx->velocity, &yhatCrossV); + if (ObjMine_GetUnitVec3f(&yhatCrossV, &rotAxis)) { + Matrix_RotateAxisF(this->actor.speedXZ / 32.0f, &rotAxis, MTXMODE_NEW); + Matrix_RotateYS(this->actor.shape.rot.y, MTXMODE_APPLY); + Matrix_RotateXS(this->actor.shape.rot.x, MTXMODE_APPLY); + Matrix_RotateZS(this->actor.shape.rot.z, MTXMODE_APPLY); + Matrix_Get(&rotMtxF); + Matrix_MtxFToYXZRot(&rotMtxF, &this->actor.shape.rot, false); } } } -void func_80A83214(ObjMine* this) { - this->actor.flags |= 0x10; - this->actor.draw = func_80A83FBC; +void ObjMine_SetupExplode(ObjMine* this) { + this->actor.flags |= ACTOR_FLAG_10; + this->actor.draw = ObjMine_DrawExplosion; this->actor.shape.shadowDraw = NULL; this->actor.scale.x = 0.02f; this->actor.scale.y = 0.02f; this->actor.scale.z = 0.02f; - this->actionFunc = func_80A83258; + this->actionFunc = ObjMine_Explode; } -void func_80A83258(ObjMine* this, PlayState* play) { +void ObjMine_Explode(ObjMine* this, PlayState* play) { this->actor.scale.x *= 1.8f; - if (this->actor.scale.x > 0.17495999f) { - Actor_MarkForDeath(&this->actor); + if (this->actor.scale.x > 30.0f * 0.001f * CUBE(1.8f)) { + Actor_Kill(&this->actor); } else { this->actor.scale.y = this->actor.scale.x; this->actor.scale.z = this->actor.scale.x; } } -void func_80A832BC(ObjMine* this) { - this->actionFunc = func_80A832D0; +void ObjMine_Air_SetupChained(ObjMine* this) { + this->actionFunc = ObjMine_Air_Chained; } -void func_80A832D0(ObjMine* this, PlayState* play) { +void ObjMine_Air_Chained(ObjMine* this, PlayState* play) { s32 pad; - s32 spA0 = OBJMINE_GET_PARAM_003F(&this->actor); - ObjMineUnkStruct* unkStruct = &this->chain1; - ObjMineUnkStruct3* temp; + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); + ObjMineAirChain* chain1 = &this->chain.air; + ObjMineAirLink* link1; s32 i; f32 sp90; f32 sp8C; f32 sp88; s16 sp86; s16 sp84; - s32 pad2; - s32 pad3; - Math_Vec3f_Copy(&unkStruct->unk_24, &unkStruct->unk_00.y); - if (func_80A8140C(this)) { - func_80A81384(this, play); - func_80A81640(this); - func_80A83214(this); + Math_Vec3f_Copy(&chain1->unk_24, &chain1->basis.y); + if (ObjMine_AirWater_CheckOC(this)) { + ObjMine_AirWater_SpawnBomb(this, play); + ObjMine_AirWater_Noop(this); + ObjMine_SetupExplode(this); return; } if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - unkStruct->unk_48 = 0.04f; - func_80A8146C(this, &unkStruct->unk_4C, &sp84); + chain1->unk_48 = 0.04f; + ObjMine_Air_CheckAC(this, &chain1->unk_4C, &sp84); sp88 = sp8C = Math_SinS(sp84) * 150.0f; - sp8C = -(sp8C / spA0); + sp8C = -(sp8C / linkCount); - for (i = 0, temp = unkStruct->unk_60; i < spA0; i++, temp++) { - temp->unk_02 += (s16)sp88; - temp->unk_02 = CLAMP(temp->unk_02, -800, 800); + for (i = 0, link1 = chain1->links; i < linkCount; i++, link1++) { + link1->unk_02 += (s16)sp88; + link1->unk_02 = CLAMP(link1->unk_02, -800, 800); sp88 -= sp8C; } } - if (unkStruct->unk_48 > 0.0001f) { - sp90 = Math_SinS(unkStruct->unk_4C) * unkStruct->unk_48; - sp8C = Math_CosS(unkStruct->unk_4C) * unkStruct->unk_48; - unkStruct->unk_38 += sp90; - unkStruct->unk_3C += sp8C; - Math_StepToF(&unkStruct->unk_48, 0.0f, 0.02f); + if (chain1->unk_48 > 0.0001f) { + sp90 = Math_SinS(chain1->unk_4C) * chain1->unk_48; + sp8C = Math_CosS(chain1->unk_4C) * chain1->unk_48; + chain1->unk_38 += sp90; + chain1->unk_3C += sp8C; + Math_StepToF(&chain1->unk_48, 0.0f, 0.02f); } - if ((Rand_Next() >> 0x1B) == 0) { - unkStruct->unk_50 = Rand_ZeroOne() * unkStruct->unk_58; - unkStruct->unk_54 = Rand_Next() >> 0x10; + if (RANDU_BITS(5) == 0) { + chain1->unk_50 = Rand_ZeroOne() * chain1->unk_58; + chain1->unk_54 = RANDU_BITS(16); } - sp90 = Math_SinS(unkStruct->unk_54) * unkStruct->unk_50; - sp8C = Math_CosS(unkStruct->unk_54) * unkStruct->unk_50; - unkStruct->unk_38 += sp90; - unkStruct->unk_3C += sp8C; + sp90 = Math_SinS(chain1->unk_54) * chain1->unk_50; + sp8C = Math_CosS(chain1->unk_54) * chain1->unk_50; + chain1->unk_38 += sp90; + chain1->unk_3C += sp8C; - unkStruct->unk_38 += unkStruct->unk_30 * unkStruct->unk_40; - unkStruct->unk_3C += unkStruct->unk_34 * unkStruct->unk_40; + chain1->unk_38 += chain1->unk_30 * chain1->unk_40; + chain1->unk_3C += chain1->unk_34 * chain1->unk_40; - unkStruct->unk_38 *= unkStruct->unk_44; - unkStruct->unk_3C *= unkStruct->unk_44; + chain1->unk_38 *= chain1->unk_44; + chain1->unk_3C *= chain1->unk_44; - unkStruct->unk_30 += unkStruct->unk_38; - unkStruct->unk_34 += unkStruct->unk_3C; + chain1->unk_30 += chain1->unk_38; + chain1->unk_34 += chain1->unk_3C; - unkStruct->unk_30 = CLAMP(unkStruct->unk_30, -5.0f, 5.0f); - unkStruct->unk_34 = CLAMP(unkStruct->unk_34, -5.0f, 5.0f); + chain1->unk_30 = CLAMP(chain1->unk_30, -5.0f, 5.0f); + chain1->unk_34 = CLAMP(chain1->unk_34, -5.0f, 5.0f); - func_80A81A00(this); - func_80A81AA4(this); + ObjMine_Air_SetBasis(this); + ObjMine_Air_SetWorld(this); - if ((unkStruct->unk_5C > -0.000001f) && - (unkStruct->unk_5C <= Math3D_XZDistanceSquared(this->actor.world.pos.x, this->actor.world.pos.z, - this->actor.home.pos.x, this->actor.home.pos.z))) { - Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 20.0f, 0.0f, 1); + if (chain1->unk_5C > -0.000001f) { + Vec3f* world = &this->actor.world.pos; + Vec3f* home = &this->actor.home.pos; - if ((this->actor.bgCheckFlags & 8) && (this->actor.wallPoly != NULL)) { - Vec3f sp70; - Vec3f sp64; - Vec3f sp58; - Vec3f sp4C; - f32 sp48; - f32 sp44; + if (chain1->unk_5C <= Math3D_XZDistanceSquared(world->x, world->z, home->x, home->z)) { - sp4C.x = unkStruct->unk_38; - sp4C.y = 0.0f; - sp4C.z = unkStruct->unk_3C; - if (func_80A81288(&sp4C, &sp70, &sp48, &sp44)) { - sp58.x = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); - sp58.y = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y); - sp58.z = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.z); - func_80179F64(&sp70, &sp58, &sp64); - sp48 *= 0.5f; - unkStruct->unk_38 = sp64.x * sp48; - unkStruct->unk_3C = sp64.z * sp48; - } else { - unkStruct->unk_38 *= -0.1f; - unkStruct->unk_3C *= -0.1f; + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 20.0f, 0.0f, 1); + + if ((this->actor.bgCheckFlags & 8) && (this->actor.wallPoly != NULL)) { + Vec3f sp70; + Vec3f sp64; + Vec3f sp58; + Vec3f sp4C; + f32 sp48; + f32 sp44; + + sp4C.x = chain1->unk_38; + sp4C.y = 0.0f; + sp4C.z = chain1->unk_3C; + + if (ObjMine_GetUnitVec3fNorm(&sp4C, &sp70, &sp48, &sp44)) { + sp58.x = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.x); + sp58.y = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.y); + sp58.z = COLPOLY_GET_NORMAL(this->actor.wallPoly->normal.z); + + func_80179F64(&sp70, &sp58, &sp64); + + sp48 *= 0.5f; + chain1->unk_38 = sp64.x * sp48; + chain1->unk_3C = sp64.z * sp48; + } else { + chain1->unk_38 *= -0.1f; + chain1->unk_3C *= -0.1f; + } + ObjMine_Air_SetChain3034(this); + ObjMine_Air_SetBasis(this); + ObjMine_Air_SetWorld(this); } - func_80A81B14(this); - func_80A81A00(this); - func_80A81AA4(this); } } - for (i = 0, temp = unkStruct->unk_60; i < spA0; i++, temp++) { - sp86 = temp->unk_00 - 0x4000; - sp88 = temp->unk_02 + (sp86 * -0.05f) + ((Rand_ZeroOne() * 30.0f) - 15.0f); + for (i = 0, link1 = chain1->links; i < linkCount; i++, link1++) { + sp86 = link1->unk_00 - 0x4000; + sp88 = link1->unk_02 + (sp86 * -0.05f) + ((Rand_ZeroOne() * 30.0f) - 15.0f); sp88 *= 0.995f; - temp->unk_02 = sp88; - temp->unk_00 += temp->unk_02; + link1->unk_02 = sp88; + link1->unk_00 += link1->unk_02; } func_800B4AEC(play, &this->actor, 0.0f); - func_80A81818(this); + ObjMine_UpdateCollider(this); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -void func_80A83A74(ObjMine* this) { - this->actionFunc = func_80A83A88; +void ObjMine_Air_SetupStationary(ObjMine* this) { + this->actionFunc = ObjMine_Air_Stationary; } -void func_80A83A88(ObjMine* this, PlayState* play) { - if (func_80A8140C(this)) { - func_80A81384(this, play); - func_80A81640(this); - func_80A83214(this); +void ObjMine_Air_Stationary(ObjMine* this, PlayState* play) { + if (ObjMine_AirWater_CheckOC(this)) { + ObjMine_AirWater_SpawnBomb(this, play); + ObjMine_AirWater_Noop(this); + ObjMine_SetupExplode(this); return; } @@ -912,59 +931,60 @@ void func_80A83A88(ObjMine* this, PlayState* play) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -void func_80A83B14(ObjMine* this) { - this->actionFunc = func_80A83B28; +void ObjMine_Water_SetupChained(ObjMine* this) { + this->actionFunc = ObjMine_Water_Chained; } -void func_80A83B28(ObjMine* this, PlayState* play) { - ObjMineTestStruct2* ptr = &this->chain2; +void ObjMine_Water_Chained(ObjMine* this, PlayState* play) { + ObjMineWaterChain* chain2 = &this->chain.water; - if (func_80A8140C(this)) { - func_80A81384(this, play); - func_80A81640(this); - func_80A83214(this); + if (ObjMine_AirWater_CheckOC(this)) { + ObjMine_AirWater_SpawnBomb(this, play); + ObjMine_AirWater_Noop(this); + ObjMine_SetupExplode(this); return; } if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - func_80A81544(this, &ptr->unk_04); - ptr->unk_10 = 7.0f; - Math_Vec3f_Scale(&ptr->unk_04, 7.0f); + ObjMine_Water_CheckAC(this, &chain2->unk_04); + chain2->unk_10 = 7.0f; + Math_Vec3f_Scale(&chain2->unk_04, 7.0f); } - if (ptr->unk_10 > 0.0001f) { - ptr->unk_10 = Math_Vec3f_StepTo( &ptr->unk_04, &gZeroVec3f, 2.8f); + if (chain2->unk_10 > 0.0001f) { + chain2->unk_10 = Math_Vec3f_StepTo(&chain2->unk_04, &gZeroVec3f, 2.8f); } - ptr->unk_00 = 0.9f; - ptr->unk_24 = -0.0002f; - ptr->unk_30 = -0.0002f; - ptr->unk_1C = 0.003f; - if ((Rand_Next() >> 0x1B) == 0) { - s16 rand = Rand_Next() >> 0x10; + chain2->unk_00 = 0.9f; + chain2->unk_24 = -0.0002f; + chain2->unk_30 = -0.0002f; + chain2->unk_1C = 0.003f; - ptr->unk_14 = Math_SinS(rand) * 1.8f * ptr->unk_1C; - ptr->unk_18 = Math_CosS(rand) * 0.2f * ptr->unk_1C; - ptr->unk_20 = Rand_Next() >> 0x13; + if (RANDU_BITS(5) == 0) { + s16 randAngle = RANDU_BITS(16); + + chain2->unk_14 = Math_SinS(randAngle) * 1.8f * chain2->unk_1C; + chain2->unk_18 = Math_CosS(randAngle) * 0.2f * chain2->unk_1C; + chain2->unk_20 = RANDU_BITS(13); } - func_80A82C28(this, play); - func_80A81DEC(this); - func_80A81818(this); + ObjMine_Water_UpdateChain(this, play); + ObjMine_Water_SetWorld(this); + ObjMine_UpdateCollider(this); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } -void func_80A83CEC(ObjMine* this) { - this->actionFunc = func_80A83D00; +void ObjMine_Water_SetupStationary(ObjMine* this) { + this->actionFunc = ObjMine_Water_Stationary; } -void func_80A83D00(ObjMine* this, PlayState* play) { - if (func_80A8140C(this)) { - func_80A81384(this, play); - func_80A81640(this); - func_80A83214(this); +void ObjMine_Water_Stationary(ObjMine* this, PlayState* play) { + if (ObjMine_AirWater_CheckOC(this)) { + ObjMine_AirWater_SpawnBomb(this, play); + ObjMine_AirWater_Noop(this); + ObjMine_SetupExplode(this); return; } @@ -973,13 +993,13 @@ void func_80A83D00(ObjMine* this, PlayState* play) { } -void ObjMine_Update(Actor* thisx, PlayState* play) { +void ObjMine_Path_Update(Actor* thisx, PlayState* play) { s32 pad; ObjMine* this = THIS; if ((this->collider.base.ocFlags2 & OC2_HIT_PLAYER) || (this->collider.base.acFlags & AC_HIT)) { - func_80A8131C(this, play); - func_80A83214(this); + ObjMine_Path_SpawnBomb(this, play); + ObjMine_SetupExplode(this); } this->actionFunc(this, play); @@ -988,26 +1008,26 @@ void ObjMine_Update(Actor* thisx, PlayState* play) { this->collider.base.ocFlags1 &= ~OC1_HIT; this->collider.base.acFlags &= ~AC_HIT; this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; - if ((this->actor.flags & 0x40) && (this->actionFunc != func_80A83258)) { + if ((this->actor.flags & ACTOR_FLAG_40) && (this->actionFunc != ObjMine_Explode)) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } } -void func_80A83E7C(Actor* thisx, PlayState* play) { +void ObjMine_AirWater_Update(Actor* thisx, PlayState* play) { ObjMine* this = THIS; this->actionFunc(this, play); } -void ObjMine_Draw(Actor* thisx, PlayState* play) { +void ObjMine_Path_Draw(Actor* thisx, PlayState* play) { s32 pad; ObjMine* this = THIS; OPEN_DISPS(play->state.gfxCtx); - if (this->actionFunc == func_80A82FC8) { + if (this->actionFunc == ObjMine_Path_Move) { Collider_UpdateSpheres(0, &this->collider); } @@ -1023,12 +1043,12 @@ void ObjMine_Draw(Actor* thisx, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } -void func_80A83FBC(Actor* thisx, PlayState* play) { - ObjMine* this = THIS; +void ObjMine_DrawExplosion(Actor* thisx, PlayState* play) { + s32 pad; // This could be thisx recast or playstate recast. OPEN_DISPS(play->state.gfxCtx); - func_800B8118(&this->actor, play, 1); + func_800B8118(thisx, play, 1); func_8012C2DC(play->state.gfxCtx); gDPSetRenderMode(POLY_XLU_DISP++, G_RM_PASS, G_RM_AA_ZB_XLU_SURF2); @@ -1039,12 +1059,12 @@ void func_80A83FBC(Actor* thisx, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } -void func_80A84088(Actor* thisx, PlayState* play) { +void ObjMine_Air_Draw(Actor* thisx, PlayState* play) { s32 pad; ObjMine* this = THIS; - s32 temp_s5 = OBJMINE_GET_PARAM_003F(&this->actor); - ObjMineUnkStruct3* temp; - ObjMineUnkStruct* ptr = &this->chain1; + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); + ObjMineAirChain* chain1 = &this->chain.air; + ObjMineAirLink* link1; s32 i; Vec3f sp94; Vec3f sp88; @@ -1059,21 +1079,21 @@ void func_80A84088(Actor* thisx, PlayState* play) { gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); - func_80A81684(&ptr->unk_00); + ObjMine_ReplaceRotation(&chain1->basis); Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); - if (temp_s5 != 0) { - Math_Vec3f_ScaleAndStore(&ptr->unk_00.y, -6.0f, &sp88); + if (linkCount != 0) { + Math_Vec3f_ScaleAndStore(&chain1->basis.y, -6.0f, &sp88); sp94.x = this->actor.home.pos.x - sp88.x; - sp94.y = (this->actor.home.pos.y - 6.0f) - sp88.y; + sp94.y = this->actor.home.pos.y - 6.0f - sp88.y; sp94.z = this->actor.home.pos.z - sp88.z; - Math_Vec3f_ScaleAndStore(&ptr->unk_00.y, -12.0f, &sp88); + Math_Vec3f_ScaleAndStore(&chain1->basis.y, -12.0f, &sp88); - for (i = 0, temp = ptr->unk_60; i < temp_s5; i++, temp++) { - Matrix_RotateYS(temp->unk_00, MTXMODE_APPLY); + for (i = 0, link1 = chain1->links; i < linkCount; i++, link1++) { + Matrix_RotateYS(link1->unk_00, MTXMODE_APPLY); sp94.x += sp88.x; sp94.y += sp88.y; sp94.z += sp88.z; - func_80A8164C(&sp94); + ObjMine_ReplaceTranslation(&sp94); gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); @@ -1081,7 +1101,7 @@ void func_80A84088(Actor* thisx, PlayState* play) { } Matrix_RotateXS(0x2000, MTXMODE_APPLY); - func_80A8164C(&this->actor.world.pos); + ObjMine_ReplaceTranslation(&this->actor.world.pos); gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPPipeSync(gfx++); @@ -1095,14 +1115,14 @@ void func_80A84088(Actor* thisx, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } -void func_80A84338(Actor* thisx, PlayState* play) { - s32 pad1; +void ObjMine_Water_Draw(Actor* thisx, PlayState* play) { + s32 pad; ObjMine* this = THIS; - s32 temp_s7 = OBJMINE_GET_PARAM_003F(&this->actor); - ObjMineTestStruct2* pad2 = &this->chain2; + s32 linkCount = OBJMINE_GET_LINK_COUNT(&this->actor); + ObjMineWaterChain* chain2 = &this->chain.water; + ObjMineWaterLink* link2; s32 i; Gfx* gfx; - ObjMineUnkStruct2* temp; func_800B8050(&this->actor, play, 1); @@ -1113,20 +1133,20 @@ void func_80A84338(Actor* thisx, PlayState* play) { gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); - for (i = 0, temp = pad2->unk_44; i < temp_s7; i++, temp++) { - func_80A81684(&temp->unk_00); - Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, 1); - if ((i & 1) == 0) { + for (i = 0, link2 = chain2->links; i < linkCount; i++, link2++) { + ObjMine_ReplaceRotation(&link2->basis); + Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); + if ((i % 2) == 0) { Matrix_RotateYS(0x4000, MTXMODE_APPLY); } - func_80A8164C(&temp->unk_24); + ObjMine_ReplaceTranslation(&link2->unk_24); gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(gfx++, object_ny_DL_000030); } - Matrix_RotateXS(0x2000, 1); - func_80A8164C(&this->actor.world.pos); + Matrix_RotateXS(0x2000, MTXMODE_APPLY); + ObjMine_ReplaceTranslation(&this->actor.world.pos); gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPPipeSync(gfx++); diff --git a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h index 467509cd4..bcee16c65 100644 --- a/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h +++ b/src/overlays/actors/ovl_Obj_Mine/z_obj_mine.h @@ -7,27 +7,33 @@ struct ObjMine; typedef void (*ObjMineActionFunc)(struct ObjMine*, PlayState*); -#define OBJMINE_GET_PARAM_003F(thisx) ((thisx)->params & 0x3F) -#define OBJMINE_GET_PARAM_00FF(thisx) ((thisx)->params & 0xFF) -#define OBJMINE_GET_PARAM_0700(thisx) ((thisx)->params >> 8 & 7) -#define OBJMINE_GET_PARAM_3000(thisx) ((thisx)->params >> 0xC & 3) +#define OBJMINE_GET_LINK_COUNT(thisx) ((thisx)->params & 0x3F) +#define OBJMINE_GET_PATH(thisx) ((thisx)->params & 0xFF) +#define OBJMINE_GET_PATH_SPEED(thisx) (((thisx)->params >> 8) & 7) +#define OBJMINE_GET_TYPE(thisx) (((thisx)->params >> 12) & 3) + +#define OBJMINE_SET_PARAM0(pathIndex, pathSpeed, type) ((pathIndex) | ((pathSpeed) << 8)) +#define OBJMINE_SET_PARAM12(linkCount, type) ((linkCount) | ((type) << 0xC)) + +typedef enum { + /* 0 */ OBJMINE_TYPE_PATH, + /* 1 */ OBJMINE_TYPE_AIR, + /* 2 */ OBJMINE_TYPE_WATER +} ObjMineType; typedef struct { - Vec3f x; - Vec3f y; - Vec3f z; - // Vec3f w; -} ObjMineMtxF3; + /* 0x00 */ Vec3f x; + /* 0x0C */ Vec3f y; + /* 0x18 */ Vec3f z; +} ObjMineMtxF3; // size = 0x24 typedef struct { /* 0x00 */ s16 unk_00; /* 0x02 */ s16 unk_02; -} ObjMineUnkStruct3; +} ObjMineAirLink; // size = 0x4 typedef struct { - /* 0x00 */ ObjMineMtxF3 unk_00; - // /* 0x0C */ Vec3f unk_0C; - // /* 0x18 */ Vec3f unk_18; + /* 0x00 */ ObjMineMtxF3 basis; /* 0x24 */ Vec3f unk_24; /* 0x30 */ f32 unk_30; /* 0x34 */ f32 unk_34; @@ -41,49 +47,48 @@ typedef struct { /* 0x54 */ s16 unk_54; /* 0x58 */ f32 unk_58; /* 0x5C */ f32 unk_5C; - /* 0x60 */ ObjMineUnkStruct3* unk_60; -} ObjMineUnkStruct; // size = ?? 0x44??? 48 array??? + /* 0x60 */ ObjMineAirLink links[0x3F]; +} ObjMineAirChain; // size = 0x15C -// probably fake typedef struct { - /* 0x00 */ ObjMineMtxF3 unk_00; - // /* 0x0c */ Vec3f unk_0C; - // /* 0x18 */ Vec3f unk_18; + /* 0x00 */ ObjMineMtxF3 basis; /* 0x24 */ Vec3f unk_24; /* 0x30 */ Vec3f unk_30; /* 0x3C */ Vec3f unk_3C; -} ObjMineUnkStruct2; // size = 0x48??? +} ObjMineWaterLink; // size = 0x48 typedef struct { - f32 unk_00; - Vec3f unk_04; - f32 unk_10; - f32 unk_14; - f32 unk_18; - f32 unk_1C; - s16 unk_20; - f32 unk_24; - f32 unk_28; - f32 unk_2C; - f32 unk_30; - f32 unk_34; - f32 unk_38; - f32 unk_3C; - s8 unk_40; - ObjMineUnkStruct2 unk_44[0x3F]; -} ObjMineTestStruct2; + /* 0x0000 */ f32 unk_00; + /* 0x0004 */ Vec3f unk_04; + /* 0x0010 */ f32 unk_10; + /* 0x0014 */ f32 unk_14; + /* 0x0018 */ f32 unk_18; + /* 0x001C */ f32 unk_1C; + /* 0x0020 */ s16 unk_20; + /* 0x0024 */ f32 unk_24; + /* 0x0028 */ f32 unk_28; + /* 0x002C */ f32 unk_2C; + /* 0x0030 */ f32 unk_30; + /* 0x0034 */ f32 unk_34; + /* 0x0038 */ f32 unk_38; + /* 0x003C */ f32 unk_3C; + /* 0x0040 */ s8 unk_40; + /* 0x0044 */ ObjMineWaterLink links[0x3F]; +} ObjMineWaterChain; // size = 0x11FC typedef struct ObjMine { /* 0x0000 */ Actor actor; /* 0x0144 */ ColliderJntSph collider; /* 0x0164 */ ColliderJntSphElement colliderElements[1]; /* 0x01A4 */ ObjMineActionFunc actionFunc; - /* 0x01A8 */ f32 unk_1A8; - /* 0x01AC */ s32 unk_1AC; - /* 0x01B0 */ s32 unk_1B0; - /* 0x01B4 */ Vec3s* unk_1B4; - // ObjMineTestStruct2 chain2; - union { ObjMineTestStruct2 chain2; ObjMineUnkStruct chain1;}; + /* 0x01A8 */ f32 pathSpeed; + /* 0x01AC */ s32 waypointCount; + /* 0x01B0 */ s32 waypointIndex; + /* 0x01B4 */ Vec3s* waypoints; + /* 0x01B8 */ union { + ObjMineAirChain air; + ObjMineWaterChain water; + } chain; } ObjMine; // size = 0x13B4 #endif // Z_OBJ_MINE_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 0e450dfa2..38b9b34da 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -11150,53 +11150,53 @@ 0x80A80508:("func_80A80508",), 0x80A80750:("func_80A80750",), 0x80A80904:("func_80A80904",), - 0x80A811D0:("func_80A811D0",), - 0x80A8120C:("func_80A8120C",), - 0x80A81288:("func_80A81288",), - 0x80A8131C:("func_80A8131C",), - 0x80A81384:("func_80A81384",), - 0x80A8140C:("func_80A8140C",), - 0x80A8146C:("func_80A8146C",), - 0x80A81544:("func_80A81544",), - 0x80A81640:("func_80A81640",), - 0x80A8164C:("func_80A8164C",), - 0x80A81684:("func_80A81684",), - 0x80A81714:("func_80A81714",), - 0x80A81818:("func_80A81818",), - 0x80A81868:("func_80A81868",), - 0x80A819A4:("func_80A819A4",), - 0x80A81A00:("func_80A81A00",), - 0x80A81AA4:("func_80A81AA4",), - 0x80A81B14:("func_80A81B14",), - 0x80A81B7C:("func_80A81B7C",), - 0x80A81D70:("func_80A81D70",), - 0x80A81DEC:("func_80A81DEC",), + 0x80A811D0:("ObjMine_Path_MoveToWaypoint",), + 0x80A8120C:("ObjMine_GetUnitVec3f",), + 0x80A81288:("ObjMine_GetUnitVec3fNorm",), + 0x80A8131C:("ObjMine_Path_SpawnBomb",), + 0x80A81384:("ObjMine_AirWater_SpawnBomb",), + 0x80A8140C:("ObjMine_AirWater_CheckOC",), + 0x80A8146C:("ObjMine_Air_CheckAC",), + 0x80A81544:("ObjMine_Water_CheckAC",), + 0x80A81640:("ObjMine_AirWater_Noop",), + 0x80A8164C:("ObjMine_ReplaceTranslation",), + 0x80A81684:("ObjMine_ReplaceRotation",), + 0x80A81714:("ObjMine_StepUntilParallel",), + 0x80A81818:("ObjMine_UpdateCollider",), + 0x80A81868:("ObjMine_Air_InitChain",), + 0x80A819A4:("ObjMine_Air_SetCollider",), + 0x80A81A00:("ObjMine_Air_SetBasis",), + 0x80A81AA4:("ObjMine_Air_SetWorld",), + 0x80A81B14:("ObjMine_Air_SetChain3034",), + 0x80A81B7C:("ObjMine_Water_InitChain",), + 0x80A81D70:("ObjMine_Water_SetCollider",), + 0x80A81DEC:("ObjMine_Water_SetWorld",), 0x80A81E7C:("func_80A81E7C",), 0x80A81FFC:("func_80A81FFC",), 0x80A828A8:("func_80A828A8",), - 0x80A82C28:("func_80A82C28",), + 0x80A82C28:("ObjMine_Water_UpdateChain",), 0x80A82C5C:("ObjMine_Init",), 0x80A82F58:("ObjMine_Destroy",), - 0x80A82F84:("func_80A82F84",), - 0x80A82F98:("func_80A82F98",), - 0x80A82FA8:("func_80A82FA8",), - 0x80A82FC8:("func_80A82FC8",), - 0x80A83214:("func_80A83214",), - 0x80A83258:("func_80A83258",), - 0x80A832BC:("func_80A832BC",), - 0x80A832D0:("func_80A832D0",), - 0x80A83A74:("func_80A83A74",), - 0x80A83A88:("func_80A83A88",), - 0x80A83B14:("func_80A83B14",), - 0x80A83B28:("func_80A83B28",), - 0x80A83CEC:("func_80A83CEC",), - 0x80A83D00:("func_80A83D00",), - 0x80A83D8C:("ObjMine_Update",), - 0x80A83E7C:("func_80A83E7C",), - 0x80A83EA0:("ObjMine_Draw",), - 0x80A83FBC:("func_80A83FBC",), - 0x80A84088:("func_80A84088",), - 0x80A84338:("func_80A84338",), + 0x80A82F84:("ObjMine_Path_SetupStationary",), + 0x80A82F98:("ObjMine_Path_Stationary",), + 0x80A82FA8:("ObjMine_Path_SetupMove",), + 0x80A82FC8:("ObjMine_Path_Move",), + 0x80A83214:("ObjMine_SetupExplode",), + 0x80A83258:("ObjMine_Explode",), + 0x80A832BC:("ObjMine_Air_SetupChained",), + 0x80A832D0:("ObjMine_Air_Chained",), + 0x80A83A74:("ObjMine_Air_SetupStationary",), + 0x80A83A88:("ObjMine_Air_Stationary",), + 0x80A83B14:("ObjMine_Water_SetupChained",), + 0x80A83B28:("ObjMine_Water_Chained",), + 0x80A83CEC:("ObjMine_Water_SetupStationary",), + 0x80A83D00:("ObjMine_Water_Stationary",), + 0x80A83D8C:("ObjMine_Path_Update",), + 0x80A83E7C:("ObjMine_AirWater_Update",), + 0x80A83EA0:("ObjMine_Path_Draw",), + 0x80A83FBC:("ObjMine_DrawExplosion",), + 0x80A84088:("ObjMine_Air_Draw",), + 0x80A84338:("ObjMine_Water_Draw",), 0x80A84CD0:("ObjPurify_SetSysMatrix",), 0x80A84CF8:("ObjPurify_IsPurified",), 0x80A84D68:("ObjPurify_Init",),