From 75d7cf668c64967fb7f8c5b9c6182bb70e7fbba9 Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Thu, 20 Oct 2022 17:30:17 -0700 Subject: [PATCH 01/10] Document object_boss_hakugin (Goht) (#1133) --- assets/xml/objects/object_boss_hakugin.xml | 180 ++++++++++-------- .../actors/ovl_En_Hakurock/z_en_hakurock.c | 4 +- 2 files changed, 104 insertions(+), 80 deletions(-) diff --git a/assets/xml/objects/object_boss_hakugin.xml b/assets/xml/objects/object_boss_hakugin.xml index 3444dc041..ba04a3071 100644 --- a/assets/xml/objects/object_boss_hakugin.xml +++ b/assets/xml/objects/object_boss_hakugin.xml @@ -1,82 +1,106 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c index 86a1be027..0e1d2f050 100644 --- a/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c +++ b/src/overlays/actors/ovl_En_Hakurock/z_en_hakurock.c @@ -353,7 +353,7 @@ void EnHakurock_Draw(Actor* thisx, PlayState* play) { func_8012C28C(play->state.gfxCtx); Matrix_Translate(-100.0f, 0.0f, 0.0f, MTXMODE_APPLY); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, object_boss_hakugin_DL_011100); - gSPDisplayList(POLY_OPA_DISP++, object_boss_hakugin_DL_011178); + gSPDisplayList(POLY_OPA_DISP++, gGohtStalactiteMaterialDL); + gSPDisplayList(POLY_OPA_DISP++, gGohtStalactiteModelDL); CLOSE_DISPS(play->state.gfxCtx); } From dca019f9fa648db1fa1dc827899002a9dffa1bb6 Mon Sep 17 00:00:00 2001 From: petrie911 <69443847+petrie911@users.noreply.github.com> Date: Thu, 20 Oct 2022 20:34:21 -0500 Subject: [PATCH 02/10] Match 4 functions in BGcheck, remove nonequivalency in DynaPoly_ExpandSRT and BgHakaBombwall (#1128) * match 1 * more matches * one thing * cleaned up conditionals * move bss * format * I swear that's all of the () Co-authored-by: petrie911 --- include/functions.h | 2 +- src/code/z_bgcheck.c | 534 +++++++++--------- .../ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c | 2 +- src/overlays/actors/ovl_Boss_06/z_boss_06.c | 2 +- 4 files changed, 278 insertions(+), 262 deletions(-) diff --git a/include/functions.h b/include/functions.h index fd562daf0..bd8e09181 100644 --- a/include/functions.h +++ b/include/functions.h @@ -164,7 +164,7 @@ f64 func_80086CEC(f64 param_1); s32 func_80086CF8(f32 param_1); s32 func_80086D08(f64 param_1); // void func_80086D18(void); -// void func_80086D24(void); +f64 func_80086D24(f64); s32 func_80086D30(f32 param_1); s32 func_80086D40(f64 param_1); // void func_80086D50(void); diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 7f4247b0d..2052449f7 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -72,17 +72,25 @@ BgSpecialSceneMaxObjects sCustomDynapolyMem[] = { // TODO: All these bss variables are localized to one function and can // likely be made into in-function static bss variables in the future -char D_801ED950[80]; -char D_801ED9A0[80]; + Vec3f D_801ED9F0[3]; // polyVerts Vec3f D_801EDA18[3]; // polyVerts -MtxF D_801EDA40; Vec3f D_801EDA80[3]; // polyVerts +Vec3f D_801EDB48[3]; // polyVerts + +#ifndef NON_MATCHING +Vec3f D_801EDB70[3]; // polyVerts; +Plane D_801EDB98; // plane; +Sphere16 D_801EDBA8; // sphere; +TriNorm D_801EDBB0; // tri; +#endif + +char D_801ED950[80]; +char D_801ED9A0[80]; + char D_801EDAA8[80]; char D_801EDAF8[80]; -Vec3f D_801EDB48[3]; // polyVerts -Vec3f D_801EDB70[3]; -Plane D_801EDB98; +MtxF D_801EDA40; void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector); f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast); @@ -281,7 +289,7 @@ void CollisionPoly_GetVertices(CollisionPoly* poly, Vec3s* vtxList, Vec3f* dest) void CollisionPoly_GetVerticesByBgId(CollisionPoly* poly, s32 bgId, CollisionContext* colCtx, Vec3f* dest) { Vec3s* vtxList; - if (poly == NULL || bgId > BG_ACTOR_MAX || dest == NULL) { + if ((poly == NULL) || (bgId > BG_ACTOR_MAX) || (dest == NULL)) { if (dest != NULL) { // @bug: dest[2] x and y are not set to 0 dest[0].x = dest[0].y = dest[0].z = dest[1].x = dest[1].y = dest[1].z = dest[2].z = 0.0f; @@ -380,40 +388,52 @@ s32 CollisionPoly_CheckZIntersectApprox(CollisionPoly* poly, Vec3s* vtxList, f32 } #ifdef NON_MATCHING +// Matches, but needs in-function static bss s32 CollisionPoly_LineVsPoly(BgLineVsPolyTest* a0) { - static Vec3f polyVerts[3]; // D_801EDB70 - static Plane plane; // D_801EDB98 + static Vec3f sPolyVerts[3]; // D_801EDB70 + static Plane sPlane; // D_801EDB98 f32 planeDistA; f32 planeDistB; - f32 planeDistDelta; + f32 dpA; + f32 dpB; + f32 originDist; - plane.originDist = a0->poly->dist; - planeDistA = COLPOLY_GET_NORMAL(a0->poly->normal.x * a0->posA->x + a0->poly->normal.y * a0->posA->y + - a0->poly->normal.z * a0->posA->z) + - plane.originDist; - planeDistB = COLPOLY_GET_NORMAL(a0->poly->normal.x * a0->posB->x + a0->poly->normal.y * a0->posB->y + - a0->poly->normal.z * a0->posB->z) + - plane.originDist; + sPlane.originDist = a0->poly->dist; + originDist = sPlane.originDist; + planeDistA = originDist; + planeDistB = originDist; - planeDistDelta = planeDistA - planeDistB; - if ((planeDistA >= 0.0f && planeDistB >= 0.0f) || (planeDistA < 0.0f && planeDistB < 0.0f) || - ((a0->checkOneFace != 0) && (planeDistA < 0.0f && planeDistB > 0.0f)) || IS_ZERO(planeDistDelta)) { + dpA = a0->poly->normal.x * a0->posA->x; + dpB = a0->poly->normal.x * a0->posB->x; + dpA += a0->poly->normal.y * a0->posA->y; + dpB += a0->poly->normal.y * a0->posB->y; + dpA += a0->poly->normal.z * a0->posA->z; + dpB += a0->poly->normal.z * a0->posB->z; + + dpA *= COLPOLY_NORMAL_FRAC; + dpB *= COLPOLY_NORMAL_FRAC; + + planeDistA += dpA; + planeDistB += dpB; + + if (((planeDistA >= 0.0f) && (planeDistB >= 0.0f)) || ((planeDistA < 0.0f) && (planeDistB < 0.0f)) || + ((a0->checkOneFace != 0) && (planeDistA < 0.0f) && (0.0f < planeDistB)) || IS_ZERO(planeDistA - planeDistB)) { return false; } - CollisionPoly_GetNormalF(a0->poly, &plane.normal.x, &plane.normal.y, &plane.normal.z); - CollisionPoly_GetVertices(a0->poly, a0->vtxList, polyVerts); - Math3D_Lerp(a0->posA, a0->posB, planeDistA / planeDistDelta, a0->planeIntersect); + CollisionPoly_GetNormalF(a0->poly, &sPlane.normal.x, &sPlane.normal.y, &sPlane.normal.z); + CollisionPoly_GetVertices(a0->poly, a0->vtxList, sPolyVerts); + Math3D_Lerp(a0->posA, a0->posB, planeDistA / (planeDistA - planeDistB), a0->planeIntersect); - if ((fabsf(plane.normal.x) > 0.5f && - Math3D_TriChkPointParaXDist(&polyVerts[0], &polyVerts[1], &polyVerts[2], a0->planeIntersect->y, - a0->planeIntersect->z, 0.0f, a0->checkDist, plane.normal.x)) || - (fabsf(plane.normal.y) > 0.5f && - Math3D_TriChkPointParaYDist(&polyVerts[0], &polyVerts[1], &polyVerts[2], a0->planeIntersect->z, - a0->planeIntersect->x, 0.0f, a0->checkDist, plane.normal.y)) || - (fabsf(plane.normal.z) > 0.5f && - Math3D_TriChkLineSegParaZDist(&polyVerts[0], &polyVerts[1], &polyVerts[2], a0->planeIntersect->x, - a0->planeIntersect->y, 0.0f, a0->checkDist, plane.normal.z))) { + if (((fabsf(sPlane.normal.x) > 0.5f) && + Math3D_TriChkPointParaXDist(&sPolyVerts[0], &sPolyVerts[1], &sPolyVerts[2], a0->planeIntersect->y, + a0->planeIntersect->z, 0.0f, a0->checkDist, sPlane.normal.x)) || + ((fabsf(sPlane.normal.y) > 0.5f) && + Math3D_TriChkPointParaYDist(&sPolyVerts[0], &sPolyVerts[1], &sPolyVerts[2], a0->planeIntersect->z, + a0->planeIntersect->x, 0.0f, a0->checkDist, sPlane.normal.y)) || + ((fabsf(sPlane.normal.z) > 0.5f) && + Math3D_TriChkLineSegParaZDist(&sPolyVerts[0], &sPolyVerts[1], &sPolyVerts[2], a0->planeIntersect->x, + a0->planeIntersect->y, 0.0f, a0->checkDist, sPlane.normal.z))) { return true; } return false; @@ -423,20 +443,26 @@ s32 CollisionPoly_LineVsPoly(BgLineVsPolyTest* a0); #pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/CollisionPoly_LineVsPoly.s") #endif +#ifdef NON_MATCHING +// Matches, but needs in-function static bss s32 CollisionPoly_SphVsPoly(CollisionPoly* poly, Vec3s* vtxList, Vec3f* center, f32 radius) { - static Sphere16 sphere; // D_801EDBA8 - static TriNorm tri; // D_801EDBB0 + static Sphere16 sSphere; // D_801EDBA8 + static TriNorm sTri; // D_801EDBB0 Vec3f intersect; - CollisionPoly_GetVertices(poly, vtxList, tri.vtx); - CollisionPoly_GetNormalF(poly, &tri.plane.normal.x, &tri.plane.normal.y, &tri.plane.normal.z); - tri.plane.originDist = poly->dist; - sphere.center.x = center->x; - sphere.center.y = center->y; - sphere.center.z = center->z; - sphere.radius = radius; - return Math3D_ColSphereTri(&sphere, &tri, &intersect); + CollisionPoly_GetVertices(poly, vtxList, sTri.vtx); + CollisionPoly_GetNormalF(poly, &sTri.plane.normal.x, &sTri.plane.normal.y, &sTri.plane.normal.z); + sTri.plane.originDist = poly->dist; + sSphere.center.x = center->x; + sSphere.center.y = center->y; + sSphere.center.z = center->z; + sSphere.radius = radius; + return Math3D_ColSphereTri(&sSphere, &sTri, &intersect); } +#else +s32 CollisionPoly_SphVsPoly(CollisionPoly* poly, Vec3s* vtxList, Vec3f* center, f32 radius); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/CollisionPoly_SphVsPoly.s") +#endif /** * Add poly to StaticLookup table @@ -466,9 +492,9 @@ void StaticLookup_AddPolyToSSList(CollisionContext* colCtx, SSList* ssList, Coll curPolyId = curNode->polyId; // if the poly being inserted has a lower y than the first poly - if (polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIA)].y && - polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIB)].y && - polyYMin < vtxList[polyList[curPolyId].vIC].y) { + if ((polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIA)].y) && + (polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIB)].y) && + (polyYMin < vtxList[polyList[curPolyId].vIC].y)) { SSNodeList_SetSSListHead(&colCtx->polyNodes, ssList, &polyId); return; } @@ -487,9 +513,9 @@ void StaticLookup_AddPolyToSSList(CollisionContext* colCtx, SSList* ssList, Coll curPolyId = nextNode->polyId; // if the poly being inserted is lower than the next poly - if (polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIA)].y && - polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIB)].y && - polyYMin < vtxList[polyList[curPolyId].vIC].y) { + if ((polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIA)].y) && + (polyYMin < vtxList[COLPOLY_VTX_INDEX(polyList[curPolyId].flags_vIB)].y) && + (polyYMin < vtxList[polyList[curPolyId].vIC].y)) { newNodeId = SSNodeList_GetNextNodeIdx(&colCtx->polyNodes); SSNode_SetValue(&colCtx->polyNodes.tbl[newNodeId], &polyId, curNode->next); curNode->next = newNodeId; @@ -542,8 +568,9 @@ f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList if (((flags & 1) && (colPoly->normal.y < 0)) || ((arg9 & 0x20) && ((colCtx->colHeader->surfaceTypeList[colPoly->type].data[0] >> 0x1E) & 1)) || COLPOLY_VIA_FLAG_TEST(colPoly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(colPoly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(colPoly->flags_vIB, 4) && + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } @@ -551,16 +578,16 @@ f32 BgCheck_RaycastFloorStaticList(CollisionContext* colCtx, u16 xpFlags, SSList continue; } - if (pos->y < colCtx->colHeader->vtxList[COLPOLY_VTX_INDEX(colPoly->flags_vIA)].y && - pos->y < colCtx->colHeader->vtxList[COLPOLY_VTX_INDEX(colPoly->flags_vIB)].y && - pos->y < colCtx->colHeader->vtxList[colPoly->vIC].y) { + if ((pos->y < colCtx->colHeader->vtxList[COLPOLY_VTX_INDEX(colPoly->flags_vIA)].y) && + (pos->y < colCtx->colHeader->vtxList[COLPOLY_VTX_INDEX(colPoly->flags_vIB)].y) && + (pos->y < colCtx->colHeader->vtxList[colPoly->vIC].y)) { break; } if (CollisionPoly_CheckYIntersect(colPoly, colCtx->colHeader->vtxList, pos->x, pos->z, &yIntersect, checkDist)) { // if poly is closer to pos without going over - if (yIntersect < pos->y && result < yIntersect) { + if ((yIntersect < pos->y) && (result < yIntersect)) { result = yIntersect; *outPoly = colPoly; } @@ -682,7 +709,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 vtxB = &vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIB)]; vtxC = &vtxList[curPoly->vIC]; - if (pos->y < vtxA->y && pos->y < vtxB->y && pos->y < vtxC->y) { + if ((pos->y < vtxA->y) && (pos->y < vtxB->y) && (pos->y < vtxC->y)) { break; } @@ -692,8 +719,9 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 normalXZ = sqrtf(SQ(nx) + SQ(nz)); planeDist = Math3D_DistPlaneToPos(nx, ny, nz, curPoly->dist, &resultPos); if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -733,7 +761,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 zMin -= radius; zMax += radius; - if (resultPos.z < zMin || resultPos.z > zMax) { + if ((resultPos.z < zMin) || (resultPos.z > zMax)) { if (curNode->next == SS_NULL) { break; } else { @@ -769,7 +797,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 vtxB = &vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIB)]; vtxC = &vtxList[curPoly->vIC]; - if (pos->y < vtxA->y && pos->y < vtxB->y && pos->y < vtxC->y) { + if ((pos->y < vtxA->y) && (pos->y < vtxB->y) && (pos->y < vtxC->y)) { break; } @@ -779,8 +807,9 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 normalXZ = sqrtf(SQ(nx) + SQ(nz)); planeDist = Math3D_DistPlaneToPos(nx, ny, nz, curPoly->dist, &resultPos); if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -820,7 +849,7 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 xMin -= radius; xMax += radius; - if (resultPos.x < xMin || xMax < resultPos.x) { + if ((resultPos.x < xMin) || (xMax < resultPos.x)) { if (curNode->next == SS_NULL) { break; } else { @@ -886,8 +915,8 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte curPoly = &polyList[curPolyId]; if (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags) || (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIB, 4) && - ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -900,7 +929,7 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte intersectDist = ceilingY - *outY; ny = COLPOLY_GET_NORMAL(curPoly->normal.y); - if (intersectDist > 0 && intersectDist < checkHeight && intersectDist * ny <= 0) { + if ((intersectDist > 0) && (intersectDist < checkHeight) && (intersectDist * ny <= 0)) { *outY = ceilingY - checkHeight; *outPoly = curPoly; result = true; @@ -923,9 +952,8 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte * `posB` and `outPos` returns the point of intersection with `outPoly` * `outDistSq` returns the squared distance from `posA` to the point of intersect */ -#ifdef NON_MATCHING s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0) { - CollisionContext* colCtx; + CollisionPoly* polyList; s32 result; Vec3f polyIntersect; // sp7C SSNode* curNode; @@ -934,16 +962,14 @@ s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0) { f32 distSq; BgLineVsPolyTest test; // sp50 s16 polyId; - CollisionPoly* polyList; result = false; if (arg0->ssList->head == SS_NULL) { return result; } - colCtx = arg0->colCtx; - curNode = &colCtx->polyNodes.tbl[arg0->ssList->head]; - polyList = colCtx->colHeader->polyList; - test.vtxList = colCtx->colHeader->vtxList; + curNode = &arg0->colCtx->polyNodes.tbl[arg0->ssList->head]; + polyList = arg0->colCtx->colHeader->polyList; + test.vtxList = arg0->colCtx->colHeader->vtxList; test.posA = arg0->posA; test.posB = arg0->posB; test.planeIntersect = &polyIntersect; // reorder maybe @@ -955,22 +981,22 @@ s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0) { test.poly = &polyList[polyId]; checkedPoly = &arg0->colCtx->polyNodes.polyCheckTbl[polyId]; - if (*checkedPoly == true || - (arg0->xpFlags2 != 0 && !COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, arg0->xpFlags2)) || + if ((*checkedPoly == true) || + ((arg0->xpFlags2 != 0) && !COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, arg0->xpFlags2)) || COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, arg0->xpFlags1) || (COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIB, 4) && - ((arg0->actor != NULL && arg0->actor->category != ACTORCAT_PLAYER) || - (arg0->actor == NULL && arg0->xpFlags1 != COLPOLY_IGNORE_CAMERA)))) { + (((arg0->actor != NULL) && (arg0->actor->category != ACTORCAT_PLAYER)) || + ((arg0->actor == NULL) && (arg0->xpFlags1 != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { - curNode = &colCtx->polyNodes.tbl[curNode->next]; + curNode = &arg0->colCtx->polyNodes.tbl[curNode->next]; continue; } } *checkedPoly = true; minY = CollisionPoly_GetMinY(test.poly, test.vtxList); - if (test.posA->y < minY && test.posB->y < minY) { + if (((test.posA->y < minY)) && (test.posB->y < minY)) { break; } if (CollisionPoly_LineVsPoly(&test)) { @@ -990,10 +1016,6 @@ s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0) { } return result; } -#else -s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/BgCheck_CheckLineAgainstSSList.s") -#endif /** * Tests if line `posA` to `posB` intersects with a static poly in `lookup`. Uses polyCheckTbl @@ -1005,21 +1027,21 @@ s32 BgCheck_CheckLineAgainstSSList(StaticLineTest* arg0); s32 BgCheck_CheckLineInSubdivision(StaticLineTest* arg0) { s32 result = false; - if ((arg0->bccFlags & BGCHECK_CHECK_FLOOR) && arg0->lookup->floor.head != SS_NULL) { + if ((arg0->bccFlags & BGCHECK_CHECK_FLOOR) && (arg0->lookup->floor.head != SS_NULL)) { arg0->ssList = &arg0->lookup->floor; if (BgCheck_CheckLineAgainstSSList(arg0)) { result = true; } } - if ((arg0->bccFlags & BGCHECK_CHECK_WALL) && arg0->lookup->wall.head != SS_NULL) { + if ((arg0->bccFlags & BGCHECK_CHECK_WALL) && (arg0->lookup->wall.head != SS_NULL)) { arg0->ssList = &arg0->lookup->wall; if (BgCheck_CheckLineAgainstSSList(arg0)) { result = true; } } - if ((arg0->bccFlags & BGCHECK_CHECK_CEILING) && arg0->lookup->ceiling.head != SS_NULL) { + if ((arg0->bccFlags & BGCHECK_CHECK_CEILING) && (arg0->lookup->ceiling.head != SS_NULL)) { arg0->ssList = &arg0->lookup->ceiling; if (BgCheck_CheckLineAgainstSSList(arg0)) { result = true; @@ -1049,8 +1071,8 @@ s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext curPoly = &polyList[curPolyId]; if (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags) || (COLPOLY_VIA_FLAG_TEST(colCtx->colHeader->polyList[curPolyId].flags_vIB, 4) && - ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (node->next != SS_NULL) { node = &colCtx->polyNodes.tbl[node->next]; continue; @@ -1058,9 +1080,9 @@ s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext break; } - if (center->y + radius < vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIA)].y && - center->y + radius < vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIB)].y && - center->y + radius < vtxList[curPoly->vIC].y) { + if ((center->y + radius < vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIA)].y) && + (center->y + radius < vtxList[COLPOLY_VTX_INDEX(curPoly->flags_vIB)].y) && + (center->y + radius < vtxList[curPoly->vIC].y)) { break; } @@ -1086,19 +1108,19 @@ s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext */ s32 BgCheck_SphVsFirstStaticPoly(StaticLookup* lookup, u16 xpFlags, CollisionContext* colCtx, Vec3f* center, f32 radius, CollisionPoly** outPoly, u16 bciFlags, Actor* actor) { - if (lookup->floor.head != SS_NULL && !(bciFlags & BGCHECK_IGNORE_FLOOR) && + if ((lookup->floor.head != SS_NULL) && !(bciFlags & BGCHECK_IGNORE_FLOOR) && BgCheck_SphVsFirstStaticPolyList(&colCtx->polyNodes.tbl[lookup->floor.head], xpFlags, colCtx, center, radius, outPoly, actor)) { return true; } - if (lookup->wall.head != SS_NULL && !(bciFlags & BGCHECK_IGNORE_WALL) && + if ((lookup->wall.head != SS_NULL) && !(bciFlags & BGCHECK_IGNORE_WALL) && BgCheck_SphVsFirstStaticPolyList(&colCtx->polyNodes.tbl[lookup->wall.head], xpFlags, colCtx, center, radius, outPoly, actor)) { return true; } - if (lookup->ceiling.head != SS_NULL && !(bciFlags & BGCHECK_IGNORE_CEILING) && + if ((lookup->ceiling.head != SS_NULL) && !(bciFlags & BGCHECK_IGNORE_CEILING) && BgCheck_SphVsFirstStaticPolyList(&colCtx->polyNodes.tbl[lookup->ceiling.head], xpFlags, colCtx, center, radius, outPoly, actor)) { return true; @@ -1634,7 +1656,7 @@ CollisionHeader* BgCheck_GetCollisionHeader(CollisionContext* colCtx, s32 bgId) if (bgId == BGCHECK_SCENE) { return colCtx->colHeader; } - if (bgId < 0 || bgId > BG_ACTOR_MAX) { + if ((bgId < 0) || (bgId > BG_ACTOR_MAX)) { return NULL; } if (!(colCtx->dyna.bgActorFlags[bgId] & 1)) { @@ -1647,12 +1669,12 @@ CollisionHeader* BgCheck_GetCollisionHeader(CollisionContext* colCtx, s32 bgId) * Test if pos is near collision boundaries */ s32 BgCheck_PosInStaticBoundingBox(CollisionContext* colCtx, Vec3f* pos) { - if (pos->x < (colCtx->minBounds.x - BGCHECK_SUBDIV_OVERLAP) || - (colCtx->maxBounds.x + BGCHECK_SUBDIV_OVERLAP) < pos->x || - pos->y < (colCtx->minBounds.y - BGCHECK_SUBDIV_OVERLAP) || - (colCtx->maxBounds.y + BGCHECK_SUBDIV_OVERLAP) < pos->y || - pos->z < (colCtx->minBounds.z - BGCHECK_SUBDIV_OVERLAP) || - (colCtx->maxBounds.z + BGCHECK_SUBDIV_OVERLAP) < pos->z) { + if ((pos->x < (colCtx->minBounds.x - BGCHECK_SUBDIV_OVERLAP)) || + ((colCtx->maxBounds.x + BGCHECK_SUBDIV_OVERLAP) < pos->x) || + (pos->y < (colCtx->minBounds.y - BGCHECK_SUBDIV_OVERLAP)) || + ((colCtx->maxBounds.y + BGCHECK_SUBDIV_OVERLAP) < pos->y) || + (pos->z < (colCtx->minBounds.z - BGCHECK_SUBDIV_OVERLAP)) || + ((colCtx->maxBounds.z + BGCHECK_SUBDIV_OVERLAP) < pos->z)) { return false; } return true; @@ -1713,7 +1735,7 @@ f32 BgCheck_RaycastFloorImpl(PlayState* play, CollisionContext* colCtx, u16 xpFl } } - if (yIntersect != BGCHECK_Y_MIN && func_800C9B68(colCtx, *outPoly, *outBgId)) { + if ((yIntersect != BGCHECK_Y_MIN) && func_800C9B68(colCtx, *outPoly, *outBgId)) { yIntersect -= 1.0f; } return yIntersect; @@ -1916,7 +1938,7 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul dz = posNext->z - posPrev->z; // if there's movement on the xz plane, and argA flag is 0, - if ((dx != 0.0f || dz != 0.0f) && (argA & 1) == 0) { + if (((dx != 0.0f) || (dz != 0.0f)) && !(argA & 1)) { if ((checkHeight + dy) < 5.0f) { //! @bug checkHeight is not applied to posPrev/posNext result = BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posNext, &posIntersect, &poly, @@ -1977,7 +1999,7 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul *outPoly = poly; *outBgId = bgId; result = true; - if (COLPOLY_GET_NORMAL(poly->normal.y) > 0.5f) { + if (poly->normal.y * COLPOLY_NORMAL_FRAC > 0.5f) { if (actor != NULL) { actor->bgCheckFlags |= 0x1000; } @@ -2010,7 +2032,7 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul result = true; } // if a collision with a dyna poly was detected - if (dynaPolyCollision || *outBgId != BGCHECK_SCENE) { + if (dynaPolyCollision || (*outBgId != BGCHECK_SCENE)) { if (BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posResult, &posIntersect2, &poly, &bgId2, actor, 1.0f, BGCHECK_CHECK_ONE_FACE | BGCHECK_CHECK_WALL)) { nx3 = COLPOLY_GET_NORMAL(poly->normal.x); @@ -2202,7 +2224,7 @@ s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2, checkLine.actor = actor; result = false; - if (subdivMin[0] != subdivMax[0] || subdivMin[1] != subdivMax[1] || subdivMin[2] != subdivMax[2]) { + if ((subdivMin[0] != subdivMax[0]) || (subdivMin[1] != subdivMax[1]) || (subdivMin[2] != subdivMax[2])) { for (i = 0; i < 3; i++) { if (subdivMax[i] < subdivMin[i]) { j = subdivMax[i]; @@ -2512,9 +2534,9 @@ void ScaleRotPos_SetValue(ScaleRotPos* srp, Vec3f* scale, Vec3s* rot, Vec3f* pos * ScaleRotPos equality test */ s32 ScaleRotPos_IsEqual(ScaleRotPos* a, ScaleRotPos* b) { - if (a->scale.x != b->scale.x || a->scale.y != b->scale.y || a->scale.z != b->scale.z || a->rot.x != b->rot.x || - a->rot.y != b->rot.y || a->rot.z != b->rot.z || a->pos.x != b->pos.x || a->pos.y != b->pos.y || - a->pos.z != b->pos.z) { + if ((a->scale.x != b->scale.x) || (a->scale.y != b->scale.y) || (a->scale.z != b->scale.z) || + (a->rot.x != b->rot.x) || (a->rot.y != b->rot.y) || (a->rot.z != b->rot.z) || (a->pos.x != b->pos.x) || + (a->pos.y != b->pos.y) || (a->pos.z != b->pos.z)) { return false; } return true; @@ -2642,7 +2664,7 @@ void DynaPoly_SetBgActorPrevTransform(PlayState* play, BgActor* bgActor) { * Is BgActor Id */ s32 DynaPoly_IsBgIdBgActor(s32 bgId) { - if (bgId < 0 || bgId >= BG_ACTOR_MAX) { + if ((bgId < 0) || (bgId >= BG_ACTOR_MAX)) { return false; } return true; @@ -2714,7 +2736,7 @@ s32 DynaPoly_SetBgActor(PlayState* play, DynaCollisionContext* dyna, Actor* acto */ DynaPolyActor* DynaPoly_GetActor(CollisionContext* colCtx, s32 bgId) { if (!DynaPoly_IsBgIdBgActor(bgId) || !(colCtx->dyna.bgActorFlags[bgId] & 1) || - colCtx->dyna.bgActorFlags[bgId] & 2) { + (colCtx->dyna.bgActorFlags[bgId] & 2)) { return NULL; } return (DynaPolyActor*)colCtx->dyna.bgActors[bgId].actor; @@ -2881,20 +2903,20 @@ void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s if (dyna->bgActorFlags[bgId] & 4) { return; } - - if (!(DYNA_WATERBOX_MAX >= *waterBoxStartIndex + pbgdata->numWaterBoxes)) { + // if(&pos){} // fake but considerably improves match. commented out to stop warnings + if (*waterBoxStartIndex + pbgdata->numWaterBoxes > DYNA_WATERBOX_MAX) { sprintf(D_801EDAA8, "water_poly Error:[MoveBG OSUGI!!!]"); sprintf(D_801EDAF8, "num = %d > %d\n", *waterBoxStartIndex + pbgdata->numWaterBoxes, DYNA_WATERBOX_MAX); Fault_AddHungupAndCrashImpl(D_801EDAA8, D_801EDAF8); } - if (!(dyna->polyListMax >= *polyStartIndex + pbgdata->numPolygons)) { + if (*polyStartIndex + pbgdata->numPolygons > dyna->polyListMax) { sprintf(D_801EDAA8, "bg_poly Error:[MoveBG OSUGI!!!]"); sprintf(D_801EDAF8, "num = %d > %d\n", *polyStartIndex + pbgdata->numPolygons, dyna->polyListMax); Fault_AddHungupAndCrashImpl(D_801EDAA8, D_801EDAF8); } - if (!(dyna->vtxListMax >= *vtxStartIndex + pbgdata->numVertices)) { + if (*vtxStartIndex + pbgdata->numVertices > dyna->vtxListMax) { sprintf(D_801EDAA8, "bg_vert Error:[MoveBG OSUGI!!!]"); sprintf(D_801EDAF8, "num = %d > %d\n", *vtxStartIndex + pbgdata->numVertices, dyna->vtxListMax); Fault_AddHungupAndCrashImpl(D_801EDAA8, D_801EDAF8); @@ -2938,7 +2960,8 @@ void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s dyna->bgActors[bgId].curTransform.pos.x, dyna->bgActors[bgId].curTransform.pos.y, dyna->bgActors[bgId].curTransform.pos.z); - if (pbgdata->numVertices != 0 && pbgdata->numPolygons != 0) { + if ((pbgdata->numVertices != 0) && (pbgdata->numPolygons != 0)) { + s32 j; numVtxInverse = 1.0f / pbgdata->numVertices; newCenterPoint.x = newCenterPoint.y = newCenterPoint.z = 0.0f; for (i = 0; i < pbgdata->numVertices; i++) { @@ -2969,13 +2992,12 @@ void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s sphere->center.z = newCenterPoint.z; newRadiusSq = -100.0f; - for (i = 0; i < pbgdata->numVertices; i++) { + for (i = 0, j = *vtxStartIndex; i < pbgdata->numVertices; i++, j++) { f32 radiusSq; - s32 idx = *vtxStartIndex + i; - newVtx.x = dyna->vtxList[idx].x; - newVtx.y = dyna->vtxList[idx].y; - newVtx.z = dyna->vtxList[idx].z; + newVtx.x = dyna->vtxList[j].x; + newVtx.y = dyna->vtxList[j].y; + newVtx.z = dyna->vtxList[j].z; radiusSq = Math3D_Vec3fDistSq(&newVtx, &newCenterPoint); if (newRadiusSq < radiusSq) { newRadiusSq = radiusSq; @@ -3022,7 +3044,7 @@ void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s newPoly->normal.z = COLPOLY_SNORMAL(newNormal.z); } - newPoly->dist = -DOTXYZ(newNormal, dVtxList[vIA]); + newPoly->dist = func_80086D24(-DOTXYZ(newNormal, vtxA)); if (newNormal.y > 0.5f) { s16 polyId = *polyStartIndex + i; @@ -3039,21 +3061,22 @@ void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s } } - for (wi = 0; wi < pbgdata->numWaterBoxes; wi++) { - Math_Vec3s_ToVec3f(&spB8, &pbgdata->waterBoxes[wi].minPos); - Math_Vec3f_Copy(&spA0, &spB8); - spA0.x += pbgdata->waterBoxes[wi].xLength; - Math_Vec3f_Copy(&sp88, &spB8); - sp88.z += pbgdata->waterBoxes[wi].zLength; - SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &spB8, &spAC); - SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &spA0, &sp94); - SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &sp88, &sp7C); - waterBox = &dyna->waterBoxList.boxes[*waterBoxStartIndex + wi]; - BgCheck_CalcWaterboxDimensions(&spAC, &sp94, &sp7C, &waterBox->minPos, &waterBox->xLength, - &waterBox->zLength); - waterBox->properties = pbgdata->waterBoxes[wi].properties; + if (pbgdata->numWaterBoxes > 0) { + for (wi = 0; wi < pbgdata->numWaterBoxes; wi++) { + Math_Vec3s_ToVec3f(&spB8, &pbgdata->waterBoxes[wi].minPos); + Math_Vec3f_Copy(&spA0, &spB8); + spA0.x += pbgdata->waterBoxes[wi].xLength; + Math_Vec3f_Copy(&sp88, &spB8); + sp88.z += pbgdata->waterBoxes[wi].zLength; + SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &spB8, &spAC); + SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &spA0, &sp94); + SkinMatrix_Vec3fMtxFMultXYZ(&D_801EDA40, &sp88, &sp7C); + waterBox = &dyna->waterBoxList.boxes[*waterBoxStartIndex + wi]; + BgCheck_CalcWaterboxDimensions(&spAC, &sp94, &sp7C, &waterBox->minPos, &waterBox->xLength, + &waterBox->zLength); + waterBox->properties = pbgdata->waterBoxes[wi].properties; + } } - *polyStartIndex += pbgdata->numPolygons; *vtxStartIndex += pbgdata->numVertices; *waterBoxStartIndex += pbgdata->numWaterBoxes; @@ -3070,7 +3093,7 @@ void BgCheck_ResetFlagsIfLoadedActor(PlayState* play, DynaCollisionContext* dyna for (i = 0; i < BG_ACTOR_MAX; i++) { if ((dyna->bgActorFlags[i] & 1)) { dynaActor = DynaPoly_GetActor(&play->colCtx, i); - if (dynaActor != NULL && &dynaActor->actor == actor) { + if ((dynaActor != NULL) && (&dynaActor->actor == actor)) { DynaPolyActor_ResetState((DynaPolyActor*)actor); return; } @@ -3101,7 +3124,7 @@ void DynaPoly_Setup(PlayState* play, DynaCollisionContext* dyna) { BgActor_Init(play, &dyna->bgActors[i]); dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } - if (dyna->bgActors[i].actor != NULL && dyna->bgActors[i].actor->update == NULL) { + if ((dyna->bgActors[i].actor != NULL) && (dyna->bgActors[i].actor->update == NULL)) { // Delete BgActor actor = DynaPoly_GetActor(&play->colCtx, i); if (actor == NULL) { @@ -3181,8 +3204,8 @@ f32 BgCheck_RaycastFloorDynaList(DynaRaycast* dynaRaycast, u32 listType) { id = curNode->polyId; if (COLPOLY_VIA_FLAG_TEST(polyList[id].flags_vIA, dynaRaycast->xpFlags) || (COLPOLY_VIA_FLAG_TEST(polyList[id].flags_vIB, 4) && - ((dynaRaycast->actor != NULL && dynaRaycast->actor->category != ACTORCAT_PLAYER) || - (dynaRaycast->actor == NULL && dynaRaycast->xpFlags != COLPOLY_IGNORE_CAMERA))) || + (((dynaRaycast->actor != NULL) && (dynaRaycast->actor->category != ACTORCAT_PLAYER)) || + ((dynaRaycast->actor == NULL) && (dynaRaycast->xpFlags != COLPOLY_IGNORE_CAMERA)))) || ((dynaRaycast->unk_24 & 0x20) && func_800C9B68(dynaRaycast->colCtx, &polyList[id], dynaRaycast->unk1C))) { if (curNode->next == SS_NULL) { break; @@ -3192,7 +3215,7 @@ f32 BgCheck_RaycastFloorDynaList(DynaRaycast* dynaRaycast, u32 listType) { } } if ((listType & (DYNA_RAYCAST_WALLS | DYNA_RAYCAST_CEILINGS)) && (dynaRaycast->unk_24 & 0x10) && - COLPOLY_GET_NORMAL(polyList[id].normal.y) < 0.0f) { + (COLPOLY_GET_NORMAL(polyList[id].normal.y) < 0.0f)) { if (curNode->next == SS_NULL) { break; } else { @@ -3202,7 +3225,7 @@ f32 BgCheck_RaycastFloorDynaList(DynaRaycast* dynaRaycast, u32 listType) { } if (CollisionPoly_CheckYIntersectApprox1(&polyList[id], dynaRaycast->dyna->vtxList, dynaRaycast->pos->x, dynaRaycast->pos->z, &yIntersect, dynaRaycast->checkDist) && - yIntersect < dynaRaycast->pos->y && result < yIntersect) { + (yIntersect < dynaRaycast->pos->y) && (result < yIntersect)) { result = yIntersect; *dynaRaycast->resultPoly = &dynaRaycast->dyna->polyList[id]; } @@ -3250,8 +3273,8 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) { continue; } - if (dynaRaycast->actor == dynaRaycast->colCtx->dyna.bgActors[i].actor || - dynaRaycast->pos->y < dynaRaycast->colCtx->dyna.bgActors[i].minY || + if ((dynaRaycast->actor == dynaRaycast->colCtx->dyna.bgActors[i].actor) || + (dynaRaycast->pos->y < dynaRaycast->colCtx->dyna.bgActors[i].minY) || !Math3D_XZInSphere(&dynaRaycast->colCtx->dyna.bgActors[i].boundingSphere, dynaRaycast->pos->x, dynaRaycast->pos->z)) { continue; @@ -3270,7 +3293,7 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) { } } if ((dynaRaycast->unk_24 & BGCHECK_IGNORE_WALL) || - (*dynaRaycast->resultPoly == NULL && (dynaRaycast->unk_24 & 8))) { + ((*dynaRaycast->resultPoly == NULL) && (dynaRaycast->unk_24 & 8))) { dynaRaycast->ssList = &dynaRaycast->colCtx->dyna.bgActors[i].dynaLookup.wall; intersect2 = BgCheck_RaycastFloorDynaList(dynaRaycast, DYNA_RAYCAST_WALLS); if (dynaRaycast->yIntersect < intersect2) { @@ -3388,8 +3411,8 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo planeDist = Math3D_DistPlaneToPos(nx, ny, nz, poly->dist, &resultPos); if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags) || - ((COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4)) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -3428,7 +3451,7 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo zMin -= radius; zMax += radius; - if (resultPos.z < zMin || zMax < resultPos.z) { + if ((resultPos.z < zMin) || (zMax < resultPos.z)) { if (curNode->next == SS_NULL) { break; } else { @@ -3464,8 +3487,8 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo planeDist = Math3D_DistPlaneToPos(nx, ny, nz, poly->dist, &resultPos); if (radius < fabsf(planeDist) || COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -3504,7 +3527,7 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo xMin -= radius; xMax += radius; - if (resultPos.x < xMin || xMax < resultPos.x) { + if ((resultPos.x < xMin) || (xMax < resultPos.x)) { if (curNode->next == SS_NULL) { break; } else { @@ -3566,7 +3589,7 @@ s32 BgCheck_SphVsDynaWall(CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* } bgActor = &colCtx->dyna.bgActors[i]; - if (bgActor->minY > resultPos.y || bgActor->maxY < resultPos.y) { + if ((bgActor->minY > resultPos.y) || (bgActor->maxY < resultPos.y)) { continue; } @@ -3575,7 +3598,7 @@ s32 BgCheck_SphVsDynaWall(CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* r = bgActor->boundingSphere.radius; dx = bgActor->boundingSphere.center.x - resultPos.x; dz = bgActor->boundingSphere.center.z - resultPos.z; - if (SQ(r) < (SQ(dx) + SQ(dz)) || (!Math3D_XYInSphere(&bgActor->boundingSphere, resultPos.x, resultPos.y) && + if ((SQ(r) < SQ(dx) + SQ(dz)) || (!Math3D_XYInSphere(&bgActor->boundingSphere, resultPos.x, resultPos.y) && !Math3D_YZInSphere(&bgActor->boundingSphere, resultPos.y, resultPos.z))) { bgActor->boundingSphere.radius -= (s16)radius; continue; @@ -3624,8 +3647,8 @@ s32 BgCheck_CheckDynaCeilingList(CollisionContext* colCtx, u16 xpFlags, DynaColl polyId = curNode->polyId; poly = &dyna->polyList[polyId]; if (COLPOLY_VIA_FLAG_TEST(poly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (COLPOLY_VIA_FLAG_TEST(poly->flags_vIB, 4) && (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -3644,7 +3667,7 @@ s32 BgCheck_CheckDynaCeilingList(CollisionContext* colCtx, u16 xpFlags, DynaColl } if (CollisionPoly_CheckYIntersectApprox2(poly, dyna->vtxList, testPos.x, testPos.z, &ceilingY)) { intersectDist = ceilingY - testPos.y; - if (testPos.y < ceilingY && intersectDist < checkHeight && intersectDist * ny <= 0.0f) { + if ((testPos.y < ceilingY) && (intersectDist < checkHeight) && (intersectDist * ny <= 0.0f)) { sign = (0.0f <= ny) ? 1.0f : -1.0f; testPos.y = (sign * checkHeight) + ceilingY; result = true; @@ -3733,8 +3756,8 @@ s32 BgCheck_CheckLineAgainstBgActorSSList(DynaLineTest* dynaLineTest) { test.poly = &dynaLineTest->dyna->polyList[polyId]; if (COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIA, dynaLineTest->xpFlags) || (COLPOLY_VIA_FLAG_TEST(test.poly->flags_vIB, 4) && - ((dynaLineTest->actor != NULL && dynaLineTest->actor->category != ACTORCAT_PLAYER) || - (dynaLineTest->actor == NULL && dynaLineTest->xpFlags != COLPOLY_IGNORE_CAMERA)))) { + (((dynaLineTest->actor != NULL) && (dynaLineTest->actor->category != ACTORCAT_PLAYER)) || + ((dynaLineTest->actor == NULL) && (dynaLineTest->xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -3830,17 +3853,19 @@ s32 BgCheck_CheckLineAgainstDyna(CollisionContext* colCtx, u16 xpFlags, Vec3f* p if (actor != colCtx->dyna.bgActors[i].actor) { ay = posA->y; by = posB->y; - if (!(ay < colCtx->dyna.bgActors[i].minY) || !(by < colCtx->dyna.bgActors[i].minY)) { - if (!(colCtx->dyna.bgActors[i].maxY < ay) || !(colCtx->dyna.bgActors[i].maxY < by)) { - line.a = *posA; - line.b = *posB; - if (Math3D_LineVsSph(&colCtx->dyna.bgActors[i].boundingSphere, &line) != 0) { - if (BgCheck_CheckLineAgainstBgActor(colCtx, xpFlags, posA, posB, posResult, outPoly, distSq, - i, checkDist, bccFlags, actor)) { - *outBgId = i; - result = true; - } - } + if ((ay < colCtx->dyna.bgActors[i].minY) && (by < colCtx->dyna.bgActors[i].minY)) { + continue; + } + if ((ay > colCtx->dyna.bgActors[i].maxY) && (by > colCtx->dyna.bgActors[i].maxY)) { + continue; + } + line.a = *posA; + line.b = *posB; + if (Math3D_LineVsSph(&colCtx->dyna.bgActors[i].boundingSphere, &line) != 0) { + if (BgCheck_CheckLineAgainstBgActor(colCtx, xpFlags, posA, posB, posResult, outPoly, distSq, i, + checkDist, bccFlags, actor)) { + *outBgId = i; + result = true; } } } @@ -3870,10 +3895,9 @@ s32 BgCheck_SphVsFirstDynaPolyList(CollisionContext* colCtx, u16 xpFlags, Collis curPolyId = curNode->polyId; curPoly = &dyna->polyList[curPolyId]; if (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIA, xpFlags) || - (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && ((actor != NULL && actor->category != ACTORCAT_PLAYER) || - (actor == NULL && xpFlags != COLPOLY_IGNORE_CAMERA)))) - - { + (COLPOLY_VIA_FLAG_TEST(curPoly->flags_vIB, 4) && + (((actor != NULL) && (actor->category != ACTORCAT_PLAYER)) || + ((actor == NULL) && (xpFlags != COLPOLY_IGNORE_CAMERA))))) { if (curNode->next == SS_NULL) { break; } else { @@ -4016,7 +4040,7 @@ u32 SurfaceType_GetData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, SurfaceType* surfaceTypes; colHeader = BgCheck_GetCollisionHeader(colCtx, bgId); - if (colHeader == NULL || poly == NULL) { + if ((colHeader == NULL) || (poly == NULL)) { return 0; } surfaceTypes = colHeader->surfaceTypeList; @@ -4256,7 +4280,7 @@ u32 func_800C9BB8(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { u16 SurfaceType_GetSfx(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { s32 id = func_800C9BB8(colCtx, poly, bgId); - if (id < 0 || id > 14) { + if ((id < 0) || (id > 14)) { return NA_SE_PL_WALK_GROUND - SFX_FLAG; } return sSurfaceTypeSfx[id]; @@ -4268,7 +4292,7 @@ u16 SurfaceType_GetSfx(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) s32 func_800C9C24(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, s32 arg3) { s32 id = func_800C9BB8(colCtx, poly, bgId); - if (id < 0 || id > 14) { + if ((id < 0) || (id > 14)) { return 0; } return D_801B46C0[id] & arg3; @@ -4398,23 +4422,24 @@ u32 SurfaceType_IsWallDamage(CollisionContext* colCtx, CollisionPoly* poly, s32 s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId) { CollisionHeader* colHeader; - u32 room; - WaterBox* curWaterBox; + s32 room; s32 i; + WaterBox* curWaterBox; + BgActor* bgActor; *bgId = BGCHECK_SCENE; colHeader = colCtx->colHeader; - if (colHeader->numWaterBoxes != 0 && colHeader->waterBoxes != NULL) { + if ((colHeader->numWaterBoxes != 0) && (colHeader->waterBoxes != NULL)) { for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes; curWaterBox++) { room = 0x3F & (curWaterBox->properties >> 13); - if (room == (u32)play->roomCtx.curRoom.num || room == 0x3F) { + if ((room == play->roomCtx.curRoom.num) || (room == 0x3F)) { if (curWaterBox->properties & 0x80000) { continue; } - if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) { - if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) { + if ((curWaterBox->minPos.x < x) && (x < curWaterBox->minPos.x + curWaterBox->xLength)) { + if ((curWaterBox->minPos.z < z) && (z < curWaterBox->minPos.z + curWaterBox->zLength)) { *outWaterBox = curWaterBox; *ySurface = curWaterBox->minPos.y; return true; @@ -4425,27 +4450,24 @@ s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f3 } for (i = 0; i < BG_ACTOR_MAX; i++) { - if (colCtx->dyna.bgActorFlags[i] & 1) { - BgActor* bgActor; - if (colCtx->dyna.bgActorFlags[i] & 4) { - continue; - } - bgActor = &colCtx->dyna.bgActors[i]; - if (bgActor->colHeader->numWaterBoxes != 0 && bgActor->colHeader->waterBoxes != NULL) { - for (curWaterBox = colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex; - curWaterBox < colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex + - bgActor->colHeader->numWaterBoxes; - curWaterBox++) { - if (curWaterBox->properties & 0x80000) { - continue; - } - if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) { - if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) { - *outWaterBox = curWaterBox; - *ySurface = curWaterBox->minPos.y; - *bgId = i; - return true; - } + if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 4)) { + continue; + } + bgActor = &colCtx->dyna.bgActors[i]; + if ((bgActor->colHeader->numWaterBoxes != 0) && (bgActor->colHeader->waterBoxes != NULL)) { + for (curWaterBox = colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex; + curWaterBox < + colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex + bgActor->colHeader->numWaterBoxes; + curWaterBox++) { + if (curWaterBox->properties & 0x80000) { + continue; + } + if ((curWaterBox->minPos.x < x) && (x < curWaterBox->minPos.x + curWaterBox->xLength)) { + if ((curWaterBox->minPos.z < z) && (z < curWaterBox->minPos.z + curWaterBox->zLength)) { + *outWaterBox = curWaterBox; + *ySurface = curWaterBox->minPos.y; + *bgId = i; + return true; } } } @@ -4467,7 +4489,6 @@ s32 WaterBox_GetSurface1_2(PlayState* play, CollisionContext* colCtx, f32 x, f32 return WaterBox_GetSurfaceImpl(play, colCtx, x, z, ySurface, outWaterBox, &bgId); } -#ifdef NON_MATCHING /** * Gets the first active WaterBox at `pos` where WaterBox.properties & 0x80000 == 0 * `surfaceCheckDist` is the absolute y distance from the water surface to check @@ -4480,12 +4501,13 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, s32 room; s32 i; WaterBox* waterBox; + BgActor* bgActor; *bgId = BGCHECK_SCENE; colHeader = colCtx->colHeader; //! @bug: check skips testing BgActor waterboxes - if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == NULL) { + if ((colHeader->numWaterBoxes == 0) || (colHeader->waterBoxes == NULL)) { *outWaterBox = NULL; return -1; } @@ -4494,15 +4516,16 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, waterBox = &colHeader->waterBoxes[i]; room = WATERBOX_ROOM(waterBox->properties); - if (!(room == play->roomCtx.curRoom.num || room == 0x3F)) { + if ((room != play->roomCtx.curRoom.num) && (room != 0x3F)) { continue; } if ((waterBox->properties & 0x80000)) { continue; } - if ((waterBox->minPos.x < pos->x && pos->x < waterBox->minPos.x + waterBox->xLength)) { - if ((waterBox->minPos.z < pos->z && pos->z < waterBox->minPos.z + waterBox->zLength)) { - if (pos->y - surfaceCheckDist < waterBox->minPos.y && waterBox->minPos.y < pos->y + surfaceCheckDist) { + if (((waterBox->minPos.x < pos->x) && (pos->x < waterBox->minPos.x + waterBox->xLength))) { + if ((waterBox->minPos.z < pos->z) && (pos->z < waterBox->minPos.z + waterBox->zLength)) { + if ((pos->y - surfaceCheckDist < waterBox->minPos.y) && + (waterBox->minPos.y < pos->y + surfaceCheckDist)) { *outWaterBox = waterBox; return i; } @@ -4511,27 +4534,25 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, } for (i = 0; i < BG_ACTOR_MAX; i++) { - WaterBox* iterator; - WaterBox* start; - BgActor* bgActor; + if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 4) || (colCtx->dyna.bgActorFlags[i] & 2)) { continue; } bgActor = &colCtx->dyna.bgActors[i]; - for (iterator = colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex; - iterator < + for (waterBox = colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex; + waterBox < colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex + bgActor->colHeader->numWaterBoxes; - iterator++) { - if (iterator->properties & 0x80000) { + waterBox++) { + if (waterBox->properties & 0x80000) { continue; } - if ((iterator->minPos.x < pos->x) && pos->x < iterator->minPos.x + iterator->xLength) { - if ((iterator->minPos.z < pos->z) && pos->z < iterator->minPos.z + iterator->zLength) { - if (pos->y - surfaceCheckDist < iterator->minPos.y && - iterator->minPos.y < pos->y + surfaceCheckDist) { + if ((waterBox->minPos.x < pos->x) && (pos->x < waterBox->minPos.x + waterBox->xLength)) { + if ((waterBox->minPos.z < pos->z) && (pos->z < waterBox->minPos.z + waterBox->zLength)) { + if ((pos->y - surfaceCheckDist < waterBox->minPos.y) && + (waterBox->minPos.y < pos->y + surfaceCheckDist)) { *bgId = i; - *outWaterBox = iterator; + *outWaterBox = waterBox; return i; } } @@ -4542,9 +4563,6 @@ s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, *outWaterBox = NULL; return -1; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/WaterBox_GetSurface2.s") -#endif f32 func_800CA568(CollisionContext* colCtx, s32 waterBoxId, s32 bgId) { CollisionHeader* colHeader; @@ -4611,7 +4629,6 @@ u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox) return prop & 0x1F; } -#ifdef NON_MATCHING /** * Get the water surface at point (`x`, `ySurface`, `z`). `ySurface` doubles as position y input * same as WaterBox_GetSurfaceImpl, but tests if WaterBox properties & 0x80000 != 0 @@ -4621,62 +4638,61 @@ u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox) s32 func_800CA6F0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox, s32* bgId) { CollisionHeader* colHeader; - u32 room; - WaterBox* curWaterBox; s32 i; + WaterBox* curWaterBox; BgActor* bgActor; + s32 room; - colHeader = colCtx->colHeader; *outWaterBox = NULL; *bgId = BGCHECK_SCENE; + colHeader = colCtx->colHeader; - if (colHeader->numWaterBoxes == 0 || colHeader->waterBoxes == NULL) { + if ((colHeader->numWaterBoxes == 0) || (colHeader->waterBoxes == NULL)) { return false; } for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes; curWaterBox++) { room = WATERBOX_ROOM(curWaterBox->properties); - if (room == (u32)play->roomCtx.curRoom.num || room == 0x3F) { - if ((curWaterBox->properties & 0x80000) != 0) { - if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) { - if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) { - *outWaterBox = curWaterBox; - *ySurface = curWaterBox->minPos.y; - return true; - } - } + + if ((room != play->roomCtx.curRoom.num) && (room != 0x3F)) { + continue; + } + if (!(curWaterBox->properties & 0x80000)) { + continue; + } + if ((curWaterBox->minPos.x < x) && (x < curWaterBox->minPos.x + curWaterBox->xLength)) { + if ((curWaterBox->minPos.z < z) && (z < curWaterBox->minPos.z + curWaterBox->zLength)) { + *outWaterBox = curWaterBox; + *ySurface = curWaterBox->minPos.y; + return true; } } } - for (i = 0; i < BG_ACTOR_MAX; i++) { - if ((colCtx->dyna.bgActorFlags[i] & 1) && !(colCtx->dyna.bgActorFlags[i] & 2)) { - WaterBox* boxes; - boxes = colCtx->dyna.waterBoxList.boxes; - bgActor = &colCtx->dyna.bgActors[i]; - if (bgActor->colHeader->numWaterBoxes != 0 && bgActor->colHeader->waterBoxes != NULL) { - for (curWaterBox = boxes + bgActor->waterboxesStartIndex; - curWaterBox < boxes + bgActor->waterboxesStartIndex + bgActor->colHeader->numWaterBoxes; - curWaterBox++) { - if ((curWaterBox->properties & 0x80000) != 0) { - if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) { - if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) { - *outWaterBox = curWaterBox; - *ySurface = curWaterBox->minPos.y; - *bgId = i; - return true; - } - } - } + if (!(colCtx->dyna.bgActorFlags[i] & 1) || (colCtx->dyna.bgActorFlags[i] & 2)) { + continue; + } + bgActor = &colCtx->dyna.bgActors[i]; + + for (curWaterBox = colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex; + curWaterBox < + colCtx->dyna.waterBoxList.boxes + bgActor->waterboxesStartIndex + bgActor->colHeader->numWaterBoxes; + curWaterBox++) { + if (!(curWaterBox->properties & 0x80000)) { + continue; + } + if ((curWaterBox->minPos.x < x) && (x < curWaterBox->minPos.x + curWaterBox->xLength)) { + if ((curWaterBox->minPos.z < z) && (z < curWaterBox->minPos.z + curWaterBox->zLength)) { + *outWaterBox = curWaterBox; + *ySurface = curWaterBox->minPos.y; + *bgId = i; + return true; } } } } return false; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800CA6F0.s") -#endif s32 func_800CA9D0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { s32 bgId; diff --git a/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c b/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c index 07a42fce8..10cea7035 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c +++ b/src/overlays/actors/ovl_Bg_Haka_Bombwall/z_bg_haka_bombwall.c @@ -137,7 +137,7 @@ void func_80BD5E6C(BgHakaBombwall* this, PlayState* play) { } EffectSsKakera_Spawn(play, &spE0, &spD4, &spE0, gravity, phi_s0, 30, 0, 0, D_80BD64CC[i & 3], phi_t0, 0, 50, -1, - OBJECT_IKANA_OBJ, object_haka_obj_DL_001680); + OBJECT_HAKA_OBJ, object_haka_obj_DL_001680); } Matrix_Pop(); diff --git a/src/overlays/actors/ovl_Boss_06/z_boss_06.c b/src/overlays/actors/ovl_Boss_06/z_boss_06.c index c6cedef2b..a72dcf8b3 100644 --- a/src/overlays/actors/ovl_Boss_06/z_boss_06.c +++ b/src/overlays/actors/ovl_Boss_06/z_boss_06.c @@ -182,7 +182,7 @@ void func_809F24A8(Boss06* this) { } #ifdef NON_MATCHING -// Weird loading of 1 +// The 1 constant from the switch branch is reused in case 2 for some reason. void func_809F24C8(Boss06* this, PlayState* play) { s16 sp4E = 0; Player* player = GET_PLAYER(play); From a848bb138d7898eacee3181d33fc5c1b7114c639 Mon Sep 17 00:00:00 2001 From: Parker Burnett Date: Thu, 20 Oct 2022 20:01:59 -0700 Subject: [PATCH 03/10] Hg and Hgo documented (#1112) * inital work * en_hg done-zo * finished hgo * forgot to format... * review comments from anon * fixing review comments * fixing comments * update name * fix --- assets/xml/objects/object_harfgibud.xml | 235 ++++++++--------- src/overlays/actors/ovl_En_Hg/z_en_hg.c | 300 ++++++++++++---------- src/overlays/actors/ovl_En_Hg/z_en_hg.h | 8 +- src/overlays/actors/ovl_En_Hgo/z_en_hgo.c | 258 +++++++++++-------- src/overlays/actors/ovl_En_Hgo/z_en_hgo.h | 20 +- tools/disasm/functions.txt | 50 ++-- 6 files changed, 477 insertions(+), 394 deletions(-) diff --git a/assets/xml/objects/object_harfgibud.xml b/assets/xml/objects/object_harfgibud.xml index 61e1fc457..99578e996 100644 --- a/assets/xml/objects/object_harfgibud.xml +++ b/assets/xml/objects/object_harfgibud.xml @@ -1,128 +1,131 @@  + - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.c b/src/overlays/actors/ovl_En_Hg/z_en_hg.c index 127ea54af..38062e995 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.c +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.c @@ -15,22 +15,39 @@ void EnHg_Destroy(Actor* thisx, PlayState* play); void EnHg_Update(Actor* thisx, PlayState* play); void EnHg_Draw(Actor* thisx, PlayState* play); -void func_80BCF354(EnHg* this); -void func_80BCF398(EnHg* this, PlayState* play); -void func_80BCF468(EnHg* this); -void func_80BCF468(EnHg* this); -void func_80BCF4AC(EnHg* this, PlayState* play); -void func_80BCF5F0(EnHg* this); -void func_80BCF634(EnHg* this, PlayState* play); -void func_80BCF68C(EnHg* this); -void func_80BCF6D0(EnHg* this, PlayState* play); -void func_80BCF8A0(EnHg* this, PlayState* play); -void func_80BCF93C(EnHg* this); -void func_80BCF95C(EnHg* this, PlayState* play); +void EnHg_SetupWait(EnHg* this); +void EnHg_Wait(EnHg* this, PlayState* play); +void EnHg_SetupChasePlayer(EnHg* this); +void EnHg_ChasePlayer(EnHg* this, PlayState* play); +void EnHg_SetupChasePlayerWait(EnHg* this); +void EnHg_ChasePlayerWait(EnHg* this, PlayState* play); +void EnHg_SetupReactToHit(EnHg* this); +void EnHg_ReactToHit(EnHg* this, PlayState* play); +void EnHg_PlayCutscene(EnHg* this, PlayState* play); +void EnHg_SetupCsAction(EnHg* this); +void EnHg_HandleCsAction(EnHg* this, PlayState* play); s32 EnHg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); void EnHg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx); -ActorInit En_Hg_InitVars = { +typedef enum { + /* 0 */ HG_ANIM_IDLE, + /* 1 */ HG_ANIM_LURCH_FORWARD, + /* 2 */ HG_ANIM_RECOIL, + /* 3 */ HG_ANIM_LEAN_FORWARD, + /* 4 */ HG_ANIM_REACH_FORWARD, + /* 5 */ HG_ANIM_CURL_UP, + /* 6 */ HG_ANIM_CROUCHED_PANIC, + /* 7 */ HG_ANIM_PANIC, +} HgAnimation; + +typedef enum { + /* 0 */ HG_CS_FIRST_ENCOUNTER, + /* 1 */ HG_CS_GET_MASK, + /* 2 */ HG_CS_SUBSEQUENT_ENCOUNTER, + /* 3 */ HG_CS_SONG_OF_HEALING, +} HgCsIndex; + +const ActorInit En_Hg_InitVars = { ACTOR_EN_HG, ACTORCAT_PROP, FLAGS, @@ -102,17 +119,17 @@ static CollisionCheckInfoInit2 sColChkInfoInit2 = { }; static AnimationInfo sAnimationInfo[] = { - { &object_harfgibud_Anim_00260C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &object_harfgibud_Anim_009D44, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &object_harfgibud_Anim_00A164, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &object_harfgibud_Anim_000370, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &object_harfgibud_Anim_001138, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_harfgibud_Anim_0015D4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &object_harfgibud_Anim_001960, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_harfgibud_Anim_00AE1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gPamelasFatherIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &gPamelasFatherLurchForwardAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &gPamelasFatherRecoilFromHitAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &gPamelasFatherLeanForwardAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gPamelasFatherReachForwardAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gPamelasFatherCurlUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gPamelasFatherCrouchedPanicAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gPamelasFatherPanicAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; -static u32 D_80BD00C8 = false; +static u32 sHasSoundPlayed = false; void EnHg_Init(Actor* thisx, PlayState* play) { EnHg* this = THIS; @@ -120,8 +137,8 @@ void EnHg_Init(Actor* thisx, PlayState* play) { s32 i; ActorShape_Init(&this->actor.shape, 0.0f, NULL, 36.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &gHarfgibudGibdoSkel, &object_harfgibud_Anim_00260C, this->jointTable, - this->morphTable, HARFGIBUD_GIBDO_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gPamelasFatherGibdoSkel, &gPamelasFatherIdleAnim, this->jointTable, + this->morphTable, PAMELAS_FATHER_GIBDO_LIMB_MAX); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit2); @@ -138,7 +155,7 @@ void EnHg_Init(Actor* thisx, PlayState* play) { this->cutscenes[i] = currentCutscene; currentCutscene = ActorCutscene_GetAdditionalCutscene(currentCutscene); } - func_80BCF354(this); + EnHg_SetupWait(this); } void EnHg_Destroy(Actor* thisx, PlayState* play) { @@ -147,16 +164,16 @@ void EnHg_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -void func_80BCF354(EnHg* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); - this->actionFunc = func_80BCF398; +void EnHg_SetupWait(EnHg* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_IDLE); + this->actionFunc = EnHg_Wait; } -void func_80BCF398(EnHg* this, PlayState* play) { +void EnHg_Wait(EnHg* this, PlayState* play) { if (this->actor.colChkInfo.health == 1) { if ((this->actor.xzDistToPlayer < 200.0f && this->actor.playerHeightRel < 40.0f) && !Cutscene_CheckActorAction(play, 0x1E3)) { - func_80BCF468(this); + EnHg_SetupChasePlayer(this); } if ((gSaveContext.sceneLayer == 0) && (play->csCtx.currentCsIndex == 0) && ((play->csCtx.frames == 20) || (play->csCtx.frames == 60))) { @@ -165,12 +182,12 @@ void func_80BCF398(EnHg* this, PlayState* play) { } } -void func_80BCF468(EnHg* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); - this->actionFunc = func_80BCF4AC; +void EnHg_SetupChasePlayer(EnHg* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_LURCH_FORWARD); + this->actionFunc = EnHg_ChasePlayer; } -void func_80BCF4AC(EnHg* this, PlayState* play) { +void EnHg_ChasePlayer(EnHg* this, PlayState* play) { Player* player = GET_PLAYER(play); s32 pad; @@ -184,38 +201,39 @@ void func_80BCF4AC(EnHg* this, PlayState* play) { } if ((Math_Vec3f_DistXZ(&this->actor.world.pos, &this->actor.home.pos) > 200.0f) && (Math_Vec3f_DistXZ(&player->actor.world.pos, &this->actor.home.pos) > 200.0f)) { - func_80BCF5F0(this); + EnHg_SetupChasePlayerWait(this); } } } -void func_80BCF5F0(EnHg* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); - this->actionFunc = func_80BCF634; +void EnHg_SetupChasePlayerWait(EnHg* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_IDLE); + this->actionFunc = EnHg_ChasePlayerWait; } -void func_80BCF634(EnHg* this, PlayState* play) { +void EnHg_ChasePlayerWait(EnHg* this, PlayState* play) { Player* player = GET_PLAYER(play); if (Math_Vec3f_DistXZ(&player->actor.world.pos, &this->actor.home.pos) < 200.0f) { - func_80BCF468(this); + EnHg_SetupChasePlayer(this); } } -void func_80BCF68C(EnHg* this) { - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); - this->actionFunc = func_80BCF6D0; +void EnHg_SetupReactToHit(EnHg* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_RECOIL); + this->actionFunc = EnHg_ReactToHit; } -void func_80BCF6D0(EnHg* this, PlayState* play) { +void EnHg_ReactToHit(EnHg* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - func_80BCF5F0(this); + EnHg_SetupChasePlayerWait(this); } } -void func_80BCF710(EnHg* this, PlayState* play) { +void EnHg_HandleTatlDialog(EnHg* this, PlayState* play) { if (Message_GetState(&play->msgCtx) == TEXT_STATE_NONE) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + // "...Sort of looks different..." Message_StartTextbox(play, 0x24F, &this->actor); } else { func_800B8614(&this->actor, play, 80.0f); @@ -223,53 +241,53 @@ void func_80BCF710(EnHg* this, PlayState* play) { } } -void func_80BCF778(EnHg* this, PlayState* play) { +void EnHg_PlayRedeadSfx(EnHg* this, PlayState* play) { if (this->actor.colChkInfo.health == 1) { - if (this->actionFunc == func_80BCF4AC || this->actionFunc == func_80BCF6D0 || - this->actionFunc == func_80BCF634) { + if ((this->actionFunc == EnHg_ChasePlayer) || (this->actionFunc == EnHg_ReactToHit) || + (this->actionFunc == EnHg_ChasePlayerWait)) { func_800B9010(&this->actor, NA_SE_EN_HALF_REDEAD_LOOP - SFX_FLAG); } } } -void func_80BCF7D8(EnHg* this, PlayState* play) { - if (this->actor.colChkInfo.health) { +void EnHg_UpdateCollision(EnHg* this, PlayState* play) { + if (this->actor.colChkInfo.health != 0) { if (this->collider.base.acFlags & AC_HIT) { this->collider.base.acFlags &= ~AC_HIT; - func_80BCF68C(this); + EnHg_SetupReactToHit(this); } Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - if (this->actionFunc != func_80BCF6D0 && this->actionFunc != func_80BCF8A0 && - this->actionFunc != func_80BCF95C) { + if ((this->actionFunc != EnHg_ReactToHit) && (this->actionFunc != EnHg_PlayCutscene) && + (this->actionFunc != EnHg_HandleCsAction)) { CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); } } } -void func_80BCF88C(EnHg* this) { - this->actionFunc = func_80BCF8A0; +void EnHg_SetupCutscene(EnHg* this) { + this->actionFunc = EnHg_PlayCutscene; } -void func_80BCF8A0(EnHg* this, PlayState* play) { - if (ActorCutscene_GetCanPlayNext(this->cutscenes[this->unk218])) { - ActorCutscene_Start(this->cutscenes[this->unk218], &this->actor); - func_80BCF93C(this); +void EnHg_PlayCutscene(EnHg* this, PlayState* play) { + if (ActorCutscene_GetCanPlayNext(this->cutscenes[this->cutsceneIndex])) { + ActorCutscene_Start(this->cutscenes[this->cutsceneIndex], &this->actor); + EnHg_SetupCsAction(this); } else { if (ActorCutscene_GetCurrentIndex() == 0x7C) { ActorCutscene_Stop(0x7C); } - ActorCutscene_SetIntentToPlay(this->cutscenes[this->unk218]); + ActorCutscene_SetIntentToPlay(this->cutscenes[this->cutsceneIndex]); } } -void func_80BCF93C(EnHg* this) { +void EnHg_SetupCsAction(EnHg* this) { this->cutscenes[3] = 0x63; this->cutscenes[2] = 0; - this->actionFunc = func_80BCF95C; + this->actionFunc = EnHg_HandleCsAction; } -void func_80BCF95C(EnHg* this, PlayState* play) { +void EnHg_HandleCsAction(EnHg* this, PlayState* play) { if (Cutscene_CheckActorAction(play, 484)) { s32 actionIndex = Cutscene_GetActorActionIndex(play, 484); @@ -278,109 +296,129 @@ void func_80BCF95C(EnHg* this, PlayState* play) { switch (play->csCtx.actorActions[actionIndex]->action) { case 1: this->animIndex = 0; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_IDLE); break; + case 2: this->cutscenes[2] = 0; - this->animIndex = 3; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); + this->animIndex = HG_ANIM_LEAN_FORWARD; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_LEAN_FORWARD); break; + case 3: this->cutscenes[2] = 0; - this->animIndex = 5; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); + this->animIndex = HG_ANIM_CURL_UP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_CURL_UP); break; + case 4: this->cutscenes[2] = 0; - this->animIndex = 7; - if ((this->unk218 == 1) || (this->unk218 == 3)) { + this->animIndex = HG_ANIM_PANIC; + if ((this->cutsceneIndex == HG_CS_GET_MASK) || (this->cutsceneIndex == HG_CS_SONG_OF_HEALING)) { func_8019F128(NA_SE_EN_HALF_REDEAD_TRANS); } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 7); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_PANIC); break; + case 5: - this->animIndex = 1; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); + this->animIndex = HG_ANIM_LURCH_FORWARD; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_LURCH_FORWARD); break; + case 6: gSaveContext.save.weekEventReg[75] |= 0x20; Actor_Kill(&this->actor); break; } - } else { - if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - switch (this->animIndex) { - case 3: - this->animIndex = 4; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); - break; - case 5: - this->animIndex = 6; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 6); - break; - } + } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + switch (this->animIndex) { + case HG_ANIM_LEAN_FORWARD: + this->animIndex = HG_ANIM_REACH_FORWARD; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_REACH_FORWARD); + break; + + case HG_ANIM_CURL_UP: + this->animIndex = HG_ANIM_CROUCHED_PANIC; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, HG_ANIM_CROUCHED_PANIC); + break; } } + switch (this->animIndex) { - case 3: - case 4: + case HG_ANIM_LEAN_FORWARD: + case HG_ANIM_REACH_FORWARD: func_800B9010(&this->actor, NA_SE_EN_HALF_REDEAD_LOOP - SFX_FLAG); break; - case 5: - case 6: + + case HG_ANIM_CURL_UP: + case HG_ANIM_CROUCHED_PANIC: func_800B9010(&this->actor, NA_SE_EN_HALF_REDEAD_SCREAME - SFX_FLAG); break; - case 7: - if ((this->unk218 == 0) || (this->unk218 == 2)) { + + case HG_ANIM_PANIC: + if ((this->cutsceneIndex == HG_CS_FIRST_ENCOUNTER) || + (this->cutsceneIndex == HG_CS_SUBSEQUENT_ENCOUNTER)) { func_800B9010(&this->actor, NA_SE_EN_HALF_REDEAD_SCREAME - SFX_FLAG); } break; } + Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); return; + } else if (play->csCtx.state == 0) { - func_80BCF354(this); + EnHg_SetupWait(this); } + this->cutscenes[3] = 0x63; } -void func_80BCFC0C(EnHg* this, PlayState* play) { +void EnHg_WaitForPlayerAction(EnHg* this, PlayState* play) { Player* player = GET_PLAYER(play); - if (this->actor.colChkInfo.health == 1 && !(fabsf(this->actor.playerHeightRel) >= 80.0f)) { - if (player->stateFlags2 & PLAYER_STATE2_8000000) { - if (!D_80BD00C8) { - play_sound(NA_SE_SY_TRE_BOX_APPEAR); - } - D_80BD00C8 = true; - } else { - D_80BD00C8 = false; + // If the player has gone upstairs this interaction will not trigger + if ((this->actor.colChkInfo.health != 1) || (fabsf(this->actor.playerHeightRel) >= 80.0f)) { + return; + } + + if (player->stateFlags2 & PLAYER_STATE2_8000000) { + if (!sHasSoundPlayed) { + play_sound(NA_SE_SY_TRE_BOX_APPEAR); } - if (play->msgCtx.ocarinaMode == 3) { - if (play->msgCtx.lastPlayedSong == OCARINA_SONG_HEALING && - gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { - if (INV_CONTENT(ITEM_MASK_GIBDO) == ITEM_MASK_GIBDO) { - this->unk218 = 3; + sHasSoundPlayed = true; + } else { + sHasSoundPlayed = false; + } + + if (play->msgCtx.ocarinaMode == 3) { + if ((play->msgCtx.lastPlayedSong == OCARINA_SONG_HEALING) && + (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN)) { + if (INV_CONTENT(ITEM_MASK_GIBDO) == ITEM_MASK_GIBDO) { + this->cutsceneIndex = HG_CS_SONG_OF_HEALING; + } else { + this->cutsceneIndex = HG_CS_GET_MASK; + } + + EnHg_SetupCutscene(this); + } + + } else { + if ((this->actor.xzDistToPlayer < 60.0f) && (fabsf(this->actor.playerHeightRel) < 40.0f)) { + if ((this->actionFunc != EnHg_PlayCutscene) && (this->actionFunc != EnHg_HandleCsAction)) { + + if (!(gSaveContext.save.weekEventReg[61] & 2)) { + gSaveContext.save.weekEventReg[61] |= 2; + this->cutsceneIndex = HG_CS_FIRST_ENCOUNTER; } else { - this->unk218 = 1; + this->cutsceneIndex = HG_CS_SUBSEQUENT_ENCOUNTER; } - func_80BCF88C(this); + + EnHg_SetupCutscene(this); + return; } - } else { - if (this->actor.xzDistToPlayer < 60.0f && fabsf(this->actor.playerHeightRel) < 40.0f) { - if ((this->actionFunc != func_80BCF8A0) && (this->actionFunc != func_80BCF95C)) { - if (!(gSaveContext.save.weekEventReg[61] & 2)) { - gSaveContext.save.weekEventReg[61] |= 2; - this->unk218 = 0; - } else { - this->unk218 = 2; - } - func_80BCF88C(this); - return; - } - } - func_80BCF710(this, play); } + + EnHg_HandleTatlDialog(this, play); } } @@ -389,10 +427,10 @@ void EnHg_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); - func_80BCF7D8(this, play); - func_80BCFC0C(this, play); + EnHg_UpdateCollision(this, play); + EnHg_WaitForPlayerAction(this, play); Actor_UpdateBgCheckInfo(play, &this->actor, 30.0f, 25.0f, 0.0f, 5); - func_80BCF778(this, play); + EnHg_PlayRedeadSfx(this, play); } s32 EnHg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { @@ -401,9 +439,9 @@ s32 EnHg_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* po void EnHg_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { EnHg* this = THIS; - if (limbIndex == HARFGIBUD_GIBDO_LIMB_EYEBROWS) { - Matrix_Get(&this->unk1D8); - } else if (limbIndex == HARFGIBUD_GIBDO_LIMB_HEAD) { + if (limbIndex == PAMELAS_FATHER_GIBDO_LIMB_EYEBROWS) { + Matrix_Get(&this->mf); + } else if (limbIndex == PAMELAS_FATHER_GIBDO_LIMB_HEAD) { Matrix_MultZero(&this->actor.focus.pos); } } @@ -415,8 +453,8 @@ void EnHg_Draw(Actor* thisx, PlayState* play) { func_8012C28C(play->state.gfxCtx); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnHg_OverrideLimbDraw, EnHg_PostLimbDraw, &this->actor); - Matrix_Put(&this->unk1D8); + Matrix_Put(&this->mf); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gHarfgibudGibdoEyebrowsDL); + gSPDisplayList(POLY_OPA_DISP++, gPamelasFatherGibdoEyebrowsDL); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Hg/z_en_hg.h b/src/overlays/actors/ovl_En_Hg/z_en_hg.h index eff7dbf9a..1211a4cf3 100644 --- a/src/overlays/actors/ovl_En_Hg/z_en_hg.h +++ b/src/overlays/actors/ovl_En_Hg/z_en_hg.h @@ -14,11 +14,11 @@ typedef struct EnHg { /* 0x144 */ ColliderCylinder collider; /* 0x190 */ SkelAnime skelAnime; /* 0x1D4 */ EnHgActionFunc actionFunc; - /* 0x1D8 */ MtxF unk1D8; - /* 0x218 */ s32 unk218; + /* 0x1D8 */ MtxF mf; + /* 0x218 */ s32 cutsceneIndex; /* 0x21C */ s32 animIndex; - /* 0x220 */ Vec3s jointTable[HARFGIBUD_GIBDO_LIMB_MAX]; - /* 0x292 */ Vec3s morphTable[HARFGIBUD_GIBDO_LIMB_MAX]; + /* 0x220 */ Vec3s jointTable[PAMELAS_FATHER_GIBDO_LIMB_MAX]; + /* 0x292 */ Vec3s morphTable[PAMELAS_FATHER_GIBDO_LIMB_MAX]; /* 0x304 */ UNK_TYPE1 pad304[0xC]; /* 0x310 */ u16 cutscenes[4]; } EnHg; // size = 0x318 diff --git a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c index add718bdc..56a88e45b 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.c @@ -15,19 +15,40 @@ void EnHgo_Destroy(Actor* thisx, PlayState* play); void EnHgo_Update(Actor* thisx, PlayState* play); void EnHgo_Draw(Actor* thisx, PlayState* play); -void func_80BD03EC(EnHgo* this); -void func_80BD0410(EnHgo* this, PlayState* play); -void func_80BD0434(EnHgo* this, PlayState* play); -void func_80BD049C(EnHgo* this); -void func_80BD04E0(EnHgo* this, PlayState* play); +void EnHgo_SetupDoNothing(EnHgo* this); +void EnHgo_DoNothing(EnHgo* this, PlayState* play); +void EnHgo_UpdateCollision(EnHgo* this, PlayState* play); +void EnHgo_SetupTalk(EnHgo* this); +void EnHgo_Talk(EnHgo* this, PlayState* play); void EnHgo_SetupDialogueHandler(EnHgo* this); void EnHgo_DefaultDialogueHandler(EnHgo* this, PlayState* play); -void func_80BD06FC(EnHgo* this, PlayState* play); -s32 func_80BD0898(EnHgo* this, PlayState* play); +void EnHgo_HandlePlayerChoice(EnHgo* this, PlayState* play); +s32 EnHgo_HandleCsAction(EnHgo* this, PlayState* play); s32 EnHgo_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx); void EnHgo_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* pos, Actor* thisx); -ActorInit En_Hgo_InitVars = { +#define TALK_FLAG_NONE 0 +#define TALK_FLAG_HAS_SPOKEN_WITH_HUMAN (1 << 0) +#define TALK_FLAG_HAS_SPOKEN_WITH_OTHER_MASK_FORM (1 << 1) +#define TALK_FLAG_HAS_SPOKEN_WITH_GIBDO_MASK (1 << 2) + +typedef enum { + /* 0 */ HGO_EYE_OPEN, + /* 1 */ HGO_EYE_HALF, + /* 2 */ HGO_EYE_CLOSED +} EyeState; + +typedef enum { + /* 0 */ HGO_ANIM_ARMS_FOLDED, + /* 1 */ HGO_ANIM_ASTONISHED, + /* 2 */ HGO_ANIM_KNEEL_DOWN_AND_HUG, + /* 3 */ HGO_ANIM_CONSOLE, + /* 4 */ HGO_ANIM_CONSOLE_HEAD_UP, + /* 5 */ HGO_ANIM_REACH_DOWN_TO_LIFT, + /* 6 */ HGO_ANIM_TOSS, +} HgoAnimation; + +const ActorInit En_Hgo_InitVars = { ACTOR_EN_HGO, ACTORCAT_NPC, FLAGS, @@ -40,13 +61,13 @@ ActorInit En_Hgo_InitVars = { }; static AnimationInfo sAnimationInfo[] = { - { &object_harfgibud_Anim_00B644, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, - { &object_harfgibud_Anim_013684, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_harfgibud_Anim_0152EC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &object_harfgibud_Anim_015C70, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_harfgibud_Anim_0165F0, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_harfgibud_Anim_014220, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &object_harfgibud_Anim_014A9C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gPamelasFatherArmsFoldedAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &gPamelasFatherAstonishedAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gPamelasFatherKneelDownAndHugAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gPamelasFatherConsoleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gPamelasFatherConsoleHeadUpAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gPamelasFatherReachDownToLiftAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gPamelasFatherTossAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -71,33 +92,27 @@ static ColliderCylinderInit sCylinderInit = { static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -static TexturePtr sEyeTextures[] = { - object_harfgibud_Tex_011138, - object_harfgibud_Tex_011938, - object_harfgibud_Tex_012138, -}; - void EnHgo_Init(Actor* thisx, PlayState* play) { - EnHgo* this = THIS; s32 pad; + EnHgo* this = THIS; ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawCircle, 36.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &gHarfgibudHumanSkel, &object_harfgibud_Anim_00B644, this->jointTable, - this->morphTable, HARFGIBUD_HUMAN_LIMB_MAX); + SkelAnime_InitFlex(play, &this->skelAnime, &gPamelasFatherHumanSkel, &gPamelasFatherArmsFoldedAnim, + this->jointTable, this->morphTable, PAMELAS_FATHER_HUMAN_LIMB_MAX); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&thisx->colChkInfo, NULL, &sColChkInfoInit); thisx->targetMode = 6; - this->unk_30C = 0; - this->unk_30E = 0; - this->unk_314 = 0; - this->unk_310 = 0; - this->unk_312 = 0; + this->eyeIndex = 0; + this->blinkTimer = 0; + this->textId = 0; + this->talkFlags = TALK_FLAG_NONE; + this->isInCutscene = false; if ((gSaveContext.save.weekEventReg[75] & 0x20) || (gSaveContext.save.weekEventReg[52] & 0x20)) { - func_80BD049C(this); + EnHgo_SetupTalk(this); } else { thisx->draw = NULL; - func_80BD03EC(this); + EnHgo_SetupDoNothing(this); } } @@ -107,59 +122,59 @@ void EnHgo_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyCylinder(play, &this->collider); } -void func_80BD03EC(EnHgo* this) { +void EnHgo_SetupDoNothing(EnHgo* this) { this->actor.flags &= ~ACTOR_FLAG_1; - this->actionFunc = func_80BD0410; + this->actionFunc = EnHgo_DoNothing; } -void func_80BD0410(EnHgo* this, PlayState* play) { +void EnHgo_DoNothing(EnHgo* this, PlayState* play) { } -void func_80BD0420(EnHgo* this) { - this->actionFunc = func_80BD0434; +void EnHgo_SetupInitCollision(EnHgo* this) { + this->actionFunc = EnHgo_UpdateCollision; } -void func_80BD0434(EnHgo* this, PlayState* play) { +void EnHgo_UpdateCollision(EnHgo* this, PlayState* play) { this->collider.dim.pos.x = this->actor.focus.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.focus.pos.z; CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -void func_80BD049C(EnHgo* this) { +void EnHgo_SetupTalk(EnHgo* this) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); - this->actionFunc = func_80BD04E0; + this->actionFunc = EnHgo_Talk; } -void func_80BD04E0(EnHgo* this, PlayState* play) { +void EnHgo_Talk(EnHgo* this, PlayState* play) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (Player_GetMask(play) == PLAYER_MASK_GIBDO) { - if (!(this->unk_310 & 4)) { - this->unk_310 |= 4; + if (!(this->talkFlags & TALK_FLAG_HAS_SPOKEN_WITH_GIBDO_MASK)) { + this->talkFlags |= TALK_FLAG_HAS_SPOKEN_WITH_GIBDO_MASK; Message_StartTextbox(play, 0x15A5, &this->actor); - this->unk_314 = 0x15A5; // That mask is a gibdo + this->textId = 0x15A5; // That mask is a gibdo } else { Message_StartTextbox(play, 0x15A7, &this->actor); - this->unk_314 = 0x15A7; // can I research that mask + this->textId = 0x15A7; // can I research that mask } } else if (gSaveContext.save.playerForm == PLAYER_FORM_HUMAN) { - if (!(this->unk_310 & 1)) { - this->unk_310 |= 1; + if (!(this->talkFlags & TALK_FLAG_HAS_SPOKEN_WITH_HUMAN)) { + this->talkFlags |= TALK_FLAG_HAS_SPOKEN_WITH_HUMAN; Message_StartTextbox(play, 0x158F, &this->actor); - this->unk_314 = 0x158F; // Isn't this a fairy + this->textId = 0x158F; // Isn't this a fairy } else { Message_StartTextbox(play, 0x1593, &this->actor); - this->unk_314 = 0x1593; // Never seen a fairy this lively + this->textId = 0x1593; // Never seen a fairy this lively } } else { - if (!(this->unk_310 & 2)) { - this->unk_310 |= 2; + if (!(this->talkFlags & TALK_FLAG_HAS_SPOKEN_WITH_OTHER_MASK_FORM)) { + this->talkFlags |= TALK_FLAG_HAS_SPOKEN_WITH_OTHER_MASK_FORM; Message_StartTextbox(play, 0x1595, &this->actor); - this->unk_314 = 0x1595; // ghost radar is reacting + this->textId = 0x1595; // ghost radar is reacting } else { Message_StartTextbox(play, 0x1598, &this->actor); - this->unk_314 = 0x1598; // you seem to be similar to a ghost + this->textId = 0x1598; // you seem to be similar to a ghost } } EnHgo_SetupDialogueHandler(this); @@ -182,12 +197,12 @@ void EnHgo_DefaultDialogueHandler(EnHgo* this, PlayState* play) { break; case TEXT_STATE_5: - func_80BD06FC(this, play); + EnHgo_HandlePlayerChoice(this, play); break; case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { - func_80BD049C(this); + EnHgo_SetupTalk(this); } break; } @@ -196,109 +211,128 @@ void EnHgo_DefaultDialogueHandler(EnHgo* this, PlayState* play) { this->actor.shape.rot.y = this->actor.world.rot.y; } -void func_80BD06FC(EnHgo* this, PlayState* play) { +// Handles the next dialogue based on player's selection +void EnHgo_HandlePlayerChoice(EnHgo* this, PlayState* play) { if (Message_ShouldAdvance(play)) { - switch (this->unk_314) { + switch (this->textId) { case 0x158F: Message_StartTextbox(play, 0x1590, &this->actor); - this->unk_314 = 0x1590; + this->textId = 0x1590; break; + case 0x1590: if (gSaveContext.save.weekEventReg[14] & 4) { Message_StartTextbox(play, 0x1591, &this->actor); - this->unk_314 = 0x1591; + this->textId = 0x1591; break; } + Message_StartTextbox(play, 0x1592, &this->actor); - this->unk_314 = 0x1592; + this->textId = 0x1592; break; + case 0x1591: Message_StartTextbox(play, 0x1592, &this->actor); - this->unk_314 = 0x1592; + this->textId = 0x1592; break; + case 0x1593: Message_StartTextbox(play, 0x1594, &this->actor); - this->unk_314 = 0x1594; + this->textId = 0x1594; break; + case 0x1595: Message_StartTextbox(play, 0x1596, &this->actor); - this->unk_314 = 0x1596; + this->textId = 0x1596; break; + case 0x1596: Message_StartTextbox(play, 0x1597, &this->actor); - this->unk_314 = 0x1597; + this->textId = 0x1597; break; + case 0x1598: Message_StartTextbox(play, 0x1599, &this->actor); - this->unk_314 = 0x1599; + this->textId = 0x1599; break; + case 0x15A5: Message_StartTextbox(play, 0x15A6, &this->actor); - this->unk_314 = 0x15A6; + this->textId = 0x15A6; break; + case 0x15A6: Message_StartTextbox(play, 0x15A7, &this->actor); - this->unk_314 = 0x15A7; + this->textId = 0x15A7; break; + case 0x15A7: func_801477B4(play); - func_80BD049C(this); + EnHgo_SetupTalk(this); break; } } } -s32 func_80BD0898(EnHgo* this, PlayState* play) { +s32 EnHgo_HandleCsAction(EnHgo* this, PlayState* play) { s32 actionIndex; if (Cutscene_CheckActorAction(play, 486)) { actionIndex = Cutscene_GetActorActionIndex(play, 486); - if (this->unk_316 != play->csCtx.actorActions[actionIndex]->action) { - this->unk_316 = play->csCtx.actorActions[actionIndex]->action; + if (this->csAction != play->csCtx.actorActions[actionIndex]->action) { + this->csAction = play->csCtx.actorActions[actionIndex]->action; switch (play->csCtx.actorActions[actionIndex]->action) { case 1: - this->unk_218 = 0; + this->animIndex = HGO_ANIM_ARMS_FOLDED; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); break; + case 2: this->actor.draw = EnHgo_Draw; - this->unk_218 = 1; + this->animIndex = HGO_ANIM_ASTONISHED; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); break; + case 3: - this->unk_218 = 2; + this->animIndex = HGO_ANIM_KNEEL_DOWN_AND_HUG; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); break; + case 4: - this->unk_218 = 3; + this->animIndex = HGO_ANIM_CONSOLE; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); break; + case 5: - this->unk_218 = 4; + this->animIndex = HGO_ANIM_CONSOLE_HEAD_UP; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); break; + case 6: - this->unk_218 = 5; + this->animIndex = HGO_ANIM_REACH_DOWN_TO_LIFT; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 5); break; } } else if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - switch (this->unk_218) { - case 1: - if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && (this->unk_312 == 0)) { - this->unk_312 = 1; + switch (this->animIndex) { + case HGO_ANIM_ASTONISHED: + if ((Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) && + (this->isInCutscene == false)) { + this->isInCutscene = true; if ((gSaveContext.sceneLayer == 0) && ((play->csCtx.currentCsIndex == 2) || (play->csCtx.currentCsIndex == 4))) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_GBVO02); } } break; - case 2: - this->unk_218 = 3; + + case HGO_ANIM_KNEEL_DOWN_AND_HUG: + this->animIndex = HGO_ANIM_CONSOLE; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); break; - case 5: - this->unk_218 = 6; + + case HGO_ANIM_REACH_DOWN_TO_LIFT: + this->animIndex = HGO_ANIM_TOSS; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 6); } } @@ -306,30 +340,32 @@ s32 func_80BD0898(EnHgo* this, PlayState* play) { Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); return true; } + if ((play->csCtx.state == 0) && (((gSaveContext.save.weekEventReg[75]) & 0x20)) && - (this->actionFunc == func_80BD0410)) { + (this->actionFunc == EnHgo_DoNothing)) { this->actor.shape.rot.y = this->actor.world.rot.y; Actor_Spawn(&play->actorCtx, play, ACTOR_ELF_MSG2, this->actor.focus.pos.x, this->actor.focus.pos.y, this->actor.focus.pos.z, 7, 0, 0, 0x7F5A); - func_80BD0420(this); + EnHgo_SetupInitCollision(this); } - this->unk_316 = 0x63; + + this->csAction = 0x63; return false; } -void func_80BD0B8C(EnHgo* this, PlayState* play) { +void EnHgo_UpdateModel(EnHgo* this, PlayState* play) { Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->torsoRot, this->actor.focus.pos); - if (this->unk_30E > 2) { - this->unk_30E--; - } else if (this->unk_30E == 2) { - this->unk_30C = 1; - this->unk_30E = 1; - } else if (this->unk_30E == 1) { - this->unk_30C = 2; - this->unk_30E = 0; + if (this->blinkTimer > 2) { + this->blinkTimer--; + } else if (this->blinkTimer == 2) { + this->eyeIndex = HGO_EYE_HALF; + this->blinkTimer = 1; + } else if (this->blinkTimer == 1) { + this->eyeIndex = HGO_EYE_CLOSED; + this->blinkTimer = 0; } else { - this->unk_30C = 0; - this->unk_30E = 60; + this->eyeIndex = HGO_EYE_OPEN; + this->blinkTimer = 60; } } @@ -339,13 +375,13 @@ void EnHgo_Update(Actor* thisx, PlayState* play) { this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); - if (func_80BD0898(this, play)) { + if (EnHgo_HandleCsAction(this, play)) { Actor_TrackNone(&this->headRot, &this->torsoRot); - } else if (this->actionFunc != func_80BD0410) { - if (this->actionFunc != func_80BD0434) { + } else if (this->actionFunc != EnHgo_DoNothing) { + if (this->actionFunc != EnHgo_UpdateCollision) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); - func_80BD0B8C(this, play); + EnHgo_UpdateModel(this, play); } } } @@ -353,7 +389,7 @@ void EnHgo_Update(Actor* thisx, PlayState* play) { s32 EnHgo_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnHgo* this = THIS; - if (limbIndex == HARFGIBUD_HUMAN_LIMB_HEAD) { + if (limbIndex == PAMELAS_FATHER_HUMAN_LIMB_HEAD) { rot->x += this->headRot.y; rot->z += this->headRot.x; } @@ -363,22 +399,28 @@ s32 EnHgo_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p void EnHgo_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* pos, Actor* thisx) { EnHgo* this = THIS; - if (limbIndex == HARFGIBUD_HUMAN_LIMB_HEAD) { - Matrix_Get(&this->unk_1D8); + if (limbIndex == PAMELAS_FATHER_HUMAN_LIMB_HEAD) { + Matrix_Get(&this->mf); Matrix_MultZero(&this->actor.focus.pos); } } +static TexturePtr sEyeTextures[] = { + gPamelasFatherHumanEyeOpenTex, + gPamelasFatherHumanEyeHalfTex, + gPamelasFatherHumanEyeClosedTex, +}; + void EnHgo_Draw(Actor* thisx, PlayState* play) { EnHgo* this = THIS; OPEN_DISPS(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->unk_30C])); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnHgo_OverrideLimbDraw, &EnHgo_PostLimbDraw, &this->actor); - Matrix_Put(&this->unk_1D8); + Matrix_Put(&this->mf); gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_OPA_DISP++, gHarfgibudHumanEyebrowsDL); + gSPDisplayList(POLY_OPA_DISP++, gPamelasFatherHumanEyebrowsDL); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.h b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.h index c9b0b53e1..6882c1127 100644 --- a/src/overlays/actors/ovl_En_Hgo/z_en_hgo.h +++ b/src/overlays/actors/ovl_En_Hgo/z_en_hgo.h @@ -13,18 +13,18 @@ typedef struct EnHgo { /* 0x144 */ ColliderCylinder collider; /* 0x190 */ SkelAnime skelAnime; /* 0x1D4 */ EnHgoActionFunc actionFunc; - /* 0x1D8 */ MtxF unk_1D8; - /* 0x218 */ s32 unk_218; - /* 0x21C */ Vec3s jointTable[HARFGIBUD_HUMAN_LIMB_MAX]; - /* 0x28E */ Vec3s morphTable[HARFGIBUD_HUMAN_LIMB_MAX]; + /* 0x1D8 */ MtxF mf; + /* 0x218 */ s32 animIndex; + /* 0x21C */ Vec3s jointTable[PAMELAS_FATHER_HUMAN_LIMB_MAX]; + /* 0x28E */ Vec3s morphTable[PAMELAS_FATHER_HUMAN_LIMB_MAX]; /* 0x300 */ Vec3s headRot; /* 0x306 */ Vec3s torsoRot; // Set, but not used - /* 0x30C */ s16 unk_30C; - /* 0x30E */ s16 unk_30E; - /* 0x310 */ s16 unk_310; - /* 0x312 */ s16 unk_312; - /* 0x314 */ u16 unk_314; - /* 0x316 */ u16 unk_316; + /* 0x30C */ s16 eyeIndex; + /* 0x30E */ s16 blinkTimer; + /* 0x310 */ s16 talkFlags; + /* 0x312 */ s16 isInCutscene; + /* 0x314 */ u16 textId; + /* 0x316 */ u16 csAction; } EnHgo; // size = 0x318 #endif // Z_EN_HGO_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 05c62d7e5..47ce688ca 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -15672,39 +15672,39 @@ 0x80BCEF0C:("EffKamejimaWave_Draw",), 0x80BCF1D0:("EnHg_Init",), 0x80BCF328:("EnHg_Destroy",), - 0x80BCF354:("func_80BCF354",), - 0x80BCF398:("func_80BCF398",), - 0x80BCF468:("func_80BCF468",), - 0x80BCF4AC:("func_80BCF4AC",), - 0x80BCF5F0:("func_80BCF5F0",), - 0x80BCF634:("func_80BCF634",), - 0x80BCF68C:("func_80BCF68C",), - 0x80BCF6D0:("func_80BCF6D0",), - 0x80BCF710:("func_80BCF710",), - 0x80BCF778:("func_80BCF778",), - 0x80BCF7D8:("func_80BCF7D8",), - 0x80BCF88C:("func_80BCF88C",), - 0x80BCF8A0:("func_80BCF8A0",), - 0x80BCF93C:("func_80BCF93C",), - 0x80BCF95C:("func_80BCF95C",), - 0x80BCFC0C:("func_80BCFC0C",), + 0x80BCF354:("EnHg_SetupWait",), + 0x80BCF398:("EnHg_Wait",), + 0x80BCF468:("EnHg_SetupChasePlayer",), + 0x80BCF4AC:("EnHg_ChasePlayer",), + 0x80BCF5F0:("EnHg_SetupChasePlayerWait",), + 0x80BCF634:("EnHg_ChasePlayerWait",), + 0x80BCF68C:("EnHg_SetupReactToHit",), + 0x80BCF6D0:("EnHg_ReactToHit",), + 0x80BCF710:("EnHg_HandleTatlDialog",), + 0x80BCF778:("EnHg_PlayRedeadSfx",), + 0x80BCF7D8:("EnHg_UpdateCollision",), + 0x80BCF88C:("EnHg_SetupCutscene",), + 0x80BCF8A0:("EnHg_PlayCutscene",), + 0x80BCF93C:("EnHg_SetupCsAction",), + 0x80BCF95C:("EnHg_HandleCsAction",), + 0x80BCFC0C:("EnHg_WaitForPlayerAction",), 0x80BCFDC4:("EnHg_Update",), 0x80BCFE54:("EnHg_OverrideLimbDraw",), 0x80BCFE70:("EnHg_PostLimbDraw",), 0x80BCFEC4:("EnHg_Draw",), 0x80BD02B0:("EnHgo_Init",), 0x80BD03C0:("EnHgo_Destroy",), - 0x80BD03EC:("func_80BD03EC",), - 0x80BD0410:("func_80BD0410",), - 0x80BD0420:("func_80BD0420",), - 0x80BD0434:("func_80BD0434",), - 0x80BD049C:("func_80BD049C",), - 0x80BD04E0:("func_80BD04E0",), + 0x80BD03EC:("EnHgo_SetupDoNothing",), + 0x80BD0410:("EnHgo_DoNothing",), + 0x80BD0420:("EnHgo_SetupInitCollision",), + 0x80BD0434:("EnHgo_UpdateCollision",), + 0x80BD049C:("EnHgo_SetupTalk",), + 0x80BD04E0:("EnHgo_Talk",), 0x80BD064C:("EnHgo_SetupDialogueHandler",), 0x80BD0660:("EnHgo_DefaultDialogueHandler",), - 0x80BD06FC:("func_80BD06FC",), - 0x80BD0898:("func_80BD0898",), - 0x80BD0B8C:("func_80BD0B8C",), + 0x80BD06FC:("EnHgo_HandlePlayerChoice",), + 0x80BD0898:("EnHgo_HandleCsAction",), + 0x80BD0B8C:("EnHgo_UpdateModel",), 0x80BD0C30:("EnHgo_Update",), 0x80BD0CF0:("EnHgo_OverrideLimbDraw",), 0x80BD0D38:("EnHgo_PostLimbDraw",), From 7d753ddabbaad7a8f042a52a265839919165375d Mon Sep 17 00:00:00 2001 From: Lucas Shaw <49287729+shawlucas@users.noreply.github.com> Date: Fri, 21 Oct 2022 13:28:36 -0400 Subject: [PATCH 04/10] z_en_lift_nuts.c OK (#889) * progress * progress * merge * progress * . * progress * two functions left! * one function left * it matches! * update * Updated spec * globalcontext to playstate * cleanup * Made suggested changes * ran format.sh * made suggested changes * Made suggested changes * various fixes * review Co-authored-by: Derek Hensley * format * Update src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c Co-authored-by: EllipticEllipsis * Update src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c Co-authored-by: EllipticEllipsis * Update src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c Co-authored-by: EllipticEllipsis * review * yes Co-authored-by: angie Co-authored-by: Derek Hensley Co-authored-by: EllipticEllipsis --- spec | 3 +- .../actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c | 992 +++++++++++++++++- .../actors/ovl_En_Lift_Nuts/z_en_lift_nuts.h | 19 +- 3 files changed, 953 insertions(+), 61 deletions(-) diff --git a/spec b/spec index ab9a801f7..2c24f8055 100644 --- a/spec +++ b/spec @@ -3453,8 +3453,7 @@ beginseg name "ovl_En_Lift_Nuts" compress include "build/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.o" - include "build/data/ovl_En_Lift_Nuts/ovl_En_Lift_Nuts.data.o" - include "build/data/ovl_En_Lift_Nuts/ovl_En_Lift_Nuts.reloc.o" + include "build/src/overlays/actors/ovl_En_Lift_Nuts/ovl_En_Lift_Nuts_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c index 172d1e2d7..6eac82838 100644 --- a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c +++ b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.c @@ -15,7 +15,40 @@ void EnLiftNuts_Destroy(Actor* thisx, PlayState* play); void EnLiftNuts_Update(Actor* thisx, PlayState* play); void EnLiftNuts_Draw(Actor* thisx, PlayState* play); -#if 0 +void func_80AEA910(EnLiftNuts* this, PlayState* play); + +s32 func_80AE9B8C(void); +void func_80AE9F28(EnLiftNuts* this); +void func_80AE9F70(EnLiftNuts* this, PlayState* play); +void func_80AEA044(EnLiftNuts* this, PlayState* play); +void func_80AEA0B4(EnLiftNuts* this); +void func_80AEA128(EnLiftNuts* this, PlayState* play); +void func_80AEA1A0(EnLiftNuts* this, PlayState* play); +void func_80AEABF0(EnLiftNuts* this); +void func_80AEAC64(EnLiftNuts* this, PlayState* play); +void func_80AEACF8(EnLiftNuts* this, PlayState* play); +void func_80AEAEAC(EnLiftNuts* this); +void func_80AEAF14(EnLiftNuts* this, PlayState* play); +void func_80AEAF8C(EnLiftNuts* this); +void func_80AEAFA0(EnLiftNuts* this, PlayState* play); +void func_80AEB114(EnLiftNuts* this); +void func_80AEB148(EnLiftNuts* this, PlayState* play); +void func_80AEB1C8(EnLiftNuts* this); +void func_80AEB230(EnLiftNuts* this, PlayState* play); +void func_80AEB280(EnLiftNuts* this); +void func_80AEB294(EnLiftNuts* this, PlayState* play); +void func_80AEB3E0(EnLiftNuts* this, PlayState* play); +void func_80AEB428(EnLiftNuts* this, PlayState* play); +void func_80AEB584(EnLiftNuts* this); +void func_80AEB598(EnLiftNuts* this, PlayState* play); +void func_80AEB684(EnLiftNuts* this); +void func_80AEB698(EnLiftNuts* this, PlayState* play); +void func_80AEB828(EnLiftNuts* this); +void func_80AEB8A4(EnLiftNuts* this, PlayState* play); +void func_80AEB934(EnLiftNuts* this, PlayState* play); +void func_80AEB974(EnLiftNuts* this); +void func_80AEB9E0(EnLiftNuts* this, PlayState* play); + ActorInit En_Lift_Nuts_InitVars = { ACTOR_EN_LIFT_NUTS, ACTORCAT_NPC, @@ -28,111 +61,956 @@ ActorInit En_Lift_Nuts_InitVars = { (ActorFunc)EnLiftNuts_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80AEBF28 = { - { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, +static AnimationInfo sAnimations[] = { + { &object_dnt_Anim_005488, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_dnt_Anim_00B0B4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_dnt_Anim_004AA0, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_dnt_Anim_0029E8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_dnt_Anim_005CA8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_dnt_Anim_0038CC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_dnt_Anim_003CC0, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_dnt_Anim_0012F4, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_dnt_Anim_004700, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_dnt_Anim_001BC8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_dnt_Anim_003438, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -2.0f }, + { &object_dnt_Anim_001E2C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_dnt_Anim_000994, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_dnt_Anim_002268, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -1.0f }, + { &object_dnt_Anim_002F08, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_dnt_Anim_00577C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -4.0f }, + { &object_dnt_Anim_004E38, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_dnt_Anim_0029E8, 1.0f, 4.0f, 0.0f, ANIMMODE_ONCE, -4.0f }, + { &object_dnt_Anim_0029E8, 1.0f, 8.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, +}; + +Gfx* D_80AEBF18[] = { + object_dnt_DL_008290, + object_dnt_DL_001350, + object_dnt_DL_001420, + NULL, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_NONE, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_2, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0x00000000, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_NONE, + OCELEM_ON, + }, { 25, 75, 0, { 0, 0, 0 } }, }; -// sColChkInfoInit -static CollisionCheckInfoInit2 D_80AEBF54 = { 0, 0, 0, 0, MASS_IMMOVABLE }; +static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; -#endif +void func_80AE9A20(EnLiftNuts* this, PlayState* play) { + static s16 D_80AEBF60 = 0; + static s32 D_80AEBF64 = false; -extern ColliderCylinderInit D_80AEBF28; -extern CollisionCheckInfoInit2 D_80AEBF54; + if (!D_80AEBF64) { + func_800B6584(play, ACTOR_EN_GAMELUPY, &D_80AEBF60, sizeof(s16)); + D_80AEBF64 = true; + } + this->ptr_1EC = &D_80AEBF60; +} -extern UNK_TYPE D_060029E8; +void func_80AE9A80(EnLiftNuts* this, PlayState* play) { + static s16 D_80AEBF68 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9A20.s") + if (!D_80AEBF68) { + func_800B6608(play, ACTOR_EN_GAMELUPY); + D_80AEBF68 = true; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9A80.s") +s32 func_80AE9AC4(EnLiftNuts* this, s32 arg1) { + static s32 D_80AEBF6C = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9AC4.s") + switch (arg1) { + case 0: + if (D_80AEBF6C == 0) { + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9B4C.s") + case 1: + if (D_80AEBF6C == 0) { + this->unk_34E = 1; + D_80AEBF6C = 1; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9B8C.s") + case 2: + if (D_80AEBF6C == 1) { + this->unk_34E = 0; + D_80AEBF6C = 0; + return true; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9BCC.s") + default: + break; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/EnLiftNuts_Init.s") +s32 func_80AE9B4C(s32 arg0, s32 arg1) { + static s32 D_80AEBF70 = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/EnLiftNuts_Destroy.s") + if (arg0 == 0) { + if (D_80AEBF70 == arg1) { + return true; + } + } else if (arg0 == 1) { + D_80AEBF70 = arg1; + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9F28.s") +s32 func_80AE9B8C() { + s32 ret = 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9F70.s") + if (gSaveContext.save.weekEventReg[14] & 0x10) { + ret = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AE9FC8.s") + if (gSaveContext.save.weekEventReg[14] & 0x20) { + ret++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEA044.s") + if (gSaveContext.save.weekEventReg[14] & 0x40) { + ret++; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEA0B4.s") + return ret; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEA128.s") +void func_80AE9BCC(EnLiftNuts* this, PlayState* play) { + if ((this->actionFunc != func_80AEB934) && (this->actionFunc != func_80AEB8A4) && + (this->actionFunc != func_80AEACF8) && (this->actionFunc != func_80AEAC64) && + (this->actionFunc != func_80AEA044) && (this->actionFunc != func_80AEB598) && + (this->actionFunc != func_80AEB698) && !func_80AE9B4C(0, 3) && (func_80AE9B8C() == 3) && + (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) && (this->actor.xzDistToPlayer < 150.0f)) { + func_80AEB828(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEA1A0.s") +void EnLiftNuts_Init(Actor* thisx, PlayState* play) { + EnLiftNuts* this = THIS; + Path* path; + Vec3s* pathPos; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEA7A4.s") + ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 35.0f); + SkelAnime_InitFlex(play, &this->skelAnime, &object_dnt_Skel_00AC70, &object_dnt_Anim_0029E8, this->jointTable, + this->morphTable, OBJECT_DNT_LIMB_MAX); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); + Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, 4); + if (this->actor.floorBgId != BGCHECK_SCENE) { + DynaPolyActor* bgActor = DynaPoly_GetActor(&play->colCtx, this->actor.floorBgId); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEA910.s") + if (bgActor != NULL) { + this->actor.world.pos = bgActor->actor.world.pos; + this->actor.home.pos = bgActor->actor.world.pos; + } + } + this->actor.targetMode = 0; + this->unk_354 = 0; + this->unk_34E = 0; + this->unk_356 = 0; + this->unk_1E4 = 0; + this->unk_1E8 = 0; + this->actor.gravity = -2.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEABF0.s") + path = &play->setupPathList[ENLIFTNUTS_GET_FF00(&this->actor)]; + pathPos = Lib_SegmentedToVirtual(path->points); + this->vec_1D8.x = pathPos->x; + this->vec_1D8.y = pathPos->y; + this->vec_1D8.z = pathPos->z; + func_80AE9A20(this, play); + if (!Flags_GetSwitch(play, 0x41)) { + func_80AE9B4C(1, 0); + func_80AE9F28(this); + } else if (func_80AE9AC4(this, 0)) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEAC64.s") + player->stateFlags1 |= PLAYER_STATE1_20; + func_80AE9AC4(this, 1); + func_80AE9B4C(1, 3); + func_80AEA0B4(this); + } else { + func_80AE9F28(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEACF8.s") +void EnLiftNuts_Destroy(Actor* thisx, PlayState* play) { + EnLiftNuts* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEAEAC.s") + Collider_DestroyCylinder(play, &this->collider); + func_80AE9A80(this, play); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEAF14.s") +void func_80AE9F28(EnLiftNuts* this) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 18); + this->actionFunc = func_80AE9F70; + this->unk_354 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEAF8C.s") +void func_80AE9F70(EnLiftNuts* this, PlayState* play) { + if (this->unk_354 < 40) { + this->unk_354++; + } else if (this->actor.xzDistToPlayer < 100.0f) { + func_80AEA0B4(this); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEAFA0.s") +void func_80AE9FC8(EnLiftNuts* this) { + if (this->actionFunc == func_80AEA1A0) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 17); + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 3); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB114.s") + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + this->actionFunc = func_80AEA044; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB148.s") +void func_80AEA044(EnLiftNuts* this, PlayState* play) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + func_80AE9F28(this); + } else if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + func_80AEB9E0(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB1C8.s") +void func_80AEA0B4(EnLiftNuts* this) { + if (func_80AE9B4C(0, 1)) { + this->actionFunc = func_80AEA1A0; + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + this->actionFunc = func_80AEA128; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB230.s") +void func_80AEA128(EnLiftNuts* this, PlayState* play) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 15); + this->actionFunc = func_80AEA1A0; + } else if (Animation_OnFrame(&this->skelAnime, 8.0f)) { + func_80AEB9E0(this, play); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB280.s") +void func_80AEA1A0(EnLiftNuts* this, PlayState* play) { + if ((func_80AE9B4C(0, 3) || func_80AE9B4C(0, 1)) && this->unk_34E == 1) { + this->actor.flags |= ACTOR_FLAG_10000; + } else if (this->actor.xzDistToPlayer > 120.0f) { + func_80AE9FC8(this); + } + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) { + if (func_80AE9B4C(0, 0)) { + switch (CURRENT_DAY) { + case 1: + if (gSaveContext.save.time > CLOCK_TIME(23, 30) || gSaveContext.save.time <= CLOCK_TIME(6, 0)) { + Message_StartTextbox(play, 0x27F7, &this->actor); + this->textId = 0x27F7; + } else if (gSaveContext.save.weekEventReg[14] & 0x10) { + Message_StartTextbox(play, 0x27D9, &this->actor); + this->textId = 0x27D9; + } else { + Message_StartTextbox(play, 0x27DA, &this->actor); + this->textId = 0x27DA; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB294.s") + case 2: + if (gSaveContext.save.time > CLOCK_TIME(23, 30) || gSaveContext.save.time <= CLOCK_TIME(6, 0)) { + Message_StartTextbox(play, 0x27F7, &this->actor); + this->textId = 0x27F7; + } else { + if (gSaveContext.save.weekEventReg[14] & 0x20) { + Message_StartTextbox(play, 0x27DB, &this->actor); + this->textId = 0x27DB; + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB3E0.s") + if (gSaveContext.save.weekEventReg[14] & 0x10) { + Message_StartTextbox(play, 0x27DC, &this->actor); + this->textId = 0x27DC; + } else { + Message_StartTextbox(play, 0x27DD, &this->actor); + this->textId = 0x27DD; + } + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB428.s") + case 3: + if (gSaveContext.save.time > CLOCK_TIME(23, 30) || gSaveContext.save.time <= CLOCK_TIME(6, 0)) { + Message_StartTextbox(play, 0x27F7, &this->actor); + this->textId = 0x27F7; + } else if (gSaveContext.save.weekEventReg[14] & 0x40) { + Message_StartTextbox(play, 0x27DE, &this->actor); + this->textId = 0x27DE; + } else if (func_80AE9B8C() == 2) { + Message_StartTextbox(play, 0x27DF, &this->actor); + this->textId = 0x27DF; + } else if (func_80AE9B8C() == 1) { + Message_StartTextbox(play, 0x27E0, &this->actor); + this->textId = 0x27E0; + } else { + Message_StartTextbox(play, 0x27E1, &this->actor); + this->textId = 0x27E1; + } + break; + } + } else if (func_80AE9B4C(0, 3)) { + if (Flags_GetSwitch(play, 0x40)) { + Flags_UnsetSwitch(play, 0x40); + Inventory_SaveDekuPlaygroundHighScore(4); + if ((gSaveContext.save.weekEventReg[14] & 0x10) && (gSaveContext.save.weekEventReg[14] & 0x20) && + CURRENT_DAY == 3) { + this->unk_354 = 0; + Message_StartTextbox(play, 0x27F4, &this->actor); + this->textId = 0x27F4; + } else { + Message_StartTextbox(play, 0x27EE, &this->actor); + this->textId = 0x27EE; + } + } else { + if (((void)0, gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]) >= + gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1]) { + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] < 0x2EE0) { + Message_StartTextbox(play, 0x27F9, &this->actor); + this->textId = 0x27F9; + } else { + Message_StartTextbox(play, 0x27EB, &this->actor); + this->textId = 0x27EB; + } + } else { + Message_StartTextbox(play, 0x27ED, &this->actor); + this->textId = 0x27ED; + } + } + Flags_UnsetSwitch(play, 0x41); + this->actor.flags &= ~ACTOR_FLAG_10000; + } else if (!Flags_GetSwitch(play, 0x42)) { + Flags_SetSwitch(play, 0x42); + Message_StartTextbox(play, 0x27E6, &this->actor); + this->textId = 0x27E6; + } else { + switch (CURRENT_DAY) { + case 1: + Message_StartTextbox(play, 0x27E7, &this->actor); + this->textId = 0x27E7; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB584.s") + case 2: + Message_StartTextbox(play, 0x27E8, &this->actor); + this->textId = 0x27E8; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB598.s") + case 3: + Message_StartTextbox(play, 0x27E9, &this->actor); + this->textId = 0x27E9; + break; + } + } + } else { + Message_StartTextbox(play, 0x27D8, &this->actor); + this->textId = 0x27D8; + } + func_80AEABF0(this); + } else if (func_80AE9AC4(this, 0) || this->unk_34E == 1) { + if (this->unk_34E == 1) { + func_800B8614(&this->actor, play, 200.0f); + } else if (this->actor.playerHeightRel >= -13.0f) { + func_800B8614(&this->actor, play, 100.0f); + } + } + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x1000, 0x500); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB684.s") +void func_80AEA7A4(EnLiftNuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB698.s") + if (Message_ShouldAdvance(play)) { + switch (this->textId) { + case 0x27E2: + if (play->msgCtx.choiceIndex == 0) { // Yes + if (gSaveContext.save.playerData.rupees >= 10) { + func_8019F208(); + Message_StartTextbox(play, 0x27E5, &this->actor); + this->textId = 0x27E5; + Rupees_ChangeBy(-10); + } else { + play_sound(NA_SE_SY_ERROR); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(play, 0x27E4, &this->actor); + this->textId = 0x27E4; + } + } else { + func_8019F230(); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(play, 0x27E3, &this->actor); + this->textId = 0x27E3; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB828.s") + case 0x238D: + if (play->msgCtx.choiceIndex == 0) { // Yes + player->stateFlags1 |= PLAYER_STATE1_20; + func_80AEB1C8(this); + } else { + func_80AE9FC8(this); + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB8A4.s") + default: + func_80AE9FC8(this); + break; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB934.s") +void func_80AEA910(EnLiftNuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB974.s") + if (Message_ShouldAdvance(play)) { + switch (this->textId) { + case 0x27D9: + case 0x27DA: + case 0x27DB: + case 0x27DC: + case 0x27DD: + case 0x27DE: + case 0x27DF: + case 0x27E0: + case 0x27E1: + Message_StartTextbox(play, 0x27E2, &this->actor); + this->textId = 0x27E2; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEB9E0.s") + case 0x27E3: + case 0x27E4: + func_80AE9FC8(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEBB30.s") + case 0x27E5: + func_801477B4(play); + player->stateFlags1 |= PLAYER_STATE1_20; + func_80AEAEAC(this); + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/EnLiftNuts_Update.s") + case 0x27E6: + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + switch (CURRENT_DAY) { + case 1: + Message_StartTextbox(play, 0x27E7, &this->actor); + this->textId = 0x27E7; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEBC18.s") + case 2: + Message_StartTextbox(play, 0x27E8, &this->actor); + this->textId = 0x27E8; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/func_80AEBC90.s") + case 3: + Message_StartTextbox(play, 0x27E9, &this->actor); + this->textId = 0x27E9; + break; + } + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Lift_Nuts/EnLiftNuts_Draw.s") + case 0x27E7: + case 0x27E8: + case 0x27E9: + Message_StartTextbox(play, 0x27FA, &this->actor); + this->textId = 0x27FA; + break; + + case 0x27FA: + func_801477B4(play); + player->stateFlags1 &= ~PLAYER_STATE1_20; + func_80AEB114(this); + break; + + case 0x27EE: + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0x10); + Message_StartTextbox(play, 0x27EF, &this->actor); + this->textId = 0x27EF; + break; + + case 0x27EF: + func_801477B4(play); + func_80AEB584(this); + func_80AEB598(this, play); + break; + + case 0x27F1: + Message_StartTextbox(play, 0x27F2, &this->actor); + this->textId = 0x27F2; + break; + + case 0x27F2: + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(play, 0x27F3, &this->actor); + this->textId = 0x27F3; + break; + + case 0x27F4: + func_801477B4(play); + func_80AEB584(this); + func_80AEB598(this, play); + break; + + case 0x27F5: + func_801477B4(play); + func_80AE9B4C(1, 0); + player->stateFlags1 &= ~PLAYER_STATE1_20; + func_80AE9FC8(this); + break; + + case 0x27F9: + Message_StartTextbox(play, 0x27ED, &this->actor); + this->textId = 0x27ED; + break; + } + } +} + +void func_80AEABF0(EnLiftNuts* this) { + this->unk_354 = 0; + + if (this->actionFunc != func_80AEB698) { + if (func_80AE9B4C(0, 0)) { + Actor_PlaySfxAtPos(&this->actor, NA_SE_EN_AKINDONUTS_HIDE); + } + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 16); + } + this->actionFunc = func_80AEAC64; +} + +void func_80AEAC64(EnLiftNuts* this, PlayState* play) { + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + if ((this->textId == 0x27EE) || (this->textId == 0x27F4) || (this->textId == 0x27F5)) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 10); + } else { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 0); + } + this->actionFunc = func_80AEACF8; + } +} + +void func_80AEACF8(EnLiftNuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + switch (Message_GetState(&play->msgCtx)) { + case 0: + case 1: + case 2: + case 3: + break; + + case 4: + func_80AEA7A4(this, play); + break; + + case 5: + func_80AEA910(this, play); + break; + + case 6: + if (Message_ShouldAdvance(play)) { + player->stateFlags1 &= ~PLAYER_STATE1_20; + func_80AE9FC8(this); + func_80AE9AC4(this, 2); + if (func_80AE9B4C(0, 3)) { + func_80AE9B4C(1, 0); + } + } + break; + } + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.yawTowardsPlayer, 0xA, 0x2000, 0x500); + if (Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { + switch (this->textId) { + case 0x27EE: + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); + break; + + case 0x27EF: + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + break; + + case 0x27F4: + if (this->unk_354 == 0) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 11); + this->unk_354++; + } else if (this->unk_354 == 4) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 12); + this->unk_354 = 0; + } else { + this->unk_354++; + } + break; + } + } + func_80AEB974(this); +} + +void func_80AEAEAC(EnLiftNuts* this) { + this->actor.speedXZ = 2.0f; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + func_80AE9AC4(this, 1); + func_80AE9B4C(1, 1); + this->actionFunc = func_80AEAF14; +} + +void func_80AEAF14(EnLiftNuts* this, PlayState* play) { + f32 dist; + + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.home.rot.y, 10, 0x1000, 0x500); + dist = Math_Vec3f_StepTo(&this->actor.world.pos, &this->vec_1D8, this->actor.speedXZ); + this->actor.world.pos.y += this->actor.gravity; + + if (dist == 0.0f) { + func_80AEAF8C(this); + } +} + +void func_80AEAF8C(EnLiftNuts* this) { + this->actionFunc = func_80AEAFA0; +} + +void func_80AEAFA0(EnLiftNuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); + f32 dist; + f32 temp_fv0; + s16 yaw; + s16 sp28; + s16 yawDiff; + + sp28 = this->actor.yawTowardsPlayer - 0x8000; + yaw = Math_Vec3f_Yaw(&player->actor.world.pos, &this->actor.home.pos); + yawDiff = yaw - sp28; + dist = Math_Vec3f_DistXZ(&player->actor.world.pos, &this->actor.home.pos); + + if (this->actor.xzDistToPlayer < dist) { + if (ABS_ALT(yawDiff) < 0x2000) { + yaw = (yawDiff > 0) ? (yaw + 0x2000) : (yaw - 0x2000); + } + } + if (dist < 5.0f) { + temp_fv0 = 10.0f; + } else if (dist < 30.0f) { + temp_fv0 = 40.0f; + } else { + temp_fv0 = 80.0f; + } + + play->actorCtx.unk268 = 1; + func_800B6F20(play, &play->actorCtx.unk_26C, temp_fv0, yaw); + if (dist < 5.0f) { + func_80AEA0B4(this); + } +} + +void func_80AEB114(EnLiftNuts* this) { + func_801A2BB8(NA_BGM_TIMED_MINI_GAME); + this->actionFunc = func_80AEB148; +} + +void func_80AEB148(EnLiftNuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if (player->stateFlags3 & PLAYER_STATE3_200) { + this->actor.speedXZ = 2.0f; + gSaveContext.eventInf[3] |= 0x10; + Interface_StartTimer(4, 0); + func_80AE9B4C(1, 2); + Actor_PlaySfxAtPos(&this->actor, NA_SE_SY_FOUND); + func_80AEB280(this); + } +} + +void func_80AEB1C8(EnLiftNuts* this) { + this->actor.speedXZ = 2.0f; + gSaveContext.eventInf[3] |= 0x10; + Interface_StartTimer(4, 0); + func_80AE9B4C(1, 2); + this->actionFunc = func_80AEB230; +} + +void func_80AEB230(EnLiftNuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if (gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] > 0) { + player->stateFlags1 &= ~PLAYER_STATE1_20; + func_80AEB280(this); + } +} + +void func_80AEB280(EnLiftNuts* this) { + this->actionFunc = func_80AEB294; +} + +void func_80AEB294(EnLiftNuts* this, PlayState* play) { + Player* player = GET_PLAYER(play); + + if (((player->actor.bgCheckFlags & 1) && (player->actor.floorBgId == BG_ACTOR_MAX) && + player->actor.world.pos.y < 20.0f) || + gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2] >= 0x2EE0) { + player->stateFlags1 |= PLAYER_STATE1_20; + Flags_SetSwitch(play, 0x41); + func_80AEB3E0(this, play); + } + + if (*this->ptr_1EC == 300) { + player->stateFlags1 |= PLAYER_STATE1_20; + + if (((void)0, gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]) < + gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1]) { + Flags_SetSwitch(play, 0x40); + } + Flags_SetSwitch(play, 0x41); + func_80AEB3E0(this, play); + } +} + +void func_80AEB3E0(EnLiftNuts* this, PlayState* play) { + play_sound(NA_SE_SY_FOUND); + this->unk_354 = 0; + gSaveContext.timerStates[TIMER_ID_MINIGAME_2] = TIMER_STATE_6; + this->actionFunc = func_80AEB428; +} + +void func_80AEB428(EnLiftNuts* this, PlayState* play) { + s32 pad; + + if (this->unk_354 == 10) { + if (((void)0, gSaveContext.timerCurTimes[TIMER_ID_MINIGAME_2]) > + gSaveContext.save.dekuPlaygroundHighScores[CURRENT_DAY - 1]) { + Message_StartTextbox(play, 0x27EA, &this->actor); + this->textId = 0x27EA; + } else if (*this->ptr_1EC == 300) { + Message_StartTextbox(play, 0x27F8, &this->actor); + this->textId = 0x27F8; + } else { + Message_StartTextbox(play, 0x27EC, &this->actor); + this->textId = 0x27EC; + } + } else if (this->unk_354 == 30) { + gSaveContext.eventInf[3] &= (u8)~0x10; + gSaveContext.respawn[RESPAWN_MODE_DOWN].entrance = ENTRANCE(DEKU_SCRUB_PLAYGROUND, 1); + gSaveContext.nextCutsceneIndex = 0; + func_80169EFC(&play->state); + gSaveContext.respawnFlag = -2; + play->transitionType = TRANS_TYPE_64; + gSaveContext.nextTransitionType = TRANS_TYPE_02; + } + this->unk_354++; +} + +void func_80AEB584(EnLiftNuts* this) { + this->actionFunc = func_80AEB598; +} + +void func_80AEB598(EnLiftNuts* this, PlayState* play) { + if (Actor_HasParent(&this->actor, play)) { + this->actor.parent = NULL; + if ((gSaveContext.save.weekEventReg[14] & 0x10) && (gSaveContext.save.weekEventReg[14] & 0x20) && + (CURRENT_DAY == 3) && !(gSaveContext.save.weekEventReg[14] & 0x80)) { + gSaveContext.save.weekEventReg[14] |= 0x80; + } + func_80AEB684(this); + } else if ((this->textId == 0x27F4) && !(gSaveContext.save.weekEventReg[14] & 0x80)) { + Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 500.0f, 100.0f); + } else { + Actor_PickUp(&this->actor, play, GI_RUPEE_PURPLE, 500.0f, 100.0f); + } +} + +void func_80AEB684(EnLiftNuts* this) { + this->actionFunc = func_80AEB698; +} + +void func_80AEB698(EnLiftNuts* this, PlayState* play) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + if ((gSaveContext.save.weekEventReg[14] & 0x10) && (gSaveContext.save.weekEventReg[14] & 0x20) && + CURRENT_DAY == 3) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 13); + Message_StartTextbox(play, 0x27F5, &this->actor); + this->textId = 0x27F5; + } else if (func_80AE9B8C() > 0) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 1); + Message_StartTextbox(play, 0x27F0, &this->actor); + this->textId = 0x27F0; + } else { + Message_StartTextbox(play, 0x27F1, &this->actor); + this->textId = 0x27F1; + } + this->actor.flags &= ~ACTOR_FLAG_10000; + func_80AEABF0(this); + switch (CURRENT_DAY) { + case 1: + gSaveContext.save.weekEventReg[14] |= 0x10; + break; + + case 2: + gSaveContext.save.weekEventReg[14] |= 0x20; + break; + + case 3: + gSaveContext.save.weekEventReg[14] |= 0x40; + break; + + default: + break; + } + } else { + func_800B85E0(&this->actor, play, 200.0f, -1); + } +} + +void func_80AEB828(EnLiftNuts* this) { + if (!func_80AE9B4C(0, 4)) { + func_80AE9B4C(1, 4); + this->unk_356 = 1; + } + if (this->actionFunc == func_80AE9F70) { + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 15); + } + this->unk_354 = 0; + this->actionFunc = func_80AEB8A4; +} + +void func_80AEB8A4(EnLiftNuts* this, PlayState* play) { + if (this->unk_354 == 22) { + if (this->unk_356 == 1) { + Message_StartTextbox(play, 0x27F6, &this->actor); + this->textId = 0x27F6; + } + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimations, 17); + this->actionFunc = func_80AEB934; + } + this->unk_354++; +} + +void func_80AEB934(EnLiftNuts* this, PlayState* play) { + if (Animation_OnFrame(&this->skelAnime, 5.0f)) { + func_80AEB9E0(this, play); + } +} + +void func_80AEB974(EnLiftNuts* this) { + s16 textId = this->textId; + + switch (textId) { + default: + this->unk_1E4 = 0; + break; + + case 0x27EE: + case 0x27EF: + this->unk_1E4 = 1; + break; + + case 0x27F5: + this->unk_1E4 = 2; + break; + + case 0x27F4: + if (this->unk_354 == 0) { + this->unk_1E4 = 2; + break; + } + this->unk_1E4 = 1; + } +} + +void func_80AEB9E0(EnLiftNuts* this, PlayState* play) { + Vec3f worldPos = this->actor.world.pos; + Vec3f velocity; + Vec3f accel; + Color_RGBA8 primColor = { 170, 130, 90, 255 }; + Color_RGBA8 envColor = { 100, 60, 20, 255 }; + s32 i; + + accel.y = 0.0f; + + for (i = 0; i < 30; i++) { + velocity.x = Rand_Centered() * 15.0f; + velocity.y = Rand_ZeroOne() * 2.0f; + velocity.z = Rand_Centered() * 15.0f; + + accel.x = -0.2f * velocity.x; + accel.z = -0.2f * velocity.z; + + func_800B0EB0(play, &worldPos, &velocity, &accel, &primColor, &envColor, 80, 25, 10); + } +} + +void func_80AEBB30(EnLiftNuts* this, PlayState* play) { + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); +} + +void EnLiftNuts_Update(Actor* thisx, PlayState* play) { + EnLiftNuts* this = THIS; + + SkelAnime_Update(&this->skelAnime); + this->actionFunc(this, play); + func_80AEBB30(this, play); + Actor_UpdateBgCheckInfo(play, thisx, 0.0f, 0.0f, 0.0f, 4); + func_80AE9BCC(this, play); + + if (func_80AE9B4C(0, 2)) { + thisx->flags &= ~ACTOR_FLAG_1; + } +} + +s32 EnLiftNuts_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { + EnLiftNuts* this = THIS; + + if (limbIndex == OBJECT_DNT_LIMB_0F || limbIndex == OBJECT_DNT_LIMB_10 || limbIndex == OBJECT_DNT_LIMB_15 || + limbIndex == OBJECT_DNT_LIMB_17 || limbIndex == OBJECT_DNT_LIMB_18 || limbIndex == OBJECT_DNT_LIMB_15 || + limbIndex == OBJECT_DNT_LIMB_1B) { + *dList = NULL; + } + + if (limbIndex == OBJECT_DNT_LIMB_1A) { + *dList = D_80AEBF18[this->unk_1E4]; + } + return false; +} + +void EnLiftNuts_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f sFocusOffset = { 0.0f, 0.0f, 0.0f }; + + if (limbIndex == OBJECT_DNT_LIMB_19) { + Matrix_MultVec3f(&sFocusOffset, &thisx->focus.pos); + } +} + +void EnLiftNuts_Draw(Actor* thisx, PlayState* play) { + EnLiftNuts* this = THIS; + + func_8012C28C(play->state.gfxCtx); + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, + EnLiftNuts_OverrideLimbDraw, EnLiftNuts_PostLimbDraw, thisx); +} diff --git a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.h b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.h index 61de8ad4f..9a54132a4 100644 --- a/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.h +++ b/src/overlays/actors/ovl_En_Lift_Nuts/z_en_lift_nuts.h @@ -2,16 +2,31 @@ #define Z_EN_LIFT_NUTS_H #include "global.h" +#include "objects/object_dnt/object_dnt.h" struct EnLiftNuts; typedef void (*EnLiftNutsActionFunc)(struct EnLiftNuts*, PlayState*); +#define ENLIFTNUTS_GET_FF00(thisx) (((thisx)->params & 0xFF00) >> 8) + typedef struct EnLiftNuts { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x90]; + /* 0x144 */ ColliderCylinder collider; + /* 0x190 */ SkelAnime skelAnime; /* 0x1D4 */ EnLiftNutsActionFunc actionFunc; - /* 0x1D8 */ char unk_1D8[0x180]; + /* 0x1D8 */ Vec3f vec_1D8; + /* 0x1E4 */ s32 unk_1E4; + /* 0x1E8 */ s32 unk_1E8; + /* 0x1EC */ s16* ptr_1EC; + /* 0x1F0 */ Vec3s jointTable[OBJECT_DNT_LIMB_MAX]; + /* 0x298 */ Vec3s morphTable[OBJECT_DNT_LIMB_MAX]; + /* 0x340 */ UNK_TYPE1 unk_340[0xC]; + /* 0x34C */ s16 textId; + /* 0x34E */ s16 unk_34E; + /* 0x350 */ UNK_TYPE1 unk_350[0x4]; + /* 0x354 */ s16 unk_354; + /* 0x356 */ s16 unk_356; } EnLiftNuts; // size = 0x358 #endif // Z_EN_LIFT_NUTS_H From 6842a065f0d82ebdcb51834e621f0ceff4bb6766 Mon Sep 17 00:00:00 2001 From: Lucas <60241136+ordlucas@users.noreply.github.com> Date: Fri, 21 Oct 2022 17:44:20 -0500 Subject: [PATCH 05/10] ovl_En_Encount4 OK (#989) * `ovl_En_Encount4` decompiled * Style changes * Suggested changes * Suggested changes * Formatting * review * review Co-authored-by: EllipticEllipsis * a Co-authored-by: angie Co-authored-by: EllipticEllipsis --- spec | 3 +- .../actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c | 2 +- .../actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h | 5 + src/overlays/actors/ovl_En_Bsb/z_en_bsb.h | 4 +- .../actors/ovl_En_Encount4/z_en_encount4.c | 179 +++++++++++++++++- .../actors/ovl_En_Encount4/z_en_encount4.h | 21 +- src/overlays/actors/ovl_En_Skb/z_en_skb.h | 4 + 7 files changed, 197 insertions(+), 21 deletions(-) diff --git a/spec b/spec index 2c24f8055..9441dc011 100644 --- a/spec +++ b/spec @@ -2268,8 +2268,7 @@ beginseg name "ovl_En_Encount4" compress include "build/src/overlays/actors/ovl_En_Encount4/z_en_encount4.o" - include "build/data/ovl_En_Encount4/ovl_En_Encount4.data.o" - include "build/data/ovl_En_Encount4/ovl_En_Encount4.reloc.o" + include "build/src/overlays/actors/ovl_En_Encount4/ovl_En_Encount4_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c index 63563f5f0..40b8c78a7 100644 --- a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c +++ b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.c @@ -193,7 +193,7 @@ void BgFireWall_Update(Actor* thisx, PlayState* play2) { if (this->actionFunc != func_809AC970) { if (this->actor.parent != NULL) { EnEncount4* parent = (EnEncount4*)this->actor.parent; - if ((parent->actor.update != NULL) && (parent->unk_150 != 0)) { + if ((parent->actor.update != NULL) && (parent->timer != 0)) { this->actionFunc = func_809AC970; } } diff --git a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h index 3c8eb1982..af5a29923 100644 --- a/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h +++ b/src/overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h @@ -7,6 +7,11 @@ struct BgFireWall; typedef void (*BgFireWallActionFunc)(struct BgFireWall*, PlayState*); +typedef enum { + /* 0 */ BGFIREWALL_PARAMS_0, + /* 1 */ BGFIREWALL_PARAMS_1, +} BgFireWallParams; + typedef struct BgFireWall { /* 0x000 */ Actor actor; /* 0x144 */ BgFireWallActionFunc actionFunc; diff --git a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.h b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.h index d2f67c008..f3cd4b7d6 100644 --- a/src/overlays/actors/ovl_En_Bsb/z_en_bsb.h +++ b/src/overlays/actors/ovl_En_Bsb/z_en_bsb.h @@ -11,7 +11,9 @@ typedef struct EnBsb { /* 0x0000 */ Actor actor; /* 0x0144 */ char unk_144[0x140]; /* 0x0284 */ EnBsbActionFunc actionFunc; - /* 0x0288 */ char unk_288[0xED0]; + /* 0x0288 */ char unk_288[0x54]; + /* 0x02DC */ s32 unk2DC; + /* 0x02E0 */ char unk2E0[0xE78]; } EnBsb; // size = 0x1158 #endif // Z_EN_BSB_H diff --git a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c index 69fa6bf09..ccb9d16b5 100644 --- a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c +++ b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.c @@ -20,7 +20,6 @@ void func_809C42A8(EnEncount4* this, PlayState* play); void func_809C4598(EnEncount4* this, PlayState* play); void func_809C464C(EnEncount4* this, PlayState* play); -#if 0 ActorInit En_Encount4_InitVars = { ACTOR_EN_ENCOUNT4, ACTORCAT_PROP, @@ -33,20 +32,180 @@ ActorInit En_Encount4_InitVars = { (ActorFunc)NULL, }; -#endif +s16 D_809C46D0[] = { + 0x4000, 0xC000, 0x4000, 0, 0xC000, +}; +f32 D_809C46DC[] = { + 200.0f, 200.0f, 100.0f, 0.0f, 100.0f, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/EnEncount4_Init.s") +void EnEncount4_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnEncount4* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/EnEncount4_Destroy.s") + this->unk_148 = ENENCOUNT4_GET_F000(thisx); + this->switchFlag = ENENCOUNT4_GET_FLAG(thisx); + if (this->switchFlag == 0x7F) { + this->switchFlag = -1; + } + if ((this->switchFlag >= 0) && Flags_GetSwitch(play, this->switchFlag)) { + Actor_Kill(&this->actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/func_809C3FD8.s") + this->actor.flags &= ~ACTOR_FLAG_1; + this->actionFunc = func_809C3FD8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/func_809C4078.s") +void EnEncount4_Destroy(Actor* thisx, PlayState* play) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/func_809C42A8.s") +void func_809C3FD8(EnEncount4* this, PlayState* play) { + Actor* actor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/func_809C4598.s") + this->unk_14E = 0; + if ((this->switchFlag >= 0) && Flags_GetSwitch(play, this->switchFlag)) { + this->timer = 100; + this->actionFunc = func_809C464C; + } else { + actor = play->actorCtx.actorLists[ACTORCAT_BOSS].first; + while (actor != NULL) { + if (actor->id != ACTOR_EN_BSB) { + actor = actor->next; + } else { + this->captainKeeta = (EnBsb*)actor; + this->actionFunc = func_809C4078; + break; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/func_809C464C.s") +void func_809C4078(EnEncount4* this, PlayState* play) { + s16 rotY; + Vec3f pos; + s32 fireWallParams; + s32 i; + EnBsb* captainKeeta = this->captainKeeta; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount4/EnEncount4_Update.s") + if ((this->switchFlag >= 0) && Flags_GetSwitch(play, this->switchFlag)) { + this->timer = 100; + this->actionFunc = func_809C464C; + } else if (BREG(1) == 0) { + if ((this->captainKeeta->actor.id != ACTOR_EN_BSB) || (captainKeeta->actor.update == NULL)) { + Actor_Kill(&this->actor); + return; + } + + if ((this->unk_148 != 0) || (this->actor.xzDistToPlayer < 240.0f)) { + if ((this->unk_148 == 0) && (captainKeeta->unk2DC != 0)) { + Actor_Kill(&this->actor); + return; + } + + fireWallParams = BGFIREWALL_PARAMS_0; + if ((this->unk_148 == 0) || (captainKeeta->unk2DC != 0)) { + i = 0; + if (this->unk_148 != 0) { + fireWallParams = BGFIREWALL_PARAMS_1; + i = 2; + } + while (i < ARRAY_COUNT(D_809C46DC)) { + rotY = D_809C46D0[i] + this->actor.world.rot.y; + pos.x = Math_SinS(rotY) * D_809C46DC[i] + this->actor.world.pos.x; + pos.y = this->actor.world.pos.y; + pos.z = Math_CosS(rotY) * D_809C46DC[i] + this->actor.world.pos.z; + Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_BG_FIRE_WALL, pos.x, pos.y, pos.z, 0, + this->actor.world.rot.y, 0, fireWallParams); + i++; + } + this->actionFunc = func_809C42A8; + } + } + } +} + +void func_809C42A8(EnEncount4* this, PlayState* play) { + Player* actor = GET_PLAYER(play); + EnBsb* captainKeeta = this->captainKeeta; + Vec3f pos; + f32 yIntersect; + s16 yRot; + CollisionPoly* colPoly; + s32 bgId; + + if ((this->switchFlag >= 0) && (Flags_GetSwitch(play, this->switchFlag))) { + this->timer = 100; + this->actionFunc = func_809C464C; + + return; + } + + if (this->unk_148 == 1) { + if ((this->captainKeeta->actor.id != ACTOR_EN_BSB) || (captainKeeta->actor.update == NULL)) { + Actor_Kill(&this->actor); + } + + return; + } else if (this->unk_14E >= 2) { + this->timer = 100; + this->actionFunc = func_809C464C; + + return; + } else if ((gSaveContext.save.weekEventReg[85] & 0x40) || (this->unk_14C >= 2) || + (this->actor.xzDistToPlayer > 240.0f)) { + return; + } + + pos.x = (Math_SinS(this->actor.world.rot.y) * 30.0f) + this->actor.world.pos.x; + pos.y = actor->actor.floorHeight + 120.0f; + pos.z = (Math_CosS(this->actor.world.rot.y) * 30.0f) + this->actor.world.pos.z; + yIntersect = BgCheck_EntityRaycastFloor5(&play->colCtx, &colPoly, &bgId, &this->actor, &pos); + if ((yIntersect <= BGCHECK_Y_MIN) || ((actor->actor.depthInWater != BGCHECK_Y_MIN) && + (yIntersect < (actor->actor.world.pos.y - actor->actor.depthInWater)))) { + return; + } + + pos.y = yIntersect; + yRot = (s32)Rand_ZeroFloat(512.0f) + this->actor.world.rot.y + 0x3800; + if (this->unk_14C != 0) { + yRot += 0x8000; + } + pos.x += Math_SinS(yRot) * (40.0f + randPlusMinusPoint5Scaled(40.0f)); + pos.z += Math_CosS(yRot) * (40.0f + randPlusMinusPoint5Scaled(40.0f)); + if (Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_SKB, pos.x, pos.y, pos.z, 0, 0, 0, + ENSKB_PARAMS_0) != NULL) { + this->unk_14C++; + if (this->unk_14C >= 2) { + this->actionFunc = func_809C4598; + } + } +} + +void func_809C4598(EnEncount4* this, PlayState* play) { + if ((this->switchFlag >= 0) && Flags_GetSwitch(play, this->switchFlag)) { + this->timer = 100; + this->actionFunc = func_809C464C; + } else if (this->unk_14E >= 2) { + this->timer = 100; + if (this->switchFlag >= 0) { + Flags_SetSwitch(play, this->switchFlag); + } + this->actionFunc = func_809C464C; + } else if (this->unk_14C == 0) { + this->actionFunc = func_809C42A8; + } +} + +void func_809C464C(EnEncount4* this, PlayState* play) { + if (this->timer == 0) { + Actor_Kill(&this->actor); + } +} + +void EnEncount4_Update(Actor* thisx, PlayState* play) { + EnEncount4* this = THIS; + + DECR(this->timer); + this->actionFunc(this, play); +} diff --git a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h index 63df20f65..a692f796a 100644 --- a/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h +++ b/src/overlays/actors/ovl_En_Encount4/z_en_encount4.h @@ -2,19 +2,26 @@ #define Z_EN_ENCOUNT4_H #include "global.h" +#include "overlays/actors/ovl_Bg_Fire_Wall/z_bg_fire_wall.h" +#include "overlays/actors/ovl_En_Bsb/z_en_bsb.h" +#include "overlays/actors/ovl_En_Skb/z_en_skb.h" struct EnEncount4; typedef void (*EnEncount4ActionFunc)(struct EnEncount4*, PlayState*); +#define ENENCOUNT4_GET_FLAG(thisx) ((thisx)->params & 0x7F) +#define ENENCOUNT4_GET_F000(thisx) (((thisx)->params >> 0xC) & 0xF) + typedef struct EnEncount4 { - /* 0x0000 */ Actor actor; - /* 0x0144 */ EnEncount4ActionFunc actionFunc; - /* 0x0148 */ char unk_148[0x4]; - /* 0x014C */ s16 unk_14C; - /* 0x014E */ s16 unk_14E; - /* 0x0150 */ s16 unk_150; - /* 0x0152 */ char unk_152[0x6]; + /* 0x000 */ Actor actor; + /* 0x144 */ EnEncount4ActionFunc actionFunc; + /* 0x148 */ s16 unk_148; + /* 0x14A */ s16 switchFlag; + /* 0x14C */ s16 unk_14C; + /* 0x14E */ s16 unk_14E; + /* 0x150 */ s16 timer; + /* 0x154 */ EnBsb* captainKeeta; } EnEncount4; // size = 0x158 #endif // Z_EN_ENCOUNT4_H diff --git a/src/overlays/actors/ovl_En_Skb/z_en_skb.h b/src/overlays/actors/ovl_En_Skb/z_en_skb.h index ebdad3cd8..1fbf441ea 100644 --- a/src/overlays/actors/ovl_En_Skb/z_en_skb.h +++ b/src/overlays/actors/ovl_En_Skb/z_en_skb.h @@ -9,6 +9,10 @@ typedef void (*EnSkbActionFunc)(struct EnSkb*, PlayState*); #define ENSKB_GET_F0(thisx) (((thisx)->params >> 4) & 0xF) +typedef enum { + /* 0 */ ENSKB_PARAMS_0, +} EnSkbParams; + typedef struct EnSkb { /* 0x000 */ Actor actor; /* 0x144 */ SkelAnime skelAnime; From f8c167384eb5d99d6967a6bae5bcbdb68451c1f7 Mon Sep 17 00:00:00 2001 From: chloe!! <47910150+chloebangbang@users.noreply.github.com> Date: Fri, 21 Oct 2022 18:12:35 -0500 Subject: [PATCH 06/10] ovl_fbdemo_wipe5 OK (#1015) * ovl_fbdemo_wipe5 OK * format * add trailing newline * bring over gbi.h * review Co-authored-by: Derek Hensley Co-authored-by: EllipticEllipsis * format * review Co-authored-by: EllipticEllipsis * minor clenaups * review Co-authored-by: EllipticEllipsis * Update src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c Co-authored-by: Derek Hensley Co-authored-by: Chloe <> Co-authored-by: angie Co-authored-by: Derek Hensley Co-authored-by: EllipticEllipsis --- include/PR/gbi.h | 8 +- include/color.h | 2 + include/functions.h | 2 +- include/ultra64.h | 1 + include/ultra64/ucode.h | 31 ++++ spec | 3 +- src/code/graph.c | 4 +- src/code/z_jpeg.c | 32 ++--- .../fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c | 136 +++++++++++++++--- .../fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h | 9 +- 10 files changed, 181 insertions(+), 47 deletions(-) create mode 100644 include/ultra64/ucode.h diff --git a/include/PR/gbi.h b/include/PR/gbi.h index 632ca3caf..5cfe31785 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -2599,11 +2599,11 @@ _DW({ \ gsSPLoadUcodeEx((uc_start), (uc_dstart), SP_UCODE_DATA_SIZE) #define gSPLoadUcodeL(pkt, ucode) \ - gSPLoadUcode((pkt), OS_K0_TO_PHYSICAL(&##ucode##TextStart), \ - OS_K0_TO_PHYSICAL(&##ucode##DataStart)) + gSPLoadUcode((pkt), OS_K0_TO_PHYSICAL(&ucode##TextStart), \ + OS_K0_TO_PHYSICAL(&ucode##DataStart)) #define gsSPLoadUcodeL(ucode) \ - gsSPLoadUcode(OS_K0_TO_PHYSICAL(&##ucode##TextStart), \ - OS_K0_TO_PHYSICAL(&##ucode##DataStart)) + gsSPLoadUcode(OS_K0_TO_PHYSICAL(&ucode##TextStart), \ + OS_K0_TO_PHYSICAL(&ucode##DataStart)) #endif #ifdef F3DEX_GBI_2 diff --git a/include/color.h b/include/color.h index b0b4d2cb0..d0cdb62f5 100644 --- a/include/color.h +++ b/include/color.h @@ -51,4 +51,6 @@ typedef union { u16 rgba; } Color_RGBA16; +#define RGBA8(r, g, b, a) ((((r) & 0xFF) << 24) | (((g) & 0xFF) << 16) | (((b) & 0xFF) << 8) | (((a) & 0xFF) << 0)) + #endif diff --git a/include/functions.h b/include/functions.h index bd8e09181..1287431ce 100644 --- a/include/functions.h +++ b/include/functions.h @@ -2168,7 +2168,7 @@ void func_80140E80(void* param_1); // void func_80140EA0(void); // void func_80140EAC(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_80141008(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); -// void func_8014116C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); +void func_8014116C(Gfx** gfxP, u16* arg1, u16* arg2, s32 width, s32 height, s32 arg5); // void func_801411B4(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7, UNK_TYPE4 param_8, UNK_TYPE4 param_9, UNK_TYPE4 param_10); // void func_80141200(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); // void func_8014151C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6); diff --git a/include/ultra64.h b/include/ultra64.h index 6ffb26ff6..ad2bc2463 100644 --- a/include/ultra64.h +++ b/include/ultra64.h @@ -14,6 +14,7 @@ #include "ultra64/rdp.h" #include "ultra64/rsp.h" #include "ultra64/r4300.h" +#include "ultra64/ucode.h" #include "ultra64/vi.h" #endif diff --git a/include/ultra64/ucode.h b/include/ultra64/ucode.h new file mode 100644 index 000000000..8a1d89037 --- /dev/null +++ b/include/ultra64/ucode.h @@ -0,0 +1,31 @@ +#ifndef ULTRA64_UCODE_H +#define ULTRA64_UCODE_H + +#include "PR/ultratypes.h" + +#define SP_DRAM_STACK_SIZE8 0x400 +#define SP_DRAM_STACK_SIZE64 (SP_DRAM_STACK_SIZE8 >> 3) + +#define SP_UCODE_SIZE 0x1000 + +#define SP_UCODE_DATA_SIZE 0x800 + +extern u64 rspbootTextStart[]; +extern u64 rspbootTextEnd[]; + +extern u64 aspMainTextStart[]; +extern u64 aspMainTextEnd[]; +extern u64 aspMainDataStart[]; +extern u64 aspMainDataEnd[]; + +extern u64 gspF3DZEX2_NoN_PosLight_fifoTextStart[]; +extern u64 gspF3DZEX2_NoN_PosLight_fifoTextEnd[]; +extern u64 gspF3DZEX2_NoN_PosLight_fifoDataStart[]; +extern u64 gspF3DZEX2_NoN_PosLight_fifoDataEnd[]; + +extern u64 gspS2DEX2_fifoTextStart[]; +extern u64 gspS2DEX2_fifoTextEnd[]; +extern u64 gspS2DEX2_fifoDataStart[]; +extern u64 gspS2DEX2_fifoDataEnd[]; + +#endif diff --git a/spec b/spec index 9441dc011..d9ebf99ce 100644 --- a/spec +++ b/spec @@ -3237,8 +3237,7 @@ beginseg name "ovl_fbdemo_wipe5" compress include "build/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.o" - include "build/data/ovl_fbdemo_wipe5/ovl_fbdemo_wipe5.data.o" - include "build/data/ovl_fbdemo_wipe5/ovl_fbdemo_wipe5.reloc.o" + include "build/src/overlays/fbdemos/ovl_fbdemo_wipe5/ovl_fbdemo_wipe5_reloc.o" endseg beginseg diff --git a/src/code/graph.c b/src/code/graph.c index 869740e4b..8edc979d4 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -174,8 +174,8 @@ retry: task->ucodeBootSize = SysUcode_GetUCodeBootSize(); task->ucode = SysUcode_GetUCode(); task->ucodeData = SysUcode_GetUCodeData(); - task->ucodeSize = 0x1000; - task->ucodeDataSize = 0x800; + task->ucodeSize = SP_UCODE_SIZE; + task->ucodeDataSize = SP_UCODE_DATA_SIZE; task->dramStack = (u64*)gGfxSPTaskStack; task->dramStackSize = sizeof(gGfxSPTaskStack); task->outputBuff = gGfxSPTaskOutputBufferPtr; diff --git a/src/code/z_jpeg.c b/src/code/z_jpeg.c index 7b9254ccd..ad592a40e 100644 --- a/src/code/z_jpeg.c +++ b/src/code/z_jpeg.c @@ -24,22 +24,22 @@ extern u64 njpgdspMainDataStart[]; */ void Jpeg_ScheduleDecoderTask(JpegContext* jpegCtx) { static OSTask_t sJpegTask = { - M_NJPEGTASK, // type - 0, // flags - NULL, // ucode_boot - 0, // ucode_boot_size - njpgdspMainTextStart, // ucode - 0x1000, // ucode_size - njpgdspMainDataStart, // ucode_data - 0x800, // ucode_data_size - NULL, // dram_stack - 0, // dram_stack_size - NULL, // output_buff - NULL, // output_buff_size - NULL, // data_ptr - sizeof(JpegTaskData), // data_size - NULL, // yield_data_ptr - 0x200, // yield_data_size + M_NJPEGTASK, // type + 0, // flags + NULL, // ucode_boot + 0, // ucode_boot_size + njpgdspMainTextStart, // ucode + SP_UCODE_SIZE, // ucode_size + njpgdspMainDataStart, // ucode_data + SP_UCODE_DATA_SIZE, // ucode_data_size + NULL, // dram_stack + 0, // dram_stack_size + NULL, // output_buff + NULL, // output_buff_size + NULL, // data_ptr + sizeof(JpegTaskData), // data_size + NULL, // yield_data_ptr + sizeof(jpegCtx->workBuf->yieldData), // yield_data_size }; JpegWork* workBuf = jpegCtx->workBuf; diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c index 0ed80c066..a3839bc40 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.c @@ -6,6 +6,8 @@ #include "z_fbdemo_wipe5.h" +#define THIS ((TransitionWipe5*)thisx) + void* TransitionWipe5_Init(void* thisx); void TransitionWipe5_Destroy(void* thisx); void TransitionWipe5_Update(void* thisx, s32 updateRate); @@ -16,37 +18,129 @@ void TransitionWipe5_SetColor(void* thisx, u32 color); void TransitionWipe5_SetEnvColor(void* thisx, u32 color); s32 TransitionWipe5_IsDone(void* thisx); -#if 0 TransitionInit TransitionWipe5_InitVars = { - TransitionWipe5_Init, - TransitionWipe5_Destroy, - TransitionWipe5_Update, - TransitionWipe5_Draw, - TransitionWipe5_Start, - TransitionWipe5_SetType, - TransitionWipe5_SetColor, - TransitionWipe5_SetEnvColor, - TransitionWipe5_IsDone, + TransitionWipe5_Init, TransitionWipe5_Destroy, TransitionWipe5_Update, + TransitionWipe5_Draw, TransitionWipe5_Start, TransitionWipe5_SetType, + TransitionWipe5_SetColor, TransitionWipe5_SetEnvColor, TransitionWipe5_IsDone, }; -#endif +void TransitionWipe5_Start(void* thisx) { + TransitionWipe5* this = THIS; -extern u16 D_0F000000[]; + this->isDone = false; + switch (this->unk_12) { + case 0: + this->unk_08 = 0.02f; + break; + case 1: + this->unk_08 = 0.05f; + break; + default: + this->unk_08 = 0.2f; + break; + } + switch (this->unk_11) { + case 0: + this->primColor.rgba = RGBA8(0, 0, 0, 255); + break; + case 1: + this->primColor.rgba = RGBA8(160, 160, 160, 255); + break; + default: + this->primColor.rgba = RGBA8(160, 160, 160, 255); + break; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_Start.s") +void* TransitionWipe5_Init(void* thisx) { + TransitionWipe5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_Init.s") + bzero(this, sizeof(TransitionWipe5)); + return this; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_Destroy.s") +void TransitionWipe5_Destroy(void* thisx) { +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_Update.s") +void TransitionWipe5_Update(void* thisx, s32 updateRate) { + TransitionWipe5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_Draw.s") + if (this->unk_10 == 0) { + this->isDone = true; + } else { + this->unk_0C += (this->unk_08 * 3.0f) / updateRate; + if (this->unk_0C >= 1.0f) { + this->unk_0C = 1.0f; + this->isDone = true; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_IsDone.s") +void TransitionWipe5_Draw(void* thisx, Gfx** gfxP) { + Gfx* gfx = *gfxP; + s32 width = gScreenWidth; + s32 height = gScreenHeight; + s32 sp50 = D_801FBB90; + TransitionWipe5* this = THIS; + s32 alpha = (1.0f - this->unk_0C) * 255.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_SetType.s") + gDPPipeSync(gfx++); + gSPLoadUcodeL(gfx++, gspS2DEX2_fifo); + if (this->unk_10 == 0) { + gDPSetOtherMode(gfx++, + G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_COPY | G_PM_NPRIMITIVE, + G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2); + func_8014116C(&gfx, D_0F000000, sp50, width, height, 1); + } else { + if (alpha == 255) { + gDPSetOtherMode(gfx++, + G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_NONE | G_ZS_PRIM | G_RM_OPA_SURF | G_RM_OPA_SURF2); + } else { + gDPSetOtherMode(gfx++, + G_AD_NOISE | G_CD_NOISE | G_CK_NONE | G_TC_FILT | G_TF_POINT | G_TT_NONE | G_TL_TILE | + G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE, + G_AC_NONE | G_ZS_PRIM | G_RM_CLD_SURF | G_RM_CLD_SURF2); + } + gDPSetEnvColor(gfx++, 255, 255, 255, alpha); + gDPSetCombineLERP(gfx++, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, ENVIRONMENT, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, + ENVIRONMENT); + func_8014116C(&gfx, sp50, D_0F000000, width, height, 0); + } + gDPPipeSync(gfx++); + gSPLoadUcode(gfx++, SysUcode_GetUCode(), SysUcode_GetUCodeData()); + *gfxP = gfx; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_SetColor.s") +s32 TransitionWipe5_IsDone(void* thisx) { + TransitionWipe5* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_fbdemo_wipe5/TransitionWipe5_SetEnvColor.s") + return this->isDone; +} + +void TransitionWipe5_SetType(void* thisx, s32 type) { + TransitionWipe5* this = THIS; + + if (type & 0x80) { + this->unk_11 = 0; + this->unk_12 = type & 1; + } else if (type == 1) { + this->unk_10 = 1; + } else { + this->unk_10 = 0; + } +} + +void TransitionWipe5_SetColor(void* thisx, u32 color) { + TransitionWipe5* this = THIS; + + this->primColor.rgba = color; +} + +void TransitionWipe5_SetEnvColor(void* thisx, u32 color) { + TransitionWipe5* this = THIS; + + this->envColor.rgba = color; +} diff --git a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h index d5f882dec..d5cd9137d 100644 --- a/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h +++ b/src/overlays/fbdemos/ovl_fbdemo_wipe5/z_fbdemo_wipe5.h @@ -4,7 +4,14 @@ #include "global.h" typedef struct { - /* 0x0000 */ char unk_0[0x14]; + /* 0x00 */ Color_RGBA8_u32 primColor; + /* 0x04 */ Color_RGBA8_u32 envColor; + /* 0x08 */ f32 unk_08; + /* 0x0C */ f32 unk_0C; + /* 0x10 */ u8 unk_10; + /* 0x11 */ u8 unk_11; + /* 0x12 */ u8 unk_12; + /* 0x13 */ u8 isDone; } TransitionWipe5; // size = 0x14 #endif From f4904ab79381b3f47535c09ef42b51f4683db2bc Mon Sep 17 00:00:00 2001 From: Tom Overton Date: Fri, 21 Oct 2022 17:36:32 -0700 Subject: [PATCH 07/10] Document object_boss01 (Odolwa) (#1132) * Document limbs * Finish object * Forgot this translation * Respond to all reviews --- assets/xml/objects/object_boss01.xml | 413 +++++++++++++----------- assets/xml/objects/object_bsmask.xml | 2 +- assets/xml/objects/object_ob.xml | 12 +- src/overlays/actors/ovl_En_Js/z_en_js.c | 2 +- 4 files changed, 236 insertions(+), 193 deletions(-) diff --git a/assets/xml/objects/object_boss01.xml b/assets/xml/objects/object_boss01.xml index 89cc97a7e..08730f034 100644 --- a/assets/xml/objects/object_boss01.xml +++ b/assets/xml/objects/object_boss01.xml @@ -1,189 +1,232 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/xml/objects/object_bsmask.xml b/assets/xml/objects/object_bsmask.xml index ea94aa89e..0e7a349cb 100644 --- a/assets/xml/objects/object_bsmask.xml +++ b/assets/xml/objects/object_bsmask.xml @@ -18,7 +18,7 @@ - + diff --git a/assets/xml/objects/object_ob.xml b/assets/xml/objects/object_ob.xml index d2390fc39..aa95db9bc 100644 --- a/assets/xml/objects/object_ob.xml +++ b/assets/xml/objects/object_ob.xml @@ -3,7 +3,7 @@ - + @@ -18,16 +18,16 @@ - - + + - - - + + + diff --git a/src/overlays/actors/ovl_En_Js/z_en_js.c b/src/overlays/actors/ovl_En_Js/z_en_js.c index fa8cebd06..51296413e 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.c +++ b/src/overlays/actors/ovl_En_Js/z_en_js.c @@ -60,7 +60,7 @@ static ColliderCylinderInit sCylinderInit = { }; static Gfx* D_8096ABCC[] = { - gMoonChildMajorasMaskDL, gMoonChildOdalwasMaskDL, gMoonChildGohtsMaskDL, + gMoonChildMajorasMaskDL, gMoonChildOdolwasMaskDL, gMoonChildGohtsMaskDL, gMoonChildGyorgsMaskDL, gMoonChildTwinmoldsMaskDL, }; From 6b588eb3d71c9d5aa1cb5df4f4305cbd3d465bf6 Mon Sep 17 00:00:00 2001 From: petrie911 <69443847+petrie911@users.noreply.github.com> Date: Fri, 21 Oct 2022 21:55:27 -0500 Subject: [PATCH 08/10] Last function in z_debug_display (#1134) * path * format * testing, fix later * Elliptic's stuff * array count Co-authored-by: petrie911 --- src/code/z_debug_display.c | 104 +++++++++++++++++++++++++++++++++---- tools/disasm/functions.txt | 4 +- 2 files changed, 96 insertions(+), 12 deletions(-) diff --git a/src/code/z_debug_display.c b/src/code/z_debug_display.c index a8b851ed7..e7c9dd0be 100644 --- a/src/code/z_debug_display.c +++ b/src/code/z_debug_display.c @@ -11,6 +11,7 @@ typedef void (*DebugDispObject_DrawFunc)(DebugDispObject*, void*, PlayState*); void DebugDisplay_DrawSpriteI8(DebugDispObject*, void*, PlayState*); void DebugDisplay_DrawPolygon(DebugDispObject*, void*, PlayState*); +Gfx* DebugDisplay_PathDisplayList(GraphicsContext* gfxCtx, Path* path); DebugDispObject* DebugDisplay_Init(void) { sDebugObjectListHead = NULL; @@ -102,24 +103,107 @@ void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, PlayState* p CLOSE_DISPS(play->state.gfxCtx); } -s32 D_801BB068[] = { - 0x00140000, 0x0000FFEC, 0x00000000, 0x00000014, 0x00000000, 0xFFEC0000, 0x00000000, 0x00140000, 0x0000FFEC, -}; +/** + * Visualise a path, see DebugDisplay_PathDisplayList for details. + */ -s32 D_801BB08C = 0; - -Gfx* func_800E99B0(GraphicsContext* gfxCtx, s32 arg1); - -void func_800E992C(PlayState* play, s32 arg1) { +void DebugDisplay_DrawPath(PlayState* play, Path* path) { s32 pad; OPEN_DISPS(play->state.gfxCtx); func_8012C560(play->state.gfxCtx); gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList(POLY_XLU_DISP++, func_800E99B0(play->state.gfxCtx, arg1)); + gSPDisplayList(POLY_XLU_DISP++, DebugDisplay_PathDisplayList(play->state.gfxCtx, path)); CLOSE_DISPS(play->state.gfxCtx); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/func_800E99B0.s") +#define R_DRAW_PATH_SEGMENT 0 // bREG(82) +#define R_DRAW_PATH_SCALE 1.0f // (1.0f + 0.1f * bREG(83)) +#define R_DRAW_PATH_RED 0 // bREG(84) +#define R_DRAW_PATH_GREEN 0 // bREG(85) +#define R_DRAW_PATH_BLUE 0 // bREG(86) +#define R_DRAW_PATH_ALPHA 0 // bREG(87) + +/** + * Offsets of the points of the triaxial shape used for visualising paths + */ +Vec3s sDebugPathVtxOffsets[][2] = { + { { 20, 0, 0 }, { -20, 0, 0 } }, + { { 0, 20, 0 }, { 0, -20, 0 } }, + { { 0, 0, 20 }, { 0, 0, -20 } }, +}; + +/** + * Constructs a displaylist to show a Path, by extruding the three-axis shape defined by `sPathDebugVtx` along it. + */ +Gfx* DebugDisplay_PathDisplayList(GraphicsContext* gfxCtx, Path* path) { + Gfx* gfxHead; + Gfx* gfx; + Vtx* curVtx; + Vtx* curBaseVtx; // First Vtx for the current point + Vtx* prevBaseVtx; // First Vtx for the previous point + Vec3s* curPoint; + s32 segment; // of path ending at the current point, 1-indexed + + if (path != NULL) { + // count - 1 segments, 1 gSPVertex and 3 gSP2Triangles for each, plus a gSPEndDisplayList + gfx = GRAPH_ALLOC(gfxCtx, ALIGN16(((path->count - 1) * 4 + 1) * sizeof(Gfx))); + curVtx = GRAPH_ALLOC(gfxCtx, ALIGN16(path->count * 6 * sizeof(Vtx))); + + gfxHead = gfx; + curBaseVtx = curVtx; + curPoint = Lib_SegmentedToVirtual(path->points); + + for (segment = 0; segment < path->count; segment++, curPoint++) { + s32 i; + s32 j; + + prevBaseVtx = curBaseVtx; + curBaseVtx = curVtx; + + // Add a vertex for each point in the triaxial shape + for (i = 0; i < ARRAY_COUNT(sDebugPathVtxOffsets); i++) { + for (j = 0; j < ARRAY_COUNT(sDebugPathVtxOffsets[0]); j++) { + curVtx->v.ob[0] = curPoint->x + (s32)(sDebugPathVtxOffsets[i][j].x * R_DRAW_PATH_SCALE); + curVtx->v.ob[1] = curPoint->y + (s32)(sDebugPathVtxOffsets[i][j].y * R_DRAW_PATH_SCALE); + curVtx->v.ob[2] = curPoint->z + (s32)(sDebugPathVtxOffsets[i][j].z * R_DRAW_PATH_SCALE); + curVtx->v.flag = 0; + curVtx->v.tc[0] = 0; + curVtx->v.tc[1] = 0; + curVtx->v.cn[0] = 128 + R_DRAW_PATH_RED; + curVtx->v.cn[1] = 128 + R_DRAW_PATH_GREEN; + curVtx->v.cn[2] = 128 + R_DRAW_PATH_BLUE; + curVtx->v.cn[3] = 128 + R_DRAW_PATH_ALPHA; + curVtx++; + } + } + + // Draw the path segment ending at point `R_DRAW_PATH_SEGMENT`, or the whole path if `R_DRAW_PATH_SEGMENT` + // is 0 + if (R_DRAW_PATH_SEGMENT == 0) { + if (segment > 0) { + gSPVertex(gfx++, prevBaseVtx, 12, 0); + gSP2Triangles(gfx++, 0, 7, 1, 0, 0, 6, 7, 0); + gSP2Triangles(gfx++, 2, 3, 8, 0, 3, 9, 8, 0); + gSP2Triangles(gfx++, 4, 11, 10, 0, 4, 5, 11, 0); + } + } else { + if ((segment > 0) && (segment == R_DRAW_PATH_SEGMENT)) { + gSPVertex(gfx++, prevBaseVtx, 12, 0); + gSP2Triangles(gfx++, 0, 7, 1, 0, 0, 6, 7, 0); + gSP2Triangles(gfx++, 2, 3, 8, 0, 3, 9, 8, 0); + gSP2Triangles(gfx++, 4, 11, 10, 0, 4, 5, 11, 0); + } + } + } + + gSPEndDisplayList(gfx++); + } else { + // No path, trivial displaylist + gfxHead = gfx = GRAPH_ALLOC(gfxCtx, ALIGN16(sizeof(Gfx))); + gSPEndDisplayList(gfx++); + } + return gfxHead; +} diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 47ce688ca..a84639222 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1525,8 +1525,8 @@ 0x800E9564:("DebugDisplay_DrawObjects",), 0x800E95F4:("DebugDisplay_DrawSpriteI8",), 0x800E97D8:("DebugDisplay_DrawPolygon",), - 0x800E992C:("func_800E992C",), - 0x800E99B0:("func_800E99B0",), + 0x800E992C:("DebugDisplay_DrawPath",), + 0x800E99B0:("DebugDisplay_PathDisplayList",), 0x800E9C90:("func_800E9C90",), 0x800E9CA0:("func_800E9CA0",), 0x800E9CFC:("func_800E9CFC",), From c1a0d0bd2b2e4cede190692e449618c9cfa5d0f8 Mon Sep 17 00:00:00 2001 From: Derek Hensley Date: Fri, 21 Oct 2022 20:12:38 -0700 Subject: [PATCH 09/10] EnOsn (Happy Mask Salesman) and object_osn Docs (#1135) * Inital cleanup * Object * Docs * Small things * PR --- assets/xml/objects/gameplay_keep.xml | 4 +- assets/xml/objects/object_osn.xml | 246 ++++--- src/code/z_player_lib.c | 2 +- .../actors/ovl_Dm_Char03/z_dm_char03.c | 4 +- src/overlays/actors/ovl_En_Osn/z_en_osn.c | 690 +++++++++++------- src/overlays/actors/ovl_En_Osn/z_en_osn.h | 29 +- tools/disasm/functions.txt | 30 +- 7 files changed, 581 insertions(+), 424 deletions(-) diff --git a/assets/xml/objects/gameplay_keep.xml b/assets/xml/objects/gameplay_keep.xml index b467c1034..2e65fb73d 100644 --- a/assets/xml/objects/gameplay_keep.xml +++ b/assets/xml/objects/gameplay_keep.xml @@ -43,7 +43,9 @@ - + + + diff --git a/assets/xml/objects/object_osn.xml b/assets/xml/objects/object_osn.xml index dbcdb8473..d6109c717 100644 --- a/assets/xml/objects/object_osn.xml +++ b/assets/xml/objects/object_osn.xml @@ -1,117 +1,139 @@  + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index a6f45dccb..21753040f 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1981,7 +1981,7 @@ Gfx* D_801C0B20[] = { gameplay_keep_DL_00B260, gameplay_keep_DL_005A10, gameplay_keep_DL_005360, - gameplay_keep_DL_0056C0, + gDekuMaskDL, object_mask_boy_DL_000900, object_mask_goron_DL_0014A0, object_mask_zora_DL_000DB0, diff --git a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c index be8ce93f1..714913231 100644 --- a/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c +++ b/src/overlays/actors/ovl_Dm_Char03/z_dm_char03.c @@ -32,7 +32,9 @@ ActorInit Dm_Char03_InitVars = { (ActorFunc)DmChar03_Draw, }; -AnimationInfo sAnimationInfo[] = { { &object_osn_Anim_020530, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f } }; +AnimationInfo sAnimationInfo[] = { + { &gDekuMaskFallOverAnim, 1.0f, 0.0f, -1.0f, ANIMMODE_ONCE, 0.0f }, +}; void DmChar03_ChangeAnim(SkelAnime* skelAnime, AnimationInfo* animationInfo, u16 animIndex) { f32 frame; diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.c b/src/overlays/actors/ovl_En_Osn/z_en_osn.c index 709881415..a61c0dc22 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.c +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.c @@ -16,6 +16,68 @@ void EnOsn_Destroy(Actor* thisx, PlayState* play); void EnOsn_Update(Actor* thisx, PlayState* play); void EnOsn_Draw(Actor* thisx, PlayState* play); +void EnOsn_Idle(EnOsn* this, PlayState* play); +void EnOsn_StartCutscene(EnOsn* this, PlayState* play); +void EnOsn_HandleCsAction(EnOsn* this, PlayState* play); +void EnOsn_Talk(EnOsn* this, PlayState* play); + +#define OSN_STATE_SPECIAL_CONVERSTATION (1 << 0) +#define OSN_STATE_MET_HUMAN (1 << 1) +#define OSN_STATE_MET_DEKU (1 << 2) +#define OSN_STATE_MET_GORON (1 << 3) +#define OSN_STATE_MET_ZORA (1 << 4) +#define OSN_STATE_END_CONVERSATION (1 << 5) + +#define OSN_MASK_TEXT_GREAT_FAIRY (1 << 0) +#define OSN_MASK_TEXT_GIBDO (1 << 1) +#define OSN_MASK_TEXT_TRUTH (1 << 2) +#define OSN_MASK_TEXT_GIANT (1 << 3) +#define OSN_MASK_TEXT_KAFEIS (1 << 4) +#define OSN_MASK_TEXT_DON_GERO (1 << 5) +#define OSN_MASK_TEXT_BLAST (1 << 6) +#define OSN_MASK_TEXT_COUPLE (1 << 7) +#define OSN_MASK_TEXT_SCENTS (1 << 8) +#define OSN_MASK_TEXT_KAMARO (1 << 9) +#define OSN_MASK_TEXT_STONE (1 << 10) +#define OSN_MASK_TEXT_POSTMAN (1 << 11) +#define OSN_MASK_TEXT_BUNNY (1 << 12) +#define OSN_MASK_TEXT_CAPTAIN (1 << 13) +#define OSN_MASK_TEXT_BREMEN (1 << 14) +#define OSN_MASK_TEXT_CIRCUS_LEADER (1 << 15) +#define OSN_MASK_TEXT_KEATON (1 << 16) +#define OSN_MASK_TEXT_GARO (1 << 17) +#define OSN_MASK_TEXT_ALL_NIGHT (1 << 18) +#define OSN_MASK_TEXT_ROMANI (1 << 19) + +typedef enum { + /* 0 */ OSN_ANIM_IDLE, + /* 1 */ OSN_ANIM_ARMS_OUT, + /* 2 */ OSN_ANIM_BOWING, + /* 3 */ OSN_ANIM_REMINISCE, + /* 4 */ OSN_ANIM_HANDS_CLASPED, + /* 5 */ OSN_ANIM_BELIEVE, + /* 6 */ OSN_ANIM_THINK, + /* 7 */ OSN_ANIM_SHAKE_HEAD, + /* 8 */ OSN_ANIM_ORGAN_TALK, + /* 9 */ OSN_ANIM_ORGAN_PLAY, + /* 10 */ OSN_ANIM_SHAKE, + /* 11 */ OSN_ANIM_CHOKE, + /* 12 */ OSN_ANIM_DESPAIR, + /* 13 */ OSN_ANIM_FAST_BOWS, + /* 14 */ OSN_ANIM_HAND_OUT, + /* 15 */ OSN_ANIM_LYING_DOWN_FACE_UP, + /* 16 */ OSN_ANIM_LYING_DOWN_FACE_DOWN, + /* 17 */ OSN_ANIM_MASK_LOOK_AT, + /* 18 */ OSN_ANIM_TURN_AROUND_START, + /* 19 */ OSN_ANIM_TURN_AROUND_LOOP, + /* 20 */ OSN_ANIM_WALK_AWAY, + /* 21 */ OSN_ANIM_MASK_LOOK_FROM_START, + /* 22 */ OSN_ANIM_MASK_LOOK_FROM_LOOP, + /* 23 */ OSN_ANIM_HAND_OUT_2, // Exact same as OSN_ANIM_HAND_OUT + /* 24 */ OSN_ANIM_WALK_AWAY_END, // Only the last frame of OSN_ANIM_WALK_AWAY + /* 25 */ OSN_ANIM_MAX +} OsnAnimation; + ActorInit En_Osn_InitVars = { ACTOR_EN_OSN, ACTORCAT_NPC, @@ -29,31 +91,31 @@ ActorInit En_Osn_InitVars = { }; static AnimationInfo sAnimationInfo[] = { - { &object_osn_Anim_0201BC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_002F74, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_0037C4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_004320, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_004C8C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_0094E4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_009BB8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_00AC60, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_001614, 1.0f, 1.0f, 39.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_001034, 1.0f, 1.0f, 70.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_00AE9C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_003A1C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_0055F8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_007220, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_00A444, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_0000C4, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &object_osn_Anim_0000C4, 0.0f, 1.0f, 1.0f, ANIMMODE_ONCE, 0.0f }, - { &object_osn_Anim_006D48, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_001D6C, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &object_osn_Anim_002634, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_008D80, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &object_osn_Anim_005D78, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, - { &object_osn_Anim_006564, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_00A444, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, - { &object_osn_Anim_008D80, 0.0f, 77.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gHappyMaskSalesmanIdleAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanArmsOutAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanBowingAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanReminisceAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanHandsClaspedAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanBelieveAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanThinkAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanShakeHeadAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanOrganTalkAnim, 1.0f, 1.0f, 39.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanOrganPlayAnim, 1.0f, 1.0f, 70.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanShakeAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanChokeAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanDespairAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanFastBowsAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanHandOutAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanLyingDownAnim, 0.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gHappyMaskSalesmanLyingDownAnim, 0.0f, 1.0f, 1.0f, ANIMMODE_ONCE, 0.0f }, + { &gHappyMaskSalesmanMaskLookAtAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanTurnAroundStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gHappyMaskSalesmanTurnAroundLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanWalkAwayAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gHappyMaskSalesmanMaskLookFromStartAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, + { &gHappyMaskSalesmanMaskLookFromLoopAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanHandOutAnim, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f }, + { &gHappyMaskSalesmanWalkAwayAnim, 0.0f, 77.0f, 0.0f, ANIMMODE_ONCE, 0.0f }, }; static ColliderCylinderInit sCylinderInit = { @@ -117,12 +179,7 @@ static InitChainEntry sInitChain[] = { ICHAIN_U8(targetMode, 0, ICHAIN_STOP), }; -void func_80AD1634(EnOsn*, PlayState*); -void func_80AD16A8(EnOsn*, PlayState*); -void func_80AD14C8(EnOsn*, PlayState*); -void func_80AD19A0(EnOsn* this, PlayState* play); - -void func_80AD0830(EnOsn* this, PlayState* play) { +void EnOsn_UpdateCollider(EnOsn* this, PlayState* play) { this->collider.dim.pos.x = this->actor.world.pos.x; this->collider.dim.pos.y = this->actor.world.pos.y; this->collider.dim.pos.z = this->actor.world.pos.z; @@ -130,225 +187,265 @@ void func_80AD0830(EnOsn* this, PlayState* play) { CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } -s32 func_80AD08B0(PlayState* play) { +s32 EnOsn_GetMaskText(PlayState* play) { switch (Player_GetMask(play)) { case PLAYER_MASK_GREAT_FAIRY: return 0x1FD6; + case PLAYER_MASK_GIBDO: return 0x1FD8; + case PLAYER_MASK_TRUTH: return 0x1FDA; + case PLAYER_MASK_GIANT: return 0x1FDC; + case PLAYER_MASK_KAFEIS_MASK: return 0x1FDE; + case PLAYER_MASK_DON_GERO: return 0x1FE0; + case PLAYER_MASK_BLAST: return 0x1FE2; + case PLAYER_MASK_COUPLE: return 0x1FE4; + case PLAYER_MASK_SCENTS: return 0x1FE6; + case PLAYER_MASK_KAMARO: return 0x1FE8; + case PLAYER_MASK_STONE: return 0x1FEA; + case PLAYER_MASK_POSTMAN: return 0x1FEC; + case PLAYER_MASK_BUNNY: return 0x1FEE; + case PLAYER_MASK_CAPTAIN: return 0x1FF0; + case PLAYER_MASK_BREMEN: return 0x1FF2; + case PLAYER_MASK_CIRCUS_LEADER: return 0x1FF4; + case PLAYER_MASK_KEATON: return 0x1FF6; + case PLAYER_MASK_GARO: return 0x1FF8; + case PLAYER_MASK_ALL_NIGHT: return 0x1FFA; + case PLAYER_MASK_ROMANI: return 0x1FFC; + default: return 0; } } -void func_80AD0998(EnOsn* this) { +void EnOsn_TurnAround(EnOsn* this) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_1EC].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - if (this->unk_1EC == 0x12 && curFrame == lastFrame) { - this->unk_1EC = 0x13; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0x13); + if ((this->animIndex == OSN_ANIM_TURN_AROUND_START) && (curFrame == lastFrame)) { + this->animIndex = OSN_ANIM_TURN_AROUND_LOOP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, OSN_ANIM_TURN_AROUND_LOOP); } } -void func_80AD0A24(EnOsn* this) { +void EnOsn_LookFromMask(EnOsn* this) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_1EC].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); - if (this->unk_1EC == 0x15 && curFrame == lastFrame) { - this->unk_1EC = 0x16; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0x16); + if ((this->animIndex == OSN_ANIM_MASK_LOOK_FROM_START) && (curFrame == lastFrame)) { + this->animIndex = OSN_ANIM_MASK_LOOK_FROM_LOOP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, OSN_ANIM_MASK_LOOK_FROM_LOOP); } } -void func_80AD0AB0(EnOsn* this) { +void EnOsn_FadeOut(EnOsn* this) { s16 curFrame = this->skelAnime.curFrame; - s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->unk_1EC].animation); + s16 lastFrame = Animation_GetLastFrame(sAnimationInfo[this->animIndex].animation); if (curFrame == lastFrame) { - this->unk_1FA -= 8; - if (this->unk_1FA < 8) { - this->unk_1FA = 0; + this->alpha -= 8; + if (this->alpha < 8) { + this->alpha = 0; Actor_Kill(&this->actor); } } } -s32 func_80AD0B38(EnOsn* this, PlayState* play) { +s32 EnOsn_GetInitialMaskText(EnOsn* this, PlayState* play) { switch (Player_GetMask(play)) { case PLAYER_MASK_GREAT_FAIRY: - if (!(this->unk_1F6 & 1)) { - this->unk_1F6 |= 1; + if (!(this->maskTextFlags & OSN_MASK_TEXT_GREAT_FAIRY)) { + this->maskTextFlags |= OSN_MASK_TEXT_GREAT_FAIRY; return 0x1FD1; } break; + case PLAYER_MASK_GIBDO: - if (!(this->unk_1F6 & 2)) { - this->unk_1F6 |= 2; + if (!(this->maskTextFlags & OSN_MASK_TEXT_GIBDO)) { + this->maskTextFlags |= OSN_MASK_TEXT_GIBDO; return 0x1FD1; } break; + case PLAYER_MASK_TRUTH: - if (!(this->unk_1F6 & 4)) { - this->unk_1F6 |= 4; + if (!(this->maskTextFlags & OSN_MASK_TEXT_TRUTH)) { + this->maskTextFlags |= OSN_MASK_TEXT_TRUTH; return 0x1FD1; } break; + case PLAYER_MASK_GIANT: - if (!(this->unk_1F6 & 8)) { - this->unk_1F6 |= 8; + if (!(this->maskTextFlags & OSN_MASK_TEXT_GIANT)) { + this->maskTextFlags |= OSN_MASK_TEXT_GIANT; return 0x1FD1; } break; + case PLAYER_MASK_KAFEIS_MASK: - if (!(this->unk_1F6 & 0x10)) { - this->unk_1F6 |= 0x10; + if (!(this->maskTextFlags & OSN_MASK_TEXT_KAFEIS)) { + this->maskTextFlags |= OSN_MASK_TEXT_KAFEIS; return 0x1FD1; } break; + case PLAYER_MASK_DON_GERO: - if (!(this->unk_1F6 & 0x20)) { - this->unk_1F6 |= 0x20; + if (!(this->maskTextFlags & OSN_MASK_TEXT_DON_GERO)) { + this->maskTextFlags |= OSN_MASK_TEXT_DON_GERO; return 0x1FD1; } break; + case PLAYER_MASK_BLAST: - if (!(this->unk_1F6 & 0x40)) { - this->unk_1F6 |= 0x40; + if (!(this->maskTextFlags & OSN_MASK_TEXT_BLAST)) { + this->maskTextFlags |= OSN_MASK_TEXT_BLAST; return 0x1FD1; } break; + case PLAYER_MASK_COUPLE: - if (!(this->unk_1F6 & 0x80)) { - this->unk_1F6 |= 0x80; + if (!(this->maskTextFlags & OSN_MASK_TEXT_COUPLE)) { + this->maskTextFlags |= OSN_MASK_TEXT_COUPLE; return 0x1FD1; } break; + case PLAYER_MASK_SCENTS: - if (!(this->unk_1F6 & 0x100)) { - this->unk_1F6 |= 0x100; + if (!(this->maskTextFlags & OSN_MASK_TEXT_SCENTS)) { + this->maskTextFlags |= OSN_MASK_TEXT_SCENTS; return 0x1FD1; } break; + case PLAYER_MASK_KAMARO: - if (!(this->unk_1F6 & 0x200)) { - this->unk_1F6 |= 0x200; + if (!(this->maskTextFlags & OSN_MASK_TEXT_KAMARO)) { + this->maskTextFlags |= OSN_MASK_TEXT_KAMARO; return 0x1FD1; } break; + case PLAYER_MASK_STONE: - if (!(this->unk_1F6 & 0x400)) { - this->unk_1F6 |= 0x400; + if (!(this->maskTextFlags & OSN_MASK_TEXT_STONE)) { + this->maskTextFlags |= OSN_MASK_TEXT_STONE; return 0x1FD1; } break; + case PLAYER_MASK_POSTMAN: - if (!(this->unk_1F6 & 0x800)) { - this->unk_1F6 |= 0x800; + if (!(this->maskTextFlags & OSN_MASK_TEXT_POSTMAN)) { + this->maskTextFlags |= OSN_MASK_TEXT_POSTMAN; return 0x1FD2; } break; + case PLAYER_MASK_BUNNY: - if (!(this->unk_1F6 & 0x1000)) { - this->unk_1F6 |= 0x1000; + if (!(this->maskTextFlags & OSN_MASK_TEXT_BUNNY)) { + this->maskTextFlags |= OSN_MASK_TEXT_BUNNY; return 0x1FD2; } break; + case PLAYER_MASK_CAPTAIN: - if (!(this->unk_1F6 & 0x2000)) { - this->unk_1F6 |= 0x2000; + if (!(this->maskTextFlags & OSN_MASK_TEXT_CAPTAIN)) { + this->maskTextFlags |= OSN_MASK_TEXT_CAPTAIN; return 0x1FD1; } break; + case PLAYER_MASK_BREMEN: - if (!(this->unk_1F6 & 0x4000)) { - this->unk_1F6 |= 0x4000; + if (!(this->maskTextFlags & OSN_MASK_TEXT_BREMEN)) { + this->maskTextFlags |= OSN_MASK_TEXT_BREMEN; return 0x1FD1; } break; + case PLAYER_MASK_CIRCUS_LEADER: - if (!(this->unk_1F6 & 0x8000)) { - this->unk_1F6 |= 0x8000; + if (!(this->maskTextFlags & OSN_MASK_TEXT_CIRCUS_LEADER)) { + this->maskTextFlags |= OSN_MASK_TEXT_CIRCUS_LEADER; return 0x1FD1; } break; + case PLAYER_MASK_KEATON: - if (!(this->unk_1F6 & 0x10000)) { - this->unk_1F6 |= 0x10000; + if (!(this->maskTextFlags & OSN_MASK_TEXT_KEATON)) { + this->maskTextFlags |= OSN_MASK_TEXT_KEATON; return 0x1FD1; } break; + case PLAYER_MASK_GARO: - if (!(this->unk_1F6 & 0x20000)) { - this->unk_1F6 |= 0x20000; + if (!(this->maskTextFlags & OSN_MASK_TEXT_GARO)) { + this->maskTextFlags |= OSN_MASK_TEXT_GARO; return 0x1FD1; } break; + case PLAYER_MASK_ALL_NIGHT: - if (!(this->unk_1F6 & 0x40000)) { - this->unk_1F6 |= 0x40000; + if (!(this->maskTextFlags & OSN_MASK_TEXT_ALL_NIGHT)) { + this->maskTextFlags |= OSN_MASK_TEXT_ALL_NIGHT; return 0x1FD1; } break; + case PLAYER_MASK_ROMANI: - if (!(this->unk_1F6 & 0x80000)) { - this->unk_1F6 |= 0x80000; + if (!(this->maskTextFlags & OSN_MASK_TEXT_ROMANI)) { + this->maskTextFlags |= OSN_MASK_TEXT_ROMANI; return 0x1FD1; } break; + default: break; } - this->unk_1EA |= 0x20; - if (gSaveContext.save.day == 3 && gSaveContext.save.time >= CLOCK_TIME(5, 0) && - gSaveContext.save.time < CLOCK_TIME(6, 0)) { + this->stateFlags |= OSN_STATE_END_CONVERSATION; + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; } -s32 func_80AD0E10(EnOsn* this, PlayState* play) { +s32 EnOsn_GetInitialText(EnOsn* this, PlayState* play) { Player* player = GET_PLAYER(play); if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) && CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { - if (this->unk_1EA & 1) { - this->unk_1EA |= 0x20; + if (this->stateFlags & OSN_STATE_SPECIAL_CONVERSTATION) { + this->stateFlags |= OSN_STATE_END_CONVERSATION; if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) && (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && @@ -361,28 +458,28 @@ s32 func_80AD0E10(EnOsn* this, PlayState* play) { } if (player->transformation == PLAYER_FORM_DEKU) { - if (this->unk_1EA & 4) { - this->unk_1EA |= 0x20; + if (this->stateFlags & OSN_STATE_MET_DEKU) { + this->stateFlags |= OSN_STATE_END_CONVERSATION; if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; } - this->unk_1EA |= 4; + this->stateFlags |= OSN_STATE_MET_DEKU; return 0x1FC8; } if (player->transformation == PLAYER_FORM_GORON) { - if (this->unk_1EA & 8) { - this->unk_1EA |= 0x20; + if (this->stateFlags & OSN_STATE_MET_GORON) { + this->stateFlags |= OSN_STATE_END_CONVERSATION; if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; } - this->unk_1EA |= 8; + this->stateFlags |= OSN_STATE_MET_GORON; if (gSaveContext.save.weekEventReg[76] & 0x20) { return 0x1FC8; } @@ -392,15 +489,15 @@ s32 func_80AD0E10(EnOsn* this, PlayState* play) { } if (player->transformation == PLAYER_FORM_ZORA) { - if (this->unk_1EA & 0x10) { - this->unk_1EA |= 0x20; + if (this->stateFlags & OSN_STATE_MET_ZORA) { + this->stateFlags |= OSN_STATE_END_CONVERSATION; if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; } - this->unk_1EA |= 0x10; + this->stateFlags |= OSN_STATE_MET_ZORA; if (gSaveContext.save.weekEventReg[76] & 0x40) { return 0x1FC8; } @@ -409,22 +506,22 @@ s32 func_80AD0E10(EnOsn* this, PlayState* play) { } if (Player_GetMask(play) == PLAYER_MASK_NONE) { - if (this->unk_1EA & 2) { - this->unk_1EA |= 0x20; + if (this->stateFlags & OSN_STATE_MET_HUMAN) { + this->stateFlags |= OSN_STATE_END_CONVERSATION; if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2006; } return 0x1FCD; } - this->unk_1EA |= 2; + this->stateFlags |= OSN_STATE_MET_HUMAN; return 0x1FC8; } - return func_80AD0B38(this, play); + return EnOsn_GetInitialMaskText(this, play); } - this->unk_1EA |= 0x20; + this->stateFlags |= OSN_STATE_END_CONVERSATION; if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && (gSaveContext.save.time < CLOCK_TIME(6, 0))) { return 0x2004; @@ -433,123 +530,123 @@ s32 func_80AD0E10(EnOsn* this, PlayState* play) { return 0x1FAE; } -void func_80AD10FC(EnOsn* this, PlayState* play) { - switch (this->unk_1F4) { +void EnOsn_HandleConversation(EnOsn* this, PlayState* play) { + switch (this->textId) { case 0x1FC8: - this->unk_1F4 = 0x1FC9; + this->textId = 0x1FC9; break; case 0x1FC9: - this->unk_1F4 = 0x1FCA; + this->textId = 0x1FCA; break; case 0x1FCA: - if ((gSaveContext.save.day == 3 && gSaveContext.save.time >= CLOCK_TIME(5, 0)) && - gSaveContext.save.time < CLOCK_TIME(6, 0)) { - this->unk_1F4 = 0x2007; + if ((gSaveContext.save.day == 3) && (gSaveContext.save.time >= CLOCK_TIME(5, 0)) && + (gSaveContext.save.time < CLOCK_TIME(6, 0))) { + this->textId = 0x2007; } else { - this->unk_1F4 = 0x1FCB; + this->textId = 0x1FCB; } break; case 0x1FCB: case 0x2007: - this->unk_1F4 = 0x1FCC; - this->unk_1EA |= 0x20; + this->textId = 0x1FCC; + this->stateFlags |= OSN_STATE_END_CONVERSATION; break; case 0x1FCE: case 0x1FD0: - this->unk_1F4 = 0x1FCF; + this->textId = 0x1FCF; break; case 0x1FCF: - this->unk_1F4 = 0x1FCA; + this->textId = 0x1FCA; break; case 0x1FD1: case 0x1FD2: - this->unk_1F4 = func_80AD08B0(play); + this->textId = EnOsn_GetMaskText(play); break; case 0x1FD6: - this->unk_1F4 = 0x1FD7; + this->textId = 0x1FD7; break; case 0x1FD8: - this->unk_1F4 = 0x1FD9; + this->textId = 0x1FD9; break; case 0x1FDA: - this->unk_1F4 = 0x1FDB; + this->textId = 0x1FDB; break; case 0x1FDC: - this->unk_1F4 = 0x1FDD; + this->textId = 0x1FDD; break; case 0x1FDE: - this->unk_1F4 = 0x1FDF; + this->textId = 0x1FDF; break; case 0x1FE0: - this->unk_1F4 = 0x1FE1; + this->textId = 0x1FE1; break; case 0x1FE2: - this->unk_1F4 = 0x1FE3; + this->textId = 0x1FE3; break; case 0x1FE4: - this->unk_1F4 = 0x1FE5; + this->textId = 0x1FE5; break; case 0x1FE6: - this->unk_1F4 = 0x1FE7; + this->textId = 0x1FE7; break; case 0x1FE8: - this->unk_1F4 = 0x1FE9; + this->textId = 0x1FE9; break; case 0x1FEA: - this->unk_1F4 = 0x1FEB; + this->textId = 0x1FEB; break; case 0x1FEC: - this->unk_1F4 = 0x1FED; + this->textId = 0x1FED; break; case 0x1FEE: - this->unk_1F4 = 0x1FEF; + this->textId = 0x1FEF; break; case 0x1FF0: - this->unk_1F4 = 0x1FF1; + this->textId = 0x1FF1; break; case 0x1FF2: - this->unk_1F4 = 0x1FF3; + this->textId = 0x1FF3; break; case 0x1FF4: - this->unk_1F4 = 0x1FF5; + this->textId = 0x1FF5; break; case 0x1FF6: - this->unk_1F4 = 0x1FF7; + this->textId = 0x1FF7; break; case 0x1FF8: - this->unk_1F4 = 0x1FF9; + this->textId = 0x1FF9; break; case 0x1FFA: - this->unk_1F4 = 0x1FFB; + this->textId = 0x1FFB; break; case 0x1FFC: - this->unk_1F4 = 0x1FFD; + this->textId = 0x1FFD; break; case 0x1FD7: @@ -563,7 +660,7 @@ void func_80AD10FC(EnOsn* this, PlayState* play) { case 0x1FF7: case 0x1FF9: case 0x1FFB: - this->unk_1F4 = 0x1FD3; + this->textId = 0x1FD3; break; case 0x1FD9: @@ -574,24 +671,24 @@ void func_80AD10FC(EnOsn* this, PlayState* play) { case 0x1FEF: case 0x1FF5: case 0x1FFD: - this->unk_1F4 = 0x1FD4; + this->textId = 0x1FD4; break; case 0x1FE5: - this->unk_1F4 = 0x1FFE; + this->textId = 0x1FFE; break; case 0x1FD3: case 0x1FD4: case 0x1FFE: - this->unk_1F4 = 0x1FD5; - this->unk_1EA |= 0x20; + this->textId = 0x1FD5; + this->stateFlags |= OSN_STATE_END_CONVERSATION; } - Message_StartTextbox(play, this->unk_1F4, &this->actor); + Message_StartTextbox(play, this->textId, &this->actor); } -void func_80AD1398(EnOsn* this) { +void EnOsn_InitCutscene(EnOsn* this) { this->cutscene = this->actor.cutscene; if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) || (INV_CONTENT(ITEM_MASK_DEKU) == ITEM_MASK_DEKU)) { @@ -604,147 +701,170 @@ void func_80AD1398(EnOsn* this) { } } -void func_80AD144C(EnOsn* this, PlayState* play) { - u32 sp1C = Flags_GetSwitch(play, 0); +void EnOsn_ChooseAction(EnOsn* this, PlayState* play) { + u32 isFlagSet = Flags_GetSwitch(play, 0); + this->cutscene = this->actor.cutscene; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 0); - if (sp1C == 0) { - this->actionFunc = func_80AD16A8; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, OSN_ANIM_IDLE); + if (!isFlagSet) { + this->actionFunc = EnOsn_HandleCsAction; } else { - this->actionFunc = func_80AD14C8; + this->actionFunc = EnOsn_Idle; } } -void func_80AD14C8(EnOsn* this, PlayState* play) { - s16 temp_v1 = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; +void EnOsn_Idle(EnOsn* this, PlayState* play) { + s16 yaw = this->actor.yawTowardsPlayer - this->actor.shape.rot.y; - if (gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE && !CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { + if ((gSaveContext.save.inventory.items[SLOT_OCARINA] != ITEM_NONE) && !CHECK_QUEST_ITEM(QUEST_SONG_HEALING)) { if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - this->actionFunc = func_80AD1634; - } else if ((((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && (temp_v1 < 0x4000)) && - (temp_v1 > -0x4000)) { + this->actionFunc = EnOsn_StartCutscene; + } else if (((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && (yaw < 0x4000) && + (yaw > -0x4000)) { func_800B863C(&this->actor, play); this->actor.textId = 0xFFFF; } - } else { - if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { - this->unk_1F4 = func_80AD0E10(this, play); - Message_StartTextbox(play, this->unk_1F4, &this->actor); - this->actionFunc = func_80AD19A0; - } else if ((((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && (temp_v1 < 0x4000)) && - (temp_v1 > -0x4000)) { - func_800B863C(&this->actor, play); - } + } else if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->textId = EnOsn_GetInitialText(this, play); + Message_StartTextbox(play, this->textId, &this->actor); + this->actionFunc = EnOsn_Talk; + } else if (((this->actor.xzDistToPlayer < 100.0f) || this->actor.isTargeted) && (yaw < 0x4000) && (yaw > -0x4000)) { + func_800B863C(&this->actor, play); } } -void func_80AD1634(EnOsn* this, PlayState* play) { +void EnOsn_StartCutscene(EnOsn* this, PlayState* play) { if (ActorCutscene_GetCanPlayNext(this->cutscene)) { ActorCutscene_Start(this->cutscene, &this->actor); - this->actionFunc = func_80AD16A8; - return; + this->actionFunc = EnOsn_HandleCsAction; + } else { + if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + } + ActorCutscene_SetIntentToPlay(this->cutscene); } - if (ActorCutscene_GetCurrentIndex() == 0x7C) { - ActorCutscene_Stop(0x7C); - } - ActorCutscene_SetIntentToPlay(this->cutscene); } -void func_80AD16A8(EnOsn* this, PlayState* play) { +void EnOsn_HandleCsAction(EnOsn* this, PlayState* play) { u8 pad; s32 actionIndex; if (Cutscene_CheckActorAction(play, 130)) { actionIndex = Cutscene_GetActorActionIndex(play, 130); - this->unk_1F0 = 0; - if (this->unk_1ED != play->csCtx.actorActions[actionIndex]->action) { - this->unk_1ED = play->csCtx.actorActions[actionIndex]->action; + this->shouldRotateHead = false; + if (this->csAction != play->csCtx.actorActions[actionIndex]->action) { + this->csAction = play->csCtx.actorActions[actionIndex]->action; switch (play->csCtx.actorActions[actionIndex]->action) { case 1: - this->unk_1EC = 2; + this->animIndex = OSN_ANIM_BOWING; break; + case 2: - this->unk_1EC = 1; + this->animIndex = OSN_ANIM_ARMS_OUT; break; + case 3: - this->unk_1EC = 7; + this->animIndex = OSN_ANIM_SHAKE_HEAD; break; + case 4: - this->unk_1EC = 3; + this->animIndex = OSN_ANIM_REMINISCE; break; + case 5: - this->unk_1EC = 6; + this->animIndex = OSN_ANIM_THINK; break; + case 6: - this->unk_1EC = 5; + this->animIndex = OSN_ANIM_BELIEVE; break; + case 7: - this->unk_1EC = 4; + this->animIndex = OSN_ANIM_HANDS_CLASPED; break; + case 8: - this->unk_1EC = 0; + this->animIndex = OSN_ANIM_IDLE; break; + case 10: - this->unk_1EC = 8; + this->animIndex = OSN_ANIM_ORGAN_TALK; break; + case 11: - this->unk_1EC = 9; + this->animIndex = OSN_ANIM_ORGAN_PLAY; break; + case 13: - this->unk_1EC = 0xA; + this->animIndex = OSN_ANIM_SHAKE; break; + case 15: - this->unk_1EC = 0xB; + this->animIndex = OSN_ANIM_CHOKE; break; + case 16: - this->unk_1EC = 0xC; + this->animIndex = OSN_ANIM_DESPAIR; break; + case 17: - this->unk_1EC = 0xD; + this->animIndex = OSN_ANIM_FAST_BOWS; break; + case 18: - this->unk_1EC = 0xE; + this->animIndex = OSN_ANIM_HAND_OUT; break; + case 19: - this->unk_1EC = 0x11; + this->animIndex = OSN_ANIM_MASK_LOOK_AT; break; + case 20: - this->unk_1EC = 0x12; + this->animIndex = OSN_ANIM_TURN_AROUND_START; break; + case 21: - this->unk_1EC = 0x14; + this->animIndex = OSN_ANIM_WALK_AWAY; break; + case 22: - this->unk_1EC = 0x15; + this->animIndex = OSN_ANIM_MASK_LOOK_FROM_START; break; + case 23: - this->unk_1EC = 0x17; + this->animIndex = OSN_ANIM_HAND_OUT_2; break; + case 24: - this->unk_1EC = 0x18; + this->animIndex = OSN_ANIM_WALK_AWAY_END; break; + default: - this->unk_1EC = 0; + this->animIndex = OSN_ANIM_IDLE; break; } - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_1EC); + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); } - if ((this->unk_1EC == 5) && (play->sceneId == SCENE_SPOT00) && (gSaveContext.sceneLayer == 0xB) && - (play->csCtx.frames == 400)) { + if ((this->animIndex == OSN_ANIM_BELIEVE) && (play->sceneId == SCENE_SPOT00) && + (gSaveContext.sceneLayer == 0xB) && (play->csCtx.frames == 400)) { Actor_PlaySfxAtPos(&this->actor, NA_SE_VO_OMVO00); } - if (this->unk_1EC == 0x12) { - func_80AD0998(this); + + if (this->animIndex == OSN_ANIM_TURN_AROUND_START) { + EnOsn_TurnAround(this); } - if (this->unk_1EC == 0x15) { - func_80AD0A24(this); + + if (this->animIndex == OSN_ANIM_MASK_LOOK_FROM_START) { + EnOsn_LookFromMask(this); } - if (this->unk_1EC == 0x18) { - func_80AD0AB0(this); + + if (this->animIndex == OSN_ANIM_WALK_AWAY_END) { + EnOsn_FadeOut(this); } - if ((this->unk_1EC == 0x14) && + + if ((this->animIndex == OSN_ANIM_WALK_AWAY) && (((Animation_OnFrame(&this->skelAnime, 17.0f))) || (Animation_OnFrame(&this->skelAnime, 27.0f)) || (Animation_OnFrame(&this->skelAnime, 37.0f)) || (Animation_OnFrame(&this->skelAnime, 47.0f)) || (Animation_OnFrame(&this->skelAnime, 57.0f)) || (Animation_OnFrame(&this->skelAnime, 67.0f)))) { @@ -752,28 +872,28 @@ void func_80AD16A8(EnOsn* this, PlayState* play) { } Cutscene_ActorTranslateAndYaw(&this->actor, play, actionIndex); } else { - this->unk_1F0 = 1; - this->unk_1ED = 0x63; - func_80AD144C(this, play); + this->shouldRotateHead = true; + this->csAction = 0x63; + EnOsn_ChooseAction(this, play); } } -void func_80AD19A0(EnOsn* this, PlayState* play) { +void EnOsn_Talk(EnOsn* this, PlayState* play) { u8 talkState = Message_GetState(&play->msgCtx); if (((talkState == TEXT_STATE_DONE) || (talkState == TEXT_STATE_5)) && Message_ShouldAdvance(play)) { - if (this->unk_1EA & 0x20) { - this->unk_1EA &= ~0x20; + if (this->stateFlags & OSN_STATE_END_CONVERSATION) { + this->stateFlags &= ~OSN_STATE_END_CONVERSATION; play->msgCtx.msgMode = 0x43; play->msgCtx.stateTimer = 4; - this->actionFunc = func_80AD14C8; + this->actionFunc = EnOsn_Idle; } else { - func_80AD10FC(this, play); + EnOsn_HandleConversation(this, play); } } } -void EnOsn_Idle(EnOsn* this, PlayState* play) { +void EnOsn_DoNothing(EnOsn* this, PlayState* play) { } void EnOsn_Init(Actor* thisx, PlayState* play) { @@ -782,51 +902,50 @@ void EnOsn_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->actor, sInitChain); ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 20.0f); - SkelAnime_InitFlex(play, &this->skelAnime, &object_osn_Skel_0202F0, &object_osn_Anim_0201BC, NULL, NULL, 0); + SkelAnime_InitFlex(play, &this->skelAnime, &gHappyMaskSalesmanSkel, &gHappyMaskSalesmanIdleAnim, NULL, NULL, 0); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, &sDamageTable, &sColChkInfoInit); - this->unk_1FA = 255; - switch (ENOSN_GET_3(&this->actor)) { - case 0: + this->alpha = 255; + + switch (ENOSN_GET_TYPE(&this->actor)) { + case OSN_TYPE_CHOOSE: if (((gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 2)) || (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 3))) || (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 6))) { - this->unk_1EA |= 1; + this->stateFlags |= OSN_STATE_SPECIAL_CONVERSTATION; } - this->unk_1F0 = 1; + this->shouldRotateHead = true; if (play->sceneId == SCENE_INSIDETOWER) { if ((gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 2)) || (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 6))) { - this->actionFunc = func_80AD16A8; - return; + this->actionFunc = EnOsn_HandleCsAction; + } else if (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 3)) { + EnOsn_InitCutscene(this); + this->actionFunc = EnOsn_StartCutscene; + } else { + EnOsn_ChooseAction(this, play); } - if (gSaveContext.save.entrance == ENTRANCE(CLOCK_TOWER_INTERIOR, 3)) { - func_80AD1398(this); - this->actionFunc = func_80AD1634; - return; - } - func_80AD144C(this, play); - return; + } else { + EnOsn_ChooseAction(this, play); } - func_80AD144C(this, play); break; - case 1: - this->unk_1EC = 0xF; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_1EC); - this->actionFunc = EnOsn_Idle; + case OSN_TYPE_LIE_FACE_DOWN: + this->animIndex = OSN_ANIM_LYING_DOWN_FACE_UP; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); + this->actionFunc = EnOsn_DoNothing; break; - case 2: - this->unk_1EC = 0x10; - Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->unk_1EC); - this->actionFunc = EnOsn_Idle; + case OSN_TYPE_LIE_FACE_UP: + this->animIndex = OSN_ANIM_LYING_DOWN_FACE_DOWN; + Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, this->animIndex); + this->actionFunc = EnOsn_DoNothing; break; - case 3: + case OSN_TYPE_CUTSCENE: this->actor.flags &= ~ACTOR_FLAG_1; - this->actionFunc = func_80AD16A8; + this->actionFunc = EnOsn_HandleCsAction; break; default: @@ -845,33 +964,35 @@ void EnOsn_Destroy(Actor* thisx, PlayState* play) { void EnOsn_Update(Actor* thisx, PlayState* play) { s32 pad; EnOsn* this = THIS; - u32 sp34; + u32 isFlagSet = Flags_GetSwitch(play, 0); - sp34 = Flags_GetSwitch(play, 0); this->actionFunc(this, play); Actor_MoveWithGravity(&this->actor); SkelAnime_Update(&this->skelAnime); - if (!ENOSN_GET_3(&this->actor)) { - if (sp34 != 0) { + + if (ENOSN_GET_TYPE(&this->actor) == OSN_TYPE_CHOOSE) { + if (isFlagSet) { this->actor.flags |= ACTOR_FLAG_1; - func_80AD0830(this, play); + EnOsn_UpdateCollider(this, play); this->actor.draw = EnOsn_Draw; } else { this->actor.draw = NULL; this->actor.flags &= ~ACTOR_FLAG_1; } } - Actor_TrackPlayer(play, &this->actor, &this->unk_1D8, &this->unk_1DE, this->actor.focus.pos); + + Actor_TrackPlayer(play, &this->actor, &this->headRot, &this->torsoRot, this->actor.focus.pos); } s32 EnOsn_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnOsn* this = (EnOsn*)thisx; - if (this->unk_1F0 && limbIndex == 11) { - Matrix_RotateXS(this->unk_1D8.y, MTXMODE_APPLY); + if (this->shouldRotateHead && (limbIndex == HAPPY_MASK_SALESMAN_LIMB_HEAD)) { + Matrix_RotateXS(this->headRot.y, MTXMODE_APPLY); } - if ((this->unk_1EC == 9 || this->unk_1EC == 8) && limbIndex == 10) { + if (((this->animIndex == OSN_ANIM_ORGAN_PLAY) || (this->animIndex == OSN_ANIM_ORGAN_TALK)) && + (limbIndex == HAPPY_MASK_SALESMAN_LIMB_BACKPACK)) { *dList = NULL; } return false; @@ -879,48 +1000,51 @@ s32 EnOsn_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p void EnOsn_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx, Gfx** gfx) { EnOsn* this = (EnOsn*)thisx; - Vec3f sp30 = { 0.0f, 0.0f, 0.0f }; - Vec3s sp28 = { 0x9920, -0x384, -0x320 }; + Vec3f headOffset = { 0.0f, 0.0f, 0.0f }; + Vec3s leftHandRot = { 0x9920, -0x384, -0x320 }; - if (limbIndex == 11) { - Matrix_MultVec3f(&sp30, &thisx->focus.pos); + if (limbIndex == HAPPY_MASK_SALESMAN_LIMB_HEAD) { + Matrix_MultVec3f(&headOffset, &this->actor.focus.pos); } - if (((this->unk_1EC == 17) || (this->unk_1EC == 21) || (this->unk_1EC == 22)) && (limbIndex == 6)) { + if (((this->animIndex == OSN_ANIM_MASK_LOOK_AT) || (this->animIndex == OSN_ANIM_MASK_LOOK_FROM_START) || + (this->animIndex == OSN_ANIM_MASK_LOOK_FROM_LOOP)) && + (limbIndex == HAPPY_MASK_SALESMAN_LIMB_LEFT_HAND)) { Matrix_Push(); Matrix_Translate(-400.0f, 1100.0f, -200.0f, MTXMODE_APPLY); - Matrix_RotateXS(sp28.x, MTXMODE_APPLY); - Matrix_RotateYS(sp28.y, MTXMODE_APPLY); - Matrix_RotateZS(sp28.z, MTXMODE_APPLY); + Matrix_RotateXS(leftHandRot.x, MTXMODE_APPLY); + Matrix_RotateYS(leftHandRot.y, MTXMODE_APPLY); + Matrix_RotateZS(leftHandRot.z, MTXMODE_APPLY); gSPMatrix((*gfx)++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPDisplayList((*gfx)++, &object_osn_DL_0192A0); + gSPDisplayList((*gfx)++, &gHappyMaskSalesmanMajorasMaskDL); Matrix_Pop(); } } void EnOsn_Draw(Actor* thisx, PlayState* play) { - static TexturePtr D_80AD2588 = object_osn_Tex_0166F8; - static TexturePtr D_80AD258C = object_osn_Tex_016EF8; - static TexturePtr D_80AD2590 = object_osn_Tex_0176F8; - static TexturePtr D_80AD2594 = object_osn_Tex_017EF8; - static TexturePtr D_80AD2598 = object_osn_Tex_0182F8; + static TexturePtr sEyeClosedHappyTex = gHappyMaskSalesmanEyeClosedHappyTex; + static TexturePtr sEyeOpenTex = gHappyMaskSalesmanEyeOpenTex; + static TexturePtr sEyeClosedAngryTex = gHappyMaskSalesmanEyeClosedAngryTex; + static TexturePtr sSmileTex = gHappyMaskSalesmanSmileTex; + static TexturePtr sFrownTex = gHappyMaskSalesmanFrownTex; s32 pad; EnOsn* this = THIS; OPEN_DISPS(play->state.gfxCtx); - if (this->unk_1FA == 0xFF) { + if (this->alpha == 255) { func_8012C28C(play->state.gfxCtx); - if ((this->unk_1EC == 0xB) || (this->unk_1EC == 0xC) || (this->unk_1EC == 0x17) || - (play->msgCtx.currentTextId == 0x1FCA)) { - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD258C)); - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2594)); - } else if ((this->unk_1EC == 7) || (this->unk_1EC == 3) || (this->unk_1EC == 0xD)) { - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD2590)); - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2598)); + if ((this->animIndex == OSN_ANIM_CHOKE) || (this->animIndex == OSN_ANIM_DESPAIR) || + (this->animIndex == OSN_ANIM_HAND_OUT_2) || (play->msgCtx.currentTextId == 0x1FCA)) { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeOpenTex)); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sSmileTex)); + } else if ((this->animIndex == OSN_ANIM_SHAKE_HEAD) || (this->animIndex == OSN_ANIM_REMINISCE) || + (this->animIndex == OSN_ANIM_FAST_BOWS)) { + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeClosedAngryTex)); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sFrownTex)); } else { - gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD2588)); - gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2594)); + gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeClosedHappyTex)); + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sSmileTex)); } gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 255); Scene_SetRenderModeXlu(play, 0, 1); @@ -929,9 +1053,9 @@ void EnOsn_Draw(Actor* thisx, PlayState* play) { EnOsn_OverrideLimbDraw, EnOsn_PostLimbDraw, &this->actor, POLY_OPA_DISP); } else { func_8012C2DC(play->state.gfxCtx); - gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(D_80AD2588)); - gSPSegment(POLY_XLU_DISP++, 0x09, Lib_SegmentedToVirtual(D_80AD2594)); - gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->unk_1FA); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(sEyeClosedHappyTex)); + gSPSegment(POLY_XLU_DISP++, 0x09, Lib_SegmentedToVirtual(sSmileTex)); + gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, this->alpha); Scene_SetRenderModeXlu(play, 1, 2); POLY_XLU_DISP = SkelAnime_DrawFlex(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, diff --git a/src/overlays/actors/ovl_En_Osn/z_en_osn.h b/src/overlays/actors/ovl_En_Osn/z_en_osn.h index 5d9858bd4..638f31e4e 100644 --- a/src/overlays/actors/ovl_En_Osn/z_en_osn.h +++ b/src/overlays/actors/ovl_En_Osn/z_en_osn.h @@ -7,25 +7,32 @@ struct EnOsn; typedef void (*EnOsnActionFunc)(struct EnOsn*, PlayState*); +#define ENOSN_GET_TYPE(this) ((thisx)->params & 3) + +typedef enum { + /* 0 */ OSN_TYPE_CHOOSE, // Will choose between Idle and Cutscene + /* 1 */ OSN_TYPE_LIE_FACE_DOWN, + /* 2 */ OSN_TYPE_LIE_FACE_UP, + /* 3 */ OSN_TYPE_CUTSCENE +} OsnType; + typedef struct EnOsn { /* 0x000 */ Actor actor; /* 0x144 */ ColliderCylinder collider; /* 0x190 */ SkelAnime skelAnime; /* 0x1D4 */ EnOsnActionFunc actionFunc; - /* 0x1D8 */ Vec3s unk_1D8; - /* 0x1DE */ Vec3s unk_1DE; + /* 0x1D8 */ Vec3s headRot; + /* 0x1DE */ Vec3s torsoRot; /* 0x1E4 */ UNK_TYPE1 unk_1E4[0x6]; - /* 0x1EA */ u16 unk_1EA; - /* 0x1EC */ u8 unk_1EC; - /* 0x1ED */ u8 unk_1ED; + /* 0x1EA */ u16 stateFlags; + /* 0x1EC */ u8 animIndex; + /* 0x1ED */ u8 csAction; /* 0x1EE */ s16 cutscene; - /* 0x1F0 */ u8 unk_1F0; + /* 0x1F0 */ u8 shouldRotateHead; /* 0x1F1 */ UNK_TYPE1 unk_1F1[0x3]; - /* 0x1F4 */ u16 unk_1F4; - /* 0x1F6 */ s32 unk_1F6; - /* 0x1FA */ u8 unk_1FA; + /* 0x1F4 */ u16 textId; + /* 0x1F6 */ s32 maskTextFlags; + /* 0x1FA */ u8 alpha; } EnOsn; // size = 0x1FB -#define ENOSN_GET_3(this) ((thisx)->params & 3) - #endif // Z_EN_OSN_H diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index a84639222..7a1f13c3c 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -12135,21 +12135,21 @@ 0x80AD02FC:("EnFuKago_Update",), 0x80AD0340:("func_80AD0340",), 0x80AD04A4:("EnFuKago_Draw",), - 0x80AD0830:("func_80AD0830",), - 0x80AD08B0:("func_80AD08B0",), - 0x80AD0998:("func_80AD0998",), - 0x80AD0A24:("func_80AD0A24",), - 0x80AD0AB0:("func_80AD0AB0",), - 0x80AD0B38:("func_80AD0B38",), - 0x80AD0E10:("func_80AD0E10",), - 0x80AD10FC:("func_80AD10FC",), - 0x80AD1398:("func_80AD1398",), - 0x80AD144C:("func_80AD144C",), - 0x80AD14C8:("func_80AD14C8",), - 0x80AD1634:("func_80AD1634",), - 0x80AD16A8:("func_80AD16A8",), - 0x80AD19A0:("func_80AD19A0",), - 0x80AD1A4C:("EnOsn_Idle",), + 0x80AD0830:("EnOsn_UpdateCollider",), + 0x80AD08B0:("EnOsn_GetMaskText",), + 0x80AD0998:("EnOsn_TurnAround",), + 0x80AD0A24:("EnOsn_LookFromMask",), + 0x80AD0AB0:("EnOsn_FadeOut",), + 0x80AD0B38:("EnOsn_GetInitialMaskText",), + 0x80AD0E10:("EnOsn_GetInitialText",), + 0x80AD10FC:("EnOsn_HandleConversation",), + 0x80AD1398:("EnOsn_InitCutscene",), + 0x80AD144C:("EnOsn_ChooseAction",), + 0x80AD14C8:("EnOsn_Idle",), + 0x80AD1634:("EnOsn_StartCutscene",), + 0x80AD16A8:("EnOsn_HandleCsAction",), + 0x80AD19A0:("EnOsn_Talk",), + 0x80AD1A4C:("EnOsn_DoNothing",), 0x80AD1A5C:("EnOsn_Init",), 0x80AD1C88:("EnOsn_Destroy",), 0x80AD1CC8:("EnOsn_Update",), From d863e7aeef846cbcfb11383d0e0a676fba4481a0 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo <96613413+sonicdcer@users.noreply.github.com> Date: Sat, 22 Oct 2022 11:18:42 -0300 Subject: [PATCH 10/10] ovl_En_Rz OK (#1029) * progress * 4 functions left * progress * all functions matching * ovl_En_Rz OK * formatting * a few things here and there * whoops! * pr review * pr review * remove temp * pr review * pr review * casts removed * merge fix * pr review * pr changes * macros and enums * struct * defines in c file * EnRzType in Header * ROSA_SISTERS * sEyeTextures * animations * @bug * sEnRzEyeTextures * func_80BFC674 * switch spaces and default * format * static * animation docs * link anim enum * Rosa Sisters animations enum * comment * a few things * EN_RZ_GET_SISTER fix * comment on array size * path enum * EnRz_SetupPath * EnRz_PathStatus * EnRzPathStatus * EnRz_Walk * EnRz_StopToThink * pr review * singular * step * EnRz_GetPathStatus * Actor_Kill * review Co-authored-by: Angie --- assets/xml/objects/object_rz.xml | 16 +- spec | 3 +- src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c | 2 +- src/overlays/actors/ovl_En_Rz/z_en_rz.c | 684 ++++++++++++++++++++-- src/overlays/actors/ovl_En_Rz/z_en_rz.h | 35 +- src/overlays/actors/ovl_En_Yb/z_en_yb.c | 2 +- tools/disasm/functions.txt | 20 +- 7 files changed, 690 insertions(+), 72 deletions(-) diff --git a/assets/xml/objects/object_rz.xml b/assets/xml/objects/object_rz.xml index d8740403a..9bf8961a9 100644 --- a/assets/xml/objects/object_rz.xml +++ b/assets/xml/objects/object_rz.xml @@ -1,13 +1,13 @@  - - - - - - - - + + + + + + + + diff --git a/spec b/spec index d9ebf99ce..f11ef25a0 100644 --- a/spec +++ b/spec @@ -4697,8 +4697,7 @@ beginseg name "ovl_En_Rz" compress include "build/src/overlays/actors/ovl_En_Rz/z_en_rz.o" - include "build/data/ovl_En_Rz/ovl_En_Rz.data.o" - include "build/data/ovl_En_Rz/ovl_En_Rz.reloc.o" + include "build/src/overlays/actors/ovl_En_Rz/ovl_En_Rz_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c index f6d08515e..e2dc0daa7 100644 --- a/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c +++ b/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.c @@ -191,7 +191,7 @@ s32 DmBal_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* p void DmBal_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { } -TexturePtr sEyeTextures[] = { object_bal_Tex_006050, object_bal_Tex_0094D0 }; +static TexturePtr sEyeTextures[] = { object_bal_Tex_006050, object_bal_Tex_0094D0 }; void DmBal_Draw(Actor* thisx, PlayState* play) { DmBal* this = THIS; diff --git a/src/overlays/actors/ovl_En_Rz/z_en_rz.c b/src/overlays/actors/ovl_En_Rz/z_en_rz.c index c53c79234..a53ad3bda 100644 --- a/src/overlays/actors/ovl_En_Rz/z_en_rz.c +++ b/src/overlays/actors/ovl_En_Rz/z_en_rz.c @@ -5,6 +5,7 @@ */ #include "z_en_rz.h" +#include "assets/objects/gameplay_keep/gameplay_keep.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8) @@ -15,21 +16,39 @@ void EnRz_Destroy(Actor* thisx, PlayState* play); void EnRz_Update(Actor* thisx, PlayState* play); void EnRz_Draw(Actor* thisx, PlayState* play); +void EnRz_ActorShadowFunc(Actor* thisx, Lights* mapper, PlayState* play); +void EnRz_ChangeAnim(PlayState*, EnRz*, s16 animIndex, u8 animMode, f32 morphFrames); +s32 EnRz_SetupPath(EnRz* this, PlayState* play); +EnRz* EnRz_FindSister(EnRz* this, PlayState*); void func_80BFC058(EnRz* this, PlayState* play); void func_80BFC078(EnRz* this, PlayState* play); -void func_80BFC19C(EnRz* this, PlayState* play); -void func_80BFC214(EnRz* this, PlayState* play); -void func_80BFC270(EnRz* this, PlayState* play); -void func_80BFC2F4(EnRz* this, PlayState* play); -void func_80BFC36C(EnRz* this, PlayState* play); void func_80BFC3F8(EnRz* this, PlayState* play); -void func_80BFC608(EnRz* this, PlayState* play); void func_80BFC674(EnRz* this, PlayState* play); -void func_80BFC728(EnRz* this, PlayState* play); void func_80BFC7E0(EnRz* this, PlayState* play); -void func_80BFC8F8(EnRz* this, PlayState* play); +void EnRz_Walk(EnRz* this, PlayState* play); + +#define EN_RZ_STATE_1 (1 << 0) +#define EN_RZ_STATE_2 (1 << 1) + +typedef enum { + /* 0 */ EN_RZ_ANIM_THINKING, + /* 1 */ EN_RZ_ANIM_STANDING, + /* 2 */ EN_RZ_ANIM_WALKING, + /* 3 */ EN_RZ_ANIM_SITTING, + /* 4 */ EN_RZ_ANIM_APPLAUDING, + /* 5 */ EN_RZ_ANIM_ON_KNEES, + /* 6 */ EN_RZ_ANIM_DANCE, + /* 7 */ EN_RZ_ANIM_LINK_NORMAL_WAIT_FREE, + /* 8 */ EN_RZ_ANIM_LINK_DANCE, + /* 9 */ EN_RZ_ANIM_MAX +} EnRzAnimation; + +typedef enum { + /* 0 */ EN_RZ_PATHSTATUS_NORMAL, //!< not near waypoint + /* 1 */ EN_RZ_PATHSTATUS_AT_POINT, //!< no path or new waypoint + /* 2 */ EN_RZ_PATHSTATUS_END //!< reached end of path +} EnRzPathStatus; -#if 0 ActorInit En_Rz_InitVars = { ACTOR_EN_RZ, ACTORCAT_NPC, @@ -42,80 +61,647 @@ ActorInit En_Rz_InitVars = { (ActorFunc)EnRz_Draw, }; -// static ColliderCylinderInit sCylinderInit = { -static ColliderCylinderInit D_80BFCCF4 = { - { COLTYPE_NONE, AT_NONE, AC_ON | AC_TYPE_ENEMY, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_1, COLSHAPE_CYLINDER, }, - { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_ON, OCELEM_ON, }, +static TexturePtr sEyeTextures[] = { + object_rz_Tex_00BC50, object_rz_Tex_00C190, object_rz_Tex_00C590, object_rz_Tex_00C990, object_rz_Tex_00CD90, +}; + +static ColliderCylinderInit sCylinderInit = { + { + COLTYPE_NONE, + AT_NONE, + AC_ON | AC_TYPE_ENEMY, + OC1_ON | OC1_TYPE_ALL, + OC2_TYPE_1, + COLSHAPE_CYLINDER, + }, + { + ELEMTYPE_UNK0, + { 0x00000000, 0x00, 0x00 }, + { 0xF7CFFFFF, 0x00, 0x00 }, + TOUCH_NONE | TOUCH_SFX_NORMAL, + BUMP_ON, + OCELEM_ON, + }, { 20, 40, 0, { 0, 0, 0 } }, }; -#endif +void EnRz_Init(Actor* thisx, PlayState* play) { + EnRz* this = THIS; + s16 tempCutscene = this->actor.cutscene; + s32 i; -extern ColliderCylinderInit D_80BFCCF4; + for (i = 0; i < ARRAY_COUNT(this->cutscenes); i++) { + this->cutscenes[i] = tempCutscene; + if (tempCutscene != -1) { + this->actor.cutscene = tempCutscene; + tempCutscene = ActorCutscene_GetAdditionalCutscene(this->actor.cutscene); + } + } -extern UNK_TYPE D_06003A20; -extern UNK_TYPE D_0600D768; + Actor_SetScale(&this->actor, 0.01f); + ActorShape_Init(&this->actor.shape, 0.0f, EnRz_ActorShadowFunc, 20.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/EnRz_Init.s") + // @bug this alignment is because of player animations, but should be using ALIGN16 + SkelAnime_InitFlex(play, &this->skelAnime, &object_rz_Skel_00D8D8, &gRosaSistersStandingAnim, + (uintptr_t)this->jointTable & ~0xF, (uintptr_t)this->morphTable & ~0xF, OBJECT_RZ_LIMB_MAX); + Animation_PlayLoop(&this->skelAnime, &gRosaSistersStandingAnim); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFB780.s") + Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit); + this->actor.colChkInfo.mass = MASS_IMMOVABLE; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFB864.s") + this->actionFunc = func_80BFC058; + EnRz_SetupPath(this, play); + this->animIndex = EN_RZ_ANIM_MAX; + this->actor.targetMode = 0; + this->actor.terminalVelocity = -9.0f; + this->actor.gravity = -1.0f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFB9E4.s") + switch (EN_RZ_GET_TYPE(thisx)) { + case EN_RZ_TYPE_1: + if (!(gSaveContext.save.weekEventReg[77] & 4)) { + Actor_Kill(&this->actor); + return; + } + EnRz_ChangeAnim(play, this, EN_RZ_ANIM_SITTING, ANIMMODE_LOOP, 0.0f); + this->actionFunc = func_80BFC674; + this->actor.shape.yOffset = -1500.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBA1C.s") + case EN_RZ_TYPE_2: + this->actor.flags |= ACTOR_FLAG_10; + if (gSaveContext.save.weekEventReg[77] & 4) { + EnRz_ChangeAnim(play, this, EN_RZ_ANIM_LINK_DANCE, ANIMMODE_LOOP, 0.0f); + } else { + EnRz_ChangeAnim(play, this, EN_RZ_ANIM_DANCE, ANIMMODE_LOOP, 0.0f); + } + this->actionFunc = func_80BFC3F8; + this->sister = EnRz_FindSister(this, play); + this->actor.uncullZoneForward = 300.0f; + break; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBA50.s") + default: // EN_RZ_TYPE_0 + this->stateFlags |= EN_RZ_STATE_2; + if (gSaveContext.save.weekEventReg[77] & 4) { + Actor_Kill(&this->actor); + return; + } + EnRz_ChangeAnim(play, this, EN_RZ_ANIM_WALKING, ANIMMODE_LOOP, 0.0f); + this->actionFunc = EnRz_Walk; + if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) { + this->actor.textId = 0x291C; + } else { // EN_RZ_MARILLA + this->actor.textId = 0x2920; + } + break; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBB44.s") + if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) { + this->csAction = 0x226; + } else { // EN_RZ_MARILLA + this->csAction = 0x227; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBC78.s") + this->actionIndex = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBCEC.s") +/** + * Custom shadow draw function of type ActorShadowFunc. + */ +void EnRz_ActorShadowFunc(Actor* thisx, Lights* mapper, PlayState* play) { + Vec3f oldPos; + EnRz* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBD54.s") + if (this->animIndex == EN_RZ_ANIM_LINK_DANCE) { + f32 tempScale = (((27.0f - this->shadowPos.y) + this->actor.world.pos.y) * ((1 / 2.25f) * 0.001f)) + 0.01f; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBDA0.s") + this->actor.scale.x = tempScale; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBDFC.s") + Math_Vec3f_Copy(&oldPos, &this->actor.world.pos); + Math_Vec3f_Copy(&this->actor.world.pos, &this->shadowPos); + func_800B4AEC(play, &this->actor, 50.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/EnRz_Destroy.s") + if (oldPos.y < this->actor.floorHeight) { + this->actor.world.pos.y = this->actor.floorHeight; + } else { + this->actor.world.pos.y = oldPos.y; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBE70.s") + ActorShadow_DrawCircle(&this->actor, mapper, play); + Math_Vec3f_Copy(&this->actor.world.pos, &oldPos); + this->actor.scale.x = 0.01f; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFBFAC.s") +void EnRz_ChangeAnim(PlayState* play, EnRz* this, s16 animIndex, u8 animMode, f32 morphFrames) { + // N.B. both of these arrays must be the same length due to how the animations are chosen + static AnimationHeader* sJudoAnimations[] = { + &gRosaSistersThinkingAnim, &gRosaSistersStandingAnim, &gRosaSistersWalkingWhileThinkingAnim, + &gRosaSistersSittingAnim, &gRosaSistersApplaudingAnim, &gRosaSistersOnKneesAnim, + &gRosaSistersDancingAnim, + }; + static AnimationHeader* sMarillaAnimations[] = { + &gRosaSistersStandingAnim, &gRosaSistersStandingAnim, &gRosaSistersWalkingAnim, &gRosaSistersSittingAnim, + &gRosaSistersApplaudingAnim, &gRosaSistersOnKneesAnim, &gRosaSistersDancingAnim, + }; + static LinkAnimationHeader* sLinkAnimations[] = { + &gPlayerAnim_link_normal_wait_free, + &gPlayerAnim_alink_dance_loop, + }; + f32 endFrame; + AnimationHeader** animationPtr; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC058.s") + if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) { + animationPtr = sJudoAnimations; + } else { // EN_RZ_MARILLA + animationPtr = sMarillaAnimations; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC078.s") + if ((animIndex >= EN_RZ_ANIM_THINKING) && (animIndex < EN_RZ_ANIM_MAX) && + ((animIndex != this->animIndex) || (animMode != ANIMMODE_LOOP))) { + if (animIndex >= ARRAY_COUNT(sJudoAnimations)) { + endFrame = Animation_GetLastFrame(sLinkAnimations[animIndex - ARRAY_COUNT(sJudoAnimations)]); + if (animMode == ANIMMODE_LOOP) { + LinkAnimation_Change(play, &this->skelAnime, sLinkAnimations[animIndex - ARRAY_COUNT(sJudoAnimations)], + 2.0f / 3.0f, 0.0f, endFrame, ANIMMODE_LOOP, morphFrames); + } else { + LinkAnimation_Change(play, &this->skelAnime, sLinkAnimations[animIndex - ARRAY_COUNT(sJudoAnimations)], + 2.0f / 3.0f, 0.0f, endFrame, ANIMMODE_LOOP, morphFrames); + } + } else { + Animation_Change(&this->skelAnime, animationPtr[animIndex], 1.0f, 0.0f, + Animation_GetLastFrame(animationPtr[animIndex]), animMode, morphFrames); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC19C.s") + this->animIndex = animIndex; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC214.s") +void func_80BFB9E4(PlayState* play, EnRz* this, s16 animIndex) { + EnRz_ChangeAnim(play, this, animIndex, ANIMMODE_LOOP, -5.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC270.s") +void func_80BFBA1C(PlayState* play, EnRz* this, s16 animIndex) { + EnRz_ChangeAnim(play, this, animIndex, ANIMMODE_LOOP, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC2F4.s") +s32 EnRz_SetupPath(EnRz* this, PlayState* play) { + if (EN_RZ_GET_PATH(&this->actor) != 0x3F) { + this->path = &play->setupPathList[EN_RZ_GET_PATH(&this->actor)]; + if (this->path != NULL) { + Path* path = this->path; + Vec3s* points = (Vec3s*)Lib_SegmentedToVirtual(path->points); + f32 diffX = points->x - this->actor.world.pos.x; + f32 diffY = points->z - this->actor.world.pos.z; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC36C.s") + if ((SQ(diffX) + SQ(diffY)) < SQ(10.0f)) { + this->curPointIndex = 0; + this->stateFlags &= ~EN_RZ_STATE_1; + } else { + this->curPointIndex = path->count - 1; + this->stateFlags |= EN_RZ_STATE_1; + return true; + } + } + } else { + this->path = NULL; + this->curPointIndex = 0; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC3F8.s") +EnRzPathStatus EnRz_GetPathStatus(EnRz* this) { + Path* path = this->path; + Vec3s* curPoint; + f32 diffX; + f32 diffZ; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC608.s") + if (path == NULL) { + return EN_RZ_PATHSTATUS_AT_POINT; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC674.s") + curPoint = &((Vec3s*)Lib_SegmentedToVirtual(path->points))[this->curPointIndex]; + diffX = curPoint->x - this->actor.world.pos.x; + diffZ = curPoint->z - this->actor.world.pos.z; + this->actor.world.rot.y = Math_Atan2S(diffX, diffZ); + Math_SmoothStepToS(&this->actor.shape.rot.y, this->actor.world.rot.y, 2, 0x07D0, 0xC8); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC728.s") + if ((SQ(diffX) + SQ(diffZ)) < SQ(10.0f)) { + if (this->stateFlags & EN_RZ_STATE_1) { + this->curPointIndex--; + if (this->curPointIndex < 0) { + return EN_RZ_PATHSTATUS_END; + } + } else { + this->curPointIndex++; + if (this->curPointIndex >= path->count) { + return EN_RZ_PATHSTATUS_END; + } + } + return EN_RZ_PATHSTATUS_AT_POINT; + } + return EN_RZ_PATHSTATUS_NORMAL; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC7E0.s") +s32 EnRz_CanTalk(EnRz* this, PlayState* play) { + if ((this->actor.xzDistToPlayer < 80.0f) && (fabsf(this->actor.playerHeightRel) < 20.0f) && + Player_IsFacingActor(&this->actor, 0x3000, play)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC8AC.s") +s32 func_80BFBCEC(EnRz* this, PlayState* play) { + s32 pad; + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFC8F8.s") + if ((this->actor.xzDistToPlayer < 100.0f) && Actor_IsFacingPlayer(&this->actor, 0x3000) && + (player->stateFlags2 & PLAYER_STATE2_2000000)) { + return true; + } + return false; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/EnRz_Update.s") +s32 EnRz_UpdateSkelAnime(EnRz* this, PlayState* play) { + if (this->animIndex < EN_RZ_ANIM_LINK_NORMAL_WAIT_FREE) { + return SkelAnime_Update(&this->skelAnime); + } else { + return LinkAnimation_Update(play, &this->skelAnime); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/func_80BFCAD0.s") +EnRz* EnRz_FindSister(EnRz* this, PlayState* play) { + Actor* npc = play->actorCtx.actorLists[ACTORCAT_NPC].first; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Rz/EnRz_Draw.s") + while (npc != NULL) { + if ((npc->id == ACTOR_EN_RZ) && (EN_RZ_GET_TYPE(&this->actor) == EN_RZ_GET_TYPE(npc))) { + if (&this->actor != npc) { + return (EnRz*)npc; + } + } + npc = npc->next; + } + return NULL; +} + +void func_80BFBDFC(PlayState* play) { + if (gSaveContext.save.weekEventReg[75] & 0x80) { + func_80151BB4(play, 0x27); + } + func_80151BB4(play, 0xC); +} + +void EnRz_Destroy(Actor* thisx, PlayState* play) { + EnRz* this = THIS; + + Collider_DestroyCylinder(play, &this->collider); +} + +s32 func_80BFBE70(EnRz* this, PlayState* play) { + u16 action; + + if ((EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) && (this->animIndex == EN_RZ_ANIM_APPLAUDING)) { + func_800B9010(&this->actor, NA_SE_EV_CLAPPING_2P - SFX_FLAG); + } + + if (Cutscene_CheckActorAction(play, this->csAction)) { + Cutscene_ActorTranslateAndYaw(&this->actor, play, Cutscene_GetActorActionIndex(play, this->csAction)); + action = play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, this->csAction)]->action; + if (this->actionIndex != action) { + this->actionIndex = action; + switch (this->actionIndex) { + case 1: + func_80BFBA1C(play, this, EN_RZ_ANIM_STANDING); + break; + + case 2: + func_80BFBA1C(play, this, EN_RZ_ANIM_ON_KNEES); + break; + + case 3: + func_80BFBA1C(play, this, EN_RZ_ANIM_APPLAUDING); + break; + + case 4: + func_80BFBA1C(play, this, EN_RZ_ANIM_LINK_DANCE); + break; + } + } + return true; + } + + return false; +} + +s32 func_80BFBFAC(EnRz* this, PlayState* play) { + if (this->actor.cutscene == -1) { + Message_StartTextbox(play, 0x2925, &this->actor); + this->actionFunc = func_80BFC078; + } else if (ActorCutscene_GetCurrentIndex() == 0x7C) { + ActorCutscene_Stop(0x7C); + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + return false; + } else if (ActorCutscene_GetCanPlayNext(this->actor.cutscene)) { + ActorCutscene_Start(this->actor.cutscene, &this->actor); + return true; + } else { + ActorCutscene_SetIntentToPlay(this->actor.cutscene); + } + return false; +} + +void func_80BFC058(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); +} + +void func_80BFC078(EnRz* this, PlayState* play) { + s32 pad; + Vec3f sp28; + + EnRz_UpdateSkelAnime(this, play); + + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + switch (play->msgCtx.currentTextId) { + case 0x2927: + case 0x2928: + func_80151938(play, play->msgCtx.currentTextId + 1); + gSaveContext.save.weekEventReg[77] |= 4; + break; + + default: + func_801477B4(play); + this->actionFunc = func_80BFC3F8; + if (this->animIndex != EN_RZ_ANIM_LINK_DANCE) { + func_80BFB9E4(play, this, EN_RZ_ANIM_DANCE); + if (this->sister != NULL) { + func_80BFB9E4(play, this->sister, EN_RZ_ANIM_DANCE); + } + } + break; + } + } + + if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) { + sp28.x = this->actor.projectedPos.x; + sp28.y = this->actor.projectedPos.y; + sp28.z = this->actor.projectedPos.z; + func_801A1FB4(3, &sp28, NA_BGM_ROSA_SISTERS, 900.0f); + } +} + +void func_80BFC19C(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + if (!func_80BFBE70(this, play)) { + this->actionFunc = func_80BFC3F8; + func_80BFBA1C(play, this, EN_RZ_ANIM_LINK_DANCE); + if (this->sister != NULL) { + func_80BFBA1C(play, this->sister, EN_RZ_ANIM_LINK_DANCE); + } + } +} + +void func_80BFC214(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + if (!func_80BFBE70(this, play) && func_80BFBFAC(this, play)) { + this->actionFunc = func_80BFC19C; + } +} + +void func_80BFC270(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + if (Actor_HasParent(&this->actor, play)) { + this->actor.parent = NULL; + this->actionFunc = func_80BFC214; + func_80BFBDFC(play); + } else { + Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 2000.0f, 1000.0f); + } +} + +void func_80BFC2F4(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + if (!func_80BFBE70(this, play)) { + func_801477B4(play); + Actor_PickUp(&this->actor, play, GI_HEART_PIECE, 2000.0f, 1000.0f); + this->actionFunc = func_80BFC270; + } +} + +void func_80BFC36C(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + if (func_80BFBFAC(this, play)) { + gSaveContext.save.weekEventReg[77] |= 4; + if (gSaveContext.save.weekEventReg[75] & 0x80) { + this->actionFunc = func_80BFC214; + } else { + this->actionFunc = func_80BFC2F4; + gSaveContext.save.weekEventReg[75] |= 0x80; + } + this->actor.cutscene = this->cutscenes[1]; + } +} + +void func_80BFC3F8(EnRz* this, PlayState* play) { + s32 pad; + Vec3f bgmPos; + + EnRz_UpdateSkelAnime(this, play); + + if (this->sister == NULL) { + this->sister = EnRz_FindSister(this, play); + } + + if (!func_80BFBE70(this, play)) { + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = func_80BFC078; + + if (CHECK_FLAG_ALL(this->actor.flags, ACTOR_FLAG_10000)) { + this->actionFunc = func_80BFC36C; + this->actor.cutscene = this->cutscenes[0]; + this->actor.flags &= ~ACTOR_FLAG_10000; + } else if (Player_GetMask(play) == PLAYER_MASK_KAMARO) { + if (gSaveContext.save.weekEventReg[77] & 4) { + Message_StartTextbox(play, 0x2925, &this->actor); + func_80BFBDFC(play); + } else { + Message_StartTextbox(play, 0x2926, &this->actor); + func_80BFBDFC(play); + } + } else { + Message_StartTextbox(play, 0x2926, &this->actor); + func_80BFBDFC(play); + } + + } else if (EnRz_CanTalk(this, play)) { + if (func_80BFBCEC(this, play) && !(gSaveContext.save.weekEventReg[77] & 4) && this->sister != NULL) { + this->actor.flags |= ACTOR_FLAG_10000; + func_800B8500(&this->actor, play, 1000.0f, 1000.0f, PLAYER_AP_MINUS1); + } else { + this->actor.flags &= ~ACTOR_FLAG_10000; + func_800B8614(&this->actor, play, 120.0f); + } + } + + if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) { + bgmPos.x = this->actor.projectedPos.x; + bgmPos.y = this->actor.projectedPos.y; + bgmPos.z = this->actor.projectedPos.z; + func_801A1FB4(3, &bgmPos, NA_BGM_ROSA_SISTERS, 900.0f); + } + } +} + +void func_80BFC608(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); + this->actionFunc = func_80BFC674; + } +} + +void func_80BFC674(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = func_80BFC608; + if (Player_GetMask(play) == PLAYER_MASK_KAMARO) { + Message_StartTextbox(play, 0x2925, &this->actor); + } else { + Message_StartTextbox(play, 0x2924, &this->actor); + } + } else if (EnRz_CanTalk(this, play)) { + func_800B8614(&this->actor, play, 120.0f); + } +} + +void func_80BFC728(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + + if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { + func_801477B4(play); + this->actionFunc = func_80BFC7E0; + this->actor.textId++; + if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) { + if (this->actor.textId >= 0x2920) { + this->actor.textId = 0x291C; + } + } else if (this->actor.textId >= 0x2924) { + this->actor.textId = 0x2920; + } + } +} + +void func_80BFC7E0(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + + if (this->timer > 0) { + this->timer--; + } else { + this->actionFunc = EnRz_Walk; + func_80BFB9E4(play, this, EN_RZ_ANIM_WALKING); + } + + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = func_80BFC728; + func_80BFB9E4(play, this, EN_RZ_ANIM_THINKING); + this->actor.speedXZ = 0.0f; + func_80BFBDFC(play); + } else if (EnRz_CanTalk(this, play)) { + func_800B8614(&this->actor, play, 120.0f); + } +} + +void EnRz_StopToThink(EnRz* this, PlayState* play) { + this->timer = 100; + this->actionFunc = func_80BFC7E0; + this->actor.speedXZ = 0.0f; + func_80BFB9E4(play, this, EN_RZ_ANIM_THINKING); +} + +void EnRz_Walk(EnRz* this, PlayState* play) { + EnRz_UpdateSkelAnime(this, play); + this->actor.speedXZ = 1.5f; + + switch (EnRz_GetPathStatus(this)) { + case EN_RZ_PATHSTATUS_END: + EnRz_SetupPath(this, play); + EnRz_StopToThink(this, play); + break; + + case EN_RZ_PATHSTATUS_AT_POINT: + EnRz_StopToThink(this, play); + break; + + default: + break; + } + + if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { + this->actionFunc = func_80BFC728; + func_80BFB9E4(play, this, EN_RZ_ANIM_THINKING); + this->actor.speedXZ = 0.0f; + func_80BFBDFC(play); + } else if (EnRz_CanTalk(this, play)) { + func_800B8614(&this->actor, play, 120.0f); + } +} + +void EnRz_Update(Actor* thisx, PlayState* play) { + s32 pad; + EnRz* this = THIS; + + Collider_UpdateCylinder(&this->actor, &this->collider); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); + Actor_MoveWithGravity(&this->actor); + Actor_UpdateBgCheckInfo(play, &this->actor, 40.0f, 25.0f, 40.0f, 5); + + this->actionFunc(this, play); + + if (DECR(this->blinkTimer) == 0) { + this->blinkTimer = Rand_S16Offset(60, 60); + } + + this->eyeIndex = this->blinkTimer; + if (this->eyeIndex > 2) { + this->eyeIndex = 0; + } +} + +void EnRz_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { + static Vec3f sFocusOffsetPos = { 500.0f, -500.0f, 0.0f }; + EnRz* this = THIS; + + if (limbIndex == OBJECT_RZ_LIMB_0B) { + Matrix_MultVec3f(&sFocusOffsetPos, &thisx->focus.pos); + } + if (limbIndex == OBJECT_RZ_LIMB_03) { + Matrix_MultVec3f(&gZeroVec3f, &this->shadowPos); + } +} + +void EnRz_Draw(Actor* thisx, PlayState* play) { + EnRz* this = THIS; + + OPEN_DISPS(play->state.gfxCtx); + + func_8012C28C(play->state.gfxCtx); + + if (EN_RZ_GET_SISTER(&this->actor) == EN_RZ_JUDO) { + AnimatedMat_DrawStepOpa(play, Lib_SegmentedToVirtual(&object_rz_Matanimheader_00D768), 0); + } else { // EN_RZ_MARILLA + AnimatedMat_DrawStepOpa(play, Lib_SegmentedToVirtual(&object_rz_Matanimheader_00D768), 1); + } + + if (this->animIndex == EN_RZ_ANIM_APPLAUDING) { + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[4])); + } else if (this->stateFlags & EN_RZ_STATE_2) { + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[3])); + } else { + gSPSegment(POLY_OPA_DISP++, 0x09, Lib_SegmentedToVirtual(sEyeTextures[this->eyeIndex])); + } + + SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, NULL, + EnRz_PostLimbDraw, &this->actor); + + CLOSE_DISPS(play->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_En_Rz/z_en_rz.h b/src/overlays/actors/ovl_En_Rz/z_en_rz.h index 299acf7d3..38a7088e8 100644 --- a/src/overlays/actors/ovl_En_Rz/z_en_rz.h +++ b/src/overlays/actors/ovl_En_Rz/z_en_rz.h @@ -2,6 +2,22 @@ #define Z_EN_RZ_H #include "global.h" +#include "assets/objects/object_rz/object_rz.h" + +#define EN_RZ_GET_SISTER(thisx) ((thisx)->params & 0x8000) +#define EN_RZ_GET_TYPE(thisx) ((thisx)->params & 0xF) +#define EN_RZ_GET_PATH(thisx) (((thisx)->params & 0x7E00) >> 9) + +typedef enum { + /* 0 */ EN_RZ_JUDO, // in red + /* 1 */ EN_RZ_MARILLA // in blue +} EnRzSister; + +typedef enum { + /* 0 */ EN_RZ_TYPE_0, + /* 1 */ EN_RZ_TYPE_1, + /* 2 */ EN_RZ_TYPE_2 +} EnRzType; struct EnRz; @@ -9,7 +25,24 @@ typedef void (*EnRzActionFunc)(struct EnRz*, PlayState*); typedef struct EnRz { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x2EC]; + /* 0x144 */ SkelAnime skelAnime; + /* 0x188 */ Vec3s jointTable[OBJECT_RZ_LIMB_MAX]; + /* 0x20C */ UNK_TYPE1 pad20C[0x94]; + /* 0x2A0 */ Vec3s morphTable[OBJECT_RZ_LIMB_MAX]; + /* 0x324 */ UNK_TYPE1 pad324[0x94]; + /* 0x3B8 */ Path* path; + /* 0x3BC */ s32 curPointIndex; + /* 0x3C0 */ ColliderCylinder collider; + /* 0x40C */ struct EnRz* sister; + /* 0x410 */ s16 eyeIndex; + /* 0x412 */ s16 blinkTimer; + /* 0x414 */ Vec3f shadowPos; + /* 0x420 */ u16 stateFlags; + /* 0x422 */ s16 animIndex; + /* 0x424 */ s16 timer; + /* 0x426 */ u16 csAction; + /* 0x428 */ u16 actionIndex; + /* 0x42A */ s16 cutscenes[2]; /* 0x430 */ EnRzActionFunc actionFunc; } EnRz; // size = 0x434 diff --git a/src/overlays/actors/ovl_En_Yb/z_en_yb.c b/src/overlays/actors/ovl_En_Yb/z_en_yb.c index a55a96afe..106b23926 100644 --- a/src/overlays/actors/ovl_En_Yb/z_en_yb.c +++ b/src/overlays/actors/ovl_En_Yb/z_en_yb.c @@ -84,7 +84,7 @@ void EnYb_Init(Actor* thisx, PlayState* play) { Actor_SetScale(&this->actor, 0.01f); ActorShape_Init(&this->actor.shape, 0.0f, EnYb_ActorShadowFunc, 20.0f); - // @Bug this alignment is because of player animations, but should be using ALIGN16 + // @bug this alignment is because of player animations, but should be using ALIGN16 SkelAnime_InitFlex(play, &this->skelAnime, &gYbSkeleton, &object_yb_Anim_000200, (uintptr_t)this->jointTable & ~0xF, (uintptr_t)this->morphTable & ~0xF, YB_LIMB_MAX); diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 7a1f13c3c..75317a3fb 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -16399,16 +16399,16 @@ 0x80BFB0E0:("EnYb_PostLimbDrawXlu",), 0x80BFB14C:("EnYb_Draw",), 0x80BFB480:("EnRz_Init",), - 0x80BFB780:("func_80BFB780",), - 0x80BFB864:("func_80BFB864",), + 0x80BFB780:("EnRz_ActorShadowFunc",), + 0x80BFB864:("EnRz_ChangeAnim",), 0x80BFB9E4:("func_80BFB9E4",), 0x80BFBA1C:("func_80BFBA1C",), - 0x80BFBA50:("func_80BFBA50",), - 0x80BFBB44:("func_80BFBB44",), - 0x80BFBC78:("func_80BFBC78",), + 0x80BFBA50:("EnRz_SetupPath",), + 0x80BFBB44:("EnRz_GetPathStatus",), + 0x80BFBC78:("EnRz_CanTalk",), 0x80BFBCEC:("func_80BFBCEC",), - 0x80BFBD54:("func_80BFBD54",), - 0x80BFBDA0:("func_80BFBDA0",), + 0x80BFBD54:("EnRz_UpdateSkelAnime",), + 0x80BFBDA0:("EnRz_FindSister",), 0x80BFBDFC:("func_80BFBDFC",), 0x80BFBE44:("EnRz_Destroy",), 0x80BFBE70:("func_80BFBE70",), @@ -16425,10 +16425,10 @@ 0x80BFC674:("func_80BFC674",), 0x80BFC728:("func_80BFC728",), 0x80BFC7E0:("func_80BFC7E0",), - 0x80BFC8AC:("func_80BFC8AC",), - 0x80BFC8F8:("func_80BFC8F8",), + 0x80BFC8AC:("EnRz_StopToThink",), + 0x80BFC8F8:("EnRz_Walk",), 0x80BFC9E4:("EnRz_Update",), - 0x80BFCAD0:("func_80BFCAD0",), + 0x80BFCAD0:("EnRz_PostLimbDraw",), 0x80BFCB3C:("EnRz_Draw",), 0x80BFCFA0:("EnScopecoin_Spin",), 0x80BFCFB8:("EnScopecoin_CheckCollectible",),