diff --git a/src/SB/Game/zAssetTypes.cpp b/src/SB/Game/zAssetTypes.cpp index 44186f3ce..0841ae140 100644 --- a/src/SB/Game/zAssetTypes.cpp +++ b/src/SB/Game/zAssetTypes.cpp @@ -73,3 +73,10 @@ U8 dummyEffectCB(U32, xAnimActiveEffect*, xAnimSingle*, void*) { return 0; } + + +U32 xSndPlay3D(U32 id, F32 vol, F32 pitch, U32 priority, U32 flags, + xEnt* ent, F32 radius, sound_category category, F32 delay) +{ + return xSndPlay3D(id, vol, pitch, priority, flags, ent, radius / 4.0f, radius, category, delay); +} diff --git a/src/SB/Game/zAssetTypes.h b/src/SB/Game/zAssetTypes.h index 091718d3c..022e676db 100644 --- a/src/SB/Game/zAssetTypes.h +++ b/src/SB/Game/zAssetTypes.h @@ -4,6 +4,7 @@ #include #include #include +#include "xSnd.h" #include "xJSP.h" @@ -16,4 +17,7 @@ struct RwMemory void FootstepHackSceneEnter(); void jsp_shadow_hack(xJSPHeader* param_1); +U32 xSndPlay3D(U32 id, F32 vol, F32 pitch, U32 priority, U32 flags, xEnt* pos, F32 radius, + sound_category category, F32 delay); + #endif diff --git a/src/SB/Game/zEnt.cpp b/src/SB/Game/zEnt.cpp index f97a79e98..c73543b60 100644 --- a/src/SB/Game/zEnt.cpp +++ b/src/SB/Game/zEnt.cpp @@ -925,9 +925,7 @@ xMat4x3* xEntGetFrame(const xEnt* ent) void xSndPlay3D(U32 id, F32 vol, F32 pitch, U32 priority, U32 flags, const xVec3* pos, F32 radius, sound_category category, F32 delay) { - // This is UB to assign radius in the function call like this, but the assembly matches a *= - // so maybe HI made a mistake here. - xSndPlay3D(id, vol, pitch, priority, flags, pos, radius *= 0.25f, radius, category, delay); + xSndPlay3D(id, vol, pitch, priority, flags, pos, radius / 4.0f, radius, category, delay); } S32 xNPCBasic::SelfType() const diff --git a/src/SB/Game/zLasso.cpp b/src/SB/Game/zLasso.cpp index f118774b4..91c3ad39c 100644 --- a/src/SB/Game/zLasso.cpp +++ b/src/SB/Game/zLasso.cpp @@ -4,6 +4,15 @@ #include +static u32 sLassoRaster; +static u32 sNumGuideLists; +static zLassoGuide* sCurrentGuide; +static void* lnverts; + +static zLassoGuideList sGuideList[64]; + +static s32 negativeHondaX = 1; + void zLasso_InitTimer(zLasso* lasso, F32 interpTime) { lasso->secsTotal = interpTime; @@ -35,4 +44,116 @@ void zLasso_InitTimer(zLasso* lasso, F32 interpTime) lasso->reindex[2] = 2; lasso->reindex[3] = 3; lasso->reindex[4] = 4; -} \ No newline at end of file +} + +void zLasso_ResetTimer(zLasso* lasso, F32 interpTime) +{ + f32 temp_f0; + f32 temp_f0_2; + + lasso->secsTotal = interpTime; + lasso->secsLeft = interpTime; + temp_f0 = lasso->crRadius; + lasso->stRadius = temp_f0; + lasso->tgRadius = temp_f0; + temp_f0_2 = lasso->crSlack; + lasso->stSlack = temp_f0_2; + lasso->tgSlack = temp_f0_2; + xVec3Copy(&lasso->stNormal, &lasso->crNormal); + xVec3Copy(&lasso->tgNormal, &lasso->crNormal); + xVec3Add(&lasso->stCenter, &lasso->crCenter, &lasso->anchor); +} + +void fizzicalRadius(zLasso* lasso, f32 arg1, xVec3* arg2) +{ + lasso->crRadius = -((2.0f * (0.75f - lasso->crSlack) * arg1) - lasso->crRadius); + if (lasso->crRadius < 0.0f) + { + lasso->crRadius = 0.0f; + } +} + +void fizzicalCenter(zLasso* lasso, f32 arg1, xVec3* arg2) +{ + xVec3AddScaled(&lasso->crCenter, &lasso->lastRefs[lasso->reindex[4]], -0.2f); + xVec3AddScaled(&lasso->crCenter, arg2, 0.2f); +} + +void fizzicalNormal(zLasso* lasso, f32 arg1, xVec3* arg2) +{ + xVec3 sp8; + f32 temp_f31; + + xVec3Sub(&sp8, &lasso->lastRefs[lasso->reindex[0]], &lasso->lastRefs[lasso->reindex[1]]); + temp_f31 = xVec3Dot(&lasso->crNormal, &sp8); + xVec3AddScaled(&lasso->crNormal, &sp8, 1.1f * (-temp_f31 / xVec3Length(&sp8))); + xVec3Normalize(&lasso->crNormal, &lasso->crNormal); +} + +void fizzicalHonda(zLasso* lasso, f32 arg1, xVec3* arg2) +{ + xVec3* temp_r3; + + xVec3SMul(&lasso->honda, arg2, -1.0f); + xVec3AddScaled(&lasso->honda, &lasso->lastRefs[lasso->reindex[0]], 0.571429f); + xVec3AddScaled(&lasso->honda, &lasso->lastRefs[lasso->reindex[1]], 0.285714f); + xVec3AddScaled(&lasso->honda, &lasso->lastRefs[lasso->reindex[2]], 0.142857f); + xVec3AddScaled(&lasso->honda, &lasso->crNormal, -xVec3Dot(&lasso->crNormal, &lasso->honda)); + temp_r3 = &lasso->honda; + xVec3Normalize(temp_r3, temp_r3); + xVec3SMulBy(&lasso->honda, lasso->crRadius); + if (((s32)negativeHondaX != 0) && (lasso->honda.x > 0.0f)) + { + xSndPlay3D(xStrHash(&"rope\0sound_rope_windup"[5]), 0.77f, 0.0f, 0U, 0x10000U, + &lasso->anchor, 100.0f, (sound_category)0, 0.0f); + negativeHondaX = 0; + } + if (lasso->honda.x < 0.0f) + { + negativeHondaX = 1; + } + xVec3AddTo(&lasso->honda, &lasso->crCenter); +} + +void nonfizzicalHonda(zLasso* lasso, f32 arg1, xVec3* arg2) +{ + f32 temp_f1; + + xVec3Sub(&lasso->honda, arg2, &lasso->crCenter); + xVec3AddScaled(&lasso->honda, &lasso->crNormal, -xVec3Dot(&lasso->honda, &lasso->crNormal)); + temp_f1 = xVec3Length2(&lasso->honda); + if (temp_f1 < 0.00001f) + { + lasso->honda.x = lasso->crNormal.y; + lasso->honda.y = -lasso->crNormal.x; + lasso->honda.z = 0.0f; + xVec3SMulBy(&lasso->honda, lasso->crRadius / xsqrt(xVec3Length2(&lasso->honda))); + xVec3AddTo(&lasso->honda, &lasso->crCenter); + return; + } + xVec3SMulBy(&lasso->honda, lasso->crRadius / xsqrt(temp_f1)); + xVec3AddTo(&lasso->honda, &lasso->crCenter); +} + +void fizzicalSlack(zLasso* lasso, f32 arg1, xVec3* arg2) +{ + f32 temp_f1; + + lasso->crSlack += (2.0f * (lasso->lastDist - lasso->currDist)) - (0.6f * arg1); + temp_f1 = lasso->crSlack; + if (temp_f1 < 0.0f) + { + lasso->crSlack = 0.0f; + return; + } + if (temp_f1 > 1.0f) + { + lasso->crSlack = 1.0f; + } +} + +void zLasso_scenePrepare() +{ + sNumGuideLists = 0; + sCurrentGuide = NULL; +} diff --git a/src/SB/Game/zLasso.h b/src/SB/Game/zLasso.h index 78647a84b..f307d4311 100644 --- a/src/SB/Game/zLasso.h +++ b/src/SB/Game/zLasso.h @@ -3,6 +3,8 @@ #include "xMath3.h" #include "xModel.h" +#include "xString.h" +#include "zEnt.h" struct zLasso { @@ -10,14 +12,14 @@ struct zLasso F32 secsTotal; F32 secsLeft; F32 stRadius; - F32 tgRadius; + F32 tgRadius; // 0x10 F32 crRadius; - xVec3 stCenter; - xVec3 tgCenter; - xVec3 crCenter; - xVec3 stNormal; + xVec3 stCenter; // 0x18 + xVec3 tgCenter; // 0x24 + xVec3 crCenter; // 0x30 + xVec3 stNormal; // 0x3C xVec3 tgNormal; - xVec3 crNormal; + xVec3 crNormal; // 0x48 xVec3 honda; F32 stSlack; F32 stSlackDist; @@ -33,9 +35,24 @@ struct zLasso xModelInstance* model; }; +struct zLassoGuide +{ + xModelInstance* poly; + xAnimState* lassoAnim; + S32 vertMap[16]; +}; + +struct zLassoGuideList // Size: 0xE0 +{ + xEnt* target; + U32 numGuides; + zLassoGuide guide[3]; +}; + void zLasso_scenePrepare(); void zLasso_InitTimer(zLasso* lasso, F32 interpTime); void zLasso_ResetTimer(zLasso* lasso, F32 interpTime); +void zLasso_AddGuide(xEnt* ent, xAnimState* lassoAnim, xModelInstance modelInst); void zLasso_SetGuide(xEnt* ent, xAnimState* lassoAnim); void zLasso_InterpToGuide(zLasso* lasso);