diff --git a/include/z64animation.h b/include/z64animation.h index bf38b5da66..f965701d58 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -37,11 +37,11 @@ typedef enum AnimationMode { /* 5 */ ANIMMODE_LOOP_PARTIAL_INTERP } AnimationMode; -typedef enum { +typedef enum AnimationTaper { /* -1 */ ANIMTAPER_DECEL = -1, /* 0 */ ANIMTAPER_NONE, /* 1 */ ANIMTAPER_ACCEL -} AnimationTapers; +} AnimationTaper; typedef struct { /* 0x0 */ Vec3s jointPos; // Root is position in model space, children are relative to parent @@ -89,76 +89,79 @@ typedef struct { /* 0xC */ u16 staticIndexMax; } AnimationHeader; // size = 0x10 -typedef enum { - /* 0 */ ANIMATION_LINKANIMETION, - /* 1 */ ANIMENTRY_COPYALL, - /* 2 */ ANIMENTRY_INTERP, - /* 3 */ ANIMENTRY_COPYTRUE, - /* 4 */ ANIMENTRY_COPYFALSE, - /* 5 */ ANIMENTRY_MOVEACTOR -} AnimationType; +typedef enum AnimTaskType { + /* 0 */ ANIMTASK_LOAD_PLAYER_FRAME, + /* 1 */ ANIMTASK_COPY, + /* 2 */ ANIMTASK_INTERP, + /* 3 */ ANIMTASK_COPY_USING_MAP, + /* 4 */ ANIMTASK_COPY_USING_MAP_INVERTED, + /* 5 */ ANIMTASK_ACTOR_MOVE, + /* 6 */ ANIMTASK_MAX +} AnimTaskType; typedef struct { /* 0x00 */ DmaRequest req; /* 0x20 */ OSMesgQueue msgQueue; /* 0x38 */ OSMesg msg[1]; -} AnimEntryLoadFrame; // size = 0x3C +} AnimTaskLoadPlayerFrame; // size = 0x3C typedef struct { - /* 0x0 */ u8 queueFlag; + /* 0x0 */ u8 group; /* 0x1 */ u8 vecCount; - /* 0x4 */ Vec3s* dst; + /* 0x4 */ Vec3s* dest; /* 0x8 */ Vec3s* src; -} AnimEntryCopyAll; // size = 0xC +} AnimTaskCopy; // size = 0xC typedef struct { - /* 0x0 */ u8 queueFlag; + /* 0x0 */ u8 group; /* 0x1 */ u8 vecCount; /* 0x4 */ Vec3s* base; /* 0x8 */ Vec3s* mod; /* 0xC */ f32 weight; -} AnimEntryInterp; // size = 0x10 +} AnimTaskInterp; // size = 0x10 typedef struct { - /* 0x0 */ u8 queueFlag; + /* 0x0 */ u8 group; /* 0x1 */ u8 vecCount; - /* 0x4 */ Vec3s* dst; + /* 0x4 */ Vec3s* dest; /* 0x8 */ Vec3s* src; - /* 0xC */ u8* copyFlag; -} AnimEntryCopyTrue; // size = 0x10 + /* 0xC */ u8* limbCopyMap; +} AnimTaskCopyUsingMap; // size = 0x10 typedef struct { - /* 0x0 */ u8 queueFlag; + /* 0x0 */ u8 group; /* 0x1 */ u8 vecCount; - /* 0x4 */ Vec3s* dst; + /* 0x4 */ Vec3s* dest; /* 0x8 */ Vec3s* src; - /* 0xC */ u8* copyFlag; -} AnimEntryCopyFalse; // size = 0x10 + /* 0xC */ u8* limbCopyMap; +} AnimTaskCopyUsingMapInverted; // size = 0x10 typedef struct { /* 0x0 */ struct Actor* actor; /* 0x4 */ struct SkelAnime* skelAnime; - /* 0x8 */ f32 unk08; -} AnimEntryMoveActor; // size = 0xC + /* 0x8 */ f32 diffScale; +} AnimTaskActorMove; // size = 0xC typedef union { - AnimEntryLoadFrame load; - AnimEntryCopyAll copy; - AnimEntryInterp interp; - AnimEntryCopyTrue copy1; - AnimEntryCopyFalse copy0; - AnimEntryMoveActor move; -} AnimationEntryData; // size = 0x3C + AnimTaskLoadPlayerFrame loadPlayerFrame; + AnimTaskCopy copy; + AnimTaskInterp interp; + AnimTaskCopyUsingMap copyUsingMap; + AnimTaskCopyUsingMapInverted copyUsingMapInverted; + AnimTaskActorMove actorMove; +} AnimTaskData; // size = 0x3C typedef struct { - /* 0x00 */ u8 type; - /* 0x04 */ AnimationEntryData data; -} AnimationEntry; // size = 0x40 + /* 0x0 */ u8 type; + /* 0x4 */ AnimTaskData data; +} AnimTask; // size = 0x40 -typedef struct AnimationContext { - /* 0x000 */ s16 animationCount; - /* 0x004 */ AnimationEntry entries[50]; -} AnimationContext; // size = 0xC84 +#define ANIM_TASK_QUEUE_MAX 50 + +typedef struct AnimTaskQueue { + /* 0x0 */ s16 count; + /* 0x4 */ AnimTask tasks[ANIM_TASK_QUEUE_MAX]; +} AnimTaskQueue; // size = 0xC84 typedef struct { /* 0x0 */ AnimationHeaderCommon common; @@ -217,8 +220,6 @@ typedef void (*TransformLimbDrawOpa)(struct PlayState* play, s32 limbIndex, stru typedef void (*TransformLimbDraw)(struct PlayState* play, s32 limbIndex, struct Actor* thisx, Gfx** gfx); -typedef void (*AnimationEntryCallback)(struct PlayState*, AnimationEntryData*); - typedef struct { /* 0x00 */ AnimationHeader* animation; /* 0x04 */ f32 playSpeed; @@ -253,17 +254,17 @@ s16 Animation_GetLastFrame(void* animation); Gfx* SkelAnime_Draw(struct PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, struct Actor* actor, Gfx* gfx); Gfx* SkelAnime_DrawFlex(struct PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, struct Actor* actor, Gfx* gfx); -void AnimationContext_Reset(AnimationContext* animationCtx); -void AnimationContext_SetNextQueue(struct PlayState* play); -void AnimationContext_DisableQueue(struct PlayState* play); -void AnimationContext_SetLoadFrame(struct PlayState* play, PlayerAnimationHeader* animation, s32 frame, s32 limbCount, Vec3s* frameTable); -void AnimationContext_SetCopyAll(struct PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src); -void AnimationContext_SetInterp(struct PlayState* play, s32 vecCount, Vec3s* base, Vec3s* mod, f32 weight); -void AnimationContext_SetCopyTrue(struct PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag); -void AnimationContext_SetCopyFalse(struct PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag); -void AnimationContext_SetMoveActor(struct PlayState* play, struct Actor* actor, SkelAnime* skelAnime, f32 arg3); +void AnimTaskQueue_Reset(AnimTaskQueue* animTaskQueue); +void AnimTaskQueue_SetNextGroup(struct PlayState* play); +void AnimTaskQueue_DisableTransformTasksForGroup(struct PlayState* play); +void AnimTaskQueue_AddLoadPlayerFrame(struct PlayState* play, PlayerAnimationHeader* animation, s32 frame, s32 limbCount, Vec3s* frameTable); +void AnimTaskQueue_AddCopy(struct PlayState* play, s32 vecCount, Vec3s* dest, Vec3s* src); +void AnimTaskQueue_AddInterp(struct PlayState* play, s32 vecCount, Vec3s* base, Vec3s* mod, f32 weight); +void AnimTaskQueue_AddCopyUsingMap(struct PlayState* play, s32 vecCount, Vec3s* dest, Vec3s* src, u8* limbCopyMap); +void AnimTaskQueue_AddCopyUsingMapInverted(struct PlayState* play, s32 vecCount, Vec3s* dest, Vec3s* src, u8* limbCopyMap); +void AnimTaskQueue_AddActorMove(struct PlayState* play, struct Actor* actor, SkelAnime* skelAnime, f32 moveDiffScale); +void AnimTaskQueue_Update(struct PlayState* play, AnimTaskQueue* animTaskQueue); -void AnimationContext_Update(struct PlayState* play, AnimationContext* animationCtx); void SkelAnime_InitPlayer(struct PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, PlayerAnimationHeader* animation, s32 flags, void* jointTableBuffer, void* morphTableBuffer, s32 limbBufCount); void PlayerAnimation_SetUpdateFunction(SkelAnime* skelAnime); s32 PlayerAnimation_Update(struct PlayState* play, SkelAnime* skelAnime); diff --git a/include/z64play.h b/include/z64play.h index e79b202497..b1f64de399 100644 --- a/include/z64play.h +++ b/include/z64play.h @@ -61,7 +61,7 @@ typedef struct PlayState { /* 0x16D30 */ PauseContext pauseCtx; /* 0x17000 */ GameOverContext gameOverCtx; /* 0x17004 */ EnvironmentContext envCtx; - /* 0x17104 */ AnimationContext animationCtx; + /* 0x17104 */ AnimTaskQueue animTaskQueue; /* 0x17D88 */ ObjectContext objectCtx; /* 0x186E0 */ RoomContext roomCtx; /* 0x18760 */ TransitionActorList transitionActors; diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index de872aba4b..47eea4f7fa 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -74,6 +74,7 @@ struct Dummy251 { int x; }; struct Dummy252 { int x; }; struct Dummy253 { int x; }; struct Dummy254 { int x; }; +struct Dummy255 { int x; }; // clang-format on Vec3f D_801EDE00; diff --git a/src/code/z_en_hy_code.c b/src/code/z_en_hy_code.c index 562849e651..f061a649ce 100644 --- a/src/code/z_en_hy_code.c +++ b/src/code/z_en_hy_code.c @@ -190,7 +190,7 @@ void func_800F0BB4(EnHy* enHy, PlayState* play, EnDoor* door, s16 arg3, s16 arg4 enHy->skelAnime.baseTransl = enHy->skelAnime.jointTable[LIMB_ROOT_POS]; enHy->skelAnime.prevTransl = enHy->skelAnime.jointTable[LIMB_ROOT_POS]; enHy->skelAnime.moveFlags |= (ANIM_FLAG_UPDATE_Y | ANIM_FLAG_1); - AnimationContext_SetMoveActor(play, &enHy->actor, &enHy->skelAnime, 1.0f); + AnimTaskQueue_AddActorMove(play, &enHy->actor, &enHy->skelAnime, 1.0f); door->knobDoor.requestOpen = true; door->knobDoor.animIndex = animIndex; } diff --git a/src/code/z_play.c b/src/code/z_play.c index 1c63b6a4b2..4cd7301487 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -975,7 +975,7 @@ void Play_UpdateMain(PlayState* this) { sp5C = IS_PAUSED(&this->pauseCtx); - AnimationContext_Reset(&this->animationCtx); + AnimTaskQueue_Reset(&this->animTaskQueue); Object_UpdateEntries(&this->objectCtx); if (!sp5C && (IREG(72) == 0)) { @@ -1023,7 +1023,7 @@ void Play_UpdateMain(PlayState* this) { Message_Update(this); Interface_Update(this); - AnimationContext_Update(this, &this->animationCtx); + AnimTaskQueue_Update(this, &this->animTaskQueue); SoundSource_UpdateAll(this); ShrinkWindow_Update(this->state.framerateDivisor); TransitionFade_Update(&this->unk_18E48, this->state.framerateDivisor); @@ -2183,7 +2183,7 @@ void Play_Init(GameState* thisx) { Effect_Init(this); EffectSS_Init(this, 100); CollisionCheck_InitContext(this, &this->colChkCtx); - AnimationContext_Reset(&this->animationCtx); + AnimTaskQueue_Reset(&this->animTaskQueue); Cutscene_InitContext(this, &this->csCtx); if (gSaveContext.nextCutsceneIndex != 0xFFEF) { @@ -2333,7 +2333,7 @@ void Play_Init(GameState* thisx) { Environment_PlaySceneSequence(this); gSaveContext.seqId = this->sceneSequences.seqId; gSaveContext.ambienceId = this->sceneSequences.ambienceId; - AnimationContext_Update(this, &this->animationCtx); + AnimTaskQueue_Update(this, &this->animTaskQueue); Cutscene_HandleEntranceTriggers(this); gSaveContext.respawnFlag = 0; sBombersNotebookOpen = false; diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 4c05290122..2dfde03947 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -14,20 +14,15 @@ void PlayerAnimation_Change(PlayState* play, SkelAnime* skelAnime, PlayerAnimati f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames); void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src); -void AnimationContext_LoadFrame(struct PlayState* play, AnimationEntryData* data); -void AnimationContext_CopyAll(struct PlayState* play, AnimationEntryData* data); -void AnimationContext_Interp(struct PlayState* play, AnimationEntryData* data); -void AnimationContext_CopyTrue(struct PlayState* play, AnimationEntryData* data); -void AnimationContext_CopyFalse(struct PlayState* play, AnimationEntryData* data); -void AnimationContext_MoveActor(struct PlayState* play, AnimationEntryData* data); +void AnimTask_LoadPlayerFrame(struct PlayState* play, AnimTaskData* data); +void AnimTask_Copy(struct PlayState* play, AnimTaskData* data); +void AnimTask_Interp(struct PlayState* play, AnimTaskData* data); +void AnimTask_CopyUsingMap(struct PlayState* play, AnimTaskData* data); +void AnimTask_CopyUsingMapInverted(struct PlayState* play, AnimTaskData* data); +void AnimTask_ActorMove(struct PlayState* play, AnimTaskData* data); -static AnimationEntryCallback sAnimationLoadDone[] = { - AnimationContext_LoadFrame, AnimationContext_CopyAll, AnimationContext_Interp, - AnimationContext_CopyTrue, AnimationContext_CopyFalse, AnimationContext_MoveActor, -}; - -s32 sAnimQueueFlags; -s32 sDisableAnimQueueFlags; +s32 sCurAnimTaskGroup; +s32 sDisabledTransformTaskGroups; /* * Draws the limb at `limbIndex` with a level of detail display lists index by `dListIndex` @@ -962,238 +957,291 @@ void SkelAnime_InterpFrameTable(s32 limbCount, Vec3s* dst, Vec3s* start, Vec3s* } /** - * Zeroes out the current request count + * Clear the current task queue. The discarded tasks will then not be processed. */ -void AnimationContext_Reset(AnimationContext* animationCtx) { - animationCtx->animationCount = 0; +void AnimTaskQueue_Reset(AnimTaskQueue* animTaskQueue) { + animTaskQueue->count = 0; } /** - * Shifts the queue flag to the next queue + * Changes `sCurAnimTaskGroup` to the next group number. + * + * Task groups allow for disabling "transformative" tasks for a defined group. + * For more information see `AnimTaskQueue_DisableTransformTasksForGroup`. + * + * Note that `sCurAnimTaskGroup` is not a whole number that increments, it is handled at the bit-level. + * Every time the group number changes, a single bit moves 1 position to the left. This is an implementation detail + * that allows for `sDisabledTransformTaskGroups` to compare against a set of bit flags. */ -void AnimationContext_SetNextQueue(PlayState* play) { - sAnimQueueFlags <<= 1; +void AnimTaskQueue_SetNextGroup(PlayState* play) { + sCurAnimTaskGroup <<= 1; } /** - * Disables the current animation queue. Only load and move actor requests will be processed for that queue. + * Marks the current task group as disabled so that "transformative" tasks are skipped. + * A transformative task is one that will alter the appearance of an animation. + * These include Copy, Interp, CopyUsingMap, and CopyUsingMapInverted. + * + * LoadPlayerFrame and ActorMove, which don't alter the appearance of an existing animation, + * will always run even if a group has its transformative tasks disabled. */ -void AnimationContext_DisableQueue(PlayState* play) { - sDisableAnimQueueFlags |= sAnimQueueFlags; +void AnimTaskQueue_DisableTransformTasksForGroup(PlayState* play) { + sDisabledTransformTaskGroups |= sCurAnimTaskGroup; } -AnimationEntry* AnimationContext_AddEntry(AnimationContext* animationCtx, AnimationType type) { - AnimationEntry* entry; - s16 index = animationCtx->animationCount; +/** + * Creates a new task and adds it to the queue, if there is room for it. + * + * The `type` value for the task gets set here, but all other + * initialization must be handled by the caller. + * + * @return a pointer to the task, or NULL if it could not be added + */ +AnimTask* AnimTaskQueue_NewTask(AnimTaskQueue* animTaskQueue, AnimTaskType type) { + AnimTask* task; + s16 taskNumber = animTaskQueue->count; - if (index >= ARRAY_COUNT(animationCtx->entries)) { + if (taskNumber >= ANIM_TASK_QUEUE_MAX) { return NULL; } - animationCtx->animationCount = index + 1; - entry = &animationCtx->entries[index]; - entry->type = type; - return entry; + animTaskQueue->count = taskNumber + 1; + + task = &animTaskQueue->tasks[taskNumber]; + task->type = type; + + return task; } #define LINK_ANIMETION_OFFSET(addr, offset) \ (SEGMENT_ROM_START(link_animetion) + ((uintptr_t)addr & 0xFFFFFF) + ((u32)offset)) /** - * Requests loading frame data from the Player animation into frameTable + * Creates a task which will load a single frame of animation data from the link_animetion file. + * The asynchronous DMA request to load the data is made as soon as the task is created. + * When the task is processed later in the AnimTaskQueue, it will wait for the DMA to finish. */ -void AnimationContext_SetLoadFrame(PlayState* play, PlayerAnimationHeader* animation, s32 frame, s32 limbCount, - Vec3s* frameTable) { - AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMATION_LINKANIMETION); +void AnimTaskQueue_AddLoadPlayerFrame(PlayState* play, PlayerAnimationHeader* animation, s32 frame, s32 limbCount, + Vec3s* frameTable) { + AnimTask* task = AnimTaskQueue_NewTask(&play->animTaskQueue, ANIMTASK_LOAD_PLAYER_FRAME); - if (entry != NULL) { + if (task != NULL) { PlayerAnimationHeader* playerAnimHeader = Lib_SegmentedToVirtual(animation); s32 pad; - osCreateMesgQueue(&entry->data.load.msgQueue, entry->data.load.msg, ARRAY_COUNT(entry->data.load.msg)); + osCreateMesgQueue(&task->data.loadPlayerFrame.msgQueue, task->data.loadPlayerFrame.msg, + ARRAY_COUNT(task->data.loadPlayerFrame.msg)); DmaMgr_RequestAsync( - &entry->data.load.req, frameTable, + &task->data.loadPlayerFrame.req, frameTable, LINK_ANIMETION_OFFSET(playerAnimHeader->linkAnimSegment, (sizeof(Vec3s) * limbCount + sizeof(s16)) * frame), - sizeof(Vec3s) * limbCount + sizeof(s16), 0, &entry->data.load.msgQueue, NULL); + sizeof(Vec3s) * limbCount + sizeof(s16), 0, &task->data.loadPlayerFrame.msgQueue, NULL); } } /** - * Requests copying all vectors from src frame table into dst frame table + * Creates a task which will copy all vectors from the `src` frame table to the `dest` frame table. + * + * Note: This task is "transformative", meaning it will alter the appearance of an animation. + * If this task's group is included in `sDisabledTransformTaskGroups`, this task will be skipped for that frame. */ -void AnimationContext_SetCopyAll(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src) { - AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_COPYALL); +void AnimTaskQueue_AddCopy(PlayState* play, s32 vecCount, Vec3s* dest, Vec3s* src) { + AnimTask* task = AnimTaskQueue_NewTask(&play->animTaskQueue, ANIMTASK_COPY); - if (entry != NULL) { - entry->data.copy.queueFlag = sAnimQueueFlags; - entry->data.copy.vecCount = vecCount; - entry->data.copy.dst = dst; - entry->data.copy.src = src; + if (task != NULL) { + task->data.copy.group = sCurAnimTaskGroup; + task->data.copy.vecCount = vecCount; + task->data.copy.dest = dest; + task->data.copy.src = src; } } /** - * Requests interpolating between base and mod frame tables with the given weight, placing the result in base + * Creates a task which will interpolate between the `base` and `mod` frame tables. + * The result of the interpolation will be placed in the original `base` table. + * + * Note: This task is "transformative", meaning it will alter the appearance of an animation. + * If this task's group is included in `sDisabledTransformTaskGroups`, this task will be skipped for that frame. */ -void AnimationContext_SetInterp(PlayState* play, s32 vecCount, Vec3s* base, Vec3s* mod, f32 weight) { - AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_INTERP); +void AnimTaskQueue_AddInterp(PlayState* play, s32 vecCount, Vec3s* base, Vec3s* mod, f32 weight) { + AnimTask* task = AnimTaskQueue_NewTask(&play->animTaskQueue, ANIMTASK_INTERP); - if (entry != NULL) { - entry->data.interp.queueFlag = sAnimQueueFlags; - entry->data.interp.vecCount = vecCount; - entry->data.interp.base = base; - entry->data.interp.mod = mod; - entry->data.interp.weight = weight; + if (task != NULL) { + task->data.interp.group = sCurAnimTaskGroup; + task->data.interp.vecCount = vecCount; + task->data.interp.base = base; + task->data.interp.mod = mod; + task->data.interp.weight = weight; } } /** - * Requests copying vectors from src frame table to dst frame table whose load flag is true + * Creates a task which will copy specified vectors from the `src` frame table to the `dest` frame table. + * Exactly which vectors will be copied is specified by the `limbCopyMap`. + * + * The copy map is an array of true/false flags that specify which limbs should have their data copied. + * Each index of the map corresponds to a limb number in the skeleton. + * Every limb that has `true` listed will have its data copied. + * + * Note: This task is "transformative", meaning it will alter the appearance of an animation. + * If this task's group is included in `sDisabledTransformTaskGroups`, this task will be skipped for that frame. */ -void AnimationContext_SetCopyTrue(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag) { - AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_COPYTRUE); +void AnimTaskQueue_AddCopyUsingMap(PlayState* play, s32 vecCount, Vec3s* dest, Vec3s* src, u8* limbCopyMap) { + AnimTask* task = AnimTaskQueue_NewTask(&play->animTaskQueue, ANIMTASK_COPY_USING_MAP); - if (entry != NULL) { - entry->data.copy1.queueFlag = sAnimQueueFlags; - entry->data.copy1.vecCount = vecCount; - entry->data.copy1.dst = dst; - entry->data.copy1.src = src; - entry->data.copy1.copyFlag = copyFlag; + if (task != NULL) { + task->data.copyUsingMap.group = sCurAnimTaskGroup; + task->data.copyUsingMap.vecCount = vecCount; + task->data.copyUsingMap.dest = dest; + task->data.copyUsingMap.src = src; + task->data.copyUsingMap.limbCopyMap = limbCopyMap; } } /** - * Requests copying vectors from src frame table to dst frame table whose load flag is false + * Identical to `AnimTaskQueue_AddCopyUsingMap`, except the meaning of the flags in the `limbCopyMap` are inverted. + * Any entry that specifies `false` will be copied, and any entry that specifies `true` will not. + * + * Note: This task is "transformative", meaning it will alter the appearance of an animation. + * If this task's group is included in `sDisabledTransformTaskGroups`, this task will be skipped for that frame. */ -void AnimationContext_SetCopyFalse(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag) { - AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_COPYFALSE); +void AnimTaskQueue_AddCopyUsingMapInverted(PlayState* play, s32 vecCount, Vec3s* dest, Vec3s* src, u8* limbCopyMap) { + AnimTask* task = AnimTaskQueue_NewTask(&play->animTaskQueue, ANIMTASK_COPY_USING_MAP_INVERTED); - if (entry != NULL) { - entry->data.copy0.queueFlag = sAnimQueueFlags; - entry->data.copy0.vecCount = vecCount; - entry->data.copy0.dst = dst; - entry->data.copy0.src = src; - entry->data.copy0.copyFlag = copyFlag; + if (task != NULL) { + task->data.copyUsingMapInverted.group = sCurAnimTaskGroup; + task->data.copyUsingMapInverted.vecCount = vecCount; + task->data.copyUsingMapInverted.dest = dest; + task->data.copyUsingMapInverted.src = src; + task->data.copyUsingMapInverted.limbCopyMap = limbCopyMap; } } /** - * Requests moving an actor according to the translation of its root limb + * Creates a task which will move an actor according to the translation of its root limb for the current frame. */ -void AnimationContext_SetMoveActor(PlayState* play, Actor* actor, SkelAnime* skelAnime, f32 arg3) { - AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_MOVEACTOR); +void AnimTaskQueue_AddActorMove(PlayState* play, Actor* actor, SkelAnime* skelAnime, f32 moveDiffScale) { + AnimTask* task = AnimTaskQueue_NewTask(&play->animTaskQueue, ANIMTASK_ACTOR_MOVE); - if (entry != NULL) { - entry->data.move.actor = actor; - entry->data.move.skelAnime = skelAnime; - entry->data.move.unk08 = arg3; + if (task != NULL) { + task->data.actorMove.actor = actor; + task->data.actorMove.skelAnime = skelAnime; + task->data.actorMove.diffScale = moveDiffScale; } } /** - * Receives the request for Player's animation frame data + * Wait for the DMA request submitted by `AnimTaskQueue_AddLoadPlayerFrame` to complete. */ -void AnimationContext_LoadFrame(PlayState* play, AnimationEntryData* data) { - AnimEntryLoadFrame* entry = &data->load; +void AnimTask_LoadPlayerFrame(PlayState* play, AnimTaskData* data) { + AnimTaskLoadPlayerFrame* task = &data->loadPlayerFrame; - osRecvMesg(&entry->msgQueue, NULL, OS_MESG_BLOCK); + osRecvMesg(&task->msgQueue, NULL, OS_MESG_BLOCK); } /** - * If the entry's queue is enabled, copies all vectors from src frame table to dst frame table + * Copy all data from the `src` frame table to the `dest` table. */ -void AnimationContext_CopyAll(PlayState* play, AnimationEntryData* data) { - AnimEntryCopyAll* entry = &data->copy; +void AnimTask_Copy(PlayState* play, AnimTaskData* data) { + AnimTaskCopy* task = &data->copy; - if (!(entry->queueFlag & sDisableAnimQueueFlags)) { - Vec3s* dst = entry->dst; - Vec3s* src = entry->src; + if (!(task->group & sDisabledTransformTaskGroups)) { + Vec3s* dest = task->dest; + Vec3s* src = task->src; s32 i; - for (i = 0; i < entry->vecCount; i++) { - *dst++ = *src++; + for (i = 0; i < task->vecCount; i++) { + *dest++ = *src++; } } } /** - * If the entry's queue is enabled, interpolates between the base and mod frame tables, placing the result in base + * Interpolate between the `base` and `mod` frame tables. */ -void AnimationContext_Interp(PlayState* play, AnimationEntryData* data) { - AnimEntryInterp* entry = &data->interp; +void AnimTask_Interp(PlayState* play, AnimTaskData* data) { + AnimTaskInterp* task = &data->interp; - if (!(entry->queueFlag & sDisableAnimQueueFlags)) { - SkelAnime_InterpFrameTable(entry->vecCount, entry->base, entry->base, entry->mod, entry->weight); + if (!(task->group & sDisabledTransformTaskGroups)) { + SkelAnime_InterpFrameTable(task->vecCount, task->base, task->base, task->mod, task->weight); } } /** - * If the entry's queue is enabled, copies all vectors from src frame table to dst frame table whose copy flag is true + * Copy all data from the `src` frame table to the `dest` table according to the copy map. */ -void AnimationContext_CopyTrue(PlayState* play, AnimationEntryData* data) { - AnimEntryCopyTrue* entry = &data->copy1; +void AnimTask_CopyUsingMap(PlayState* play, AnimTaskData* data) { + AnimTaskCopyUsingMap* task = &data->copyUsingMap; - if (!(entry->queueFlag & sDisableAnimQueueFlags)) { - Vec3s* dst = entry->dst; - Vec3s* src = entry->src; - u8* copyFlag = entry->copyFlag; + if (!(task->group & sDisabledTransformTaskGroups)) { + Vec3s* dest = task->dest; + Vec3s* src = task->src; + u8* limbCopyMap = task->limbCopyMap; s32 i; - for (i = 0; i < entry->vecCount; i++, dst++, src++) { - if (*copyFlag++) { - *dst = *src; + for (i = 0; i < task->vecCount; i++, dest++, src++) { + if (*limbCopyMap++) { + *dest = *src; } } } } /** - * If the entry's queue is enabled, copies all vectors from src frame table to dst frame table whose copy flag is false + * Copy all data from the `src` frame table to the `dest` table according to the inverted copy map. */ -void AnimationContext_CopyFalse(PlayState* play, AnimationEntryData* data) { - AnimEntryCopyFalse* entry = &data->copy0; +void AnimTask_CopyUsingMapInverted(PlayState* play, AnimTaskData* data) { + AnimTaskCopyUsingMapInverted* task = &data->copyUsingMapInverted; - if (!(entry->queueFlag & sDisableAnimQueueFlags)) { - Vec3s* dst = entry->dst; - Vec3s* src = entry->src; - u8* copyFlag = entry->copyFlag; + if (!(task->group & sDisabledTransformTaskGroups)) { + Vec3s* dest = task->dest; + Vec3s* src = task->src; + u8* limbCopyMap = task->limbCopyMap; s32 i; - for (i = 0; i < entry->vecCount; i++, dst++, src++) { - if (!(*copyFlag++)) { - *dst = *src; + for (i = 0; i < task->vecCount; i++, dest++, src++) { + if (!(*limbCopyMap++)) { + *dest = *src; } } } } /** - * Moves an actor according to the translation of its root limb + * Move an actor according to the translation of its root limb for the current animation frame. */ -void AnimationContext_MoveActor(PlayState* play, AnimationEntryData* data) { - AnimEntryMoveActor* entry = &data->move; - Actor* actor = entry->actor; +void AnimTask_ActorMove(PlayState* play, AnimTaskData* data) { + AnimTaskActorMove* task = &data->actorMove; + Actor* actor = task->actor; Vec3f diff; - SkelAnime_UpdateTranslation(entry->skelAnime, &diff, actor->shape.rot.y); - actor->world.pos.x += diff.x * actor->scale.x * entry->unk08; - actor->world.pos.y += diff.y * actor->scale.y * entry->unk08; - actor->world.pos.z += diff.z * actor->scale.z * entry->unk08; + SkelAnime_UpdateTranslation(task->skelAnime, &diff, actor->shape.rot.y); + + actor->world.pos.x += diff.x * actor->scale.x * task->diffScale; + actor->world.pos.y += diff.y * actor->scale.y * task->diffScale; + actor->world.pos.z += diff.z * actor->scale.z * task->diffScale; } -/** - * Performs all requests in the animation queue, then resets the queue flags. - */ -void AnimationContext_Update(PlayState* play, AnimationContext* animationCtx) { - AnimationEntry* entry = animationCtx->entries; +typedef void (*AnimTaskFunc)(struct PlayState* play, AnimTaskData* data); - for (; animationCtx->animationCount != 0; animationCtx->animationCount--) { - sAnimationLoadDone[entry->type](play, &entry->data); - entry++; +/** + * Update the AnimTaskQueue, processing all tasks in order. + * Variables related to anim task groups are then reset for the next frame. + */ +void AnimTaskQueue_Update(PlayState* play, AnimTaskQueue* animTaskQueue) { + static AnimTaskFunc sAnimTaskFuncs[ANIMTASK_MAX] = { + AnimTask_LoadPlayerFrame, AnimTask_Copy, AnimTask_Interp, AnimTask_CopyUsingMap, + AnimTask_CopyUsingMapInverted, AnimTask_ActorMove, + }; + AnimTask* task = animTaskQueue->tasks; + + while (animTaskQueue->count != 0) { + sAnimTaskFuncs[task->type](play, &task->data); + task++; + animTaskQueue->count--; } - sAnimQueueFlags = 1; - sDisableAnimQueueFlags = 0; + sCurAnimTaskGroup = 1 << 0; + sDisabledTransformTaskGroups = 0; } /** @@ -1274,8 +1322,8 @@ s32 PlayerAnimation_Morph(PlayState* play, SkelAnime* skelAnime) { PlayerAnimation_SetUpdateFunction(skelAnime); } - AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, - 1.0f - (skelAnime->morphWeight / prevMorphWeight)); + AnimTaskQueue_AddInterp(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, + 1.0f - (skelAnime->morphWeight / prevMorphWeight)); return false; } @@ -1284,16 +1332,16 @@ s32 PlayerAnimation_Morph(PlayState* play, SkelAnime* skelAnime) { * jointTable and morphTable */ void PlayerAnimation_AnimateFrame(PlayState* play, SkelAnime* skelAnime) { - AnimationContext_SetLoadFrame(play, skelAnime->animation, skelAnime->curFrame, skelAnime->limbCount, - skelAnime->jointTable); + AnimTaskQueue_AddLoadPlayerFrame(play, skelAnime->animation, skelAnime->curFrame, skelAnime->limbCount, + skelAnime->jointTable); if (skelAnime->morphWeight != 0) { f32 updateRate = (s32)play->state.framerateDivisor * 0.5f; skelAnime->morphWeight -= skelAnime->morphRate * updateRate; if (skelAnime->morphWeight <= 0.0f) { skelAnime->morphWeight = 0.0f; } else { - AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, - skelAnime->morphWeight); + AnimTaskQueue_AddInterp(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, + skelAnime->morphWeight); } } } @@ -1364,14 +1412,14 @@ void PlayerAnimation_Change(PlayState* play, SkelAnime* skelAnime, PlayerAnimati morphFrames = -morphFrames; } else { skelAnime->update.player = PlayerAnimation_Morph; - AnimationContext_SetLoadFrame(play, animation, (s32)startFrame, skelAnime->limbCount, - skelAnime->morphTable); + AnimTaskQueue_AddLoadPlayerFrame(play, animation, (s32)startFrame, skelAnime->limbCount, + skelAnime->morphTable); } skelAnime->morphWeight = 1.0f; skelAnime->morphRate = 1.0f / morphFrames; } else { PlayerAnimation_SetUpdateFunction(skelAnime); - AnimationContext_SetLoadFrame(play, animation, (s32)startFrame, skelAnime->limbCount, skelAnime->jointTable); + AnimTaskQueue_AddLoadPlayerFrame(play, animation, (s32)startFrame, skelAnime->limbCount, skelAnime->jointTable); skelAnime->morphWeight = 0.0f; } @@ -1422,35 +1470,35 @@ void PlayerAnimation_PlayLoopSetSpeed(PlayState* play, SkelAnime* skelAnime, Pla * Requests copying jointTable to morphTable */ void PlayerAnimation_CopyJointToMorph(PlayState* play, SkelAnime* skelAnime) { - AnimationContext_SetCopyAll(play, skelAnime->limbCount, skelAnime->morphTable, skelAnime->jointTable); + AnimTaskQueue_AddCopy(play, skelAnime->limbCount, skelAnime->morphTable, skelAnime->jointTable); } /** * Requests copying morphTable to jointTable */ void PlayerAnimation_CopyMorphToJoint(PlayState* play, SkelAnime* skelAnime) { - AnimationContext_SetCopyAll(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable); + AnimTaskQueue_AddCopy(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable); } /** * Requests loading frame data from the Player animation into morphTable */ void PlayerAnimation_LoadToMorph(PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation, f32 frame) { - AnimationContext_SetLoadFrame(play, animation, (s32)frame, skelAnime->limbCount, skelAnime->morphTable); + AnimTaskQueue_AddLoadPlayerFrame(play, animation, (s32)frame, skelAnime->limbCount, skelAnime->morphTable); } /** * Requests loading frame data from the Player animation into jointTable */ void PlayerAnimation_LoadToJoint(PlayState* play, SkelAnime* skelAnime, PlayerAnimationHeader* animation, f32 frame) { - AnimationContext_SetLoadFrame(play, animation, (s32)frame, skelAnime->limbCount, skelAnime->jointTable); + AnimTaskQueue_AddLoadPlayerFrame(play, animation, (s32)frame, skelAnime->limbCount, skelAnime->jointTable); } /** * Requests interpolating between jointTable and morphTable, placing the result in jointTable */ void PlayerAnimation_InterpJointMorph(PlayState* play, SkelAnime* skelAnime, f32 weight) { - AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, weight); + AnimTaskQueue_AddInterp(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, weight); } /** @@ -1461,12 +1509,12 @@ void PlayerAnimation_BlendToJoint(PlayState* play, SkelAnime* skelAnime, PlayerA void* blendTableBuffer) { void* alignedBlendTable; - AnimationContext_SetLoadFrame(play, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->jointTable); + AnimTaskQueue_AddLoadPlayerFrame(play, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->jointTable); alignedBlendTable = (void*)ALIGN16((uintptr_t)blendTableBuffer); - AnimationContext_SetLoadFrame(play, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable); - AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->jointTable, alignedBlendTable, blendWeight); + AnimTaskQueue_AddLoadPlayerFrame(play, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable); + AnimTaskQueue_AddInterp(play, skelAnime->limbCount, skelAnime->jointTable, alignedBlendTable, blendWeight); } /** @@ -1477,12 +1525,12 @@ void PlayerAnimation_BlendToMorph(PlayState* play, SkelAnime* skelAnime, PlayerA void* blendTableBuffer) { void* alignedBlendTable; - AnimationContext_SetLoadFrame(play, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->morphTable); + AnimTaskQueue_AddLoadPlayerFrame(play, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->morphTable); alignedBlendTable = (void*)ALIGN16((uintptr_t)blendTableBuffer); - AnimationContext_SetLoadFrame(play, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable); - AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->morphTable, alignedBlendTable, blendWeight); + AnimTaskQueue_AddLoadPlayerFrame(play, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable); + AnimTaskQueue_AddInterp(play, skelAnime->limbCount, skelAnime->morphTable, alignedBlendTable, blendWeight); } /** diff --git a/src/overlays/actors/ovl_En_Gm/z_en_gm.c b/src/overlays/actors/ovl_En_Gm/z_en_gm.c index 2b7e228f3b..fb8125ed57 100644 --- a/src/overlays/actors/ovl_En_Gm/z_en_gm.c +++ b/src/overlays/actors/ovl_En_Gm/z_en_gm.c @@ -1469,7 +1469,7 @@ s32 func_809503F8(EnGm* this, PlayState* play) { SubS_SetOfferMode(&this->unk_3A4, SUBS_OFFER_MODE_ONSCREEN, SUBS_OFFER_MODE_MASK); EnGm_ChangeAnim(this, play, ENGM_ANIM_0); } else { - AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); + AnimTaskQueue_AddActorMove(play, &this->actor, &this->skelAnime, 1.0f); } } return false; @@ -1506,7 +1506,7 @@ s32 func_80950490(EnGm* this, PlayState* play) { EnGm_ChangeAnim(this, play, ENGM_ANIM_0); func_8094E278(play); } else { - AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); + AnimTaskQueue_AddActorMove(play, &this->actor, &this->skelAnime, 1.0f); } break; diff --git a/src/overlays/actors/ovl_En_Tru/z_en_tru.c b/src/overlays/actors/ovl_En_Tru/z_en_tru.c index 15774c9af1..f3b281ad34 100644 --- a/src/overlays/actors/ovl_En_Tru/z_en_tru.c +++ b/src/overlays/actors/ovl_En_Tru/z_en_tru.c @@ -1088,7 +1088,7 @@ s32 func_80A87DC0(Actor* thisx, PlayState* play) { case 3: if (!Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { - AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, 1.0f); + AnimTaskQueue_AddActorMove(play, &this->actor, &this->skelAnime, 1.0f); break; } else { EnTru_ChangeAnim(this, KOUME_ANIM_FLY); diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index d3913b4deb..fca3ee9ab2 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -1988,7 +1988,7 @@ void Player_AnimReplace_Setup(PlayState* play, Player* this, s32 moveFlags) { this->skelAnime.moveFlags = moveFlags; Player_StopHorizontalMovement(this); - AnimationContext_DisableQueue(play); + AnimTaskQueue_DisableTransformTasksForGroup(play); } void Player_AnimReplace_PlayOnceSetSpeed(PlayState* play, Player* this, PlayerAnimationHeader* anim, s32 moveFlags, @@ -4561,21 +4561,21 @@ bool Player_UpdateUpperBody(Player* this, PlayState* play) { if (this->skelAnimeUpperBlendWeight != 0.0f) { if ((func_8082ED94(this) == 0) || (this->linearVelocity != 0.0f)) { - AnimationContext_SetCopyFalse(play, this->skelAnime.limbCount, this->skelAnimeUpper.jointTable, - this->skelAnime.jointTable, sPlayerUpperBodyLimbCopyMap); + AnimTaskQueue_AddCopyUsingMapInverted(play, this->skelAnime.limbCount, this->skelAnimeUpper.jointTable, + this->skelAnime.jointTable, sPlayerUpperBodyLimbCopyMap); } if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && !(this->skelAnime.moveFlags & ANIM_FLAG_8)) { Math_StepToF(&this->skelAnimeUpperBlendWeight, 0.0f, 0.25f); - AnimationContext_SetInterp(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnimeUpper.jointTable, 1.0f - this->skelAnimeUpperBlendWeight); + AnimTaskQueue_AddInterp(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + this->skelAnimeUpper.jointTable, 1.0f - this->skelAnimeUpperBlendWeight); } } else if ((func_8082ED94(this) == 0) || (this->linearVelocity != 0.0f) || (this->skelAnime.moveFlags & ANIM_FLAG_8)) { - AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnimeUpper.jointTable, sPlayerUpperBodyLimbCopyMap); + AnimTaskQueue_AddCopyUsingMap(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + this->skelAnimeUpper.jointTable, sPlayerUpperBodyLimbCopyMap); } else { - AnimationContext_SetCopyAll(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnimeUpper.jointTable); + AnimTaskQueue_AddCopy(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + this->skelAnimeUpper.jointTable); } return true; @@ -5989,7 +5989,7 @@ s32 Player_ActionChange_12(Player* this, PlayState* play) { this->actor.bgCheckFlags |= BGCHECKFLAG_GROUND; PlayerAnimation_PlayOnceSetSpeed(play, &this->skelAnime, anim, 1.3f); - AnimationContext_DisableQueue(play); + AnimTaskQueue_DisableTransformTasksForGroup(play); this->actor.shape.rot.y = this->currentYaw = this->actor.wallYaw + 0x8000; return true; } @@ -12240,9 +12240,8 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { Player_UpdateCamAndSeqModes(play, this); if (this->skelAnime.moveFlags & ANIM_FLAG_8) { - AnimationContext_SetMoveActor(play, &this->actor, &this->skelAnime, - (this->skelAnime.moveFlags & ANIM_FLAG_4) ? 1.0f - : this->ageProperties->unk_08); + AnimTaskQueue_AddActorMove(play, &this->actor, &this->skelAnime, + (this->skelAnime.moveFlags & ANIM_FLAG_4) ? 1.0f : this->ageProperties->unk_08); } func_80832578(this, play); @@ -12366,7 +12365,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { } } - AnimationContext_SetNextQueue(play); + AnimTaskQueue_SetNextGroup(play); } func_801229FC(this); @@ -14160,10 +14159,10 @@ void Player_Action_10(Player* this, PlayState* play) { PlayerAnimation_Update(play, &this->skelAnime); if (Player_IsHoldingTwoHandedWeapon(this)) { - AnimationContext_SetLoadFrame(play, func_8082ED20(this), 0, this->skelAnime.limbCount, - this->skelAnime.morphTable); - AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnime.morphTable, sPlayerUpperBodyLimbCopyMap); + AnimTaskQueue_AddLoadPlayerFrame(play, func_8082ED20(this), 0, this->skelAnime.limbCount, + this->skelAnime.morphTable); + AnimTaskQueue_AddCopyUsingMap(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + this->skelAnime.morphTable, sPlayerUpperBodyLimbCopyMap); } Player_GetMovementSpeedAndYaw(this, &speedTarget, &yawTarget, SPEED_MODE_CURVED, play); @@ -14729,7 +14728,7 @@ void Player_Action_25(Player* this, PlayState* play) { ((this->yDistToLedge < (150.0f * this->ageProperties->unk_08)) && (((this->actor.world.pos.y - this->actor.floorHeight) + this->yDistToLedge)) > (70.0f * this->ageProperties->unk_08))) { - AnimationContext_DisableQueue(play); + AnimTaskQueue_DisableTransformTasksForGroup(play); if (this->stateFlags3 & PLAYER_STATE3_10000) { Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_HOOKSHOT_HANG); } else { @@ -15576,8 +15575,8 @@ void Player_Action_44(Player* this, PlayState* play) { } } } - AnimationContext_SetCopyFalse(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnimeUpper.jointTable, sPlayerUpperBodyLimbCopyMap); + AnimTaskQueue_AddCopyUsingMapInverted(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + this->skelAnimeUpper.jointTable, sPlayerUpperBodyLimbCopyMap); } else if (!(this->stateFlags1 & PLAYER_STATE1_800) && (this->skelAnime.animation == &gPlayerAnim_link_normal_talk_free_wait)) { s32 temp_v0 = this->actor.focus.rot.y - this->actor.shape.rot.y; @@ -16117,8 +16116,7 @@ void Player_Action_52(Player* this, PlayState* play) { PlayerAnimation_AnimateFrame(play, &this->skelAnime); } - AnimationContext_SetCopyAll(play, this->skelAnime.limbCount, this->skelAnime.morphTable, - this->skelAnime.jointTable); + AnimTaskQueue_AddCopy(play, this->skelAnime.limbCount, this->skelAnime.morphTable, this->skelAnime.jointTable); if ((play->csCtx.state != CS_STATE_IDLE) || (this->csAction != PLAYER_CSACTION_NONE)) { this->unk_AA5 = PLAYER_UNKAA5_0; @@ -16149,16 +16147,16 @@ void Player_Action_52(Player* this, PlayState* play) { Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_LASH); } - AnimationContext_SetCopyAll(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnimeUpper.jointTable); + AnimTaskQueue_AddCopy(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + this->skelAnimeUpper.jointTable); } else { if (PlayerAnimation_OnFrame(&this->skelAnimeUpper, 10.0f)) { Player_PlaySfx(this, NA_SE_IT_LASH); Player_AnimSfx_PlayVoice(this, NA_SE_VO_LI_LASH); } - AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnimeUpper.jointTable, sPlayerUpperBodyLimbCopyMap); + AnimTaskQueue_AddCopyUsingMap(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + this->skelAnimeUpper.jointTable, sPlayerUpperBodyLimbCopyMap); } } else if (!CHECK_FLAG_ALL(this->actor.flags, 0x100)) { PlayerAnimationHeader* anim = NULL; @@ -16736,10 +16734,10 @@ void func_80851F18(PlayState* play, Player* this) { i = 0; temp_v0 = &this->unk_B10[this->unk_B86[i]]; - AnimationContext_SetLoadFrame(play, temp->unk_4, *temp_v0, this->skelAnime.limbCount, - this->skelAnime.morphTable); - AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - this->skelAnime.morphTable, D_8085BA08); + AnimTaskQueue_AddLoadPlayerFrame(play, temp->unk_4, *temp_v0, this->skelAnime.limbCount, + this->skelAnime.morphTable); + AnimTaskQueue_AddCopyUsingMap(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + this->skelAnime.morphTable, D_8085BA08); } i = this->unk_B86[1]; if (i >= 0) { @@ -16747,10 +16745,10 @@ void func_80851F18(PlayState* play, Player* this) { i = 1; temp_v0 = &this->unk_B10[this->unk_B86[i]]; - AnimationContext_SetLoadFrame(play, temp->unk_4, *temp_v0, this->skelAnime.limbCount, - (void*)ALIGN16((uintptr_t)this->blendTableBuffer)); - AnimationContext_SetCopyTrue(play, this->skelAnime.limbCount, this->skelAnime.jointTable, - (void*)ALIGN16((uintptr_t)this->blendTableBuffer), D_8085BA20); + AnimTaskQueue_AddLoadPlayerFrame(play, temp->unk_4, *temp_v0, this->skelAnime.limbCount, + (void*)ALIGN16((uintptr_t)this->blendTableBuffer)); + AnimTaskQueue_AddCopyUsingMap(play, this->skelAnime.limbCount, this->skelAnime.jointTable, + (void*)ALIGN16((uintptr_t)this->blendTableBuffer), D_8085BA20); } temp_v0 = this->unk_B10; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index fa5ee19ec8..bc9b7f95cd 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2541,23 +2541,23 @@ 0x801353F8:("Animation_GetLengthLegacy",), 0x8013541C:("Animation_GetLastFrameLegacy",), 0x80135448:("SkelAnime_InterpFrameTable",), - 0x801358C8:("AnimationContext_Reset",), - 0x801358D4:("AnimationContext_SetNextQueue",), - 0x801358F4:("AnimationContext_DisableQueue",), - 0x8013591C:("AnimationContext_AddEntry",), - 0x80135954:("AnimationContext_SetLoadFrame",), - 0x80135A28:("AnimationContext_SetCopyAll",), - 0x80135A90:("AnimationContext_SetInterp",), - 0x80135B00:("AnimationContext_SetCopyTrue",), - 0x80135B70:("AnimationContext_SetCopyFalse",), - 0x80135BE0:("AnimationContext_SetMoveActor",), - 0x80135C3C:("AnimationContext_LoadFrame",), - 0x80135C6C:("AnimationContext_CopyAll",), - 0x80135CDC:("AnimationContext_Interp",), - 0x80135D38:("AnimationContext_CopyTrue",), - 0x80135DB8:("AnimationContext_CopyFalse",), - 0x80135E3C:("AnimationContext_MoveActor",), - 0x80135EE8:("AnimationContext_Update",), + 0x801358C8:("AnimTaskQueue_Reset",), + 0x801358D4:("AnimTaskQueue_SetNextGroup",), + 0x801358F4:("AnimTaskQueue_DisableTransformTasksForGroup",), + 0x8013591C:("AnimTaskQueue_NewTask",), + 0x80135954:("AnimTaskQueue_AddLoadPlayerFrame",), + 0x80135A28:("AnimTaskQueue_AddCopy",), + 0x80135A90:("AnimTaskQueue_AddInterp",), + 0x80135B00:("AnimTaskQueue_AddCopyUsingMap",), + 0x80135B70:("AnimTaskQueue_AddCopyUsingMapInverted",), + 0x80135BE0:("AnimTaskQueue_AddActorMove",), + 0x80135C3C:("AnimTask_LoadPlayerFrame",), + 0x80135C6C:("AnimTask_Copy",), + 0x80135CDC:("AnimTask_Interp",), + 0x80135D38:("AnimTask_CopyUsingMap",), + 0x80135DB8:("AnimTask_CopyUsingMapInverted",), + 0x80135E3C:("AnimTask_ActorMove",), + 0x80135EE8:("AnimTaskQueue_Update",), 0x80135F88:("SkelAnime_InitPlayer",), 0x801360A8:("PlayerAnimation_SetUpdateFunction",), 0x801360E0:("PlayerAnimation_Update",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 80294f706d..cd18689662 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -3912,8 +3912,8 @@ 0x801F5AA0:("sMatAnimStep","s32","",0x4), 0x801F5AA4:("sMatAnimFlags","u32","",0x4), 0x801F5AA8:("sMatAnimAlphaRatio","f32","",0x4), - 0x801F5AB0:("sAnimQueueFlags","UNK_TYPE1","",0x1), - 0x801F5AB4:("sDisableAnimQueueFlags","UNK_TYPE1","",0x1), + 0x801F5AB0:("sCurAnimTaskGroup","UNK_TYPE1","",0x1), + 0x801F5AB4:("sDisabledTransformTaskGroups","UNK_TYPE1","",0x1), 0x801F5AC0:("gSkinLimbMatrices","MtxF","[60]",0xF00), 0x801F69C0:("D_801F69C0","UNK_TYPE1","",0x10), 0x801F69D0:("gRumbleMgr","RumbleManager","",0x10E), diff --git a/tools/namefixer.py b/tools/namefixer.py index 33ff23755d..ecc918f90b 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -247,10 +247,10 @@ wordReplace = { "SkelAnime_GetFrameCount": "Animation_GetLastFrame", "SkelAnime_Draw2": "SkelAnime_Draw", "SkelAnime_DrawSV2": "SkelAnime_DrawFlex", - "SkelAnime_AnimationCtxReset": "AnimationContext_Reset", - "func_801358D4": "AnimationContext_SetNextQueue", - "func_801358F4": "AnimationContext_DisableQueue", - "SkelAnime_LoadLinkAnimetion": "AnimationContext_SetLoadFrame", + "SkelAnime_AnimationCtxReset": "AnimTaskQueue_Reset", + "func_801358D4": "AnimTaskQueue_SetNextGroup", + "func_801358F4": "AnimTaskQueue_DisableTransformTasksForGroup", + "SkelAnime_LoadLinkAnimetion": "AnimTaskQueue_AddLoadPlayerFrame", "play_sound": "Audio_PlaySfx", "func_8019F128": "Audio_PlaySfx_2", "func_8019F170": "Audio_PlaySfx_AtPosWithPresetLowFreqAndHighReverb", @@ -295,12 +295,12 @@ wordReplace = { "func_801000CC": "Lib_PlaySfx_2", "Lib_PlaySfxAtPos": "Lib_PlaySfx_AtPos", - "SkelAnime_AnimationType1Loaded": "AnimationContext_CopyAll", - "SkelAnime_AnimationType2Loaded": "AnimationContext_CopyInterp", - "SkelAnime_AnimationType3Loaded": "AnimationContext_CopyTrue", - "SkelAnime_AnimationType4Loaded": "AnimationContext_CopyFalse", - "SkelAnime_AnimationType5Loaded": "AnimationContext_MoveActor", - "func_80135EE8": "AnimationContext_Update", + "SkelAnime_AnimationType1Loaded": "AnimTask_Copy", + "SkelAnime_AnimationType2Loaded": "AnimTask_Interp", + "SkelAnime_AnimationType3Loaded": "AnimTask_CopyUsingMap", + "SkelAnime_AnimationType4Loaded": "AnimTask_CopyUsingMapInverted", + "SkelAnime_AnimationType5Loaded": "AnimTask_ActorMove", + "func_80135EE8": "AnimTaskQueue_Update", "SkelAnime_InitLink": "SkelAnime_InitPlayer", "LinkAnimation_SetUpdateFunction": "PlayerAnimation_SetUpdateFunction", "LinkAnimation_Update": "PlayerAnimation_Update", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 07d0834626..0bbb7ee4c6 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2055,23 +2055,23 @@ asm/non_matchings/code/z_skelanime/Animation_GetLimbCountLegacy.s,Animation_GetL asm/non_matchings/code/z_skelanime/SkelAnime_GetTotalFrames2.s,SkelAnime_GetTotalFrames2,0x801353F8,0x9 asm/non_matchings/code/z_skelanime/SkelAnime_GetFrameCount2.s,SkelAnime_GetFrameCount2,0x8013541C,0xB asm/non_matchings/code/z_skelanime/SkelAnime_InterpFrameTable.s,SkelAnime_InterpFrameTable,0x80135448,0x120 -asm/non_matchings/code/z_skelanime/AnimationContext_Reset.s,AnimationContext_Reset,0x801358C8,0x3 -asm/non_matchings/code/z_skelanime/AnimationContext_SetNextQueue.s,AnimationContext_SetNextQueue,0x801358D4,0x8 -asm/non_matchings/code/z_skelanime/AnimationContext_DisableQueue.s,AnimationContext_DisableQueue,0x801358F4,0xA -asm/non_matchings/code/z_skelanime/AnimationContext_AddEntry.s,AnimationContext_AddEntry,0x8013591C,0xE -asm/non_matchings/code/z_skelanime/AnimationContext_SetLoadFrame.s,AnimationContext_SetLoadFrame,0x80135954,0x35 -asm/non_matchings/code/z_skelanime/AnimationContext_SetCopyAll.s,AnimationContext_SetCopyAll,0x80135A28,0x1A -asm/non_matchings/code/z_skelanime/AnimationContext_SetInterp.s,AnimationContext_SetInterp,0x80135A90,0x1C -asm/non_matchings/code/z_skelanime/AnimationContext_SetCopyTrue.s,AnimationContext_SetCopyTrue,0x80135B00,0x1C -asm/non_matchings/code/z_skelanime/AnimationContext_SetCopyFalse.s,AnimationContext_SetCopyFalse,0x80135B70,0x1C -asm/non_matchings/code/z_skelanime/AnimationContext_SetMoveActor.s,AnimationContext_SetMoveActor,0x80135BE0,0x17 -asm/non_matchings/code/z_skelanime/AnimationContext_LoadFrame.s,AnimationContext_LoadFrame,0x80135C3C,0xC -asm/non_matchings/code/z_skelanime/AnimationContext_CopyAll.s,AnimationContext_CopyAll,0x80135C6C,0x1C -asm/non_matchings/code/z_skelanime/AnimationContext_CopyInterp.s,AnimationContext_CopyInterp,0x80135CDC,0x17 -asm/non_matchings/code/z_skelanime/AnimationContext_CopyTrue.s,AnimationContext_CopyTrue,0x80135D38,0x20 -asm/non_matchings/code/z_skelanime/AnimationContext_CopyFalse.s,AnimationContext_CopyFalse,0x80135DB8,0x21 -asm/non_matchings/code/z_skelanime/AnimationContext_MoveActor.s,AnimationContext_MoveActor,0x80135E3C,0x2B -asm/non_matchings/code/z_skelanime/AnimationContext_Update.s,AnimationContext_Update,0x80135EE8,0x28 +asm/non_matchings/code/z_skelanime/AnimTaskQueue_Reset.s,AnimTaskQueue_Reset,0x801358C8,0x3 +asm/non_matchings/code/z_skelanime/AnimTaskQueue_SetNextGroup.s,AnimTaskQueue_SetNextGroup,0x801358D4,0x8 +asm/non_matchings/code/z_skelanime/AnimTaskQueue_DisableTransformTasksForGroup.s,AnimTaskQueue_DisableTransformTasksForGroup,0x801358F4,0xA +asm/non_matchings/code/z_skelanime/AnimTaskQueue_NewTask.s,AnimTaskQueue_NewTask,0x8013591C,0xE +asm/non_matchings/code/z_skelanime/AnimTaskQueue_AddLoadPlayerFrame.s,AnimTaskQueue_AddLoadPlayerFrame,0x80135954,0x35 +asm/non_matchings/code/z_skelanime/AnimTaskQueue_AddCopy.s,AnimTaskQueue_AddCopy,0x80135A28,0x1A +asm/non_matchings/code/z_skelanime/AnimTaskQueue_AddInterp.s,AnimTaskQueue_AddInterp,0x80135A90,0x1C +asm/non_matchings/code/z_skelanime/AnimTaskQueue_AddCopyUsingMap.s,AnimTaskQueue_AddCopyUsingMap,0x80135B00,0x1C +asm/non_matchings/code/z_skelanime/AnimTaskQueue_AddCopyUsingMapInverted.s,AnimTaskQueue_AddCopyUsingMapInverted,0x80135B70,0x1C +asm/non_matchings/code/z_skelanime/AnimTaskQueue_AddActorMove.s,AnimTaskQueue_AddActorMove,0x80135BE0,0x17 +asm/non_matchings/code/z_skelanime/AnimTask_LoadPlayerFrame.s,AnimTask_LoadPlayerFrame,0x80135C3C,0xC +asm/non_matchings/code/z_skelanime/AnimTask_Copy.s,AnimTask_Copy,0x80135C6C,0x1C +asm/non_matchings/code/z_skelanime/AnimTask_Interp.s,AnimTask_Interp,0x80135CDC,0x17 +asm/non_matchings/code/z_skelanime/AnimTask_CopyUsingMap.s,AnimTask_CopyUsingMap,0x80135D38,0x20 +asm/non_matchings/code/z_skelanime/AnimTask_CopyUsingMapInverted.s,AnimTask_CopyUsingMapInverted,0x80135DB8,0x21 +asm/non_matchings/code/z_skelanime/AnimTask_ActorMove.s,AnimTask_ActorMove,0x80135E3C,0x2B +asm/non_matchings/code/z_skelanime/AnimTaskQueue_Update.s,AnimTaskQueue_Update,0x80135EE8,0x28 asm/non_matchings/code/z_skelanime/SkelAnime_InitPlayerAnimetion.s,SkelAnime_InitPlayerAnimetion,0x80135F88,0x48 asm/non_matchings/code/z_skelanime/PlayerAnimation_SetUpdateFunction.s,PlayerAnimation_SetUpdateFunction,0x801360A8,0xE asm/non_matchings/code/z_skelanime/PlayerAnimation_Update.s,PlayerAnimation_Update,0x801360E0,0x9