1
0
mirror of https://github.com/zeldaret/oot.git synced 2024-09-22 21:35:27 +00:00
oot/src/code/z_skelanime.c

1761 lines
65 KiB
C
Raw Normal View History

2020-03-17 04:31:30 +00:00
#include <ultra64.h>
#include <global.h>
#include <vt.h>
2020-03-17 04:31:30 +00:00
s32 func_800A3D70(GlobalContext*, SkelAnime*);
s32 func_800A3E0C(GlobalContext*, SkelAnime*);
2020-03-20 21:12:26 +00:00
s32 func_800A4D9C(SkelAnime* skelAnime);
s32 func_800A4EE0(SkelAnime* skelAnime);
s32 func_800A4E38(SkelAnime* skelAnime);
void SkelAnime_CopyVec3s(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src);
void SkelAnime_LinkAnimetionLoaded(GlobalContext* globalCtx, AnimationEntryType0* entry);
void SkelAnime_AnimationType1Loaded(GlobalContext* globalCtx, AnimationEntryType1* entry);
void SkelAnime_AnimationType2Loaded(GlobalContext* globalCtx, AnimationEntryType2* entry);
void SkelAnime_AnimationType3Loaded(GlobalContext* globalCtx, AnimationEntryType3* entry);
void SkelAnime_AnimationType4Loaded(GlobalContext* globalCtx, AnimationEntryType4* entry);
void SkelAnime_AnimationType5Loaded(GlobalContext* globalCtx, AnimationEntryType5* entry);
2020-03-31 23:29:09 +00:00
// .data
2020-03-23 01:24:00 +00:00
u32 D_8012A480 = 0;
2020-03-25 19:44:42 +00:00
static AnimationEntryCallback sAnimationLoadDone[] = {
2020-03-25 16:07:09 +00:00
&SkelAnime_LinkAnimetionLoaded, &SkelAnime_AnimationType1Loaded, &SkelAnime_AnimationType2Loaded,
&SkelAnime_AnimationType3Loaded, &SkelAnime_AnimationType4Loaded, &SkelAnime_AnimationType5Loaded,
2020-03-20 21:12:26 +00:00
};
// .bss
2020-03-20 21:12:26 +00:00
u32 D_801600B0;
2020-03-30 22:53:26 +00:00
/*
* Draws the limb at `limbIndex` with a level of detail display lists index by `dListIndex`
*/
void SkelAnime_LodDrawLimb(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skeleton, Vec3s* actorDrawTable,
SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc,
Actor* actor, s32 dListIndex) {
2020-03-20 21:12:26 +00:00
SkelLimbEntry* limbEntry;
Gfx* dList;
2020-03-21 02:51:12 +00:00
Vec3f pos;
Vec3s rot;
GraphicsContext* gfxCtx;
Gfx* dispRefs[4];
2020-03-20 21:12:26 +00:00
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_skelanime.c", 773);
2020-03-20 21:12:26 +00:00
Matrix_Push();
limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[limbIndex]);
2020-03-20 21:12:26 +00:00
limbIndex++;
rot = actorDrawTable[limbIndex];
2020-03-23 01:24:00 +00:00
pos.x = limbEntry->translation.x;
pos.y = limbEntry->translation.y;
pos.z = limbEntry->translation.z;
2020-03-20 21:12:26 +00:00
2020-03-21 02:51:12 +00:00
dList = limbEntry->displayLists[dListIndex];
if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList, &pos, &rot, actor) == 0)) {
Matrix_TranslateThenRotateZYX(&pos, &rot);
if (dList != NULL) {
do {
if (1) {
gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 805),
G_MTX_LOAD);
2020-03-21 02:51:12 +00:00
gSPDisplayList(gfxCtx->polyOpa.p++, dList);
}
} while (0);
2020-03-20 21:12:26 +00:00
}
}
if (appendDlistFunc != NULL) {
2020-03-20 21:12:26 +00:00
appendDlistFunc(globalCtx, limbIndex, &dList, &rot, actor);
}
if (limbEntry->firstChildIndex != LIMB_DONE) {
SkelAnime_LodDrawLimb(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor, dListIndex);
2020-03-21 02:51:12 +00:00
}
Matrix_Pull();
if (limbEntry->nextLimbIndex != LIMB_DONE) {
SkelAnime_LodDrawLimb(globalCtx, limbEntry->nextLimbIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor, dListIndex);
2020-03-21 02:51:12 +00:00
}
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_skelanime.c", 821);
2020-03-21 02:51:12 +00:00
}
2020-03-30 22:53:26 +00:00
/*
* Draws the Skeleton described by `skeleton` with a level of detail display list indexed by `dListIndex`
*/
void SkelAnime_LodDraw(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable,
SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc,
Actor* actor, s32 dListIndex) {
2020-03-21 02:51:12 +00:00
SkelLimbEntry* limbEntry;
char pad[4];
Gfx* dList;
Vec3f pos;
Vec3s rot;
GraphicsContext* gfxCtx;
Gfx* dispRefs[4];
2020-03-21 02:51:12 +00:00
if (skeleton == NULL) {
osSyncPrintf(VT_FGCOL(RED));
osSyncPrintf("Si2_Lod_draw():skelがNULLです。\n"); // Si2_Lod_draw (): skel is NULL.
osSyncPrintf(VT_RST);
2020-03-21 02:51:12 +00:00
return;
2020-03-20 21:12:26 +00:00
}
2020-03-21 02:51:12 +00:00
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_skelanime.c", 849);
2020-03-21 02:51:12 +00:00
Matrix_Push();
limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[0]);
pos.x = actorDrawTable->x;
pos.y = actorDrawTable->y;
pos.z = actorDrawTable->z;
2020-03-20 21:12:26 +00:00
rot = actorDrawTable[1];
2020-03-21 02:51:12 +00:00
dList = limbEntry->displayLists[dListIndex];
if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList, &pos, &rot, actor) == 0)) {
Matrix_TranslateThenRotateZYX(&pos, &rot);
if (dList != NULL) {
gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 881), G_MTX_LOAD);
2020-03-21 02:51:12 +00:00
gSPDisplayList(gfxCtx->polyOpa.p++, dList);
}
}
if (appendDlistFunc != NULL) {
2020-03-21 02:51:12 +00:00
appendDlistFunc(globalCtx, 1, &dList, &rot, actor);
}
if (limbEntry->firstChildIndex != 0xFF) {
SkelAnime_LodDrawLimb(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor, dListIndex);
2020-03-21 02:51:12 +00:00
}
2020-03-20 21:12:26 +00:00
Matrix_Pull();
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_skelanime.c", 894);
2020-03-21 02:51:12 +00:00
}
2020-03-30 22:53:26 +00:00
/*
* Draws the limb at `limbIndex` with a level of detail display lists index by `dListIndex`, Limb matrices come
* from a dynamic allocation from the graph arena.
*/
void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skeleton, Vec3s* actorDrawTable,
SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc,
Actor* actor, s32 dListIndex, Mtx** mtx) {
2020-03-21 02:51:12 +00:00
SkelLimbEntry* limbEntry;
Gfx* dList[2];
2020-03-21 02:51:12 +00:00
Vec3f pos;
Vec3s rot;
GraphicsContext* gfxCtx;
Gfx* dispRefs[4];
2020-03-21 02:51:12 +00:00
Matrix_Push();
limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[limbIndex]);
2020-03-21 02:51:12 +00:00
limbIndex++;
rot = actorDrawTable[limbIndex];
pos.x = limbEntry->translation.x;
pos.y = limbEntry->translation.y;
pos.z = limbEntry->translation.z;
2020-03-30 22:53:26 +00:00
// Double assignment here would not work.
dList[0] = limbEntry->displayLists[dListIndex];
dList[1] = dList[0];
if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList[1], &pos, &rot, actor) == 0)) {
Matrix_TranslateThenRotateZYX(&pos, &rot);
if (dList[1] != NULL) {
Matrix_ToMtx(*mtx, "../z_skelanime.c", 945);
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_skelanime.c", 946);
2020-03-21 02:51:12 +00:00
gSPMatrix(gfxCtx->polyOpa.p++, *mtx, G_MTX_LOAD);
gSPDisplayList(gfxCtx->polyOpa.p++, dList[1]);
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_skelanime.c", 949);
2020-03-21 02:51:12 +00:00
(*mtx)++;
} else if (dList[0] != NULL) {
2020-03-21 02:51:12 +00:00
Matrix_ToMtx(*mtx, "../z_skelanime.c", 954);
(*mtx)++;
}
}
if (appendDlistFunc != NULL) {
appendDlistFunc(globalCtx, limbIndex, &dList[0], &rot, actor);
2020-03-21 02:51:12 +00:00
}
if (limbEntry->firstChildIndex != LIMB_DONE) {
SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor, dListIndex, mtx);
2020-03-21 02:51:12 +00:00
}
2020-03-18 03:15:19 +00:00
2020-03-21 02:51:12 +00:00
Matrix_Pull();
if (limbEntry->nextLimbIndex != LIMB_DONE) {
SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->nextLimbIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor, dListIndex, mtx);
2020-03-20 21:12:26 +00:00
}
}
2020-03-17 04:31:30 +00:00
2020-03-30 22:53:26 +00:00
/*
* Draws the Skeleton described by `skeleton` with a level of detail display list indexed by `dListIndex`
* Matricies for the limbs are dynamically allocted from the graph arena. The dynamic allocation occurs
* because the Skeleton is too large to be supported by the normal matrix stack.
*/
2020-03-30 22:53:26 +00:00
void SkelAnime_LodDrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, s32 dListCount,
SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc,
Actor* actor, s32 dListIndex) {
SkelLimbEntry* limbEntry;
2020-03-30 22:53:26 +00:00
char pad[4];
2020-03-21 02:51:12 +00:00
Gfx* dList[2];
Vec3f pos;
Vec3s rot;
Mtx* mtx;
GraphicsContext* gfxCtx;
Gfx* dispRefs[4];
2020-03-21 02:51:12 +00:00
2020-03-30 22:53:26 +00:00
mtx = Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(Mtx));
if (skeleton == NULL) {
osSyncPrintf(VT_FGCOL(RED));
osSyncPrintf("Si2_Lod_draw_SV():skelがNULLです。\n"); // Si2_Lod_draw_SV (): skel is NULL.
osSyncPrintf(VT_RST);
2020-03-21 02:51:12 +00:00
return;
}
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_skelanime.c", 1000);
2020-03-21 02:51:12 +00:00
gSPSegment(gfxCtx->polyOpa.p++, 0xD, mtx);
Matrix_Push();
limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[0]);
2020-03-21 02:51:12 +00:00
pos.x = actorDrawTable->x;
pos.y = actorDrawTable->y;
pos.z = actorDrawTable->z;
rot = actorDrawTable[1];
2020-03-30 22:53:26 +00:00
dList[0] = limbEntry->displayLists[dListIndex];
dList[1] = dList[0];
if ((updateMtxFunc == 0) || (updateMtxFunc(globalCtx, 1, &dList[1], &pos, &rot, actor) == 0)) {
Matrix_TranslateThenRotateZYX(&pos, &rot);
if (dList[1] != NULL) {
Matrix_ToMtx(mtx, "../z_skelanime.c", 1033);
2020-03-21 02:51:12 +00:00
gSPMatrix(gfxCtx->polyOpa.p++, mtx, G_MTX_LOAD);
gSPDisplayList(gfxCtx->polyOpa.p++, dList[1]);
mtx++;
} else if (dList[0] != NULL) {
Matrix_ToMtx(mtx, "../z_skelanime.c", 1040);
mtx++;
2020-03-21 02:51:12 +00:00
}
}
2020-03-17 04:31:30 +00:00
if (appendDlistFunc != NULL) {
2020-03-21 02:51:12 +00:00
appendDlistFunc(globalCtx, 1, &dList[0], &rot, actor);
}
if (limbEntry->firstChildIndex != LIMB_DONE) {
SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor, dListIndex, &mtx);
2020-03-21 02:51:12 +00:00
}
2020-03-21 02:51:12 +00:00
Matrix_Pull();
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_skelanime.c", 1053);
2020-03-21 02:51:12 +00:00
}
2020-03-17 04:31:30 +00:00
2020-03-30 22:53:26 +00:00
/*
* Draws the limb of the Skeleton `skeleton` at `limbIndex`
*/
void SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skeleton, Vec3s* actorDrawTable,
SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc,
Actor* actor) {
2020-03-20 21:12:26 +00:00
SkelLimbEntry* limbEntry;
Gfx* dList;
Vec3f pos;
Vec3s rot;
GraphicsContext* gfxCtx;
Gfx* dispRefs[4];
2020-03-20 21:12:26 +00:00
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_skelanime.c", 1076);
2020-03-20 21:12:26 +00:00
Matrix_Push();
limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[limbIndex]);
2020-03-20 21:12:26 +00:00
limbIndex++;
rot = actorDrawTable[limbIndex];
pos.x = limbEntry->translation.x;
pos.y = limbEntry->translation.y;
pos.z = limbEntry->translation.z;
dList = limbEntry->displayLists[0];
if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList, &pos, &rot, actor) == 0)) {
Matrix_TranslateThenRotateZYX(&pos, &rot);
if (dList != NULL) {
do {
if (1) {
gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 1103),
G_MTX_LOAD);
gSPDisplayList(gfxCtx->polyOpa.p++, dList);
}
} while (0);
2020-03-20 21:12:26 +00:00
}
}
if (appendDlistFunc != NULL) {
2020-03-20 21:12:26 +00:00
appendDlistFunc(globalCtx, limbIndex, &dList, &rot, actor);
}
if (limbEntry->firstChildIndex != LIMB_DONE) {
SkelAnime_DrawLimb(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor);
2020-03-20 21:12:26 +00:00
}
Matrix_Pull();
if (limbEntry->nextLimbIndex != LIMB_DONE) {
SkelAnime_DrawLimb(globalCtx, limbEntry->nextLimbIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor);
2020-03-20 21:12:26 +00:00
}
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_skelanime.c", 1121);
2020-03-20 21:12:26 +00:00
}
void SkelAnime_Draw(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable,
SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) {
2020-03-20 21:12:26 +00:00
SkelLimbEntry* rootLimb;
char pad[4];
2020-03-20 21:12:26 +00:00
Gfx* dList;
Vec3f pos;
Vec3s rot;
2020-03-20 21:12:26 +00:00
GraphicsContext* gfxCtx;
Gfx* dispRefs[4];
2020-03-20 21:12:26 +00:00
if (skeleton == NULL) {
osSyncPrintf(VT_FGCOL(RED));
2020-03-20 21:12:26 +00:00
osSyncPrintf("Si2_draw():skelがNULLです。\n"); // Si2_draw (): skel is NULL.
osSyncPrintf(VT_RST);
2020-03-20 21:12:26 +00:00
return;
}
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_skelanime.c", 1148);
2020-03-20 21:12:26 +00:00
Matrix_Push();
rootLimb = SEGMENTED_TO_VIRTUAL(skeleton->limbs[0]);
2020-03-20 21:12:26 +00:00
pos.x = actorDrawTable[0].x;
pos.y = actorDrawTable[0].y;
pos.z = actorDrawTable[0].z;
2020-03-20 21:12:26 +00:00
rot = actorDrawTable[1];
dList = rootLimb->displayLists[0];
2020-03-20 21:12:26 +00:00
if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList, &pos, &rot, actor) == 0)) {
Matrix_TranslateThenRotateZYX(&pos, &rot);
if (dList != NULL) {
gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 1176),
G_MTX_LOAD);
2020-03-20 21:12:26 +00:00
gSPDisplayList(gfxCtx->polyOpa.p++, dList);
}
}
if (appendDlistFunc != NULL) {
2020-03-20 21:12:26 +00:00
appendDlistFunc(globalCtx, 1, &dList, &rot, actor);
}
2020-03-17 04:31:30 +00:00
if (rootLimb->firstChildIndex != LIMB_DONE) {
SkelAnime_DrawLimb(globalCtx, rootLimb->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor);
2020-03-20 21:12:26 +00:00
}
Matrix_Pull();
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_skelanime.c", 1190);
2020-03-20 21:12:26 +00:00
}
void SkelAnime_DrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skeleton, Vec3s* actorDrawTable,
SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc,
Actor* actor, Mtx** limbMatricies) {
2020-03-20 21:12:26 +00:00
SkelLimbEntry* limbEntry;
Gfx* dList[2];
Vec3f pos;
Vec3s rot;
GraphicsContext* gfxCtx;
Gfx* dispRefs[4];
2020-03-20 21:12:26 +00:00
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_skelanime.c", 1214);
2020-03-20 21:12:26 +00:00
Matrix_Push();
limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[limbIndex]);
limbIndex++;
rot = actorDrawTable[limbIndex];
pos.x = limbEntry->translation.x;
pos.y = limbEntry->translation.y;
pos.z = limbEntry->translation.z;
2020-03-20 21:12:26 +00:00
2020-03-30 22:53:26 +00:00
dList[0] = limbEntry->displayLists[0];
dList[1] = dList[0];
2020-03-20 21:12:26 +00:00
if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList[1], &pos, &rot, actor) == 0)) {
Matrix_TranslateThenRotateZYX(&pos, &rot);
if (dList[1] != NULL) {
Matrix_ToMtx(*limbMatricies, "../z_skelanime.c", 1242);
2020-03-20 21:12:26 +00:00
gSPMatrix(gfxCtx->polyOpa.p++, *limbMatricies, G_MTX_LOAD);
gSPDisplayList(gfxCtx->polyOpa.p++, dList[1]);
(*limbMatricies)++;
} else if (dList[0] != NULL) {
Matrix_ToMtx(*limbMatricies, "../z_skelanime.c", 1249);
2020-03-20 21:12:26 +00:00
(*limbMatricies)++;
}
}
if (appendDlistFunc != NULL) {
appendDlistFunc(globalCtx, limbIndex, &dList[0], &rot, actor);
2020-03-20 21:12:26 +00:00
}
if (limbEntry->firstChildIndex != LIMB_DONE) {
SkelAnime_DrawLimbSV(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor, limbMatricies);
2020-03-20 21:12:26 +00:00
}
Matrix_Pull();
if (limbEntry->nextLimbIndex != LIMB_DONE) {
SkelAnime_DrawLimbSV(globalCtx, limbEntry->nextLimbIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor, limbMatricies);
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_skelanime.c", 1265);
2020-03-20 21:12:26 +00:00
}
2020-03-30 22:53:26 +00:00
void SkelAnime_DrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, s32 dListCount,
SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc,
Actor* actor) {
SkelLimbEntry* limbEntry;
char pad[4];
Gfx* dList[2];
2020-03-20 21:12:26 +00:00
Vec3f pos;
Vec3s rot;
Mtx* mtx;
2020-03-20 21:12:26 +00:00
GraphicsContext* gfxCtx;
Gfx* dispRefs[4];
2020-03-20 21:12:26 +00:00
2020-03-30 22:53:26 +00:00
mtx = Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(Mtx));
2020-03-20 21:12:26 +00:00
if (skeleton == NULL) {
osSyncPrintf(VT_FGCOL(RED));
osSyncPrintf("Si2_draw_SV():skelがNULLです。\n"); // Si2_draw_SV (): skel is NULL.
osSyncPrintf(VT_RST);
2020-03-20 21:12:26 +00:00
return;
}
gfxCtx = globalCtx->state.gfxCtx;
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_skelanime.c", 1294);
2020-03-20 21:12:26 +00:00
gSPSegment(gfxCtx->polyOpa.p++, 0xD, mtx);
2020-03-20 21:12:26 +00:00
Matrix_Push();
limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[0]);
pos.x = actorDrawTable->x;
2020-03-30 22:53:26 +00:00
pos.y = actorDrawTable->y;
pos.z = actorDrawTable->z;
2020-03-20 21:12:26 +00:00
rot = actorDrawTable[1];
2020-03-30 22:53:26 +00:00
dList[0] = limbEntry->displayLists[0];
dList[1] = dList[0];
2020-03-17 04:31:30 +00:00
if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList[1], &pos, &rot, actor) == 0)) {
Matrix_TranslateThenRotateZYX(&pos, &rot);
if (dList[1] != NULL) {
Matrix_ToMtx(mtx, "../z_skelanime.c", 1327);
gSPMatrix(gfxCtx->polyOpa.p++, mtx, G_MTX_LOAD);
gSPDisplayList(gfxCtx->polyOpa.p++, dList[1]);
mtx++;
} else {
if (dList[0] != NULL) {
Matrix_ToMtx(mtx, "../z_skelanime.c", 1334);
mtx++;
2020-03-20 21:12:26 +00:00
}
}
}
if (appendDlistFunc != NULL) {
appendDlistFunc(globalCtx, 1, &dList[0], &rot, actor);
2020-03-20 21:12:26 +00:00
}
if (limbEntry->firstChildIndex != LIMB_DONE) {
SkelAnime_DrawLimbSV(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor, &mtx);
2020-03-20 21:12:26 +00:00
}
Matrix_Pull();
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_skelanime.c", 1347);
2020-03-20 21:12:26 +00:00
}
/*
2020-03-23 01:24:00 +00:00
* Copies the rotation values from the rotation value table, indexed by the rotation index table
* When a rotation index is >= the animation limit, the output rotation value is copied from the frame's
* rotation value list, otherwise it is copied from the initial rotation value list
*/
void SkelAnime_AnimateFrame(AnimationHeader* animationSeg, s32 currentFrame, s32 limbCount, Vec3s* dst) {
2020-03-23 01:24:00 +00:00
AnimationRotationIndex* index;
AnimationRotationValue* rotationValueTable;
AnimationRotationValue* frameRotationValueTable;
AnimationHeader* animationHeader;
2020-03-23 01:24:00 +00:00
s32 i;
u16 limit;
2020-03-20 21:12:26 +00:00
animationHeader = SEGMENTED_TO_VIRTUAL(animationSeg);
2020-03-23 01:24:00 +00:00
index = SEGMENTED_TO_VIRTUAL(animationHeader->rotationIndexSeg);
rotationValueTable = SEGMENTED_TO_VIRTUAL(animationHeader->rotationValueSeg);
frameRotationValueTable = &rotationValueTable[currentFrame];
limit = animationHeader->limit;
for (i = 0; i < limbCount; i++, dst++, index++) {
if ((dst == NULL) || (index == NULL) || (frameRotationValueTable == NULL) || (rotationValueTable == NULL)) {
if (1) {} // Necessary to match.
LOG_ADDRESS("out", dst, "../z_skelanime.c", 1392);
LOG_ADDRESS("ref_tbl", index, "../z_skelanime.c", 1393);
LOG_ADDRESS("frame_tbl", frameRotationValueTable, "../z_skelanime.c", 1394);
LOG_ADDRESS("tbl", rotationValueTable, "../z_skelanime.c", 1395);
2020-03-20 21:12:26 +00:00
}
2020-03-23 01:24:00 +00:00
dst->x = index->x >= limit ? frameRotationValueTable[index->x] : rotationValueTable[index->x];
dst->y = index->y >= limit ? frameRotationValueTable[index->y] : rotationValueTable[index->y];
dst->z = index->z >= limit ? frameRotationValueTable[index->z] : rotationValueTable[index->z];
2020-03-20 21:12:26 +00:00
}
}
2020-03-17 04:31:30 +00:00
2020-03-30 22:53:26 +00:00
s16 SkelAnime_GetTotalFrames(GenericAnimationHeader* animationSeg) {
GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg);
return animation->frameCount;
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
s16 SkelAnime_GetFrameCount(GenericAnimationHeader* animationSeg) {
GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg);
2020-03-30 22:53:26 +00:00
// Loads an unsigned half for some reason.
return (u16)animation->frameCount - 1;
2020-03-18 03:15:19 +00:00
}
2020-03-17 04:31:30 +00:00
2020-03-30 22:53:26 +00:00
/*
* Draws the Skeleton `skeleton`'s limb at index `limbIndex`. Appends all generated graphics commands to
* `gfx`. Returns a pointer to the next gfx to be appended to.
*/
Gfx* SkelAnime_Draw2Limb(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skeleton, Vec3s* actorDrawTable,
SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc,
Actor* actor, Gfx* gfx) {
SkelLimbEntry* limbEntry;
Gfx* dList;
Vec3f pos;
Vec3s rot;
Matrix_Push();
limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[limbIndex]);
limbIndex++;
rot = actorDrawTable[limbIndex];
pos.x = limbEntry->translation.x;
pos.y = limbEntry->translation.y;
pos.z = limbEntry->translation.z;
dList = limbEntry->displayLists[0];
if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList, &pos, &rot, actor, &gfx) == 0)) {
Matrix_TranslateThenRotateZYX(&pos, &rot);
if (dList != NULL) {
gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 1489), G_MTX_LOAD);
gSPDisplayList(gfx++, dList);
}
}
if (appendDlistFunc != NULL) {
appendDlistFunc(globalCtx, limbIndex, &dList, &rot, actor, &gfx);
}
if (limbEntry->firstChildIndex != LIMB_DONE) {
gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor, gfx);
}
Matrix_Pull();
if (limbEntry->nextLimbIndex != LIMB_DONE) {
gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->nextLimbIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor, gfx);
}
return gfx;
}
2020-03-30 22:53:26 +00:00
/*
* Draws the Skeleton `skeleton` Appends all generated graphics to `gfx`, and returns a pointer to the
* next gfx to be appended to.
*/
Gfx* SkelAnime_Draw2(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable,
SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc,
Actor* actor, Gfx* gfx) {
SkelLimbEntry* limbEntry;
char pad[4];
Gfx* dList;
Vec3f pos;
Vec3s rot;
2020-03-17 04:31:30 +00:00
if (skeleton == NULL) {
osSyncPrintf(VT_FGCOL(RED));
osSyncPrintf("Si2_draw2():skelがNULLです。NULLを返します。\n"); // Si2_draw2 (): skel is NULL. Returns NULL.
osSyncPrintf(VT_RST);
return NULL;
}
Matrix_Push();
limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[0]);
pos.x = actorDrawTable->x;
pos.y = actorDrawTable->y;
pos.z = actorDrawTable->z;
rot = actorDrawTable[1];
dList = limbEntry->displayLists[0];
if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList, &pos, &rot, actor, &gfx) == 0)) {
Matrix_TranslateThenRotateZYX(&pos, &rot);
if (dList != NULL) {
gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 1558), G_MTX_LOAD);
gSPDisplayList(gfx++, dList);
}
}
if (appendDlistFunc != NULL) {
appendDlistFunc(globalCtx, 1, &dList, &rot, actor, &gfx);
}
if (limbEntry->firstChildIndex != LIMB_DONE) {
gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor, gfx);
}
Matrix_Pull();
return gfx;
}
Gfx* SkelAnime_DrawLimbSV2(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skeleton, Vec3s* actorDrawTable,
SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc,
Actor* actor, Mtx** mtx, Gfx* gfx) {
SkelLimbEntry* limbEntry;
Gfx* dList1;
Gfx* dList2;
Vec3f pos;
Vec3s rot;
char pad[4];
Matrix_Push();
limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[limbIndex]);
limbIndex++;
rot = actorDrawTable[limbIndex];
pos.x = limbEntry->translation.x;
pos.y = limbEntry->translation.y;
pos.z = limbEntry->translation.z;
dList1 = dList2 = limbEntry->displayLists[0];
if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList1, &pos, &rot, actor, &gfx) == 0)) {
Matrix_TranslateThenRotateZYX(&pos, &rot);
if (dList1 != NULL) {
Matrix_ToMtx(*mtx, "../z_skelanime.c", 1623);
gSPMatrix(gfx++, *mtx, G_MTX_LOAD);
gSPDisplayList(gfx++, dList1);
(*mtx)++;
} else {
if (dList2 != NULL) {
Matrix_ToMtx(*mtx, "../z_skelanime.c", 1630);
(*mtx)++;
}
}
}
if (appendDlistFunc != NULL) {
appendDlistFunc(globalCtx, limbIndex, &dList2, &rot, actor, &gfx);
}
if (limbEntry->firstChildIndex != LIMB_DONE) {
gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor, mtx, gfx);
}
Matrix_Pull();
2020-03-17 04:31:30 +00:00
if (limbEntry->nextLimbIndex != LIMB_DONE) {
gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->nextLimbIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor, mtx, gfx);
}
return gfx;
}
2020-03-17 04:31:30 +00:00
/*
* Draws the Skeleton `skeleton` Appends all generated graphics to `gfx`, and returns a pointer to the
* next gfx to be appended to. Allocates matricies for display lists on the graph heap.
*/
Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, s32 dListCount,
SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc,
Actor* actor, Gfx* gfx) {
2020-03-23 01:24:00 +00:00
SkelLimbEntry* limbEntry;
char pad[4];
Gfx* dList1;
Gfx* dList2;
Vec3f pos;
Vec3s rot;
Mtx* mtx;
mtx = Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(*mtx));
if (skeleton == NULL) {
osSyncPrintf(VT_FGCOL(RED));
osSyncPrintf(
"Si2_draw2_SV():skelがNULLです。NULLを返します。\n"); // Si2_draw2_SV (): skel is NULL. Returns NULL.
osSyncPrintf(VT_RST);
2020-03-23 01:24:00 +00:00
return NULL;
}
2020-03-23 01:24:00 +00:00
gSPSegment(gfx++, 0xD, mtx);
Matrix_Push();
limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[0]);
2020-03-23 01:24:00 +00:00
pos.x = actorDrawTable->x;
pos.y = actorDrawTable->y;
pos.z = actorDrawTable->z;
2020-03-23 01:24:00 +00:00
rot = actorDrawTable[1];
dList1 = dList2 = limbEntry->displayLists[0];
if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList1, &pos, &rot, actor, &gfx) == 0)) {
Matrix_TranslateThenRotateZYX(&pos, &rot);
if (dList1 != NULL) {
Matrix_ToMtx(mtx, "../z_skelanime.c", 1710);
2020-03-23 01:24:00 +00:00
gSPMatrix(gfx++, mtx, G_MTX_LOAD);
gSPDisplayList(gfx++, dList1);
mtx++;
} else {
if (dList2 != NULL) {
Matrix_ToMtx(mtx, "../z_skelanime.c", 1717);
2020-03-23 01:24:00 +00:00
mtx++;
}
}
}
if (appendDlistFunc != NULL) {
2020-03-23 01:24:00 +00:00
appendDlistFunc(globalCtx, 1, &dList2, &rot, actor, &gfx);
}
if (limbEntry->firstChildIndex != LIMB_DONE) {
gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc,
appendDlistFunc, actor, &mtx, gfx);
2020-03-23 01:24:00 +00:00
}
2020-03-23 01:24:00 +00:00
Matrix_Pull();
2020-03-23 01:24:00 +00:00
return gfx;
}
2020-03-17 04:31:30 +00:00
2020-03-31 23:29:09 +00:00
#ifdef NON_MATCHING
// Function is unused. This is functionally equivilent, misplace andi which caused regalloc
s32 func_800A29BC(s32 arg0, s32 arg1, Vec3s* arg2) {
2020-03-31 23:29:09 +00:00
s16* temp_t1;
s16* temp_a3;
AnimationHeader* temp_v0;
2020-03-31 23:29:09 +00:00
s32 phi_v0;
s32 t;
temp_v0 = SEGMENTED_TO_VIRTUAL(arg0);
t = temp_v0->genericHeader.unk_02;
temp_a3 = SEGMENTED_TO_VIRTUAL(temp_v0->rotationIndexSeg);
temp_t1 = SEGMENTED_TO_VIRTUAL(temp_v0->rotationValueSeg);
arg2->x = arg1 < temp_a3[0] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[1]] : temp_t1[temp_a3[1]];
arg2->y = arg1 < temp_a3[2] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[3]] : temp_t1[temp_a3[3]];
arg2->z = arg1 < temp_a3[4] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[5]] : temp_t1[temp_a3[5]];
phi_v0 = 1;
arg2++;
temp_a3 += 6;
if (t > 0) {
if (t & 1) {
2020-03-31 23:29:09 +00:00
phi_v0++;
arg2->x = arg1 < temp_a3[0] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[1]] : temp_t1[temp_a3[1]];
arg2->y = arg1 < temp_a3[2] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[3]] : temp_t1[temp_a3[3]];
arg2->z = arg1 < temp_a3[4] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[5]] : temp_t1[temp_a3[5]];
temp_a3 += 6;
arg2++;
if (t + 1 == phi_v0) {
2020-03-31 23:29:09 +00:00
goto ret;
}
}
do {
2020-03-31 23:29:09 +00:00
phi_v0 += 2;
arg2->x = arg1 < temp_a3[0] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[1]] : temp_t1[temp_a3[1]];
arg2->y = arg1 < temp_a3[2] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[3]] : temp_t1[temp_a3[3]];
arg2->z = arg1 < temp_a3[4] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[5]] : temp_t1[temp_a3[5]];
temp_a3 += 6;
arg2++;
arg2->x = arg1 < temp_a3[0] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[1]] : temp_t1[temp_a3[1]];
arg2->y = arg1 < temp_a3[2] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[3]] : temp_t1[temp_a3[3]];
arg2->z = arg1 < temp_a3[4] ? ((s16*)((arg1 * 2) + (u32)temp_t1))[temp_a3[5]] : temp_t1[temp_a3[5]];
temp_a3 += 6;
arg2++;
} while (phi_v0 != t + 1);
2020-03-31 23:29:09 +00:00
}
ret:
return t;
}
#else
2020-03-17 04:31:30 +00:00
#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A29BC.s")
2020-03-31 23:29:09 +00:00
#endif
2020-03-17 04:31:30 +00:00
s16 func_800A2DBC(GenericAnimationHeader* animationSeg) {
GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg);
2020-03-20 21:12:26 +00:00
return animation->unk_02;
2020-03-20 21:12:26 +00:00
}
2020-03-30 22:53:26 +00:00
/*
* Appears to be unused anywhere in the game. Appears to be a clone of
* SkelAnime_GetTotalFrames
*/
2020-03-30 22:53:26 +00:00
s16 SkelAnime_GetTotalFrames2(GenericAnimationHeader* animationSeg) {
GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg);
2020-03-20 21:12:26 +00:00
return animation->frameCount;
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
2020-03-30 22:53:26 +00:00
/*
* Appears to be unused anywhere in the game. Appears to be a clone of
* SkelAnime_GetFrameCount
*/
2020-03-30 22:53:26 +00:00
s16 SkelAnime_GetFrameCount2(GenericAnimationHeader* animationSeg) {
GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg);
2020-03-17 04:31:30 +00:00
return animation->frameCount - 1;
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
void SkelAnime_InterpolateVec3s(s32 limbCount, Vec3s* dst, Vec3s* vec2, Vec3s* vec3, f32 unkf) {
2020-03-30 22:53:26 +00:00
s32 i;
s16 dist;
s16 temp2;
if (unkf < 1.0f) {
for (i = 0; i < limbCount; i++, dst++, vec2++, vec3++) {
2020-03-30 22:53:26 +00:00
temp2 = vec2->x;
dist = vec3->x - temp2;
dst->x = (s16)(dist * unkf) + temp2;
temp2 = vec2->y;
dist = vec3->y - temp2;
dst->y = (s16)(dist * unkf) + temp2;
temp2 = vec2->z;
dist = vec3->z - temp2;
dst->z = (s16)(dist * unkf) + temp2;
}
} else {
for (i = 0; i < limbCount; i++, dst++, vec3++) {
2020-03-30 22:53:26 +00:00
dst->x = vec3->x;
dst->y = vec3->y;
dst->z = vec3->z;
}
}
}
2020-03-17 04:31:30 +00:00
void SkelAnime_AnimationCtxReset(AnimationContext* animationCtx) {
animationCtx->animationCount = 0;
2020-03-20 21:12:26 +00:00
}
void func_800A32F4(GlobalContext* globalCtx) {
D_801600B0 <<= 1;
2020-03-20 21:12:26 +00:00
}
void func_800A3310(GlobalContext* globalCtx) {
2020-03-20 21:12:26 +00:00
u32* D_8012A480Ptr = &D_8012A480;
*D_8012A480Ptr |= D_801600B0;
}
2020-03-17 04:31:30 +00:00
AnimationEntry* SkelAnime_NextEntry(AnimationContext* animationCtx, AnimationType type) {
AnimationEntry* entry;
2020-03-20 21:12:26 +00:00
s16 index = animationCtx->animationCount;
2020-03-17 04:31:30 +00:00
if (index >= ANIMATION_ENTRY_MAX) {
2020-03-20 21:12:26 +00:00
return NULL;
}
animationCtx->animationCount = index + 1;
entry = &animationCtx->entries[index];
2020-03-23 01:24:00 +00:00
entry->type = type;
2020-03-20 21:12:26 +00:00
return entry;
}
2020-03-17 04:31:30 +00:00
2020-03-23 01:24:00 +00:00
/*
* The next 6 functions are coordinate with the AnimationType enum
*/
2020-03-17 04:31:30 +00:00
2020-03-25 16:07:09 +00:00
void SkelAnime_LoadLinkAnimetion(GlobalContext* globalCtx, LinkAnimetionEntry* linkAnimetionSeg, s32 frame,
s32 limbCount, void* ram) {
2020-03-23 01:24:00 +00:00
AnimationEntry* entry;
LinkAnimetionEntry* linkAnimetionEntry;
2020-03-23 01:24:00 +00:00
char pad[4];
2020-03-20 21:12:26 +00:00
entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_LINKANIMETION);
if (entry != NULL) {
2020-03-23 01:24:00 +00:00
linkAnimetionEntry = SEGMENTED_TO_VIRTUAL(linkAnimetionSeg);
osCreateMesgQueue(&entry->types.type0.msgQueue, &entry->types.type0.msg, 1);
DmaMgr_SendRequest2(
&entry->types.type0.req, ram,
LINK_ANIMETION_OFFSET(linkAnimetionEntry->animationSegAddress, ((sizeof(Vec3s) * limbCount + 2) * frame)),
sizeof(Vec3s) * limbCount + 2, 0, &entry->types.type0.msgQueue, NULL, "../z_skelanime.c", 2004);
2020-03-23 01:24:00 +00:00
}
}
void SkelAnime_LoadAnimationType1(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src) {
AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE1);
if (entry != NULL) {
2020-03-23 01:24:00 +00:00
entry->types.type1.unk_00 = D_801600B0;
entry->types.type1.vecCount = vecCount;
entry->types.type1.dst = dst;
entry->types.type1.src = src;
}
}
void SkelAnime_LoadAnimationType2(GlobalContext* globalCtx, s32 limbCount, Vec3s* arg2, Vec3s* arg3, f32 arg4) {
AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE2);
if (entry != NULL) {
2020-03-23 01:24:00 +00:00
entry->types.type2.unk_00 = D_801600B0;
entry->types.type2.limbCount = limbCount;
2020-03-23 01:24:00 +00:00
entry->types.type2.unk_04 = arg2;
entry->types.type2.unk_08 = arg3;
entry->types.type2.unk_0C = arg4;
}
}
void SkelAnime_LoadAnimationType3(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index) {
AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE3);
if (entry != NULL) {
2020-03-23 01:24:00 +00:00
entry->types.type3.unk_00 = D_801600B0;
entry->types.type3.vecCount = vecCount;
entry->types.type3.dst = dst;
entry->types.type3.src = src;
entry->types.type3.index = index;
}
}
void SkelAnime_LoadAnimationType4(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index) {
AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE4);
if (entry != NULL) {
2020-03-23 01:24:00 +00:00
entry->types.type4.unk_00 = D_801600B0;
entry->types.type4.vecCount = vecCount;
entry->types.type4.dst = dst;
entry->types.type4.src = src;
entry->types.type4.index = index;
}
}
void SkelAnime_LoadAnimationType5(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 arg3) {
AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE5);
if (entry != NULL) {
2020-03-23 01:24:00 +00:00
entry->types.type5.actor = actor;
entry->types.type5.skelAnime = skelAnime;
entry->types.type5.unk_08 = arg3;
2020-03-20 21:12:26 +00:00
}
}
2020-03-17 04:31:30 +00:00
2020-03-23 01:24:00 +00:00
/* The next functions are callbacks to loading animations */
2020-03-17 04:31:30 +00:00
void SkelAnime_LinkAnimetionLoaded(GlobalContext* globalCtx, AnimationEntryType0* entry) {
2020-03-23 01:24:00 +00:00
osRecvMesg(&entry->msgQueue, NULL, OS_MESG_BLOCK);
}
2020-03-17 04:31:30 +00:00
void SkelAnime_AnimationType1Loaded(GlobalContext* globalCtx, AnimationEntryType1* entry) {
2020-03-23 01:24:00 +00:00
s32 i;
Vec3s* dst;
Vec3s* src;
AnimationEntryRaw* genericEntry = (AnimationEntryRaw*)entry;
2020-03-17 04:31:30 +00:00
if ((genericEntry->raw[0] & D_8012A480) != 0) {
2020-03-23 01:24:00 +00:00
return;
}
2020-03-17 04:31:30 +00:00
for (dst = entry->dst, src = entry->src, i = 0; i < genericEntry->raw[1]; i++) {
2020-03-23 01:24:00 +00:00
*dst++ = *src++;
}
}
2020-03-17 04:31:30 +00:00
void SkelAnime_AnimationType2Loaded(GlobalContext* globalCtx, AnimationEntryType2* entry) {
if ((entry->unk_00 & D_8012A480) == 0) {
SkelAnime_InterpolateVec3s(entry->limbCount, entry->unk_04, entry->unk_04, entry->unk_08, entry->unk_0C);
2020-03-23 01:24:00 +00:00
}
}
2020-03-17 04:31:30 +00:00
void SkelAnime_AnimationType3Loaded(GlobalContext* globalCtx, AnimationEntryType3* entry) {
2020-03-23 01:24:00 +00:00
s32 i;
Vec3s* dst;
Vec3s* src;
u8* index;
AnimationEntryRaw* rawEntry = (AnimationEntryRaw*)entry;
2020-03-17 04:31:30 +00:00
if ((rawEntry->raw[0] & D_8012A480) == 0) {
for (dst = entry->dst, src = entry->src, index = entry->index, i = 0; i < rawEntry->raw[1]; i++, dst++, src++) {
if (*index++) {
2020-03-23 01:24:00 +00:00
*dst = *src;
}
}
}
}
2020-03-17 04:31:30 +00:00
void SkelAnime_AnimationType4Loaded(GlobalContext* globalCtx, AnimationEntryType4* entry) {
2020-03-23 01:24:00 +00:00
s32 i;
Vec3s* dst;
Vec3s* src;
u8* index;
AnimationEntryRaw* rawEntry = (AnimationEntryRaw*)entry;
2020-03-17 04:31:30 +00:00
if ((rawEntry->raw[0] & D_8012A480) == 0) {
for (dst = entry->dst, src = entry->src, index = entry->index, i = 0; i < rawEntry->raw[1]; i++, dst++, src++) {
if (*index++ < 1U) {
2020-03-23 01:24:00 +00:00
*dst = *src;
}
}
}
}
2020-03-20 21:12:26 +00:00
void SkelAnime_AnimationType5Loaded(GlobalContext* globalCtx, AnimationEntryType5* entry) {
2020-03-18 03:15:19 +00:00
char pad[4];
2020-03-23 01:24:00 +00:00
Actor* actor = entry->actor;
2020-03-18 03:15:19 +00:00
Vec3f pos;
2020-03-23 01:24:00 +00:00
func_800A54FC(entry->skelAnime, &pos, actor->shape.rot.y);
actor->posRot.pos.x += pos.x * actor->scale.x;
actor->posRot.pos.y += pos.y * actor->scale.y * entry->unk_08;
actor->posRot.pos.z += pos.z * actor->scale.z;
2020-03-18 03:15:19 +00:00
}
2020-03-17 04:31:30 +00:00
void func_800A390C(GlobalContext* globalCtx, AnimationContext* animationCtx) {
2020-03-20 21:12:26 +00:00
AnimationEntry* entry;
2020-03-17 04:31:30 +00:00
for (entry = animationCtx->entries; animationCtx->animationCount != 0; entry++, animationCtx->animationCount--) {
2020-03-25 19:44:42 +00:00
sAnimationLoadDone[entry->type](globalCtx, &entry->types);
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
2020-03-20 21:12:26 +00:00
D_801600B0 = 1;
D_8012A480 = 0;
}
2020-03-17 04:31:30 +00:00
void SkelAnime_InitLinkAnimetion(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg,
2020-04-01 01:53:53 +00:00
LinkAnimetionEntry* linkAnimetionEntrySeg, s32 flags, Vec3s* actorDrawTbl,
Vec3s* transitionDrawTbl, s32 limbBufCount) {
char pad[8];
SkeletonHeader* skeletonHeader;
size_t allocSize;
s32 limbCount;
s32 headerCount;
2020-03-20 21:12:26 +00:00
skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg);
headerCount = skeletonHeader->limbCount;
2020-03-26 03:01:24 +00:00
skelAnime->initFlags = flags;
limbCount = (flags & 2) ? headerCount : 1;
2020-03-17 04:31:30 +00:00
if (flags & 1) {
limbCount += headerCount;
2020-03-20 21:12:26 +00:00
}
if (flags & 4) {
limbCount += headerCount;
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
skelAnime->limbCount = limbCount;
skelAnime->dListCount = skeletonHeader->dListCount;
allocSize = limbCount * sizeof(Vec3s);
skelAnime->skeleton = SEGMENTED_TO_VIRTUAL(skeletonHeader->skeletonSeg);
if (flags & 8) {
allocSize += 2;
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
if (actorDrawTbl == NULL) {
skelAnime->actorDrawTbl = ZeldaArena_MallocDebug(allocSize, "../z_skelanime.c", 2364);
2020-03-26 03:01:24 +00:00
skelAnime->transitionDrawTbl = ZeldaArena_MallocDebug(allocSize, "../z_skelanime.c", 2365);
} else {
if (limbBufCount != limbCount) {
2020-03-20 21:12:26 +00:00
__assert("joint_buff_num == joint_num", "../z_skelanime.c", 2369);
}
2020-03-17 04:31:30 +00:00
skelAnime->actorDrawTbl = (Vec3s*)ALIGN16((u32)actorDrawTbl);
2020-04-01 01:53:53 +00:00
skelAnime->transitionDrawTbl = (Vec3s*)ALIGN16((u32)transitionDrawTbl);
2020-03-20 21:12:26 +00:00
}
2020-03-26 03:01:24 +00:00
if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->transitionDrawTbl == NULL)) {
osSyncPrintf(VT_FGCOL(RED));
osSyncPrintf(
"Skeleton_Info_Rom_SV_ct メモリアロケーションエラー\n"); // Skeleton_Info_Rom_SV_ct Memory allocation error
osSyncPrintf(VT_RST);
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
2020-04-02 17:44:19 +00:00
SkelAnime_ChangeLinkAnim(globalCtx, skelAnime, linkAnimetionEntrySeg, 1.0f, 0.0f, 0.0f, 0, 0.0f);
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
void func_800A3B8C(SkelAnime* skelAnime) {
2020-03-31 01:12:49 +00:00
if (skelAnime->mode < 2) {
2020-03-23 01:24:00 +00:00
skelAnime->animUpdate = &func_800A3D70;
} else {
2020-03-23 01:24:00 +00:00
skelAnime->animUpdate = &func_800A3E0C;
2020-03-20 21:12:26 +00:00
}
2020-03-26 03:01:24 +00:00
skelAnime->transCurrentFrame = 0.0f;
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
2020-03-31 23:29:09 +00:00
s32 func_800A3BC0(GlobalContext* globalCtx, SkelAnime* skelAnime) {
return skelAnime->animUpdate(globalCtx, skelAnime);
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
s32 func_800A3BE4(GlobalContext* globalCtx, SkelAnime* skelAnime) {
2020-03-26 03:01:24 +00:00
f32 prevUnk28 = skelAnime->transCurrentFrame;
f32 updateRate = R_UPDATE_RATE * 0.5f;
2020-03-26 03:01:24 +00:00
skelAnime->transCurrentFrame -= skelAnime->transitionStep * updateRate;
2020-03-26 03:01:24 +00:00
if (skelAnime->transCurrentFrame <= 0.0f) {
2020-03-20 21:12:26 +00:00
func_800A3B8C(skelAnime);
}
2020-03-26 03:01:24 +00:00
SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->transitionDrawTbl,
1.0f - (skelAnime->transCurrentFrame / prevUnk28));
2020-03-20 21:12:26 +00:00
return 0;
}
2020-03-17 04:31:30 +00:00
void func_800A3C9C(GlobalContext* globalCtx, SkelAnime* skelAnime) {
2020-03-20 21:12:26 +00:00
f32 updateRate;
2020-03-17 04:31:30 +00:00
2020-03-25 16:07:09 +00:00
SkelAnime_LoadLinkAnimetion(globalCtx, skelAnime->linkAnimetionSeg, skelAnime->animCurrentFrame,
skelAnime->limbCount, skelAnime->actorDrawTbl);
2020-03-26 03:01:24 +00:00
if (skelAnime->transCurrentFrame != 0) {
2020-03-20 21:12:26 +00:00
updateRate = R_UPDATE_RATE * 0.5f;
2020-03-26 03:01:24 +00:00
skelAnime->transCurrentFrame -= skelAnime->transitionStep * updateRate;
if (skelAnime->transCurrentFrame <= 0.0f) {
skelAnime->transCurrentFrame = 0.0f;
2020-03-20 21:12:26 +00:00
return;
}
SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl,
skelAnime->transitionDrawTbl, skelAnime->transCurrentFrame);
2020-03-20 21:12:26 +00:00
}
}
2020-03-17 04:31:30 +00:00
s32 func_800A3D70(GlobalContext* globalCtx, SkelAnime* skelAnime) {
2020-03-20 21:12:26 +00:00
f32 updateRate = R_UPDATE_RATE * 0.5f;
2020-03-17 04:31:30 +00:00
2020-03-20 21:12:26 +00:00
skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate;
if (skelAnime->animCurrentFrame < 0.0f) {
2020-03-30 22:53:26 +00:00
skelAnime->animCurrentFrame += skelAnime->totalFrames;
} else if (skelAnime->totalFrames <= skelAnime->animCurrentFrame) {
skelAnime->animCurrentFrame -= skelAnime->totalFrames;
2020-03-20 21:12:26 +00:00
}
func_800A3C9C(globalCtx, skelAnime);
return 0;
}
s32 func_800A3E0C(GlobalContext* globalCtx, SkelAnime* skelAnime) {
2020-03-20 21:12:26 +00:00
f32 updateRate = R_UPDATE_RATE * 0.5f;
if (skelAnime->animCurrentFrame == skelAnime->animFrameCount) {
2020-03-20 21:12:26 +00:00
func_800A3C9C(globalCtx, skelAnime);
return 1;
}
skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate;
if (0.0f < ((skelAnime->animCurrentFrame - skelAnime->animFrameCount) * skelAnime->animPlaybackSpeed)) {
2020-03-20 21:12:26 +00:00
skelAnime->animCurrentFrame = skelAnime->animFrameCount;
} else {
if (skelAnime->animCurrentFrame < 0.0f) {
2020-03-30 22:53:26 +00:00
skelAnime->animCurrentFrame += skelAnime->totalFrames;
} else if (skelAnime->totalFrames <= skelAnime->animCurrentFrame) {
skelAnime->animCurrentFrame -= skelAnime->totalFrames;
2020-03-20 21:12:26 +00:00
}
}
2020-03-20 21:12:26 +00:00
func_800A3C9C(globalCtx, skelAnime);
return 0;
}
2020-04-01 01:53:53 +00:00
void SkelAnime_SetTransition(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 transitionRate) {
2020-03-26 03:01:24 +00:00
skelAnime->transCurrentFrame = 1.0f;
skelAnime->transitionStep = 1.0f / transitionRate;
2020-03-20 21:12:26 +00:00
}
2020-04-02 17:44:19 +00:00
void SkelAnime_ChangeLinkAnim(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg,
f32 playbackSpeed, f32 frame, f32 frameCount, u8 animationMode, f32 transitionRate) {
2020-03-20 21:12:26 +00:00
2020-03-31 01:12:49 +00:00
skelAnime->mode = animationMode;
2020-03-26 03:01:24 +00:00
if ((transitionRate != 0.0f) &&
2020-03-30 22:53:26 +00:00
((linkAnimetionEntrySeg != skelAnime->linkAnimetionSeg) || (frame != skelAnime->animCurrentFrame))) {
if (transitionRate < 0) {
2020-03-20 21:12:26 +00:00
func_800A3B8C(skelAnime);
2020-03-26 03:01:24 +00:00
SkelAnime_CopyVec3s(skelAnime, skelAnime->transitionDrawTbl, skelAnime->actorDrawTbl);
transitionRate = -transitionRate;
} else {
skelAnime->animUpdate = &func_800A3BE4;
2020-03-25 16:07:09 +00:00
SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount,
2020-03-26 03:01:24 +00:00
skelAnime->transitionDrawTbl);
2020-03-20 21:12:26 +00:00
}
2020-03-26 03:01:24 +00:00
skelAnime->transCurrentFrame = 1.0f;
skelAnime->transitionStep = 1.0f / transitionRate;
} else {
2020-03-20 21:12:26 +00:00
func_800A3B8C(skelAnime);
2020-03-25 16:07:09 +00:00
SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount,
skelAnime->actorDrawTbl);
2020-03-26 03:01:24 +00:00
skelAnime->transCurrentFrame = 0.0f;
2020-03-20 21:12:26 +00:00
}
2020-03-30 22:53:26 +00:00
skelAnime->linkAnimetionSeg = linkAnimetionEntrySeg;
skelAnime->animCurrentFrame = 0.0f;
2020-03-26 03:01:24 +00:00
skelAnime->initialFrame = frame;
skelAnime->animCurrentFrame = frame;
2020-03-20 21:12:26 +00:00
skelAnime->animFrameCount = frameCount;
2020-03-30 22:53:26 +00:00
skelAnime->totalFrames = SkelAnime_GetTotalFrames(linkAnimetionEntrySeg);
2020-03-20 21:12:26 +00:00
skelAnime->animPlaybackSpeed = playbackSpeed;
}
2020-04-02 17:44:19 +00:00
void SkelAnime_ChangeLinkAnimDefaultStop(GlobalContext* globalCtx, SkelAnime* skelAnime,
LinkAnimetionEntry* linkAnimetionEntrySeg) {
SkelAnime_ChangeLinkAnim(globalCtx, skelAnime, linkAnimetionEntrySeg, 1.0f, 0.0f,
SkelAnime_GetFrameCount(&linkAnimetionEntrySeg->genericHeader), 2, 0.0f);
2020-03-20 21:12:26 +00:00
}
2020-04-02 17:44:19 +00:00
void SkelAnime_ChangeLinkAnimPlaybackStop(GlobalContext* globalCtx, SkelAnime* skelAnime,
LinkAnimetionEntry* linkAnimetionEntrySeg, f32 playbackSpeed) {
SkelAnime_ChangeLinkAnim(globalCtx, skelAnime, linkAnimetionEntrySeg, playbackSpeed, 0.0f,
SkelAnime_GetFrameCount(&linkAnimetionEntrySeg->genericHeader), 2, 0.0f);
2020-03-20 21:12:26 +00:00
}
2020-04-02 17:44:19 +00:00
void SkelAnime_ChangeLinkAnimDefaultRepeat(GlobalContext* globalCtx, SkelAnime* skelAnime,
LinkAnimetionEntry* linkAnimetionEntrySeg) {
SkelAnime_ChangeLinkAnim(globalCtx, skelAnime, linkAnimetionEntrySeg, 1.0f, 0.0f,
SkelAnime_GetFrameCount(&linkAnimetionEntrySeg->genericHeader), 0, 0.0f);
2020-03-20 21:12:26 +00:00
}
2020-04-02 17:44:19 +00:00
void SkelAnime_ChangeLinkAnimPlaybackRepeat(GlobalContext* globalCtx, SkelAnime* skelAnime,
LinkAnimetionEntry* linkAnimetionEntrySeg, f32 playbackSpeed) {
SkelAnime_ChangeLinkAnim(globalCtx, skelAnime, linkAnimetionEntrySeg, playbackSpeed, 0.0f,
SkelAnime_GetFrameCount(&linkAnimetionEntrySeg->genericHeader), 0, 0.0f);
2020-03-20 21:12:26 +00:00
}
void func_800A41FC(GlobalContext* globalCtx, SkelAnime* skelAnime) {
SkelAnime_LoadAnimationType1(globalCtx, skelAnime->limbCount, skelAnime->transitionDrawTbl,
skelAnime->actorDrawTbl);
2020-03-20 21:12:26 +00:00
}
void func_800A422C(GlobalContext* globalCtx, SkelAnime* skelAnime) {
SkelAnime_LoadAnimationType1(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl,
skelAnime->transitionDrawTbl);
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
2020-03-25 16:07:09 +00:00
void func_800A425C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg,
f32 frame) {
SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount,
skelAnime->transitionDrawTbl);
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
2020-03-25 16:07:09 +00:00
void func_800A42A0(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg,
f32 frame) {
SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount,
skelAnime->actorDrawTbl);
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
2020-04-01 01:53:53 +00:00
void func_800A42E4(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 frame) {
SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->transitionDrawTbl,
2020-04-01 01:53:53 +00:00
frame);
2020-03-20 21:12:26 +00:00
}
2020-04-01 01:53:53 +00:00
void func_800A431C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg,
f32 transitionFrame, LinkAnimetionEntry* linkAnimetionEntrySeg2, f32 frame, f32 transitionRate,
Vec3s* actorDrawTbl) {
Vec3s* alignedActorDrawTbl;
SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)transitionFrame, skelAnime->limbCount,
2020-03-25 16:07:09 +00:00
skelAnime->actorDrawTbl);
2020-03-17 04:31:30 +00:00
2020-04-01 01:53:53 +00:00
alignedActorDrawTbl = (Vec3s*)ALIGN16((u32)actorDrawTbl);
2020-03-20 21:12:26 +00:00
2020-04-01 01:53:53 +00:00
SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg2, (s32)frame, skelAnime->limbCount,
alignedActorDrawTbl);
SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, alignedActorDrawTbl,
transitionRate);
2020-03-20 21:12:26 +00:00
}
2020-04-01 01:53:53 +00:00
void func_800A43B8(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg,
f32 transitionFrame, LinkAnimetionEntry* linkAnimetionEntrySeg2, f32 frame, f32 transitionRate,
Vec3s* actorDrawTbl) {
Vec3s* alignedActorDrawTbl;
2020-04-01 01:53:53 +00:00
SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)transitionFrame, skelAnime->limbCount,
skelAnime->transitionDrawTbl);
2020-04-01 01:53:53 +00:00
alignedActorDrawTbl = (Vec3s*)ALIGN16((u32)actorDrawTbl);
2020-04-01 01:53:53 +00:00
SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg2, (s32)frame, skelAnime->limbCount,
alignedActorDrawTbl);
SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->transitionDrawTbl, alignedActorDrawTbl,
transitionRate);
}
2020-03-20 21:12:26 +00:00
2020-04-01 01:53:53 +00:00
void SkelAnime_SetModeStop(SkelAnime* skelAnime) {
2020-03-31 01:12:49 +00:00
skelAnime->mode = 2;
2020-03-20 21:12:26 +00:00
func_800A3B8C(skelAnime);
}
s32 func_800A4478(SkelAnime* skelAnime, f32 arg1, f32 updateRate) {
2020-03-23 01:24:00 +00:00
f32 updateSpeed;
2020-03-20 21:12:26 +00:00
f32 temp_f12;
2020-03-23 01:24:00 +00:00
f32 nextFrame;
2020-03-17 04:31:30 +00:00
2020-03-23 01:24:00 +00:00
updateSpeed = skelAnime->animPlaybackSpeed * updateRate;
nextFrame = skelAnime->animCurrentFrame - updateSpeed;
if (nextFrame < 0.0f) {
2020-03-30 22:53:26 +00:00
nextFrame += skelAnime->totalFrames;
} else if (skelAnime->totalFrames <= nextFrame) {
2020-03-31 23:29:09 +00:00
nextFrame -= skelAnime->totalFrames;
2020-03-20 21:12:26 +00:00
}
2020-03-31 23:29:09 +00:00
if ((arg1 == 0.0f) && (updateSpeed > 0.0f)) {
arg1 = skelAnime->totalFrames;
2020-03-20 21:12:26 +00:00
}
2020-03-31 23:29:09 +00:00
2020-03-23 01:24:00 +00:00
temp_f12 = (nextFrame + updateSpeed) - arg1;
2020-03-31 23:29:09 +00:00
if ((0.0f <= (temp_f12 * updateSpeed)) && (((temp_f12 - updateSpeed) * updateSpeed) < 0.0f)) {
return 1;
2020-03-20 21:12:26 +00:00
}
return 0;
}
2020-03-17 04:31:30 +00:00
s32 func_800A4530(SkelAnime* skelAnime, f32 arg1) {
2020-03-20 21:12:26 +00:00
f32 updateRate = R_UPDATE_RATE * 0.5f;
2020-03-17 04:31:30 +00:00
2020-03-20 21:12:26 +00:00
return func_800A4478(skelAnime, arg1, updateRate);
}
2020-03-17 04:31:30 +00:00
void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg,
2020-03-26 03:01:24 +00:00
AnimationHeader* animationSeg, Vec3s* actorDrawTable, Vec3s* transitionDrawTable, s32 limbCount) {
SkeletonHeader* skeletonHeader;
2020-03-17 04:31:30 +00:00
skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg);
skelAnime->limbCount = skeletonHeader->limbCount + 1;
skelAnime->skeleton = SEGMENTED_TO_VIRTUAL(skeletonHeader->skeletonSeg);
if (actorDrawTable == NULL) {
skelAnime->actorDrawTbl =
ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), "../z_skelanime.c", 2968);
skelAnime->transitionDrawTbl = ZeldaArena_MallocDebug(
skelAnime->limbCount * sizeof(*skelAnime->transitionDrawTbl), "../z_skelanime.c", 2969);
} else {
if (limbCount != skelAnime->limbCount) {
2020-03-20 21:12:26 +00:00
__assert("joint_buff_num == this->joint_num", "../z_skelanime.c", 2973);
}
skelAnime->actorDrawTbl = actorDrawTable;
2020-03-26 03:01:24 +00:00
skelAnime->transitionDrawTbl = transitionDrawTable;
2020-03-20 21:12:26 +00:00
}
2020-03-26 03:01:24 +00:00
if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->transitionDrawTbl == NULL)) {
osSyncPrintf(VT_FGCOL(RED));
2020-03-20 21:12:26 +00:00
osSyncPrintf("Skeleton_Info2_ct メモリアロケーションエラー\n"); // Skeleton_Info2_ct memory allocation error
osSyncPrintf(VT_RST);
2020-03-20 21:12:26 +00:00
}
if (animationSeg != NULL) {
2020-04-02 17:44:19 +00:00
SkelAnime_ChangeAnimDefaultRepeat(skelAnime, animationSeg);
2020-03-20 21:12:26 +00:00
}
}
void SkelAnime_InitSV(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg,
2020-03-26 03:01:24 +00:00
AnimationHeader* animationSeg, Vec3s* actorDrawTable, Vec3s* transitionDrawTable, s32 limbCount) {
SkeletonHeader* skeletonHeader;
2020-03-20 21:12:26 +00:00
skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg);
skelAnime->limbCount = skeletonHeader->limbCount + 1;
skelAnime->dListCount = skeletonHeader->dListCount;
skelAnime->skeleton = SEGMENTED_TO_VIRTUAL(skeletonHeader->skeletonSeg);
2020-03-20 21:12:26 +00:00
if (actorDrawTable == NULL) {
skelAnime->actorDrawTbl =
ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), "../z_skelanime.c", 3047);
skelAnime->transitionDrawTbl = ZeldaArena_MallocDebug(
skelAnime->limbCount * sizeof(*skelAnime->transitionDrawTbl), "../z_skelanime.c", 3048);
} else {
if (limbCount != skelAnime->limbCount) {
__assert("joint_buff_num == this->joint_num", "../z_skelanime.c", 3052);
2020-03-20 21:12:26 +00:00
}
skelAnime->actorDrawTbl = actorDrawTable;
2020-03-26 03:01:24 +00:00
skelAnime->transitionDrawTbl = transitionDrawTable;
2020-03-20 21:12:26 +00:00
}
2020-03-26 03:01:24 +00:00
if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->transitionDrawTbl == NULL)) {
osSyncPrintf(VT_FGCOL(RED));
osSyncPrintf(
"Skeleton_Info_Rom_SV_ct メモリアロケーションエラー\n"); // Skeleton_Info_Rom_SV_ct Memory allocation error
osSyncPrintf(VT_RST);
2020-03-20 21:12:26 +00:00
}
if (animationSeg != NULL) {
2020-04-02 17:44:19 +00:00
SkelAnime_ChangeAnimDefaultRepeat(skelAnime, animationSeg);
2020-03-20 21:12:26 +00:00
}
}
void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg,
AnimationHeader* animationSeg) {
SkeletonHeader* skeletonHeader;
2020-03-20 21:12:26 +00:00
skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg);
skelAnime->limbCount = skeletonHeader->limbCount + 1;
skelAnime->skeleton = SEGMENTED_TO_VIRTUAL(skeletonHeader->skeletonSeg);
skelAnime->actorDrawTbl =
ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), "../z_skelanime.c", 3120);
2020-03-26 03:01:24 +00:00
skelAnime->transitionDrawTbl =
ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->transitionDrawTbl), "../z_skelanime.c", 3121);
if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->transitionDrawTbl == NULL)) {
osSyncPrintf(VT_FGCOL(RED));
osSyncPrintf(
"Skeleton_Info2_skin2_ct メモリアロケーションエラー\n"); // Skeleton_Info2_skin2_ct Memory allocation error
osSyncPrintf(VT_RST);
2020-03-20 21:12:26 +00:00
}
if (animationSeg != NULL) {
2020-04-02 17:44:19 +00:00
SkelAnime_ChangeAnimDefaultRepeat(skelAnime, animationSeg);
2020-03-20 21:12:26 +00:00
}
}
2020-03-17 04:31:30 +00:00
void func_800A49B0(SkelAnime* skelAnime) {
2020-03-31 01:12:49 +00:00
if (skelAnime->mode < 2) {
2020-03-23 01:24:00 +00:00
skelAnime->animUpdate = &func_800A4D9C;
2020-03-31 01:12:49 +00:00
} else if (skelAnime->mode < 4) {
2020-03-23 01:24:00 +00:00
skelAnime->animUpdate = &func_800A4EE0;
} else {
skelAnime->animUpdate = &func_800A4E38;
2020-03-20 21:12:26 +00:00
}
}
2020-03-17 04:31:30 +00:00
s32 SkelAnime_FrameUpdateMatrix(SkelAnime* skelAnime) {
2020-03-23 01:24:00 +00:00
return skelAnime->animUpdate(skelAnime);
2020-03-18 03:15:19 +00:00
}
2020-03-17 04:31:30 +00:00
s32 func_800A4A20(SkelAnime* skelAnime) {
f32 prevUnk28;
f32 updateRate;
2020-03-20 21:12:26 +00:00
2020-03-26 03:01:24 +00:00
prevUnk28 = skelAnime->transCurrentFrame;
2020-04-02 17:44:19 +00:00
updateRate = R_UPDATE_RATE * (1.0f / 3.0f);
2020-03-26 03:01:24 +00:00
skelAnime->transCurrentFrame -= skelAnime->transitionStep * updateRate;
if (skelAnime->transCurrentFrame <= 0.0f) {
2020-03-20 21:12:26 +00:00
func_800A49B0(skelAnime);
2020-03-26 03:01:24 +00:00
skelAnime->transCurrentFrame = 0.0f;
2020-03-20 21:12:26 +00:00
}
SkelAnime_InterpolateVec3s(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl,
skelAnime->transitionDrawTbl, 1.0f - (skelAnime->transCurrentFrame / prevUnk28));
2020-03-20 21:12:26 +00:00
return 0;
}
2020-03-17 04:31:30 +00:00
s32 func_800A4AD8(SkelAnime* skelAnime) {
2020-03-20 21:12:26 +00:00
s16 temp_a2;
2020-03-30 22:53:26 +00:00
s16 temp_a1;
f32 sp28;
2020-03-20 21:12:26 +00:00
f32 phi_f2;
f32 updateRate;
2020-03-20 21:12:26 +00:00
2020-03-26 03:01:24 +00:00
temp_a2 = (s16)(skelAnime->transCurrentFrame * 16384.0f);
2020-04-02 17:44:19 +00:00
updateRate = R_UPDATE_RATE * (1.0f / 3.0f);
2020-03-26 03:01:24 +00:00
skelAnime->transCurrentFrame -= skelAnime->transitionStep * updateRate;
if (skelAnime->transCurrentFrame <= 0.0f) {
2020-03-20 21:12:26 +00:00
func_800A49B0(skelAnime);
2020-03-26 03:01:24 +00:00
skelAnime->transCurrentFrame = 0.0f;
2020-03-20 21:12:26 +00:00
}
2020-03-26 03:01:24 +00:00
temp_a1 = (s16)(skelAnime->transCurrentFrame * 16384.0f);
if (skelAnime->unk_03 < 0) {
2020-03-20 21:12:26 +00:00
sp28 = 1.0f - Math_Coss(temp_a2);
phi_f2 = 1.0f - Math_Coss(temp_a1);
} else {
2020-03-20 21:12:26 +00:00
sp28 = Math_Sins(temp_a2);
phi_f2 = Math_Sins(temp_a1);
}
if (phi_f2 != 0.0f) {
2020-03-20 21:12:26 +00:00
phi_f2 /= sp28;
} else {
2020-03-20 21:12:26 +00:00
phi_f2 = 0.0f;
}
SkelAnime_InterpolateVec3s(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl,
skelAnime->transitionDrawTbl, 1.0f - phi_f2);
2020-03-20 21:12:26 +00:00
return 0;
}
2020-03-17 04:31:30 +00:00
void func_800A4C58(SkelAnime* skelAnime) {
2020-03-31 23:29:09 +00:00
s32 t;
f32 updateRate;
char pad[4];
Vec3s sp38[98];
2020-03-23 01:24:00 +00:00
f32 temp_f10;
f32 temp_f2;
2020-03-20 21:12:26 +00:00
SkelAnime_AnimateFrame(skelAnime->animCurrentSeg, skelAnime->animCurrentFrame, skelAnime->limbCount,
skelAnime->actorDrawTbl);
2020-03-31 03:22:10 +00:00
if (skelAnime->mode & 0x1) {
2020-03-31 23:29:09 +00:00
t = (s32)skelAnime->animCurrentFrame;
temp_f10 = t;
2020-03-23 01:24:00 +00:00
temp_f2 = skelAnime->animCurrentFrame - temp_f10;
2020-03-31 23:29:09 +00:00
t++;
if (t >= (s32)skelAnime->totalFrames) {
t = 0;
2020-03-20 21:12:26 +00:00
}
2020-03-31 23:29:09 +00:00
SkelAnime_AnimateFrame(skelAnime->animCurrentSeg, t, skelAnime->limbCount, sp38);
SkelAnime_InterpolateVec3s(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, sp38,
temp_f2);
2020-03-20 21:12:26 +00:00
}
2020-03-26 03:01:24 +00:00
if (skelAnime->transCurrentFrame != 0) {
2020-04-02 17:44:19 +00:00
updateRate = R_UPDATE_RATE * (1.0f / 3.0f);
2020-03-31 23:29:09 +00:00
skelAnime->transCurrentFrame -= skelAnime->transitionStep * updateRate;
if (skelAnime->transCurrentFrame <= 0.0f) {
2020-03-26 03:01:24 +00:00
skelAnime->transCurrentFrame = 0.0f;
2020-03-20 21:12:26 +00:00
return;
}
SkelAnime_InterpolateVec3s(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl,
skelAnime->transitionDrawTbl, skelAnime->transCurrentFrame);
2020-03-20 21:12:26 +00:00
}
}
2020-03-17 04:31:30 +00:00
s32 func_800A4D9C(SkelAnime* skelAnime) {
2020-04-02 17:44:19 +00:00
f32 updateRate = R_UPDATE_RATE * (1.0f / 3.0f);
skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate;
if (skelAnime->animCurrentFrame < 0.0f) {
2020-03-30 22:53:26 +00:00
skelAnime->animCurrentFrame += skelAnime->totalFrames;
} else if (skelAnime->totalFrames <= skelAnime->animCurrentFrame) {
skelAnime->animCurrentFrame -= skelAnime->totalFrames;
2020-03-20 21:12:26 +00:00
}
func_800A4C58(skelAnime);
return 0;
}
2020-03-17 04:31:30 +00:00
s32 func_800A4E38(SkelAnime* skelAnime) {
2020-04-02 17:44:19 +00:00
f32 updateRate = R_UPDATE_RATE * (1.0f / 3.0f);
skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate;
2020-03-26 03:01:24 +00:00
if (skelAnime->animCurrentFrame < skelAnime->initialFrame) {
skelAnime->animCurrentFrame =
(skelAnime->animCurrentFrame - skelAnime->initialFrame) + skelAnime->animFrameCount;
} else if (skelAnime->animFrameCount <= skelAnime->animCurrentFrame) {
skelAnime->animCurrentFrame =
(skelAnime->animCurrentFrame - skelAnime->animFrameCount) + skelAnime->initialFrame;
2020-03-20 21:12:26 +00:00
}
2020-03-20 21:12:26 +00:00
func_800A4C58(skelAnime);
return 0;
}
2020-03-17 04:31:30 +00:00
s32 func_800A4EE0(SkelAnime* skelAnime) {
f32 updateRate;
2020-03-17 04:31:30 +00:00
2020-04-02 17:44:19 +00:00
updateRate = R_UPDATE_RATE * (1.0f / 3.0f);
if (skelAnime->animCurrentFrame == skelAnime->animFrameCount) {
2020-03-20 21:12:26 +00:00
SkelAnime_AnimateFrame(skelAnime->animCurrentSeg, (s32)skelAnime->animCurrentFrame, skelAnime->limbCount,
skelAnime->actorDrawTbl);
2020-03-20 21:12:26 +00:00
func_800A4C58(skelAnime);
return 1;
}
skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate;
if (0.0f < ((skelAnime->animCurrentFrame - skelAnime->animFrameCount) * skelAnime->animPlaybackSpeed)) {
2020-03-20 21:12:26 +00:00
skelAnime->animCurrentFrame = skelAnime->animFrameCount;
} else {
if (skelAnime->animCurrentFrame < 0.0f) {
2020-03-30 22:53:26 +00:00
skelAnime->animCurrentFrame += skelAnime->totalFrames;
} else {
2020-03-30 22:53:26 +00:00
if (skelAnime->totalFrames <= skelAnime->animCurrentFrame) {
skelAnime->animCurrentFrame -= skelAnime->totalFrames;
2020-03-20 21:12:26 +00:00
}
}
}
func_800A4C58(skelAnime);
return 0;
}
2020-04-02 17:44:19 +00:00
void SkelAnime_ChangeAnimImpl(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed, f32 frame,
f32 frameCount, u8 animationType, f32 transitionRate, s8 unk2) {
2020-03-31 01:12:49 +00:00
skelAnime->mode = animationType;
if ((transitionRate != 0.0f) &&
((animationSeg != skelAnime->animCurrentSeg) || (frame != skelAnime->animCurrentFrame))) {
if (transitionRate < 0) {
2020-03-20 21:12:26 +00:00
func_800A49B0(skelAnime);
2020-03-26 03:01:24 +00:00
SkelAnime_CopyVec3s(skelAnime, skelAnime->transitionDrawTbl, skelAnime->actorDrawTbl);
2020-03-20 21:12:26 +00:00
transitionRate = -transitionRate;
} else {
if (unk2 != 0) {
skelAnime->animUpdate = &func_800A4AD8;
2020-03-20 21:12:26 +00:00
skelAnime->unk_03 = unk2;
} else {
skelAnime->animUpdate = &func_800A4A20;
2020-03-20 21:12:26 +00:00
}
2020-03-26 03:01:24 +00:00
SkelAnime_AnimateFrame(animationSeg, frame, skelAnime->limbCount, skelAnime->transitionDrawTbl);
2020-03-20 21:12:26 +00:00
}
2020-03-26 03:01:24 +00:00
skelAnime->transCurrentFrame = 1.0f;
skelAnime->transitionStep = 1.0f / transitionRate;
} else {
2020-03-20 21:12:26 +00:00
func_800A49B0(skelAnime);
SkelAnime_AnimateFrame(animationSeg, frame, skelAnime->limbCount, skelAnime->actorDrawTbl);
2020-03-26 03:01:24 +00:00
skelAnime->transCurrentFrame = 0.0f;
2020-03-20 21:12:26 +00:00
}
skelAnime->animCurrentSeg = animationSeg;
2020-03-26 03:01:24 +00:00
skelAnime->initialFrame = frame;
2020-03-20 21:12:26 +00:00
skelAnime->animFrameCount = frameCount;
2020-03-30 22:53:26 +00:00
skelAnime->totalFrames = SkelAnime_GetTotalFrames(&animationSeg->genericHeader);
2020-03-31 01:12:49 +00:00
if (skelAnime->mode >= 4) {
2020-03-20 21:12:26 +00:00
skelAnime->animCurrentFrame = 0.0f;
} else {
skelAnime->animCurrentFrame = frame;
2020-03-31 01:12:49 +00:00
if (skelAnime->mode < 2) {
2020-03-30 22:53:26 +00:00
skelAnime->animFrameCount = skelAnime->totalFrames - 1.0f;
2020-03-20 21:12:26 +00:00
}
}
skelAnime->animPlaybackSpeed = playbackSpeed;
}
2020-03-17 04:31:30 +00:00
2020-04-02 17:44:19 +00:00
void SkelAnime_ChangeAnim(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed, f32 frame,
f32 frameCount, u8 mode, f32 transitionRate) {
SkelAnime_ChangeAnimImpl(skelAnime, animationSeg, playbackSpeed, frame, frameCount, mode, transitionRate, 0);
2020-03-18 03:15:19 +00:00
}
2020-03-31 23:29:09 +00:00
2020-04-02 17:44:19 +00:00
void SkelAnime_ChangeAnimDefaultStop(SkelAnime* skelAnime, AnimationHeader* animationSeg) {
SkelAnime_ChangeAnim(skelAnime, animationSeg, 1.0f, 0.0f, SkelAnime_GetFrameCount(&animationSeg->genericHeader), 2,
0.0f);
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
2020-04-02 17:44:19 +00:00
void SkelAnime_ChangeAnimTransitionStop(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate) {
SkelAnime_ChangeAnim(skelAnime, animationSeg, 1.0f, 0, SkelAnime_GetFrameCount(&animationSeg->genericHeader), 2,
transitionRate);
2020-03-20 21:12:26 +00:00
}
2020-03-31 23:29:09 +00:00
2020-04-02 17:44:19 +00:00
void SkelAnime_ChangeAnimPlaybackStop(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed) {
SkelAnime_ChangeAnim(skelAnime, animationSeg, playbackSpeed, 0.0f,
SkelAnime_GetFrameCount(&animationSeg->genericHeader), 2, 0.0f);
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
2020-04-02 17:44:19 +00:00
void SkelAnime_ChangeAnimDefaultRepeat(SkelAnime* skelAnime, AnimationHeader* animationSeg) {
SkelAnime_ChangeAnim(skelAnime, animationSeg, 1.0f, 0.0f, SkelAnime_GetFrameCount(&animationSeg->genericHeader), 0,
0.0f);
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
2020-04-02 17:44:19 +00:00
void SkelAnime_ChangeAnimTransitionRepeat(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate) {
SkelAnime_ChangeAnim(skelAnime, animationSeg, 1.0f, 0.0f, 0.0f, 0, transitionRate);
2020-03-20 21:12:26 +00:00
}
2020-04-02 17:44:19 +00:00
void SkelAnime_ChangeAnimPlaybackRepeat(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed) {
SkelAnime_ChangeAnim(skelAnime, animationSeg, playbackSpeed, 0.0f,
SkelAnime_GetFrameCount(&animationSeg->genericHeader), 0, 0.0f);
2020-03-20 21:12:26 +00:00
}
2020-03-17 04:31:30 +00:00
2020-04-02 17:44:19 +00:00
void SkelAnime_AnimSetStop(SkelAnime* skelAnime) {
2020-03-31 01:12:49 +00:00
skelAnime->mode = 2;
2020-03-30 22:53:26 +00:00
skelAnime->animFrameCount = skelAnime->totalFrames;
2020-03-20 21:12:26 +00:00
func_800A49B0(skelAnime);
}
2020-03-17 04:31:30 +00:00
2020-04-02 17:44:19 +00:00
void SkelAnime_AnimReverse(SkelAnime* skelAnime) {
2020-03-31 23:29:09 +00:00
f32 initialFrame = skelAnime->initialFrame;
skelAnime->initialFrame = skelAnime->animFrameCount;
skelAnime->animPlaybackSpeed = -skelAnime->animPlaybackSpeed;
2020-03-31 23:29:09 +00:00
skelAnime->animFrameCount = initialFrame;
2020-03-20 21:12:26 +00:00
}
2020-03-23 01:57:25 +00:00
void func_800A5428(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* index) {
2020-03-23 01:57:25 +00:00
s32 i;
for (i = 0; i < skelAnime->limbCount; i++, dst++, src++) {
if (*index++) {
2020-03-23 01:57:25 +00:00
*dst = *src;
}
}
}
2020-03-17 04:31:30 +00:00
void func_800A5490(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* arg3) {
2020-03-23 01:57:25 +00:00
s32 i;
for (i = 0; i < skelAnime->limbCount; i++, dst++, src++) {
if (*arg3++ < 1U) {
2020-03-23 01:57:25 +00:00
*dst = *src;
}
}
}
2020-03-17 04:31:30 +00:00
2020-03-26 03:01:24 +00:00
/*
* Moves `pos` backwards on the xz plane from `angle`
*/
void func_800A54FC(SkelAnime* skelAnime, Vec3f* pos, s16 angle) {
2020-03-23 01:57:25 +00:00
f32 x;
f32 z;
f32 sin;
f32 cos;
2020-03-18 03:15:19 +00:00
2020-03-26 03:01:24 +00:00
if (skelAnime->flags & 0x10) {
2020-03-23 01:57:25 +00:00
pos->z = 0.0f;
pos->x = 0.0f;
} else {
2020-03-26 03:01:24 +00:00
// `angle` rotation around y axis.
x = skelAnime->actorDrawTbl->x;
z = skelAnime->actorDrawTbl->z;
2020-03-23 01:57:25 +00:00
sin = Math_Sins(angle);
cos = Math_Coss(angle);
pos->x = x * cos + z * sin;
pos->z = z * cos - x * sin;
2020-03-26 03:01:24 +00:00
x = skelAnime->prevFramePos.x;
z = skelAnime->prevFramePos.z;
// `prevFrameRot` rotation around y axis.
sin = Math_Sins(skelAnime->prevFrameRot);
cos = Math_Coss(skelAnime->prevFrameRot);
2020-03-23 01:57:25 +00:00
pos->x -= x * cos + z * sin;
pos->z -= z * cos - x * sin;
}
2020-03-26 03:01:24 +00:00
skelAnime->prevFrameRot = angle;
skelAnime->prevFramePos.x = skelAnime->actorDrawTbl->x;
skelAnime->actorDrawTbl->x = skelAnime->unk_3E.x;
skelAnime->prevFramePos.z = skelAnime->actorDrawTbl->z;
skelAnime->actorDrawTbl->z = skelAnime->unk_3E.z;
2020-04-02 17:44:19 +00:00
if (skelAnime->flags & ANIM_FLAG_UPDATEXZ) {
if (skelAnime->flags & ANIM_FLAG_UPDATEY) {
2020-03-23 01:57:25 +00:00
pos->y = 0.0f;
} else {
2020-03-26 03:01:24 +00:00
pos->y = skelAnime->actorDrawTbl->y - skelAnime->prevFramePos.y;
2020-03-23 01:57:25 +00:00
}
2020-03-26 03:01:24 +00:00
skelAnime->prevFramePos.y = skelAnime->actorDrawTbl->y;
skelAnime->actorDrawTbl->y = skelAnime->unk_3E.y;
} else {
2020-03-23 01:57:25 +00:00
pos->y = 0.0f;
2020-03-26 03:01:24 +00:00
skelAnime->prevFramePos.y = skelAnime->actorDrawTbl->y;
2020-03-23 01:57:25 +00:00
}
2020-04-02 17:44:19 +00:00
skelAnime->flags &= ~ANIM_FLAG_UPDATEY;
2020-03-23 01:57:25 +00:00
}
2020-03-18 03:15:19 +00:00
s32 func_800A56C8(SkelAnime* skelAnime, f32 arg1) {
2020-03-23 01:57:25 +00:00
return func_800A4478(skelAnime, arg1, 1.0f);
}
2020-03-18 03:15:19 +00:00
void SkelAnime_Free(SkelAnime* skelAnime, GlobalContext* globalCtx) {
if (skelAnime->actorDrawTbl != NULL) {
2020-03-23 01:57:25 +00:00
ZeldaArena_FreeDebug(skelAnime->actorDrawTbl, "../z_skelanime.c", 3729);
} else {
2020-03-23 01:57:25 +00:00
osSyncPrintf("now_joint あきまへん!!\n"); // now_joint Akimane! !
}
2020-03-26 03:01:24 +00:00
if (skelAnime->transitionDrawTbl != NULL) {
ZeldaArena_FreeDebug(skelAnime->transitionDrawTbl, "../z_skelanime.c", 3731);
} else {
osSyncPrintf("morf_joint あきまへん!!\n"); // "morf_joint Akimane !!"
2020-03-23 01:57:25 +00:00
}
}
2020-03-18 03:15:19 +00:00
void SkelAnime_CopyVec3s(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src) {
2020-03-23 01:57:25 +00:00
s32 i;
for (i = 0; i < skelAnime->limbCount; i++) {
2020-03-23 01:57:25 +00:00
*dst++ = *src++;
}
}