1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-02 22:14:33 +00:00

Document SkelCurve system (#1192)

* Rename and document SkelCurve

* AVOID_UB in DemoTreLgt_OverrideLimbDraw

* Rename code_8006C510

* Objdump flags in the makefile

* Move CC_CHECK above compilation

* Review 1

* Review 2

* Review 3

* Review
Add doxygen comments to file head
use angle macro,
improve bug comment,
make arguments of SkelCurve_Draw more consistent,
Change this temp to pad in MagicWind
This commit is contained in:
EllipticEllipsis 2022-05-20 07:27:54 +01:00 committed by GitHub
parent 0584b3d288
commit 0e51a51fb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 342 additions and 213 deletions

View file

@ -2043,7 +2043,7 @@ void DemoEffect_DrawGetItem(Actor* thisx, GlobalContext* globalCtx) {
/**
* Callback for the SkelCurve system to draw the animated limbs.
*/
s32 DemoEffect_DrawTimewarpLimbs(GlobalContext* globalCtx, SkelAnimeCurve* skelCuve, s32 limbIndex, void* thisx) {
s32 DemoEffect_OverrideLimbDrawTimeWarp(GlobalContext* globalCtx, SkelCurve* skelCurve, s32 limbIndex, void* thisx) {
s32 pad;
DemoEffect* this = (DemoEffect*)thisx;
u32 frames = globalCtx->gameplayFrames;
@ -2058,13 +2058,13 @@ s32 DemoEffect_DrawTimewarpLimbs(GlobalContext* globalCtx, SkelAnimeCurve* skelC
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_effect.c", 3172);
if (limbIndex == 0) {
LimbTransform* transform = &skelCuve->transforms[0];
s16* transform = skelCurve->jointTable[0];
transform->scale.y = 1024;
transform->scale.z = transform->scale.x = 1024;
transform[2] = transform[0] = 1024;
transform[1] = 1024;
}
return 1;
return true;
}
/**
@ -2079,9 +2079,11 @@ void DemoEffect_DrawTimeWarp(Actor* thisx, GlobalContext* globalCtx) {
Flags_GetEnv(globalCtx, 1) || gSaveContext.sceneSetupIndex >= 4 ||
gSaveContext.entranceIndex == ENTR_TOKINOMA_4) {
OPEN_DISPS(gfxCtx, "../z_demo_effect.c", 3201);
POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 25);
Matrix_Scale(2.0f, 2.0f, 2.0f, MTXMODE_APPLY);
SkelCurve_Draw(thisx, globalCtx, &this->skelCurve, DemoEffect_DrawTimewarpLimbs, NULL, 1, this);
SkelCurve_Draw(&this->actor, globalCtx, &this->skelCurve, DemoEffect_OverrideLimbDrawTimeWarp, NULL, 1, &this->actor);
CLOSE_DISPS(gfxCtx, "../z_demo_effect.c", 3216);
}
}

View file

@ -78,7 +78,7 @@ typedef struct {
typedef struct DemoEffect {
/* 0x0000 */ Actor actor;
/* 0x014C */ SkelAnimeCurve skelCurve;
/* 0x014C */ SkelCurve skelCurve;
/* 0x016C */ u8 initObjectBankIndex;
/* 0x0170 */ Gfx* jewelDisplayList;
/* 0x0174 */ Gfx* jewelHolderDisplayList;

View file

@ -38,7 +38,7 @@ const ActorInit Demo_Tre_Lgt_InitVars = {
(ActorFunc)DemoTreLgt_Draw,
};
static TransformUpdateIndex* sTransformUpdIdx[] = { &gTreasureChestCurveAnim_4B60, &gTreasureChestCurveAnim_4F70 };
static CurveAnimationHeader* sAnimations[] = { &gTreasureChestCurveAnim_4B60, &gTreasureChestCurveAnim_4F70 };
static DemoTreLgtActionFunc sActionFuncs[] = {
func_8099375C,
@ -48,7 +48,7 @@ static DemoTreLgtActionFunc sActionFuncs[] = {
void DemoTreLgt_Init(Actor* thisx, GlobalContext* globalCtx) {
DemoTreLgt* this = (DemoTreLgt*)thisx;
if (!SkelCurve_Init(globalCtx, &this->skelCurve, &gTreasureChestCurveSkel, sTransformUpdIdx[0])) {
if (!SkelCurve_Init(globalCtx, &this->skelCurve, &gTreasureChestCurveSkel, sAnimations[0])) {
// "Demo_Tre_Lgt_Actor_ct (); Construct failed"
osSyncPrintf("Demo_Tre_Lgt_Actor_ct();コンストラクト失敗\n");
}
@ -74,25 +74,25 @@ void func_80993754(DemoTreLgt* this) {
void func_8099375C(DemoTreLgt* this, GlobalContext* globalCtx) {
EnBox* treasureChest = (EnBox*)this->actor.parent;
if (treasureChest != NULL && Animation_OnFrame(&treasureChest->skelanime, 10.0f)) {
if ((treasureChest != NULL) && Animation_OnFrame(&treasureChest->skelanime, 10.0f)) {
func_809937B4(this, globalCtx, treasureChest->skelanime.curFrame);
}
}
void func_809937B4(DemoTreLgt* this, GlobalContext* globalCtx, f32 currentFrame) {
SkelAnimeCurve* skelCurve = &this->skelCurve;
SkelCurve* skelCurve = &this->skelCurve;
s32 pad[2];
this->action = DEMO_TRE_LGT_ACTION_ANIMATE;
SkelCurve_SetAnim(skelCurve, sTransformUpdIdx[gSaveContext.linkAge], 1.0f,
SkelCurve_SetAnim(skelCurve, sAnimations[gSaveContext.linkAge], 1.0f,
sDemoTreLgtInfo[gSaveContext.linkAge].endFrame + sDemoTreLgtInfo[gSaveContext.linkAge].unk_08,
currentFrame, 1.0f);
SkelCurve_Update(globalCtx, skelCurve);
}
void func_80993848(DemoTreLgt* this, GlobalContext* globalCtx) {
f32 currentFrame = this->skelCurve.animCurFrame;
f32 currentFrame = this->skelCurve.curFrame;
if (currentFrame < sDemoTreLgtInfo[((void)0, gSaveContext.linkAge)].endFrame) {
this->unk_170 = 255;
@ -131,7 +131,7 @@ void DemoTreLgt_Update(Actor* thisx, GlobalContext* globalCtx) {
sActionFuncs[this->action](this, globalCtx);
}
s32 DemoTreLgt_OverrideLimbDraw(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, s32 limbIndex, void* thisx) {
s32 DemoTreLgt_OverrideLimbDraw(GlobalContext* globalCtx, SkelCurve* skelCurve, s32 limbIndex, void* thisx) {
s32 pad;
DemoTreLgt* this = (DemoTreLgt*)thisx;
@ -149,9 +149,14 @@ s32 DemoTreLgt_OverrideLimbDraw(GlobalContext* globalCtx, SkelAnimeCurve* skelCu
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_demo_tre_lgt.c", 448);
//! @bug missing return
// If the return value ends up being false (0), the limb won't draw (meaning no limb at all will draw).
// In MQ Debug, `Graph_CloseDisps` has the last instruction writing to v0 before this function ends.
// That instruction sets v0 to a non-NULL pointer, which is "true", so the limbs get drawn.
//! If the returned value (i.e. the contents of v0) ends up being false (0), the limb won't draw. Therefore what
//! matters is what was last written to v0 before the end of the function.
//! - In debug versions, the last instruction that does this is in `Graph_CloseDisps`.
//! - In retail versions, `gDPSetPrimColor` writes to it last.
//! In both cases, that instruction sets v0 to a non-NULL pointer, which is "true", so the limb happens to be drawn.
#ifdef AVOID_UB
return true;
#endif
}
void DemoTreLgt_Draw(Actor* thisx, GlobalContext* globalCtx) {
@ -166,7 +171,7 @@ void DemoTreLgt_Draw(Actor* thisx, GlobalContext* globalCtx) {
func_80093D84(gfxCtx);
gDPSetEnvColor(POLY_XLU_DISP++, 200, 255, 0, 0);
SkelCurve_Draw(&this->actor, globalCtx, &this->skelCurve, DemoTreLgt_OverrideLimbDraw, NULL, 1, thisx);
SkelCurve_Draw(&this->actor, globalCtx, &this->skelCurve, DemoTreLgt_OverrideLimbDraw, NULL, 1, &this->actor);
CLOSE_DISPS(gfxCtx, "../z_demo_tre_lgt.c", 476);
}

View file

@ -10,7 +10,7 @@ typedef void (*DemoTreLgtActionFunc)(struct DemoTreLgt*, GlobalContext*);
typedef struct DemoTreLgt {
/* 0x0000 */ Actor actor;
/* 0x014C */ SkelAnimeCurve skelCurve;
/* 0x014C */ SkelCurve skelCurve;
/* 0x016C */ s32 action;
/* 0x0170 */ u32 unk_170; // some sort of alpha
/* 0x0174 */ u32 unk_174; // another sort of alpha

View file

@ -45,7 +45,7 @@ void MagicWind_Init(Actor* thisx, GlobalContext* globalCtx) {
MagicWind* this = (MagicWind*)thisx;
Player* player = GET_PLAYER(globalCtx);
if (SkelCurve_Init(globalCtx, &this->skelCurve, &sSkel, &sAnim) == 0) {
if (!SkelCurve_Init(globalCtx, &this->skelCurve, &sSkel, &sAnim)) {
// "Magic_Wind_Actor_ct (): Construct failed"
osSyncPrintf("Magic_Wind_Actor_ct():コンストラクト失敗\n");
}
@ -140,8 +140,8 @@ void MagicWind_Update(Actor* thisx, GlobalContext* globalCtx) {
this->actionFunc(this, globalCtx);
}
s32 MagicWind_OverrideLimbDraw(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, s32 limbIndex, void* thisx) {
MagicWind* this = (MagicWind*)thisx;
s32 MagicWind_OverrideLimbDraw(GlobalContext* globalCtx, SkelCurve* skelCurve, s32 limbIndex, void* thisx) {
s32 pad;
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_magic_wind.c", 615);
@ -173,7 +173,7 @@ void MagicWind_Draw(Actor* thisx, GlobalContext* globalCtx) {
if (this->actionFunc != MagicWind_WaitForTimer) {
POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 25);
SkelCurve_Draw(thisx, globalCtx, &this->skelCurve, MagicWind_OverrideLimbDraw, NULL, 1, NULL);
SkelCurve_Draw(&this->actor, globalCtx, &this->skelCurve, MagicWind_OverrideLimbDraw, NULL, 1, NULL);
}
CLOSE_DISPS(gfxCtx, "../z_magic_wind.c", 673);

View file

@ -10,7 +10,7 @@ typedef void (*MagicWindFunc)(struct MagicWind* this, GlobalContext* globalCtx);
typedef struct MagicWind {
/* 0x0000 */ Actor actor;
/* 0x014C */ SkelAnimeCurve skelCurve;
/* 0x014C */ SkelCurve skelCurve;
/* 0x016C */ s16 timer;
/* 0x0170 */ MagicWindFunc actionFunc;
} MagicWind; // size = 0x0174