Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SeekyCt committed Sep 2, 2024
1 parent f99c67e commit 4fad84c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 26 deletions.
5 changes: 5 additions & 0 deletions spm-headers/include/nw4r/lyt/drawInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion spm-headers/include/nw4r/math/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,5 @@ struct MTX34 : public _MTX34
};
SIZE_ASSERT(MTX34, 0x30)


} // namespace math
} // namespace nw4r
22 changes: 11 additions & 11 deletions spm-headers/include/wii/mtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
46 changes: 32 additions & 14 deletions src/seq_title.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <msl/math.h>
#include <msl/new.h>
#include <nw4r/db/panic.h>
#include <nw4r/math/types.h>

extern "C" {

Expand Down Expand Up @@ -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]);
Expand All @@ -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);
}
Expand All @@ -269,6 +279,9 @@ const char * getNextDanMapname(s32 dungeonNo)
{
if (dungeonNo < 100)
{
// Fipside

// Enemy rooms
switch (dungeonNo)
{
case 9:
Expand All @@ -288,6 +301,7 @@ const char * getNextDanMapname(s32 dungeonNo)
return "dan_30";
}

// Chest rooms / boss
if (dungeonNo < 25)
return "dan_01";
if (dungeonNo < 49)
Expand All @@ -298,6 +312,9 @@ const char * getNextDanMapname(s32 dungeonNo)
}
else
{
// Flopside

// Chest rooms / boss
switch (dungeonNo - 100)
{
case 9:
Expand All @@ -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)
Expand Down

0 comments on commit 4fad84c

Please sign in to comment.