From 4fad84c0ed72906fb0e0873bf3e3ced88b410485 Mon Sep 17 00:00:00 2001 From: Seeky <58006653+SeekyCt@users.noreply.github.com> Date: Mon, 2 Sep 2024 23:46:22 +0100 Subject: [PATCH] More cleanup --- spm-headers/include/nw4r/lyt/drawInfo.h | 5 +++ spm-headers/include/nw4r/math/types.h | 1 - spm-headers/include/wii/mtx.h | 22 ++++++------ src/seq_title.c | 46 +++++++++++++++++-------- 4 files changed, 48 insertions(+), 26 deletions(-) diff --git a/spm-headers/include/nw4r/lyt/drawInfo.h b/spm-headers/include/nw4r/lyt/drawInfo.h index 2397d7a..d0ea65f 100644 --- a/spm-headers/include/nw4r/lyt/drawInfo.h +++ b/spm-headers/include/nw4r/lyt/drawInfo.h @@ -13,6 +13,11 @@ class DrawInfo virtual ~DrawInfo(); DrawInfo(); + void SetViewMtx(const struct math::MTX34 & mtx) + { + mViewMtx = mtx; + } + math::MTX34 mViewMtx; ut::Rect mViewRect; math::VEC2 mLocationAdjustScale; diff --git a/spm-headers/include/nw4r/math/types.h b/spm-headers/include/nw4r/math/types.h index 7498e48..47d88f9 100644 --- a/spm-headers/include/nw4r/math/types.h +++ b/spm-headers/include/nw4r/math/types.h @@ -87,6 +87,5 @@ struct MTX34 : public _MTX34 }; SIZE_ASSERT(MTX34, 0x30) - } // namespace math } // namespace nw4r diff --git a/spm-headers/include/wii/mtx.h b/spm-headers/include/wii/mtx.h index d00a2af..f0a067c 100644 --- a/spm-headers/include/wii/mtx.h +++ b/spm-headers/include/wii/mtx.h @@ -34,7 +34,7 @@ typedef f32 Mtx34[3][4]; typedef f32 Mtx44[4][4]; void PSMTXIdentity(Mtx34 dest); -void PSMTXCopy(Mtx34 src, Mtx34 dest); +void PSMTXCopy(const Mtx34 src, Mtx34 dest); UNKNOWN_FUNCTION(PSMTXConcat); UNKNOWN_FUNCTION(PSMTXInverse); UNKNOWN_FUNCTION(PSMTXInvXpose); @@ -43,9 +43,9 @@ UNKNOWN_FUNCTION(PSMTXRotTrig); UNKNOWN_FUNCTION(__PSMTXRotAxisRadInternal); UNKNOWN_FUNCTION(PSMTXRotAxisRad); void PSMTXTrans(Mtx34 dest, f32 x, f32 y, f32 z); -void PSMTXTransApply(Mtx34 src, Mtx34 dest, f32 x, f32 y, f32 z); +void PSMTXTransApply(const Mtx34 src, Mtx34 dest, f32 x, f32 y, f32 z); void PSMTXScale(Mtx34 dest, f32 x, f32 y, f32 z); -void PSMTXScaleApply(Mtx34 src, Mtx34 dest, f32 x, f32 y, f32 z); +void PSMTXScaleApply(const Mtx34 src, Mtx34 dest, f32 x, f32 y, f32 z); UNKNOWN_FUNCTION(PSMTXQuat); UNKNOWN_FUNCTION(C_MTXLookAt); UNKNOWN_FUNCTION(C_MTXLightFrustum); @@ -56,18 +56,18 @@ UNKNOWN_FUNCTION(PSMTXMultVecArray); UNKNOWN_FUNCTION(PSMTXMultVecSR); UNKNOWN_FUNCTION(C_MTXFrustum); UNKNOWN_FUNCTION(C_MTXPerspective); -void C_MTXOrtho(Mtx44 * dest, f32 top, f32 bottom, f32 left, f32 right, f32 near, f32 far); +void C_MTXOrtho(Mtx44 dest, f32 top, f32 bottom, f32 left, f32 right, f32 near, f32 far); UNKNOWN_FUNCTION(PSMTX44Copy); UNKNOWN_FUNCTION(PSMTX44MultVec); UNKNOWN_FUNCTION(PSMTX44MultVecArray); UNKNOWN_FUNCTION(PSVECAdd); -void PSVECSubtract(Vec3 * src1, Vec3 * src2, Vec3 * dest); -void PSVECScale(Vec3 * src, Vec3 * dest, f32 scale); -void PSVECNormalize(Vec3 * src, Vec3 * dest); -f32 PSVecSquareMag(Vec3 * src); -f32 PSVecMag(Vec3 * src); -f32 PSVECDotProduct(Vec3 * src1, Vec3 * src2); -void PSVECCrossProduct(Vec3 * src1, Vec3 * src2, Vec3 * dest); +void PSVECSubtract(const Vec3 * src1, const Vec3 * src2, Vec3 * dest); +void PSVECScale(const Vec3 * src, Vec3 * dest, f32 scale); +void PSVECNormalize(const Vec3 * src, Vec3 * dest); +f32 PSVecSquareMag(const Vec3 * src); +f32 PSVecMag(const Vec3 * src); +f32 PSVECDotProduct(const Vec3 * src1, const Vec3 * src2); +void PSVECCrossProduct(const Vec3 * src1, const Vec3 * src2, Vec3 * dest); UNKNOWN_FUNCTION(VECHalfAngle); UNKNOWN_FUNCTION(VECReflect); UNKNOWN_FUNCTION(PSVECSquareDistance); diff --git a/src/seq_title.c b/src/seq_title.c index 28e6626..4d63cad 100644 --- a/src/seq_title.c +++ b/src/seq_title.c @@ -17,6 +17,7 @@ #include #include #include +#include extern "C" { @@ -221,33 +222,41 @@ void seqTitleInitLayout() void seqTitleDisp() { - // TODO: nw4r inlines + // Setup draw info nw4r::math::MTX34 viewMtx; PSMTXCopy(camGetCurPtr()->viewMtx, viewMtx); nw4r::math::VEC3 scale(0.95f, 1.0f, 1.0f); PSMTXScaleApply(viewMtx, viewMtx, scale.x, scale.y, scale.z); - wp->drawInfo.mViewMtx = viewMtx; + wp->drawInfo.SetViewMtx(viewMtx); wp->drawInfo.mViewRect = wp->layout->GetLayoutRect(); + + // Update layout wp->layout->Animate(0); wp->layout->CalculateMtx(wp->drawInfo); - f32 temp = (wp->animFrame / wp->animations[wp->animNum]->GetFrameSize()); - f32 unk = cosf(temp * PIx2 * 8.0f); - s32 unk2 = (s32) (255.0f - ((unk * 256.0f) + 128.0f)); - if (unk2 > 0xff) - unk2 = 0xff; - if (unk2 < 0) - unk2 = 0; + + // Update alpha + f32 animProgress = (wp->animFrame / wp->animations[wp->animNum]->GetFrameSize()); + f32 cosProgress = cosf(animProgress * PIx2 * 8.0f); + s32 alpha = (s32) (255.0f - ((cosProgress * 256.0f) + 128.0f)); + if (alpha > 0xff) + alpha = 0xff; + if (alpha < 0) + alpha = 0; if (wp->animNum == 0) - unk2 = 0; - wp->pushu2Pane->mAlpha = (u8) unk2; - GXColorS10 col = {0, 0, 0, (s16) unk2}; + alpha = 0; + wp->pushu2Pane->mAlpha = (u8) alpha; + GXColorS10 col = {0, 0, 0, (s16) alpha}; nw4r::lyt::Material * material = wp->pushuBotanPane->GetMaterial(); material->mTevCols[1] = col; + + // Render wp->layout->Draw(wp->drawInfo); - wp->animFrame += 60.0f / gp->fps; + // Update animation progress + wp->animFrame += 60.0f / gp->fps; while (wp->animFrame >= wp->animations[wp->animNum]->GetFrameSize()) { + // If 0, move on to next animation if (wp->animNum == 0) { wp->layout->UnbindAnimation(wp->animations[wp->animNum]); @@ -259,8 +268,9 @@ void seqTitleDisp() wp->animFrame -= (float) wp->animations[wp->animNum]->GetFrameSize(); } - wp->animations[wp->animNum]->mFrame = wp->animFrame; + + // Set projection matrix (restoring for other disp functions?) CamEntry * cam = camGetCurPtr(); GXSetProjection(cam->projMtx, cam->projectionType); } @@ -269,6 +279,9 @@ const char * getNextDanMapname(s32 dungeonNo) { if (dungeonNo < 100) { + // Fipside + + // Enemy rooms switch (dungeonNo) { case 9: @@ -288,6 +301,7 @@ const char * getNextDanMapname(s32 dungeonNo) return "dan_30"; } + // Chest rooms / boss if (dungeonNo < 25) return "dan_01"; if (dungeonNo < 49) @@ -298,6 +312,9 @@ const char * getNextDanMapname(s32 dungeonNo) } else { + // Flopside + + // Chest rooms / boss switch (dungeonNo - 100) { case 9: @@ -317,6 +334,7 @@ const char * getNextDanMapname(s32 dungeonNo) return "dan_70"; } + // Enemy rooms if (dungeonNo - 100 < 25) return "dan_41"; if (dungeonNo - 100 < 49)