From aa2d45310dee1f3d9d96a79b836cbc1175d1017b Mon Sep 17 00:00:00 2001 From: KrimtonZ Date: Tue, 17 Mar 2020 22:15:19 -0500 Subject: start z_skelanime.c --- src/code/z_skelanime.c | 137 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 126 insertions(+), 11 deletions(-) (limited to 'src/code') diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 9b51b29cb..ff51b8f99 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1,6 +1,8 @@ #include #include +s32 func_800A4478(SkelAnime*,f32,f32); + #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A08A0.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A0B40.s") @@ -21,7 +23,12 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A1FC8.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_GetFrameCount.s") +s32 SkelAnime_GetFrameCount(u32 animation) +{ + u16* virt = (u16*)SEGMENTED_TO_VIRTUAL(animation); + + return (s16)(*virt - 1); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A2044.s") @@ -71,7 +78,23 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A37F0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3874.s") +typedef struct { + Actor* actor; + SkelAnime* skelAnime; + f32 unk_8; +} UNK_800A3874_A1; +void func_800A54FC(SkelAnime*,Vec3f*,s16); +void func_800A3874(s32 arg0, UNK_800A3874_A1* arg1) +{ + char pad[4]; + Actor* temp_v0 = arg1->actor; + Vec3f pos; + + func_800A54FC(arg1->skelAnime, &pos, temp_v0->shape.rot.y); + temp_v0->posRot.pos.x += pos.x * temp_v0->scale.x; + temp_v0->posRot.pos.y += pos.y * temp_v0->scale.y * arg1->unk_8; + temp_v0->posRot.pos.z += pos.z * temp_v0->scale.z; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A390C.s") @@ -129,7 +152,9 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A49B0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_FrameUpdateMatrix.s") +s32 SkelAnime_FrameUpdateMatrix(SkelAnime* skelAnime){ + return skelAnime->mtxUpdate(skelAnime); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4A20.s") @@ -145,7 +170,10 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4FE4.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_ChangeAnimation.s") +void SkelAnime_ChangeAnimation(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 unk0, /* 0x10 */ f32 frameCount, /* 0x14 */ u8 unk1, /* 0x18 */ f32 transitionRate) +{ + func_800A4FE4(skelAnime, animation, playbackSpeed, unk0, frameCount, unk1, transitionRate, 0); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A51E8.s") @@ -167,11 +195,98 @@ #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A5490.s") +#ifdef NON_MATCHING +void func_800A54FC(SkelAnime* skelAnime, Vec3f* pos, s16 angle) +{ + f32 temp_f20; + f32 temp_f20_2; + f32 temp_f22; + f32 temp_f22_2; + f32 temp_f24; + f32 temp_f24_2; + f32 temp_ret; + f32 temp_ret_2; + + if ((skelAnime->unk_35 & 0x10) != 0) + { + pos->z = 0.0f; + pos->x = 0.0f; + } + else + { + + temp_f20 = (f32) *(s16*)(skelAnime->actorDrawTbl); + temp_f22 = (f32) ((s16*)skelAnime->actorDrawTbl)[2]; + temp_f24 = Math_Sins(angle); + temp_ret = Math_Coss(angle); + pos->x = (f32) ((temp_f20 * temp_ret) + (temp_f22 * temp_f24)); + pos->z = (f32) ((temp_f22 * temp_ret) - (temp_f20 * temp_f24)); + temp_f20_2 = (f32) skelAnime->unk_38; + temp_f22_2 = (f32) skelAnime->unk_3C; + temp_f24_2 = Math_Sins(skelAnime->unk_36); + temp_ret_2 = Math_Coss(skelAnime->unk_36); + pos->x -= ((temp_f20_2 * temp_ret_2) + (temp_f22_2 * temp_f24_2)); + pos->z -= ((temp_f22_2 * temp_ret_2) - (temp_f20_2 * temp_f24_2)); + //arg1->unk0 = (f32) (arg1->unk0 - ((temp_f20_2 * temp_ret_2) + (temp_f22_2 * temp_f24_2))); + //arg1->unk8 = (f32) (arg1->unk8 - ((temp_f22_2 * temp_ret_2) - (temp_f20_2 * temp_f24_2))); + } + skelAnime->unk_36 = angle; + skelAnime->unk_38 = *(s16*)(skelAnime->actorDrawTbl); + *(s16*)(skelAnime->actorDrawTbl) = skelAnime->unk_3E; + skelAnime->unk_3C = ((s16*)skelAnime->actorDrawTbl)[2]; + ((s16*)skelAnime->actorDrawTbl)[2] = skelAnime->unk_42; + if ((skelAnime->unk_35 & 2) != 0) + { + if ((skelAnime->unk_35 & 0x10) != 0) + { + pos->y = 0.0f; + } + else + { + pos->y = (f32) ((s16*)skelAnime->actorDrawTbl)[1]; + } + skelAnime->unk_3A = ((s16*)skelAnime->actorDrawTbl)[1]; + ((s16*)skelAnime->actorDrawTbl)[1] = skelAnime->unk_40; + } + else + { + pos->y = 0.0f; + skelAnime->unk_3A = ((s16*)skelAnime->actorDrawTbl)[1]; + } + skelAnime->unk_35 &= ~0x10; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A54FC.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A56C8.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A56F0.s") - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A5774.s") - +#endif + +s32 func_800A56C8(SkelAnime *skelAnime, f32 arg1) +{ + return func_800A4478(skelAnime, arg1, 1.0f); +} + +void func_800A56F0(SkelAnime *skelAnime, s32 arg1) +{ + if (skelAnime->actorDrawTbl != 0) + { + ZeldaArena_FreeDebug(skelAnime->actorDrawTbl, "../z_skelanime.c", 3729); + } + else + { + osSyncPrintf("now_joint あきまへん!!\n"); // now_joint Akimane! ! + } + if (skelAnime->unk_24 != 0) + { + ZeldaArena_FreeDebug(skelAnime->unk_24, "../z_skelanime.c", 3731); + return; + } + osSyncPrintf("morf_joint あきまへん!!\n"); // "morf_joint Akimane !!" +} + +s32 func_800A5774(SkelAnime* skelAnime, Vec3s *dst, Vec3s *src) +{ + s32 i; + for(i = 0; i < skelAnime->limbCount; i++) + { + *dst++ = *src++; + } +} -- cgit v1.2.3 From db5f70ad1cc8477bf7556517517ff5f347c70070 Mon Sep 17 00:00:00 2001 From: KrimtonZ Date: Fri, 20 Mar 2020 16:12:26 -0500 Subject: skelanime wip --- src/code/z_skelanime.c | 1390 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 1304 insertions(+), 86 deletions(-) (limited to 'src/code') diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index ff51b8f99..cf13a38c1 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -2,8 +2,97 @@ #include s32 func_800A4478(SkelAnime*,f32,f32); +void func_800A52F8(SkelAnime* skelAnime, u32 animation); +void func_800A54FC(SkelAnime*,Vec3f*,s16); +s32 func_800A3D70(GlobalContext*,SkelAnime*); +s32 func_800A3E0C(GlobalContext*,SkelAnime*); +void func_800A34DC(GlobalContext*,u8,Vec3s*,Vec3s*,f32); +void func_800A336C(GlobalContext* globalCtx, s32 arg1, s32 arg2, s32 limbCount, void* ram); +s32 func_800A4D9C(SkelAnime* skelAnime); +s32 func_800A4EE0(SkelAnime* skelAnime); +s32 func_800A4E38(SkelAnime* skelAnime); +void func_800A1D8C(u32,s32,u8,Vec3s*); +void func_800A2E70(u8,Vec3s*,Vec3s*,Vec3s*,f32); +void func_800A49B0(SkelAnime*); + +typedef struct +{ + u32 limbIndexSeg; + u8 limbCount; + char unk_05[3]; + u8 dListCount; +} SkelAnimeInit; + +//.data +static u32 D_8012A480 = 0; +typedef void (*testfunc)(GlobalContext*,char*); +static testfunc D_8012A484[] = +{ + (testfunc)0x800A3678, + (testfunc)0x800A36A4, + (testfunc)0x800A3714, + (testfunc)0x800A3770, + (testfunc)0x800A37F0, + (testfunc)0x800A3874, +}; + +//.bss +u32 D_801600B0; + +#ifdef NON_MATCHING +void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 arg7) +{ + GraphicsContext* gfxCtx; + Gfx* gfx[3]; + SkelLimbEntry* limbEntry; + Vec3s rot; + Vec3f pos; + Gfx* dList; + + gfxCtx = globalCtx->state.gfxCtx; + func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 773); + Matrix_Push(); + limbEntry = SEGMENTED_TO_VIRTUAL(limbTable[limbIndex]); + limbIndex++; + rot = actorDrawTable[limbIndex]; + + pos.x = limbEntry->pos.x; + pos.y = limbEntry->pos.y; + pos.z = limbEntry->pos.z; + + dList = &limbEntry->dList[arg7]; + if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList, &pos, &rot, actor) == 0)) + { + func_800D1340(&pos, &rot); + if (dList != NULL) + { + gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(gfxCtx, "../z_skelanime.c", 0x325), G_MTX_LOAD); + gSPDisplayList(gfxCtx->polyOpa.p++, dList); + } + } + + if (appendDlistFunc != NULL) + { + appendDlistFunc(globalCtx, limbIndex, &dList, &rot, actor); + } + + if (limbEntry->firstChildIndex != 0xFF) + { + func_800A08A0(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, arg7); + } + + Matrix_Pull(); + if (limbEntry->nextLimbIndex != 0xFF) + { + func_800A08A0(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, arg7); + } + func_800C6B54(&gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x335); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A08A0.s") +#endif +#undef NON_MATCHING #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A0B40.s") @@ -11,17 +100,376 @@ s32 func_800A4478(SkelAnime*,f32,f32); #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A106C.s") +#ifdef NON_MATCHING +// SkelAnime_DrawLimb +void func_800A1344(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) +{ + GraphicsContext* gfxCtx; + Gfx* gfx[4]; + SkelLimbEntry* limbEntry; + Vec3s rot; + Vec3f pos; + Gfx* dList; + + gfxCtx = globalCtx->state.gfxCtx; + func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x434); + Matrix_Push(); + limbEntry = SEGMENTED_TO_VIRTUAL(limbTable[limbIndex]); + limbIndex++; + rot = actorDrawTable[limbIndex]; + pos.x = (f32) limbEntry->pos.x; + pos.y = (f32) limbEntry->pos.y; + pos.z = (f32) limbEntry->pos.z; + dList = limbEntry->dList; + if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList, &pos, &rot, actor) == 0)) + { + func_800D1340(&pos, &rot); + if (dList != NULL) + { + gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(gfxCtx, "../z_skelanime.c", 0x44F), G_MTX_LOAD); + gSPDisplayList(gfxCtx->polyOpa.p++, dList); + } + } + + if (appendDlistFunc != NULL) + { + appendDlistFunc(globalCtx, limbIndex, &dList, &rot, actor); + } + + if (limbEntry->firstChildIndex != 0xFF) + { + func_800A1344(globalCtx, limbEntry->firstChildIndex, limbTable, + actorDrawTable, updateMtxFunc, appendDlistFunc, actor); + } + + Matrix_Pull(); + + if (limbEntry->nextLimbIndex != 0xFF) + { + func_800A1344(globalCtx, limbEntry->nextLimbIndex, limbTable, + actorDrawTable, updateMtxFunc, appendDlistFunc, actor); + } + + func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x461); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A1344.s") +#endif + +#ifdef NON_MATCHING +void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) +{ + SkelLimbEntry* rootLimb; + Vec3s rot; + Vec3f pos; + Gfx* dList; + GraphicsContext* gfxCtx; + Gfx* gfx[5]; + + if (limbTable == NULL) + { + osSyncPrintf("\x1b[31m"); + osSyncPrintf("Si2_draw():skelがNULLです。\n"); // Si2_draw (): skel is NULL. + osSyncPrintf("\x1b[m"); + return; + } + + gfxCtx = globalCtx->state.gfxCtx; + + func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1148); + Matrix_Push(); + rootLimb = SEGMENTED_TO_VIRTUAL(*limbTable); + + pos.x = (f32) actorDrawTable[0].x; + pos.y = (f32) actorDrawTable[0].y; + pos.z = (f32) actorDrawTable[0].z; + + rot = actorDrawTable[1]; + dList = rootLimb->dList; + + if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList, &pos, &rot, actor) == 0)) + { + func_800D1340(&pos, &rot); + if (dList != NULL) + { + gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 1176), G_MTX_LOAD); + gSPDisplayList(gfxCtx->polyOpa.p++, dList); + } + } + + if (appendDlistFunc != NULL) + { + appendDlistFunc(globalCtx, 1, &dList, &rot, actor); + } + if (rootLimb->firstChildIndex != 0xFF) + { + func_800A1344(globalCtx, rootLimb->firstChildIndex, limbTable, + actorDrawTable, updateMtxFunc, appendDlistFunc, actor); + } + + Matrix_Pull(); + func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1190); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_Draw.s") +#endif + +#ifdef NON_MATCHING +// SkelAnime_Draw2Limb +void func_800A180C(GlobalContext *globalCtx, u32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, Mtx** limbMatricies) +{ + Gfx* limbDlist[2]; + Vec3f limbPos; + Vec3s limbRot; + GraphicsContext *gfxCtx; + Gfx* sp34[3]; + SkelLimbEntry* limbEntry; + + gfxCtx = globalCtx->state.gfxCtx; + func_800C6AC4(sp34, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x4BE); + Matrix_Push(); + limbEntry = SEGMENTED_TO_VIRTUAL(limbTable[limbIndex]); + limbRot = actorDrawTable[++limbIndex]; + + limbPos.x = (f32) limbEntry->pos.x; + limbPos.y = (f32) limbEntry->pos.y; + limbPos.z = (f32) limbEntry->pos.z; + + limbDlist[0] = limbEntry->dList; + limbDlist[1] = limbEntry->dList; + + if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &limbDlist[0], &limbPos, &limbRot, actor) == 0)) + { + func_800D1340(&limbPos, &limbRot); + if (limbDlist[0] != NULL) + { + Matrix_ToMtx(*limbMatricies, "../z_skelanime.c", 0x4DA); + gSPMatrix(gfxCtx->polyOpa.p++, *limbMatricies, G_MTX_LOAD); + gSPDisplayList(gfxCtx->polyOpa.p++, &limbDlist[0]); + (*limbMatricies)++; + } + else + { + if (&limbDlist[1] != 0) + { + Matrix_ToMtx(*limbMatricies, "../z_skelanime.c", 0x4E1); + (*limbMatricies)++; + } + } + } + + if (appendDlistFunc != NULL) + { + appendDlistFunc(globalCtx, limbIndex, &limbDlist[1], &limbRot, actor); + } + + if (limbEntry->firstChildIndex != 0xFF) + { + func_800A180C(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, limbMatricies); + } + + Matrix_Pull(); + + if (limbEntry->nextLimbIndex != 0xFF) + { + func_800A180C(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, + updateMtxFunc, appendDlistFunc, actor, limbMatricies); + } + func_800C6B54(sp34, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x4F1); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A180C.s") +#endif + +#ifdef NON_MATCHING +// SkelAnime_Draw2 +void func_800A1AC8(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, u32 dListCount, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) +{ + SkelLimbEntry *rootLimb; + Gfx* skelDlist[2]; + Vec3f pos; + Vec3s rot; + GraphicsContext* gfxCtx; + Mtx* limbMatricies; + Gfx *gfx[5]; + + limbMatricies = Graph_Alloc(globalCtx->state.gfxCtx, dListCount << 6); + + if (limbTable == NULL) + { + osSyncPrintf("\x1b[31m"); + osSyncPrintf("Si2_draw_SV():skelがNULLです。\n"); //Si2_draw_SV (): skel is NULL. + osSyncPrintf("\x1b[m"); + return; + } + + gfxCtx = globalCtx->state.gfxCtx; + + func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1294); + + gSPSegment(gfxCtx->polyOpa.p++, 0xD, limbMatricies); + Matrix_Push(); + rootLimb = SEGMENTED_TO_VIRTUAL(*limbTable); + + pos.x = (f32) actorDrawTable[0].x; + pos.y = (f32) actorDrawTable[0].y; + pos.z = (f32) actorDrawTable[0].z; + + rot = actorDrawTable[1]; + + skelDlist[0] = skelDlist[1] = rootLimb->dList; + if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &skelDlist[0], &pos, &rot, actor) == 0)) + { + func_800D1340(&pos, &rot); + if (skelDlist[0] != NULL) + { + Matrix_ToMtx(limbMatricies, "../z_skelanime.c", 1327); + gSPMatrix(gfxCtx->polyOpa.p++, limbMatricies, G_MTX_LOAD); + gSPDisplayList(gfxCtx->polyOpa.p++, skelDlist[0]); + limbMatricies++; + } + else + { + if (skelDlist[1] != 0) + { + Matrix_ToMtx(limbMatricies, "../z_skelanime.c", 1334); + limbMatricies++; + } + } + } + + if (appendDlistFunc != 0) + { + appendDlistFunc(globalCtx, 1, &skelDlist[1], &rot, actor); + } + + if (rootLimb->firstChildIndex != 0xFF) + { + func_800A180C(globalCtx, rootLimb->firstChildIndex, limbTable, actorDrawTable, + updateMtxFunc, appendDlistFunc, actor, &limbMatricies); + } + + Matrix_Pull(); + func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1347); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A1AC8.s") +#endif +#undef NON_MATCHING + +#ifdef NON_MATCHING +typedef struct +{ + s16 animFrameCount; + u32 rotationValuesSeg; + u32 actorDrawTableSeg; + s16 limit; +} AnimationHeader; + +typedef struct +{ + Vec3s pos; + Vec3s rotations[1]; +} RotationIndex; + +u16 func_800A1D8C(u32 animationSeg, s32 arg1, s32 arg2, Vec3s* arg3) +{ + s32 temp_s2; + s32 temp_s3; + s32 temp_s4; + u16 temp_v0_2; + u16 temp_v0_3; + u16 temp_v0_4; + void *temp_v0; + void *phi_s0; + void *phi_s1; + s32 phi_s4; + u16 phi_return; + AnimationHeader* animation; + Vec3s* rotationValues; + u32* limbTable; + u32 i; + + animation = SEGMENTED_TO_VIRTUAL(animationSeg); + rotationValues = SEGMENTED_TO_VIRTUAL(animation->rotationValuesSeg); + + phi_return = temp_v0; + for(i = 0;i < arg2; i++){ + } + if (arg2 > 0) + { + temp_s3 = (arg1 * 2) + temp_s2; + phi_s0 = arg3; + phi_s1 = (*(&gSegments + (((u32) (temp_v0->unk8 * 0x10) >> 0x1C) * 4)) + (temp_v0->unk8 & 0xFFFFFF)) + 0x80000000; + phi_s4 = 0; +loop_2: + if ((((phi_s0 == 0) || (phi_s1 == 0)) || (temp_s3 == 0)) || (temp_s2 == 0)) + { + LogUtils_LogThreadId("../z_skelanime.c", 0x570); + osSyncPrintf("out = %08x\n", phi_s0); + LogUtils_LogThreadId("../z_skelanime.c", 0x571); + osSyncPrintf("ref_tbl = %08x\n", phi_s1); + LogUtils_LogThreadId("../z_skelanime.c", 0x572); + osSyncPrintf("frame_tbl = %08x\n", temp_s3); + LogUtils_LogThreadId("../z_skelanime.c", 0x573); + osSyncPrintf("tbl = %08x\n", temp_s2); + } + else + { + + } + temp_v0_2 = phi_s1->unk0; + temp_s4 = phi_s4 + 1; + if (temp_v0_2 >= temp_v0->unkC) + { + phi_s0->unk0 = (s16) *(temp_s3 + (temp_v0_2 * 2)); + } + else + { + phi_s0->unk0 = (s16) *(temp_s2 + (temp_v0_2 * 2)); + } + temp_v0_3 = phi_s1->unk2; + if (temp_v0_3 >= temp_v0->unkC) + { + phi_s0->unk2 = (s16) *(temp_s3 + (temp_v0_3 * 2)); + } + else + { + phi_s0->unk2 = (s16) *(temp_s2 + (temp_v0_3 * 2)); + } + temp_v0_4 = phi_s1->unk4; + if (temp_v0_4 >= temp_v0->unkC) + { + phi_s0->unk4 = (s16) *(temp_s3 + (temp_v0_4 * 2)); + } + else + { + phi_s0->unk4 = (s16) *(temp_s2 + (temp_v0_4 * 2)); + } + phi_s0 = phi_s0 + 6; + phi_s1 = phi_s1 + 6; + phi_s4 = temp_s4; + phi_return = temp_v0_4; + if (temp_s4 != arg2) + { + goto loop_2; + } + } + return phi_return; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A1D8C.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A1FC8.s") +s32 func_800A1FC8(s32 arg0) +{ + u16* virt = (u16*)SEGMENTED_TO_VIRTUAL(arg0); + return (s16)(*virt); +} s32 SkelAnime_GetFrameCount(u32 animation) { @@ -40,23 +488,93 @@ s32 SkelAnime_GetFrameCount(u32 animation) #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A29BC.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A2DBC.s") +s16 func_800A2DBC(s32 arg0) +{ + u16* virt = SEGMENTED_TO_VIRTUAL(arg0); + + return virt[1]; +} + +s16 func_800A2DF4(s32 arg0) +{ + u16* virt = SEGMENTED_TO_VIRTUAL(arg0); + + return *virt; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A2DF4.s") +s32 func_800A2E2C(s32 arg0){ + s16* virt = SEGMENTED_TO_VIRTUAL(arg0); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A2E2C.s") + return (s16)(*virt - 1); +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A2E70.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A32EC.s") +void func_800A32EC(u16* arg0) +{ + *arg0 = 0; +} + +void func_800A32F4(s32 arg0) +{ + D_801600B0 *= 2; +} + +void func_800A3310(void* arg0) +{ + u32* D_8012A480Ptr = &D_8012A480; + + *D_8012A480Ptr |= D_801600B0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A32F4.s") +AnimationEntry* func_800A3334(AnimationContext* animationCtx, s32 arg1) +{ + AnimationEntry *entry; + s16 index = animationCtx->animationCount; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3310.s") + if (index >= 0x32) + { + return NULL; + } + animationCtx->animationCount = index + 1; + entry = &animationCtx->entries[index]; + entry->unk_00 = arg1; + return entry; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3334.s") +#ifdef NON_MATCHING +typedef struct +{ + u32 unk_00; + u32 rom; +} anim; +void func_800A336C(GlobalContext* globalCtx, s32 arg1, s32 arg2, s32 limbCount, void* ram) +{ + s32 sp3C; + anim *sp38; + s32 sp30; + OSMesgQueue temp_a0; + s32 temp_a3; + s32 temp_at; + AnimationEntry* temp_ret; + DmaRequest req; + + temp_ret = func_800A3334(&globalCtx->animationCtx, 0); + if (temp_ret != NULL) + { + temp_a0 = temp_ret->msgQueue; + sp38 = SEGMENTED_TO_VIRTUAL(arg1); + sp3C = temp_ret; + osCreateMesgQueue(temp_ret, &temp_ret->msg, 1); + temp_a3 = sizeof(Vec3s) * limbCount; + DmaMgr_SendRequest2(&req, ram, ((sp38->rom + (u32)&_link_animetionSegmentRomStart) - 0x7000000) + (temp_a3 * arg2), temp_a3, 0, &temp_ret->msgQueue, NULL, "../z_skelanime.c" , 0x7D4); + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A336C.s") +#endif +#undef NON_MATCHING #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3478.s") @@ -83,7 +601,7 @@ typedef struct { SkelAnime* skelAnime; f32 unk_8; } UNK_800A3874_A1; -void func_800A54FC(SkelAnime*,Vec3f*,s16); + void func_800A3874(s32 arg0, UNK_800A3874_A1* arg1) { char pad[4]; @@ -96,168 +614,868 @@ void func_800A3874(s32 arg0, UNK_800A3874_A1* arg1) temp_v0->posRot.pos.z += pos.z * temp_v0->scale.z; } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A390C.s") +void func_800A390C(GlobalContext* globalCtx, AnimationContext* animationCtx) +{ + AnimationEntry* entry; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A39AC.s") + for(entry = animationCtx->entries; animationCtx->animationCount != 0; entry++, animationCtx->animationCount--) + { + D_8012A484[entry->unk_00](globalCtx, entry->unk_04); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3B8C.s") + D_801600B0 = 1; + D_8012A480 = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3BC0.s") +#ifdef NON_MATCHING +// some kind of init +void func_800A3F08(GlobalContext*,SkelAnime*,s32,f32,f32,f32,s8,f32); +void func_800A39AC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 skelAnimeInitSeg, s32 arg3, s8 arg4, Vec3s* actorDrawTable, s32 arg6, s32 arg7) +{ + SkelAnimeInit* skelAnimeInit; + u8 flag; + size_t size; + + skelAnimeInit = SEGMENTED_TO_VIRTUAL(skelAnimeInitSeg); + skelAnime->unk_34 = arg4; + flag = arg4 & 2 == 0 ? 1U : skelAnimeInit->limbCount; + if ((arg4 & 2) != 0) + { + flag = skelAnimeInit->limbCount; + } + else + { + flag = 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3BE4.s") + if((arg4 & 1) != 0) + { + flag += skelAnimeInit->limbCount; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3C9C.s") + if((arg4 & 4) != 0) + { + flag += skelAnimeInit->limbCount; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3D70.s") + skelAnime->limbCount = flag; + skelAnime->dListCount = skelAnimeInit->dListCount; + skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(skelAnimeInit->limbIndexSeg); + size = sizeof(Vec3s); + if ((arg4 & 8) != 0) + { + size += 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3E0C.s") + if (actorDrawTable == NULL) + { + skelAnime->actorDrawTbl = ZeldaArena_MallocDebug(size, "../z_skelanime.c", 2364); + skelAnime->unk_24 = ZeldaArena_MallocDebug(size, "../z_skelanime.c", 2365); + } + else + { + if (arg7 != flag) + { + __assert("joint_buff_num == joint_num", "../z_skelanime.c", 2369); + } + skelAnime->actorDrawTbl = ALIGN16((u32)actorDrawTable); + skelAnime->unk_24 = ALIGN16(arg6); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3EE8.s") + } + if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) + { + osSyncPrintf("\x1b[31m"); + osSyncPrintf("Skeleton_Info_Rom_SV_ct メモリアロケーションエラー\n"); //Skeleton_Info_Rom_SV_ct Memory allocation error + osSyncPrintf("\x1b[m"); + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3F08.s") + func_800A3F08(globalCtx, skelAnime, arg3, 1.0f, 0.0f, 0.0f, 0, 0.0f); +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A39AC.s") +#endif +#undef NON_MATCHING -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A407C.s") +void func_800A3B8C(SkelAnime* skelAnime) +{ + if (skelAnime->unk_01 < 2) + { + skelAnime->mtxUpdate = &func_800A3D70; + } + else + { + skelAnime->mtxUpdate = &func_800A3E0C; + } + skelAnime->unk_28 = 0.0f; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A40DC.s") +//SkelAnime_FrameUpdateMatrixGlobalCtx +void func_800A3BC0(GlobalContext* globalCtx, SkelAnime* skelAnime) +{ + skelAnime->mtxUpdate(globalCtx, skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4140.s") +#ifdef NON_MATCHING +s32 func_800A3BE4(GlobalContext* globalCtx, SkelAnime* skelAnime) +{ + f32 prevUnk28 = skelAnime->unk_28; + skelAnime->unk_28 -= skelAnime->unk_2C * (R_UPDATE_RATE * 0.5f); + if (skelAnime->unk_28 <= 0.0f) + { + func_800A3B8C(skelAnime); + } + func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, 1.0f - (skelAnime->unk_28 / prevUnk28)); + return 0; +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3BE4.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A419C.s") +void func_800A3C9C(GlobalContext* globalCtx, SkelAnime* skelAnime) +{ + f32 updateRate; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A41FC.s") + func_800A336C(globalCtx, skelAnime->animCurrent, skelAnime->animCurrentFrame, skelAnime->limbCount, skelAnime->actorDrawTbl); + if (skelAnime->unk_28 != 0) + { + updateRate = R_UPDATE_RATE * 0.5f; + skelAnime->unk_28 -= skelAnime->unk_2C * updateRate; + if (skelAnime->unk_28 <= 0.0f) + { + skelAnime->unk_28 = 0.0f; + return; + } + func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, skelAnime->unk_28); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A422C.s") +s32 func_800A3D70(GlobalContext* globalCtx, SkelAnime* skelAnime) +{ + f32 updateRate = R_UPDATE_RATE * 0.5f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A425C.s") + skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate; + if (skelAnime->animCurrentFrame < 0.0f) + { + skelAnime->animCurrentFrame += skelAnime->unk_14; + } + else + { + if (skelAnime->unk_14 <= skelAnime->animCurrentFrame){ + skelAnime->animCurrentFrame -= skelAnime->unk_14; + } + } + func_800A3C9C(globalCtx, skelAnime); + return 0; +} + +// returns 1 if animation is done? +s32 func_800A3E0C(GlobalContext* globalCtx, SkelAnime* skelAnime) +{ + f32 updateRate = R_UPDATE_RATE * 0.5f; + + if (skelAnime->animCurrentFrame == skelAnime->animFrameCount) + { + func_800A3C9C(globalCtx, skelAnime); + return 1; + } + skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate; + if (0.0f < ((skelAnime->animCurrentFrame - skelAnime->animFrameCount) * skelAnime->animPlaybackSpeed)) + { + skelAnime->animCurrentFrame = skelAnime->animFrameCount; + } + else + { + if (skelAnime->animCurrentFrame < 0.0f) + { + skelAnime->animCurrentFrame += skelAnime->unk_14; + } + else + { + if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) + { + skelAnime->animCurrentFrame -= skelAnime->unk_14; + } + } + } + func_800A3C9C(globalCtx, skelAnime); + return 0; +} + + +void func_800A3EE8(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 arg2) +{ + skelAnime->unk_28 = 1.0f; + skelAnime->unk_2C = 1.0f / arg2; +} + +s32 func_800A3BE4(GlobalContext* globalCtx, SkelAnime* skelAnime); +void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 arg4, f32 frameCount, u8 arg6, f32 arg7); +#ifdef NON_MATCHING +void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 arg4, f32 frameCount, u8 arg6, f32 arg7) +{ + + skelAnime->unk_01 = arg6; + if ((arg7 != 0.0f) && + ((animation == skelAnime->animCurrent) || (arg4 != skelAnime->animCurrentFrame))) + { + if(arg7 < 0.0f) + { + func_800A3B8C(skelAnime); + func_800A5774(skelAnime, skelAnime->unk_24, skelAnime->actorDrawTbl); + arg7 = -arg7; + } + else + { + skelAnime->mtxUpdate = &func_800A3BE4; + func_800A336C(globalCtx, animation, (s32) arg4, skelAnime->limbCount, skelAnime->unk_24); + } + skelAnime->unk_28 = 1.0f; + skelAnime->unk_2C = 1.0f / arg7; + } + else + { + func_800A3B8C(skelAnime); + func_800A336C(globalCtx, animation, (s32) arg4, skelAnime->limbCount, skelAnime->actorDrawTbl); + skelAnime->unk_28 = 0.0f; + } + + skelAnime->animCurrentFrame = animation; + skelAnime->unk_0C = arg4; + skelAnime->animCurrentFrame = arg4; + skelAnime->animFrameCount = frameCount; + skelAnime->unk_14 = func_800A1FC8(animation); + skelAnime->animPlaybackSpeed = playbackSpeed; +} +#else +#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3F08.s") +#endif +#undef NON_MATCHING + +void func_800A407C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation) +{ + func_800A3F08(globalCtx, skelAnime, animation, 1.0f, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 2, 0.0f); +} + +void func_800A40DC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) +{ + func_800A3F08(globalCtx, skelAnime, animation, playbackSpeed, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 2, 0.0f); +} + +void func_800A4140(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation) +{ + func_800A3F08(globalCtx, skelAnime, animation, 1.0f, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 0, 0.0f); +} + +void func_800A419C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) +{ + func_800A3F08(globalCtx, skelAnime, animation, playbackSpeed, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 0, 0.0f); +} + +void func_800A3478(GlobalContext*,u8,Vec3s*,Vec3s*); +void func_800A41FC(GlobalContext* globalCtx, SkelAnime* skelAnime) +{ + func_800A3478(globalCtx, skelAnime->limbCount, skelAnime->unk_24, skelAnime->actorDrawTbl); +} + +void func_800A422C(GlobalContext* globalCtx, SkelAnime* skelAnime) +{ + func_800A3478(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A42A0.s") +void func_800A425C(GlobalContext* globalCtx, SkelAnime* skelAnime, s32 arg2, f32 arg3) +{ + func_800A336C(globalCtx, arg2, (s32) arg3, skelAnime->limbCount, skelAnime->unk_24); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A42E4.s") +void func_800A42A0(GlobalContext* globalCtx, SkelAnime* skelAnime, s32 arg2, f32 arg3) +{ + func_800A336C(globalCtx, arg2, (s32) arg3, skelAnime->limbCount, skelAnime->actorDrawTbl); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A431C.s") +void func_800A42E4(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 arg2) +{ + func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, arg2); +} + +void func_800A431C(GlobalContext* globalCtx, SkelAnime* skelAnime, s32 arg2, f32 arg3, s32 arg4, f32 arg5, f32 arg6, s32 arg7) +{ + s32 alignedAddr; + func_800A336C(globalCtx, arg2, (s32) arg3, skelAnime->limbCount, skelAnime->actorDrawTbl); + alignedAddr = ALIGN16(arg7); + + func_800A336C(globalCtx, arg4, (s32) arg5, skelAnime->limbCount, alignedAddr); + func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, alignedAddr, arg6); +} + +#ifdef NON_MATCHING +void func_800A43B8(s32 arg0, void *arg1, ? arg2, f32 arg3, s32 arg4, f32 arg5, f32 arg6, s32 arg7) +{ + s32 sp28; + s32 temp_v0; + + func_800A336C(arg3, arg2, (s32) arg3, arg1->unk0, (s32) arg1->unk24); + temp_v0 = (arg7 + 0xF) & -0x10; + sp28 = temp_v0; + func_800A336C(arg0, arg4, (s32) arg5, arg1->unk0, temp_v0); + func_800A34DC(arg0, arg1->unk0, arg1->unk24, sp28, arg6); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A43B8.s") +#endif + +void func_800A4454(SkelAnime* skelAnime) +{ + skelAnime->unk_01 = 2; + func_800A3B8C(skelAnime); +} + + +s32 func_800A4478(SkelAnime* skelAnime, f32 arg1, f32 updateRate) +{ + f32 temp_f0; + f32 temp_f12; + f32 temp_f2; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4454.s") + temp_f0 = skelAnime->animPlaybackSpeed * updateRate; + temp_f2 = skelAnime->animCurrentFrame - temp_f0; + if (temp_f2 < 0.0f) + { + temp_f2 += skelAnime->unk_14; + } + else + { + temp_f2 = temp_f2; + if (skelAnime->unk_14 <= temp_f2) + { + temp_f2 = temp_f2 - skelAnime->unk_14; + } + } + if (arg1 == 0.0f) + { + if (0.0f < temp_f0) + { + arg1 = skelAnime->unk_14; + } + } + temp_f12 = (temp_f2 + temp_f0) - arg1; + if (0.0f <= (temp_f12 * temp_f0)) + { + if (((temp_f12 - temp_f0) * temp_f0) < 0.0f) + { + return 1; + } + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4478.s") +s32 func_800A4530(SkelAnime* skelAnime, f32 arg1) +{ + f32 updateRate = R_UPDATE_RATE * 0.5f; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4530.s") + return func_800A4478(skelAnime, arg1, updateRate); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_Init.s") +void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 skelAnimeInitSeg, u32 animation, Vec3s* actorDrawTable, s32 arg5, s32 limbCount) +{ + SkelAnimeInit* skelAnimeInit; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A46F8.s") + skelAnimeInit = SEGMENTED_TO_VIRTUAL(skelAnimeInitSeg); + skelAnime->limbCount = skelAnimeInit->limbCount + 1; + skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(skelAnimeInit->limbIndexSeg); + if (actorDrawTable == NULL) + { + skelAnime->actorDrawTbl = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), "../z_skelanime.c", 2968); + skelAnime->unk_24 = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->unk_24), "../z_skelanime.c", 2969); + } + else + { + if (limbCount != skelAnime->limbCount) + { + __assert("joint_buff_num == this->joint_num", "../z_skelanime.c", 2973); + } + skelAnime->actorDrawTbl = actorDrawTable; + skelAnime->unk_24 = arg5; + } + if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) + { + osSyncPrintf("\x1b[31m"); + osSyncPrintf("Skeleton_Info2_ct メモリアロケーションエラー\n"); // Skeleton_Info2_ct memory allocation error + osSyncPrintf("\x1b[m"); + } + + if (animation != 0) + { + func_800A52F8(skelAnime, animation); + } +} + +// another init +void func_800A46F8(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 skelAnimeInitSeg, u32 animation, Vec3s* actorDrawTable, s32 arg5, s32 limbCount) +{ + SkelAnimeInit *skelAnimeInit; + + skelAnimeInit = SEGMENTED_TO_VIRTUAL(skelAnimeInitSeg); + skelAnime->limbCount = skelAnimeInit->limbCount + 1; + skelAnime->dListCount = skelAnimeInit->dListCount; + skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(skelAnimeInit->limbIndexSeg); + + if (actorDrawTable == NULL) + { + skelAnime->actorDrawTbl = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), "../z_skelanime.c", 3047); + skelAnime->unk_24 = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->unk_24), "../z_skelanime.c", 3048); + } + else + { + if (limbCount != skelAnime->limbCount) + { + __assert("joint_buff_num == this->joint_num", "../z_skelanime.c", 0xBEC); + } + skelAnime->actorDrawTbl = actorDrawTable; + skelAnime->unk_24 = arg5; + } + if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) + { + osSyncPrintf("\x1b[31m"); + osSyncPrintf("Skeleton_Info_Rom_SV_ct メモリアロケーションエラー\n"); // Skeleton_Info_Rom_SV_ct Memory allocation error + osSyncPrintf("\x1b[m"); + } + + if (animation != 0) + { + func_800A52F8(skelAnime, animation); + } +} + +// some kind of init +void func_800A487C(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 skelAnimeInitSeg, u32 animation) +{ + SkelAnimeInit *skelAnimeInit; + + skelAnimeInit = SEGMENTED_TO_VIRTUAL(skelAnimeInitSeg); + skelAnime->limbCount = skelAnimeInit->limbCount + 1; + skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(skelAnimeInit->limbIndexSeg); + skelAnime->actorDrawTbl = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), "../z_skelanime.c", 3120); + skelAnime->unk_24 = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->unk_24), "../z_skelanime.c", 3121); + if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) + { + osSyncPrintf("\x1b[31m"); + osSyncPrintf("Skeleton_Info2_skin2_ct メモリアロケーションエラー\n"); //Skeleton_Info2_skin2_ct Memory allocation error + osSyncPrintf("\x1b[m"); + } + + if (animation != 0) + { + func_800A52F8(skelAnime, animation); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A487C.s") +void func_800A49B0(SkelAnime* skelAnime) +{ + if (skelAnime->unk_01 < 2) + { + skelAnime->mtxUpdate = &func_800A4D9C; + return; + } + if (skelAnime->unk_01 < 4) + { + skelAnime->mtxUpdate = &func_800A4EE0; + return; + } + skelAnime->mtxUpdate = &func_800A4E38; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A49B0.s") s32 SkelAnime_FrameUpdateMatrix(SkelAnime* skelAnime){ return skelAnime->mtxUpdate(skelAnime); } +#ifdef NON_MATCHING +s32 func_800A4A20(SkelAnime* skelAnime) +{ + f32 sp2C; + f32 temp_f12; + f32 phi_f0; + + temp_f12 = skelAnime->unk_28; + skelAnime->unk_28 -= skelAnime->unk_2C * (R_UPDATE_RATE * 0.33333334f); + phi_f0 = skelAnime->unk_28; + if (skelAnime->unk_28 <= 0.0f) + { + sp2C = temp_f12; + func_800A49B0(skelAnime); + skelAnime->unk_28 = 0.0f; + phi_f0 = skelAnime->unk_28; + } + func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, skelAnime->unk_24, 1.0f - (phi_f0 / temp_f12)); + return 0; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4A20.s") +#endif +#ifdef NON_MATCHING +s32 func_800A4AD8(SkelAnime* skelAnime) +{ + f32 sp28; + s16 temp_a1; + s16 temp_a2; + f32 phi_f2; + + temp_a2 = (s16)(skelAnime->unk_28 * 16384.0f); + skelAnime->unk_28 -= skelAnime->unk_2C * (R_UPDATE_RATE * 0.33333334f); + if (skelAnime->unk_28 <= 0.0f) + { + func_800A49B0(skelAnime); + skelAnime->unk_28 = 0.0f; + } + temp_a1 = (s16)(skelAnime->unk_28 * 16384.0f); + if (skelAnime->unk_03 < 0) + { + sp28 = 1.0f - Math_Coss(temp_a2); + phi_f2 = 1.0f - Math_Coss(temp_a1); + } + else + { + sp28 = Math_Sins(temp_a2); + phi_f2 = Math_Sins(temp_a1); + } + if (phi_f2 != 0.0f) + { + phi_f2 /= sp28; + } + else + { + phi_f2 = 0.0f; + } + func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, skelAnime->unk_24, 1.0f - phi_f2); + return 0; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4AD8.s") +#endif +#ifdef NON_MATCHING +// close +void func_800A4C58(SkelAnime* skelAnime) +{ + Vec3s sp38[98]; + f32 temp_f0; + f32 temp_f2; + s32 temp_f10; + s32 temp_f8; + + func_800A1D8C(skelAnime->animCurrent, (s32) skelAnime->animPlaybackSpeed, skelAnime->limbCount, skelAnime->actorDrawTbl); + if ((skelAnime->unk_01 & 1) != 0) + { + temp_f8 = (s32) skelAnime->animCurrentFrame; + temp_f10 = temp_f8; + temp_f8 = temp_f8 + 1; + temp_f2 = skelAnime->animCurrentFrame - (f32) temp_f10; + if (temp_f8 >= (s32) skelAnime->unk_14) + { + temp_f8 = 0; + } + func_800A1D8C(skelAnime->animCurrent, temp_f8, skelAnime->limbCount, sp38); + func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, &sp38, temp_f2); + } + if (0.0f != skelAnime->unk_28) + { + skelAnime->unk_28 -= skelAnime->unk_2C * (R_UPDATE_RATE * 0.33333334f); + temp_f0 = skelAnime->unk_28; + if (temp_f0 <= 0.0f) + { + skelAnime->unk_28 = 0.0f; + return; + } + func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, skelAnime->unk_24, skelAnime->unk_28); + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4C58.s") +#endif +#undef NON_MATCHING +#ifdef NON_MATCHING +//reg alloc +s32 func_800A4D9C(SkelAnime* skelAnime) +{ + skelAnime->animCurrentFrame += (R_UPDATE_RATE * 0.33333334f) + skelAnime->animPlaybackSpeed; + if (skelAnime->animCurrentFrame < 0.0f) + { + skelAnime->animCurrentFrame += skelAnime->unk_14; + } + else if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) + { + skelAnime->animCurrentFrame -= skelAnime->unk_14; + } + func_800A4C58(skelAnime); + return 0; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4D9C.s") +#endif +#undef NON_MATCHING +#ifdef NON_MATCHING +//reg alloc +s32 func_800A4E38(SkelAnime* skelAnime) +{ + skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * (R_UPDATE_RATE * 0.33333334f); + if (skelAnime->animCurrentFrame < skelAnime->unk_0C) + { + skelAnime->animCurrentFrame = (skelAnime->animCurrentFrame - skelAnime->unk_0C) + skelAnime->animFrameCount; + } + else + { + if (skelAnime->animFrameCount <= skelAnime->animCurrentFrame) + { + skelAnime->animCurrentFrame = (skelAnime->animCurrentFrame - skelAnime->animFrameCount) + skelAnime->unk_0C; + } + } + func_800A4C58(skelAnime); + return 0; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4E38.s") +#endif +#undef NON_MATCHING -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4EE0.s") +s32 func_800A4EE0(SkelAnime *skelAnime) +{ + f32 temp_f14; + temp_f14 = (f32) R_UPDATE_RATE * 0.33333334f; + if (skelAnime->animCurrentFrame == skelAnime->animFrameCount) + { + + func_800A1D8C(skelAnime->animCurrent, (s32)skelAnime->animCurrentFrame, skelAnime->limbCount, skelAnime->actorDrawTbl); + func_800A4C58(skelAnime); + return 1; + } + skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * temp_f14; + if (0.0f < ((skelAnime->animCurrentFrame - skelAnime->animFrameCount) * skelAnime->animPlaybackSpeed)) + { + skelAnime->animCurrentFrame = skelAnime->animFrameCount; + } + else + { + if (skelAnime->animCurrentFrame < 0.0f) + { + skelAnime->animCurrentFrame += skelAnime->unk_14; + } + else + { + if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) + { + skelAnime->animCurrentFrame -= skelAnime->unk_14; + } + } + } + func_800A4C58(skelAnime); + return 0; +} + +#ifdef NON_MATCHING +// close some regalloc, missing move zero fpr +s32 func_800A4AD8(SkelAnime* skelAnime); +s32 func_800A4A20(SkelAnime* skelAnime); +void func_800A1D8C(u32,s32,u8,Vec3s*); +void func_800A4FE4(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 unk0, f32 frameCount, u8 unk1, f32 transitionRate, s8 unk2) +{ + skelAnime->unk_01 = unk1; + if ((transitionRate != 0.0f) && + ((animation != skelAnime->animCurrent) || (unk0 != skelAnime->animCurrentFrame))) + { + if (transitionRate < 0.0f) + { + func_800A49B0(skelAnime); + func_800A5774(skelAnime, skelAnime->unk_24, skelAnime->actorDrawTbl); + transitionRate = -transitionRate; + } + else + { + if (unk2 != 0) + { + skelAnime->mtxUpdate = (void*)&func_800A4AD8; + skelAnime->unk_03 = unk2; + } + else + { + skelAnime->mtxUpdate = (void*)&func_800A4A20; + } + func_800A1D8C(animation, (s32)unk0, skelAnime->limbCount, skelAnime->actorDrawTbl); + } + skelAnime->unk_28 = 1.0f; + skelAnime->unk_2C = 1.0f / transitionRate; + } + else + { + func_800A49B0(skelAnime); + func_800A1D8C(animation, (s32)unk0, skelAnime->limbCount, skelAnime->actorDrawTbl); + skelAnime->unk_28 = 0.0f; + } + + skelAnime->animCurrent = animation; + skelAnime->unk_0C = unk0; + skelAnime->animFrameCount = frameCount; + skelAnime->unk_14 = (f32) func_800A1FC8(animation); + if (skelAnime->unk_01 >= 4) + { + skelAnime->animCurrentFrame = 0.0f; + } + else + { + skelAnime->animCurrentFrame = unk0; + if (skelAnime->unk_01 < 2) + { + skelAnime->animFrameCount = skelAnime->unk_14 - 1.0f; + } + } + skelAnime->animPlaybackSpeed = playbackSpeed; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4FE4.s") +#endif +#undef NON_MATCHING void SkelAnime_ChangeAnimation(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 unk0, /* 0x10 */ f32 frameCount, /* 0x14 */ u8 unk1, /* 0x18 */ f32 transitionRate) { func_800A4FE4(skelAnime, animation, playbackSpeed, unk0, frameCount, unk1, transitionRate, 0); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A51E8.s") +void func_800A51E8(SkelAnime* skelAnime, u32 animation) +{ + SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 2, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A5240.s") +void func_800A5240(SkelAnime* skelAnime, u32 animation, f32 transitionRate) +{ + SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0, (f32) SkelAnime_GetFrameCount(animation), 2, transitionRate); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A529C.s") +void func_800A529C(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) +{ + SkelAnime_ChangeAnimation(skelAnime, animation, playbackSpeed, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 2, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A52F8.s") +// SkelAnime_ChangeAnimationDefault +void func_800A52F8(SkelAnime* skelAnime, u32 animation) +{ + SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 0, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A534C.s") +// SkelAnime_ChangeAnimationTransitionRate +void func_800A534C(SkelAnime* skelAnime, u32 animation, f32 transitionRate) +{ + SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, 0.0f, 0, transitionRate); +} + +//SkelAnime_ChangeAnimationPlaybackSpeed +void func_800A5384(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) +{ + SkelAnime_ChangeAnimation(skelAnime, animation, playbackSpeed, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 0, 0.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A5384.s") +void func_800A53DC(SkelAnime* skelAnime) +{ + skelAnime->unk_01 = 2; + skelAnime->animFrameCount = skelAnime->unk_14; + func_800A49B0(skelAnime); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A53DC.s") +#ifdef NON_MATCHING +// regalloc +void func_800A5408(SkelAnime* skelAnime) +{ + f32 animPlaybackSpeed = skelAnime->animPlaybackSpeed; + f32 unk_C = skelAnime->unk_0C; + f32 frameCount = skelAnime->animFrameCount; + skelAnime->animFrameCount = unk_C; + skelAnime->animPlaybackSpeed = -animPlaybackSpeed; + skelAnime->unk_0C = frameCount; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A5408.s") +#endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A5428.s") +void func_800A5428(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* arg3) +{ + s32 i; + for(i = 0; i < skelAnime->limbCount; i++, dst++, src++) + { + if(*arg3++) + { + *dst = *src; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A5490.s") +void func_800A5490(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* arg3) +{ + s32 i; + for(i = 0;i < skelAnime->limbCount; i++, dst++, src++) + { + if(*arg3++ < 1U){ + *dst = *src; + } + } +} -#ifdef NON_MATCHING void func_800A54FC(SkelAnime* skelAnime, Vec3f* pos, s16 angle) { - f32 temp_f20; - f32 temp_f20_2; - f32 temp_f22; - f32 temp_f22_2; - f32 temp_f24; - f32 temp_f24_2; - f32 temp_ret; - f32 temp_ret_2; + f32 x; + f32 z; + f32 sin; + f32 cos; - if ((skelAnime->unk_35 & 0x10) != 0) + if((skelAnime->unk_35 & 0x10) != 0) { pos->z = 0.0f; pos->x = 0.0f; } else { - - temp_f20 = (f32) *(s16*)(skelAnime->actorDrawTbl); - temp_f22 = (f32) ((s16*)skelAnime->actorDrawTbl)[2]; - temp_f24 = Math_Sins(angle); - temp_ret = Math_Coss(angle); - pos->x = (f32) ((temp_f20 * temp_ret) + (temp_f22 * temp_f24)); - pos->z = (f32) ((temp_f22 * temp_ret) - (temp_f20 * temp_f24)); - temp_f20_2 = (f32) skelAnime->unk_38; - temp_f22_2 = (f32) skelAnime->unk_3C; - temp_f24_2 = Math_Sins(skelAnime->unk_36); - temp_ret_2 = Math_Coss(skelAnime->unk_36); - pos->x -= ((temp_f20_2 * temp_ret_2) + (temp_f22_2 * temp_f24_2)); - pos->z -= ((temp_f22_2 * temp_ret_2) - (temp_f20_2 * temp_f24_2)); - //arg1->unk0 = (f32) (arg1->unk0 - ((temp_f20_2 * temp_ret_2) + (temp_f22_2 * temp_f24_2))); - //arg1->unk8 = (f32) (arg1->unk8 - ((temp_f22_2 * temp_ret_2) - (temp_f20_2 * temp_f24_2))); + x = (f32)skelAnime->actorDrawTbl->x; + z = (f32)skelAnime->actorDrawTbl->z; + sin = Math_Sins(angle); + cos = Math_Coss(angle); + pos->x = x * cos + z * sin; + pos->z = z * cos - x * sin; + x = (f32)skelAnime->unk_38; + z = (f32)skelAnime->unk_3C; + sin = Math_Sins(skelAnime->unk_36); + cos = Math_Coss(skelAnime->unk_36); + pos->x -= x * cos + z * sin; + pos->z -= z * cos - x * sin; } + skelAnime->unk_36 = angle; - skelAnime->unk_38 = *(s16*)(skelAnime->actorDrawTbl); - *(s16*)(skelAnime->actorDrawTbl) = skelAnime->unk_3E; - skelAnime->unk_3C = ((s16*)skelAnime->actorDrawTbl)[2]; - ((s16*)skelAnime->actorDrawTbl)[2] = skelAnime->unk_42; - if ((skelAnime->unk_35 & 2) != 0) + skelAnime->unk_38 = skelAnime->actorDrawTbl->x; + skelAnime->actorDrawTbl->x = skelAnime->unk_3E; + skelAnime->unk_3C = skelAnime->actorDrawTbl->z; + skelAnime->actorDrawTbl->z = skelAnime->unk_42; + if((skelAnime->unk_35 & 2) != 0) { - if ((skelAnime->unk_35 & 0x10) != 0) + if((skelAnime->unk_35 & 0x10) != 0) { pos->y = 0.0f; } else { - pos->y = (f32) ((s16*)skelAnime->actorDrawTbl)[1]; + pos->y = (f32)(skelAnime->actorDrawTbl->y - skelAnime->unk_3A); } - skelAnime->unk_3A = ((s16*)skelAnime->actorDrawTbl)[1]; - ((s16*)skelAnime->actorDrawTbl)[1] = skelAnime->unk_40; + skelAnime->unk_3A = skelAnime->actorDrawTbl->y; + skelAnime->actorDrawTbl->y = skelAnime->unk_40; } else { pos->y = 0.0f; - skelAnime->unk_3A = ((s16*)skelAnime->actorDrawTbl)[1]; + skelAnime->unk_3A = skelAnime->actorDrawTbl->y; } skelAnime->unk_35 &= ~0x10; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A54FC.s") -#endif s32 func_800A56C8(SkelAnime *skelAnime, f32 arg1) { @@ -266,7 +1484,7 @@ s32 func_800A56C8(SkelAnime *skelAnime, f32 arg1) void func_800A56F0(SkelAnime *skelAnime, s32 arg1) { - if (skelAnime->actorDrawTbl != 0) + if (skelAnime->actorDrawTbl != NULL) { ZeldaArena_FreeDebug(skelAnime->actorDrawTbl, "../z_skelanime.c", 3729); } @@ -274,7 +1492,7 @@ void func_800A56F0(SkelAnime *skelAnime, s32 arg1) { osSyncPrintf("now_joint あきまへん!!\n"); // now_joint Akimane! ! } - if (skelAnime->unk_24 != 0) + if (skelAnime->unk_24 != NULL) { ZeldaArena_FreeDebug(skelAnime->unk_24, "../z_skelanime.c", 3731); return; -- cgit v1.2.3 From 96ba073f198482e37349b1e7a77935e7f26ae3a5 Mon Sep 17 00:00:00 2001 From: KrimtonZ Date: Fri, 20 Mar 2020 21:51:12 -0500 Subject: skelanime, wip --- src/code/z_skelanime.c | 218 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 203 insertions(+), 15 deletions(-) (limited to 'src/code') diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index cf13a38c1..ada66eed0 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -39,15 +39,15 @@ static testfunc D_8012A484[] = //.bss u32 D_801600B0; -#ifdef NON_MATCHING -void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 arg7) +// SkelAnime_LodDrawLimb +void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) { - GraphicsContext* gfxCtx; - Gfx* gfx[3]; SkelLimbEntry* limbEntry; - Vec3s rot; - Vec3f pos; Gfx* dList; + Vec3f pos; + Vec3s rot; + GraphicsContext* gfxCtx; + Gfx* gfx[4]; gfxCtx = globalCtx->state.gfxCtx; func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 773); @@ -60,14 +60,20 @@ void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec pos.y = limbEntry->pos.y; pos.z = limbEntry->pos.z; - dList = &limbEntry->dList[arg7]; + dList = limbEntry->displayLists[dListIndex]; if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList, &pos, &rot, actor) == 0)) { func_800D1340(&pos, &rot); if (dList != NULL) { - gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(gfxCtx, "../z_skelanime.c", 0x325), G_MTX_LOAD); - gSPDisplayList(gfxCtx->polyOpa.p++, dList); + do + { + if(1) + { + gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 0x325), G_MTX_LOAD); + gSPDisplayList(gfxCtx->polyOpa.p++, dList); + } + } while(0); } } @@ -78,27 +84,209 @@ void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec if (limbEntry->firstChildIndex != 0xFF) { - func_800A08A0(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, arg7); + func_800A08A0(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex); } Matrix_Pull(); if (limbEntry->nextLimbIndex != 0xFF) { - func_800A08A0(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, arg7); + func_800A08A0(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex); + } + func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x335); +} + +// SkelAnime_LodDraw +void func_800A0B40(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) +{ + SkelLimbEntry* limbEntry; + char pad[4]; + Gfx* dList; + Vec3f pos; + Vec3s rot; + GraphicsContext* gfxCtx; + Gfx* gfx[4]; + + if (limbIndex == NULL) + { + osSyncPrintf("\x1b[31m"); + osSyncPrintf("Si2_Lod_draw():skelがNULLです。\n"); + osSyncPrintf("\x1b[m"); + return; + } + gfxCtx = globalCtx->state.gfxCtx; + func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x351); + Matrix_Push(); + + limbEntry = SEGMENTED_TO_VIRTUAL(*limbIndex); + pos.x = (f32) actorDrawTable->x; + pos.y = (f32) actorDrawTable->y; + pos.z = (f32) actorDrawTable->z; + + rot = actorDrawTable[1]; + dList = limbEntry->displayLists[dListIndex]; + + if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList, &pos, &rot, actor) == 0)) + { + func_800D1340(&pos, &rot); + if (dList != NULL) + { + gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 0x371), G_MTX_LOAD); + gSPDisplayList(gfxCtx->polyOpa.p++, dList); + } + } + if (appendDlistFunc != NULL) + { + appendDlistFunc(globalCtx, 1, &dList, &rot, actor); + } + if (limbEntry->firstChildIndex != 0xFF) + { + func_800A08A0(globalCtx, limbEntry->firstChildIndex, limbIndex, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex); + } + Matrix_Pull(); + func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x37E); +} + +#ifdef NON_MATCHING +// SkelAnime_LodDrawLimbSV +void func_800A0D94(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, + SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, + Actor* actor, s32 dListIndex, Mtx** mtx) +{ + Gfx* dList[2]; + GraphicsContext* gfxCtx; + SkelLimbEntry* limbEntry; + Vec3f pos; + Vec3s rot; + Gfx* gfx[3]; + + Matrix_Push(); + + limbEntry = SEGMENTED_TO_VIRTUAL(limbTable[limbIndex]); + limbIndex++; + + rot = actorDrawTable[limbIndex]; + pos.x = limbEntry->pos.x; + pos.y = limbEntry->pos.y; + pos.z = limbEntry->pos.z; + dList[1] = dList[0] = limbEntry->displayLists[dListIndex]; + if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList[1], &pos, &rot, actor) == 0)) + { + func_800D1340(&pos, &rot); + if (dList[1] != NULL) + { + Matrix_ToMtx(*mtx, "../z_skelanime.c", 945); gfxCtx = globalCtx->state.gfxCtx; + func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 946); + gSPMatrix(gfxCtx->polyOpa.p++, *mtx, G_MTX_LOAD); + gSPDisplayList(gfxCtx->polyOpa.p++, dList[1]); + func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 949); + (*mtx)++; + } + else if (dList[0] != 0) + { + Matrix_ToMtx(*mtx, "../z_skelanime.c", 954); + (*mtx)++; + } + } + if (appendDlistFunc != NULL) + { + appendDlistFunc(globalCtx, limbIndex, &dList[1], &rot, actor); + } + if (limbEntry->firstChildIndex != 0xFF) + { + func_800A0D94(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, + updateMtxFunc, appendDlistFunc, actor, dListIndex, mtx); + } + + Matrix_Pull(); + + if (limbEntry->nextLimbIndex != 0xFF) + { + func_800A0D94(globalCtx, limbEntry->nextLimbIndex, limbTable, + actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex, mtx); } - func_800C6B54(&gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x335); } #else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A08A0.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A0D94.s") #endif #undef NON_MATCHING -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A0B40.s") +#ifdef NON_MATCHING +// SkelAnime_LodDrawSV +void func_800A106C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, s32 limbCount, + SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, + Actor* actor, s32 dListIndex) +{ + SkelLimbEntry *limbEntry; + Gfx* dList[2]; + Vec3f pos; + Vec3s rot; + Mtx* mtx; + GraphicsContext* gfxCtx; + Gfx* gfx[4]; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A0D94.s") + do + { + if(1) + { + mtx = Graph_Alloc(globalCtx->state.gfxCtx, limbCount * 0x40); + } + } while(0); + + if (limbTable == NULL) + { + osSyncPrintf("\x1b[31m"); + osSyncPrintf("Si2_Lod_draw_SV():skelがNULLです。\n"); + osSyncPrintf("\x1b[m"); + return; + } + gfxCtx = globalCtx->state.gfxCtx; + func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1000); + gSPSegment(gfxCtx->polyOpa.p++, 0xD, mtx); + Matrix_Push(); + + limbEntry = SEGMENTED_TO_VIRTUAL(*limbTable); + pos.x = actorDrawTable->x; + pos.y = actorDrawTable->y; + pos.z = actorDrawTable->z; + + rot = actorDrawTable[1]; + + dList[0] = dList[1] = limbEntry->displayLists[dListIndex]; + + if ((updateMtxFunc == 0) || (updateMtxFunc(globalCtx, 1, &dList[1], &pos, &rot, actor) == 0)) + { + func_800D1340(&pos, &rot); + if (dList[1] != NULL) + { + mtx = Matrix_ToMtx(mtx, "../z_skelanime.c", 1033); + 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++; + } + } + + if (appendDlistFunc != 0) + { + appendDlistFunc(globalCtx, 1, &dList[0], &rot, actor); + } + if (limbEntry->firstChildIndex != 0xFF) + { + func_800A0D94(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex, &mtx); + } + Matrix_Pull(); + func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1053); +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A106C.s") +#endif +#undef NON_MATCHING #ifdef NON_MATCHING // SkelAnime_DrawLimb -- cgit v1.2.3 From 2a158f79ce06adc9a961c6047acf8e3c0d870b39 Mon Sep 17 00:00:00 2001 From: KrimtonZ Date: Sun, 22 Mar 2020 20:24:00 -0500 Subject: skelanime WIP --- src/code/z_skelanime.c | 601 ++++++++++++++++++++++++++++--------------------- 1 file changed, 344 insertions(+), 257 deletions(-) (limited to 'src/code') diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index ada66eed0..b258a412a 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -6,26 +6,22 @@ void func_800A52F8(SkelAnime* skelAnime, u32 animation); void func_800A54FC(SkelAnime*,Vec3f*,s16); s32 func_800A3D70(GlobalContext*,SkelAnime*); s32 func_800A3E0C(GlobalContext*,SkelAnime*); -void func_800A34DC(GlobalContext*,u8,Vec3s*,Vec3s*,f32); -void func_800A336C(GlobalContext* globalCtx, s32 arg1, s32 arg2, s32 limbCount, void* ram); +void func_800A34DC(GlobalContext*,s32,Vec3s*,Vec3s*,f32); +void func_800A336C(GlobalContext* globalCtx, u32 linkAnimetionSeg, s32 frame, s32 limbCount, void* ram); s32 func_800A4D9C(SkelAnime* skelAnime); s32 func_800A4EE0(SkelAnime* skelAnime); s32 func_800A4E38(SkelAnime* skelAnime); -void func_800A1D8C(u32,s32,u8,Vec3s*); +void func_800A1D8C(u32 animation, s32 currentFrame, s32 limbCount, Vec3s *arg3); void func_800A2E70(u8,Vec3s*,Vec3s*,Vec3s*,f32); void func_800A49B0(SkelAnime*); - -typedef struct -{ - u32 limbIndexSeg; - u8 limbCount; - char unk_05[3]; - u8 dListCount; -} SkelAnimeInit; +void func_800A3478(GlobalContext*,s32,Vec3s*,Vec3s*); +void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 arg4, f32 frameCount, u8 arg6, f32 arg7); +void func_800A4FE4(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 unk0, f32 frameCount, u8 unk1, f32 transitionRate, s8 unk2); +Gfx* func_800A24A0(GlobalContext*, u8, u32*, Vec3s*, SkelAnime_LimbUpdateMatrix2, SkelAnime_LimbAppendDlist2, Actor*, Mtx**, Gfx*); //.data -static u32 D_8012A480 = 0; -typedef void (*testfunc)(GlobalContext*,char*); +u32 D_8012A480 = 0; +typedef void (*testfunc)(GlobalContext*, AnimationEntryType*); static testfunc D_8012A484[] = { (testfunc)0x800A3678, @@ -40,6 +36,7 @@ static testfunc D_8012A484[] = u32 D_801600B0; // SkelAnime_LodDrawLimb +// func_800A08A0 void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) { SkelLimbEntry* limbEntry; @@ -56,9 +53,9 @@ void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec limbIndex++; rot = actorDrawTable[limbIndex]; - pos.x = limbEntry->pos.x; - pos.y = limbEntry->pos.y; - pos.z = limbEntry->pos.z; + pos.x = limbEntry->translation.x; + pos.y = limbEntry->translation.y; + pos.z = limbEntry->translation.z; dList = limbEntry->displayLists[dListIndex]; if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList, &pos, &rot, actor) == 0)) @@ -82,14 +79,14 @@ void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec appendDlistFunc(globalCtx, limbIndex, &dList, &rot, actor); } - if (limbEntry->firstChildIndex != 0xFF) + if (limbEntry->firstChildIndex != LIMB_DONE) { func_800A08A0(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex); } Matrix_Pull(); - if (limbEntry->nextLimbIndex != 0xFF) + if (limbEntry->nextLimbIndex != LIMB_DONE) { func_800A08A0(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex); } @@ -97,6 +94,7 @@ void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec } // SkelAnime_LodDraw +// func_800A0B40 void func_800A0B40(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) { SkelLimbEntry* limbEntry; @@ -149,6 +147,7 @@ void func_800A0B40(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDrawTab #ifdef NON_MATCHING // SkelAnime_LodDrawLimbSV +// func_800A0D94 void func_800A0D94(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex, Mtx** mtx) @@ -192,7 +191,7 @@ void func_800A0D94(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3 { appendDlistFunc(globalCtx, limbIndex, &dList[1], &rot, actor); } - if (limbEntry->firstChildIndex != 0xFF) + if (limbEntry->firstChildIndex != LIMB_DONE) { func_800A0D94(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex, mtx); @@ -200,7 +199,7 @@ void func_800A0D94(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3 Matrix_Pull(); - if (limbEntry->nextLimbIndex != 0xFF) + if (limbEntry->nextLimbIndex != LIMB_DONE) { func_800A0D94(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex, mtx); @@ -213,6 +212,7 @@ void func_800A0D94(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3 #ifdef NON_MATCHING // SkelAnime_LodDrawSV +// func_800A106C void func_800A106C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, s32 limbCount, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) @@ -276,7 +276,7 @@ void func_800A106C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab { appendDlistFunc(globalCtx, 1, &dList[0], &rot, actor); } - if (limbEntry->firstChildIndex != 0xFF) + if (limbEntry->firstChildIndex != LIMB_DONE) { func_800A0D94(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex, &mtx); } @@ -290,6 +290,7 @@ void func_800A106C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab #ifdef NON_MATCHING // SkelAnime_DrawLimb +// func_800A1344 void func_800A1344(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) { GraphicsContext* gfxCtx; @@ -324,7 +325,7 @@ void func_800A1344(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3 appendDlistFunc(globalCtx, limbIndex, &dList, &rot, actor); } - if (limbEntry->firstChildIndex != 0xFF) + if (limbEntry->firstChildIndex != LIMB_DONE) { func_800A1344(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor); @@ -332,7 +333,7 @@ void func_800A1344(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3 Matrix_Pull(); - if (limbEntry->nextLimbIndex != 0xFF) + if (limbEntry->nextLimbIndex != LIMB_DONE) { func_800A1344(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor); @@ -390,7 +391,7 @@ void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTa appendDlistFunc(globalCtx, 1, &dList, &rot, actor); } - if (rootLimb->firstChildIndex != 0xFF) + if (rootLimb->firstChildIndex != LIMB_DONE) { func_800A1344(globalCtx, rootLimb->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor); @@ -452,14 +453,14 @@ void func_800A180C(GlobalContext *globalCtx, u32 limbIndex, u32* limbTable, Vec3 appendDlistFunc(globalCtx, limbIndex, &limbDlist[1], &limbRot, actor); } - if (limbEntry->firstChildIndex != 0xFF) + if (limbEntry->firstChildIndex != LIMB_DONE) { func_800A180C(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, limbMatricies); } Matrix_Pull(); - if (limbEntry->nextLimbIndex != 0xFF) + if (limbEntry->nextLimbIndex != LIMB_DONE) { func_800A180C(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, limbMatricies); @@ -534,7 +535,7 @@ void func_800A1AC8(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab appendDlistFunc(globalCtx, 1, &skelDlist[1], &rot, actor); } - if (rootLimb->firstChildIndex != 0xFF) + if (rootLimb->firstChildIndex != LIMB_DONE) { func_800A180C(globalCtx, rootLimb->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, &limbMatricies); @@ -548,110 +549,45 @@ void func_800A1AC8(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab #endif #undef NON_MATCHING -#ifdef NON_MATCHING -typedef struct -{ - s16 animFrameCount; - u32 rotationValuesSeg; - u32 actorDrawTableSeg; - s16 limit; -} AnimationHeader; - -typedef struct -{ - Vec3s pos; - Vec3s rotations[1]; -} RotationIndex; - -u16 func_800A1D8C(u32 animationSeg, s32 arg1, s32 arg2, Vec3s* arg3) -{ - s32 temp_s2; - s32 temp_s3; - s32 temp_s4; - u16 temp_v0_2; - u16 temp_v0_3; - u16 temp_v0_4; - void *temp_v0; - void *phi_s0; - void *phi_s1; - s32 phi_s4; - u16 phi_return; - AnimationHeader* animation; - Vec3s* rotationValues; - u32* limbTable; - u32 i; - - animation = SEGMENTED_TO_VIRTUAL(animationSeg); - rotationValues = SEGMENTED_TO_VIRTUAL(animation->rotationValuesSeg); - - phi_return = temp_v0; - for(i = 0;i < arg2; i++){ - - } - if (arg2 > 0) - { - temp_s3 = (arg1 * 2) + temp_s2; - phi_s0 = arg3; - phi_s1 = (*(&gSegments + (((u32) (temp_v0->unk8 * 0x10) >> 0x1C) * 4)) + (temp_v0->unk8 & 0xFFFFFF)) + 0x80000000; - phi_s4 = 0; -loop_2: - if ((((phi_s0 == 0) || (phi_s1 == 0)) || (temp_s3 == 0)) || (temp_s2 == 0)) - { - LogUtils_LogThreadId("../z_skelanime.c", 0x570); - osSyncPrintf("out = %08x\n", phi_s0); - LogUtils_LogThreadId("../z_skelanime.c", 0x571); - osSyncPrintf("ref_tbl = %08x\n", phi_s1); - LogUtils_LogThreadId("../z_skelanime.c", 0x572); - osSyncPrintf("frame_tbl = %08x\n", temp_s3); - LogUtils_LogThreadId("../z_skelanime.c", 0x573); - osSyncPrintf("tbl = %08x\n", temp_s2); - } - else - { +/* SkelAnime_AnimateFrame + * 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 func_800A1D8C(u32 animation, s32 currentFrame, s32 limbCount, Vec3s *dst) +{ + AnimationRotationIndex* index; + AnimationRotationValue* rotationValueTable; + AnimationRotationValue* frameRotationValueTable; + AnimationHeader *animationHeader; + + s32 i; + u16 limit; - } - temp_v0_2 = phi_s1->unk0; - temp_s4 = phi_s4 + 1; - if (temp_v0_2 >= temp_v0->unkC) - { - phi_s0->unk0 = (s16) *(temp_s3 + (temp_v0_2 * 2)); - } - else - { - phi_s0->unk0 = (s16) *(temp_s2 + (temp_v0_2 * 2)); - } - temp_v0_3 = phi_s1->unk2; - if (temp_v0_3 >= temp_v0->unkC) - { - phi_s0->unk2 = (s16) *(temp_s3 + (temp_v0_3 * 2)); - } - else - { - phi_s0->unk2 = (s16) *(temp_s2 + (temp_v0_3 * 2)); - } - temp_v0_4 = phi_s1->unk4; - if (temp_v0_4 >= temp_v0->unkC) - { - phi_s0->unk4 = (s16) *(temp_s3 + (temp_v0_4 * 2)); - } - else - { - phi_s0->unk4 = (s16) *(temp_s2 + (temp_v0_4 * 2)); - } - phi_s0 = phi_s0 + 6; - phi_s1 = phi_s1 + 6; - phi_s4 = temp_s4; - phi_return = temp_v0_4; - if (temp_s4 != arg2) + animationHeader = SEGMENTED_TO_VIRTUAL(animation); + 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)) { - goto loop_2; + if(1) { } // Necessary to match. + LOG("../z_skelanime.c", 0x570, "out = %08x\n", dst); + LOG("../z_skelanime.c", 0x571, "ref_tbl = %08x\n", index); + LOG("../z_skelanime.c", 0x572, "frame_tbl = %08x\n", frameRotationValueTable); + LOG("../z_skelanime.c", 0x573, "tbl = %08x\n", rotationValueTable); } + + 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]; } - return phi_return; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A1D8C.s") -#endif s32 func_800A1FC8(s32 arg0) { @@ -672,7 +608,67 @@ s32 SkelAnime_GetFrameCount(u32 animation) #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A24A0.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A273C.s") +// SkelAnime_DrawSV2 +Gfx* func_800A273C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, s32 dListCount, SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, Actor* actor, Gfx* gfx) +{ + 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 (limbTable == NULL) + { + osSyncPrintf("\x1b[31m"); + osSyncPrintf("Si2_draw2_SV():skelがNULLです。NULLを返します。\n"); + osSyncPrintf("\x1b[m"); + return NULL; + } + gSPSegment(gfx++, 0xD, mtx); + Matrix_Push(); + limbEntry = SEGMENTED_TO_VIRTUAL(*limbTable); + + pos.x = actorDrawTable->x; + pos.y = actorDrawTable->y; + pos.z = actorDrawTable->z; + + rot = actorDrawTable[1]; + + dList1 = dList2 = limbEntry->displayLists[0]; + + if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList1, &pos, &rot, actor, &gfx) == 0)) + { + func_800D1340(&pos, &rot); + if (dList1 != NULL) + { + Matrix_ToMtx(mtx, "../z_skelanime.c", 0x6AE); + gSPMatrix(gfx++, mtx, G_MTX_LOAD); + gSPDisplayList(gfx++, dList1); + mtx++; + } + else + { + if (dList2 != NULL) + { + Matrix_ToMtx(mtx, "../z_skelanime.c", 0x6B5); + mtx++; + } + } + } + if (appendDlistFunc != NULL) + { + appendDlistFunc(globalCtx, 1, &dList2, &rot, actor, &gfx); + } + if (limbEntry->firstChildIndex != LIMB_DONE) + { + gfx = func_800A24A0(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, &mtx, gfx); + } + Matrix_Pull(); + return gfx; +} #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A29BC.s") @@ -696,6 +692,7 @@ s32 func_800A2E2C(s32 arg0){ return (s16)(*virt - 1); } +// Big boi function #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A2E70.s") void func_800A32EC(u16* arg0) @@ -715,7 +712,8 @@ void func_800A3310(void* arg0) *D_8012A480Ptr |= D_801600B0; } -AnimationEntry* func_800A3334(AnimationContext* animationCtx, s32 arg1) +// SkelAnime_NextEntry +AnimationEntry* func_800A3334(AnimationContext* animationCtx, AnimationType type) { AnimationEntry *entry; s16 index = animationCtx->animationCount; @@ -726,80 +724,187 @@ AnimationEntry* func_800A3334(AnimationContext* animationCtx, s32 arg1) } animationCtx->animationCount = index + 1; entry = &animationCtx->entries[index]; - entry->unk_00 = arg1; + entry->type = type; return entry; } -#ifdef NON_MATCHING -typedef struct -{ - u32 unk_00; - u32 rom; -} anim; +/* + * These next 6 functions seem to inialize an entry in the global context's + * animation context. +*/ -void func_800A336C(GlobalContext* globalCtx, s32 arg1, s32 arg2, s32 limbCount, void* ram) +// SkelAnime_AnimationEntryType0Init +void func_800A336C(GlobalContext* globalCtx, u32 linkAnimetionSeg, s32 frame, s32 limbCount, void* ram) { - s32 sp3C; - anim *sp38; - s32 sp30; - OSMesgQueue temp_a0; - s32 temp_a3; - s32 temp_at; - AnimationEntry* temp_ret; - DmaRequest req; + AnimationEntry* entry; + LinkAnimetionEntry *linkAnimetionEntry; + char pad[4]; - temp_ret = func_800A3334(&globalCtx->animationCtx, 0); - if (temp_ret != NULL) + entry = func_800A3334(&globalCtx->animationCtx, 0); + if (entry != NULL) { - temp_a0 = temp_ret->msgQueue; - sp38 = SEGMENTED_TO_VIRTUAL(arg1); - sp3C = temp_ret; - osCreateMesgQueue(temp_ret, &temp_ret->msg, 1); - temp_a3 = sizeof(Vec3s) * limbCount; - DmaMgr_SendRequest2(&req, ram, ((sp38->rom + (u32)&_link_animetionSegmentRomStart) - 0x7000000) + (temp_a3 * arg2), temp_a3, 0, &temp_ret->msgQueue, NULL, "../z_skelanime.c" , 0x7D4); + 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" , 0x7D4); + } +} +//SkelAnime_AnimationEntryType1Init +void func_800A3478(GlobalContext* globalCtx, s32 vecCount, + Vec3s* dst, Vec3s* src) +{ + AnimationEntry* entry = func_800A3334(&globalCtx->animationCtx, 1); + if (entry != NULL) + { + entry->types.type1.unk_00 = D_801600B0; + entry->types.type1.vecCount = vecCount; + entry->types.type1.dst = dst; + entry->types.type1.src = src; + } +} +//SkelAnime_AnimationEntryType2Init +void func_800A34DC(GlobalContext* globalCtx, s32 arg1, + Vec3s* arg2, Vec3s* arg3, f32 arg4) +{ + AnimationEntry* entry = func_800A3334(&globalCtx->animationCtx, 2); + if (entry != NULL) + { + entry->types.type2.unk_00 = D_801600B0; + entry->types.type2.unk_01 = arg1; + entry->types.type2.unk_04 = arg2; + entry->types.type2.unk_08 = arg3; + entry->types.type2.unk_0C = arg4; + } +} +//SkelAnime_AnimationEntryType3Init +void func_800A3548(GlobalContext* globalCtx, s32 vecCount, + s32 dst, s32 src, s32 index) +{ + AnimationEntry* entry = func_800A3334(&globalCtx->animationCtx, 3); + if (entry != NULL) + { + 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; + } +} +//SkelAnime_AnimationEntryType4Init +void func_800A35B4(GlobalContext* globalCtx, s32 vecCount, + Vec3s* dst, Vec3s* src, u8* index) +{ + AnimationEntry* entry = func_800A3334(&globalCtx->animationCtx, 4); + if (entry != NULL) + { + 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; + } +} +//SkelAnime_AnimationEntryType4Init +void func_800A3620(GlobalContext* globalCtx, Actor* actor, + SkelAnime* skelAnime, f32 arg3) +{ + AnimationEntry* entry = func_800A3334(&globalCtx->animationCtx, 5); + if (entry != NULL) + { + entry->types.type5.actor = actor; + entry->types.type5.skelAnime = skelAnime; + entry->types.type5.unk_08 = arg3; } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A336C.s") -#endif -#undef NON_MATCHING - -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3478.s") -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A34DC.s") +/* The next functions are callbacks to loading animations */ -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3548.s") +void func_800A3678(GlobalContext* globalCtx, AnimationEntryType0* entry) +{ + osRecvMesg(&entry->msgQueue, NULL, OS_MESG_BLOCK); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A35B4.s") +void func_800A36A4(GlobalContext* globalCtx, AnimationEntryType1* entry) +{ + s32 i; + Vec3s* dst; + Vec3s* src; + AnimationEntryRaw* genericEntry = (AnimationEntryRaw*)entry; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3620.s") + if ((genericEntry->raw[0] & D_8012A480) != 0) + { + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3678.s") + for(dst = entry->dst, src = entry->src, i = 0; + i < genericEntry->raw[1]; + i++) + { + *dst++ = *src++; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A36A4.s") +void func_800A3714(GlobalContext* globalCtx, AnimationEntryType2* entry) +{ + if ((entry->unk_00 & D_8012A480) == 0) + { + func_800A2E70(entry->unk_01, entry->unk_04, entry->unk_04, entry->unk_08, entry->unk_0C); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3714.s") +void func_800A3770(GlobalContext* globalCtx, AnimationEntryType3* entry) +{ + s32 i; + Vec3s* dst; + Vec3s* src; + u8* index; + AnimationEntryRaw* rawEntry = (AnimationEntryRaw*)entry; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3770.s") + 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++) + { + *dst = *src; + } + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A37F0.s") +void func_800A37F0(GlobalContext* globalCtx, AnimationEntryType4* entry) +{ + s32 i; + Vec3s* dst; + Vec3s* src; + u8* index; + AnimationEntryRaw* rawEntry = (AnimationEntryRaw*)entry; -typedef struct { - Actor* actor; - SkelAnime* skelAnime; - f32 unk_8; -} UNK_800A3874_A1; + 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) + { + *dst = *src; + } + } + } +} -void func_800A3874(s32 arg0, UNK_800A3874_A1* arg1) +void func_800A3874(GlobalContext* globalCtx, AnimationEntryType5* entry) { char pad[4]; - Actor* temp_v0 = arg1->actor; + Actor* actor = entry->actor; Vec3f pos; - func_800A54FC(arg1->skelAnime, &pos, temp_v0->shape.rot.y); - temp_v0->posRot.pos.x += pos.x * temp_v0->scale.x; - temp_v0->posRot.pos.y += pos.y * temp_v0->scale.y * arg1->unk_8; - temp_v0->posRot.pos.z += pos.z * temp_v0->scale.z; + 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; } void func_800A390C(GlobalContext* globalCtx, AnimationContext* animationCtx) @@ -808,7 +913,7 @@ void func_800A390C(GlobalContext* globalCtx, AnimationContext* animationCtx) for(entry = animationCtx->entries; animationCtx->animationCount != 0; entry++, animationCtx->animationCount--) { - D_8012A484[entry->unk_00](globalCtx, entry->unk_04); + D_8012A484[entry->type](globalCtx, &entry->types); } D_801600B0 = 1; @@ -817,19 +922,18 @@ void func_800A390C(GlobalContext* globalCtx, AnimationContext* animationCtx) #ifdef NON_MATCHING // some kind of init -void func_800A3F08(GlobalContext*,SkelAnime*,s32,f32,f32,f32,s8,f32); -void func_800A39AC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 skelAnimeInitSeg, s32 arg3, s8 arg4, Vec3s* actorDrawTable, s32 arg6, s32 arg7) +void func_800A39AC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, s32 arg3, s8 arg4, Vec3s* actorDrawTable, s32 arg6, s32 arg7) { - SkelAnimeInit* skelAnimeInit; + SkelAnimeLimbHeader* limbHeader; u8 flag; size_t size; - skelAnimeInit = SEGMENTED_TO_VIRTUAL(skelAnimeInitSeg); + limbHeader = SEGMENTED_TO_VIRTUAL(limbHeaderSeg); skelAnime->unk_34 = arg4; - flag = arg4 & 2 == 0 ? 1U : skelAnimeInit->limbCount; + flag = arg4 & 2 == 0 ? 1U : limbHeader->limbCount; if ((arg4 & 2) != 0) { - flag = skelAnimeInit->limbCount; + flag = limbHeader->limbCount; } else { @@ -838,17 +942,17 @@ void func_800A39AC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 skelAnime if((arg4 & 1) != 0) { - flag += skelAnimeInit->limbCount; + flag += limbHeader->limbCount; } if((arg4 & 4) != 0) { - flag += skelAnimeInit->limbCount; + flag += limbHeader->limbCount; } skelAnime->limbCount = flag; - skelAnime->dListCount = skelAnimeInit->dListCount; - skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(skelAnimeInit->limbIndexSeg); + skelAnime->dListCount = limbHeader->dListCount; + skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg); size = sizeof(Vec3s); if ((arg4 & 8) != 0) { @@ -884,15 +988,16 @@ void func_800A39AC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 skelAnime #endif #undef NON_MATCHING +// SkelAnime_SetUpdateFunc void func_800A3B8C(SkelAnime* skelAnime) { if (skelAnime->unk_01 < 2) { - skelAnime->mtxUpdate = &func_800A3D70; + skelAnime->animUpdate = &func_800A3D70; } else { - skelAnime->mtxUpdate = &func_800A3E0C; + skelAnime->animUpdate = &func_800A3E0C; } skelAnime->unk_28 = 0.0f; } @@ -900,7 +1005,7 @@ void func_800A3B8C(SkelAnime* skelAnime) //SkelAnime_FrameUpdateMatrixGlobalCtx void func_800A3BC0(GlobalContext* globalCtx, SkelAnime* skelAnime) { - skelAnime->mtxUpdate(globalCtx, skelAnime); + skelAnime->animUpdate(globalCtx, skelAnime); } #ifdef NON_MATCHING @@ -984,7 +1089,7 @@ s32 func_800A3E0C(GlobalContext* globalCtx, SkelAnime* skelAnime) skelAnime->animCurrentFrame -= skelAnime->unk_14; } } - } + } func_800A3C9C(globalCtx, skelAnime); return 0; } @@ -996,8 +1101,6 @@ void func_800A3EE8(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 arg2) skelAnime->unk_2C = 1.0f / arg2; } -s32 func_800A3BE4(GlobalContext* globalCtx, SkelAnime* skelAnime); -void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 arg4, f32 frameCount, u8 arg6, f32 arg7); #ifdef NON_MATCHING void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 arg4, f32 frameCount, u8 arg6, f32 arg7) { @@ -1059,7 +1162,6 @@ void func_800A419C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation func_800A3F08(globalCtx, skelAnime, animation, playbackSpeed, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 0, 0.0f); } -void func_800A3478(GlobalContext*,u8,Vec3s*,Vec3s*); void func_800A41FC(GlobalContext* globalCtx, SkelAnime* skelAnime) { func_800A3478(globalCtx, skelAnime->limbCount, skelAnime->unk_24, skelAnime->actorDrawTbl); @@ -1096,21 +1198,7 @@ void func_800A431C(GlobalContext* globalCtx, SkelAnime* skelAnime, s32 arg2, f32 func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, alignedAddr, arg6); } -#ifdef NON_MATCHING -void func_800A43B8(s32 arg0, void *arg1, ? arg2, f32 arg3, s32 arg4, f32 arg5, f32 arg6, s32 arg7) -{ - s32 sp28; - s32 temp_v0; - - func_800A336C(arg3, arg2, (s32) arg3, arg1->unk0, (s32) arg1->unk24); - temp_v0 = (arg7 + 0xF) & -0x10; - sp28 = temp_v0; - func_800A336C(arg0, arg4, (s32) arg5, arg1->unk0, temp_v0); - func_800A34DC(arg0, arg1->unk0, arg1->unk24, sp28, arg6); -} -#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A43B8.s") -#endif void func_800A4454(SkelAnime* skelAnime) { @@ -1118,38 +1206,36 @@ void func_800A4454(SkelAnime* skelAnime) func_800A3B8C(skelAnime); } - s32 func_800A4478(SkelAnime* skelAnime, f32 arg1, f32 updateRate) { - f32 temp_f0; + f32 updateSpeed; f32 temp_f12; - f32 temp_f2; + f32 nextFrame; - temp_f0 = skelAnime->animPlaybackSpeed * updateRate; - temp_f2 = skelAnime->animCurrentFrame - temp_f0; - if (temp_f2 < 0.0f) + updateSpeed = skelAnime->animPlaybackSpeed * updateRate; + nextFrame = skelAnime->animCurrentFrame - updateSpeed; + if (nextFrame < 0.0f) { - temp_f2 += skelAnime->unk_14; + nextFrame += skelAnime->unk_14; } else { - temp_f2 = temp_f2; - if (skelAnime->unk_14 <= temp_f2) + if (skelAnime->unk_14 <= nextFrame) { - temp_f2 = temp_f2 - skelAnime->unk_14; + nextFrame -= skelAnime->unk_14; } } if (arg1 == 0.0f) { - if (0.0f < temp_f0) + if (0.0f < updateSpeed) { arg1 = skelAnime->unk_14; } } - temp_f12 = (temp_f2 + temp_f0) - arg1; - if (0.0f <= (temp_f12 * temp_f0)) + temp_f12 = (nextFrame + updateSpeed) - arg1; + if (0.0f <= (temp_f12 * updateSpeed)) { - if (((temp_f12 - temp_f0) * temp_f0) < 0.0f) + if (((temp_f12 - updateSpeed) * updateSpeed) < 0.0f) { return 1; } @@ -1164,13 +1250,13 @@ s32 func_800A4530(SkelAnime* skelAnime, f32 arg1) return func_800A4478(skelAnime, arg1, updateRate); } -void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 skelAnimeInitSeg, u32 animation, Vec3s* actorDrawTable, s32 arg5, s32 limbCount) +void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, u32 animation, Vec3s* actorDrawTable, s32 arg5, s32 limbCount) { - SkelAnimeInit* skelAnimeInit; + SkelAnimeLimbHeader* limbHeader; - skelAnimeInit = SEGMENTED_TO_VIRTUAL(skelAnimeInitSeg); - skelAnime->limbCount = skelAnimeInit->limbCount + 1; - skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(skelAnimeInit->limbIndexSeg); + limbHeader = SEGMENTED_TO_VIRTUAL(limbHeaderSeg); + skelAnime->limbCount = limbHeader->limbCount + 1; + skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg); if (actorDrawTable == NULL) { skelAnime->actorDrawTbl = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), "../z_skelanime.c", 2968); @@ -1197,16 +1283,15 @@ void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 skelAnim func_800A52F8(skelAnime, animation); } } - -// another init -void func_800A46F8(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 skelAnimeInitSeg, u32 animation, Vec3s* actorDrawTable, s32 arg5, s32 limbCount) +// SkelAnime_InitSV +void func_800A46F8(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, u32 animation, Vec3s* actorDrawTable, s32 arg5, s32 limbCount) { - SkelAnimeInit *skelAnimeInit; + SkelAnimeLimbHeader *limbHeader; - skelAnimeInit = SEGMENTED_TO_VIRTUAL(skelAnimeInitSeg); - skelAnime->limbCount = skelAnimeInit->limbCount + 1; - skelAnime->dListCount = skelAnimeInit->dListCount; - skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(skelAnimeInit->limbIndexSeg); + limbHeader = SEGMENTED_TO_VIRTUAL(limbHeaderSeg); + skelAnime->limbCount = limbHeader->limbCount + 1; + skelAnime->dListCount = limbHeader->dListCount; + skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg); if (actorDrawTable == NULL) { @@ -1234,15 +1319,14 @@ void func_800A46F8(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 skelAnime func_800A52F8(skelAnime, animation); } } - -// some kind of init -void func_800A487C(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 skelAnimeInitSeg, u32 animation) +// SkelAnime_InitSkin +void func_800A487C(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 limbHeaderSeg, u32 animation) { - SkelAnimeInit *skelAnimeInit; + SkelAnimeLimbHeader *limbHeader; - skelAnimeInit = SEGMENTED_TO_VIRTUAL(skelAnimeInitSeg); - skelAnime->limbCount = skelAnimeInit->limbCount + 1; - skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(skelAnimeInit->limbIndexSeg); + limbHeader = SEGMENTED_TO_VIRTUAL(limbHeaderSeg); + skelAnime->limbCount = limbHeader->limbCount + 1; + skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg); skelAnime->actorDrawTbl = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), "../z_skelanime.c", 3120); skelAnime->unk_24 = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->unk_24), "../z_skelanime.c", 3121); if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) @@ -1262,20 +1346,20 @@ void func_800A49B0(SkelAnime* skelAnime) { if (skelAnime->unk_01 < 2) { - skelAnime->mtxUpdate = &func_800A4D9C; + skelAnime->animUpdate = &func_800A4D9C; return; } if (skelAnime->unk_01 < 4) { - skelAnime->mtxUpdate = &func_800A4EE0; + skelAnime->animUpdate = &func_800A4EE0; return; } - skelAnime->mtxUpdate = &func_800A4E38; + skelAnime->animUpdate = &func_800A4E38; } s32 SkelAnime_FrameUpdateMatrix(SkelAnime* skelAnime){ - return skelAnime->mtxUpdate(skelAnime); + return skelAnime->animUpdate(skelAnime); } #ifdef NON_MATCHING @@ -1347,27 +1431,28 @@ s32 func_800A4AD8(SkelAnime* skelAnime) // close void func_800A4C58(SkelAnime* skelAnime) { - Vec3s sp38[98]; + char pad[6]; f32 temp_f0; - f32 temp_f2; - s32 temp_f10; + f32 temp_f10; + Vec3s sp38[97]; s32 temp_f8; + f32 temp_f2; - func_800A1D8C(skelAnime->animCurrent, (s32) skelAnime->animPlaybackSpeed, skelAnime->limbCount, skelAnime->actorDrawTbl); + func_800A1D8C(skelAnime->animCurrent, (s32) skelAnime->animCurrentFrame, skelAnime->limbCount, skelAnime->actorDrawTbl); if ((skelAnime->unk_01 & 1) != 0) { temp_f8 = (s32) skelAnime->animCurrentFrame; temp_f10 = temp_f8; - temp_f8 = temp_f8 + 1; - temp_f2 = skelAnime->animCurrentFrame - (f32) temp_f10; + temp_f8++; + temp_f2 = skelAnime->animCurrentFrame - temp_f10; if (temp_f8 >= (s32) skelAnime->unk_14) { temp_f8 = 0; } func_800A1D8C(skelAnime->animCurrent, temp_f8, skelAnime->limbCount, sp38); - func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, &sp38, temp_f2); + func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, sp38, temp_f2); } - if (0.0f != skelAnime->unk_28) + if (skelAnime->unk_28 != 0) { skelAnime->unk_28 -= skelAnime->unk_2C * (R_UPDATE_RATE * 0.33333334f); temp_f0 = skelAnime->unk_28; @@ -1670,6 +1755,7 @@ s32 func_800A56C8(SkelAnime *skelAnime, f32 arg1) return func_800A4478(skelAnime, arg1, 1.0f); } +// SkelAnime_Free void func_800A56F0(SkelAnime *skelAnime, s32 arg1) { if (skelAnime->actorDrawTbl != NULL) @@ -1688,7 +1774,8 @@ void func_800A56F0(SkelAnime *skelAnime, s32 arg1) osSyncPrintf("morf_joint あきまへん!!\n"); // "morf_joint Akimane !!" } -s32 func_800A5774(SkelAnime* skelAnime, Vec3s *dst, Vec3s *src) +// SkelAnime_CopyVec3s +void func_800A5774(SkelAnime* skelAnime, Vec3s *dst, Vec3s *src) { s32 i; for(i = 0; i < skelAnime->limbCount; i++) -- cgit v1.2.3 From 6072055c8561c2504eb874b5005e2ab9c56d216e Mon Sep 17 00:00:00 2001 From: KrimtonZ Date: Sun, 22 Mar 2020 20:57:25 -0500 Subject: fix merge conflics --- src/code/z_skelanime.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 106 insertions(+), 6 deletions(-) (limited to 'src/code') diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 9c376faa3..b258a412a 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1671,15 +1671,115 @@ void func_800A5408(SkelAnime* skelAnime) } #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A5408.s") +#endif + +void func_800A5428(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* arg3) +{ + s32 i; + for(i = 0; i < skelAnime->limbCount; i++, dst++, src++) + { + if(*arg3++) + { + *dst = *src; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A5428.s") +void func_800A5490(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* arg3) +{ + s32 i; + for(i = 0;i < skelAnime->limbCount; i++, dst++, src++) + { + if(*arg3++ < 1U){ + *dst = *src; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A5490.s") +void func_800A54FC(SkelAnime* skelAnime, Vec3f* pos, s16 angle) +{ + f32 x; + f32 z; + f32 sin; + f32 cos; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A54FC.s") + if((skelAnime->unk_35 & 0x10) != 0) + { + pos->z = 0.0f; + pos->x = 0.0f; + } + else + { + x = (f32)skelAnime->actorDrawTbl->x; + z = (f32)skelAnime->actorDrawTbl->z; + sin = Math_Sins(angle); + cos = Math_Coss(angle); + pos->x = x * cos + z * sin; + pos->z = z * cos - x * sin; + x = (f32)skelAnime->unk_38; + z = (f32)skelAnime->unk_3C; + sin = Math_Sins(skelAnime->unk_36); + cos = Math_Coss(skelAnime->unk_36); + pos->x -= x * cos + z * sin; + pos->z -= z * cos - x * sin; + } + + skelAnime->unk_36 = angle; + skelAnime->unk_38 = skelAnime->actorDrawTbl->x; + skelAnime->actorDrawTbl->x = skelAnime->unk_3E; + skelAnime->unk_3C = skelAnime->actorDrawTbl->z; + skelAnime->actorDrawTbl->z = skelAnime->unk_42; + if((skelAnime->unk_35 & 2) != 0) + { + if((skelAnime->unk_35 & 0x10) != 0) + { + pos->y = 0.0f; + } + else + { + pos->y = (f32)(skelAnime->actorDrawTbl->y - skelAnime->unk_3A); + } + skelAnime->unk_3A = skelAnime->actorDrawTbl->y; + skelAnime->actorDrawTbl->y = skelAnime->unk_40; + } + else + { + pos->y = 0.0f; + skelAnime->unk_3A = skelAnime->actorDrawTbl->y; + } + skelAnime->unk_35 &= ~0x10; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A56C8.s") +s32 func_800A56C8(SkelAnime *skelAnime, f32 arg1) +{ + return func_800A4478(skelAnime, arg1, 1.0f); +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A56F0.s") +// SkelAnime_Free +void func_800A56F0(SkelAnime *skelAnime, s32 arg1) +{ + if (skelAnime->actorDrawTbl != NULL) + { + ZeldaArena_FreeDebug(skelAnime->actorDrawTbl, "../z_skelanime.c", 3729); + } + else + { + osSyncPrintf("now_joint あきまへん!!\n"); // now_joint Akimane! ! + } + if (skelAnime->unk_24 != NULL) + { + ZeldaArena_FreeDebug(skelAnime->unk_24, "../z_skelanime.c", 3731); + return; + } + osSyncPrintf("morf_joint あきまへん!!\n"); // "morf_joint Akimane !!" +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A5774.s") +// SkelAnime_CopyVec3s +void func_800A5774(SkelAnime* skelAnime, Vec3s *dst, Vec3s *src) +{ + s32 i; + for(i = 0; i < skelAnime->limbCount; i++) + { + *dst++ = *src++; + } +} -- cgit v1.2.3 From 0d93e48035c5f0a7f729919d395c6a4f6eb12980 Mon Sep 17 00:00:00 2001 From: KrimtonZ Date: Mon, 23 Mar 2020 16:31:24 -0500 Subject: skelanime WIP, name Matrix_TranslateThanRotateZYX, match Matrix_Translate --- src/code/sys_matrix.c | 168 ++++++++++++------- src/code/z_debug_display.c | 2 +- src/code/z_skelanime.c | 410 +++++++++++++++++++++++++++++++-------------- 3 files changed, 400 insertions(+), 180 deletions(-) (limited to 'src/code') diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index b300f189d..688b21500 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -2,13 +2,16 @@ #include // clang-format off -Mtx gMtxClear = { +Mtx gMtxClear = +{ 65536, 0, 1, 0, 0, 65536, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, }; -MtxF gMtxFClear = { + +MtxF gMtxFClear = +{ 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, @@ -19,67 +22,88 @@ MtxF gMtxFClear = { MtxF* sMatrixStack; // "Matrix_stack" MtxF* sCurrentMatrix; // "Matrix_now" -void Matrix_Init(GameState* gameState) { +void Matrix_Init(GameState* gameState) +{ sCurrentMatrix = Game_Alloc(gameState, 20 * sizeof(MtxF), "../sys_matrix.c", 153); sMatrixStack = sCurrentMatrix; } -void Matrix_Push(void) { +void Matrix_Push(void) +{ Matrix_MtxFCopy(sCurrentMatrix + 1, sCurrentMatrix); sCurrentMatrix++; } -void Matrix_Pull(void) { +void Matrix_Pull(void) +{ sCurrentMatrix--; - if (sCurrentMatrix < sMatrixStack) { + if (sCurrentMatrix < sMatrixStack) + { __assert("Matrix_now >= Matrix_stack", "../sys_matrix.c", 176); } } -void Matrix_Get(MtxF* dest) { +void Matrix_Get(MtxF* dest) +{ Matrix_MtxFCopy(dest, sCurrentMatrix); } -void Matrix_Put(MtxF* src) { +void Matrix_Put(MtxF* src) +{ Matrix_MtxFCopy(sCurrentMatrix, src); } -MtxF* Matrix_GetCurrent(void) { +MtxF* Matrix_GetCurrent(void) +{ return sCurrentMatrix; } -void Matrix_Mult(MtxF* mf, u8 mode) { +void Matrix_Mult(MtxF* mf, u8 mode) +{ MtxF* cmf = Matrix_GetCurrent(); - if (mode == MTXMODE_APPLY) { + if (mode == MTXMODE_APPLY) + { func_800A6FA0(cmf, mf, cmf); - } else { + } + else + { Matrix_MtxFCopy(sCurrentMatrix, mf); } } -#ifdef NON_MATCHING -// minor ordering and regalloc differences void Matrix_Translate(f32 x, f32 y, f32 z, u8 mode) { MtxF* cmf = sCurrentMatrix; - - if (mode == MTXMODE_APPLY) { - cmf->wx += cmf->xx * x + cmf->yx * y + cmf->zx * z; - cmf->wy += cmf->xy * x + cmf->yy * y + cmf->zy * z; - cmf->wz += cmf->xz * x + cmf->yz * y + cmf->zz * z; - cmf->ww += cmf->xw * x + cmf->yw * y + cmf->zw * z; - } else { + f32 tx; + f32 ty; + + if (mode == MTXMODE_APPLY) + { + tx = cmf->xx; + ty = cmf->yx; + cmf->wx += tx * x + ty * y + cmf->zx * z; + tx = cmf->xy; + ty = cmf->yy; + cmf->wy += tx * x + ty * y + cmf->zy * z; + tx = cmf->xz; + ty = cmf->yz; + cmf->wz += tx * x + ty * y + cmf->zz * z; + tx = cmf->xw; + ty = cmf->yw; + cmf->ww += tx * x + ty * y + cmf->zw * z; + } + else + { func_800A7A24(cmf, x, y, z); } } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_Translate.s") -#endif -void Matrix_Scale(f32 x, f32 y, f32 z, u8 mode) { +void Matrix_Scale(f32 x, f32 y, f32 z, u8 mode) +{ MtxF* cmf = sCurrentMatrix; - if (mode == MTXMODE_APPLY) { + if (mode == MTXMODE_APPLY) + { cmf->xx *= x; cmf->xy *= x; cmf->xz *= x; @@ -92,20 +116,25 @@ void Matrix_Scale(f32 x, f32 y, f32 z, u8 mode) { cmf->xw *= x; cmf->yw *= y; cmf->zw *= z; - } else { + } + else + { func_800A76A4(cmf, x, y, z); } } -void Matrix_RotateX(f32 x, u8 mode) { +void Matrix_RotateX(f32 x, u8 mode) +{ MtxF* cmf; f32 sin; f32 cos; f32 temp1; f32 temp2; - if (mode == MTXMODE_APPLY) { - if (x != 0) { + if (mode == MTXMODE_APPLY) + { + if (x != 0) + { cmf = sCurrentMatrix; sin = sinf(x); @@ -131,13 +160,18 @@ void Matrix_RotateX(f32 x, u8 mode) { cmf->yw = temp1 * cos + temp2 * sin; cmf->zw = temp2 * cos - temp1 * sin; } - } else { + } + else + { cmf = sCurrentMatrix; - if (x != 0) { + if (x != 0) + { sin = sinf(x); cos = cosf(x); - } else { + } + else + { sin = 0.0f; cos = 1.0f; } @@ -161,15 +195,18 @@ void Matrix_RotateX(f32 x, u8 mode) { } } -void Matrix_RotateY(f32 y, u8 mode) { +void Matrix_RotateY(f32 y, u8 mode) +{ MtxF* cmf; f32 sin; f32 cos; f32 temp1; f32 temp2; - if (mode == MTXMODE_APPLY) { - if (y != 0) { + if (mode == MTXMODE_APPLY) + { + if (y != 0) + { cmf = sCurrentMatrix; sin = sinf(y); @@ -195,13 +232,18 @@ void Matrix_RotateY(f32 y, u8 mode) { cmf->xw = temp1 * cos - temp2 * sin; cmf->zw = temp1 * sin + temp2 * cos; } - } else { + } + else + { cmf = sCurrentMatrix; - if (y != 0) { + if (y != 0) + { sin = sinf(y); cos = cosf(y); - } else { + } + else + { sin = 0.0f; cos = 1.0f; } @@ -225,15 +267,18 @@ void Matrix_RotateY(f32 y, u8 mode) { } } -void Matrix_RotateZ(f32 z, u8 mode) { +void Matrix_RotateZ(f32 z, u8 mode) +{ MtxF* cmf; f32 sin; f32 cos; f32 temp1; f32 temp2; - if (mode == MTXMODE_APPLY) { - if (z != 0) { + if (mode == MTXMODE_APPLY) + { + if (z != 0) + { cmf = sCurrentMatrix; sin = sinf(z); @@ -289,7 +334,13 @@ void Matrix_RotateZ(f32 z, u8 mode) { } } -void Matrix_RotateXYZ(s16 x, s16 y, s16 z, u8 mode) { +/* + * Rotates the top of the matrix stack by `z` degrees, then + * rotates that matrix by `y` degrees, then rotates that matrix + * by `x` degrees. + * Original Name: Matrix_RotateXYZ, changed to reflect rotation order. +*/ +void Matrix_RotateZYX(s16 x, s16 y, s16 z, u8 mode) { MtxF* cmf = sCurrentMatrix; f32 temp1; f32 temp2; @@ -374,43 +425,48 @@ void Matrix_RotateXYZ(s16 x, s16 y, s16 z, u8 mode) { } } -void func_800D1340(Vec3f* arg0, Vec3s* arg1) { +/* + * Translates the top of the matrix stack by `translation` units, + * then rotates that matrix by `rotation` in Z-Y-X order +*/ +void Matrix_TranslateThenRotateZYX(Vec3f* translation, Vec3s* rotation) +{ MtxF* cmf = sCurrentMatrix; f32 sin; f32 cos; f32 temp1; f32 temp2; - sin = Math_Sins(arg1->z); - cos = Math_Coss(arg1->z); + sin = Math_Sins(rotation->z); + cos = Math_Coss(rotation->z); temp1 = cmf->xx; temp2 = cmf->yx; - cmf->wx += temp1 * arg0->x + temp2 * arg0->y + cmf->zx * arg0->z; + cmf->wx += temp1 * translation->x + temp2 * translation->y + cmf->zx * translation->z; cmf->xx = temp1 * cos + temp2 * sin; cmf->yx = temp2 * cos - temp1 * sin; temp1 = cmf->xy; temp2 = cmf->yy; - cmf->wy += temp1 * arg0->x + temp2 * arg0->y + cmf->zy * arg0->z; + cmf->wy += temp1 * translation->x + temp2 * translation->y + cmf->zy * translation->z; cmf->xy = temp1 * cos + temp2 * sin; cmf->yy = temp2 * cos - temp1 * sin; temp1 = cmf->xz; temp2 = cmf->yz; - cmf->wz += temp1 * arg0->x + temp2 * arg0->y + cmf->zz * arg0->z; + cmf->wz += temp1 * translation->x + temp2 * translation->y + cmf->zz * translation->z; cmf->xz = temp1 * cos + temp2 * sin; cmf->yz = temp2 * cos - temp1 * sin; temp1 = cmf->xw; temp2 = cmf->yw; - cmf->ww += temp1 * arg0->x + temp2 * arg0->y + cmf->zw * arg0->z; + cmf->ww += temp1 * translation->x + temp2 * translation->y + cmf->zw * translation->z; cmf->xw = temp1 * cos + temp2 * sin; cmf->yw = temp2 * cos - temp1 * sin; - if (arg1->y != 0) { - sin = Math_Sins(arg1->y); - cos = Math_Coss(arg1->y); + if (rotation->y != 0) { + sin = Math_Sins(rotation->y); + cos = Math_Coss(rotation->y); temp1 = cmf->xx; temp2 = cmf->zx; @@ -433,9 +489,9 @@ void func_800D1340(Vec3f* arg0, Vec3s* arg1) { cmf->zw = temp1 * sin + temp2 * cos; } - if (arg1->x != 0) { - sin = Math_Sins(arg1->x); - cos = Math_Coss(arg1->x); + if (rotation->x != 0) { + sin = Math_Sins(rotation->x); + cos = Math_Coss(rotation->x); temp1 = cmf->yx; temp2 = cmf->zx; diff --git a/src/code/z_debug_display.c b/src/code/z_debug_display.c index e27afafeb..e96ccdc2f 100644 --- a/src/code/z_debug_display.c +++ b/src/code/z_debug_display.c @@ -83,7 +83,7 @@ static void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, u32 texture, Glo Matrix_Translate(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, MTXMODE_NEW); Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY); Matrix_Mult(&globalCtx->mf_11DA0, MTXMODE_APPLY); - Matrix_RotateXYZ(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, MTXMODE_APPLY); + Matrix_RotateZYX(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, MTXMODE_APPLY); gDPLoadTextureBlock(gfxCtx->polyXlu.p++, texture, G_IM_FMT_I, G_IM_SIZ_8b, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index b258a412a..97dd3fb9e 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -15,28 +15,25 @@ void func_800A1D8C(u32 animation, s32 currentFrame, s32 limbCount, Vec3s *arg3); void func_800A2E70(u8,Vec3s*,Vec3s*,Vec3s*,f32); void func_800A49B0(SkelAnime*); void func_800A3478(GlobalContext*,s32,Vec3s*,Vec3s*); -void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 arg4, f32 frameCount, u8 arg6, f32 arg7); +void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32* animation, f32 playbackSpeed, f32 arg4, f32 frameCount, u8 arg6, f32 arg7); void func_800A4FE4(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 unk0, f32 frameCount, u8 unk1, f32 transitionRate, s8 unk2); -Gfx* func_800A24A0(GlobalContext*, u8, u32*, Vec3s*, SkelAnime_LimbUpdateMatrix2, SkelAnime_LimbAppendDlist2, Actor*, Mtx**, Gfx*); //.data u32 D_8012A480 = 0; -typedef void (*testfunc)(GlobalContext*, AnimationEntryType*); -static testfunc D_8012A484[] = -{ - (testfunc)0x800A3678, - (testfunc)0x800A36A4, - (testfunc)0x800A3714, - (testfunc)0x800A3770, - (testfunc)0x800A37F0, - (testfunc)0x800A3874, +static AnimationEntryCallback D_8012A484[] = +{ + (AnimationEntryCallback)0x800A3678, + (AnimationEntryCallback)0x800A36A4, + (AnimationEntryCallback)0x800A3714, + (AnimationEntryCallback)0x800A3770, + (AnimationEntryCallback)0x800A37F0, + (AnimationEntryCallback)0x800A3874, }; //.bss u32 D_801600B0; // SkelAnime_LodDrawLimb -// func_800A08A0 void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) { SkelLimbEntry* limbEntry; @@ -60,7 +57,7 @@ void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec dList = limbEntry->displayLists[dListIndex]; if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList, &pos, &rot, actor) == 0)) { - func_800D1340(&pos, &rot); + Matrix_TranslateThenRotateZYX(&pos, &rot); if (dList != NULL) { do @@ -94,7 +91,6 @@ void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec } // SkelAnime_LodDraw -// func_800A0B40 void func_800A0B40(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) { SkelLimbEntry* limbEntry; @@ -115,18 +111,18 @@ void func_800A0B40(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDrawTab gfxCtx = globalCtx->state.gfxCtx; func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x351); Matrix_Push(); - + limbEntry = SEGMENTED_TO_VIRTUAL(*limbIndex); pos.x = (f32) actorDrawTable->x; pos.y = (f32) actorDrawTable->y; pos.z = (f32) actorDrawTable->z; - rot = actorDrawTable[1]; + rot = actorDrawTable[1]; dList = limbEntry->displayLists[dListIndex]; if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList, &pos, &rot, actor) == 0)) { - func_800D1340(&pos, &rot); + Matrix_TranslateThenRotateZYX(&pos, &rot); if (dList != NULL) { gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 0x371), G_MTX_LOAD); @@ -147,16 +143,15 @@ void func_800A0B40(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDrawTab #ifdef NON_MATCHING // SkelAnime_LodDrawLimbSV -// func_800A0D94 void func_800A0D94(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex, Mtx** mtx) { - Gfx* dList[2]; - GraphicsContext* gfxCtx; SkelLimbEntry* limbEntry; + Gfx* dList[2]; Vec3f pos; Vec3s rot; + GraphicsContext* gfxCtx; Gfx* gfx[3]; Matrix_Push(); @@ -165,16 +160,18 @@ void func_800A0D94(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3 limbIndex++; rot = actorDrawTable[limbIndex]; - pos.x = limbEntry->pos.x; - pos.y = limbEntry->pos.y; - pos.z = limbEntry->pos.z; + + pos.x = limbEntry->translation.x; + pos.y = limbEntry->translation.y; + pos.z = limbEntry->translation.z; dList[1] = dList[0] = limbEntry->displayLists[dListIndex]; + if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList[1], &pos, &rot, actor) == 0)) { - func_800D1340(&pos, &rot); + Matrix_TranslateThenRotateZYX(&pos, &rot); if (dList[1] != NULL) { - Matrix_ToMtx(*mtx, "../z_skelanime.c", 945); gfxCtx = globalCtx->state.gfxCtx; + Matrix_ToMtx(*mtx, "../z_skelanime.c", 945); gfxCtx = globalCtx->state.gfxCtx; func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 946); gSPMatrix(gfxCtx->polyOpa.p++, *mtx, G_MTX_LOAD); gSPDisplayList(gfxCtx->polyOpa.p++, dList[1]); @@ -189,7 +186,7 @@ void func_800A0D94(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3 } if (appendDlistFunc != NULL) { - appendDlistFunc(globalCtx, limbIndex, &dList[1], &rot, actor); + appendDlistFunc(globalCtx, limbIndex, &dList[0], &rot, actor); } if (limbEntry->firstChildIndex != LIMB_DONE) { @@ -198,7 +195,7 @@ void func_800A0D94(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3 } Matrix_Pull(); - + if (limbEntry->nextLimbIndex != LIMB_DONE) { func_800A0D94(globalCtx, limbEntry->nextLimbIndex, limbTable, @@ -208,13 +205,12 @@ void func_800A0D94(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3 #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A0D94.s") #endif -#undef NON_MATCHING #ifdef NON_MATCHING // SkelAnime_LodDrawSV // func_800A106C void func_800A106C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, s32 limbCount, - SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, + SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) { SkelLimbEntry *limbEntry; @@ -232,7 +228,7 @@ void func_800A106C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab mtx = Graph_Alloc(globalCtx->state.gfxCtx, limbCount * 0x40); } } while(0); - + if (limbTable == NULL) { osSyncPrintf("\x1b[31m"); @@ -252,27 +248,30 @@ void func_800A106C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab pos.z = actorDrawTable->z; rot = actorDrawTable[1]; - - dList[0] = dList[1] = limbEntry->displayLists[dListIndex]; - + + dList[1] = dList[0] = limbEntry->displayLists[dListIndex]; + if ((updateMtxFunc == 0) || (updateMtxFunc(globalCtx, 1, &dList[1], &pos, &rot, actor) == 0)) { - func_800D1340(&pos, &rot); + Matrix_TranslateThenRotateZYX(&pos, &rot); if (dList[1] != NULL) { - mtx = Matrix_ToMtx(mtx, "../z_skelanime.c", 1033); + Matrix_ToMtx(mtx, "../z_skelanime.c", 1033); gSPMatrix(gfxCtx->polyOpa.p++, mtx, G_MTX_LOAD); gSPDisplayList(gfxCtx->polyOpa.p++, dList[1]); mtx++; } - else if (dList[0] != NULL) + else { - Matrix_ToMtx(mtx, "../z_skelanime.c", 1040); - mtx++; + if (dList[0] != NULL) + { + Matrix_ToMtx(mtx, "../z_skelanime.c", 1040); + mtx++; + } } } - if (appendDlistFunc != 0) + if (appendDlistFunc != NULL) { appendDlistFunc(globalCtx, 1, &dList[0], &rot, actor); } @@ -280,43 +279,52 @@ void func_800A106C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab { func_800A0D94(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex, &mtx); } + Matrix_Pull(); + func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1053); } #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A106C.s") #endif -#undef NON_MATCHING -#ifdef NON_MATCHING // SkelAnime_DrawLimb // func_800A1344 void func_800A1344(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) { - GraphicsContext* gfxCtx; - Gfx* gfx[4]; SkelLimbEntry* limbEntry; - Vec3s rot; - Vec3f pos; Gfx* dList; + Vec3f pos; + Vec3s rot; + GraphicsContext* gfxCtx; + Gfx* gfx[4]; gfxCtx = globalCtx->state.gfxCtx; + func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x434); Matrix_Push(); + limbEntry = SEGMENTED_TO_VIRTUAL(limbTable[limbIndex]); limbIndex++; rot = actorDrawTable[limbIndex]; - pos.x = (f32) limbEntry->pos.x; - pos.y = (f32) limbEntry->pos.y; - pos.z = (f32) limbEntry->pos.z; - dList = limbEntry->dList; + pos.x = (f32) limbEntry->translation.x; + pos.y = (f32) limbEntry->translation.y; + pos.z = (f32) limbEntry->translation.z; + dList = limbEntry->displayLists[0]; + if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList, &pos, &rot, actor) == 0)) { - func_800D1340(&pos, &rot); + Matrix_TranslateThenRotateZYX(&pos, &rot); if (dList != NULL) { - gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(gfxCtx, "../z_skelanime.c", 0x44F), G_MTX_LOAD); - gSPDisplayList(gfxCtx->polyOpa.p++, dList); + 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); } } @@ -339,21 +347,18 @@ void func_800A1344(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3 actorDrawTable, updateMtxFunc, appendDlistFunc, actor); } - func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x461); + func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1121); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A1344.s") -#endif -#ifdef NON_MATCHING void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) { SkelLimbEntry* rootLimb; - Vec3s rot; - Vec3f pos; + char pad[4]; Gfx* dList; + Vec3f pos; + Vec3s rot; GraphicsContext* gfxCtx; - Gfx* gfx[5]; + Gfx* gfx[4]; if (limbTable == NULL) { @@ -374,11 +379,11 @@ void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTa pos.z = (f32) actorDrawTable[0].z; rot = actorDrawTable[1]; - dList = rootLimb->dList; + dList = rootLimb->displayLists[0]; if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList, &pos, &rot, actor) == 0)) { - func_800D1340(&pos, &rot); + Matrix_TranslateThenRotateZYX(&pos, &rot); if (dList != NULL) { gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 1176), G_MTX_LOAD); @@ -398,11 +403,9 @@ void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTa } Matrix_Pull(); + func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1190); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_Draw.s") -#endif #ifdef NON_MATCHING // SkelAnime_Draw2Limb @@ -430,7 +433,7 @@ void func_800A180C(GlobalContext *globalCtx, u32 limbIndex, u32* limbTable, Vec3 if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &limbDlist[0], &limbPos, &limbRot, actor) == 0)) { - func_800D1340(&limbPos, &limbRot); + Matrix_TranslateThenRotateZYX(&limbPos, &limbRot); if (limbDlist[0] != NULL) { Matrix_ToMtx(*limbMatricies, "../z_skelanime.c", 0x4DA); @@ -512,7 +515,7 @@ void func_800A1AC8(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &skelDlist[0], &pos, &rot, actor) == 0)) { - func_800D1340(&pos, &rot); + Matrix_TranslateThenRotateZYX(&pos, &rot); if (skelDlist[0] != NULL) { Matrix_ToMtx(limbMatricies, "../z_skelanime.c", 1327); @@ -560,7 +563,7 @@ void func_800A1D8C(u32 animation, s32 currentFrame, s32 limbCount, Vec3s *dst) AnimationRotationValue* rotationValueTable; AnimationRotationValue* frameRotationValueTable; AnimationHeader *animationHeader; - + s32 i; u16 limit; @@ -573,7 +576,7 @@ void func_800A1D8C(u32 animation, s32 currentFrame, s32 limbCount, Vec3s *dst) for(i = 0; i < limbCount; i++, dst++, index++) { if ((dst == NULL) || (index == NULL) || - (frameRotationValueTable == NULL) || + (frameRotationValueTable == NULL) || (rotationValueTable == NULL)) { if(1) { } // Necessary to match. @@ -602,11 +605,172 @@ s32 SkelAnime_GetFrameCount(u32 animation) return (s16)(*virt - 1); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A2044.s") +// SkelAnime_DrawLimb2 +Gfx* func_800A2044(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, 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(limbTable[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", 0x5D1), G_MTX_LOAD); + gSPDisplayList(gfx++, dList); + } + } + + if (appendDlistFunc != NULL) + { + appendDlistFunc(globalCtx, limbIndex, &dList, &rot, actor, &gfx); + } + + if (limbEntry->firstChildIndex != LIMB_DONE) + { + gfx = func_800A2044(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, gfx); + } + + Matrix_Pull(); + + if (limbEntry->nextLimbIndex != LIMB_DONE) + { + gfx = func_800A2044(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, gfx); + } + + return gfx; +} + +#ifdef NON_MATCHING +// Some regalloc, and nonmatching stack usage +// SkelAnime_Draw2 +Gfx* func_800A2288(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, Actor* actor, Gfx* gfx) +{ + SkelLimbEntry* limbEntry; + Vec3f pos; + Vec3s rot; + Gfx* dList; + if (limbTable == NULL) + { + osSyncPrintf("\x1b[31m"); + osSyncPrintf("Si2_draw2():skelがNULLです。NULLを返します。\n"); + osSyncPrintf("\x1b[m"); + return NULL; + } + + Matrix_Push(); + + limbEntry = SEGMENTED_TO_VIRTUAL(*limbTable); + + pos.x = limbEntry->translation.x; + pos.y = limbEntry->translation.y; + pos.z = limbEntry->translation.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", 0x616), G_MTX_LOAD); + gSPDisplayList(gfx++, dList); + } + } + + if (appendDlistFunc != NULL) + { + appendDlistFunc(globalCtx, 1, &dList, &rot, actor, &gfx); + } + + if (limbEntry->firstChildIndex != LIMB_DONE) + { + gfx = func_800A2044(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, gfx); + } + + Matrix_Pull(); + + return gfx; +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A2288.s") +#endif + +// SkelAnime_DrawLimbSV2 +Gfx* func_800A24A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, 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(limbTable[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", 0x657); + gSPMatrix(gfx++, *mtx, G_MTX_LOAD); + gSPDisplayList(gfx++, dList1); + (*mtx)++; + } + else + { + if (dList2 != NULL) + { + Matrix_ToMtx(*mtx, "../z_skelanime.c", 0x65E); + (*mtx)++; + } + } + } + if (appendDlistFunc != 0) + { + appendDlistFunc(globalCtx, limbIndex, &dList2, &rot, actor, &gfx); + } + if (limbEntry->firstChildIndex != LIMB_DONE) + { + gfx = func_800A24A0(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, mtx, gfx); + } + + Matrix_Pull(); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A24A0.s") + if (limbEntry->nextLimbIndex != LIMB_DONE) + { + gfx = func_800A24A0(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, mtx, gfx); + } + return gfx; +} // SkelAnime_DrawSV2 Gfx* func_800A273C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, s32 dListCount, SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, Actor* actor, Gfx* gfx) @@ -634,14 +798,14 @@ Gfx* func_800A273C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab pos.x = actorDrawTable->x; pos.y = actorDrawTable->y; pos.z = actorDrawTable->z; - + rot = actorDrawTable[1]; dList1 = dList2 = limbEntry->displayLists[0]; if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList1, &pos, &rot, actor, &gfx) == 0)) { - func_800D1340(&pos, &rot); + Matrix_TranslateThenRotateZYX(&pos, &rot); if (dList1 != NULL) { Matrix_ToMtx(mtx, "../z_skelanime.c", 0x6AE); @@ -733,7 +897,7 @@ AnimationEntry* func_800A3334(AnimationContext* animationCtx, AnimationType type * animation context. */ -// SkelAnime_AnimationEntryType0Init +// SkelAnime_LinkAnimetionDma void func_800A336C(GlobalContext* globalCtx, u32 linkAnimetionSeg, s32 frame, s32 limbCount, void* ram) { AnimationEntry* entry; @@ -746,7 +910,7 @@ void func_800A336C(GlobalContext* globalCtx, u32 linkAnimetionSeg, s32 frame, s3 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, + sizeof(Vec3s) * limbCount + 2, 0, &entry->types.type0.msgQueue, NULL, "../z_skelanime.c" , 0x7D4); } } @@ -920,60 +1084,55 @@ void func_800A390C(GlobalContext* globalCtx, AnimationContext* animationCtx) D_8012A480 = 0; } -#ifdef NON_MATCHING -// some kind of init -void func_800A39AC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, s32 arg3, s8 arg4, Vec3s* actorDrawTable, s32 arg6, s32 arg7) +void func_800A39AC(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 limbHeaderSeg, u32* animation, s32 flags, Vec3s* actorDrawTbl, Vec3s* arg6, s32 limbBufCount) { - SkelAnimeLimbHeader* limbHeader; - u8 flag; - size_t size; + char pad[8]; + SkelAnimeLimbHeader *limbHeader; + size_t allocSize; + s32 limbCount; + s32 headerCount; limbHeader = SEGMENTED_TO_VIRTUAL(limbHeaderSeg); - skelAnime->unk_34 = arg4; - flag = arg4 & 2 == 0 ? 1U : limbHeader->limbCount; - if ((arg4 & 2) != 0) - { - flag = limbHeader->limbCount; - } - else - { - flag = 1; - } + headerCount = limbHeader->limbCount; + skelAnime->unk_34 = flags; + limbCount = (flags & 2) != 0 ? headerCount : 1; - if((arg4 & 1) != 0) + if ((flags & 1) != 0) { - flag += limbHeader->limbCount; + limbCount += headerCount; } - - if((arg4 & 4) != 0) + if ((flags & 4) != 0) { - flag += limbHeader->limbCount; + limbCount += headerCount; } - skelAnime->limbCount = flag; + skelAnime->limbCount = (u8)limbCount; skelAnime->dListCount = limbHeader->dListCount; + + allocSize = limbCount * sizeof(Vec3s); skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg); - size = sizeof(Vec3s); - if ((arg4 & 8) != 0) + + if ((flags & 8) != 0) { - size += 2; + allocSize += 2; } - if (actorDrawTable == NULL) + if (actorDrawTbl == NULL) { - skelAnime->actorDrawTbl = ZeldaArena_MallocDebug(size, "../z_skelanime.c", 2364); - skelAnime->unk_24 = ZeldaArena_MallocDebug(size, "../z_skelanime.c", 2365); + skelAnime->actorDrawTbl = ZeldaArena_MallocDebug(allocSize, "../z_skelanime.c", 2364); + skelAnime->unk_24 = ZeldaArena_MallocDebug(allocSize, "../z_skelanime.c", 2365); } else { - if (arg7 != flag) + if (limbBufCount != limbCount) { __assert("joint_buff_num == joint_num", "../z_skelanime.c", 2369); } - skelAnime->actorDrawTbl = ALIGN16((u32)actorDrawTable); - skelAnime->unk_24 = ALIGN16(arg6); + skelAnime->actorDrawTbl = (Vec3s*)ALIGN16((u32)actorDrawTbl); + skelAnime->unk_24 = (Vec3s*)ALIGN16((u32)arg6); } + if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) { osSyncPrintf("\x1b[31m"); @@ -981,12 +1140,8 @@ void func_800A39AC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeade osSyncPrintf("\x1b[m"); } - func_800A3F08(globalCtx, skelAnime, arg3, 1.0f, 0.0f, 0.0f, 0, 0.0f); + func_800A3F08(globalCtx, skelAnime, animation, 1.0f, 0.0f, 0.0f, 0, 0.0f); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A39AC.s") -#endif -#undef NON_MATCHING // SkelAnime_SetUpdateFunc void func_800A3B8C(SkelAnime* skelAnime) @@ -1008,21 +1163,21 @@ void func_800A3BC0(GlobalContext* globalCtx, SkelAnime* skelAnime) skelAnime->animUpdate(globalCtx, skelAnime); } -#ifdef NON_MATCHING s32 func_800A3BE4(GlobalContext* globalCtx, SkelAnime* skelAnime) { f32 prevUnk28 = skelAnime->unk_28; - skelAnime->unk_28 -= skelAnime->unk_2C * (R_UPDATE_RATE * 0.5f); + f32 updateRate = R_UPDATE_RATE * 0.5f; + + skelAnime->unk_28 -= skelAnime->unk_2C * updateRate; + if (skelAnime->unk_28 <= 0.0f) { func_800A3B8C(skelAnime); } + func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, 1.0f - (skelAnime->unk_28 / prevUnk28)); return 0; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3BE4.s") -#endif void func_800A3C9C(GlobalContext* globalCtx, SkelAnime* skelAnime) { @@ -1089,7 +1244,7 @@ s32 func_800A3E0C(GlobalContext* globalCtx, SkelAnime* skelAnime) skelAnime->animCurrentFrame -= skelAnime->unk_14; } } - } + } func_800A3C9C(globalCtx, skelAnime); return 0; } @@ -1102,7 +1257,7 @@ void func_800A3EE8(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 arg2) } #ifdef NON_MATCHING -void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 arg4, f32 frameCount, u8 arg6, f32 arg7) +void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32* animation, f32 playbackSpeed, f32 arg4, f32 frameCount, u8 arg6, f32 arg7) { skelAnime->unk_01 = arg6; @@ -1117,7 +1272,7 @@ void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation } else { - skelAnime->mtxUpdate = &func_800A3BE4; + skelAnime->animUpdate = &func_800A3BE4; func_800A336C(globalCtx, animation, (s32) arg4, skelAnime->limbCount, skelAnime->unk_24); } skelAnime->unk_28 = 1.0f; @@ -1130,7 +1285,7 @@ void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation skelAnime->unk_28 = 0.0f; } - skelAnime->animCurrentFrame = animation; + skelAnime->animCurrentFrame = 0.0f; skelAnime->unk_0C = arg4; skelAnime->animCurrentFrame = arg4; skelAnime->animFrameCount = frameCount; @@ -1140,7 +1295,6 @@ void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3F08.s") #endif -#undef NON_MATCHING void func_800A407C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation) { @@ -1198,7 +1352,17 @@ void func_800A431C(GlobalContext* globalCtx, SkelAnime* skelAnime, s32 arg2, f32 func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, alignedAddr, arg6); } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A43B8.s") +void func_800A43B8(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 animation, f32 frame, s32 arg4, f32 arg5, f32 arg6, s32 arg7) +{ + s32 alignedAddr; + + func_800A336C(globalCtx, animation, (s32)frame, skelAnime->limbCount, skelAnime->unk_24); + + alignedAddr = ALIGN16(arg7); + + func_800A336C(globalCtx, arg4, (s32)arg5, skelAnime->limbCount, alignedAddr); + func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->unk_24, alignedAddr, arg6); +} void func_800A4454(SkelAnime* skelAnime) { @@ -1775,7 +1939,7 @@ void func_800A56F0(SkelAnime *skelAnime, s32 arg1) } // SkelAnime_CopyVec3s -void func_800A5774(SkelAnime* skelAnime, Vec3s *dst, Vec3s *src) +void func_800A5774(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src) { s32 i; for(i = 0; i < skelAnime->limbCount; i++) -- cgit v1.2.3 From ac4a51bf8fdc93221d4ba674351b683d0eedfd9b Mon Sep 17 00:00:00 2001 From: KrimtonZ Date: Tue, 24 Mar 2020 11:52:12 -0500 Subject: Rename SkelAnime functions, which in turn modified a bunch of actor functions. Move necessary skelanime function calls to functions.h, remove unnecessary skelanime functions from functions.h, other skelanime cleanup --- src/code/z_actor.c | 6 +- src/code/z_skelanime.c | 354 ++++++++++++++++++++++++++----------------------- 2 files changed, 191 insertions(+), 169 deletions(-) (limited to 'src/code') diff --git a/src/code/z_actor.c b/src/code/z_actor.c index be598da4a..01ff7ed32 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -910,7 +910,7 @@ void func_8002D9A4(Actor* actor, f32 arg1) { void func_8002D9F8(Actor* actor, UNK_PTR arg1) { Vec3f sp1C; - func_800A54FC(arg1, &sp1C, actor->shape.rot.y, actor); + func_800A54FC(arg1, &sp1C, actor->shape.rot.y); actor->posRot.pos.x += sp1C.x * actor->scale.x; actor->posRot.pos.y += sp1C.y * actor->scale.y; actor->posRot.pos.z += sp1C.z * actor->scale.z; @@ -3887,7 +3887,7 @@ void func_80034BA0(GlobalContext* globalCtx, SkelAnime* skelAnime, void* unkFunc gDPPipeSync(gfxCtx->polyOpa.p++); gSPSegment(gfxCtx->polyOpa.p++, 0x0C, func_80034B28(globalCtx->state.gfxCtx)); - gfxCtx->polyOpa.p = func_800A273C(globalCtx, skelAnime->limbIndex, skelAnime->actorDrawTbl, skelAnime->dListCount, + gfxCtx->polyOpa.p = SkelAnime_DrawSV2(globalCtx, skelAnime->limbIndex, skelAnime->actorDrawTbl, skelAnime->dListCount, unkFunc1, unkFunc2, actor, gfxCtx->polyOpa.p); func_800C6B54(gfxArr, globalCtx->state.gfxCtx, "../z_actor.c", 8860); @@ -3906,7 +3906,7 @@ void func_80034CC4(GlobalContext* globalCtx, SkelAnime* skelAnime, void* unkFunc gDPSetEnvColor(gfxCtx->polyXlu.p++, 0x00, 0x00, 0x00, alpha); gSPSegment(gfxCtx->polyXlu.p++, 0x0C, func_80034B54(globalCtx->state.gfxCtx)); - gfxCtx->polyXlu.p = func_800A273C(globalCtx, skelAnime->limbIndex, skelAnime->actorDrawTbl, skelAnime->dListCount, + gfxCtx->polyXlu.p = SkelAnime_DrawSV2(globalCtx, skelAnime->limbIndex, skelAnime->actorDrawTbl, skelAnime->dListCount, unkFunc1, unkFunc2, actor, gfxCtx->polyXlu.p); func_800C6B54(gfxArr, globalCtx->state.gfxCtx, "../z_actor.c", 8904); diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 97dd3fb9e..9066a226c 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1,40 +1,37 @@ #include #include -s32 func_800A4478(SkelAnime*,f32,f32); -void func_800A52F8(SkelAnime* skelAnime, u32 animation); -void func_800A54FC(SkelAnime*,Vec3f*,s16); s32 func_800A3D70(GlobalContext*,SkelAnime*); s32 func_800A3E0C(GlobalContext*,SkelAnime*); -void func_800A34DC(GlobalContext*,s32,Vec3s*,Vec3s*,f32); -void func_800A336C(GlobalContext* globalCtx, u32 linkAnimetionSeg, s32 frame, s32 limbCount, void* ram); s32 func_800A4D9C(SkelAnime* skelAnime); s32 func_800A4EE0(SkelAnime* skelAnime); s32 func_800A4E38(SkelAnime* skelAnime); -void func_800A1D8C(u32 animation, s32 currentFrame, s32 limbCount, Vec3s *arg3); -void func_800A2E70(u8,Vec3s*,Vec3s*,Vec3s*,f32); -void func_800A49B0(SkelAnime*); -void func_800A3478(GlobalContext*,s32,Vec3s*,Vec3s*); -void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32* animation, f32 playbackSpeed, f32 arg4, f32 frameCount, u8 arg6, f32 arg7); -void func_800A4FE4(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 unk0, f32 frameCount, u8 unk1, f32 transitionRate, s8 unk2); +void SkelAnime_CopyVec3s(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); +void func_800A3678(GlobalContext* globalCtx, AnimationEntryType0* entry); +void func_800A36A4(GlobalContext* globalCtx, AnimationEntryType1* entry); +void func_800A3714(GlobalContext* globalCtx, AnimationEntryType2* entry); +void func_800A3770(GlobalContext* globalCtx, AnimationEntryType3* entry); +void func_800A37F0(GlobalContext* globalCtx, AnimationEntryType4* entry); +void func_800A3874(GlobalContext* globalCtx, AnimationEntryType5* entry); //.data u32 D_8012A480 = 0; static AnimationEntryCallback D_8012A484[] = { - (AnimationEntryCallback)0x800A3678, - (AnimationEntryCallback)0x800A36A4, - (AnimationEntryCallback)0x800A3714, - (AnimationEntryCallback)0x800A3770, - (AnimationEntryCallback)0x800A37F0, - (AnimationEntryCallback)0x800A3874, + (AnimationEntryCallback)&func_800A3678, + (AnimationEntryCallback)&func_800A36A4, + (AnimationEntryCallback)&func_800A3714, + (AnimationEntryCallback)&func_800A3770, + (AnimationEntryCallback)&func_800A37F0, + (AnimationEntryCallback)&func_800A3874, }; //.bss u32 D_801600B0; -// SkelAnime_LodDrawLimb -void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) +void SkelAnime_LodDrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec3s* actorDrawTable, + SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, + Actor* actor, s32 dListIndex) { SkelLimbEntry* limbEntry; Gfx* dList; @@ -64,7 +61,10 @@ void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec { if(1) { - gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 0x325), G_MTX_LOAD); + gSPMatrix(gfxCtx->polyOpa.p++, + Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 0x325), + G_MTX_LOAD); + gSPDisplayList(gfxCtx->polyOpa.p++, dList); } } while(0); @@ -78,20 +78,24 @@ void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec if (limbEntry->firstChildIndex != LIMB_DONE) { - func_800A08A0(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex); + SkelAnime_LodDrawLimb(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, + updateMtxFunc, appendDlistFunc, actor, dListIndex); } Matrix_Pull(); if (limbEntry->nextLimbIndex != LIMB_DONE) { - func_800A08A0(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex); + SkelAnime_LodDrawLimb(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, + updateMtxFunc, appendDlistFunc, actor, dListIndex); } + func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x335); } -// SkelAnime_LodDraw -void func_800A0B40(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) +void SkelAnime_LodDraw(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDrawTable, + SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, + Actor* actor, s32 dListIndex) { SkelLimbEntry* limbEntry; char pad[4]; @@ -125,7 +129,10 @@ void func_800A0B40(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDrawTab Matrix_TranslateThenRotateZYX(&pos, &rot); if (dList != NULL) { - gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 0x371), G_MTX_LOAD); + gSPMatrix(gfxCtx->polyOpa.p++, + Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 0x371), + G_MTX_LOAD); + gSPDisplayList(gfxCtx->polyOpa.p++, dList); } } @@ -133,19 +140,20 @@ void func_800A0B40(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDrawTab { appendDlistFunc(globalCtx, 1, &dList, &rot, actor); } + if (limbEntry->firstChildIndex != 0xFF) { - func_800A08A0(globalCtx, limbEntry->firstChildIndex, limbIndex, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex); + SkelAnime_LodDrawLimb(globalCtx, limbEntry->firstChildIndex, limbIndex, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex); } + Matrix_Pull(); func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x37E); } #ifdef NON_MATCHING -// SkelAnime_LodDrawLimbSV -void func_800A0D94(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, - SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, - Actor* actor, s32 dListIndex, Mtx** mtx) +void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, + SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, + Actor* actor, s32 dListIndex, Mtx** mtx) { SkelLimbEntry* limbEntry; Gfx* dList[2]; @@ -190,7 +198,7 @@ void func_800A0D94(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3 } if (limbEntry->firstChildIndex != LIMB_DONE) { - func_800A0D94(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, + SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex, mtx); } @@ -198,20 +206,18 @@ void func_800A0D94(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3 if (limbEntry->nextLimbIndex != LIMB_DONE) { - func_800A0D94(globalCtx, limbEntry->nextLimbIndex, limbTable, + SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex, mtx); } } #else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A0D94.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_LodDrawLimbSV.s") #endif #ifdef NON_MATCHING -// SkelAnime_LodDrawSV -// func_800A106C -void func_800A106C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, s32 limbCount, - SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, - Actor* actor, s32 dListIndex) +void SkelAnime_LodDrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, s32 limbCount, + SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, + Actor* actor, s32 dListIndex) { SkelLimbEntry *limbEntry; Gfx* dList[2]; @@ -277,7 +283,7 @@ void func_800A106C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab } if (limbEntry->firstChildIndex != LIMB_DONE) { - func_800A0D94(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex, &mtx); + SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex, &mtx); } Matrix_Pull(); @@ -285,12 +291,12 @@ void func_800A106C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1053); } #else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A106C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_LodDrawSV.s") #endif -// SkelAnime_DrawLimb -// func_800A1344 -void func_800A1344(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) +void SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, + SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, + Actor* actor) { SkelLimbEntry* limbEntry; Gfx* dList; @@ -335,7 +341,7 @@ void func_800A1344(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3 if (limbEntry->firstChildIndex != LIMB_DONE) { - func_800A1344(globalCtx, limbEntry->firstChildIndex, limbTable, + SkelAnime_DrawLimb(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor); } @@ -343,14 +349,16 @@ void func_800A1344(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3 if (limbEntry->nextLimbIndex != LIMB_DONE) { - func_800A1344(globalCtx, limbEntry->nextLimbIndex, limbTable, + SkelAnime_DrawLimb(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor); } func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1121); } -void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) +void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, + SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, + Actor* actor) { SkelLimbEntry* rootLimb; char pad[4]; @@ -398,7 +406,7 @@ void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTa if (rootLimb->firstChildIndex != LIMB_DONE) { - func_800A1344(globalCtx, rootLimb->firstChildIndex, limbTable, + SkelAnime_DrawLimb(globalCtx, rootLimb->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor); } @@ -408,8 +416,9 @@ void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTa } #ifdef NON_MATCHING -// SkelAnime_Draw2Limb -void func_800A180C(GlobalContext *globalCtx, u32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, Mtx** limbMatricies) +void SkelAnime_DrawLimbSV(GlobalContext *globalCtx, u32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, + SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, + Actor* actor, Mtx** limbMatricies) { Gfx* limbDlist[2]; Vec3f limbPos; @@ -458,26 +467,27 @@ void func_800A180C(GlobalContext *globalCtx, u32 limbIndex, u32* limbTable, Vec3 if (limbEntry->firstChildIndex != LIMB_DONE) { - func_800A180C(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, limbMatricies); + SkelAnime_DrawLimbSV(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, limbMatricies); } Matrix_Pull(); if (limbEntry->nextLimbIndex != LIMB_DONE) { - func_800A180C(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, + SkelAnime_DrawLimbSV(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, limbMatricies); } func_800C6B54(sp34, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x4F1); } #else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A180C.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_DrawLimbSV.s") #endif #ifdef NON_MATCHING -// SkelAnime_Draw2 -void func_800A1AC8(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, u32 dListCount, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) +void SkelAnime_DrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, u32 dListCount, + SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, + Actor* actor) { SkelLimbEntry *rootLimb; Gfx* skelDlist[2]; @@ -540,7 +550,7 @@ void func_800A1AC8(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab if (rootLimb->firstChildIndex != LIMB_DONE) { - func_800A180C(globalCtx, rootLimb->firstChildIndex, limbTable, actorDrawTable, + SkelAnime_DrawLimbSV(globalCtx, rootLimb->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, &limbMatricies); } @@ -548,16 +558,16 @@ void func_800A1AC8(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1347); } #else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A1AC8.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_DrawSV.s") #endif #undef NON_MATCHING -/* SkelAnime_AnimateFrame +/* * 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 func_800A1D8C(u32 animation, s32 currentFrame, s32 limbCount, Vec3s *dst) +void SkelAnime_AnimateFrame(u32 animation, s32 currentFrame, s32 limbCount, Vec3s *dst) { AnimationRotationIndex* index; AnimationRotationValue* rotationValueTable; @@ -580,10 +590,10 @@ void func_800A1D8C(u32 animation, s32 currentFrame, s32 limbCount, Vec3s *dst) (rotationValueTable == NULL)) { if(1) { } // Necessary to match. - LOG("../z_skelanime.c", 0x570, "out = %08x\n", dst); - LOG("../z_skelanime.c", 0x571, "ref_tbl = %08x\n", index); - LOG("../z_skelanime.c", 0x572, "frame_tbl = %08x\n", frameRotationValueTable); - LOG("../z_skelanime.c", 0x573, "tbl = %08x\n", rotationValueTable); + LogUtils_LogThreadId("../z_skelanime.c", 1392); osSyncPrintf("out = %08x\n", dst); + LogUtils_LogThreadId("../z_skelanime.c", 1393); osSyncPrintf("ref_tbl = %08x\n", index); + LogUtils_LogThreadId("../z_skelanime.c", 1394); osSyncPrintf("frame_tbl = %08x\n", frameRotationValueTable); + LogUtils_LogThreadId("../z_skelanime.c", 1395); osSyncPrintf("tbl = %08x\n", rotationValueTable); } dst->x = index->x >= limit ? frameRotationValueTable[index->x] : rotationValueTable[index->x]; @@ -592,21 +602,22 @@ void func_800A1D8C(u32 animation, s32 currentFrame, s32 limbCount, Vec3s *dst) } } -s32 func_800A1FC8(s32 arg0) +s16 func_800A1FC8(u32 animationSeg) { - u16* virt = (u16*)SEGMENTED_TO_VIRTUAL(arg0); - return (s16)(*virt); + AnimationHeader* animation = (u16*)SEGMENTED_TO_VIRTUAL(animationSeg); + return animation->frameCount; } -s32 SkelAnime_GetFrameCount(u32 animation) +s32 SkelAnime_GetFrameCount(u32 animationSeg) { - u16* virt = (u16*)SEGMENTED_TO_VIRTUAL(animation); + AnimationHeader* animation = (u16*)SEGMENTED_TO_VIRTUAL(animationSeg); - return (s16)(*virt - 1); + return (s16)((u16)animation->frameCount - 1); } -// SkelAnime_DrawLimb2 -Gfx* func_800A2044(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, Actor* actor, Gfx* gfx) +Gfx* SkelAnime_Draw2Limb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, + SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, + Actor* actor, Gfx* gfx) { SkelLimbEntry* limbEntry; Gfx* dList; @@ -643,14 +654,16 @@ Gfx* func_800A2044(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3 if (limbEntry->firstChildIndex != LIMB_DONE) { - gfx = func_800A2044(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, gfx); + gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, + updateMtxFunc, appendDlistFunc, actor, gfx); } Matrix_Pull(); if (limbEntry->nextLimbIndex != LIMB_DONE) { - gfx = func_800A2044(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, gfx); + gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, + updateMtxFunc, appendDlistFunc, actor, gfx); } return gfx; @@ -658,8 +671,9 @@ Gfx* func_800A2044(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3 #ifdef NON_MATCHING // Some regalloc, and nonmatching stack usage -// SkelAnime_Draw2 -Gfx* func_800A2288(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, Actor* actor, Gfx* gfx) +Gfx* SkelAnime_Draw2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, + SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, + Actor* actor, Gfx* gfx) { SkelLimbEntry* limbEntry; Vec3f pos; @@ -703,7 +717,8 @@ Gfx* func_800A2288(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab if (limbEntry->firstChildIndex != LIMB_DONE) { - gfx = func_800A2044(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, gfx); + gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, + updateMtxFunc, appendDlistFunc, actor, gfx); } Matrix_Pull(); @@ -711,11 +726,12 @@ Gfx* func_800A2288(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab return gfx; } #else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A2288.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_Draw2.s") #endif -// SkelAnime_DrawLimbSV2 -Gfx* func_800A24A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, Actor* actor, Mtx** mtx, Gfx* gfx) +Gfx* SkelAnime_DrawLimbSV2(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, + SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, + Actor* actor, Mtx** mtx, Gfx* gfx) { SkelLimbEntry* limbEntry; Gfx* dList1; @@ -760,20 +776,22 @@ Gfx* func_800A24A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3 } if (limbEntry->firstChildIndex != LIMB_DONE) { - gfx = func_800A24A0(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, mtx, gfx); + gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, mtx, gfx); } Matrix_Pull(); if (limbEntry->nextLimbIndex != LIMB_DONE) { - gfx = func_800A24A0(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, mtx, gfx); + gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, mtx, gfx); } + return gfx; } -// SkelAnime_DrawSV2 -Gfx* func_800A273C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, s32 dListCount, SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, Actor* actor, Gfx* gfx) +Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, s32 dListCount, + SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, + Actor* actor, Gfx* gfx) { SkelLimbEntry* limbEntry; char pad[4]; @@ -791,6 +809,7 @@ Gfx* func_800A273C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab osSyncPrintf("\x1b[m"); return NULL; } + gSPSegment(gfx++, 0xD, mtx); Matrix_Push(); limbEntry = SEGMENTED_TO_VIRTUAL(*limbTable); @@ -828,35 +847,40 @@ Gfx* func_800A273C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab } if (limbEntry->firstChildIndex != LIMB_DONE) { - gfx = func_800A24A0(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, &mtx, gfx); + gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor, &mtx, gfx); } + Matrix_Pull(); + return gfx; } +// Seems to be some kind of rotations update, somewhat large. #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A29BC.s") -s16 func_800A2DBC(s32 arg0) +s16 func_800A2DBC(u32 animationSeg) { - u16* virt = SEGMENTED_TO_VIRTUAL(arg0); + AnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); - return virt[1]; + return animation->unk_02; } -s16 func_800A2DF4(s32 arg0) +s16 func_800A2DF4(u32 animationSeg) { - u16* virt = SEGMENTED_TO_VIRTUAL(arg0); + AnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); - return *virt; + return animation->frameCount; } -s32 func_800A2E2C(s32 arg0){ - s16* virt = SEGMENTED_TO_VIRTUAL(arg0); +s16 func_800A2E2C(u32 animationSeg) +{ + AnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); - return (s16)(*virt - 1); + return (s16)(animation->frameCount - 1); } -// Big boi function +// Very large update function #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A2E70.s") void func_800A32EC(u16* arg0) @@ -876,8 +900,8 @@ void func_800A3310(void* arg0) *D_8012A480Ptr |= D_801600B0; } -// SkelAnime_NextEntry -AnimationEntry* func_800A3334(AnimationContext* animationCtx, AnimationType type) + +AnimationEntry* SkelAnime_NextEntry(AnimationContext* animationCtx, AnimationType type) { AnimationEntry *entry; s16 index = animationCtx->animationCount; @@ -893,18 +917,17 @@ AnimationEntry* func_800A3334(AnimationContext* animationCtx, AnimationType type } /* - * These next 6 functions seem to inialize an entry in the global context's - * animation context. + * The next 6 functions are coordinate with the AnimationType enum */ -// SkelAnime_LinkAnimetionDma void func_800A336C(GlobalContext* globalCtx, u32 linkAnimetionSeg, s32 frame, s32 limbCount, void* ram) { AnimationEntry* entry; LinkAnimetionEntry *linkAnimetionEntry; char pad[4]; - entry = func_800A3334(&globalCtx->animationCtx, 0); + entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE0); + if (entry != NULL) { linkAnimetionEntry = SEGMENTED_TO_VIRTUAL(linkAnimetionSeg); @@ -914,11 +937,11 @@ void func_800A336C(GlobalContext* globalCtx, u32 linkAnimetionSeg, s32 frame, s3 "../z_skelanime.c" , 0x7D4); } } -//SkelAnime_AnimationEntryType1Init + void func_800A3478(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src) { - AnimationEntry* entry = func_800A3334(&globalCtx->animationCtx, 1); + AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE1); if (entry != NULL) { entry->types.type1.unk_00 = D_801600B0; @@ -927,11 +950,11 @@ void func_800A3478(GlobalContext* globalCtx, s32 vecCount, entry->types.type1.src = src; } } -//SkelAnime_AnimationEntryType2Init + void func_800A34DC(GlobalContext* globalCtx, s32 arg1, Vec3s* arg2, Vec3s* arg3, f32 arg4) { - AnimationEntry* entry = func_800A3334(&globalCtx->animationCtx, 2); + AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE2); if (entry != NULL) { entry->types.type2.unk_00 = D_801600B0; @@ -941,11 +964,11 @@ void func_800A34DC(GlobalContext* globalCtx, s32 arg1, entry->types.type2.unk_0C = arg4; } } -//SkelAnime_AnimationEntryType3Init + void func_800A3548(GlobalContext* globalCtx, s32 vecCount, s32 dst, s32 src, s32 index) { - AnimationEntry* entry = func_800A3334(&globalCtx->animationCtx, 3); + AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE3); if (entry != NULL) { entry->types.type3.unk_00 = D_801600B0; @@ -955,11 +978,11 @@ void func_800A3548(GlobalContext* globalCtx, s32 vecCount, entry->types.type3.index = index; } } -//SkelAnime_AnimationEntryType4Init + void func_800A35B4(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index) { - AnimationEntry* entry = func_800A3334(&globalCtx->animationCtx, 4); + AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE4); if (entry != NULL) { entry->types.type4.unk_00 = D_801600B0; @@ -969,11 +992,11 @@ void func_800A35B4(GlobalContext* globalCtx, s32 vecCount, entry->types.type4.index = index; } } -//SkelAnime_AnimationEntryType4Init + void func_800A3620(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 arg3) { - AnimationEntry* entry = func_800A3334(&globalCtx->animationCtx, 5); + AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE5); if (entry != NULL) { entry->types.type5.actor = actor; @@ -1084,7 +1107,8 @@ void func_800A390C(GlobalContext* globalCtx, AnimationContext* animationCtx) D_8012A480 = 0; } -void func_800A39AC(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 limbHeaderSeg, u32* animation, s32 flags, Vec3s* actorDrawTbl, Vec3s* arg6, s32 limbBufCount) +void func_800A39AC(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 limbHeaderSeg, u32* animation, + s32 flags, Vec3s* actorDrawTbl, Vec3s* arg6, s32 limbBufCount) { char pad[8]; SkelAnimeLimbHeader *limbHeader; @@ -1143,7 +1167,6 @@ void func_800A39AC(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 limbHeade func_800A3F08(globalCtx, skelAnime, animation, 1.0f, 0.0f, 0.0f, 0, 0.0f); } -// SkelAnime_SetUpdateFunc void func_800A3B8C(SkelAnime* skelAnime) { if (skelAnime->unk_01 < 2) @@ -1157,7 +1180,6 @@ void func_800A3B8C(SkelAnime* skelAnime) skelAnime->unk_28 = 0.0f; } -//SkelAnime_FrameUpdateMatrixGlobalCtx void func_800A3BC0(GlobalContext* globalCtx, SkelAnime* skelAnime) { skelAnime->animUpdate(globalCtx, skelAnime); @@ -1216,7 +1238,6 @@ s32 func_800A3D70(GlobalContext* globalCtx, SkelAnime* skelAnime) return 0; } -// returns 1 if animation is done? s32 func_800A3E0C(GlobalContext* globalCtx, SkelAnime* skelAnime) { f32 updateRate = R_UPDATE_RATE * 0.5f; @@ -1257,7 +1278,8 @@ void func_800A3EE8(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 arg2) } #ifdef NON_MATCHING -void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32* animation, f32 playbackSpeed, f32 arg4, f32 frameCount, u8 arg6, f32 arg7) +void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32* animation, f32 playbackSpeed, + f32 arg4, f32 frameCount, u8 arg6, f32 arg7) { skelAnime->unk_01 = arg6; @@ -1267,7 +1289,7 @@ void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32* animatio if(arg7 < 0.0f) { func_800A3B8C(skelAnime); - func_800A5774(skelAnime, skelAnime->unk_24, skelAnime->actorDrawTbl); + SkelAnime_CopyVec3s(skelAnime, skelAnime->unk_24, skelAnime->actorDrawTbl); arg7 = -arg7; } else @@ -1313,7 +1335,7 @@ void func_800A4140(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation void func_800A419C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) { - func_800A3F08(globalCtx, skelAnime, animation, playbackSpeed, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 0, 0.0f); + func_800A3F08(globalCtx, skelAnime, animation, playbackSpeed, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 0, 0.0f); } void func_800A41FC(GlobalContext* globalCtx, SkelAnime* skelAnime) @@ -1326,14 +1348,14 @@ void func_800A422C(GlobalContext* globalCtx, SkelAnime* skelAnime) func_800A3478(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24); } -void func_800A425C(GlobalContext* globalCtx, SkelAnime* skelAnime, s32 arg2, f32 arg3) +void func_800A425C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 frame) { - func_800A336C(globalCtx, arg2, (s32) arg3, skelAnime->limbCount, skelAnime->unk_24); + func_800A336C(globalCtx, animation, (s32)frame, skelAnime->limbCount, skelAnime->unk_24); } -void func_800A42A0(GlobalContext* globalCtx, SkelAnime* skelAnime, s32 arg2, f32 arg3) +void func_800A42A0(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 frame) { - func_800A336C(globalCtx, arg2, (s32) arg3, skelAnime->limbCount, skelAnime->actorDrawTbl); + func_800A336C(globalCtx, animation, (s32)frame, skelAnime->limbCount, skelAnime->actorDrawTbl); } void func_800A42E4(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 arg2) @@ -1341,18 +1363,20 @@ void func_800A42E4(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 arg2) func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, arg2); } -void func_800A431C(GlobalContext* globalCtx, SkelAnime* skelAnime, s32 arg2, f32 arg3, s32 arg4, f32 arg5, f32 arg6, s32 arg7) +void func_800A431C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animationSeg, + f32 frame, s32 arg4, f32 arg5, f32 arg6, s32 arg7) { s32 alignedAddr; - func_800A336C(globalCtx, arg2, (s32) arg3, skelAnime->limbCount, skelAnime->actorDrawTbl); + func_800A336C(globalCtx, animationSeg, (s32)frame, skelAnime->limbCount, skelAnime->actorDrawTbl); alignedAddr = ALIGN16(arg7); - func_800A336C(globalCtx, arg4, (s32) arg5, skelAnime->limbCount, alignedAddr); + func_800A336C(globalCtx, arg4, (s32)arg5, skelAnime->limbCount, alignedAddr); func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, alignedAddr, arg6); } -void func_800A43B8(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 animation, f32 frame, s32 arg4, f32 arg5, f32 arg6, s32 arg7) +void func_800A43B8(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 animation, + f32 frame, s32 arg4, f32 arg5, f32 arg6, s32 arg7) { s32 alignedAddr; @@ -1414,7 +1438,8 @@ s32 func_800A4530(SkelAnime* skelAnime, f32 arg1) return func_800A4478(skelAnime, arg1, updateRate); } -void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, u32 animation, Vec3s* actorDrawTable, s32 arg5, s32 limbCount) +void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, + u32 animation, Vec3s* actorDrawTable, s32 arg5, s32 limbCount) { SkelAnimeLimbHeader* limbHeader; @@ -1444,11 +1469,12 @@ void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHead if (animation != 0) { - func_800A52F8(skelAnime, animation); + SkelAnime_ChangeAnimationDefault(skelAnime, animation); } } -// SkelAnime_InitSV -void func_800A46F8(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, u32 animation, Vec3s* actorDrawTable, s32 arg5, s32 limbCount) + +void SkelAnime_InitSV(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, + u32 animation, Vec3s* actorDrawTable, s32 arg5, s32 limbCount) { SkelAnimeLimbHeader *limbHeader; @@ -1459,8 +1485,11 @@ void func_800A46F8(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeade if (actorDrawTable == NULL) { - skelAnime->actorDrawTbl = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), "../z_skelanime.c", 3047); - skelAnime->unk_24 = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->unk_24), "../z_skelanime.c", 3048); + skelAnime->actorDrawTbl = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), + "../z_skelanime.c", 3047); + + skelAnime->unk_24 = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->unk_24), + "../z_skelanime.c", 3048); } else { @@ -1480,11 +1509,12 @@ void func_800A46F8(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeade if (animation != 0) { - func_800A52F8(skelAnime, animation); + SkelAnime_ChangeAnimationDefault(skelAnime, animation); } } -// SkelAnime_InitSkin -void func_800A487C(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 limbHeaderSeg, u32 animation) + +void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime *skelAnime, + u32 limbHeaderSeg, u32 animation) { SkelAnimeLimbHeader *limbHeader; @@ -1502,7 +1532,7 @@ void func_800A487C(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 limbHeade if (animation != 0) { - func_800A52F8(skelAnime, animation); + SkelAnime_ChangeAnimationDefault(skelAnime, animation); } } @@ -1592,7 +1622,6 @@ s32 func_800A4AD8(SkelAnime* skelAnime) #endif #ifdef NON_MATCHING -// close void func_800A4C58(SkelAnime* skelAnime) { char pad[6]; @@ -1602,7 +1631,7 @@ void func_800A4C58(SkelAnime* skelAnime) s32 temp_f8; f32 temp_f2; - func_800A1D8C(skelAnime->animCurrent, (s32) skelAnime->animCurrentFrame, skelAnime->limbCount, skelAnime->actorDrawTbl); + SkelAnime_AnimateFrame(skelAnime->animCurrent, (s32) skelAnime->animCurrentFrame, skelAnime->limbCount, skelAnime->actorDrawTbl); if ((skelAnime->unk_01 & 1) != 0) { temp_f8 = (s32) skelAnime->animCurrentFrame; @@ -1613,7 +1642,7 @@ void func_800A4C58(SkelAnime* skelAnime) { temp_f8 = 0; } - func_800A1D8C(skelAnime->animCurrent, temp_f8, skelAnime->limbCount, sp38); + SkelAnime_AnimateFrame(skelAnime->animCurrent, temp_f8, skelAnime->limbCount, sp38); func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, sp38, temp_f2); } if (skelAnime->unk_28 != 0) @@ -1634,7 +1663,6 @@ void func_800A4C58(SkelAnime* skelAnime) #undef NON_MATCHING #ifdef NON_MATCHING -//reg alloc s32 func_800A4D9C(SkelAnime* skelAnime) { skelAnime->animCurrentFrame += (R_UPDATE_RATE * 0.33333334f) + skelAnime->animPlaybackSpeed; @@ -1655,7 +1683,6 @@ s32 func_800A4D9C(SkelAnime* skelAnime) #undef NON_MATCHING #ifdef NON_MATCHING -//reg alloc s32 func_800A4E38(SkelAnime* skelAnime) { skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * (R_UPDATE_RATE * 0.33333334f); @@ -1686,7 +1713,7 @@ s32 func_800A4EE0(SkelAnime *skelAnime) if (skelAnime->animCurrentFrame == skelAnime->animFrameCount) { - func_800A1D8C(skelAnime->animCurrent, (s32)skelAnime->animCurrentFrame, skelAnime->limbCount, skelAnime->actorDrawTbl); + SkelAnime_AnimateFrame(skelAnime->animCurrent, (s32)skelAnime->animCurrentFrame, skelAnime->limbCount, skelAnime->actorDrawTbl); func_800A4C58(skelAnime); return 1; } @@ -1714,11 +1741,8 @@ s32 func_800A4EE0(SkelAnime *skelAnime) } #ifdef NON_MATCHING -// close some regalloc, missing move zero fpr -s32 func_800A4AD8(SkelAnime* skelAnime); -s32 func_800A4A20(SkelAnime* skelAnime); -void func_800A1D8C(u32,s32,u8,Vec3s*); -void func_800A4FE4(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 unk0, f32 frameCount, u8 unk1, f32 transitionRate, s8 unk2) +void SkelAnime_ChangeAnimationImpl(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, + f32 unk0, f32 frameCount, u8 unk1, f32 transitionRate, s8 unk2) { skelAnime->unk_01 = unk1; if ((transitionRate != 0.0f) && @@ -1727,7 +1751,7 @@ void func_800A4FE4(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 u if (transitionRate < 0.0f) { func_800A49B0(skelAnime); - func_800A5774(skelAnime, skelAnime->unk_24, skelAnime->actorDrawTbl); + SkelAnime_CopyVec3s(skelAnime, skelAnime->unk_24, skelAnime->actorDrawTbl); transitionRate = -transitionRate; } else @@ -1741,7 +1765,7 @@ void func_800A4FE4(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 u { skelAnime->mtxUpdate = (void*)&func_800A4A20; } - func_800A1D8C(animation, (s32)unk0, skelAnime->limbCount, skelAnime->actorDrawTbl); + SkelAnime_AnimateFrame(animation, (s32)unk0, skelAnime->limbCount, skelAnime->actorDrawTbl); } skelAnime->unk_28 = 1.0f; skelAnime->unk_2C = 1.0f / transitionRate; @@ -1749,7 +1773,7 @@ void func_800A4FE4(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 u else { func_800A49B0(skelAnime); - func_800A1D8C(animation, (s32)unk0, skelAnime->limbCount, skelAnime->actorDrawTbl); + SkelAnime_AnimateFrame(animation, (s32)unk0, skelAnime->limbCount, skelAnime->actorDrawTbl); skelAnime->unk_28 = 0.0f; } @@ -1772,44 +1796,44 @@ void func_800A4FE4(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 u skelAnime->animPlaybackSpeed = playbackSpeed; } #else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4FE4.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_ChangeAnimationImpl.s") #endif #undef NON_MATCHING -void SkelAnime_ChangeAnimation(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 unk0, /* 0x10 */ f32 frameCount, /* 0x14 */ u8 unk1, /* 0x18 */ f32 transitionRate) +void SkelAnime_ChangeAnimation(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, + f32 unk0, f32 frameCount, u8 unk1, f32 transitionRate) { - func_800A4FE4(skelAnime, animation, playbackSpeed, unk0, frameCount, unk1, transitionRate, 0); + SkelAnime_ChangeAnimationImpl(skelAnime, animation, playbackSpeed, unk0, frameCount, unk1, transitionRate, 0); } void func_800A51E8(SkelAnime* skelAnime, u32 animation) { - SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 2, 0.0f); + SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 2, 0.0f); } void func_800A5240(SkelAnime* skelAnime, u32 animation, f32 transitionRate) { - SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0, (f32) SkelAnime_GetFrameCount(animation), 2, transitionRate); + SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0, + (f32)SkelAnime_GetFrameCount(animation), 2, transitionRate); } void func_800A529C(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) { - SkelAnime_ChangeAnimation(skelAnime, animation, playbackSpeed, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 2, 0.0f); + SkelAnime_ChangeAnimation(skelAnime, animation, playbackSpeed, 0.0f, + (f32)SkelAnime_GetFrameCount(animation), 2, 0.0f); } -// SkelAnime_ChangeAnimationDefault -void func_800A52F8(SkelAnime* skelAnime, u32 animation) +void SkelAnime_ChangeAnimationDefault(SkelAnime* skelAnime, u32 animation) { SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 0, 0.0f); } -// SkelAnime_ChangeAnimationTransitionRate -void func_800A534C(SkelAnime* skelAnime, u32 animation, f32 transitionRate) +void SkelAnime_ChangeAnimationTransitionRate(SkelAnime* skelAnime, u32 animation, f32 transitionRate) { SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, 0.0f, 0, transitionRate); } -//SkelAnime_ChangeAnimationPlaybackSpeed -void func_800A5384(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) +void SkelAnime_ChangeAnimationPlaybackSpeed(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) { SkelAnime_ChangeAnimation(skelAnime, animation, playbackSpeed, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 0, 0.0f); } @@ -1837,12 +1861,12 @@ void func_800A5408(SkelAnime* skelAnime) #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A5408.s") #endif -void func_800A5428(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* arg3) +void func_800A5428(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* index) { s32 i; for(i = 0; i < skelAnime->limbCount; i++, dst++, src++) { - if(*arg3++) + if(*index++) { *dst = *src; } @@ -1919,8 +1943,7 @@ s32 func_800A56C8(SkelAnime *skelAnime, f32 arg1) return func_800A4478(skelAnime, arg1, 1.0f); } -// SkelAnime_Free -void func_800A56F0(SkelAnime *skelAnime, s32 arg1) +void SkelAnime_Free(SkelAnime *skelAnime, GlobalContext* globalCtx) { if (skelAnime->actorDrawTbl != NULL) { @@ -1938,8 +1961,7 @@ void func_800A56F0(SkelAnime *skelAnime, s32 arg1) osSyncPrintf("morf_joint あきまへん!!\n"); // "morf_joint Akimane !!" } -// SkelAnime_CopyVec3s -void func_800A5774(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src) +void SkelAnime_CopyVec3s(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src) { s32 i; for(i = 0; i < skelAnime->limbCount; i++) -- cgit v1.2.3 From db3cfe1b61397a6656f4d92dd0835a589cf72c68 Mon Sep 17 00:00:00 2001 From: KrimtonZ Date: Tue, 24 Mar 2020 12:16:13 -0500 Subject: use clang, modify z64animation.h and z64dma.h to use open braces on newline --- src/code/sys_matrix.c | 104 ++--- src/code/z_actor.c | 8 +- src/code/z_sample.c | 5 +- src/code/z_skelanime.c | 1143 ++++++++++++++++++------------------------------ 4 files changed, 466 insertions(+), 794 deletions(-) (limited to 'src/code') diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index 0d1ed55e7..fd474f1fc 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -22,52 +22,41 @@ MtxF gMtxFClear = MtxF* sMatrixStack; // "Matrix_stack" MtxF* sCurrentMatrix; // "Matrix_now" -void Matrix_Init(GameState* gameState) -{ +void Matrix_Init(GameState* gameState) { sCurrentMatrix = Game_Alloc(gameState, 20 * sizeof(MtxF), "../sys_matrix.c", 153); sMatrixStack = sCurrentMatrix; } -void Matrix_Push(void) -{ +void Matrix_Push(void) { Matrix_MtxFCopy(sCurrentMatrix + 1, sCurrentMatrix); sCurrentMatrix++; } -void Matrix_Pull(void) -{ +void Matrix_Pull(void) { sCurrentMatrix--; - if (sCurrentMatrix < sMatrixStack) - { + if (sCurrentMatrix < sMatrixStack) { __assert("Matrix_now >= Matrix_stack", "../sys_matrix.c", 176); } } -void Matrix_Get(MtxF* dest) -{ +void Matrix_Get(MtxF* dest) { Matrix_MtxFCopy(dest, sCurrentMatrix); } -void Matrix_Put(MtxF* src) -{ +void Matrix_Put(MtxF* src) { Matrix_MtxFCopy(sCurrentMatrix, src); } -MtxF* Matrix_GetCurrent(void) -{ +MtxF* Matrix_GetCurrent(void) { return sCurrentMatrix; } -void Matrix_Mult(MtxF* mf, u8 mode) -{ +void Matrix_Mult(MtxF* mf, u8 mode) { MtxF* cmf = Matrix_GetCurrent(); - if (mode == MTXMODE_APPLY) - { + if (mode == MTXMODE_APPLY) { func_800A6FA0(cmf, mf, cmf); - } - else - { + } else { Matrix_MtxFCopy(sCurrentMatrix, mf); } } @@ -77,8 +66,7 @@ void Matrix_Translate(f32 x, f32 y, f32 z, u8 mode) { f32 tx; f32 ty; - if (mode == MTXMODE_APPLY) - { + if (mode == MTXMODE_APPLY) { tx = cmf->xx; ty = cmf->yx; cmf->wx += tx * x + ty * y + cmf->zx * z; @@ -91,19 +79,15 @@ void Matrix_Translate(f32 x, f32 y, f32 z, u8 mode) { tx = cmf->xw; ty = cmf->yw; cmf->ww += tx * x + ty * y + cmf->zw * z; - } - else - { + } else { func_800A7A24(cmf, x, y, z); } } -void Matrix_Scale(f32 x, f32 y, f32 z, u8 mode) -{ +void Matrix_Scale(f32 x, f32 y, f32 z, u8 mode) { MtxF* cmf = sCurrentMatrix; - if (mode == MTXMODE_APPLY) - { + if (mode == MTXMODE_APPLY) { cmf->xx *= x; cmf->xy *= x; cmf->xz *= x; @@ -116,25 +100,20 @@ void Matrix_Scale(f32 x, f32 y, f32 z, u8 mode) cmf->xw *= x; cmf->yw *= y; cmf->zw *= z; - } - else - { + } else { func_800A76A4(cmf, x, y, z); } } -void Matrix_RotateX(f32 x, u8 mode) -{ +void Matrix_RotateX(f32 x, u8 mode) { MtxF* cmf; f32 sin; f32 cos; f32 temp1; f32 temp2; - if (mode == MTXMODE_APPLY) - { - if (x != 0) - { + if (mode == MTXMODE_APPLY) { + if (x != 0) { cmf = sCurrentMatrix; sin = sinf(x); @@ -160,18 +139,13 @@ void Matrix_RotateX(f32 x, u8 mode) cmf->yw = temp1 * cos + temp2 * sin; cmf->zw = temp2 * cos - temp1 * sin; } - } - else - { + } else { cmf = sCurrentMatrix; - if (x != 0) - { + if (x != 0) { sin = sinf(x); cos = cosf(x); - } - else - { + } else { sin = 0.0f; cos = 1.0f; } @@ -195,18 +169,15 @@ void Matrix_RotateX(f32 x, u8 mode) } } -void Matrix_RotateY(f32 y, u8 mode) -{ +void Matrix_RotateY(f32 y, u8 mode) { MtxF* cmf; f32 sin; f32 cos; f32 temp1; f32 temp2; - if (mode == MTXMODE_APPLY) - { - if (y != 0) - { + if (mode == MTXMODE_APPLY) { + if (y != 0) { cmf = sCurrentMatrix; sin = sinf(y); @@ -232,18 +203,13 @@ void Matrix_RotateY(f32 y, u8 mode) cmf->xw = temp1 * cos - temp2 * sin; cmf->zw = temp1 * sin + temp2 * cos; } - } - else - { + } else { cmf = sCurrentMatrix; - if (y != 0) - { + if (y != 0) { sin = sinf(y); cos = cosf(y); - } - else - { + } else { sin = 0.0f; cos = 1.0f; } @@ -267,18 +233,15 @@ void Matrix_RotateY(f32 y, u8 mode) } } -void Matrix_RotateZ(f32 z, u8 mode) -{ +void Matrix_RotateZ(f32 z, u8 mode) { MtxF* cmf; f32 sin; f32 cos; f32 temp1; f32 temp2; - if (mode == MTXMODE_APPLY) - { - if (z != 0) - { + if (mode == MTXMODE_APPLY) { + if (z != 0) { cmf = sCurrentMatrix; sin = sinf(z); @@ -339,7 +302,7 @@ void Matrix_RotateZ(f32 z, u8 mode) * rotates that matrix by `y` degrees, then rotates that matrix * by `x` degrees. * Original Name: Matrix_RotateXYZ, changed to reflect rotation order. -*/ + */ void Matrix_RotateZYX(s16 x, s16 y, s16 z, u8 mode) { MtxF* cmf = sCurrentMatrix; f32 temp1; @@ -428,9 +391,8 @@ void Matrix_RotateZYX(s16 x, s16 y, s16 z, u8 mode) { /* * Translates the top of the matrix stack by `translation` units, * then rotates that matrix by `rotation` in Z-Y-X order -*/ -void Matrix_TranslateThenRotateZYX(Vec3f* translation, Vec3s* rotation) -{ + */ +void Matrix_TranslateThenRotateZYX(Vec3f* translation, Vec3s* rotation) { MtxF* cmf = sCurrentMatrix; f32 sin; f32 cos; diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 91bf21c5e..eec16df03 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -3898,8 +3898,8 @@ void func_80034BA0(GlobalContext* globalCtx, SkelAnime* skelAnime, void* unkFunc gDPPipeSync(gfxCtx->polyOpa.p++); gSPSegment(gfxCtx->polyOpa.p++, 0x0C, func_80034B28(globalCtx->state.gfxCtx)); - gfxCtx->polyOpa.p = SkelAnime_DrawSV2(globalCtx, skelAnime->limbIndex, skelAnime->actorDrawTbl, skelAnime->dListCount, - unkFunc1, unkFunc2, actor, gfxCtx->polyOpa.p); + gfxCtx->polyOpa.p = SkelAnime_DrawSV2(globalCtx, skelAnime->limbIndex, skelAnime->actorDrawTbl, + skelAnime->dListCount, unkFunc1, unkFunc2, actor, gfxCtx->polyOpa.p); func_800C6B54(gfxArr, globalCtx->state.gfxCtx, "../z_actor.c", 8860); } @@ -3917,8 +3917,8 @@ void func_80034CC4(GlobalContext* globalCtx, SkelAnime* skelAnime, void* unkFunc gDPSetEnvColor(gfxCtx->polyXlu.p++, 0x00, 0x00, 0x00, alpha); gSPSegment(gfxCtx->polyXlu.p++, 0x0C, func_80034B54(globalCtx->state.gfxCtx)); - gfxCtx->polyXlu.p = SkelAnime_DrawSV2(globalCtx, skelAnime->limbIndex, skelAnime->actorDrawTbl, skelAnime->dListCount, - unkFunc1, unkFunc2, actor, gfxCtx->polyXlu.p); + gfxCtx->polyXlu.p = SkelAnime_DrawSV2(globalCtx, skelAnime->limbIndex, skelAnime->actorDrawTbl, + skelAnime->dListCount, unkFunc1, unkFunc2, actor, gfxCtx->polyXlu.p); func_800C6B54(gfxArr, globalCtx->state.gfxCtx, "../z_actor.c", 8904); } diff --git a/src/code/z_sample.c b/src/code/z_sample.c index 2f4f3fc6f..9b9fa9559 100644 --- a/src/code/z_sample.c +++ b/src/code/z_sample.c @@ -34,10 +34,11 @@ void Sample_Draw(SampleContext* this) { gfxCtx->polyOpa.p = func_80093708(gfxCtx->polyOpa.p, 0xFF, 0xFF, 0xFF, 0, 0, 0); func_80093D18(gfxCtx); - + gDPSetCycleType(gfxCtx->polyOpa.p++, G_CYC_1CYCLE); gDPSetRenderMode(gfxCtx->polyOpa.p++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - gDPSetCombineLERP(gfxCtx->polyOpa.p++, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE); + gDPSetCombineLERP(gfxCtx->polyOpa.p++, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE, 0, 0, 0, + PRIMITIVE); gDPSetPrimColor(gfxCtx->polyOpa.p++, 0, 0, 0xFF, 0xFF, 0x00, 0x00); func_800C6B54(gfxArr, gfxCtx, "../z_sample.c", 111); diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 9066a226c..7001c8fca 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1,8 +1,8 @@ #include #include -s32 func_800A3D70(GlobalContext*,SkelAnime*); -s32 func_800A3E0C(GlobalContext*,SkelAnime*); +s32 func_800A3D70(GlobalContext*, SkelAnime*); +s32 func_800A3E0C(GlobalContext*, SkelAnime*); s32 func_800A4D9C(SkelAnime* skelAnime); s32 func_800A4EE0(SkelAnime* skelAnime); s32 func_800A4E38(SkelAnime* skelAnime); @@ -16,23 +16,18 @@ void func_800A3874(GlobalContext* globalCtx, AnimationEntryType5* entry); //.data u32 D_8012A480 = 0; -static AnimationEntryCallback D_8012A484[] = -{ - (AnimationEntryCallback)&func_800A3678, - (AnimationEntryCallback)&func_800A36A4, - (AnimationEntryCallback)&func_800A3714, - (AnimationEntryCallback)&func_800A3770, - (AnimationEntryCallback)&func_800A37F0, - (AnimationEntryCallback)&func_800A3874, +static AnimationEntryCallback D_8012A484[] = { + (AnimationEntryCallback)&func_800A3678, (AnimationEntryCallback)&func_800A36A4, + (AnimationEntryCallback)&func_800A3714, (AnimationEntryCallback)&func_800A3770, + (AnimationEntryCallback)&func_800A37F0, (AnimationEntryCallback)&func_800A3874, }; //.bss u32 D_801600B0; -void SkelAnime_LodDrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec3s* actorDrawTable, +void SkelAnime_LodDrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, - Actor* actor, s32 dListIndex) -{ + Actor* actor, s32 dListIndex) { SkelLimbEntry* limbEntry; Gfx* dList; Vec3f pos; @@ -52,42 +47,34 @@ void SkelAnime_LodDrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTab pos.z = limbEntry->translation.z; dList = limbEntry->displayLists[dListIndex]; - if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList, &pos, &rot, actor) == 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", 0x325), + if (dList != NULL) { + do { + if (1) { + gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 0x325), G_MTX_LOAD); gSPDisplayList(gfxCtx->polyOpa.p++, dList); } - } while(0); + } while (0); } } - if (appendDlistFunc != NULL) - { + if (appendDlistFunc != NULL) { appendDlistFunc(globalCtx, limbIndex, &dList, &rot, actor); } - if (limbEntry->firstChildIndex != LIMB_DONE) - { - SkelAnime_LodDrawLimb(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, - updateMtxFunc, appendDlistFunc, actor, dListIndex); + if (limbEntry->firstChildIndex != LIMB_DONE) { + SkelAnime_LodDrawLimb(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor, dListIndex); } Matrix_Pull(); - if (limbEntry->nextLimbIndex != LIMB_DONE) - { - SkelAnime_LodDrawLimb(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, - updateMtxFunc, appendDlistFunc, actor, dListIndex); + if (limbEntry->nextLimbIndex != LIMB_DONE) { + SkelAnime_LodDrawLimb(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor, dListIndex); } func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x335); @@ -95,8 +82,7 @@ void SkelAnime_LodDrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTab void SkelAnime_LodDraw(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, - Actor* actor, s32 dListIndex) -{ + Actor* actor, s32 dListIndex) { SkelLimbEntry* limbEntry; char pad[4]; Gfx* dList; @@ -105,8 +91,7 @@ void SkelAnime_LodDraw(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDra GraphicsContext* gfxCtx; Gfx* gfx[4]; - if (limbIndex == NULL) - { + if (limbIndex == NULL) { osSyncPrintf("\x1b[31m"); osSyncPrintf("Si2_Lod_draw():skelがNULLです。\n"); osSyncPrintf("\x1b[m"); @@ -117,33 +102,29 @@ void SkelAnime_LodDraw(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDra Matrix_Push(); limbEntry = SEGMENTED_TO_VIRTUAL(*limbIndex); - pos.x = (f32) actorDrawTable->x; - pos.y = (f32) actorDrawTable->y; - pos.z = (f32) actorDrawTable->z; + pos.x = (f32)actorDrawTable->x; + pos.y = (f32)actorDrawTable->y; + pos.z = (f32)actorDrawTable->z; rot = actorDrawTable[1]; dList = limbEntry->displayLists[dListIndex]; - if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList, &pos, &rot, actor) == 0)) - { + 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", 0x371), + if (dList != NULL) { + gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 0x371), G_MTX_LOAD); gSPDisplayList(gfxCtx->polyOpa.p++, dList); } } - if (appendDlistFunc != NULL) - { + if (appendDlistFunc != NULL) { appendDlistFunc(globalCtx, 1, &dList, &rot, actor); } - if (limbEntry->firstChildIndex != 0xFF) - { - SkelAnime_LodDrawLimb(globalCtx, limbEntry->firstChildIndex, limbIndex, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex); + if (limbEntry->firstChildIndex != 0xFF) { + SkelAnime_LodDrawLimb(globalCtx, limbEntry->firstChildIndex, limbIndex, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor, dListIndex); } Matrix_Pull(); @@ -153,8 +134,7 @@ void SkelAnime_LodDraw(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDra #ifdef NON_MATCHING void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, - Actor* actor, s32 dListIndex, Mtx** mtx) -{ + Actor* actor, s32 dListIndex, Mtx** mtx) { SkelLimbEntry* limbEntry; Gfx* dList[2]; Vec3f pos; @@ -174,40 +154,34 @@ void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, u32* limbT pos.z = limbEntry->translation.z; dList[1] = dList[0] = limbEntry->displayLists[dListIndex]; - if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList[1], &pos, &rot, actor) == 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; + if (dList[1] != NULL) { + Matrix_ToMtx(*mtx, "../z_skelanime.c", 945); + gfxCtx = globalCtx->state.gfxCtx; func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 946); gSPMatrix(gfxCtx->polyOpa.p++, *mtx, G_MTX_LOAD); gSPDisplayList(gfxCtx->polyOpa.p++, dList[1]); func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 949); (*mtx)++; - } - else if (dList[0] != 0) - { + } else if (dList[0] != 0) { Matrix_ToMtx(*mtx, "../z_skelanime.c", 954); (*mtx)++; } } - if (appendDlistFunc != NULL) - { + if (appendDlistFunc != NULL) { appendDlistFunc(globalCtx, limbIndex, &dList[0], &rot, actor); } - if (limbEntry->firstChildIndex != LIMB_DONE) - { - SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, - updateMtxFunc, appendDlistFunc, actor, dListIndex, mtx); + if (limbEntry->firstChildIndex != LIMB_DONE) { + SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor, dListIndex, mtx); } Matrix_Pull(); - if (limbEntry->nextLimbIndex != LIMB_DONE) - { - SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->nextLimbIndex, limbTable, - actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex, mtx); + if (limbEntry->nextLimbIndex != LIMB_DONE) { + SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor, dListIndex, mtx); } } #else @@ -217,9 +191,8 @@ void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, u32* limbT #ifdef NON_MATCHING void SkelAnime_LodDrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, s32 limbCount, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, - Actor* actor, s32 dListIndex) -{ - SkelLimbEntry *limbEntry; + Actor* actor, s32 dListIndex) { + SkelLimbEntry* limbEntry; Gfx* dList[2]; Vec3f pos; Vec3s rot; @@ -227,16 +200,13 @@ void SkelAnime_LodDrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorD GraphicsContext* gfxCtx; Gfx* gfx[4]; - do - { - if(1) - { + do { + if (1) { mtx = Graph_Alloc(globalCtx->state.gfxCtx, limbCount * 0x40); } - } while(0); + } while (0); - if (limbTable == NULL) - { + if (limbTable == NULL) { osSyncPrintf("\x1b[31m"); osSyncPrintf("Si2_Lod_draw_SV():skelがNULLです。\n"); osSyncPrintf("\x1b[m"); @@ -255,35 +225,29 @@ void SkelAnime_LodDrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorD rot = actorDrawTable[1]; - dList[1] = dList[0] = limbEntry->displayLists[dListIndex]; + dList[1] = dList[0] = limbEntry->displayLists[dListIndex]; - if ((updateMtxFunc == 0) || (updateMtxFunc(globalCtx, 1, &dList[1], &pos, &rot, actor) == 0)) - { + if ((updateMtxFunc == 0) || (updateMtxFunc(globalCtx, 1, &dList[1], &pos, &rot, actor) == 0)) { Matrix_TranslateThenRotateZYX(&pos, &rot); - if (dList[1] != NULL) - { + if (dList[1] != NULL) { Matrix_ToMtx(mtx, "../z_skelanime.c", 1033); gSPMatrix(gfxCtx->polyOpa.p++, mtx, G_MTX_LOAD); gSPDisplayList(gfxCtx->polyOpa.p++, dList[1]); mtx++; - } - else - { - if (dList[0] != NULL) - { + } else { + if (dList[0] != NULL) { Matrix_ToMtx(mtx, "../z_skelanime.c", 1040); mtx++; } } } - if (appendDlistFunc != NULL) - { + if (appendDlistFunc != NULL) { appendDlistFunc(globalCtx, 1, &dList[0], &rot, actor); } - if (limbEntry->firstChildIndex != LIMB_DONE) - { - SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex, &mtx); + if (limbEntry->firstChildIndex != LIMB_DONE) { + SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor, dListIndex, &mtx); } Matrix_Pull(); @@ -296,8 +260,7 @@ void SkelAnime_LodDrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorD void SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, - Actor* actor) -{ + Actor* actor) { SkelLimbEntry* limbEntry; Gfx* dList; Vec3f pos; @@ -313,53 +276,45 @@ void SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, limbEntry = SEGMENTED_TO_VIRTUAL(limbTable[limbIndex]); limbIndex++; rot = actorDrawTable[limbIndex]; - pos.x = (f32) limbEntry->translation.x; - pos.y = (f32) limbEntry->translation.y; - pos.z = (f32) limbEntry->translation.z; + pos.x = (f32)limbEntry->translation.x; + pos.y = (f32)limbEntry->translation.y; + pos.z = (f32)limbEntry->translation.z; dList = limbEntry->displayLists[0]; - if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList, &pos, &rot, actor) == 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); + 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); + } while (0); } } - if (appendDlistFunc != NULL) - { + if (appendDlistFunc != NULL) { appendDlistFunc(globalCtx, limbIndex, &dList, &rot, actor); } - if (limbEntry->firstChildIndex != LIMB_DONE) - { - SkelAnime_DrawLimb(globalCtx, limbEntry->firstChildIndex, limbTable, - actorDrawTable, updateMtxFunc, appendDlistFunc, actor); + if (limbEntry->firstChildIndex != LIMB_DONE) { + SkelAnime_DrawLimb(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor); } Matrix_Pull(); - if (limbEntry->nextLimbIndex != LIMB_DONE) - { - SkelAnime_DrawLimb(globalCtx, limbEntry->nextLimbIndex, limbTable, - actorDrawTable, updateMtxFunc, appendDlistFunc, actor); + if (limbEntry->nextLimbIndex != LIMB_DONE) { + SkelAnime_DrawLimb(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor); } func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1121); } void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, - SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, - Actor* actor) -{ + SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) { SkelLimbEntry* rootLimb; char pad[4]; Gfx* dList; @@ -368,8 +323,7 @@ void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTa GraphicsContext* gfxCtx; Gfx* gfx[4]; - if (limbTable == NULL) - { + if (limbTable == NULL) { osSyncPrintf("\x1b[31m"); osSyncPrintf("Si2_draw():skelがNULLです。\n"); // Si2_draw (): skel is NULL. osSyncPrintf("\x1b[m"); @@ -382,32 +336,29 @@ void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTa Matrix_Push(); rootLimb = SEGMENTED_TO_VIRTUAL(*limbTable); - pos.x = (f32) actorDrawTable[0].x; - pos.y = (f32) actorDrawTable[0].y; - pos.z = (f32) actorDrawTable[0].z; + pos.x = (f32)actorDrawTable[0].x; + pos.y = (f32)actorDrawTable[0].y; + pos.z = (f32)actorDrawTable[0].z; rot = actorDrawTable[1]; dList = rootLimb->displayLists[0]; - if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList, &pos, &rot, actor) == 0)) - { + 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); + if (dList != NULL) { + gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 1176), + G_MTX_LOAD); gSPDisplayList(gfxCtx->polyOpa.p++, dList); } } - if (appendDlistFunc != NULL) - { + if (appendDlistFunc != NULL) { appendDlistFunc(globalCtx, 1, &dList, &rot, actor); } - if (rootLimb->firstChildIndex != LIMB_DONE) - { - SkelAnime_DrawLimb(globalCtx, rootLimb->firstChildIndex, limbTable, - actorDrawTable, updateMtxFunc, appendDlistFunc, actor); + if (rootLimb->firstChildIndex != LIMB_DONE) { + SkelAnime_DrawLimb(globalCtx, rootLimb->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor); } Matrix_Pull(); @@ -416,14 +367,13 @@ void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTa } #ifdef NON_MATCHING -void SkelAnime_DrawLimbSV(GlobalContext *globalCtx, u32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, +void SkelAnime_DrawLimbSV(GlobalContext* globalCtx, u32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, - Actor* actor, Mtx** limbMatricies) -{ + Actor* actor, Mtx** limbMatricies) { Gfx* limbDlist[2]; Vec3f limbPos; Vec3s limbRot; - GraphicsContext *gfxCtx; + GraphicsContext* gfxCtx; Gfx* sp34[3]; SkelLimbEntry* limbEntry; @@ -433,49 +383,43 @@ void SkelAnime_DrawLimbSV(GlobalContext *globalCtx, u32 limbIndex, u32* limbTabl limbEntry = SEGMENTED_TO_VIRTUAL(limbTable[limbIndex]); limbRot = actorDrawTable[++limbIndex]; - limbPos.x = (f32) limbEntry->pos.x; - limbPos.y = (f32) limbEntry->pos.y; - limbPos.z = (f32) limbEntry->pos.z; + limbPos.x = (f32)limbEntry->pos.x; + limbPos.y = (f32)limbEntry->pos.y; + limbPos.z = (f32)limbEntry->pos.z; limbDlist[0] = limbEntry->dList; limbDlist[1] = limbEntry->dList; - if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &limbDlist[0], &limbPos, &limbRot, actor) == 0)) - { + if ((updateMtxFunc == NULL) || + (updateMtxFunc(globalCtx, limbIndex, &limbDlist[0], &limbPos, &limbRot, actor) == 0)) { Matrix_TranslateThenRotateZYX(&limbPos, &limbRot); - if (limbDlist[0] != NULL) - { + if (limbDlist[0] != NULL) { Matrix_ToMtx(*limbMatricies, "../z_skelanime.c", 0x4DA); gSPMatrix(gfxCtx->polyOpa.p++, *limbMatricies, G_MTX_LOAD); gSPDisplayList(gfxCtx->polyOpa.p++, &limbDlist[0]); (*limbMatricies)++; - } - else - { - if (&limbDlist[1] != 0) - { + } else { + if (&limbDlist[1] != 0) { Matrix_ToMtx(*limbMatricies, "../z_skelanime.c", 0x4E1); (*limbMatricies)++; } } } - if (appendDlistFunc != NULL) - { + if (appendDlistFunc != NULL) { appendDlistFunc(globalCtx, limbIndex, &limbDlist[1], &limbRot, actor); } - if (limbEntry->firstChildIndex != LIMB_DONE) - { - SkelAnime_DrawLimbSV(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, limbMatricies); + if (limbEntry->firstChildIndex != LIMB_DONE) { + SkelAnime_DrawLimbSV(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor, limbMatricies); } Matrix_Pull(); - if (limbEntry->nextLimbIndex != LIMB_DONE) - { - SkelAnime_DrawLimbSV(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, - updateMtxFunc, appendDlistFunc, actor, limbMatricies); + if (limbEntry->nextLimbIndex != LIMB_DONE) { + SkelAnime_DrawLimbSV(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor, limbMatricies); } func_800C6B54(sp34, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x4F1); @@ -487,22 +431,20 @@ void SkelAnime_DrawLimbSV(GlobalContext *globalCtx, u32 limbIndex, u32* limbTabl #ifdef NON_MATCHING void SkelAnime_DrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, u32 dListCount, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, - Actor* actor) -{ - SkelLimbEntry *rootLimb; + Actor* actor) { + SkelLimbEntry* rootLimb; Gfx* skelDlist[2]; Vec3f pos; Vec3s rot; GraphicsContext* gfxCtx; Mtx* limbMatricies; - Gfx *gfx[5]; + Gfx* gfx[5]; limbMatricies = Graph_Alloc(globalCtx->state.gfxCtx, dListCount << 6); - if (limbTable == NULL) - { + if (limbTable == NULL) { osSyncPrintf("\x1b[31m"); - osSyncPrintf("Si2_draw_SV():skelがNULLです。\n"); //Si2_draw_SV (): skel is NULL. + osSyncPrintf("Si2_draw_SV():skelがNULLです。\n"); // Si2_draw_SV (): skel is NULL. osSyncPrintf("\x1b[m"); return; } @@ -515,43 +457,36 @@ void SkelAnime_DrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDraw Matrix_Push(); rootLimb = SEGMENTED_TO_VIRTUAL(*limbTable); - pos.x = (f32) actorDrawTable[0].x; - pos.y = (f32) actorDrawTable[0].y; - pos.z = (f32) actorDrawTable[0].z; + pos.x = (f32)actorDrawTable[0].x; + pos.y = (f32)actorDrawTable[0].y; + pos.z = (f32)actorDrawTable[0].z; rot = actorDrawTable[1]; skelDlist[0] = skelDlist[1] = rootLimb->dList; - if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &skelDlist[0], &pos, &rot, actor) == 0)) - { + if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &skelDlist[0], &pos, &rot, actor) == 0)) { Matrix_TranslateThenRotateZYX(&pos, &rot); - if (skelDlist[0] != NULL) - { + if (skelDlist[0] != NULL) { Matrix_ToMtx(limbMatricies, "../z_skelanime.c", 1327); gSPMatrix(gfxCtx->polyOpa.p++, limbMatricies, G_MTX_LOAD); gSPDisplayList(gfxCtx->polyOpa.p++, skelDlist[0]); limbMatricies++; - } - else - { - if (skelDlist[1] != 0) - { + } else { + if (skelDlist[1] != 0) { Matrix_ToMtx(limbMatricies, "../z_skelanime.c", 1334); limbMatricies++; } } } - if (appendDlistFunc != 0) - { + if (appendDlistFunc != 0) { appendDlistFunc(globalCtx, 1, &skelDlist[1], &rot, actor); } - if (rootLimb->firstChildIndex != LIMB_DONE) - { - SkelAnime_DrawLimbSV(globalCtx, rootLimb->firstChildIndex, limbTable, actorDrawTable, - updateMtxFunc, appendDlistFunc, actor, &limbMatricies); + if (rootLimb->firstChildIndex != LIMB_DONE) { + SkelAnime_DrawLimbSV(globalCtx, rootLimb->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor, &limbMatricies); } Matrix_Pull(); @@ -566,13 +501,12 @@ void SkelAnime_DrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDraw * 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(u32 animation, s32 currentFrame, s32 limbCount, Vec3s *dst) -{ + */ +void SkelAnime_AnimateFrame(u32 animation, s32 currentFrame, s32 limbCount, Vec3s* dst) { AnimationRotationIndex* index; AnimationRotationValue* rotationValueTable; AnimationRotationValue* frameRotationValueTable; - AnimationHeader *animationHeader; + AnimationHeader* animationHeader; s32 i; u16 limit; @@ -583,17 +517,17 @@ void SkelAnime_AnimateFrame(u32 animation, s32 currentFrame, s32 limbCount, Vec3 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. - LogUtils_LogThreadId("../z_skelanime.c", 1392); osSyncPrintf("out = %08x\n", dst); - LogUtils_LogThreadId("../z_skelanime.c", 1393); osSyncPrintf("ref_tbl = %08x\n", index); - LogUtils_LogThreadId("../z_skelanime.c", 1394); osSyncPrintf("frame_tbl = %08x\n", frameRotationValueTable); - LogUtils_LogThreadId("../z_skelanime.c", 1395); osSyncPrintf("tbl = %08x\n", rotationValueTable); + for (i = 0; i < limbCount; i++, dst++, index++) { + if ((dst == NULL) || (index == NULL) || (frameRotationValueTable == NULL) || (rotationValueTable == NULL)) { + if (1) {} // Necessary to match. + LogUtils_LogThreadId("../z_skelanime.c", 1392); + osSyncPrintf("out = %08x\n", dst); + LogUtils_LogThreadId("../z_skelanime.c", 1393); + osSyncPrintf("ref_tbl = %08x\n", index); + LogUtils_LogThreadId("../z_skelanime.c", 1394); + osSyncPrintf("frame_tbl = %08x\n", frameRotationValueTable); + LogUtils_LogThreadId("../z_skelanime.c", 1395); + osSyncPrintf("tbl = %08x\n", rotationValueTable); } dst->x = index->x >= limit ? frameRotationValueTable[index->x] : rotationValueTable[index->x]; @@ -602,14 +536,12 @@ void SkelAnime_AnimateFrame(u32 animation, s32 currentFrame, s32 limbCount, Vec3 } } -s16 func_800A1FC8(u32 animationSeg) -{ +s16 func_800A1FC8(u32 animationSeg) { AnimationHeader* animation = (u16*)SEGMENTED_TO_VIRTUAL(animationSeg); return animation->frameCount; } -s32 SkelAnime_GetFrameCount(u32 animationSeg) -{ +s32 SkelAnime_GetFrameCount(u32 animationSeg) { AnimationHeader* animation = (u16*)SEGMENTED_TO_VIRTUAL(animationSeg); return (s16)((u16)animation->frameCount - 1); @@ -617,8 +549,7 @@ s32 SkelAnime_GetFrameCount(u32 animationSeg) Gfx* SkelAnime_Draw2Limb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, - Actor* actor, Gfx* gfx) -{ + Actor* actor, Gfx* gfx) { SkelLimbEntry* limbEntry; Gfx* dList; Vec3f pos; @@ -637,33 +568,28 @@ Gfx* SkelAnime_Draw2Limb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable dList = limbEntry->displayLists[0]; - if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList, &pos, &rot, actor, &gfx) == 0)) - { + if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList, &pos, &rot, actor, &gfx) == 0)) { Matrix_TranslateThenRotateZYX(&pos, &rot); - if (dList != NULL) - { + if (dList != NULL) { gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 0x5D1), G_MTX_LOAD); gSPDisplayList(gfx++, dList); } } - if (appendDlistFunc != NULL) - { + if (appendDlistFunc != NULL) { appendDlistFunc(globalCtx, limbIndex, &dList, &rot, actor, &gfx); } - if (limbEntry->firstChildIndex != LIMB_DONE) - { - gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, - updateMtxFunc, appendDlistFunc, actor, gfx); + if (limbEntry->firstChildIndex != LIMB_DONE) { + gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor, gfx); } Matrix_Pull(); - if (limbEntry->nextLimbIndex != LIMB_DONE) - { - gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, - updateMtxFunc, appendDlistFunc, actor, gfx); + if (limbEntry->nextLimbIndex != LIMB_DONE) { + gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor, gfx); } return gfx; @@ -673,15 +599,13 @@ Gfx* SkelAnime_Draw2Limb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable // Some regalloc, and nonmatching stack usage Gfx* SkelAnime_Draw2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, - Actor* actor, Gfx* gfx) -{ + Actor* actor, Gfx* gfx) { SkelLimbEntry* limbEntry; Vec3f pos; Vec3s rot; Gfx* dList; - if (limbTable == NULL) - { + if (limbTable == NULL) { osSyncPrintf("\x1b[31m"); osSyncPrintf("Si2_draw2():skelがNULLです。NULLを返します。\n"); osSyncPrintf("\x1b[m"); @@ -700,25 +624,21 @@ Gfx* SkelAnime_Draw2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawT dList = limbEntry->displayLists[0]; - if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList, &pos, &rot, actor, &gfx) == 0)) - { + if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList, &pos, &rot, actor, &gfx) == 0)) { Matrix_TranslateThenRotateZYX(&pos, &rot); - if (dList != NULL) - { + if (dList != NULL) { gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 0x616), G_MTX_LOAD); gSPDisplayList(gfx++, dList); } } - if (appendDlistFunc != NULL) - { + if (appendDlistFunc != NULL) { appendDlistFunc(globalCtx, 1, &dList, &rot, actor, &gfx); } - if (limbEntry->firstChildIndex != LIMB_DONE) - { - gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, - updateMtxFunc, appendDlistFunc, actor, gfx); + if (limbEntry->firstChildIndex != LIMB_DONE) { + gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor, gfx); } Matrix_Pull(); @@ -731,8 +651,7 @@ Gfx* SkelAnime_Draw2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawT Gfx* SkelAnime_DrawLimbSV2(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, - Actor* actor, Mtx** mtx, Gfx* gfx) -{ + Actor* actor, Mtx** mtx, Gfx* gfx) { SkelLimbEntry* limbEntry; Gfx* dList1; Gfx* dList2; @@ -751,39 +670,33 @@ Gfx* SkelAnime_DrawLimbSV2(GlobalContext* globalCtx, s32 limbIndex, u32* limbTab pos.z = limbEntry->translation.z; dList1 = dList2 = limbEntry->displayLists[0]; - if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList1, &pos, &rot, actor, &gfx) == 0)) - { + if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &dList1, &pos, &rot, actor, &gfx) == 0)) { Matrix_TranslateThenRotateZYX(&pos, &rot); - if (dList1 != NULL) - { + if (dList1 != NULL) { Matrix_ToMtx(*mtx, "../z_skelanime.c", 0x657); gSPMatrix(gfx++, *mtx, G_MTX_LOAD); gSPDisplayList(gfx++, dList1); (*mtx)++; - } - else - { - if (dList2 != NULL) - { + } else { + if (dList2 != NULL) { Matrix_ToMtx(*mtx, "../z_skelanime.c", 0x65E); (*mtx)++; } } } - if (appendDlistFunc != 0) - { + if (appendDlistFunc != 0) { appendDlistFunc(globalCtx, limbIndex, &dList2, &rot, actor, &gfx); } - if (limbEntry->firstChildIndex != LIMB_DONE) - { - gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, mtx, gfx); + if (limbEntry->firstChildIndex != LIMB_DONE) { + gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor, mtx, gfx); } Matrix_Pull(); - if (limbEntry->nextLimbIndex != LIMB_DONE) - { - gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, mtx, gfx); + if (limbEntry->nextLimbIndex != LIMB_DONE) { + gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor, mtx, gfx); } return gfx; @@ -791,8 +704,7 @@ Gfx* SkelAnime_DrawLimbSV2(GlobalContext* globalCtx, s32 limbIndex, u32* limbTab Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, s32 dListCount, SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, - Actor* actor, Gfx* gfx) -{ + Actor* actor, Gfx* gfx) { SkelLimbEntry* limbEntry; char pad[4]; Gfx* dList1; @@ -802,8 +714,7 @@ Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDra Mtx* mtx; mtx = Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(*mtx)); - if (limbTable == NULL) - { + if (limbTable == NULL) { osSyncPrintf("\x1b[31m"); osSyncPrintf("Si2_draw2_SV():skelがNULLです。NULLを返します。\n"); osSyncPrintf("\x1b[m"); @@ -822,31 +733,24 @@ Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDra dList1 = dList2 = limbEntry->displayLists[0]; - if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList1, &pos, &rot, actor, &gfx) == 0)) - { + if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList1, &pos, &rot, actor, &gfx) == 0)) { Matrix_TranslateThenRotateZYX(&pos, &rot); - if (dList1 != NULL) - { + if (dList1 != NULL) { Matrix_ToMtx(mtx, "../z_skelanime.c", 0x6AE); gSPMatrix(gfx++, mtx, G_MTX_LOAD); gSPDisplayList(gfx++, dList1); mtx++; - } - else - { - if (dList2 != NULL) - { + } else { + if (dList2 != NULL) { Matrix_ToMtx(mtx, "../z_skelanime.c", 0x6B5); mtx++; } } } - if (appendDlistFunc != NULL) - { + if (appendDlistFunc != NULL) { appendDlistFunc(globalCtx, 1, &dList2, &rot, actor, &gfx); } - if (limbEntry->firstChildIndex != LIMB_DONE) - { + if (limbEntry->firstChildIndex != LIMB_DONE) { gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, &mtx, gfx); } @@ -859,22 +763,19 @@ Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDra // Seems to be some kind of rotations update, somewhat large. #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A29BC.s") -s16 func_800A2DBC(u32 animationSeg) -{ +s16 func_800A2DBC(u32 animationSeg) { AnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); return animation->unk_02; } -s16 func_800A2DF4(u32 animationSeg) -{ +s16 func_800A2DF4(u32 animationSeg) { AnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); return animation->frameCount; } -s16 func_800A2E2C(u32 animationSeg) -{ +s16 func_800A2E2C(u32 animationSeg) { AnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); return (s16)(animation->frameCount - 1); @@ -883,31 +784,25 @@ s16 func_800A2E2C(u32 animationSeg) // Very large update function #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A2E70.s") -void func_800A32EC(u16* arg0) -{ +void func_800A32EC(u16* arg0) { *arg0 = 0; } -void func_800A32F4(s32 arg0) -{ +void func_800A32F4(s32 arg0) { D_801600B0 *= 2; } -void func_800A3310(void* arg0) -{ +void func_800A3310(void* arg0) { u32* D_8012A480Ptr = &D_8012A480; *D_8012A480Ptr |= D_801600B0; } - -AnimationEntry* SkelAnime_NextEntry(AnimationContext* animationCtx, AnimationType type) -{ - AnimationEntry *entry; +AnimationEntry* SkelAnime_NextEntry(AnimationContext* animationCtx, AnimationType type) { + AnimationEntry* entry; s16 index = animationCtx->animationCount; - if (index >= 0x32) - { + if (index >= 0x32) { return NULL; } animationCtx->animationCount = index + 1; @@ -918,32 +813,28 @@ AnimationEntry* SkelAnime_NextEntry(AnimationContext* animationCtx, AnimationTyp /* * The next 6 functions are coordinate with the AnimationType enum -*/ + */ -void func_800A336C(GlobalContext* globalCtx, u32 linkAnimetionSeg, s32 frame, s32 limbCount, void* ram) -{ +void func_800A336C(GlobalContext* globalCtx, u32 linkAnimetionSeg, s32 frame, s32 limbCount, void* ram) { AnimationEntry* entry; - LinkAnimetionEntry *linkAnimetionEntry; + LinkAnimetionEntry* linkAnimetionEntry; char pad[4]; entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE0); - if (entry != NULL) - { + if (entry != NULL) { 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" , 0x7D4); + 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", 0x7D4); } } -void func_800A3478(GlobalContext* globalCtx, s32 vecCount, - Vec3s* dst, Vec3s* src) -{ +void func_800A3478(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src) { AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE1); - if (entry != NULL) - { + if (entry != NULL) { entry->types.type1.unk_00 = D_801600B0; entry->types.type1.vecCount = vecCount; entry->types.type1.dst = dst; @@ -951,12 +842,9 @@ void func_800A3478(GlobalContext* globalCtx, s32 vecCount, } } -void func_800A34DC(GlobalContext* globalCtx, s32 arg1, - Vec3s* arg2, Vec3s* arg3, f32 arg4) -{ +void func_800A34DC(GlobalContext* globalCtx, s32 arg1, Vec3s* arg2, Vec3s* arg3, f32 arg4) { AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE2); - if (entry != NULL) - { + if (entry != NULL) { entry->types.type2.unk_00 = D_801600B0; entry->types.type2.unk_01 = arg1; entry->types.type2.unk_04 = arg2; @@ -965,12 +853,9 @@ void func_800A34DC(GlobalContext* globalCtx, s32 arg1, } } -void func_800A3548(GlobalContext* globalCtx, s32 vecCount, - s32 dst, s32 src, s32 index) -{ +void func_800A3548(GlobalContext* globalCtx, s32 vecCount, s32 dst, s32 src, s32 index) { AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE3); - if (entry != NULL) - { + if (entry != NULL) { entry->types.type3.unk_00 = D_801600B0; entry->types.type3.vecCount = vecCount; entry->types.type3.dst = dst; @@ -979,12 +864,9 @@ void func_800A3548(GlobalContext* globalCtx, s32 vecCount, } } -void func_800A35B4(GlobalContext* globalCtx, s32 vecCount, - Vec3s* dst, Vec3s* src, u8* index) -{ +void func_800A35B4(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index) { AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE4); - if (entry != NULL) - { + if (entry != NULL) { entry->types.type4.unk_00 = D_801600B0; entry->types.type4.vecCount = vecCount; entry->types.type4.dst = dst; @@ -993,12 +875,9 @@ void func_800A35B4(GlobalContext* globalCtx, s32 vecCount, } } -void func_800A3620(GlobalContext* globalCtx, Actor* actor, - SkelAnime* skelAnime, f32 arg3) -{ - AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE5); - if (entry != NULL) - { +void func_800A3620(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 arg3) { + AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE5); + if (entry != NULL) { entry->types.type5.actor = actor; entry->types.type5.skelAnime = skelAnime; entry->types.type5.unk_08 = arg3; @@ -1007,83 +886,64 @@ void func_800A3620(GlobalContext* globalCtx, Actor* actor, /* The next functions are callbacks to loading animations */ -void func_800A3678(GlobalContext* globalCtx, AnimationEntryType0* entry) -{ +void func_800A3678(GlobalContext* globalCtx, AnimationEntryType0* entry) { osRecvMesg(&entry->msgQueue, NULL, OS_MESG_BLOCK); } -void func_800A36A4(GlobalContext* globalCtx, AnimationEntryType1* entry) -{ +void func_800A36A4(GlobalContext* globalCtx, AnimationEntryType1* entry) { s32 i; Vec3s* dst; Vec3s* src; AnimationEntryRaw* genericEntry = (AnimationEntryRaw*)entry; - if ((genericEntry->raw[0] & D_8012A480) != 0) - { + if ((genericEntry->raw[0] & D_8012A480) != 0) { return; } - for(dst = entry->dst, src = entry->src, i = 0; - i < genericEntry->raw[1]; - i++) - { + for (dst = entry->dst, src = entry->src, i = 0; i < genericEntry->raw[1]; i++) { *dst++ = *src++; } } -void func_800A3714(GlobalContext* globalCtx, AnimationEntryType2* entry) -{ - if ((entry->unk_00 & D_8012A480) == 0) - { +void func_800A3714(GlobalContext* globalCtx, AnimationEntryType2* entry) { + if ((entry->unk_00 & D_8012A480) == 0) { func_800A2E70(entry->unk_01, entry->unk_04, entry->unk_04, entry->unk_08, entry->unk_0C); } } -void func_800A3770(GlobalContext* globalCtx, AnimationEntryType3* entry) -{ +void func_800A3770(GlobalContext* globalCtx, AnimationEntryType3* entry) { s32 i; Vec3s* dst; Vec3s* src; u8* index; AnimationEntryRaw* rawEntry = (AnimationEntryRaw*)entry; - 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++) - { + 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++) { *dst = *src; } } } } -void func_800A37F0(GlobalContext* globalCtx, AnimationEntryType4* entry) -{ +void func_800A37F0(GlobalContext* globalCtx, AnimationEntryType4* entry) { s32 i; Vec3s* dst; Vec3s* src; u8* index; AnimationEntryRaw* rawEntry = (AnimationEntryRaw*)entry; - 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) - { + 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) { *dst = *src; } } } } -void func_800A3874(GlobalContext* globalCtx, AnimationEntryType5* entry) -{ +void func_800A3874(GlobalContext* globalCtx, AnimationEntryType5* entry) { char pad[4]; Actor* actor = entry->actor; Vec3f pos; @@ -1094,12 +954,10 @@ void func_800A3874(GlobalContext* globalCtx, AnimationEntryType5* entry) actor->posRot.pos.z += pos.z * actor->scale.z; } -void func_800A390C(GlobalContext* globalCtx, AnimationContext* animationCtx) -{ +void func_800A390C(GlobalContext* globalCtx, AnimationContext* animationCtx) { AnimationEntry* entry; - for(entry = animationCtx->entries; animationCtx->animationCount != 0; entry++, animationCtx->animationCount--) - { + for (entry = animationCtx->entries; animationCtx->animationCount != 0; entry++, animationCtx->animationCount--) { D_8012A484[entry->type](globalCtx, &entry->types); } @@ -1107,11 +965,10 @@ void func_800A390C(GlobalContext* globalCtx, AnimationContext* animationCtx) D_8012A480 = 0; } -void func_800A39AC(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 limbHeaderSeg, u32* animation, - s32 flags, Vec3s* actorDrawTbl, Vec3s* arg6, s32 limbBufCount) -{ +void func_800A39AC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, u32* animation, s32 flags, + Vec3s* actorDrawTbl, Vec3s* arg6, s32 limbBufCount) { char pad[8]; - SkelAnimeLimbHeader *limbHeader; + SkelAnimeLimbHeader* limbHeader; size_t allocSize; s32 limbCount; s32 headerCount; @@ -1121,12 +978,10 @@ void func_800A39AC(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 limbHeade skelAnime->unk_34 = flags; limbCount = (flags & 2) != 0 ? headerCount : 1; - if ((flags & 1) != 0) - { + if ((flags & 1) != 0) { limbCount += headerCount; } - if ((flags & 4) != 0) - { + if ((flags & 4) != 0) { limbCount += headerCount; } @@ -1136,20 +991,15 @@ void func_800A39AC(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 limbHeade allocSize = limbCount * sizeof(Vec3s); skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg); - if ((flags & 8) != 0) - { + if ((flags & 8) != 0) { allocSize += 2; } - if (actorDrawTbl == NULL) - { + if (actorDrawTbl == NULL) { skelAnime->actorDrawTbl = ZeldaArena_MallocDebug(allocSize, "../z_skelanime.c", 2364); skelAnime->unk_24 = ZeldaArena_MallocDebug(allocSize, "../z_skelanime.c", 2365); - } - else - { - if (limbBufCount != limbCount) - { + } else { + if (limbBufCount != limbCount) { __assert("joint_buff_num == joint_num", "../z_skelanime.c", 2369); } @@ -1157,61 +1007,53 @@ void func_800A39AC(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 limbHeade skelAnime->unk_24 = (Vec3s*)ALIGN16((u32)arg6); } - if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) - { + if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) { osSyncPrintf("\x1b[31m"); - osSyncPrintf("Skeleton_Info_Rom_SV_ct メモリアロケーションエラー\n"); //Skeleton_Info_Rom_SV_ct Memory allocation error + osSyncPrintf( + "Skeleton_Info_Rom_SV_ct メモリアロケーションエラー\n"); // Skeleton_Info_Rom_SV_ct Memory allocation error osSyncPrintf("\x1b[m"); } func_800A3F08(globalCtx, skelAnime, animation, 1.0f, 0.0f, 0.0f, 0, 0.0f); } -void func_800A3B8C(SkelAnime* skelAnime) -{ - if (skelAnime->unk_01 < 2) - { +void func_800A3B8C(SkelAnime* skelAnime) { + if (skelAnime->unk_01 < 2) { skelAnime->animUpdate = &func_800A3D70; - } - else - { + } else { skelAnime->animUpdate = &func_800A3E0C; } skelAnime->unk_28 = 0.0f; } -void func_800A3BC0(GlobalContext* globalCtx, SkelAnime* skelAnime) -{ +void func_800A3BC0(GlobalContext* globalCtx, SkelAnime* skelAnime) { skelAnime->animUpdate(globalCtx, skelAnime); } -s32 func_800A3BE4(GlobalContext* globalCtx, SkelAnime* skelAnime) -{ +s32 func_800A3BE4(GlobalContext* globalCtx, SkelAnime* skelAnime) { f32 prevUnk28 = skelAnime->unk_28; f32 updateRate = R_UPDATE_RATE * 0.5f; skelAnime->unk_28 -= skelAnime->unk_2C * updateRate; - if (skelAnime->unk_28 <= 0.0f) - { + if (skelAnime->unk_28 <= 0.0f) { func_800A3B8C(skelAnime); } - func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, 1.0f - (skelAnime->unk_28 / prevUnk28)); + func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, + 1.0f - (skelAnime->unk_28 / prevUnk28)); return 0; } -void func_800A3C9C(GlobalContext* globalCtx, SkelAnime* skelAnime) -{ +void func_800A3C9C(GlobalContext* globalCtx, SkelAnime* skelAnime) { f32 updateRate; - func_800A336C(globalCtx, skelAnime->animCurrent, skelAnime->animCurrentFrame, skelAnime->limbCount, skelAnime->actorDrawTbl); - if (skelAnime->unk_28 != 0) - { + func_800A336C(globalCtx, skelAnime->animCurrent, skelAnime->animCurrentFrame, skelAnime->limbCount, + skelAnime->actorDrawTbl); + if (skelAnime->unk_28 != 0) { updateRate = R_UPDATE_RATE * 0.5f; skelAnime->unk_28 -= skelAnime->unk_2C * updateRate; - if (skelAnime->unk_28 <= 0.0f) - { + if (skelAnime->unk_28 <= 0.0f) { skelAnime->unk_28 = 0.0f; return; } @@ -1219,18 +1061,14 @@ void func_800A3C9C(GlobalContext* globalCtx, SkelAnime* skelAnime) } } -s32 func_800A3D70(GlobalContext* globalCtx, SkelAnime* skelAnime) -{ +s32 func_800A3D70(GlobalContext* globalCtx, SkelAnime* skelAnime) { f32 updateRate = R_UPDATE_RATE * 0.5f; skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate; - if (skelAnime->animCurrentFrame < 0.0f) - { + if (skelAnime->animCurrentFrame < 0.0f) { skelAnime->animCurrentFrame += skelAnime->unk_14; - } - else - { - if (skelAnime->unk_14 <= skelAnime->animCurrentFrame){ + } else { + if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) { skelAnime->animCurrentFrame -= skelAnime->unk_14; } } @@ -1238,30 +1076,21 @@ s32 func_800A3D70(GlobalContext* globalCtx, SkelAnime* skelAnime) return 0; } -s32 func_800A3E0C(GlobalContext* globalCtx, SkelAnime* skelAnime) -{ +s32 func_800A3E0C(GlobalContext* globalCtx, SkelAnime* skelAnime) { f32 updateRate = R_UPDATE_RATE * 0.5f; - if (skelAnime->animCurrentFrame == skelAnime->animFrameCount) - { + if (skelAnime->animCurrentFrame == skelAnime->animFrameCount) { func_800A3C9C(globalCtx, skelAnime); return 1; } skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate; - if (0.0f < ((skelAnime->animCurrentFrame - skelAnime->animFrameCount) * skelAnime->animPlaybackSpeed)) - { + if (0.0f < ((skelAnime->animCurrentFrame - skelAnime->animFrameCount) * skelAnime->animPlaybackSpeed)) { skelAnime->animCurrentFrame = skelAnime->animFrameCount; - } - else - { - if (skelAnime->animCurrentFrame < 0.0f) - { + } else { + if (skelAnime->animCurrentFrame < 0.0f) { skelAnime->animCurrentFrame += skelAnime->unk_14; - } - else - { - if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) - { + } else { + if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) { skelAnime->animCurrentFrame -= skelAnime->unk_14; } } @@ -1270,40 +1099,30 @@ s32 func_800A3E0C(GlobalContext* globalCtx, SkelAnime* skelAnime) return 0; } - -void func_800A3EE8(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 arg2) -{ +void func_800A3EE8(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 arg2) { skelAnime->unk_28 = 1.0f; skelAnime->unk_2C = 1.0f / arg2; } #ifdef NON_MATCHING -void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32* animation, f32 playbackSpeed, - f32 arg4, f32 frameCount, u8 arg6, f32 arg7) -{ +void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32* animation, f32 playbackSpeed, f32 arg4, + f32 frameCount, u8 arg6, f32 arg7) { skelAnime->unk_01 = arg6; - if ((arg7 != 0.0f) && - ((animation == skelAnime->animCurrent) || (arg4 != skelAnime->animCurrentFrame))) - { - if(arg7 < 0.0f) - { + if ((arg7 != 0.0f) && ((animation == skelAnime->animCurrent) || (arg4 != skelAnime->animCurrentFrame))) { + if (arg7 < 0.0f) { func_800A3B8C(skelAnime); SkelAnime_CopyVec3s(skelAnime, skelAnime->unk_24, skelAnime->actorDrawTbl); arg7 = -arg7; - } - else - { + } else { skelAnime->animUpdate = &func_800A3BE4; - func_800A336C(globalCtx, animation, (s32) arg4, skelAnime->limbCount, skelAnime->unk_24); + func_800A336C(globalCtx, animation, (s32)arg4, skelAnime->limbCount, skelAnime->unk_24); } skelAnime->unk_28 = 1.0f; skelAnime->unk_2C = 1.0f / arg7; - } - else - { + } else { func_800A3B8C(skelAnime); - func_800A336C(globalCtx, animation, (s32) arg4, skelAnime->limbCount, skelAnime->actorDrawTbl); + func_800A336C(globalCtx, animation, (s32)arg4, skelAnime->limbCount, skelAnime->actorDrawTbl); skelAnime->unk_28 = 0.0f; } @@ -1318,54 +1137,46 @@ void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32* animatio #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3F08.s") #endif -void func_800A407C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation) -{ - func_800A3F08(globalCtx, skelAnime, animation, 1.0f, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 2, 0.0f); +void func_800A407C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation) { + func_800A3F08(globalCtx, skelAnime, animation, 1.0f, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 2, 0.0f); } -void func_800A40DC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) -{ - func_800A3F08(globalCtx, skelAnime, animation, playbackSpeed, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 2, 0.0f); +void func_800A40DC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) { + func_800A3F08(globalCtx, skelAnime, animation, playbackSpeed, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 2, + 0.0f); } -void func_800A4140(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation) -{ - func_800A3F08(globalCtx, skelAnime, animation, 1.0f, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 0, 0.0f); +void func_800A4140(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation) { + func_800A3F08(globalCtx, skelAnime, animation, 1.0f, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 0, 0.0f); } -void func_800A419C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) -{ - func_800A3F08(globalCtx, skelAnime, animation, playbackSpeed, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 0, 0.0f); +void func_800A419C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) { + func_800A3F08(globalCtx, skelAnime, animation, playbackSpeed, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 0, + 0.0f); } -void func_800A41FC(GlobalContext* globalCtx, SkelAnime* skelAnime) -{ +void func_800A41FC(GlobalContext* globalCtx, SkelAnime* skelAnime) { func_800A3478(globalCtx, skelAnime->limbCount, skelAnime->unk_24, skelAnime->actorDrawTbl); } -void func_800A422C(GlobalContext* globalCtx, SkelAnime* skelAnime) -{ +void func_800A422C(GlobalContext* globalCtx, SkelAnime* skelAnime) { func_800A3478(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24); } -void func_800A425C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 frame) -{ +void func_800A425C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 frame) { func_800A336C(globalCtx, animation, (s32)frame, skelAnime->limbCount, skelAnime->unk_24); } -void func_800A42A0(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 frame) -{ +void func_800A42A0(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 frame) { func_800A336C(globalCtx, animation, (s32)frame, skelAnime->limbCount, skelAnime->actorDrawTbl); } -void func_800A42E4(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 arg2) -{ +void func_800A42E4(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 arg2) { func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, arg2); } -void func_800A431C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animationSeg, - f32 frame, s32 arg4, f32 arg5, f32 arg6, s32 arg7) -{ +void func_800A431C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animationSeg, f32 frame, s32 arg4, f32 arg5, + f32 arg6, s32 arg7) { s32 alignedAddr; func_800A336C(globalCtx, animationSeg, (s32)frame, skelAnime->limbCount, skelAnime->actorDrawTbl); @@ -1375,9 +1186,8 @@ void func_800A431C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, alignedAddr, arg6); } -void func_800A43B8(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 animation, - f32 frame, s32 arg4, f32 arg5, f32 arg6, s32 arg7) -{ +void func_800A43B8(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 frame, s32 arg4, f32 arg5, + f32 arg6, s32 arg7) { s32 alignedAddr; func_800A336C(globalCtx, animation, (s32)frame, skelAnime->limbCount, skelAnime->unk_24); @@ -1388,177 +1198,149 @@ void func_800A43B8(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 animation func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->unk_24, alignedAddr, arg6); } -void func_800A4454(SkelAnime* skelAnime) -{ +void func_800A4454(SkelAnime* skelAnime) { skelAnime->unk_01 = 2; func_800A3B8C(skelAnime); } -s32 func_800A4478(SkelAnime* skelAnime, f32 arg1, f32 updateRate) -{ +s32 func_800A4478(SkelAnime* skelAnime, f32 arg1, f32 updateRate) { f32 updateSpeed; f32 temp_f12; f32 nextFrame; updateSpeed = skelAnime->animPlaybackSpeed * updateRate; nextFrame = skelAnime->animCurrentFrame - updateSpeed; - if (nextFrame < 0.0f) - { + if (nextFrame < 0.0f) { nextFrame += skelAnime->unk_14; - } - else - { - if (skelAnime->unk_14 <= nextFrame) - { + } else { + if (skelAnime->unk_14 <= nextFrame) { nextFrame -= skelAnime->unk_14; } } - if (arg1 == 0.0f) - { - if (0.0f < updateSpeed) - { + if (arg1 == 0.0f) { + if (0.0f < updateSpeed) { arg1 = skelAnime->unk_14; } } temp_f12 = (nextFrame + updateSpeed) - arg1; - if (0.0f <= (temp_f12 * updateSpeed)) - { - if (((temp_f12 - updateSpeed) * updateSpeed) < 0.0f) - { + if (0.0f <= (temp_f12 * updateSpeed)) { + if (((temp_f12 - updateSpeed) * updateSpeed) < 0.0f) { return 1; } } return 0; } -s32 func_800A4530(SkelAnime* skelAnime, f32 arg1) -{ +s32 func_800A4530(SkelAnime* skelAnime, f32 arg1) { f32 updateRate = R_UPDATE_RATE * 0.5f; return func_800A4478(skelAnime, arg1, updateRate); } -void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, - u32 animation, Vec3s* actorDrawTable, s32 arg5, s32 limbCount) -{ +void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, u32 animation, + Vec3s* actorDrawTable, s32 arg5, s32 limbCount) { SkelAnimeLimbHeader* limbHeader; limbHeader = SEGMENTED_TO_VIRTUAL(limbHeaderSeg); skelAnime->limbCount = limbHeader->limbCount + 1; skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg); - if (actorDrawTable == NULL) - { - skelAnime->actorDrawTbl = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), "../z_skelanime.c", 2968); - skelAnime->unk_24 = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->unk_24), "../z_skelanime.c", 2969); - } - else - { - if (limbCount != skelAnime->limbCount) - { + if (actorDrawTable == NULL) { + skelAnime->actorDrawTbl = + ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), "../z_skelanime.c", 2968); + skelAnime->unk_24 = + ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->unk_24), "../z_skelanime.c", 2969); + } else { + if (limbCount != skelAnime->limbCount) { __assert("joint_buff_num == this->joint_num", "../z_skelanime.c", 2973); } skelAnime->actorDrawTbl = actorDrawTable; skelAnime->unk_24 = arg5; } - if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) - { + if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) { osSyncPrintf("\x1b[31m"); osSyncPrintf("Skeleton_Info2_ct メモリアロケーションエラー\n"); // Skeleton_Info2_ct memory allocation error osSyncPrintf("\x1b[m"); } - if (animation != 0) - { + if (animation != 0) { SkelAnime_ChangeAnimationDefault(skelAnime, animation); } } -void SkelAnime_InitSV(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, - u32 animation, Vec3s* actorDrawTable, s32 arg5, s32 limbCount) -{ - SkelAnimeLimbHeader *limbHeader; +void SkelAnime_InitSV(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, u32 animation, + Vec3s* actorDrawTable, s32 arg5, s32 limbCount) { + SkelAnimeLimbHeader* limbHeader; limbHeader = SEGMENTED_TO_VIRTUAL(limbHeaderSeg); skelAnime->limbCount = limbHeader->limbCount + 1; skelAnime->dListCount = limbHeader->dListCount; skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg); - if (actorDrawTable == NULL) - { - skelAnime->actorDrawTbl = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), - "../z_skelanime.c", 3047); + if (actorDrawTable == NULL) { + skelAnime->actorDrawTbl = + ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), "../z_skelanime.c", 3047); - skelAnime->unk_24 = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->unk_24), - "../z_skelanime.c", 3048); - } - else - { - if (limbCount != skelAnime->limbCount) - { + skelAnime->unk_24 = + ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->unk_24), "../z_skelanime.c", 3048); + } else { + if (limbCount != skelAnime->limbCount) { __assert("joint_buff_num == this->joint_num", "../z_skelanime.c", 0xBEC); } skelAnime->actorDrawTbl = actorDrawTable; skelAnime->unk_24 = arg5; } - if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) - { + if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) { osSyncPrintf("\x1b[31m"); - osSyncPrintf("Skeleton_Info_Rom_SV_ct メモリアロケーションエラー\n"); // Skeleton_Info_Rom_SV_ct Memory allocation error + osSyncPrintf( + "Skeleton_Info_Rom_SV_ct メモリアロケーションエラー\n"); // Skeleton_Info_Rom_SV_ct Memory allocation error osSyncPrintf("\x1b[m"); } - if (animation != 0) - { + if (animation != 0) { SkelAnime_ChangeAnimationDefault(skelAnime, animation); } } -void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime *skelAnime, - u32 limbHeaderSeg, u32 animation) -{ - SkelAnimeLimbHeader *limbHeader; +void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, u32 animation) { + SkelAnimeLimbHeader* limbHeader; limbHeader = SEGMENTED_TO_VIRTUAL(limbHeaderSeg); skelAnime->limbCount = limbHeader->limbCount + 1; skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg); - skelAnime->actorDrawTbl = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), "../z_skelanime.c", 3120); - skelAnime->unk_24 = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->unk_24), "../z_skelanime.c", 3121); - if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) - { + skelAnime->actorDrawTbl = + ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), "../z_skelanime.c", 3120); + skelAnime->unk_24 = + ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->unk_24), "../z_skelanime.c", 3121); + if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) { osSyncPrintf("\x1b[31m"); - osSyncPrintf("Skeleton_Info2_skin2_ct メモリアロケーションエラー\n"); //Skeleton_Info2_skin2_ct Memory allocation error + osSyncPrintf( + "Skeleton_Info2_skin2_ct メモリアロケーションエラー\n"); // Skeleton_Info2_skin2_ct Memory allocation error osSyncPrintf("\x1b[m"); } - if (animation != 0) - { + if (animation != 0) { SkelAnime_ChangeAnimationDefault(skelAnime, animation); } } -void func_800A49B0(SkelAnime* skelAnime) -{ - if (skelAnime->unk_01 < 2) - { +void func_800A49B0(SkelAnime* skelAnime) { + if (skelAnime->unk_01 < 2) { skelAnime->animUpdate = &func_800A4D9C; return; } - if (skelAnime->unk_01 < 4) - { + if (skelAnime->unk_01 < 4) { skelAnime->animUpdate = &func_800A4EE0; return; } skelAnime->animUpdate = &func_800A4E38; } - -s32 SkelAnime_FrameUpdateMatrix(SkelAnime* skelAnime){ +s32 SkelAnime_FrameUpdateMatrix(SkelAnime* skelAnime) { return skelAnime->animUpdate(skelAnime); } #ifdef NON_MATCHING -s32 func_800A4A20(SkelAnime* skelAnime) -{ +s32 func_800A4A20(SkelAnime* skelAnime) { f32 sp2C; f32 temp_f12; f32 phi_f0; @@ -1566,14 +1348,14 @@ s32 func_800A4A20(SkelAnime* skelAnime) temp_f12 = skelAnime->unk_28; skelAnime->unk_28 -= skelAnime->unk_2C * (R_UPDATE_RATE * 0.33333334f); phi_f0 = skelAnime->unk_28; - if (skelAnime->unk_28 <= 0.0f) - { + if (skelAnime->unk_28 <= 0.0f) { sp2C = temp_f12; func_800A49B0(skelAnime); skelAnime->unk_28 = 0.0f; phi_f0 = skelAnime->unk_28; } - func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, skelAnime->unk_24, 1.0f - (phi_f0 / temp_f12)); + func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, skelAnime->unk_24, + 1.0f - (phi_f0 / temp_f12)); return 0; } #else @@ -1581,8 +1363,7 @@ s32 func_800A4A20(SkelAnime* skelAnime) #endif #ifdef NON_MATCHING -s32 func_800A4AD8(SkelAnime* skelAnime) -{ +s32 func_800A4AD8(SkelAnime* skelAnime) { f32 sp28; s16 temp_a1; s16 temp_a2; @@ -1590,31 +1371,25 @@ s32 func_800A4AD8(SkelAnime* skelAnime) temp_a2 = (s16)(skelAnime->unk_28 * 16384.0f); skelAnime->unk_28 -= skelAnime->unk_2C * (R_UPDATE_RATE * 0.33333334f); - if (skelAnime->unk_28 <= 0.0f) - { + if (skelAnime->unk_28 <= 0.0f) { func_800A49B0(skelAnime); skelAnime->unk_28 = 0.0f; } temp_a1 = (s16)(skelAnime->unk_28 * 16384.0f); - if (skelAnime->unk_03 < 0) - { + if (skelAnime->unk_03 < 0) { sp28 = 1.0f - Math_Coss(temp_a2); phi_f2 = 1.0f - Math_Coss(temp_a1); - } - else - { + } else { sp28 = Math_Sins(temp_a2); phi_f2 = Math_Sins(temp_a1); } - if (phi_f2 != 0.0f) - { + if (phi_f2 != 0.0f) { phi_f2 /= sp28; - } - else - { + } else { phi_f2 = 0.0f; } - func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, skelAnime->unk_24, 1.0f - phi_f2); + func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, skelAnime->unk_24, + 1.0f - phi_f2); return 0; } #else @@ -1622,8 +1397,7 @@ s32 func_800A4AD8(SkelAnime* skelAnime) #endif #ifdef NON_MATCHING -void func_800A4C58(SkelAnime* skelAnime) -{ +void func_800A4C58(SkelAnime* skelAnime) { char pad[6]; f32 temp_f0; f32 temp_f10; @@ -1631,30 +1405,28 @@ void func_800A4C58(SkelAnime* skelAnime) s32 temp_f8; f32 temp_f2; - SkelAnime_AnimateFrame(skelAnime->animCurrent, (s32) skelAnime->animCurrentFrame, skelAnime->limbCount, skelAnime->actorDrawTbl); - if ((skelAnime->unk_01 & 1) != 0) - { - temp_f8 = (s32) skelAnime->animCurrentFrame; + SkelAnime_AnimateFrame(skelAnime->animCurrent, (s32)skelAnime->animCurrentFrame, skelAnime->limbCount, + skelAnime->actorDrawTbl); + if ((skelAnime->unk_01 & 1) != 0) { + temp_f8 = (s32)skelAnime->animCurrentFrame; temp_f10 = temp_f8; temp_f8++; temp_f2 = skelAnime->animCurrentFrame - temp_f10; - if (temp_f8 >= (s32) skelAnime->unk_14) - { + if (temp_f8 >= (s32)skelAnime->unk_14) { temp_f8 = 0; } SkelAnime_AnimateFrame(skelAnime->animCurrent, temp_f8, skelAnime->limbCount, sp38); func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, sp38, temp_f2); } - if (skelAnime->unk_28 != 0) - { + if (skelAnime->unk_28 != 0) { skelAnime->unk_28 -= skelAnime->unk_2C * (R_UPDATE_RATE * 0.33333334f); temp_f0 = skelAnime->unk_28; - if (temp_f0 <= 0.0f) - { + if (temp_f0 <= 0.0f) { skelAnime->unk_28 = 0.0f; return; } - func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, skelAnime->unk_24, skelAnime->unk_28); + func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, skelAnime->unk_24, + skelAnime->unk_28); } } #else @@ -1663,15 +1435,11 @@ void func_800A4C58(SkelAnime* skelAnime) #undef NON_MATCHING #ifdef NON_MATCHING -s32 func_800A4D9C(SkelAnime* skelAnime) -{ +s32 func_800A4D9C(SkelAnime* skelAnime) { skelAnime->animCurrentFrame += (R_UPDATE_RATE * 0.33333334f) + skelAnime->animPlaybackSpeed; - if (skelAnime->animCurrentFrame < 0.0f) - { + if (skelAnime->animCurrentFrame < 0.0f) { skelAnime->animCurrentFrame += skelAnime->unk_14; - } - else if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) - { + } else if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) { skelAnime->animCurrentFrame -= skelAnime->unk_14; } func_800A4C58(skelAnime); @@ -1683,17 +1451,12 @@ s32 func_800A4D9C(SkelAnime* skelAnime) #undef NON_MATCHING #ifdef NON_MATCHING -s32 func_800A4E38(SkelAnime* skelAnime) -{ +s32 func_800A4E38(SkelAnime* skelAnime) { skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * (R_UPDATE_RATE * 0.33333334f); - if (skelAnime->animCurrentFrame < skelAnime->unk_0C) - { + if (skelAnime->animCurrentFrame < skelAnime->unk_0C) { skelAnime->animCurrentFrame = (skelAnime->animCurrentFrame - skelAnime->unk_0C) + skelAnime->animFrameCount; - } - else - { - if (skelAnime->animFrameCount <= skelAnime->animCurrentFrame) - { + } else { + if (skelAnime->animFrameCount <= skelAnime->animCurrentFrame) { skelAnime->animCurrentFrame = (skelAnime->animCurrentFrame - skelAnime->animFrameCount) + skelAnime->unk_0C; } } @@ -1705,33 +1468,25 @@ s32 func_800A4E38(SkelAnime* skelAnime) #endif #undef NON_MATCHING -s32 func_800A4EE0(SkelAnime *skelAnime) -{ +s32 func_800A4EE0(SkelAnime* skelAnime) { f32 temp_f14; - temp_f14 = (f32) R_UPDATE_RATE * 0.33333334f; - if (skelAnime->animCurrentFrame == skelAnime->animFrameCount) - { + temp_f14 = (f32)R_UPDATE_RATE * 0.33333334f; + if (skelAnime->animCurrentFrame == skelAnime->animFrameCount) { - SkelAnime_AnimateFrame(skelAnime->animCurrent, (s32)skelAnime->animCurrentFrame, skelAnime->limbCount, skelAnime->actorDrawTbl); + SkelAnime_AnimateFrame(skelAnime->animCurrent, (s32)skelAnime->animCurrentFrame, skelAnime->limbCount, + skelAnime->actorDrawTbl); func_800A4C58(skelAnime); return 1; } skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * temp_f14; - if (0.0f < ((skelAnime->animCurrentFrame - skelAnime->animFrameCount) * skelAnime->animPlaybackSpeed)) - { + if (0.0f < ((skelAnime->animCurrentFrame - skelAnime->animFrameCount) * skelAnime->animPlaybackSpeed)) { skelAnime->animCurrentFrame = skelAnime->animFrameCount; - } - else - { - if (skelAnime->animCurrentFrame < 0.0f) - { + } else { + if (skelAnime->animCurrentFrame < 0.0f) { skelAnime->animCurrentFrame += skelAnime->unk_14; - } - else - { - if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) - { + } else { + if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) { skelAnime->animCurrentFrame -= skelAnime->unk_14; } } @@ -1741,37 +1496,26 @@ s32 func_800A4EE0(SkelAnime *skelAnime) } #ifdef NON_MATCHING -void SkelAnime_ChangeAnimationImpl(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, - f32 unk0, f32 frameCount, u8 unk1, f32 transitionRate, s8 unk2) -{ +void SkelAnime_ChangeAnimationImpl(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 unk0, f32 frameCount, + u8 unk1, f32 transitionRate, s8 unk2) { skelAnime->unk_01 = unk1; - if ((transitionRate != 0.0f) && - ((animation != skelAnime->animCurrent) || (unk0 != skelAnime->animCurrentFrame))) - { - if (transitionRate < 0.0f) - { + if ((transitionRate != 0.0f) && ((animation != skelAnime->animCurrent) || (unk0 != skelAnime->animCurrentFrame))) { + if (transitionRate < 0.0f) { func_800A49B0(skelAnime); SkelAnime_CopyVec3s(skelAnime, skelAnime->unk_24, skelAnime->actorDrawTbl); transitionRate = -transitionRate; - } - else - { - if (unk2 != 0) - { + } else { + if (unk2 != 0) { skelAnime->mtxUpdate = (void*)&func_800A4AD8; skelAnime->unk_03 = unk2; - } - else - { + } else { skelAnime->mtxUpdate = (void*)&func_800A4A20; } SkelAnime_AnimateFrame(animation, (s32)unk0, skelAnime->limbCount, skelAnime->actorDrawTbl); } skelAnime->unk_28 = 1.0f; skelAnime->unk_2C = 1.0f / transitionRate; - } - else - { + } else { func_800A49B0(skelAnime); SkelAnime_AnimateFrame(animation, (s32)unk0, skelAnime->limbCount, skelAnime->actorDrawTbl); skelAnime->unk_28 = 0.0f; @@ -1780,16 +1524,12 @@ void SkelAnime_ChangeAnimationImpl(SkelAnime* skelAnime, u32 animation, f32 play skelAnime->animCurrent = animation; skelAnime->unk_0C = unk0; skelAnime->animFrameCount = frameCount; - skelAnime->unk_14 = (f32) func_800A1FC8(animation); - if (skelAnime->unk_01 >= 4) - { + skelAnime->unk_14 = (f32)func_800A1FC8(animation); + if (skelAnime->unk_01 >= 4) { skelAnime->animCurrentFrame = 0.0f; - } - else - { + } else { skelAnime->animCurrentFrame = unk0; - if (skelAnime->unk_01 < 2) - { + if (skelAnime->unk_01 < 2) { skelAnime->animFrameCount = skelAnime->unk_14 - 1.0f; } } @@ -1800,46 +1540,39 @@ void SkelAnime_ChangeAnimationImpl(SkelAnime* skelAnime, u32 animation, f32 play #endif #undef NON_MATCHING -void SkelAnime_ChangeAnimation(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, - f32 unk0, f32 frameCount, u8 unk1, f32 transitionRate) -{ +void SkelAnime_ChangeAnimation(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 unk0, f32 frameCount, + u8 unk1, f32 transitionRate) { SkelAnime_ChangeAnimationImpl(skelAnime, animation, playbackSpeed, unk0, frameCount, unk1, transitionRate, 0); } -void func_800A51E8(SkelAnime* skelAnime, u32 animation) -{ +void func_800A51E8(SkelAnime* skelAnime, u32 animation) { SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 2, 0.0f); } -void func_800A5240(SkelAnime* skelAnime, u32 animation, f32 transitionRate) -{ - SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0, - (f32)SkelAnime_GetFrameCount(animation), 2, transitionRate); +void func_800A5240(SkelAnime* skelAnime, u32 animation, f32 transitionRate) { + SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0, (f32)SkelAnime_GetFrameCount(animation), 2, + transitionRate); } -void func_800A529C(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) -{ - SkelAnime_ChangeAnimation(skelAnime, animation, playbackSpeed, 0.0f, - (f32)SkelAnime_GetFrameCount(animation), 2, 0.0f); +void func_800A529C(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) { + SkelAnime_ChangeAnimation(skelAnime, animation, playbackSpeed, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 2, + 0.0f); } -void SkelAnime_ChangeAnimationDefault(SkelAnime* skelAnime, u32 animation) -{ - SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 0, 0.0f); +void SkelAnime_ChangeAnimationDefault(SkelAnime* skelAnime, u32 animation) { + SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 0, 0.0f); } -void SkelAnime_ChangeAnimationTransitionRate(SkelAnime* skelAnime, u32 animation, f32 transitionRate) -{ +void SkelAnime_ChangeAnimationTransitionRate(SkelAnime* skelAnime, u32 animation, f32 transitionRate) { SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, 0.0f, 0, transitionRate); } -void SkelAnime_ChangeAnimationPlaybackSpeed(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) -{ - SkelAnime_ChangeAnimation(skelAnime, animation, playbackSpeed, 0.0f, (f32) SkelAnime_GetFrameCount(animation), 0, 0.0f); +void SkelAnime_ChangeAnimationPlaybackSpeed(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) { + SkelAnime_ChangeAnimation(skelAnime, animation, playbackSpeed, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 0, + 0.0f); } -void func_800A53DC(SkelAnime* skelAnime) -{ +void func_800A53DC(SkelAnime* skelAnime) { skelAnime->unk_01 = 2; skelAnime->animFrameCount = skelAnime->unk_14; func_800A49B0(skelAnime); @@ -1847,8 +1580,7 @@ void func_800A53DC(SkelAnime* skelAnime) #ifdef NON_MATCHING // regalloc -void func_800A5408(SkelAnime* skelAnime) -{ +void func_800A5408(SkelAnime* skelAnime) { f32 animPlaybackSpeed = skelAnime->animPlaybackSpeed; f32 unk_C = skelAnime->unk_0C; f32 frameCount = skelAnime->animFrameCount; @@ -1861,43 +1593,34 @@ void func_800A5408(SkelAnime* skelAnime) #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A5408.s") #endif -void func_800A5428(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* index) -{ +void func_800A5428(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* index) { s32 i; - for(i = 0; i < skelAnime->limbCount; i++, dst++, src++) - { - if(*index++) - { + for (i = 0; i < skelAnime->limbCount; i++, dst++, src++) { + if (*index++) { *dst = *src; } } } -void func_800A5490(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* arg3) -{ +void func_800A5490(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src, u8* arg3) { s32 i; - for(i = 0;i < skelAnime->limbCount; i++, dst++, src++) - { - if(*arg3++ < 1U){ + for (i = 0; i < skelAnime->limbCount; i++, dst++, src++) { + if (*arg3++ < 1U) { *dst = *src; } } } -void func_800A54FC(SkelAnime* skelAnime, Vec3f* pos, s16 angle) -{ +void func_800A54FC(SkelAnime* skelAnime, Vec3f* pos, s16 angle) { f32 x; f32 z; f32 sin; f32 cos; - if((skelAnime->unk_35 & 0x10) != 0) - { + if ((skelAnime->unk_35 & 0x10) != 0) { pos->z = 0.0f; pos->x = 0.0f; - } - else - { + } else { x = (f32)skelAnime->actorDrawTbl->x; z = (f32)skelAnime->actorDrawTbl->z; sin = Math_Sins(angle); @@ -1917,55 +1640,41 @@ void func_800A54FC(SkelAnime* skelAnime, Vec3f* pos, s16 angle) skelAnime->actorDrawTbl->x = skelAnime->unk_3E; skelAnime->unk_3C = skelAnime->actorDrawTbl->z; skelAnime->actorDrawTbl->z = skelAnime->unk_42; - if((skelAnime->unk_35 & 2) != 0) - { - if((skelAnime->unk_35 & 0x10) != 0) - { + if ((skelAnime->unk_35 & 2) != 0) { + if ((skelAnime->unk_35 & 0x10) != 0) { pos->y = 0.0f; - } - else - { + } else { pos->y = (f32)(skelAnime->actorDrawTbl->y - skelAnime->unk_3A); } skelAnime->unk_3A = skelAnime->actorDrawTbl->y; skelAnime->actorDrawTbl->y = skelAnime->unk_40; - } - else - { + } else { pos->y = 0.0f; skelAnime->unk_3A = skelAnime->actorDrawTbl->y; } skelAnime->unk_35 &= ~0x10; } -s32 func_800A56C8(SkelAnime *skelAnime, f32 arg1) -{ +s32 func_800A56C8(SkelAnime* skelAnime, f32 arg1) { return func_800A4478(skelAnime, arg1, 1.0f); } -void SkelAnime_Free(SkelAnime *skelAnime, GlobalContext* globalCtx) -{ - if (skelAnime->actorDrawTbl != NULL) - { +void SkelAnime_Free(SkelAnime* skelAnime, GlobalContext* globalCtx) { + if (skelAnime->actorDrawTbl != NULL) { ZeldaArena_FreeDebug(skelAnime->actorDrawTbl, "../z_skelanime.c", 3729); - } - else - { + } else { osSyncPrintf("now_joint あきまへん!!\n"); // now_joint Akimane! ! } - if (skelAnime->unk_24 != NULL) - { + if (skelAnime->unk_24 != NULL) { ZeldaArena_FreeDebug(skelAnime->unk_24, "../z_skelanime.c", 3731); return; } osSyncPrintf("morf_joint あきまへん!!\n"); // "morf_joint Akimane !!" } -void SkelAnime_CopyVec3s(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src) -{ +void SkelAnime_CopyVec3s(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src) { s32 i; - for(i = 0; i < skelAnime->limbCount; i++) - { + for (i = 0; i < skelAnime->limbCount; i++) { *dst++ = *src++; } } -- cgit v1.2.3 From f2c65d615b287aca85a4225edc4103aefc675d36 Mon Sep 17 00:00:00 2001 From: KrimtonZ Date: Tue, 24 Mar 2020 13:06:15 -0500 Subject: fix jenkins build errors, small prototype update --- src/code/z_skelanime.c | 97 ++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 51 deletions(-) (limited to 'src/code') diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 7001c8fca..5a3b261f0 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1,5 +1,6 @@ #include #include +#include s32 func_800A3D70(GlobalContext*, SkelAnime*); s32 func_800A3E0C(GlobalContext*, SkelAnime*); @@ -52,7 +53,7 @@ void SkelAnime_LodDrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTab if (dList != NULL) { do { if (1) { - gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 0x325), + gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 805), G_MTX_LOAD); gSPDisplayList(gfxCtx->polyOpa.p++, dList); @@ -77,7 +78,7 @@ void SkelAnime_LodDrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTab appendDlistFunc, actor, dListIndex); } - func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x335); + func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 821); } void SkelAnime_LodDraw(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDrawTable, @@ -92,13 +93,13 @@ void SkelAnime_LodDraw(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDra Gfx* gfx[4]; if (limbIndex == NULL) { - osSyncPrintf("\x1b[31m"); + osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf("Si2_Lod_draw():skelがNULLです。\n"); - osSyncPrintf("\x1b[m"); + osSyncPrintf(VT_RST); return; } gfxCtx = globalCtx->state.gfxCtx; - func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x351); + func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 849); Matrix_Push(); limbEntry = SEGMENTED_TO_VIRTUAL(*limbIndex); @@ -112,7 +113,7 @@ void SkelAnime_LodDraw(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDra 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", 0x371), + gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 881), G_MTX_LOAD); gSPDisplayList(gfxCtx->polyOpa.p++, dList); @@ -128,7 +129,7 @@ void SkelAnime_LodDraw(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDra } Matrix_Pull(); - func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x37E); + func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 894); } #ifdef NON_MATCHING @@ -207,9 +208,9 @@ void SkelAnime_LodDrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorD } while (0); if (limbTable == NULL) { - osSyncPrintf("\x1b[31m"); + osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf("Si2_Lod_draw_SV():skelがNULLです。\n"); - osSyncPrintf("\x1b[m"); + osSyncPrintf(VT_RST); return; } gfxCtx = globalCtx->state.gfxCtx; @@ -270,7 +271,7 @@ void SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, gfxCtx = globalCtx->state.gfxCtx; - func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x434); + func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1076); Matrix_Push(); limbEntry = SEGMENTED_TO_VIRTUAL(limbTable[limbIndex]); @@ -324,9 +325,9 @@ void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTa Gfx* gfx[4]; if (limbTable == NULL) { - osSyncPrintf("\x1b[31m"); + osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf("Si2_draw():skelがNULLです。\n"); // Si2_draw (): skel is NULL. - osSyncPrintf("\x1b[m"); + osSyncPrintf(VT_RST); return; } @@ -378,29 +379,28 @@ void SkelAnime_DrawLimbSV(GlobalContext* globalCtx, u32 limbIndex, u32* limbTabl SkelLimbEntry* limbEntry; gfxCtx = globalCtx->state.gfxCtx; - func_800C6AC4(sp34, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x4BE); + func_800C6AC4(sp34, globalCtx->state.gfxCtx, "../z_skelanime.c", 1214); Matrix_Push(); limbEntry = SEGMENTED_TO_VIRTUAL(limbTable[limbIndex]); limbRot = actorDrawTable[++limbIndex]; - limbPos.x = (f32)limbEntry->pos.x; - limbPos.y = (f32)limbEntry->pos.y; - limbPos.z = (f32)limbEntry->pos.z; + limbPos.x = (f32)limbEntry->translation.x; + limbPos.y = (f32)limbEntry->translation.y; + limbPos.z = (f32)limbEntry->translation.z; - limbDlist[0] = limbEntry->dList; - limbDlist[1] = limbEntry->dList; + limbDlist[0] = limbDlist[1] = limbEntry->displayLists[0]; if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, limbIndex, &limbDlist[0], &limbPos, &limbRot, actor) == 0)) { Matrix_TranslateThenRotateZYX(&limbPos, &limbRot); if (limbDlist[0] != NULL) { - Matrix_ToMtx(*limbMatricies, "../z_skelanime.c", 0x4DA); + Matrix_ToMtx(*limbMatricies, "../z_skelanime.c", 1242); gSPMatrix(gfxCtx->polyOpa.p++, *limbMatricies, G_MTX_LOAD); gSPDisplayList(gfxCtx->polyOpa.p++, &limbDlist[0]); (*limbMatricies)++; } else { if (&limbDlist[1] != 0) { - Matrix_ToMtx(*limbMatricies, "../z_skelanime.c", 0x4E1); + Matrix_ToMtx(*limbMatricies, "../z_skelanime.c", 1249); (*limbMatricies)++; } } @@ -422,7 +422,7 @@ void SkelAnime_DrawLimbSV(GlobalContext* globalCtx, u32 limbIndex, u32* limbTabl appendDlistFunc, actor, limbMatricies); } - func_800C6B54(sp34, globalCtx->state.gfxCtx, "../z_skelanime.c", 0x4F1); + func_800C6B54(sp34, globalCtx->state.gfxCtx, "../z_skelanime.c", 1265); } #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_DrawLimbSV.s") @@ -443,9 +443,9 @@ void SkelAnime_DrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDraw limbMatricies = Graph_Alloc(globalCtx->state.gfxCtx, dListCount << 6); if (limbTable == NULL) { - osSyncPrintf("\x1b[31m"); + osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf("Si2_draw_SV():skelがNULLです。\n"); // Si2_draw_SV (): skel is NULL. - osSyncPrintf("\x1b[m"); + osSyncPrintf(VT_RST); return; } @@ -463,7 +463,7 @@ void SkelAnime_DrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDraw rot = actorDrawTable[1]; - skelDlist[0] = skelDlist[1] = rootLimb->dList; + skelDlist[0] = skelDlist[1] = rootLimb->displayLists[0]; if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &skelDlist[0], &pos, &rot, actor) == 0)) { Matrix_TranslateThenRotateZYX(&pos, &rot); @@ -495,7 +495,6 @@ void SkelAnime_DrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDraw #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_DrawSV.s") #endif -#undef NON_MATCHING /* * Copies the rotation values from the rotation value table, indexed by the rotation index table @@ -571,7 +570,7 @@ Gfx* SkelAnime_Draw2Limb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable 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", 0x5D1), G_MTX_LOAD); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 1489), G_MTX_LOAD); gSPDisplayList(gfx++, dList); } } @@ -606,9 +605,9 @@ Gfx* SkelAnime_Draw2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawT Gfx* dList; if (limbTable == NULL) { - osSyncPrintf("\x1b[31m"); + osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf("Si2_draw2():skelがNULLです。NULLを返します。\n"); - osSyncPrintf("\x1b[m"); + osSyncPrintf(VT_RST); return NULL; } @@ -627,7 +626,7 @@ Gfx* SkelAnime_Draw2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawT 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", 0x616), G_MTX_LOAD); + gSPMatrix(gfx++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 1558), G_MTX_LOAD); gSPDisplayList(gfx++, dList); } } @@ -673,13 +672,13 @@ Gfx* SkelAnime_DrawLimbSV2(GlobalContext* globalCtx, s32 limbIndex, u32* limbTab 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", 0x657); + 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", 0x65E); + Matrix_ToMtx(*mtx, "../z_skelanime.c", 1630); (*mtx)++; } } @@ -715,9 +714,9 @@ Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDra mtx = Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(*mtx)); if (limbTable == NULL) { - osSyncPrintf("\x1b[31m"); + osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf("Si2_draw2_SV():skelがNULLです。NULLを返します。\n"); - osSyncPrintf("\x1b[m"); + osSyncPrintf(VT_RST); return NULL; } @@ -736,13 +735,13 @@ Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDra 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", 0x6AE); + Matrix_ToMtx(mtx, "../z_skelanime.c", 1710); gSPMatrix(gfx++, mtx, G_MTX_LOAD); gSPDisplayList(gfx++, dList1); mtx++; } else { if (dList2 != NULL) { - Matrix_ToMtx(mtx, "../z_skelanime.c", 0x6B5); + Matrix_ToMtx(mtx, "../z_skelanime.c", 1717); mtx++; } } @@ -828,7 +827,7 @@ void func_800A336C(GlobalContext* globalCtx, u32 linkAnimetionSeg, s32 frame, s3 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", 0x7D4); + sizeof(Vec3s) * limbCount + 2, 0, &entry->types.type0.msgQueue, NULL, "../z_skelanime.c", 2004); } } @@ -1008,10 +1007,10 @@ void func_800A39AC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeade } if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) { - osSyncPrintf("\x1b[31m"); + osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf( "Skeleton_Info_Rom_SV_ct メモリアロケーションエラー\n"); // Skeleton_Info_Rom_SV_ct Memory allocation error - osSyncPrintf("\x1b[m"); + osSyncPrintf(VT_RST); } func_800A3F08(globalCtx, skelAnime, animation, 1.0f, 0.0f, 0.0f, 0, 0.0f); @@ -1257,9 +1256,9 @@ void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHead skelAnime->unk_24 = arg5; } if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) { - osSyncPrintf("\x1b[31m"); + osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf("Skeleton_Info2_ct メモリアロケーションエラー\n"); // Skeleton_Info2_ct memory allocation error - osSyncPrintf("\x1b[m"); + osSyncPrintf(VT_RST); } if (animation != 0) { @@ -1284,16 +1283,16 @@ void SkelAnime_InitSV(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHe ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->unk_24), "../z_skelanime.c", 3048); } else { if (limbCount != skelAnime->limbCount) { - __assert("joint_buff_num == this->joint_num", "../z_skelanime.c", 0xBEC); + __assert("joint_buff_num == this->joint_num", "../z_skelanime.c", 3052); } skelAnime->actorDrawTbl = actorDrawTable; skelAnime->unk_24 = arg5; } if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) { - osSyncPrintf("\x1b[31m"); + osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf( "Skeleton_Info_Rom_SV_ct メモリアロケーションエラー\n"); // Skeleton_Info_Rom_SV_ct Memory allocation error - osSyncPrintf("\x1b[m"); + osSyncPrintf(VT_RST); } if (animation != 0) { @@ -1312,10 +1311,10 @@ void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limb skelAnime->unk_24 = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->unk_24), "../z_skelanime.c", 3121); if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) { - osSyncPrintf("\x1b[31m"); + osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf( "Skeleton_Info2_skin2_ct メモリアロケーションエラー\n"); // Skeleton_Info2_skin2_ct Memory allocation error - osSyncPrintf("\x1b[m"); + osSyncPrintf(VT_RST); } if (animation != 0) { @@ -1432,7 +1431,6 @@ void func_800A4C58(SkelAnime* skelAnime) { #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4C58.s") #endif -#undef NON_MATCHING #ifdef NON_MATCHING s32 func_800A4D9C(SkelAnime* skelAnime) { @@ -1448,7 +1446,6 @@ s32 func_800A4D9C(SkelAnime* skelAnime) { #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4D9C.s") #endif -#undef NON_MATCHING #ifdef NON_MATCHING s32 func_800A4E38(SkelAnime* skelAnime) { @@ -1466,7 +1463,6 @@ s32 func_800A4E38(SkelAnime* skelAnime) { #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4E38.s") #endif -#undef NON_MATCHING s32 func_800A4EE0(SkelAnime* skelAnime) { f32 temp_f14; @@ -1506,10 +1502,10 @@ void SkelAnime_ChangeAnimationImpl(SkelAnime* skelAnime, u32 animation, f32 play transitionRate = -transitionRate; } else { if (unk2 != 0) { - skelAnime->mtxUpdate = (void*)&func_800A4AD8; + skelAnime->animUpdate = (void*)&func_800A4AD8; skelAnime->unk_03 = unk2; } else { - skelAnime->mtxUpdate = (void*)&func_800A4A20; + skelAnime->animUpdate = (void*)&func_800A4A20; } SkelAnime_AnimateFrame(animation, (s32)unk0, skelAnime->limbCount, skelAnime->actorDrawTbl); } @@ -1538,7 +1534,6 @@ void SkelAnime_ChangeAnimationImpl(SkelAnime* skelAnime, u32 animation, f32 play #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_ChangeAnimationImpl.s") #endif -#undef NON_MATCHING void SkelAnime_ChangeAnimation(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 unk0, f32 frameCount, u8 unk1, f32 transitionRate) { -- cgit v1.2.3 From a99840162b2ab08125bc09fa5ec7aa47a8466e21 Mon Sep 17 00:00:00 2001 From: KrimtonZ Date: Tue, 24 Mar 2020 14:01:00 -0500 Subject: minor formatting updates, match func_800A4A20 --- src/code/sys_matrix.c | 6 +-- src/code/z_skelanime.c | 135 ++++++++++++++++++++++++------------------------- 2 files changed, 67 insertions(+), 74 deletions(-) (limited to 'src/code') diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c index fd474f1fc..24c5768d0 100644 --- a/src/code/sys_matrix.c +++ b/src/code/sys_matrix.c @@ -2,16 +2,14 @@ #include // clang-format off -Mtx gMtxClear = -{ +Mtx gMtxClear = { 65536, 0, 1, 0, 0, 65536, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, }; -MtxF gMtxFClear = -{ +MtxF gMtxFClear = { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 5a3b261f0..a919d43f5 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -103,9 +103,9 @@ void SkelAnime_LodDraw(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDra Matrix_Push(); limbEntry = SEGMENTED_TO_VIRTUAL(*limbIndex); - pos.x = (f32)actorDrawTable->x; - pos.y = (f32)actorDrawTable->y; - pos.z = (f32)actorDrawTable->z; + pos.x = actorDrawTable->x; + pos.y = actorDrawTable->y; + pos.z = actorDrawTable->z; rot = actorDrawTable[1]; dList = limbEntry->displayLists[dListIndex]; @@ -133,6 +133,7 @@ void SkelAnime_LodDraw(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDra } #ifdef NON_MATCHING +//regalloc void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex, Mtx** mtx) { @@ -190,6 +191,7 @@ void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, u32* limbT #endif #ifdef NON_MATCHING +//regalloc void SkelAnime_LodDrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, s32 limbCount, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) { @@ -203,7 +205,7 @@ void SkelAnime_LodDrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorD do { if (1) { - mtx = Graph_Alloc(globalCtx->state.gfxCtx, limbCount * 0x40); + mtx = Graph_Alloc(globalCtx->state.gfxCtx, limbCount * sizeof(Mtx)); } } while (0); @@ -277,9 +279,9 @@ void SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, limbEntry = SEGMENTED_TO_VIRTUAL(limbTable[limbIndex]); limbIndex++; rot = actorDrawTable[limbIndex]; - pos.x = (f32)limbEntry->translation.x; - pos.y = (f32)limbEntry->translation.y; - pos.z = (f32)limbEntry->translation.z; + 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)) { @@ -337,9 +339,9 @@ void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTa Matrix_Push(); rootLimb = SEGMENTED_TO_VIRTUAL(*limbTable); - pos.x = (f32)actorDrawTable[0].x; - pos.y = (f32)actorDrawTable[0].y; - pos.z = (f32)actorDrawTable[0].z; + pos.x = actorDrawTable[0].x; + pos.y = actorDrawTable[0].y; + pos.z = actorDrawTable[0].z; rot = actorDrawTable[1]; dList = rootLimb->displayLists[0]; @@ -368,6 +370,7 @@ void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTa } #ifdef NON_MATCHING +// close, needs a bit bmore work. Mainly seems centered around SEGMENTED_TO_VIRTUAL void SkelAnime_DrawLimbSV(GlobalContext* globalCtx, u32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, Mtx** limbMatricies) { @@ -384,9 +387,9 @@ void SkelAnime_DrawLimbSV(GlobalContext* globalCtx, u32 limbIndex, u32* limbTabl limbEntry = SEGMENTED_TO_VIRTUAL(limbTable[limbIndex]); limbRot = actorDrawTable[++limbIndex]; - limbPos.x = (f32)limbEntry->translation.x; - limbPos.y = (f32)limbEntry->translation.y; - limbPos.z = (f32)limbEntry->translation.z; + limbPos.x = limbEntry->translation.x; + limbPos.y = limbEntry->translation.y; + limbPos.z = limbEntry->translation.z; limbDlist[0] = limbDlist[1] = limbEntry->displayLists[0]; @@ -429,6 +432,7 @@ void SkelAnime_DrawLimbSV(GlobalContext* globalCtx, u32 limbIndex, u32* limbTabl #endif #ifdef NON_MATCHING +// Regalloc, pretty much same as SkelAnime_LodDrawSV void SkelAnime_DrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, u32 dListCount, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) { @@ -457,9 +461,9 @@ void SkelAnime_DrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDraw Matrix_Push(); rootLimb = SEGMENTED_TO_VIRTUAL(*limbTable); - pos.x = (f32)actorDrawTable[0].x; - pos.y = (f32)actorDrawTable[0].y; - pos.z = (f32)actorDrawTable[0].z; + pos.x = actorDrawTable[0].x; + pos.y = actorDrawTable[0].y; + pos.z = actorDrawTable[0].z; rot = actorDrawTable[1]; @@ -473,7 +477,7 @@ void SkelAnime_DrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDraw gSPDisplayList(gfxCtx->polyOpa.p++, skelDlist[0]); limbMatricies++; } else { - if (skelDlist[1] != 0) { + if (skelDlist[1] != NULL) { Matrix_ToMtx(limbMatricies, "../z_skelanime.c", 1334); limbMatricies++; } @@ -975,12 +979,12 @@ void func_800A39AC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeade limbHeader = SEGMENTED_TO_VIRTUAL(limbHeaderSeg); headerCount = limbHeader->limbCount; skelAnime->unk_34 = flags; - limbCount = (flags & 2) != 0 ? headerCount : 1; + limbCount = (flags & 2) ? headerCount : 1; - if ((flags & 1) != 0) { + if (flags & 1) { limbCount += headerCount; } - if ((flags & 4) != 0) { + if (flags & 4) { limbCount += headerCount; } @@ -990,7 +994,7 @@ void func_800A39AC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeade allocSize = limbCount * sizeof(Vec3s); skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg); - if ((flags & 8) != 0) { + if (flags & 8) { allocSize += 2; } @@ -1066,10 +1070,8 @@ s32 func_800A3D70(GlobalContext* globalCtx, SkelAnime* skelAnime) { skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate; if (skelAnime->animCurrentFrame < 0.0f) { skelAnime->animCurrentFrame += skelAnime->unk_14; - } else { - if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) { - skelAnime->animCurrentFrame -= skelAnime->unk_14; - } + } else if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) { + skelAnime->animCurrentFrame -= skelAnime->unk_14; } func_800A3C9C(globalCtx, skelAnime); return 0; @@ -1088,10 +1090,8 @@ s32 func_800A3E0C(GlobalContext* globalCtx, SkelAnime* skelAnime) { } else { if (skelAnime->animCurrentFrame < 0.0f) { skelAnime->animCurrentFrame += skelAnime->unk_14; - } else { - if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) { - skelAnime->animCurrentFrame -= skelAnime->unk_14; - } + } else if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) { + skelAnime->animCurrentFrame -= skelAnime->unk_14; } } func_800A3C9C(globalCtx, skelAnime); @@ -1137,20 +1137,20 @@ void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32* animatio #endif void func_800A407C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation) { - func_800A3F08(globalCtx, skelAnime, animation, 1.0f, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 2, 0.0f); + func_800A3F08(globalCtx, skelAnime, animation, 1.0f, 0.0f, SkelAnime_GetFrameCount(animation), 2, 0.0f); } void func_800A40DC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) { - func_800A3F08(globalCtx, skelAnime, animation, playbackSpeed, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 2, + func_800A3F08(globalCtx, skelAnime, animation, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(animation), 2, 0.0f); } void func_800A4140(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation) { - func_800A3F08(globalCtx, skelAnime, animation, 1.0f, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 0, 0.0f); + func_800A3F08(globalCtx, skelAnime, animation, 1.0f, 0.0f, SkelAnime_GetFrameCount(animation), 0, 0.0f); } void func_800A419C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) { - func_800A3F08(globalCtx, skelAnime, animation, playbackSpeed, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 0, + func_800A3F08(globalCtx, skelAnime, animation, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(animation), 0, 0.0f); } @@ -1325,51 +1325,45 @@ void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limb void func_800A49B0(SkelAnime* skelAnime) { if (skelAnime->unk_01 < 2) { skelAnime->animUpdate = &func_800A4D9C; - return; - } - if (skelAnime->unk_01 < 4) { + } else if (skelAnime->unk_01 < 4) { skelAnime->animUpdate = &func_800A4EE0; - return; + } else { + skelAnime->animUpdate = &func_800A4E38; } - skelAnime->animUpdate = &func_800A4E38; } s32 SkelAnime_FrameUpdateMatrix(SkelAnime* skelAnime) { return skelAnime->animUpdate(skelAnime); } -#ifdef NON_MATCHING s32 func_800A4A20(SkelAnime* skelAnime) { - f32 sp2C; - f32 temp_f12; - f32 phi_f0; + f32 prevUnk28; + f32 updateRate; - temp_f12 = skelAnime->unk_28; - skelAnime->unk_28 -= skelAnime->unk_2C * (R_UPDATE_RATE * 0.33333334f); - phi_f0 = skelAnime->unk_28; + prevUnk28 = skelAnime->unk_28; + updateRate = R_UPDATE_RATE * 0.33333334f; + skelAnime->unk_28 -= skelAnime->unk_2C * updateRate; if (skelAnime->unk_28 <= 0.0f) { - sp2C = temp_f12; func_800A49B0(skelAnime); skelAnime->unk_28 = 0.0f; - phi_f0 = skelAnime->unk_28; } func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, skelAnime->unk_24, - 1.0f - (phi_f0 / temp_f12)); + 1.0f - (skelAnime->unk_28 / prevUnk28)); return 0; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4A20.s") -#endif #ifdef NON_MATCHING +// small stack alloc s32 func_800A4AD8(SkelAnime* skelAnime) { - f32 sp28; s16 temp_a1; s16 temp_a2; + f32 sp28; f32 phi_f2; + f32 updateRate; temp_a2 = (s16)(skelAnime->unk_28 * 16384.0f); - skelAnime->unk_28 -= skelAnime->unk_2C * (R_UPDATE_RATE * 0.33333334f); + updateRate = R_UPDATE_RATE * 0.33333334f; + skelAnime->unk_28 -= skelAnime->unk_2C * updateRate; if (skelAnime->unk_28 <= 0.0f) { func_800A49B0(skelAnime); skelAnime->unk_28 = 0.0f; @@ -1467,7 +1461,7 @@ s32 func_800A4E38(SkelAnime* skelAnime) { s32 func_800A4EE0(SkelAnime* skelAnime) { f32 temp_f14; - temp_f14 = (f32)R_UPDATE_RATE * 0.33333334f; + temp_f14 = R_UPDATE_RATE * 0.33333334f; if (skelAnime->animCurrentFrame == skelAnime->animFrameCount) { SkelAnime_AnimateFrame(skelAnime->animCurrent, (s32)skelAnime->animCurrentFrame, skelAnime->limbCount, @@ -1492,7 +1486,7 @@ s32 func_800A4EE0(SkelAnime* skelAnime) { } #ifdef NON_MATCHING -void SkelAnime_ChangeAnimationImpl(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 unk0, f32 frameCount, +void SkelAnime_ChangeAnimationImpl(SkelAnime* skelAnime, u32* animation, f32 playbackSpeed, f32 unk0, f32 frameCount, u8 unk1, f32 transitionRate, s8 unk2) { skelAnime->unk_01 = unk1; if ((transitionRate != 0.0f) && ((animation != skelAnime->animCurrent) || (unk0 != skelAnime->animCurrentFrame))) { @@ -1520,7 +1514,7 @@ void SkelAnime_ChangeAnimationImpl(SkelAnime* skelAnime, u32 animation, f32 play skelAnime->animCurrent = animation; skelAnime->unk_0C = unk0; skelAnime->animFrameCount = frameCount; - skelAnime->unk_14 = (f32)func_800A1FC8(animation); + skelAnime->unk_14 = func_800A1FC8(animation); if (skelAnime->unk_01 >= 4) { skelAnime->animCurrentFrame = 0.0f; } else { @@ -1541,21 +1535,21 @@ void SkelAnime_ChangeAnimation(SkelAnime* skelAnime, u32 animation, f32 playback } void func_800A51E8(SkelAnime* skelAnime, u32 animation) { - SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 2, 0.0f); + SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, SkelAnime_GetFrameCount(animation), 2, 0.0f); } void func_800A5240(SkelAnime* skelAnime, u32 animation, f32 transitionRate) { - SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0, (f32)SkelAnime_GetFrameCount(animation), 2, + SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0, SkelAnime_GetFrameCount(animation), 2, transitionRate); } void func_800A529C(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) { - SkelAnime_ChangeAnimation(skelAnime, animation, playbackSpeed, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 2, + SkelAnime_ChangeAnimation(skelAnime, animation, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(animation), 2, 0.0f); } void SkelAnime_ChangeAnimationDefault(SkelAnime* skelAnime, u32 animation) { - SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 0, 0.0f); + SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, SkelAnime_GetFrameCount(animation), 0, 0.0f); } void SkelAnime_ChangeAnimationTransitionRate(SkelAnime* skelAnime, u32 animation, f32 transitionRate) { @@ -1563,7 +1557,7 @@ void SkelAnime_ChangeAnimationTransitionRate(SkelAnime* skelAnime, u32 animation } void SkelAnime_ChangeAnimationPlaybackSpeed(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) { - SkelAnime_ChangeAnimation(skelAnime, animation, playbackSpeed, 0.0f, (f32)SkelAnime_GetFrameCount(animation), 0, + SkelAnime_ChangeAnimation(skelAnime, animation, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(animation), 0, 0.0f); } @@ -1612,18 +1606,18 @@ void func_800A54FC(SkelAnime* skelAnime, Vec3f* pos, s16 angle) { f32 sin; f32 cos; - if ((skelAnime->unk_35 & 0x10) != 0) { + if (skelAnime->unk_35 & 0x10) { pos->z = 0.0f; pos->x = 0.0f; } else { - x = (f32)skelAnime->actorDrawTbl->x; - z = (f32)skelAnime->actorDrawTbl->z; + x = skelAnime->actorDrawTbl->x; + z = skelAnime->actorDrawTbl->z; sin = Math_Sins(angle); cos = Math_Coss(angle); pos->x = x * cos + z * sin; pos->z = z * cos - x * sin; - x = (f32)skelAnime->unk_38; - z = (f32)skelAnime->unk_3C; + x = skelAnime->unk_38; + z = skelAnime->unk_3C; sin = Math_Sins(skelAnime->unk_36); cos = Math_Coss(skelAnime->unk_36); pos->x -= x * cos + z * sin; @@ -1635,11 +1629,11 @@ void func_800A54FC(SkelAnime* skelAnime, Vec3f* pos, s16 angle) { skelAnime->actorDrawTbl->x = skelAnime->unk_3E; skelAnime->unk_3C = skelAnime->actorDrawTbl->z; skelAnime->actorDrawTbl->z = skelAnime->unk_42; - if ((skelAnime->unk_35 & 2) != 0) { + if (skelAnime->unk_35 & 2) { if ((skelAnime->unk_35 & 0x10) != 0) { pos->y = 0.0f; } else { - pos->y = (f32)(skelAnime->actorDrawTbl->y - skelAnime->unk_3A); + pos->y = skelAnime->actorDrawTbl->y - skelAnime->unk_3A; } skelAnime->unk_3A = skelAnime->actorDrawTbl->y; skelAnime->actorDrawTbl->y = skelAnime->unk_40; @@ -1660,11 +1654,12 @@ void SkelAnime_Free(SkelAnime* skelAnime, GlobalContext* globalCtx) { } else { osSyncPrintf("now_joint あきまへん!!\n"); // now_joint Akimane! ! } + if (skelAnime->unk_24 != NULL) { ZeldaArena_FreeDebug(skelAnime->unk_24, "../z_skelanime.c", 3731); - return; + } else { + osSyncPrintf("morf_joint あきまへん!!\n"); // "morf_joint Akimane !!" } - osSyncPrintf("morf_joint あきまへん!!\n"); // "morf_joint Akimane !!" } void SkelAnime_CopyVec3s(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src) { -- cgit v1.2.3 From 4b7f998b20cdc606fdedea04934257671453896c Mon Sep 17 00:00:00 2001 From: dark-samus Date: Tue, 24 Mar 2020 16:53:09 -0400 Subject: match final non-matching in sys_cfb.c --- src/code/sys_cfb.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/code') diff --git a/src/code/sys_cfb.c b/src/code/sys_cfb.c index 454b63a58..421037c38 100644 --- a/src/code/sys_cfb.c +++ b/src/code/sys_cfb.c @@ -1,14 +1,15 @@ #include -volatile u32 sSysCfbFbPtr[2]; // may not be volatile but it currently gets SysCfb_Init closer from matching +u32 sSysCfbFbPtr[2]; u32 sSysCfbEnd; -// small reaordering -#ifdef NON_MATCHING void SysCfb_Init(s32 n64dd) { + u32 screenSize; + u32 tmpFbEnd; if (osMemSize >= 0x800000U) { // 8MB or more memory is installed osSyncPrintf("8Mバイト以上のメモリが搭載されています\n"); + tmpFbEnd = 0x8044BE80; if (n64dd == 1) { // RAM 8M mode (N64DD compatible) osSyncPrintf("RAM 8M mode (N64DD対応)\n"); @@ -16,26 +17,24 @@ void SysCfb_Init(s32 n64dd) { } else { // The margin for this version is% dK bytes osSyncPrintf("このバージョンのマージンは %dK バイトです\n", (0x4BC00 / 1024)); - sSysCfbEnd = 0x8044BE80; + sSysCfbEnd = tmpFbEnd; } } else if (osMemSize >= 0x400000U) { - sSysCfbEnd = 0x80400000; osSyncPrintf("RAM4M mode\n"); + sSysCfbEnd = 0x80400000; } else { LogUtils_HungupThread("../sys_cfb.c", 0x162); } + screenSize = SCREEN_WIDTH * SCREEN_HEIGHT; sSysCfbEnd &= ~0x3f; // The final address used by the system is% 08x osSyncPrintf("システムが使用する最終アドレスは %08x です\n", sSysCfbEnd); - sSysCfbFbPtr[0] = sSysCfbEnd - (SCREEN_WIDTH * SCREEN_HEIGHT * 4); - sSysCfbFbPtr[1] = sSysCfbEnd - (SCREEN_WIDTH * SCREEN_HEIGHT * 2); + sSysCfbFbPtr[0] = sSysCfbEnd - (screenSize * 4); + sSysCfbFbPtr[1] = sSysCfbEnd - (screenSize * 2); // Frame buffer addresses are% 08x and% 08x osSyncPrintf("フレームバッファのアドレスは %08x と %08x です\n", sSysCfbFbPtr[0], sSysCfbFbPtr[1]); } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cfb/SysCfb_Init.s") -#endif void SysCfb_Reset() { sSysCfbFbPtr[0] = 0; -- cgit v1.2.3 From f0c033ce701a5064a9b943a163be4462724bf70d Mon Sep 17 00:00:00 2001 From: JoshDuMan Date: Tue, 24 Mar 2020 19:52:07 -0400 Subject: Match func_809C1CAC --- src/code/z_sample.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/code') diff --git a/src/code/z_sample.c b/src/code/z_sample.c index 2f4f3fc6f..9b9fa9559 100644 --- a/src/code/z_sample.c +++ b/src/code/z_sample.c @@ -34,10 +34,11 @@ void Sample_Draw(SampleContext* this) { gfxCtx->polyOpa.p = func_80093708(gfxCtx->polyOpa.p, 0xFF, 0xFF, 0xFF, 0, 0, 0); func_80093D18(gfxCtx); - + gDPSetCycleType(gfxCtx->polyOpa.p++, G_CYC_1CYCLE); gDPSetRenderMode(gfxCtx->polyOpa.p++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2); - gDPSetCombineLERP(gfxCtx->polyOpa.p++, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE); + gDPSetCombineLERP(gfxCtx->polyOpa.p++, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE, 0, 0, 0, + PRIMITIVE); gDPSetPrimColor(gfxCtx->polyOpa.p++, 0, 0, 0xFF, 0xFF, 0x00, 0x00); func_800C6B54(gfxArr, gfxCtx, "../z_sample.c", 111); -- cgit v1.2.3 From 8970968cfcfcfb86b70eec9b26528d7d9d2c160e Mon Sep 17 00:00:00 2001 From: KrimtonZ Date: Wed, 25 Mar 2020 10:51:25 -0500 Subject: name SkelAnime_InitLinkAnimetion, name load animation types and callbacks, rename several segement addresses in decompiled actors --- src/code/z_actor.c | 8 +- src/code/z_skelanime.c | 560 ++++++++++++++++++++++++------------------------- 2 files changed, 276 insertions(+), 292 deletions(-) (limited to 'src/code') diff --git a/src/code/z_actor.c b/src/code/z_actor.c index eec16df03..9928be4d9 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -9,7 +9,7 @@ void ActorShape_Init(ActorShape* shape, f32 arg1, void* shadowDrawFunc, f32 arg3 shape->unk_14 = -1; } -void func_8002B200(Actor* actor, LightMapper* lightMapper, GlobalContext* globalCtx, u32 dlist, Color_RGBA8* color) { +void func_8002B200(Actor* actor, LightMapper* lightMapper, GlobalContext* globalCtx, Gfx* dlist, Color_RGBA8* color) { f32 temp1; f32 temp2; MtxF sp60; @@ -41,7 +41,7 @@ void func_8002B200(Actor* actor, LightMapper* lightMapper, GlobalContext* global func_80038A28(actor->floorPoly, actor->posRot.pos.x, actor->unk_80, actor->posRot.pos.z, &sp60); Matrix_Put(&sp60); - if (dlist != (u32)&D_04049210) { + if (dlist != D_04049210) { Matrix_RotateY(actor->shape.rot.y * (M_PI / 32768), MTXMODE_APPLY); } @@ -3898,7 +3898,7 @@ void func_80034BA0(GlobalContext* globalCtx, SkelAnime* skelAnime, void* unkFunc gDPPipeSync(gfxCtx->polyOpa.p++); gSPSegment(gfxCtx->polyOpa.p++, 0x0C, func_80034B28(globalCtx->state.gfxCtx)); - gfxCtx->polyOpa.p = SkelAnime_DrawSV2(globalCtx, skelAnime->limbIndex, skelAnime->actorDrawTbl, + gfxCtx->polyOpa.p = SkelAnime_DrawSV2(globalCtx, skelAnime->skeleton, skelAnime->actorDrawTbl, skelAnime->dListCount, unkFunc1, unkFunc2, actor, gfxCtx->polyOpa.p); func_800C6B54(gfxArr, globalCtx->state.gfxCtx, "../z_actor.c", 8860); @@ -3917,7 +3917,7 @@ void func_80034CC4(GlobalContext* globalCtx, SkelAnime* skelAnime, void* unkFunc gDPSetEnvColor(gfxCtx->polyXlu.p++, 0x00, 0x00, 0x00, alpha); gSPSegment(gfxCtx->polyXlu.p++, 0x0C, func_80034B54(globalCtx->state.gfxCtx)); - gfxCtx->polyXlu.p = SkelAnime_DrawSV2(globalCtx, skelAnime->limbIndex, skelAnime->actorDrawTbl, + gfxCtx->polyXlu.p = SkelAnime_DrawSV2(globalCtx, skelAnime->skeleton, skelAnime->actorDrawTbl, skelAnime->dListCount, unkFunc1, unkFunc2, actor, gfxCtx->polyXlu.p); func_800C6B54(gfxArr, globalCtx->state.gfxCtx, "../z_actor.c", 8904); diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index a919d43f5..e625a3784 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -7,26 +7,27 @@ s32 func_800A3E0C(GlobalContext*, SkelAnime*); s32 func_800A4D9C(SkelAnime* skelAnime); s32 func_800A4EE0(SkelAnime* skelAnime); s32 func_800A4E38(SkelAnime* skelAnime); +s32 func_800A4AD8(SkelAnime* skelAnime); void SkelAnime_CopyVec3s(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); -void func_800A3678(GlobalContext* globalCtx, AnimationEntryType0* entry); -void func_800A36A4(GlobalContext* globalCtx, AnimationEntryType1* entry); -void func_800A3714(GlobalContext* globalCtx, AnimationEntryType2* entry); -void func_800A3770(GlobalContext* globalCtx, AnimationEntryType3* entry); -void func_800A37F0(GlobalContext* globalCtx, AnimationEntryType4* entry); -void func_800A3874(GlobalContext* globalCtx, AnimationEntryType5* entry); +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); //.data u32 D_8012A480 = 0; static AnimationEntryCallback D_8012A484[] = { - (AnimationEntryCallback)&func_800A3678, (AnimationEntryCallback)&func_800A36A4, - (AnimationEntryCallback)&func_800A3714, (AnimationEntryCallback)&func_800A3770, - (AnimationEntryCallback)&func_800A37F0, (AnimationEntryCallback)&func_800A3874, + &SkelAnime_LinkAnimetionLoaded, &SkelAnime_AnimationType1Loaded, + &SkelAnime_AnimationType2Loaded, &SkelAnime_AnimationType3Loaded, + &SkelAnime_AnimationType4Loaded, &SkelAnime_AnimationType5Loaded, }; //.bss u32 D_801600B0; -void SkelAnime_LodDrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, +void SkelAnime_LodDrawLimb(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skeleton, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) { SkelLimbEntry* limbEntry; @@ -39,7 +40,7 @@ void SkelAnime_LodDrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTab gfxCtx = globalCtx->state.gfxCtx; func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 773); Matrix_Push(); - limbEntry = SEGMENTED_TO_VIRTUAL(limbTable[limbIndex]); + limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[limbIndex]); limbIndex++; rot = actorDrawTable[limbIndex]; @@ -67,21 +68,21 @@ void SkelAnime_LodDrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTab } if (limbEntry->firstChildIndex != LIMB_DONE) { - SkelAnime_LodDrawLimb(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + SkelAnime_LodDrawLimb(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex); } Matrix_Pull(); if (limbEntry->nextLimbIndex != LIMB_DONE) { - SkelAnime_LodDrawLimb(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, + SkelAnime_LodDrawLimb(globalCtx, limbEntry->nextLimbIndex, skeleton, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex); } func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 821); } -void SkelAnime_LodDraw(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDrawTable, +void SkelAnime_LodDraw(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) { SkelLimbEntry* limbEntry; @@ -92,7 +93,7 @@ void SkelAnime_LodDraw(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDra GraphicsContext* gfxCtx; Gfx* gfx[4]; - if (limbIndex == NULL) { + if (skeleton == NULL) { osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf("Si2_Lod_draw():skelがNULLです。\n"); osSyncPrintf(VT_RST); @@ -102,7 +103,7 @@ void SkelAnime_LodDraw(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDra func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 849); Matrix_Push(); - limbEntry = SEGMENTED_TO_VIRTUAL(*limbIndex); + limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[0]); pos.x = actorDrawTable->x; pos.y = actorDrawTable->y; pos.z = actorDrawTable->z; @@ -113,8 +114,7 @@ void SkelAnime_LodDraw(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDra 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); + gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_skelanime.c", 881), G_MTX_LOAD); gSPDisplayList(gfxCtx->polyOpa.p++, dList); } @@ -124,7 +124,7 @@ void SkelAnime_LodDraw(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDra } if (limbEntry->firstChildIndex != 0xFF) { - SkelAnime_LodDrawLimb(globalCtx, limbEntry->firstChildIndex, limbIndex, actorDrawTable, updateMtxFunc, + SkelAnime_LodDrawLimb(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex); } @@ -132,9 +132,10 @@ void SkelAnime_LodDraw(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDra func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 894); } +//#define NON_MATCHING #ifdef NON_MATCHING -//regalloc -void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, +// regalloc +void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skeleton, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex, Mtx** mtx) { SkelLimbEntry* limbEntry; @@ -146,7 +147,7 @@ void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, u32* limbT Matrix_Push(); - limbEntry = SEGMENTED_TO_VIRTUAL(limbTable[limbIndex]); + limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[limbIndex]); limbIndex++; rot = actorDrawTable[limbIndex]; @@ -166,7 +167,7 @@ void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, u32* limbT gSPDisplayList(gfxCtx->polyOpa.p++, dList[1]); func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 949); (*mtx)++; - } else if (dList[0] != 0) { + } else if (dList[0] != NULL) { Matrix_ToMtx(*mtx, "../z_skelanime.c", 954); (*mtx)++; } @@ -175,14 +176,14 @@ void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, u32* limbT appendDlistFunc(globalCtx, limbIndex, &dList[0], &rot, actor); } if (limbEntry->firstChildIndex != LIMB_DONE) { - SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex, mtx); } Matrix_Pull(); if (limbEntry->nextLimbIndex != LIMB_DONE) { - SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, + SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->nextLimbIndex, skeleton, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex, mtx); } } @@ -191,8 +192,8 @@ void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, u32* limbT #endif #ifdef NON_MATCHING -//regalloc -void SkelAnime_LodDrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, s32 limbCount, +// regalloc +void SkelAnime_LodDrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, s32 limbCount, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) { SkelLimbEntry* limbEntry; @@ -203,13 +204,9 @@ void SkelAnime_LodDrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorD GraphicsContext* gfxCtx; Gfx* gfx[4]; - do { - if (1) { - mtx = Graph_Alloc(globalCtx->state.gfxCtx, limbCount * sizeof(Mtx)); - } - } while (0); + mtx = Graph_Alloc(globalCtx->state.gfxCtx, limbCount * sizeof(Mtx)); - if (limbTable == NULL) { + if (skeleton == NULL) { osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf("Si2_Lod_draw_SV():skelがNULLです。\n"); osSyncPrintf(VT_RST); @@ -220,15 +217,15 @@ void SkelAnime_LodDrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorD gSPSegment(gfxCtx->polyOpa.p++, 0xD, mtx); Matrix_Push(); - limbEntry = SEGMENTED_TO_VIRTUAL(*limbTable); - + limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[0]); + if (limbEntry) {} pos.x = actorDrawTable->x; pos.y = actorDrawTable->y; pos.z = actorDrawTable->z; rot = actorDrawTable[1]; - dList[1] = dList[0] = limbEntry->displayLists[dListIndex]; + dList[0] = dList[1] = limbEntry->displayLists[dListIndex]; if ((updateMtxFunc == 0) || (updateMtxFunc(globalCtx, 1, &dList[1], &pos, &rot, actor) == 0)) { Matrix_TranslateThenRotateZYX(&pos, &rot); @@ -237,11 +234,9 @@ void SkelAnime_LodDrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorD 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++; - } + } else if (dList[0] != NULL) { + Matrix_ToMtx(mtx, "../z_skelanime.c", 1040); + mtx++; } } @@ -249,7 +244,7 @@ void SkelAnime_LodDrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorD appendDlistFunc(globalCtx, 1, &dList[0], &rot, actor); } if (limbEntry->firstChildIndex != LIMB_DONE) { - SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + SkelAnime_LodDrawLimbSV(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex, &mtx); } @@ -261,7 +256,7 @@ void SkelAnime_LodDrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorD #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_LodDrawSV.s") #endif -void SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, +void SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skeleton, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) { SkelLimbEntry* limbEntry; @@ -276,7 +271,7 @@ void SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1076); Matrix_Push(); - limbEntry = SEGMENTED_TO_VIRTUAL(limbTable[limbIndex]); + limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[limbIndex]); limbIndex++; rot = actorDrawTable[limbIndex]; pos.x = limbEntry->translation.x; @@ -302,21 +297,21 @@ void SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, } if (limbEntry->firstChildIndex != LIMB_DONE) { - SkelAnime_DrawLimb(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + SkelAnime_DrawLimb(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc, appendDlistFunc, actor); } Matrix_Pull(); if (limbEntry->nextLimbIndex != LIMB_DONE) { - SkelAnime_DrawLimb(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, + SkelAnime_DrawLimb(globalCtx, limbEntry->nextLimbIndex, skeleton, actorDrawTable, updateMtxFunc, appendDlistFunc, actor); } func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1121); } -void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, +void SkelAnime_Draw(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) { SkelLimbEntry* rootLimb; char pad[4]; @@ -326,7 +321,7 @@ void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTa GraphicsContext* gfxCtx; Gfx* gfx[4]; - if (limbTable == NULL) { + if (skeleton == NULL) { osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf("Si2_draw():skelがNULLです。\n"); // Si2_draw (): skel is NULL. osSyncPrintf(VT_RST); @@ -337,7 +332,7 @@ void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTa func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1148); Matrix_Push(); - rootLimb = SEGMENTED_TO_VIRTUAL(*limbTable); + rootLimb = SEGMENTED_TO_VIRTUAL(skeleton->limbs[0]); pos.x = actorDrawTable[0].x; pos.y = actorDrawTable[0].y; @@ -360,7 +355,7 @@ void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTa } if (rootLimb->firstChildIndex != LIMB_DONE) { - SkelAnime_DrawLimb(globalCtx, rootLimb->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + SkelAnime_DrawLimb(globalCtx, rootLimb->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc, appendDlistFunc, actor); } @@ -371,61 +366,60 @@ void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTa #ifdef NON_MATCHING // close, needs a bit bmore work. Mainly seems centered around SEGMENTED_TO_VIRTUAL -void SkelAnime_DrawLimbSV(GlobalContext* globalCtx, u32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, +void SkelAnime_DrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skeleton, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, Mtx** limbMatricies) { - Gfx* limbDlist[2]; - Vec3f limbPos; - Vec3s limbRot; - GraphicsContext* gfxCtx; - Gfx* sp34[3]; SkelLimbEntry* limbEntry; + Gfx* dList[2]; + Vec3f pos; + Vec3s rot; + GraphicsContext* gfxCtx; + Gfx* gfx[3]; gfxCtx = globalCtx->state.gfxCtx; - func_800C6AC4(sp34, globalCtx->state.gfxCtx, "../z_skelanime.c", 1214); + func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1214); Matrix_Push(); - limbEntry = SEGMENTED_TO_VIRTUAL(limbTable[limbIndex]); - limbRot = actorDrawTable[++limbIndex]; - limbPos.x = limbEntry->translation.x; - limbPos.y = limbEntry->translation.y; - limbPos.z = limbEntry->translation.z; + 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; - limbDlist[0] = limbDlist[1] = limbEntry->displayLists[0]; + dList[0] = dList[1] = limbEntry->displayLists[0]; - if ((updateMtxFunc == NULL) || - (updateMtxFunc(globalCtx, limbIndex, &limbDlist[0], &limbPos, &limbRot, actor) == 0)) { - Matrix_TranslateThenRotateZYX(&limbPos, &limbRot); - if (limbDlist[0] != NULL) { + 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); gSPMatrix(gfxCtx->polyOpa.p++, *limbMatricies, G_MTX_LOAD); - gSPDisplayList(gfxCtx->polyOpa.p++, &limbDlist[0]); + gSPDisplayList(gfxCtx->polyOpa.p++, dList[1]); + (*limbMatricies)++; + } else if (dList[0] != NULL) { + Matrix_ToMtx(*limbMatricies, "../z_skelanime.c", 1249); (*limbMatricies)++; - } else { - if (&limbDlist[1] != 0) { - Matrix_ToMtx(*limbMatricies, "../z_skelanime.c", 1249); - (*limbMatricies)++; - } } } if (appendDlistFunc != NULL) { - appendDlistFunc(globalCtx, limbIndex, &limbDlist[1], &limbRot, actor); + appendDlistFunc(globalCtx, limbIndex, &dList[0], &rot, actor); } if (limbEntry->firstChildIndex != LIMB_DONE) { - SkelAnime_DrawLimbSV(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + SkelAnime_DrawLimbSV(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, limbMatricies); } Matrix_Pull(); if (limbEntry->nextLimbIndex != LIMB_DONE) { - SkelAnime_DrawLimbSV(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, + SkelAnime_DrawLimbSV(globalCtx, limbEntry->nextLimbIndex, skeleton, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, limbMatricies); } - func_800C6B54(sp34, globalCtx->state.gfxCtx, "../z_skelanime.c", 1265); + func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1265); } #else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_DrawLimbSV.s") @@ -433,20 +427,21 @@ void SkelAnime_DrawLimbSV(GlobalContext* globalCtx, u32 limbIndex, u32* limbTabl #ifdef NON_MATCHING // Regalloc, pretty much same as SkelAnime_LodDrawSV -void SkelAnime_DrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, u32 dListCount, +void SkelAnime_DrawSV(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, s32 limbCount, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) { - SkelLimbEntry* rootLimb; - Gfx* skelDlist[2]; + SkelLimbEntry* limbEntry; + char pad[4]; + Gfx* dList[2]; Vec3f pos; Vec3s rot; + Mtx* mtx; GraphicsContext* gfxCtx; - Mtx* limbMatricies; - Gfx* gfx[5]; + Gfx* gfx[4]; - limbMatricies = Graph_Alloc(globalCtx->state.gfxCtx, dListCount << 6); + mtx = Graph_Alloc(globalCtx->state.gfxCtx, limbCount * sizeof(Mtx)); - if (limbTable == NULL) { + if (skeleton == NULL) { osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf("Si2_draw_SV():skelがNULLです。\n"); // Si2_draw_SV (): skel is NULL. osSyncPrintf(VT_RST); @@ -457,40 +452,42 @@ void SkelAnime_DrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDraw func_800C6AC4(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 1294); - gSPSegment(gfxCtx->polyOpa.p++, 0xD, limbMatricies); + gSPSegment(gfxCtx->polyOpa.p++, 0xD, mtx); + Matrix_Push(); - rootLimb = SEGMENTED_TO_VIRTUAL(*limbTable); - pos.x = actorDrawTable[0].x; - pos.y = actorDrawTable[0].y; - pos.z = actorDrawTable[0].z; + limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[0]); + + pos.x = actorDrawTable->x; + pos.y = actorDrawTable->x; + pos.z = actorDrawTable->z; rot = actorDrawTable[1]; - skelDlist[0] = skelDlist[1] = rootLimb->displayLists[0]; + dList[0] = dList[1] = limbEntry->displayLists[0]; - if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &skelDlist[0], &pos, &rot, actor) == 0)) { + if ((updateMtxFunc == NULL) || (updateMtxFunc(globalCtx, 1, &dList[1], &pos, &rot, actor) == 0)) { Matrix_TranslateThenRotateZYX(&pos, &rot); - if (skelDlist[0] != NULL) { - Matrix_ToMtx(limbMatricies, "../z_skelanime.c", 1327); - gSPMatrix(gfxCtx->polyOpa.p++, limbMatricies, G_MTX_LOAD); - gSPDisplayList(gfxCtx->polyOpa.p++, skelDlist[0]); - limbMatricies++; + 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 (skelDlist[1] != NULL) { - Matrix_ToMtx(limbMatricies, "../z_skelanime.c", 1334); - limbMatricies++; + if (dList[0] != NULL) { + Matrix_ToMtx(mtx, "../z_skelanime.c", 1334); + mtx++; } } } - if (appendDlistFunc != 0) { - appendDlistFunc(globalCtx, 1, &skelDlist[1], &rot, actor); + if (appendDlistFunc != NULL) { + appendDlistFunc(globalCtx, 1, &dList[0], &rot, actor); } - if (rootLimb->firstChildIndex != LIMB_DONE) { - SkelAnime_DrawLimbSV(globalCtx, rootLimb->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, - appendDlistFunc, actor, &limbMatricies); + if (limbEntry->firstChildIndex != LIMB_DONE) { + SkelAnime_DrawLimbSV(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc, + appendDlistFunc, actor, &mtx); } Matrix_Pull(); @@ -505,7 +502,7 @@ void SkelAnime_DrawSV(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDraw * 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(u32 animation, s32 currentFrame, s32 limbCount, Vec3s* dst) { +void SkelAnime_AnimateFrame(AnimationHeader* animationSeg, s32 currentFrame, s32 limbCount, Vec3s* dst) { AnimationRotationIndex* index; AnimationRotationValue* rotationValueTable; AnimationRotationValue* frameRotationValueTable; @@ -514,7 +511,7 @@ void SkelAnime_AnimateFrame(u32 animation, s32 currentFrame, s32 limbCount, Vec3 s32 i; u16 limit; - animationHeader = SEGMENTED_TO_VIRTUAL(animation); + animationHeader = SEGMENTED_TO_VIRTUAL(animationSeg); index = SEGMENTED_TO_VIRTUAL(animationHeader->rotationIndexSeg); rotationValueTable = SEGMENTED_TO_VIRTUAL(animationHeader->rotationValueSeg); frameRotationValueTable = &rotationValueTable[currentFrame]; @@ -539,18 +536,18 @@ void SkelAnime_AnimateFrame(u32 animation, s32 currentFrame, s32 limbCount, Vec3 } } -s16 func_800A1FC8(u32 animationSeg) { - AnimationHeader* animation = (u16*)SEGMENTED_TO_VIRTUAL(animationSeg); +s16 func_800A1FC8(GenericAnimationHeader* animationSeg) { + GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); return animation->frameCount; } -s32 SkelAnime_GetFrameCount(u32 animationSeg) { - AnimationHeader* animation = (u16*)SEGMENTED_TO_VIRTUAL(animationSeg); +s16 SkelAnime_GetFrameCount(GenericAnimationHeader* animationSeg) { + GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); - return (s16)((u16)animation->frameCount - 1); + return (u16)animation->frameCount - 1; } -Gfx* SkelAnime_Draw2Limb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, +Gfx* SkelAnime_Draw2Limb(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skeleton, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, Actor* actor, Gfx* gfx) { SkelLimbEntry* limbEntry; @@ -560,7 +557,7 @@ Gfx* SkelAnime_Draw2Limb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable Matrix_Push(); - limbEntry = SEGMENTED_TO_VIRTUAL(limbTable[limbIndex]); + limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[limbIndex]); limbIndex++; rot = actorDrawTable[limbIndex]; @@ -584,31 +581,30 @@ Gfx* SkelAnime_Draw2Limb(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable } if (limbEntry->firstChildIndex != LIMB_DONE) { - gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + 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, limbTable, actorDrawTable, updateMtxFunc, + gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->nextLimbIndex, skeleton, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, gfx); } return gfx; } -#ifdef NON_MATCHING -// Some regalloc, and nonmatching stack usage -Gfx* SkelAnime_Draw2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, +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; - Gfx* dList; - if (limbTable == NULL) { + if (skeleton == NULL) { osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf("Si2_draw2():skelがNULLです。NULLを返します。\n"); osSyncPrintf(VT_RST); @@ -617,11 +613,11 @@ Gfx* SkelAnime_Draw2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawT Matrix_Push(); - limbEntry = SEGMENTED_TO_VIRTUAL(*limbTable); + limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[0]); - pos.x = limbEntry->translation.x; - pos.y = limbEntry->translation.y; - pos.z = limbEntry->translation.z; + pos.x = actorDrawTable->x; + pos.y = actorDrawTable->y; + pos.z = actorDrawTable->z; rot = actorDrawTable[1]; @@ -640,7 +636,7 @@ Gfx* SkelAnime_Draw2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawT } if (limbEntry->firstChildIndex != LIMB_DONE) { - gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + gfx = SkelAnime_Draw2Limb(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, gfx); } @@ -648,11 +644,8 @@ Gfx* SkelAnime_Draw2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawT return gfx; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_Draw2.s") -#endif -Gfx* SkelAnime_DrawLimbSV2(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, +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; @@ -664,7 +657,7 @@ Gfx* SkelAnime_DrawLimbSV2(GlobalContext* globalCtx, s32 limbIndex, u32* limbTab Matrix_Push(); - limbEntry = SEGMENTED_TO_VIRTUAL(limbTable[limbIndex]); + limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[limbIndex]); limbIndex++; rot = actorDrawTable[limbIndex]; @@ -687,25 +680,25 @@ Gfx* SkelAnime_DrawLimbSV2(GlobalContext* globalCtx, s32 limbIndex, u32* limbTab } } } - if (appendDlistFunc != 0) { + if (appendDlistFunc != NULL) { appendDlistFunc(globalCtx, limbIndex, &dList2, &rot, actor, &gfx); } if (limbEntry->firstChildIndex != LIMB_DONE) { - gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, mtx, gfx); } Matrix_Pull(); if (limbEntry->nextLimbIndex != LIMB_DONE) { - gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, + gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->nextLimbIndex, skeleton, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, mtx, gfx); } return gfx; } -Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, s32 dListCount, +Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* actorDrawTable, s32 dListCount, SkelAnime_LimbUpdateMatrix2 updateMtxFunc, SkelAnime_LimbAppendDlist2 appendDlistFunc, Actor* actor, Gfx* gfx) { SkelLimbEntry* limbEntry; @@ -717,7 +710,7 @@ Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDra Mtx* mtx; mtx = Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(*mtx)); - if (limbTable == NULL) { + if (skeleton == NULL) { osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf("Si2_draw2_SV():skelがNULLです。NULLを返します。\n"); osSyncPrintf(VT_RST); @@ -726,7 +719,7 @@ Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDra gSPSegment(gfx++, 0xD, mtx); Matrix_Push(); - limbEntry = SEGMENTED_TO_VIRTUAL(*limbTable); + limbEntry = SEGMENTED_TO_VIRTUAL(skeleton->limbs[0]); pos.x = actorDrawTable->x; pos.y = actorDrawTable->y; @@ -754,7 +747,7 @@ Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDra appendDlistFunc(globalCtx, 1, &dList2, &rot, actor, &gfx); } if (limbEntry->firstChildIndex != LIMB_DONE) { - gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, + gfx = SkelAnime_DrawLimbSV2(globalCtx, limbEntry->firstChildIndex, skeleton, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, &mtx, gfx); } @@ -766,22 +759,22 @@ Gfx* SkelAnime_DrawSV2(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDra // Seems to be some kind of rotations update, somewhat large. #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A29BC.s") -s16 func_800A2DBC(u32 animationSeg) { - AnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); +s16 func_800A2DBC(GenericAnimationHeader* animationSeg) { + GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); return animation->unk_02; } -s16 func_800A2DF4(u32 animationSeg) { - AnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); +s16 func_800A2DF4(GenericAnimationHeader* animationSeg) { + GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); return animation->frameCount; } -s16 func_800A2E2C(u32 animationSeg) { - AnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); +s16 func_800A2E2C(GenericAnimationHeader* animationSeg) { + GenericAnimationHeader* animation = SEGMENTED_TO_VIRTUAL(animationSeg); - return (s16)(animation->frameCount - 1); + return animation->frameCount - 1; } // Very large update function @@ -805,7 +798,7 @@ AnimationEntry* SkelAnime_NextEntry(AnimationContext* animationCtx, AnimationTyp AnimationEntry* entry; s16 index = animationCtx->animationCount; - if (index >= 0x32) { + if (index >= ANIMATION_ENTRY_MAX) { return NULL; } animationCtx->animationCount = index + 1; @@ -818,12 +811,13 @@ AnimationEntry* SkelAnime_NextEntry(AnimationContext* animationCtx, AnimationTyp * The next 6 functions are coordinate with the AnimationType enum */ -void func_800A336C(GlobalContext* globalCtx, u32 linkAnimetionSeg, s32 frame, s32 limbCount, void* ram) { +void SkelAnime_LoadLinkAnimetion(GlobalContext* globalCtx, LinkAnimetionEntry* linkAnimetionSeg, s32 frame, s32 limbCount, + void* ram) { AnimationEntry* entry; LinkAnimetionEntry* linkAnimetionEntry; char pad[4]; - entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE0); + entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_LINKANIMETION); if (entry != NULL) { linkAnimetionEntry = SEGMENTED_TO_VIRTUAL(linkAnimetionSeg); @@ -835,7 +829,7 @@ void func_800A336C(GlobalContext* globalCtx, u32 linkAnimetionSeg, s32 frame, s3 } } -void func_800A3478(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src) { +void SkelAnime_LoadAnimationType1(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src) { AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE1); if (entry != NULL) { entry->types.type1.unk_00 = D_801600B0; @@ -845,18 +839,18 @@ void func_800A3478(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* sr } } -void func_800A34DC(GlobalContext* globalCtx, s32 arg1, Vec3s* arg2, Vec3s* arg3, f32 arg4) { +void SkelAnime_LoadAnimationType2(GlobalContext* globalCtx, s32 limbCount, Vec3s* arg2, Vec3s* arg3, f32 arg4) { AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE2); if (entry != NULL) { entry->types.type2.unk_00 = D_801600B0; - entry->types.type2.unk_01 = arg1; + entry->types.type2.limbCount = limbCount; entry->types.type2.unk_04 = arg2; entry->types.type2.unk_08 = arg3; entry->types.type2.unk_0C = arg4; } } -void func_800A3548(GlobalContext* globalCtx, s32 vecCount, s32 dst, s32 src, s32 index) { +void SkelAnime_LoadAnimationType3(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* index) { AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE3); if (entry != NULL) { entry->types.type3.unk_00 = D_801600B0; @@ -867,7 +861,7 @@ void func_800A3548(GlobalContext* globalCtx, s32 vecCount, s32 dst, s32 src, s32 } } -void func_800A35B4(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* 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) { entry->types.type4.unk_00 = D_801600B0; @@ -878,7 +872,7 @@ void func_800A35B4(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* sr } } -void func_800A3620(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 arg3) { +void SkelAnime_LoadAnimationType5(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 arg3) { AnimationEntry* entry = SkelAnime_NextEntry(&globalCtx->animationCtx, ANIMATION_TYPE5); if (entry != NULL) { entry->types.type5.actor = actor; @@ -889,11 +883,11 @@ void func_800A3620(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, /* The next functions are callbacks to loading animations */ -void func_800A3678(GlobalContext* globalCtx, AnimationEntryType0* entry) { +void SkelAnime_LinkAnimetionLoaded(GlobalContext* globalCtx, AnimationEntryType0* entry) { osRecvMesg(&entry->msgQueue, NULL, OS_MESG_BLOCK); } -void func_800A36A4(GlobalContext* globalCtx, AnimationEntryType1* entry) { +void SkelAnime_AnimationType1Loaded(GlobalContext* globalCtx, AnimationEntryType1* entry) { s32 i; Vec3s* dst; Vec3s* src; @@ -908,13 +902,13 @@ void func_800A36A4(GlobalContext* globalCtx, AnimationEntryType1* entry) { } } -void func_800A3714(GlobalContext* globalCtx, AnimationEntryType2* entry) { +void SkelAnime_AnimationType2Loaded(GlobalContext* globalCtx, AnimationEntryType2* entry) { if ((entry->unk_00 & D_8012A480) == 0) { - func_800A2E70(entry->unk_01, entry->unk_04, entry->unk_04, entry->unk_08, entry->unk_0C); + func_800A2E70(entry->limbCount, entry->unk_04, entry->unk_04, entry->unk_08, entry->unk_0C); } } -void func_800A3770(GlobalContext* globalCtx, AnimationEntryType3* entry) { +void SkelAnime_AnimationType3Loaded(GlobalContext* globalCtx, AnimationEntryType3* entry) { s32 i; Vec3s* dst; Vec3s* src; @@ -930,7 +924,7 @@ void func_800A3770(GlobalContext* globalCtx, AnimationEntryType3* entry) { } } -void func_800A37F0(GlobalContext* globalCtx, AnimationEntryType4* entry) { +void SkelAnime_AnimationType4Loaded(GlobalContext* globalCtx, AnimationEntryType4* entry) { s32 i; Vec3s* dst; Vec3s* src; @@ -946,7 +940,7 @@ void func_800A37F0(GlobalContext* globalCtx, AnimationEntryType4* entry) { } } -void func_800A3874(GlobalContext* globalCtx, AnimationEntryType5* entry) { +void SkelAnime_AnimationType5Loaded(GlobalContext* globalCtx, AnimationEntryType5* entry) { char pad[4]; Actor* actor = entry->actor; Vec3f pos; @@ -968,16 +962,16 @@ void func_800A390C(GlobalContext* globalCtx, AnimationContext* animationCtx) { D_8012A480 = 0; } -void func_800A39AC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, u32* animation, s32 flags, - Vec3s* actorDrawTbl, Vec3s* arg6, s32 limbBufCount) { +void SkelAnime_InitLinkAnimetion(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, + LinkAnimetionEntry* linkAnimetionEntrySeg, s32 flags, Vec3s* actorDrawTbl, Vec3s* arg6, s32 limbBufCount) { char pad[8]; - SkelAnimeLimbHeader* limbHeader; + SkeletonHeader* skeletonHeader; size_t allocSize; s32 limbCount; s32 headerCount; - limbHeader = SEGMENTED_TO_VIRTUAL(limbHeaderSeg); - headerCount = limbHeader->limbCount; + skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg); + headerCount = skeletonHeader->limbCount; skelAnime->unk_34 = flags; limbCount = (flags & 2) ? headerCount : 1; @@ -988,11 +982,11 @@ void func_800A39AC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeade limbCount += headerCount; } - skelAnime->limbCount = (u8)limbCount; - skelAnime->dListCount = limbHeader->dListCount; + skelAnime->limbCount = limbCount; + skelAnime->dListCount = skeletonHeader->dListCount; allocSize = limbCount * sizeof(Vec3s); - skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg); + skelAnime->skeleton = SEGMENTED_TO_VIRTUAL(skeletonHeader->skeletonSeg); if (flags & 8) { allocSize += 2; @@ -1017,7 +1011,7 @@ void func_800A39AC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeade osSyncPrintf(VT_RST); } - func_800A3F08(globalCtx, skelAnime, animation, 1.0f, 0.0f, 0.0f, 0, 0.0f); + SkelAnime_LinkChangeAnimation(globalCtx, skelAnime, linkAnimetionEntrySeg, 1.0f, 0.0f, 0.0f, 0, 0.0f); } void func_800A3B8C(SkelAnime* skelAnime) { @@ -1043,7 +1037,7 @@ s32 func_800A3BE4(GlobalContext* globalCtx, SkelAnime* skelAnime) { func_800A3B8C(skelAnime); } - func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, + SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, 1.0f - (skelAnime->unk_28 / prevUnk28)); return 0; } @@ -1051,7 +1045,7 @@ s32 func_800A3BE4(GlobalContext* globalCtx, SkelAnime* skelAnime) { void func_800A3C9C(GlobalContext* globalCtx, SkelAnime* skelAnime) { f32 updateRate; - func_800A336C(globalCtx, skelAnime->animCurrent, skelAnime->animCurrentFrame, skelAnime->limbCount, + SkelAnime_LoadLinkAnimetion(globalCtx, skelAnime->linkAnimetionSeg, skelAnime->animCurrentFrame, skelAnime->limbCount, skelAnime->actorDrawTbl); if (skelAnime->unk_28 != 0) { updateRate = R_UPDATE_RATE * 0.5f; @@ -1060,7 +1054,7 @@ void func_800A3C9C(GlobalContext* globalCtx, SkelAnime* skelAnime) { skelAnime->unk_28 = 0.0f; return; } - func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, skelAnime->unk_28); + SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, skelAnime->unk_28); } } @@ -1104,97 +1098,97 @@ void func_800A3EE8(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 arg2) { } #ifdef NON_MATCHING -void func_800A3F08(GlobalContext* globalCtx, SkelAnime* skelAnime, u32* animation, f32 playbackSpeed, f32 arg4, - f32 frameCount, u8 arg6, f32 arg7) { +void SkelAnime_LinkChangeAnimation(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, f32 playbackSpeed, + f32 frame, f32 frameCount, u8 arg6, f32 arg7) { skelAnime->unk_01 = arg6; - if ((arg7 != 0.0f) && ((animation == skelAnime->animCurrent) || (arg4 != skelAnime->animCurrentFrame))) { + if ((arg7 != 0.0f) && ((linkAnimetionEntrySeg == skelAnime->linkAnimetionSeg) || (frame != skelAnime->animCurrentFrame))) { if (arg7 < 0.0f) { func_800A3B8C(skelAnime); SkelAnime_CopyVec3s(skelAnime, skelAnime->unk_24, skelAnime->actorDrawTbl); arg7 = -arg7; } else { skelAnime->animUpdate = &func_800A3BE4; - func_800A336C(globalCtx, animation, (s32)arg4, skelAnime->limbCount, skelAnime->unk_24); + SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount, skelAnime->unk_24); } skelAnime->unk_28 = 1.0f; skelAnime->unk_2C = 1.0f / arg7; } else { func_800A3B8C(skelAnime); - func_800A336C(globalCtx, animation, (s32)arg4, skelAnime->limbCount, skelAnime->actorDrawTbl); + SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount, skelAnime->actorDrawTbl); skelAnime->unk_28 = 0.0f; } skelAnime->animCurrentFrame = 0.0f; - skelAnime->unk_0C = arg4; - skelAnime->animCurrentFrame = arg4; + skelAnime->unk_0C = frame; + skelAnime->animCurrentFrame = frame; skelAnime->animFrameCount = frameCount; - skelAnime->unk_14 = func_800A1FC8(animation); + skelAnime->unk_14 = func_800A1FC8(&linkAnimetionEntrySeg->genericHeader); skelAnime->animPlaybackSpeed = playbackSpeed; } #else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3F08.s") +#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_LinkChangeAnimation.s") #endif -void func_800A407C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation) { - func_800A3F08(globalCtx, skelAnime, animation, 1.0f, 0.0f, SkelAnime_GetFrameCount(animation), 2, 0.0f); +void func_800A407C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg) { + SkelAnime_LinkChangeAnimation(globalCtx, skelAnime, linkAnimetionEntrySeg, 1.0f, 0.0f, SkelAnime_GetFrameCount(&linkAnimetionEntrySeg->genericHeader), 2, 0.0f); } -void func_800A40DC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) { - func_800A3F08(globalCtx, skelAnime, animation, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(animation), 2, +void func_800A40DC(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, f32 playbackSpeed) { + SkelAnime_LinkChangeAnimation(globalCtx, skelAnime, linkAnimetionEntrySeg, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(&linkAnimetionEntrySeg->genericHeader), 2, 0.0f); } -void func_800A4140(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation) { - func_800A3F08(globalCtx, skelAnime, animation, 1.0f, 0.0f, SkelAnime_GetFrameCount(animation), 0, 0.0f); +void func_800A4140(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg) { + SkelAnime_LinkChangeAnimation(globalCtx, skelAnime, linkAnimetionEntrySeg, 1.0f, 0.0f, SkelAnime_GetFrameCount(&linkAnimetionEntrySeg->genericHeader), 0, 0.0f); } -void func_800A419C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) { - func_800A3F08(globalCtx, skelAnime, animation, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(animation), 0, +void func_800A419C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, f32 playbackSpeed) { + SkelAnime_LinkChangeAnimation(globalCtx, skelAnime, linkAnimetionEntrySeg, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(&linkAnimetionEntrySeg->genericHeader), 0, 0.0f); } void func_800A41FC(GlobalContext* globalCtx, SkelAnime* skelAnime) { - func_800A3478(globalCtx, skelAnime->limbCount, skelAnime->unk_24, skelAnime->actorDrawTbl); + SkelAnime_LoadAnimationType1(globalCtx, skelAnime->limbCount, skelAnime->unk_24, skelAnime->actorDrawTbl); } void func_800A422C(GlobalContext* globalCtx, SkelAnime* skelAnime) { - func_800A3478(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24); + SkelAnime_LoadAnimationType1(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24); } -void func_800A425C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 frame) { - func_800A336C(globalCtx, animation, (s32)frame, skelAnime->limbCount, skelAnime->unk_24); +void func_800A425C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, f32 frame) { + SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount, skelAnime->unk_24); } -void func_800A42A0(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 frame) { - func_800A336C(globalCtx, animation, (s32)frame, skelAnime->limbCount, skelAnime->actorDrawTbl); +void func_800A42A0(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, f32 frame) { + SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount, skelAnime->actorDrawTbl); } void func_800A42E4(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 arg2) { - func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, arg2); + SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, arg2); } -void func_800A431C(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animationSeg, f32 frame, s32 arg4, f32 arg5, - f32 arg6, s32 arg7) { - s32 alignedAddr; - func_800A336C(globalCtx, animationSeg, (s32)frame, skelAnime->limbCount, skelAnime->actorDrawTbl); +void func_800A431C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, f32 frame, LinkAnimetionEntry* linkAnimetionEntrySeg2, + f32 arg5, f32 arg6, Vec3s* arg7) { + Vec3s* alignedArg7; + SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount, skelAnime->actorDrawTbl); - alignedAddr = ALIGN16(arg7); + alignedArg7 = (Vec3s*)ALIGN16((u32)arg7); - func_800A336C(globalCtx, arg4, (s32)arg5, skelAnime->limbCount, alignedAddr); - func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, alignedAddr, arg6); + SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg2, (s32)arg5, skelAnime->limbCount, alignedArg7); + SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, alignedArg7, arg6); } -void func_800A43B8(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 animation, f32 frame, s32 arg4, f32 arg5, - f32 arg6, s32 arg7) { - s32 alignedAddr; +void func_800A43B8(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, f32 frame, LinkAnimetionEntry* linkAnimetionEntrySeg2, + f32 arg5, f32 arg6, Vec3s* arg7) { + Vec3s* alignedArg7; - func_800A336C(globalCtx, animation, (s32)frame, skelAnime->limbCount, skelAnime->unk_24); + SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount, skelAnime->unk_24); - alignedAddr = ALIGN16(arg7); + alignedArg7 = (Vec3s*)ALIGN16((u32)arg7); - func_800A336C(globalCtx, arg4, (s32)arg5, skelAnime->limbCount, alignedAddr); - func_800A34DC(globalCtx, skelAnime->limbCount, skelAnime->unk_24, alignedAddr, arg6); + SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg2, (s32)arg5, skelAnime->limbCount, alignedArg7); + SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->unk_24, alignedArg7, arg6); } void func_800A4454(SkelAnime* skelAnime) { @@ -1236,13 +1230,13 @@ s32 func_800A4530(SkelAnime* skelAnime, f32 arg1) { return func_800A4478(skelAnime, arg1, updateRate); } -void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, u32 animation, - Vec3s* actorDrawTable, s32 arg5, s32 limbCount) { - SkelAnimeLimbHeader* limbHeader; +void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, + AnimationHeader* animationSeg, Vec3s* actorDrawTable, Vec3s* arg5, s32 limbCount) { + SkeletonHeader* skeletonHeader; - limbHeader = SEGMENTED_TO_VIRTUAL(limbHeaderSeg); - skelAnime->limbCount = limbHeader->limbCount + 1; - skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg); + 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); @@ -1261,19 +1255,19 @@ void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHead osSyncPrintf(VT_RST); } - if (animation != 0) { - SkelAnime_ChangeAnimationDefault(skelAnime, animation); + if (animationSeg != NULL) { + SkelAnime_ChangeAnimationDefault(skelAnime, animationSeg); } } -void SkelAnime_InitSV(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, u32 animation, - Vec3s* actorDrawTable, s32 arg5, s32 limbCount) { - SkelAnimeLimbHeader* limbHeader; +void SkelAnime_InitSV(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, + AnimationHeader* animationSeg, Vec3s* actorDrawTable, Vec3s* arg5, s32 limbCount) { + SkeletonHeader* skeletonHeader; - limbHeader = SEGMENTED_TO_VIRTUAL(limbHeaderSeg); - skelAnime->limbCount = limbHeader->limbCount + 1; - skelAnime->dListCount = limbHeader->dListCount; - skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg); + skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg); + skelAnime->limbCount = skeletonHeader->limbCount + 1; + skelAnime->dListCount = skeletonHeader->dListCount; + skelAnime->skeleton = SEGMENTED_TO_VIRTUAL(skeletonHeader->skeletonSeg); if (actorDrawTable == NULL) { skelAnime->actorDrawTbl = @@ -1295,17 +1289,18 @@ void SkelAnime_InitSV(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHe osSyncPrintf(VT_RST); } - if (animation != 0) { - SkelAnime_ChangeAnimationDefault(skelAnime, animation); + if (animationSeg != NULL) { + SkelAnime_ChangeAnimationDefault(skelAnime, animationSeg); } } -void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, u32 animation) { - SkelAnimeLimbHeader* limbHeader; +void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, + AnimationHeader* animationSeg) { + SkeletonHeader* skeletonHeader; - limbHeader = SEGMENTED_TO_VIRTUAL(limbHeaderSeg); - skelAnime->limbCount = limbHeader->limbCount + 1; - skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg); + 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); skelAnime->unk_24 = @@ -1317,8 +1312,8 @@ void SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limb osSyncPrintf(VT_RST); } - if (animation != 0) { - SkelAnime_ChangeAnimationDefault(skelAnime, animation); + if (animationSeg != NULL) { + SkelAnime_ChangeAnimationDefault(skelAnime, animationSeg); } } @@ -1390,6 +1385,7 @@ s32 func_800A4AD8(SkelAnime* skelAnime) { #endif #ifdef NON_MATCHING +// regalloc void func_800A4C58(SkelAnime* skelAnime) { char pad[6]; f32 temp_f0; @@ -1398,9 +1394,9 @@ void func_800A4C58(SkelAnime* skelAnime) { s32 temp_f8; f32 temp_f2; - SkelAnime_AnimateFrame(skelAnime->animCurrent, (s32)skelAnime->animCurrentFrame, skelAnime->limbCount, + SkelAnime_AnimateFrame(skelAnime->animCurrentSeg, skelAnime->animCurrentFrame, skelAnime->limbCount, skelAnime->actorDrawTbl); - if ((skelAnime->unk_01 & 1) != 0) { + if (skelAnime->unk_01) { temp_f8 = (s32)skelAnime->animCurrentFrame; temp_f10 = temp_f8; temp_f8++; @@ -1408,7 +1404,7 @@ void func_800A4C58(SkelAnime* skelAnime) { if (temp_f8 >= (s32)skelAnime->unk_14) { temp_f8 = 0; } - SkelAnime_AnimateFrame(skelAnime->animCurrent, temp_f8, skelAnime->limbCount, sp38); + SkelAnime_AnimateFrame(skelAnime->animCurrentSeg, temp_f8, skelAnime->limbCount, sp38); func_800A2E70(skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->actorDrawTbl, sp38, temp_f2); } if (skelAnime->unk_28 != 0) { @@ -1426,9 +1422,9 @@ void func_800A4C58(SkelAnime* skelAnime) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4C58.s") #endif -#ifdef NON_MATCHING s32 func_800A4D9C(SkelAnime* skelAnime) { - skelAnime->animCurrentFrame += (R_UPDATE_RATE * 0.33333334f) + skelAnime->animPlaybackSpeed; + f32 updateRate = R_UPDATE_RATE * 0.33333334f; + skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate; if (skelAnime->animCurrentFrame < 0.0f) { skelAnime->animCurrentFrame += skelAnime->unk_14; } else if (skelAnime->unk_14 <= skelAnime->animCurrentFrame) { @@ -1437,26 +1433,19 @@ s32 func_800A4D9C(SkelAnime* skelAnime) { func_800A4C58(skelAnime); return 0; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4D9C.s") -#endif -#ifdef NON_MATCHING s32 func_800A4E38(SkelAnime* skelAnime) { - skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * (R_UPDATE_RATE * 0.33333334f); + f32 updateRate = R_UPDATE_RATE * 0.33333334f; + skelAnime->animCurrentFrame += skelAnime->animPlaybackSpeed * updateRate; if (skelAnime->animCurrentFrame < skelAnime->unk_0C) { skelAnime->animCurrentFrame = (skelAnime->animCurrentFrame - skelAnime->unk_0C) + skelAnime->animFrameCount; - } else { - if (skelAnime->animFrameCount <= skelAnime->animCurrentFrame) { - skelAnime->animCurrentFrame = (skelAnime->animCurrentFrame - skelAnime->animFrameCount) + skelAnime->unk_0C; - } + } else if (skelAnime->animFrameCount <= skelAnime->animCurrentFrame) { + skelAnime->animCurrentFrame = (skelAnime->animCurrentFrame - skelAnime->animFrameCount) + skelAnime->unk_0C; } + func_800A4C58(skelAnime); return 0; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A4E38.s") -#endif s32 func_800A4EE0(SkelAnime* skelAnime) { f32 temp_f14; @@ -1464,7 +1453,7 @@ s32 func_800A4EE0(SkelAnime* skelAnime) { temp_f14 = R_UPDATE_RATE * 0.33333334f; if (skelAnime->animCurrentFrame == skelAnime->animFrameCount) { - SkelAnime_AnimateFrame(skelAnime->animCurrent, (s32)skelAnime->animCurrentFrame, skelAnime->limbCount, + SkelAnime_AnimateFrame(skelAnime->animCurrentSeg, (s32)skelAnime->animCurrentFrame, skelAnime->limbCount, skelAnime->actorDrawTbl); func_800A4C58(skelAnime); return 1; @@ -1485,79 +1474,76 @@ s32 func_800A4EE0(SkelAnime* skelAnime) { return 0; } -#ifdef NON_MATCHING -void SkelAnime_ChangeAnimationImpl(SkelAnime* skelAnime, u32* animation, f32 playbackSpeed, f32 unk0, f32 frameCount, - u8 unk1, f32 transitionRate, s8 unk2) { +void SkelAnime_ChangeAnimationImpl(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed, f32 frame, + f32 frameCount, u8 unk1, f32 transitionRate, s8 unk2) { skelAnime->unk_01 = unk1; - if ((transitionRate != 0.0f) && ((animation != skelAnime->animCurrent) || (unk0 != skelAnime->animCurrentFrame))) { - if (transitionRate < 0.0f) { + if ((transitionRate != 0.0f) && + ((animationSeg != skelAnime->animCurrentSeg) || (frame != skelAnime->animCurrentFrame))) { + if (transitionRate < 0) { func_800A49B0(skelAnime); SkelAnime_CopyVec3s(skelAnime, skelAnime->unk_24, skelAnime->actorDrawTbl); transitionRate = -transitionRate; } else { if (unk2 != 0) { - skelAnime->animUpdate = (void*)&func_800A4AD8; + skelAnime->animUpdate = &func_800A4AD8; skelAnime->unk_03 = unk2; } else { - skelAnime->animUpdate = (void*)&func_800A4A20; + skelAnime->animUpdate = &func_800A4A20; } - SkelAnime_AnimateFrame(animation, (s32)unk0, skelAnime->limbCount, skelAnime->actorDrawTbl); + SkelAnime_AnimateFrame(animationSeg, frame, skelAnime->limbCount, skelAnime->unk_24); } skelAnime->unk_28 = 1.0f; skelAnime->unk_2C = 1.0f / transitionRate; } else { func_800A49B0(skelAnime); - SkelAnime_AnimateFrame(animation, (s32)unk0, skelAnime->limbCount, skelAnime->actorDrawTbl); + SkelAnime_AnimateFrame(animationSeg, frame, skelAnime->limbCount, skelAnime->actorDrawTbl); skelAnime->unk_28 = 0.0f; } - skelAnime->animCurrent = animation; - skelAnime->unk_0C = unk0; + skelAnime->animCurrentSeg = animationSeg; + skelAnime->unk_0C = frame; skelAnime->animFrameCount = frameCount; - skelAnime->unk_14 = func_800A1FC8(animation); + skelAnime->unk_14 = func_800A1FC8(&animationSeg->genericHeader); if (skelAnime->unk_01 >= 4) { skelAnime->animCurrentFrame = 0.0f; } else { - skelAnime->animCurrentFrame = unk0; + skelAnime->animCurrentFrame = frame; if (skelAnime->unk_01 < 2) { skelAnime->animFrameCount = skelAnime->unk_14 - 1.0f; } } skelAnime->animPlaybackSpeed = playbackSpeed; } -#else -#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/SkelAnime_ChangeAnimationImpl.s") -#endif -void SkelAnime_ChangeAnimation(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed, f32 unk0, f32 frameCount, - u8 unk1, f32 transitionRate) { - SkelAnime_ChangeAnimationImpl(skelAnime, animation, playbackSpeed, unk0, frameCount, unk1, transitionRate, 0); +void SkelAnime_ChangeAnimation(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed, f32 frame, + f32 frameCount, u8 unk1, f32 transitionRate) { + SkelAnime_ChangeAnimationImpl(skelAnime, animationSeg, playbackSpeed, frame, frameCount, unk1, transitionRate, 0); } -void func_800A51E8(SkelAnime* skelAnime, u32 animation) { - SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, SkelAnime_GetFrameCount(animation), 2, 0.0f); +void func_800A51E8(SkelAnime* skelAnime, AnimationHeader* animationSeg) { + SkelAnime_ChangeAnimation(skelAnime, animationSeg, 1.0f, 0.0f, SkelAnime_GetFrameCount(&animationSeg->genericHeader), 2, 0.0f); } -void func_800A5240(SkelAnime* skelAnime, u32 animation, f32 transitionRate) { - SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0, SkelAnime_GetFrameCount(animation), 2, +void func_800A5240(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate) { + SkelAnime_ChangeAnimation(skelAnime, animationSeg, 1.0f, 0, SkelAnime_GetFrameCount(&animationSeg->genericHeader), 2, transitionRate); } -void func_800A529C(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) { - SkelAnime_ChangeAnimation(skelAnime, animation, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(animation), 2, +void func_800A529C(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed) { + SkelAnime_ChangeAnimation(skelAnime, animationSeg, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(&animationSeg->genericHeader), 2, 0.0f); } -void SkelAnime_ChangeAnimationDefault(SkelAnime* skelAnime, u32 animation) { - SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, SkelAnime_GetFrameCount(animation), 0, 0.0f); +void SkelAnime_ChangeAnimationDefault(SkelAnime* skelAnime, AnimationHeader* animationSeg) { + SkelAnime_ChangeAnimation(skelAnime, animationSeg, 1.0f, 0.0f, SkelAnime_GetFrameCount(&animationSeg->genericHeader), 0, 0.0f); } -void SkelAnime_ChangeAnimationTransitionRate(SkelAnime* skelAnime, u32 animation, f32 transitionRate) { - SkelAnime_ChangeAnimation(skelAnime, animation, 1.0f, 0.0f, 0.0f, 0, transitionRate); +void SkelAnime_ChangeAnimationTransitionRate(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate) { + SkelAnime_ChangeAnimation(skelAnime, animationSeg, 1.0f, 0.0f, 0.0f, 0, transitionRate); } -void SkelAnime_ChangeAnimationPlaybackSpeed(SkelAnime* skelAnime, u32 animation, f32 playbackSpeed) { - SkelAnime_ChangeAnimation(skelAnime, animation, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(animation), 0, +void SkelAnime_ChangeAnimationPlaybackSpeed(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed) { + SkelAnime_ChangeAnimation(skelAnime, animationSeg, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(&animationSeg->genericHeader), 0, 0.0f); } @@ -1570,12 +1556,10 @@ void func_800A53DC(SkelAnime* skelAnime) { #ifdef NON_MATCHING // regalloc void func_800A5408(SkelAnime* skelAnime) { - f32 animPlaybackSpeed = skelAnime->animPlaybackSpeed; - f32 unk_C = skelAnime->unk_0C; f32 frameCount = skelAnime->animFrameCount; - skelAnime->animFrameCount = unk_C; - skelAnime->animPlaybackSpeed = -animPlaybackSpeed; + skelAnime->animFrameCount = skelAnime->unk_0C; + skelAnime->animPlaybackSpeed = -skelAnime->animPlaybackSpeed; skelAnime->unk_0C = frameCount; } #else @@ -1630,7 +1614,7 @@ void func_800A54FC(SkelAnime* skelAnime, Vec3f* pos, s16 angle) { skelAnime->unk_3C = skelAnime->actorDrawTbl->z; skelAnime->actorDrawTbl->z = skelAnime->unk_42; if (skelAnime->unk_35 & 2) { - if ((skelAnime->unk_35 & 0x10) != 0) { + if (skelAnime->unk_35 & 0x10) { pos->y = 0.0f; } else { pos->y = skelAnime->actorDrawTbl->y - skelAnime->unk_3A; -- cgit v1.2.3 From 095924d05ab7f791227603e1137f6d8d19078bed Mon Sep 17 00:00:00 2001 From: KrimtonZ Date: Wed, 25 Mar 2020 11:07:09 -0500 Subject: clang formatting --- src/code/z_skelanime.c | 93 +++++++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 39 deletions(-) (limited to 'src/code') diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index e625a3784..bf0a19567 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -19,9 +19,8 @@ void SkelAnime_AnimationType5Loaded(GlobalContext* globalCtx, AnimationEntryType //.data u32 D_8012A480 = 0; static AnimationEntryCallback D_8012A484[] = { - &SkelAnime_LinkAnimetionLoaded, &SkelAnime_AnimationType1Loaded, - &SkelAnime_AnimationType2Loaded, &SkelAnime_AnimationType3Loaded, - &SkelAnime_AnimationType4Loaded, &SkelAnime_AnimationType5Loaded, + &SkelAnime_LinkAnimetionLoaded, &SkelAnime_AnimationType1Loaded, &SkelAnime_AnimationType2Loaded, + &SkelAnime_AnimationType3Loaded, &SkelAnime_AnimationType4Loaded, &SkelAnime_AnimationType5Loaded, }; //.bss @@ -811,8 +810,8 @@ AnimationEntry* SkelAnime_NextEntry(AnimationContext* animationCtx, AnimationTyp * The next 6 functions are coordinate with the AnimationType enum */ -void SkelAnime_LoadLinkAnimetion(GlobalContext* globalCtx, LinkAnimetionEntry* linkAnimetionSeg, s32 frame, s32 limbCount, - void* ram) { +void SkelAnime_LoadLinkAnimetion(GlobalContext* globalCtx, LinkAnimetionEntry* linkAnimetionSeg, s32 frame, + s32 limbCount, void* ram) { AnimationEntry* entry; LinkAnimetionEntry* linkAnimetionEntry; char pad[4]; @@ -963,7 +962,8 @@ void func_800A390C(GlobalContext* globalCtx, AnimationContext* animationCtx) { } void SkelAnime_InitLinkAnimetion(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, - LinkAnimetionEntry* linkAnimetionEntrySeg, s32 flags, Vec3s* actorDrawTbl, Vec3s* arg6, s32 limbBufCount) { + LinkAnimetionEntry* linkAnimetionEntrySeg, s32 flags, Vec3s* actorDrawTbl, Vec3s* arg6, + s32 limbBufCount) { char pad[8]; SkeletonHeader* skeletonHeader; size_t allocSize; @@ -1038,15 +1038,15 @@ s32 func_800A3BE4(GlobalContext* globalCtx, SkelAnime* skelAnime) { } SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, - 1.0f - (skelAnime->unk_28 / prevUnk28)); + 1.0f - (skelAnime->unk_28 / prevUnk28)); return 0; } void func_800A3C9C(GlobalContext* globalCtx, SkelAnime* skelAnime) { f32 updateRate; - SkelAnime_LoadLinkAnimetion(globalCtx, skelAnime->linkAnimetionSeg, skelAnime->animCurrentFrame, skelAnime->limbCount, - skelAnime->actorDrawTbl); + SkelAnime_LoadLinkAnimetion(globalCtx, skelAnime->linkAnimetionSeg, skelAnime->animCurrentFrame, + skelAnime->limbCount, skelAnime->actorDrawTbl); if (skelAnime->unk_28 != 0) { updateRate = R_UPDATE_RATE * 0.5f; skelAnime->unk_28 -= skelAnime->unk_2C * updateRate; @@ -1054,7 +1054,8 @@ void func_800A3C9C(GlobalContext* globalCtx, SkelAnime* skelAnime) { skelAnime->unk_28 = 0.0f; return; } - SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, skelAnime->unk_28); + SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, + skelAnime->unk_28); } } @@ -1098,24 +1099,28 @@ void func_800A3EE8(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 arg2) { } #ifdef NON_MATCHING -void SkelAnime_LinkChangeAnimation(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, f32 playbackSpeed, - f32 frame, f32 frameCount, u8 arg6, f32 arg7) { +void SkelAnime_LinkChangeAnimation(GlobalContext* globalCtx, SkelAnime* skelAnime, + LinkAnimetionEntry* linkAnimetionEntrySeg, f32 playbackSpeed, f32 frame, + f32 frameCount, u8 arg6, f32 arg7) { skelAnime->unk_01 = arg6; - if ((arg7 != 0.0f) && ((linkAnimetionEntrySeg == skelAnime->linkAnimetionSeg) || (frame != skelAnime->animCurrentFrame))) { + if ((arg7 != 0.0f) && + ((linkAnimetionEntrySeg == skelAnime->linkAnimetionSeg) || (frame != skelAnime->animCurrentFrame))) { if (arg7 < 0.0f) { func_800A3B8C(skelAnime); SkelAnime_CopyVec3s(skelAnime, skelAnime->unk_24, skelAnime->actorDrawTbl); arg7 = -arg7; } else { skelAnime->animUpdate = &func_800A3BE4; - SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount, skelAnime->unk_24); + SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount, + skelAnime->unk_24); } skelAnime->unk_28 = 1.0f; skelAnime->unk_2C = 1.0f / arg7; } else { func_800A3B8C(skelAnime); - SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount, skelAnime->actorDrawTbl); + SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount, + skelAnime->actorDrawTbl); skelAnime->unk_28 = 0.0f; } @@ -1131,21 +1136,25 @@ void SkelAnime_LinkChangeAnimation(GlobalContext* globalCtx, SkelAnime* skelAnim #endif void func_800A407C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg) { - SkelAnime_LinkChangeAnimation(globalCtx, skelAnime, linkAnimetionEntrySeg, 1.0f, 0.0f, SkelAnime_GetFrameCount(&linkAnimetionEntrySeg->genericHeader), 2, 0.0f); + SkelAnime_LinkChangeAnimation(globalCtx, skelAnime, linkAnimetionEntrySeg, 1.0f, 0.0f, + SkelAnime_GetFrameCount(&linkAnimetionEntrySeg->genericHeader), 2, 0.0f); } -void func_800A40DC(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, f32 playbackSpeed) { - SkelAnime_LinkChangeAnimation(globalCtx, skelAnime, linkAnimetionEntrySeg, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(&linkAnimetionEntrySeg->genericHeader), 2, - 0.0f); +void func_800A40DC(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, + f32 playbackSpeed) { + SkelAnime_LinkChangeAnimation(globalCtx, skelAnime, linkAnimetionEntrySeg, playbackSpeed, 0.0f, + SkelAnime_GetFrameCount(&linkAnimetionEntrySeg->genericHeader), 2, 0.0f); } void func_800A4140(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg) { - SkelAnime_LinkChangeAnimation(globalCtx, skelAnime, linkAnimetionEntrySeg, 1.0f, 0.0f, SkelAnime_GetFrameCount(&linkAnimetionEntrySeg->genericHeader), 0, 0.0f); + SkelAnime_LinkChangeAnimation(globalCtx, skelAnime, linkAnimetionEntrySeg, 1.0f, 0.0f, + SkelAnime_GetFrameCount(&linkAnimetionEntrySeg->genericHeader), 0, 0.0f); } -void func_800A419C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, f32 playbackSpeed) { - SkelAnime_LinkChangeAnimation(globalCtx, skelAnime, linkAnimetionEntrySeg, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(&linkAnimetionEntrySeg->genericHeader), 0, - 0.0f); +void func_800A419C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, + f32 playbackSpeed) { + SkelAnime_LinkChangeAnimation(globalCtx, skelAnime, linkAnimetionEntrySeg, playbackSpeed, 0.0f, + SkelAnime_GetFrameCount(&linkAnimetionEntrySeg->genericHeader), 0, 0.0f); } void func_800A41FC(GlobalContext* globalCtx, SkelAnime* skelAnime) { @@ -1156,22 +1165,26 @@ void func_800A422C(GlobalContext* globalCtx, SkelAnime* skelAnime) { SkelAnime_LoadAnimationType1(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24); } -void func_800A425C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, f32 frame) { +void func_800A425C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, + f32 frame) { SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount, skelAnime->unk_24); } -void func_800A42A0(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, f32 frame) { - SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount, skelAnime->actorDrawTbl); +void func_800A42A0(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, + f32 frame) { + SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount, + skelAnime->actorDrawTbl); } void func_800A42E4(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 arg2) { SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, skelAnime->unk_24, arg2); } -void func_800A431C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, f32 frame, LinkAnimetionEntry* linkAnimetionEntrySeg2, - f32 arg5, f32 arg6, Vec3s* arg7) { +void func_800A431C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, f32 frame, + LinkAnimetionEntry* linkAnimetionEntrySeg2, f32 arg5, f32 arg6, Vec3s* arg7) { Vec3s* alignedArg7; - SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount, skelAnime->actorDrawTbl); + SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount, + skelAnime->actorDrawTbl); alignedArg7 = (Vec3s*)ALIGN16((u32)arg7); @@ -1179,8 +1192,8 @@ void func_800A431C(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetion SkelAnime_LoadAnimationType2(globalCtx, skelAnime->limbCount, skelAnime->actorDrawTbl, alignedArg7, arg6); } -void func_800A43B8(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, f32 frame, LinkAnimetionEntry* linkAnimetionEntrySeg2, - f32 arg5, f32 arg6, Vec3s* arg7) { +void func_800A43B8(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimetionEntry* linkAnimetionEntrySeg, f32 frame, + LinkAnimetionEntry* linkAnimetionEntrySeg2, f32 arg5, f32 arg6, Vec3s* arg7) { Vec3s* alignedArg7; SkelAnime_LoadLinkAnimetion(globalCtx, linkAnimetionEntrySeg, (s32)frame, skelAnime->limbCount, skelAnime->unk_24); @@ -1521,21 +1534,23 @@ void SkelAnime_ChangeAnimation(SkelAnime* skelAnime, AnimationHeader* animationS } void func_800A51E8(SkelAnime* skelAnime, AnimationHeader* animationSeg) { - SkelAnime_ChangeAnimation(skelAnime, animationSeg, 1.0f, 0.0f, SkelAnime_GetFrameCount(&animationSeg->genericHeader), 2, 0.0f); + SkelAnime_ChangeAnimation(skelAnime, animationSeg, 1.0f, 0.0f, + SkelAnime_GetFrameCount(&animationSeg->genericHeader), 2, 0.0f); } void func_800A5240(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate) { - SkelAnime_ChangeAnimation(skelAnime, animationSeg, 1.0f, 0, SkelAnime_GetFrameCount(&animationSeg->genericHeader), 2, - transitionRate); + SkelAnime_ChangeAnimation(skelAnime, animationSeg, 1.0f, 0, SkelAnime_GetFrameCount(&animationSeg->genericHeader), + 2, transitionRate); } void func_800A529C(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed) { - SkelAnime_ChangeAnimation(skelAnime, animationSeg, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(&animationSeg->genericHeader), 2, - 0.0f); + SkelAnime_ChangeAnimation(skelAnime, animationSeg, playbackSpeed, 0.0f, + SkelAnime_GetFrameCount(&animationSeg->genericHeader), 2, 0.0f); } void SkelAnime_ChangeAnimationDefault(SkelAnime* skelAnime, AnimationHeader* animationSeg) { - SkelAnime_ChangeAnimation(skelAnime, animationSeg, 1.0f, 0.0f, SkelAnime_GetFrameCount(&animationSeg->genericHeader), 0, 0.0f); + SkelAnime_ChangeAnimation(skelAnime, animationSeg, 1.0f, 0.0f, + SkelAnime_GetFrameCount(&animationSeg->genericHeader), 0, 0.0f); } void SkelAnime_ChangeAnimationTransitionRate(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 transitionRate) { @@ -1543,8 +1558,8 @@ void SkelAnime_ChangeAnimationTransitionRate(SkelAnime* skelAnime, AnimationHead } void SkelAnime_ChangeAnimationPlaybackSpeed(SkelAnime* skelAnime, AnimationHeader* animationSeg, f32 playbackSpeed) { - SkelAnime_ChangeAnimation(skelAnime, animationSeg, playbackSpeed, 0.0f, SkelAnime_GetFrameCount(&animationSeg->genericHeader), 0, - 0.0f); + SkelAnime_ChangeAnimation(skelAnime, animationSeg, playbackSpeed, 0.0f, + SkelAnime_GetFrameCount(&animationSeg->genericHeader), 0, 0.0f); } void func_800A53DC(SkelAnime* skelAnime) { -- cgit v1.2.3 From 582b32d39c16fa565fd1cda320da2632abba4296 Mon Sep 17 00:00:00 2001 From: KrimtonZ Date: Wed, 25 Mar 2020 11:43:11 -0500 Subject: Fix Draw Callbacks, fix segmented address in z_en_bird --- src/code/z_actor.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/code') diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 9928be4d9..49086f289 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -3884,8 +3884,8 @@ Gfx* func_80034B54(GraphicsContext* gfxCtx) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_80034B54.s") #endif -void func_80034BA0(GlobalContext* globalCtx, SkelAnime* skelAnime, void* unkFunc1, void* unkFunc2, Actor* actor, - s16 alpha) { +void func_80034BA0(GlobalContext* globalCtx, SkelAnime* skelAnime, SkelAnime_LimbUpdateMatrix2 unkFunc1, + SkelAnime_LimbAppendDlist2 unkFunc2, Actor* actor, s16 alpha) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; Gfx* gfxArr[4]; @@ -3904,8 +3904,8 @@ void func_80034BA0(GlobalContext* globalCtx, SkelAnime* skelAnime, void* unkFunc func_800C6B54(gfxArr, globalCtx->state.gfxCtx, "../z_actor.c", 8860); } -void func_80034CC4(GlobalContext* globalCtx, SkelAnime* skelAnime, void* unkFunc1, void* unkFunc2, Actor* actor, - s16 alpha) { +void func_80034CC4(GlobalContext* globalCtx, SkelAnime* skelAnime, SkelAnime_LimbUpdateMatrix2 unkFunc1, + SkelAnime_LimbAppendDlist2 unkFunc2, Actor* actor, s16 alpha) { GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; Gfx* gfxArr[4]; -- cgit v1.2.3 From 864cb28e272d68deaf1805dc62286531854edb48 Mon Sep 17 00:00:00 2001 From: KrimtonZ Date: Wed, 25 Mar 2020 14:38:16 -0500 Subject: remove skelanime data files, few extra namings, add non_matching for func_800A2E70 --- src/code/z_skelanime.c | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'src/code') diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index bf0a19567..f7eae881a 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -18,7 +18,7 @@ void SkelAnime_AnimationType5Loaded(GlobalContext* globalCtx, AnimationEntryType //.data u32 D_8012A480 = 0; -static AnimationEntryCallback D_8012A484[] = { +static AnimationEntryCallback AnimationLoadDone[] = { &SkelAnime_LinkAnimetionLoaded, &SkelAnime_AnimationType1Loaded, &SkelAnime_AnimationType2Loaded, &SkelAnime_AnimationType3Loaded, &SkelAnime_AnimationType4Loaded, &SkelAnime_AnimationType5Loaded, }; @@ -131,7 +131,6 @@ void SkelAnime_LodDraw(GlobalContext* globalCtx, Skeleton* skeleton, Vec3s* acto func_800C6B54(gfx, globalCtx->state.gfxCtx, "../z_skelanime.c", 894); } -//#define NON_MATCHING #ifdef NON_MATCHING // regalloc void SkelAnime_LodDrawLimbSV(GlobalContext* globalCtx, s32 limbIndex, Skeleton* skeleton, Vec3s* actorDrawTable, @@ -776,18 +775,44 @@ s16 func_800A2E2C(GenericAnimationHeader* animationSeg) { return animation->frameCount - 1; } -// Very large update function +#ifdef NON_MATCHING +// Functionally equal, but loop unrolling is way off. +void func_800A2E70(s32 limbCount, Vec3s* vec1, Vec3s* vec2, Vec3s* vec3, f32 unkf) { + Vec3s* pvec1; + Vec3s* pvec2; + Vec3s* pvec3; + s32 iVar3; + + if (unkf < 1.0f) { + for (iVar3 = 0, pvec1 = vec1, pvec2 = vec2, pvec3 = vec3; iVar3 < limbCount; + iVar3++, pvec1++, pvec2++, pvec3++) { + pvec1->x = pvec2->x + ((s16)(pvec3->x - pvec2->x) * unkf); + pvec1->y = pvec2->y + ((s16)(pvec3->y - pvec2->y) * unkf); + pvec1->z = pvec2->z + ((s16)(pvec3->z - pvec2->z) * unkf); + } + } else { + for (iVar3 = 0; iVar3 < limbCount; iVar3++) { + pvec1 = &vec1[iVar3]; + pvec3 = &vec3[iVar3]; + pvec1->x = pvec3->x; + pvec1->y = pvec3->y; + pvec1->z = pvec3->z; + } + } +} +#else #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A2E70.s") +#endif -void func_800A32EC(u16* arg0) { - *arg0 = 0; +void SkelAnime_AnimationCtxReset(AnimationContext* animationCtx) { + animationCtx->animationCount = 0; } -void func_800A32F4(s32 arg0) { - D_801600B0 *= 2; +void func_800A32F4(GlobalContext* globalCtx) { + D_801600B0 <<= 1; } -void func_800A3310(void* arg0) { +void func_800A3310(GlobalContext* globalCtx) { u32* D_8012A480Ptr = &D_8012A480; *D_8012A480Ptr |= D_801600B0; @@ -954,7 +979,7 @@ void func_800A390C(GlobalContext* globalCtx, AnimationContext* animationCtx) { AnimationEntry* entry; for (entry = animationCtx->entries; animationCtx->animationCount != 0; entry++, animationCtx->animationCount--) { - D_8012A484[entry->type](globalCtx, &entry->types); + AnimationLoadDone[entry->type](globalCtx, &entry->types); } D_801600B0 = 1; -- cgit v1.2.3 From dc35cba293616678b234c6a8c132f960c02a4644 Mon Sep 17 00:00:00 2001 From: KrimtonZ Date: Wed, 25 Mar 2020 14:44:42 -0500 Subject: naming update --- src/code/z_skelanime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/code') diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index f7eae881a..501797081 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -18,7 +18,7 @@ void SkelAnime_AnimationType5Loaded(GlobalContext* globalCtx, AnimationEntryType //.data u32 D_8012A480 = 0; -static AnimationEntryCallback AnimationLoadDone[] = { +static AnimationEntryCallback sAnimationLoadDone[] = { &SkelAnime_LinkAnimetionLoaded, &SkelAnime_AnimationType1Loaded, &SkelAnime_AnimationType2Loaded, &SkelAnime_AnimationType3Loaded, &SkelAnime_AnimationType4Loaded, &SkelAnime_AnimationType5Loaded, }; @@ -979,7 +979,7 @@ void func_800A390C(GlobalContext* globalCtx, AnimationContext* animationCtx) { AnimationEntry* entry; for (entry = animationCtx->entries; animationCtx->animationCount != 0; entry++, animationCtx->animationCount--) { - AnimationLoadDone[entry->type](globalCtx, &entry->types); + sAnimationLoadDone[entry->type](globalCtx, &entry->types); } D_801600B0 = 1; -- cgit v1.2.3