diff --git a/include/z64.h b/include/z64.h index 25cd7a8d8b..78ba63b3c8 100644 --- a/include/z64.h +++ b/include/z64.h @@ -27,6 +27,7 @@ #include "sys_matrix.h" #include "z64actor.h" #include "z64animation.h" +#include "z64animation_legacy.h" #include "z64audio.h" #include "z64bgcheck.h" #include "z64camera.h" diff --git a/include/z64animation.h b/include/z64animation.h index 3e4ac8eaea..1319be5fc9 100644 --- a/include/z64animation.h +++ b/include/z64animation.h @@ -11,10 +11,7 @@ struct Actor; struct SkelAnime; struct PlayerAnimationFrame; -#define LINK_ANIMETION_OFFSET(addr, offset) \ - (SEGMENT_ROM_START(link_animetion) + ((uintptr_t)addr & 0xFFFFFF) + ((u32)offset)) #define LIMB_DONE 0xFF -#define ANIMATION_ENTRY_MAX 50 #define ANIM_FLAG_1 (1 << 0) #define ANIM_FLAG_UPDATEY (1 << 1) @@ -82,22 +79,6 @@ typedef struct { /* 0xC */ u16 staticIndexMax; } AnimationHeader; // size = 0x10 -typedef struct { - /* 0x00 */ s16 xMax; - /* 0x02 */ s16 x; - /* 0x04 */ s16 yMax; - /* 0x06 */ s16 y; - /* 0x08 */ s16 zMax; - /* 0x10 */ s16 z; -} JointKey; // size = 0x12 - -typedef struct { - /* 0x0 */ s16 frameCount; - /* 0x2 */ s16 limbCount; - /* 0x4 */ s16* frameData; - /* 0x8 */ JointKey* jointKey; -} LegacyAnimationHeader; // size = 0xC - typedef enum { /* 0 */ ANIMATION_LINKANIMETION, /* 1 */ ANIMENTRY_COPYALL, @@ -166,7 +147,7 @@ typedef struct { typedef struct AnimationContext { /* 0x000 */ s16 animationCount; - /* 0x004 */ AnimationEntry entries[ANIMATION_ENTRY_MAX]; + /* 0x004 */ AnimationEntry entries[50]; } AnimationContext; // size = 0xC84 typedef struct { @@ -331,11 +312,6 @@ 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); -s16 SkelAnime_GetFrameDataLegacy(LegacyAnimationHeader* animation, s32 frame, Vec3s* frameTable); -s16 Animation_GetLimbCount2(LegacyAnimationHeader* animation); -s16 Animation_GetLength2(LegacyAnimationHeader* animation); -s16 Animation_GetLastFrame2(LegacyAnimationHeader* animation); - void AnimationContext_Reset(AnimationContext* animationCtx); void AnimationContext_SetNextQueue(struct PlayState* play); void AnimationContext_DisableQueue(struct PlayState* play); diff --git a/include/z64animation_legacy.h b/include/z64animation_legacy.h new file mode 100644 index 0000000000..238939f747 --- /dev/null +++ b/include/z64animation_legacy.h @@ -0,0 +1,36 @@ +#ifndef Z64_ANIMATION_LEGACY_H +#define Z64_ANIMATION_LEGACY_H + +#include "ultra64.h" +#include "z64math.h" + +typedef struct LegacyLimb { + /* 0x00 */ Gfx* dList; + /* 0x04 */ Vec3f trans; + /* 0x10 */ Vec3s rot; + /* 0x18 */ struct LegacyLimb* sibling; + /* 0x1C */ struct LegacyLimb* child; +} LegacyLimb; // size = 0x20 + +typedef struct { + /* 0x00 */ s16 xMax; + /* 0x02 */ s16 x; + /* 0x04 */ s16 yMax; + /* 0x06 */ s16 y; + /* 0x08 */ s16 zMax; + /* 0x10 */ s16 z; +} LegacyJointKey; // size = 0x12 + +typedef struct { + /* 0x0 */ s16 frameCount; + /* 0x2 */ s16 limbCount; + /* 0x4 */ s16* frameData; + /* 0x8 */ LegacyJointKey* jointKey; +} LegacyAnimationHeader; // size = 0xC + +s16 SkelAnime_GetFrameDataLegacy(LegacyAnimationHeader* animation, s32 frame, Vec3s* frameTable); +s16 Animation_GetLimbCountLegacy(LegacyAnimationHeader* animation); +s16 Animation_GetLengthLegacy(LegacyAnimationHeader* animation); +s16 Animation_GetLastFrameLegacy(LegacyAnimationHeader* animation); + +#endif diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index c486b254bc..4affb11b8e 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -881,7 +881,7 @@ Gfx* SkelAnime_DrawFlex(PlayState* play, void** skeleton, Vec3s* jointTable, s32 s16 SkelAnime_GetFrameDataLegacy(LegacyAnimationHeader* animation, s32 frame, Vec3s* frameTable) { LegacyAnimationHeader* animHeader = Lib_SegmentedToVirtual(animation); s16 limbCount = animHeader->limbCount; - JointKey* key = Lib_SegmentedToVirtual(animHeader->jointKey); + LegacyJointKey* key = Lib_SegmentedToVirtual(animHeader->jointKey); s16* frameData = Lib_SegmentedToVirtual(animHeader->frameData); s16* staticData = &frameData[0]; s16* dynamicData = &frameData[frame]; @@ -906,7 +906,7 @@ s16 SkelAnime_GetFrameDataLegacy(LegacyAnimationHeader* animation, s32 frame, Ve /** * Used by legacy animation format */ -s16 Animation_GetLimbCount2(LegacyAnimationHeader* animation) { +s16 Animation_GetLimbCountLegacy(LegacyAnimationHeader* animation) { LegacyAnimationHeader* animHeader = Lib_SegmentedToVirtual(animation); return animHeader->limbCount; @@ -915,7 +915,7 @@ s16 Animation_GetLimbCount2(LegacyAnimationHeader* animation) { /** * Used by legacy animation format */ -s16 Animation_GetLength2(LegacyAnimationHeader* animation) { +s16 Animation_GetLengthLegacy(LegacyAnimationHeader* animation) { LegacyAnimationHeader* animHeader = Lib_SegmentedToVirtual(animation); return animHeader->frameCount; @@ -924,7 +924,7 @@ s16 Animation_GetLength2(LegacyAnimationHeader* animation) { /** * Used by legacy animation format */ -s16 Animation_GetLastFrame2(LegacyAnimationHeader* animation) { +s16 Animation_GetLastFrameLegacy(LegacyAnimationHeader* animation) { AnimationHeaderCommon* animHeader = Lib_SegmentedToVirtual(animation); return animHeader->frameCount - 1; @@ -984,7 +984,7 @@ AnimationEntry* AnimationContext_AddEntry(AnimationContext* animationCtx, Animat AnimationEntry* entry; s16 index = animationCtx->animationCount; - if (index >= ANIMATION_ENTRY_MAX) { + if (index >= ARRAY_COUNT(animationCtx->entries)) { return NULL; } @@ -994,6 +994,9 @@ AnimationEntry* AnimationContext_AddEntry(AnimationContext* animationCtx, Animat return entry; } +#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 */ @@ -1003,13 +1006,13 @@ void AnimationContext_SetLoadFrame(PlayState* play, PlayerAnimationHeader* anima if (entry != NULL) { PlayerAnimationHeader* playerAnimHeader = Lib_SegmentedToVirtual(animation); - uintptr_t ram = frameTable; + void* ram = (void*)frameTable; osCreateMesgQueue(&entry->data.load.msgQueue, entry->data.load.msg, ARRAY_COUNT(entry->data.load.msg)); DmaMgr_SendRequestImpl( &entry->data.load.req, ram, - LINK_ANIMETION_OFFSET(playerAnimHeader->segment, (sizeof(Vec3s) * limbCount + 2) * frame), - sizeof(Vec3s) * limbCount + 2, 0, &entry->data.load.msgQueue, NULL); + LINK_ANIMETION_OFFSET(playerAnimHeader->segment, (sizeof(Vec3s) * limbCount + sizeof(s16)) * frame), + sizeof(Vec3s) * limbCount + sizeof(s16), 0, &entry->data.load.msgQueue, NULL); } } diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index a8c912e2af..f33d4f0801 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -2537,9 +2537,9 @@ 0x80134B54:("SkelAnime_DrawFlexLimb",), 0x80134DBC:("SkelAnime_DrawFlex",), 0x80134FFC:("SkelAnime_GetFrameDataLegacy",), - 0x801353D4:("Animation_GetLimbCount2",), - 0x801353F8:("Animation_GetLength2",), - 0x8013541C:("Animation_GetLastFrame2",), + 0x801353D4:("Animation_GetLimbCountLegacy",), + 0x801353F8:("Animation_GetLengthLegacy",), + 0x8013541C:("Animation_GetLastFrameLegacy",), 0x80135448:("SkelAnime_InterpFrameTable",), 0x801358C8:("AnimationContext_Reset",), 0x801358D4:("AnimationContext_SetNextQueue",), diff --git a/tools/namefixer.py b/tools/namefixer.py index e86b31dc5a..37a3c8fee6 100755 --- a/tools/namefixer.py +++ b/tools/namefixer.py @@ -172,10 +172,6 @@ wordReplace = { "SkelAnime_GetFrameCount": "Animation_GetLastFrame", "SkelAnime_Draw2": "SkelAnime_Draw", "SkelAnime_DrawSV2": "SkelAnime_DrawFlex", - "func_80134FFC": "SkelAnime_GetFrameData2", - "func_801353D4": "Animation_GetLimbCount2", - "SkelAnime_GetTotalFrames2": "Animation_GetLength2", - "SkelAnime_GetFrameCount2": "Animation_GetLastFrame2", "SkelAnime_AnimationCtxReset": "AnimationContext_Reset", "func_801358D4": "AnimationContext_SetNextQueue", "func_801358F4": "AnimationContext_DisableQueue", diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index cf20b9ecd6..222c34b7a2 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -2051,7 +2051,7 @@ asm/non_matchings/code/z_skelanime/SkelAnime_Draw.s,SkelAnime_Draw,0x80134990,0x asm/non_matchings/code/z_skelanime/SkelAnime_DrawLimbSV2.s,SkelAnime_DrawLimbSV2,0x80134B54,0x9A asm/non_matchings/code/z_skelanime/SkelAnime_DrawFlex.s,SkelAnime_DrawFlex,0x80134DBC,0x90 asm/non_matchings/code/z_skelanime/SkelAnime_GetFrameData2.s,SkelAnime_GetFrameData2,0x80134FFC,0xF6 -asm/non_matchings/code/z_skelanime/Animation_GetLimbCount2.s,Animation_GetLimbCount2,0x801353D4,0x9 +asm/non_matchings/code/z_skelanime/Animation_GetLimbCountLegacy.s,Animation_GetLimbCountLegacy,0x801353D4,0x9 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