1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-14 05:19:36 +00:00

skelanime WIP

This commit is contained in:
KrimtonZ 2020-03-22 20:24:00 -05:00
parent 7bf1c2fb50
commit 2a158f79ce
8 changed files with 578 additions and 334 deletions

View file

@ -1123,7 +1123,7 @@ void func_800A1AC8(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab
s32 SkelAnime_GetFrameCount(u32 animation); s32 SkelAnime_GetFrameCount(u32 animation);
// ? func_800A2044(?); // ? func_800A2044(?);
// ? func_800A24A0(?); // ? func_800A24A0(?);
Gfx* func_800A273C(GlobalContext* globalCtx, u32 limbIndex, u32 adt, u8 limbDListCnt, void* internal0, void* internal1, Actor* actor, Gfx* gfx); Gfx* func_800A273C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, s32 arg3, SkelAnime_LimbUpdateMatrix2 arg4, SkelAnime_LimbAppendDlist2 arg5, Actor* arg6, Gfx *arg7);
// ? func_800A2E70(?); // ? func_800A2E70(?);
// ? func_800A32EC(?); // ? func_800A32EC(?);
// ? func_800A3334(?); // ? func_800A3334(?);

View file

@ -11,6 +11,8 @@
#include <z64scene.h> #include <z64scene.h>
#include <z64effect.h> #include <z64effect.h>
#include <z64item.h> #include <z64item.h>
#include <z64animation.h>
#include <z64dma.h>
#include <bgm.h> #include <bgm.h>
#include <sfx.h> #include <sfx.h>
#include <color.h> #include <color.h>
@ -530,18 +532,6 @@ typedef struct
/* 0xE40E */ char unk_E40E[0x0A]; /* 0xE40E */ char unk_E40E[0x0A];
} MessageContext; // size = 0xE418 } MessageContext; // size = 0xE418
typedef struct
{
/* 0x00 */ u32 vromAddr; // VROM address (source)
/* 0x04 */ void* dramAddr; // DRAM address (destination)
/* 0x08 */ u32 size; // File Transfer size
/* 0x0C */ char* filename; // Filename for debugging
/* 0x10 */ s32 line; // Line for debugging
/* 0x14 */ s32 unk_14;
/* 0x18 */ OSMesgQueue* notifyQueue; // Message queue for the notification message
/* 0x1C */ OSMesg notifyMsg; // Completion notification message
} DmaRequest; // size = 0x20
typedef struct typedef struct
{ {
/* 0x0000 */ View view; /* 0x0000 */ View view;
@ -863,22 +853,6 @@ typedef struct
/* 0x01E2 */ char unk_1E2[6]; /* 0x01E2 */ char unk_1E2[6];
} TitleContext; // size = 0x1E8 } TitleContext; // size = 0x1E8
typedef struct
{
/* 0x000 */ u8 unk_00;
/* 0x001 */ char unk_01[3];
/* 0x004 */ char unk_04[0x20];
/* 0x024 */ OSMesgQueue msgQueue;
/* 0x03C */ OSMesg msg;
} AnimationEntry; // size = 0x40
typedef struct
{
s16 animationCount;
char unk_02[2];
AnimationEntry entries[0x32];
} AnimationContext;
// Global Context (dbg ram start: 80212020) // Global Context (dbg ram start: 80212020)
typedef struct GlobalContext typedef struct GlobalContext
{ {
@ -1036,46 +1010,6 @@ typedef struct LoadedParticleEntry
/* 0x005F */ u8 type; /* 0x005F */ u8 type;
} LoadedParticleEntry; // size = 0x60 } LoadedParticleEntry; // size = 0x60
typedef s32 (*SkelAnime_LimbUpdateMatrix)(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList,
Vec3f* pos, Vec3s* rot, Actor* actor);
typedef void (*SkelAnime_LimbAppendDlist)(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList,
Vec3s* rot, Actor* actor);
typedef struct
{
Vec3s pos;
u8 firstChildIndex;
u8 nextLimbIndex;
Gfx* displayLists[1]; // maybe?
} SkelLimbEntry;
typedef struct SkelAnime
{
/* 0x00 */ u8 limbCount;
/* 0x01 */ u8 unk_01;
/* 0x02 */ u8 dListCount;
/* 0x03 */ s8 unk_03;
/* 0x04 */ u32 limbIndex;
/* 0x08 */ u32 animCurrent;
/* 0x0C */ f32 unk_0C;
/* 0x10 */ f32 animFrameCount;
/* 0x14 */ f32 unk_14;
/* 0x18 */ f32 animCurrentFrame;
/* 0x1C */ f32 animPlaybackSpeed;
/* 0x20 */ u32 actorDrawTbl;
/* 0x24 */ u32 unk_24;
/* 0x28 */ u32 unk_28;
/* 0x2C */ u32 unk_2C;
/* 0x30 */ void* funcUnk30; /* Some function pointer */
/* 0x34 */ s32 unk_34;
/* 0x38 */ s32 unk_38;
/* 0x3C */ u16 unk_3C;
/* 0x3E */ u16 unk_3E;
/* 0x40 */ u16 unk_40;
/* 0x42 */ u16 unk_42;
} SkelAnime; // size = 0x44
typedef struct typedef struct
{ {
/* 0x00 */ u32 unk_00; /* 0x00 */ u32 unk_00;
@ -1300,14 +1234,6 @@ typedef struct
/* 0x20 */ u8 data[0x10000-0x20]; /* 0x20 */ u8 data[0x10000-0x20];
} ISVDbg; } ISVDbg;
typedef struct
{
/* 0x00 */ u32 vromStart;
/* 0x04 */ u32 vromEnd;
/* 0x08 */ u32 romStart;
/* 0x0C */ u32 romEnd;
} DmaEntry;
typedef struct typedef struct
{ {
char name[0x18]; char name[0x18];

205
include/z64animation.h Executable file
View file

@ -0,0 +1,205 @@
#ifndef _Z64_ANIMATION_H
#define _Z64_ANIMATION_H
#include <ultra64.h>
#include <ultra64/gbi.h>
#include <z64dma.h>
struct GlobalContext;
struct Actor;
typedef s32 (*SkelAnime_LimbUpdateMatrix)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList,
Vec3f* pos, Vec3s* rot, struct Actor* actor);
typedef void (*SkelAnime_LimbAppendDlist)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList,
Vec3s* rot, struct Actor* actor);
typedef s32 (*SkelAnime_LimbUpdateMatrix2)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList,
Vec3f* pos, Vec3s* rot, struct Actor* actor, Gfx** gfx);
typedef void (*SkelAnime_LimbAppendDlist2)(struct GlobalContext* globalCtx, s32 limbIndex, Gfx** dList,
Vec3s* rot, struct Actor* actor, Gfx** gfx);
typedef struct
{
/* 0x000 */ u32 limbs[1]; // One ore more limbs, index 0 is the root limb.
} SkelLimbTable; // Size >= 4
typedef struct
{
/* 0x000 */ Vec3s translation; // Translation relative to parent limb. root limb is a tranlation for entire model.
/* 0x006 */ u8 firstChildIndex; // The first child's index into the limb table.
/* 0x007 */ u8 nextLimbIndex; // The parent limb's next limb index into the limb table.
/* 0x008 */ Gfx* displayLists[1]; // Display lists for the limb. Index 0 is the normal display list, index 1 is the far model display list.
} SkelLimbEntry; // Size = 0xC or 0x10
typedef struct
{
u32 limbIndexSeg; // Segment address of SkelLimbIndex.
u8 limbCount; // Number of limbs in the model.
char pad[3]; // Padding.
u8 dListCount; // Number of display lists in the model.
char pad2[3]; // Padding.
} SkelAnimeLimbHeader; // Size = 0xC
typedef struct SkelAnime
{
/* 0x00 */ u8 limbCount; // joint_Num
/* 0x01 */ u8 unk_01; // state? 00 = loop 02 = don't loop ?
/* 0x02 */ u8 dListCount;
/* 0x03 */ s8 unk_03;
/* 0x04 */ u32 limbIndex;
/* 0x08 */ u32 animCurrent;
/* 0x0C */ f32 unk_0C;
/* 0x10 */ f32 animFrameCount; // ending frame?
/* 0x14 */ f32 unk_14; // Loop frame?
/* 0x18 */ f32 animCurrentFrame;
/* 0x1C */ f32 animPlaybackSpeed;
/* 0x20 */ Vec3s* actorDrawTbl; // now_joint
/* 0x24 */ Vec3s* unk_24; // morf_joint
/* 0x28 */ f32 unk_28;
/* 0x2C */ f32 unk_2C;
/* 0x30 */ s32 (*animUpdate)();
/* 0x34 */ s8 unk_34;
/* 0x35 */ u8 unk_35; // flags
/* 0x36 */ s16 unk_36;
/* 0x38 */ s16 unk_38;
/* 0x3A */ s16 unk_3A;
/* 0x3C */ s16 unk_3C;
/* 0x3E */ s16 unk_3E;
/* 0x40 */ s16 unk_40;
/* 0x42 */ s16 unk_42;
} SkelAnime; // size = 0x44
typedef s16 AnimationRotationValue;
typedef struct
{
u16 x;
u16 y;
u16 z;
} AnimationRotationIndex;
typedef struct
{
/* 0x000 */ s16 frameCount;
/* 0x002 */ char pad[2];
/* 0x004 */ u32 rotationValueSeg; // tbl
/* 0x008 */ u32 rotationIndexSeg; //ref_tbl
/* 0x00C */ u16 limit;
/* 0x00E */ char pad2[2];
} AnimationHeader; // size = 0x10
typedef enum {
ANIMATION_TYPE0,
ANIMATION_TYPE1,
ANIMATION_TYPE2,
ANIMATION_TYPE3,
ANIMATION_TYPE4,
ANIMATION_TYPE5,
} AnimationType;
typedef struct
{
DmaRequest req;
OSMesgQueue msgQueue;
OSMesg msg;
} AnimationEntryType0;
typedef struct
{
u8 unk_00;
u8 vecCount;
char pad[2];
Vec3s* dst;
Vec3s* src;
char unk_0C[0x30];
} AnimationEntryType1;
typedef struct
{
u8 unk_00;
u8 unk_01;
char pad[2];
Vec3s* unk_04;
Vec3s* unk_08;
f32 unk_0C;
char unk_10[0x2C];
} AnimationEntryType2;
typedef struct
{
u8 unk_00;
u8 vecCount;
char pad[2];
Vec3s* dst;
Vec3s* src;
u8* index;
char unk_10[0x2C];
} AnimationEntryType3;
typedef struct
{
u8 unk_00;
u8 vecCount;
char unk_02[0x2];
Vec3s* dst;
Vec3s* src;
u8* index;
char unk_10[0x2C];
} AnimationEntryType4;
typedef struct
{
struct Actor* actor;
SkelAnime* skelAnime;
f32 unk_08;
char unk_0C[0x30];
} AnimationEntryType5;
typedef struct
{
u8 raw[0x3C];
} AnimationEntryRaw;
typedef union
{
AnimationEntryRaw raw;
AnimationEntryType0 type0;
AnimationEntryType1 type1;
AnimationEntryType2 type2;
AnimationEntryType3 type3;
AnimationEntryType4 type4;
AnimationEntryType5 type5;
} AnimationEntryType;
typedef struct
{
/* 0x000 */ u8 type;
/* 0x001 */ u8 unk_01;
/* 0x002 */ char pad[2];
/* 0x004 */ AnimationEntryType types;
} AnimationEntry; // size = 0x40
typedef struct AnimationContext
{
s16 animationCount;
char unk_02[2];
AnimationEntry entries[0x32];
} AnimationContext;
typedef struct
{
u16 frameCount;
char pad[2];
u32 animationSegAddress;
} LinkAnimetionEntry;
#endif
extern u32 link_animetion_segment; // 0x07000000
#define LINK_ANIMETION_OFFSET(addr,offset) (((u32)&_link_animetionSegmentRomStart)+((u32)addr)-((u32)&link_animetion_segment)+((u32)offset))
#define LIMB_DONE 0xFF
#define LOG(file,line,msg,arg) LogUtils_LogThreadId(file, line); osSyncPrintf(msg, arg)

25
include/z64dma.h Executable file
View file

@ -0,0 +1,25 @@
#ifndef _Z64_DMA_H_
#define _Z64_DMA_H_
#include <ultra64.h>
typedef struct
{
/* 0x00 */ u32 vromAddr; // VROM address (source)
/* 0x04 */ void* dramAddr; // DRAM address (destination)
/* 0x08 */ u32 size; // File Transfer size
/* 0x0C */ char* filename; // Filename for debugging
/* 0x10 */ s32 line; // Line for debugging
/* 0x14 */ s32 unk_14;
/* 0x18 */ OSMesgQueue* notifyQueue; // Message queue for the notification message
/* 0x1C */ OSMesg notifyMsg; // Completion notification message
} DmaRequest; // size = 0x20
typedef struct
{
/* 0x00 */ u32 vromStart;
/* 0x04 */ u32 vromEnd;
/* 0x08 */ u32 romStart;
/* 0x0C */ u32 romEnd;
} DmaEntry;
#endif

2
spec
View file

@ -367,8 +367,6 @@ beginseg
include "build/src/code/z_scene.o" include "build/src/code/z_scene.o"
include "build/src/code/z_scene_table.o" include "build/src/code/z_scene_table.o"
include "build/src/code/z_skelanime.o" include "build/src/code/z_skelanime.o"
include "build/data/z_skelanime.data.o"
include "build/data/z_skelanime.bss.o"
include "build/src/code/z_skin.o" include "build/src/code/z_skin.o"
include "build/data/z_skin.bss.o" include "build/data/z_skin.bss.o"
include "build/src/code/z_skin_awb.o" include "build/src/code/z_skin_awb.o"

View file

@ -6,26 +6,22 @@ void func_800A52F8(SkelAnime* skelAnime, u32 animation);
void func_800A54FC(SkelAnime*,Vec3f*,s16); void func_800A54FC(SkelAnime*,Vec3f*,s16);
s32 func_800A3D70(GlobalContext*,SkelAnime*); s32 func_800A3D70(GlobalContext*,SkelAnime*);
s32 func_800A3E0C(GlobalContext*,SkelAnime*); s32 func_800A3E0C(GlobalContext*,SkelAnime*);
void func_800A34DC(GlobalContext*,u8,Vec3s*,Vec3s*,f32); void func_800A34DC(GlobalContext*,s32,Vec3s*,Vec3s*,f32);
void func_800A336C(GlobalContext* globalCtx, s32 arg1, s32 arg2, s32 limbCount, void* ram); void func_800A336C(GlobalContext* globalCtx, u32 linkAnimetionSeg, s32 frame, s32 limbCount, void* ram);
s32 func_800A4D9C(SkelAnime* skelAnime); s32 func_800A4D9C(SkelAnime* skelAnime);
s32 func_800A4EE0(SkelAnime* skelAnime); s32 func_800A4EE0(SkelAnime* skelAnime);
s32 func_800A4E38(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_800A2E70(u8,Vec3s*,Vec3s*,Vec3s*,f32);
void func_800A49B0(SkelAnime*); void func_800A49B0(SkelAnime*);
void func_800A3478(GlobalContext*,s32,Vec3s*,Vec3s*);
typedef struct 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);
u32 limbIndexSeg; Gfx* func_800A24A0(GlobalContext*, u8, u32*, Vec3s*, SkelAnime_LimbUpdateMatrix2, SkelAnime_LimbAppendDlist2, Actor*, Mtx**, Gfx*);
u8 limbCount;
char unk_05[3];
u8 dListCount;
} SkelAnimeInit;
//.data //.data
static u32 D_8012A480 = 0; u32 D_8012A480 = 0;
typedef void (*testfunc)(GlobalContext*,char*); typedef void (*testfunc)(GlobalContext*, AnimationEntryType*);
static testfunc D_8012A484[] = static testfunc D_8012A484[] =
{ {
(testfunc)0x800A3678, (testfunc)0x800A3678,
@ -40,6 +36,7 @@ static testfunc D_8012A484[] =
u32 D_801600B0; u32 D_801600B0;
// SkelAnime_LodDrawLimb // 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) void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex)
{ {
SkelLimbEntry* limbEntry; SkelLimbEntry* limbEntry;
@ -56,9 +53,9 @@ void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec
limbIndex++; limbIndex++;
rot = actorDrawTable[limbIndex]; rot = actorDrawTable[limbIndex];
pos.x = limbEntry->pos.x; pos.x = limbEntry->translation.x;
pos.y = limbEntry->pos.y; pos.y = limbEntry->translation.y;
pos.z = limbEntry->pos.z; pos.z = limbEntry->translation.z;
dList = limbEntry->displayLists[dListIndex]; 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))
@ -82,14 +79,14 @@ void func_800A08A0(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable , Vec
appendDlistFunc(globalCtx, limbIndex, &dList, &rot, actor); 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); func_800A08A0(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex);
} }
Matrix_Pull(); Matrix_Pull();
if (limbEntry->nextLimbIndex != 0xFF) if (limbEntry->nextLimbIndex != LIMB_DONE)
{ {
func_800A08A0(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex); 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 // SkelAnime_LodDraw
// func_800A0B40
void func_800A0B40(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex) void func_800A0B40(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor, s32 dListIndex)
{ {
SkelLimbEntry* limbEntry; SkelLimbEntry* limbEntry;
@ -149,6 +147,7 @@ void func_800A0B40(GlobalContext* globalCtx, u32* limbIndex, Vec3s* actorDrawTab
#ifdef NON_MATCHING #ifdef NON_MATCHING
// SkelAnime_LodDrawLimbSV // SkelAnime_LodDrawLimbSV
// func_800A0D94
void func_800A0D94(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, void func_800A0D94(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable,
SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc,
Actor* actor, s32 dListIndex, Mtx** mtx) 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); appendDlistFunc(globalCtx, limbIndex, &dList[1], &rot, actor);
} }
if (limbEntry->firstChildIndex != 0xFF) if (limbEntry->firstChildIndex != LIMB_DONE)
{ {
func_800A0D94(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, func_800A0D94(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable,
updateMtxFunc, appendDlistFunc, actor, dListIndex, mtx); updateMtxFunc, appendDlistFunc, actor, dListIndex, mtx);
@ -200,7 +199,7 @@ void func_800A0D94(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3
Matrix_Pull(); Matrix_Pull();
if (limbEntry->nextLimbIndex != 0xFF) if (limbEntry->nextLimbIndex != LIMB_DONE)
{ {
func_800A0D94(globalCtx, limbEntry->nextLimbIndex, limbTable, func_800A0D94(globalCtx, limbEntry->nextLimbIndex, limbTable,
actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex, mtx); actorDrawTable, updateMtxFunc, appendDlistFunc, actor, dListIndex, mtx);
@ -213,6 +212,7 @@ void func_800A0D94(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3
#ifdef NON_MATCHING #ifdef NON_MATCHING
// SkelAnime_LodDrawSV // SkelAnime_LodDrawSV
// func_800A106C
void func_800A106C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTable, s32 limbCount, 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) Actor* actor, s32 dListIndex)
@ -276,7 +276,7 @@ void func_800A106C(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab
{ {
appendDlistFunc(globalCtx, 1, &dList[0], &rot, actor); 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); 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 #ifdef NON_MATCHING
// SkelAnime_DrawLimb // SkelAnime_DrawLimb
// func_800A1344
void func_800A1344(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor) void func_800A1344(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3s* actorDrawTable, SkelAnime_LimbUpdateMatrix updateMtxFunc, SkelAnime_LimbAppendDlist appendDlistFunc, Actor* actor)
{ {
GraphicsContext* gfxCtx; GraphicsContext* gfxCtx;
@ -324,7 +325,7 @@ void func_800A1344(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3
appendDlistFunc(globalCtx, limbIndex, &dList, &rot, actor); appendDlistFunc(globalCtx, limbIndex, &dList, &rot, actor);
} }
if (limbEntry->firstChildIndex != 0xFF) if (limbEntry->firstChildIndex != LIMB_DONE)
{ {
func_800A1344(globalCtx, limbEntry->firstChildIndex, limbTable, func_800A1344(globalCtx, limbEntry->firstChildIndex, limbTable,
actorDrawTable, updateMtxFunc, appendDlistFunc, actor); actorDrawTable, updateMtxFunc, appendDlistFunc, actor);
@ -332,7 +333,7 @@ void func_800A1344(GlobalContext* globalCtx, s32 limbIndex, u32* limbTable, Vec3
Matrix_Pull(); Matrix_Pull();
if (limbEntry->nextLimbIndex != 0xFF) if (limbEntry->nextLimbIndex != LIMB_DONE)
{ {
func_800A1344(globalCtx, limbEntry->nextLimbIndex, limbTable, func_800A1344(globalCtx, limbEntry->nextLimbIndex, limbTable,
actorDrawTable, updateMtxFunc, appendDlistFunc, actor); actorDrawTable, updateMtxFunc, appendDlistFunc, actor);
@ -390,7 +391,7 @@ void SkelAnime_Draw(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTa
appendDlistFunc(globalCtx, 1, &dList, &rot, actor); appendDlistFunc(globalCtx, 1, &dList, &rot, actor);
} }
if (rootLimb->firstChildIndex != 0xFF) if (rootLimb->firstChildIndex != LIMB_DONE)
{ {
func_800A1344(globalCtx, rootLimb->firstChildIndex, limbTable, func_800A1344(globalCtx, rootLimb->firstChildIndex, limbTable,
actorDrawTable, updateMtxFunc, appendDlistFunc, actor); 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); 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); func_800A180C(globalCtx, limbEntry->firstChildIndex, limbTable, actorDrawTable, updateMtxFunc, appendDlistFunc, actor, limbMatricies);
} }
Matrix_Pull(); Matrix_Pull();
if (limbEntry->nextLimbIndex != 0xFF) if (limbEntry->nextLimbIndex != LIMB_DONE)
{ {
func_800A180C(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable, func_800A180C(globalCtx, limbEntry->nextLimbIndex, limbTable, actorDrawTable,
updateMtxFunc, appendDlistFunc, actor, limbMatricies); updateMtxFunc, appendDlistFunc, actor, limbMatricies);
@ -534,7 +535,7 @@ void func_800A1AC8(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab
appendDlistFunc(globalCtx, 1, &skelDlist[1], &rot, actor); appendDlistFunc(globalCtx, 1, &skelDlist[1], &rot, actor);
} }
if (rootLimb->firstChildIndex != 0xFF) if (rootLimb->firstChildIndex != LIMB_DONE)
{ {
func_800A180C(globalCtx, rootLimb->firstChildIndex, limbTable, actorDrawTable, func_800A180C(globalCtx, rootLimb->firstChildIndex, limbTable, actorDrawTable,
updateMtxFunc, appendDlistFunc, actor, &limbMatricies); updateMtxFunc, appendDlistFunc, actor, &limbMatricies);
@ -548,110 +549,45 @@ void func_800A1AC8(GlobalContext* globalCtx, u32* limbTable, Vec3s* actorDrawTab
#endif #endif
#undef NON_MATCHING #undef NON_MATCHING
#ifdef NON_MATCHING /* SkelAnime_AnimateFrame
typedef struct * 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)
{ {
s16 animFrameCount; AnimationRotationIndex* index;
u32 rotationValuesSeg; AnimationRotationValue* rotationValueTable;
u32 actorDrawTableSeg; AnimationRotationValue* frameRotationValueTable;
s16 limit; AnimationHeader *animationHeader;
} AnimationHeader;
s32 i;
u16 limit;
typedef struct animationHeader = SEGMENTED_TO_VIRTUAL(animation);
{ index = SEGMENTED_TO_VIRTUAL(animationHeader->rotationIndexSeg);
Vec3s pos; rotationValueTable = SEGMENTED_TO_VIRTUAL(animationHeader->rotationValueSeg);
Vec3s rotations[1]; frameRotationValueTable = &rotationValueTable[currentFrame];
} RotationIndex; limit = animationHeader->limit;
u16 func_800A1D8C(u32 animationSeg, s32 arg1, s32 arg2, Vec3s* arg3) for(i = 0; i < limbCount; i++, dst++, index++)
{
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; if ((dst == NULL) || (index == NULL) ||
phi_s0 = arg3; (frameRotationValueTable == NULL) ||
phi_s1 = (*(&gSegments + (((u32) (temp_v0->unk8 * 0x10) >> 0x1C) * 4)) + (temp_v0->unk8 & 0xFFFFFF)) + 0x80000000; (rotationValueTable == NULL))
phi_s4 = 0;
loop_2:
if ((((phi_s0 == 0) || (phi_s1 == 0)) || (temp_s3 == 0)) || (temp_s2 == 0))
{ {
LogUtils_LogThreadId("../z_skelanime.c", 0x570); if(1) { } // Necessary to match.
osSyncPrintf("out = %08x\n", phi_s0); LOG("../z_skelanime.c", 0x570, "out = %08x\n", dst);
LogUtils_LogThreadId("../z_skelanime.c", 0x571); LOG("../z_skelanime.c", 0x571, "ref_tbl = %08x\n", index);
osSyncPrintf("ref_tbl = %08x\n", phi_s1); LOG("../z_skelanime.c", 0x572, "frame_tbl = %08x\n", frameRotationValueTable);
LogUtils_LogThreadId("../z_skelanime.c", 0x572); LOG("../z_skelanime.c", 0x573, "tbl = %08x\n", rotationValueTable);
osSyncPrintf("frame_tbl = %08x\n", temp_s3);
LogUtils_LogThreadId("../z_skelanime.c", 0x573);
osSyncPrintf("tbl = %08x\n", temp_s2);
} }
else
{
} dst->x = index->x >= limit ? frameRotationValueTable[index->x] : rotationValueTable[index->x];
temp_v0_2 = phi_s1->unk0; dst->y = index->y >= limit ? frameRotationValueTable[index->y] : rotationValueTable[index->y];
temp_s4 = phi_s4 + 1; dst->z = index->z >= limit ? frameRotationValueTable[index->z] : rotationValueTable[index->z];
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
s32 func_800A1FC8(s32 arg0) 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_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") #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); return (s16)(*virt - 1);
} }
// Big boi function
#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A2E70.s") #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A2E70.s")
void func_800A32EC(u16* arg0) void func_800A32EC(u16* arg0)
@ -715,7 +712,8 @@ void func_800A3310(void* arg0)
*D_8012A480Ptr |= D_801600B0; *D_8012A480Ptr |= D_801600B0;
} }
AnimationEntry* func_800A3334(AnimationContext* animationCtx, s32 arg1) // SkelAnime_NextEntry
AnimationEntry* func_800A3334(AnimationContext* animationCtx, AnimationType type)
{ {
AnimationEntry *entry; AnimationEntry *entry;
s16 index = animationCtx->animationCount; s16 index = animationCtx->animationCount;
@ -726,80 +724,187 @@ AnimationEntry* func_800A3334(AnimationContext* animationCtx, s32 arg1)
} }
animationCtx->animationCount = index + 1; animationCtx->animationCount = index + 1;
entry = &animationCtx->entries[index]; entry = &animationCtx->entries[index];
entry->unk_00 = arg1; entry->type = type;
return entry; return entry;
} }
#ifdef NON_MATCHING /*
typedef struct * These next 6 functions seem to inialize an entry in the global context's
{ * animation context.
u32 unk_00; */
u32 rom;
} anim;
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; AnimationEntry* entry;
anim *sp38; LinkAnimetionEntry *linkAnimetionEntry;
s32 sp30; char pad[4];
OSMesgQueue temp_a0;
s32 temp_a3;
s32 temp_at;
AnimationEntry* temp_ret;
DmaRequest req;
temp_ret = func_800A3334(&globalCtx->animationCtx, 0); entry = func_800A3334(&globalCtx->animationCtx, 0);
if (temp_ret != NULL) if (entry != NULL)
{ {
temp_a0 = temp_ret->msgQueue; linkAnimetionEntry = SEGMENTED_TO_VIRTUAL(linkAnimetionSeg);
sp38 = SEGMENTED_TO_VIRTUAL(arg1); osCreateMesgQueue(&entry->types.type0.msgQueue, &entry->types.type0.msg, 1);
sp3C = temp_ret; DmaMgr_SendRequest2(&entry->types.type0.req, ram, LINK_ANIMETION_OFFSET(linkAnimetionEntry->animationSegAddress, ((sizeof(Vec3s) * limbCount + 2) * frame)),
osCreateMesgQueue(temp_ret, &temp_ret->msg, 1); sizeof(Vec3s) * limbCount + 2, 0, &entry->types.type0.msgQueue, NULL,
temp_a3 = sizeof(Vec3s) * limbCount; "../z_skelanime.c" , 0x7D4);
DmaMgr_SendRequest2(&req, ram, ((sp38->rom + (u32)&_link_animetionSegmentRomStart) - 0x7000000) + (temp_a3 * arg2), temp_a3, 0, &temp_ret->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") /* The next functions are callbacks to loading animations */
#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A34DC.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_800A3548.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_800A35B4.s") if ((genericEntry->raw[0] & D_8012A480) != 0)
{
return;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A3620.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_800A3678.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_800A36A4.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_800A3714.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_800A3770.s") void func_800A37F0(GlobalContext* globalCtx, AnimationEntryType4* entry)
{
s32 i;
Vec3s* dst;
Vec3s* src;
u8* index;
AnimationEntryRaw* rawEntry = (AnimationEntryRaw*)entry;
#pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A37F0.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++ < 1U)
{
*dst = *src;
}
}
}
}
typedef struct { void func_800A3874(GlobalContext* globalCtx, AnimationEntryType5* entry)
Actor* actor;
SkelAnime* skelAnime;
f32 unk_8;
} UNK_800A3874_A1;
void func_800A3874(s32 arg0, UNK_800A3874_A1* arg1)
{ {
char pad[4]; char pad[4];
Actor* temp_v0 = arg1->actor; Actor* actor = entry->actor;
Vec3f pos; Vec3f pos;
func_800A54FC(arg1->skelAnime, &pos, temp_v0->shape.rot.y); func_800A54FC(entry->skelAnime, &pos, actor->shape.rot.y);
temp_v0->posRot.pos.x += pos.x * temp_v0->scale.x; actor->posRot.pos.x += pos.x * actor->scale.x;
temp_v0->posRot.pos.y += pos.y * temp_v0->scale.y * arg1->unk_8; actor->posRot.pos.y += pos.y * actor->scale.y * entry->unk_08;
temp_v0->posRot.pos.z += pos.z * temp_v0->scale.z; actor->posRot.pos.z += pos.z * actor->scale.z;
} }
void func_800A390C(GlobalContext* globalCtx, AnimationContext* animationCtx) 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--) 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; D_801600B0 = 1;
@ -817,19 +922,18 @@ void func_800A390C(GlobalContext* globalCtx, AnimationContext* animationCtx)
#ifdef NON_MATCHING #ifdef NON_MATCHING
// some kind of init // some kind of init
void func_800A3F08(GlobalContext*,SkelAnime*,s32,f32,f32,f32,s8,f32); 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 skelAnimeInitSeg, s32 arg3, s8 arg4, Vec3s* actorDrawTable, s32 arg6, s32 arg7)
{ {
SkelAnimeInit* skelAnimeInit; SkelAnimeLimbHeader* limbHeader;
u8 flag; u8 flag;
size_t size; size_t size;
skelAnimeInit = SEGMENTED_TO_VIRTUAL(skelAnimeInitSeg); limbHeader = SEGMENTED_TO_VIRTUAL(limbHeaderSeg);
skelAnime->unk_34 = arg4; skelAnime->unk_34 = arg4;
flag = arg4 & 2 == 0 ? 1U : skelAnimeInit->limbCount; flag = arg4 & 2 == 0 ? 1U : limbHeader->limbCount;
if ((arg4 & 2) != 0) if ((arg4 & 2) != 0)
{ {
flag = skelAnimeInit->limbCount; flag = limbHeader->limbCount;
} }
else else
{ {
@ -838,17 +942,17 @@ void func_800A39AC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 skelAnime
if((arg4 & 1) != 0) if((arg4 & 1) != 0)
{ {
flag += skelAnimeInit->limbCount; flag += limbHeader->limbCount;
} }
if((arg4 & 4) != 0) if((arg4 & 4) != 0)
{ {
flag += skelAnimeInit->limbCount; flag += limbHeader->limbCount;
} }
skelAnime->limbCount = flag; skelAnime->limbCount = flag;
skelAnime->dListCount = skelAnimeInit->dListCount; skelAnime->dListCount = limbHeader->dListCount;
skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(skelAnimeInit->limbIndexSeg); skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg);
size = sizeof(Vec3s); size = sizeof(Vec3s);
if ((arg4 & 8) != 0) if ((arg4 & 8) != 0)
{ {
@ -884,15 +988,16 @@ void func_800A39AC(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 skelAnime
#endif #endif
#undef NON_MATCHING #undef NON_MATCHING
// SkelAnime_SetUpdateFunc
void func_800A3B8C(SkelAnime* skelAnime) void func_800A3B8C(SkelAnime* skelAnime)
{ {
if (skelAnime->unk_01 < 2) if (skelAnime->unk_01 < 2)
{ {
skelAnime->mtxUpdate = &func_800A3D70; skelAnime->animUpdate = &func_800A3D70;
} }
else else
{ {
skelAnime->mtxUpdate = &func_800A3E0C; skelAnime->animUpdate = &func_800A3E0C;
} }
skelAnime->unk_28 = 0.0f; skelAnime->unk_28 = 0.0f;
} }
@ -900,7 +1005,7 @@ void func_800A3B8C(SkelAnime* skelAnime)
//SkelAnime_FrameUpdateMatrixGlobalCtx //SkelAnime_FrameUpdateMatrixGlobalCtx
void func_800A3BC0(GlobalContext* globalCtx, SkelAnime* skelAnime) void func_800A3BC0(GlobalContext* globalCtx, SkelAnime* skelAnime)
{ {
skelAnime->mtxUpdate(globalCtx, skelAnime); skelAnime->animUpdate(globalCtx, skelAnime);
} }
#ifdef NON_MATCHING #ifdef NON_MATCHING
@ -984,7 +1089,7 @@ s32 func_800A3E0C(GlobalContext* globalCtx, SkelAnime* skelAnime)
skelAnime->animCurrentFrame -= skelAnime->unk_14; skelAnime->animCurrentFrame -= skelAnime->unk_14;
} }
} }
} }
func_800A3C9C(globalCtx, skelAnime); func_800A3C9C(globalCtx, skelAnime);
return 0; return 0;
} }
@ -996,8 +1101,6 @@ void func_800A3EE8(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 arg2)
skelAnime->unk_2C = 1.0f / 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 #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)
{ {
@ -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); 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) void func_800A41FC(GlobalContext* globalCtx, SkelAnime* skelAnime)
{ {
func_800A3478(globalCtx, skelAnime->limbCount, skelAnime->unk_24, skelAnime->actorDrawTbl); 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); 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") #pragma GLOBAL_ASM("asm/non_matchings/code/z_skelanime/func_800A43B8.s")
#endif
void func_800A4454(SkelAnime* skelAnime) void func_800A4454(SkelAnime* skelAnime)
{ {
@ -1118,38 +1206,36 @@ void func_800A4454(SkelAnime* skelAnime)
func_800A3B8C(skelAnime); func_800A3B8C(skelAnime);
} }
s32 func_800A4478(SkelAnime* skelAnime, f32 arg1, f32 updateRate) s32 func_800A4478(SkelAnime* skelAnime, f32 arg1, f32 updateRate)
{ {
f32 temp_f0; f32 updateSpeed;
f32 temp_f12; f32 temp_f12;
f32 temp_f2; f32 nextFrame;
temp_f0 = skelAnime->animPlaybackSpeed * updateRate; updateSpeed = skelAnime->animPlaybackSpeed * updateRate;
temp_f2 = skelAnime->animCurrentFrame - temp_f0; nextFrame = skelAnime->animCurrentFrame - updateSpeed;
if (temp_f2 < 0.0f) if (nextFrame < 0.0f)
{ {
temp_f2 += skelAnime->unk_14; nextFrame += skelAnime->unk_14;
} }
else else
{ {
temp_f2 = temp_f2; if (skelAnime->unk_14 <= nextFrame)
if (skelAnime->unk_14 <= temp_f2)
{ {
temp_f2 = temp_f2 - skelAnime->unk_14; nextFrame -= skelAnime->unk_14;
} }
} }
if (arg1 == 0.0f) if (arg1 == 0.0f)
{ {
if (0.0f < temp_f0) if (0.0f < updateSpeed)
{ {
arg1 = skelAnime->unk_14; arg1 = skelAnime->unk_14;
} }
} }
temp_f12 = (temp_f2 + temp_f0) - arg1; temp_f12 = (nextFrame + updateSpeed) - arg1;
if (0.0f <= (temp_f12 * temp_f0)) if (0.0f <= (temp_f12 * updateSpeed))
{ {
if (((temp_f12 - temp_f0) * temp_f0) < 0.0f) if (((temp_f12 - updateSpeed) * updateSpeed) < 0.0f)
{ {
return 1; return 1;
} }
@ -1164,13 +1250,13 @@ s32 func_800A4530(SkelAnime* skelAnime, f32 arg1)
return func_800A4478(skelAnime, arg1, updateRate); 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); limbHeader = SEGMENTED_TO_VIRTUAL(limbHeaderSeg);
skelAnime->limbCount = skelAnimeInit->limbCount + 1; skelAnime->limbCount = limbHeader->limbCount + 1;
skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(skelAnimeInit->limbIndexSeg); skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg);
if (actorDrawTable == NULL) if (actorDrawTable == NULL)
{ {
skelAnime->actorDrawTbl = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), "../z_skelanime.c", 2968); 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); func_800A52F8(skelAnime, animation);
} }
} }
// SkelAnime_InitSV
// another init void func_800A46F8(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 limbHeaderSeg, u32 animation, Vec3s* actorDrawTable, s32 arg5, s32 limbCount)
void func_800A46F8(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 skelAnimeInitSeg, u32 animation, Vec3s* actorDrawTable, s32 arg5, s32 limbCount)
{ {
SkelAnimeInit *skelAnimeInit; SkelAnimeLimbHeader *limbHeader;
skelAnimeInit = SEGMENTED_TO_VIRTUAL(skelAnimeInitSeg); limbHeader = SEGMENTED_TO_VIRTUAL(limbHeaderSeg);
skelAnime->limbCount = skelAnimeInit->limbCount + 1; skelAnime->limbCount = limbHeader->limbCount + 1;
skelAnime->dListCount = skelAnimeInit->dListCount; skelAnime->dListCount = limbHeader->dListCount;
skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(skelAnimeInit->limbIndexSeg); skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg);
if (actorDrawTable == NULL) if (actorDrawTable == NULL)
{ {
@ -1234,15 +1319,14 @@ void func_800A46F8(GlobalContext* globalCtx, SkelAnime* skelAnime, u32 skelAnime
func_800A52F8(skelAnime, animation); func_800A52F8(skelAnime, animation);
} }
} }
// SkelAnime_InitSkin
// some kind of init void func_800A487C(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 limbHeaderSeg, u32 animation)
void func_800A487C(GlobalContext* globalCtx, SkelAnime *skelAnime, u32 skelAnimeInitSeg, u32 animation)
{ {
SkelAnimeInit *skelAnimeInit; SkelAnimeLimbHeader *limbHeader;
skelAnimeInit = SEGMENTED_TO_VIRTUAL(skelAnimeInitSeg); limbHeader = SEGMENTED_TO_VIRTUAL(limbHeaderSeg);
skelAnime->limbCount = skelAnimeInit->limbCount + 1; skelAnime->limbCount = limbHeader->limbCount + 1;
skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(skelAnimeInit->limbIndexSeg); skelAnime->limbIndex = SEGMENTED_TO_VIRTUAL(limbHeader->limbIndexSeg);
skelAnime->actorDrawTbl = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->actorDrawTbl), "../z_skelanime.c", 3120); 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); skelAnime->unk_24 = ZeldaArena_MallocDebug(skelAnime->limbCount * sizeof(*skelAnime->unk_24), "../z_skelanime.c", 3121);
if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL)) if ((skelAnime->actorDrawTbl == NULL) || (skelAnime->unk_24 == NULL))
@ -1262,20 +1346,20 @@ void func_800A49B0(SkelAnime* skelAnime)
{ {
if (skelAnime->unk_01 < 2) if (skelAnime->unk_01 < 2)
{ {
skelAnime->mtxUpdate = &func_800A4D9C; skelAnime->animUpdate = &func_800A4D9C;
return; return;
} }
if (skelAnime->unk_01 < 4) if (skelAnime->unk_01 < 4)
{ {
skelAnime->mtxUpdate = &func_800A4EE0; skelAnime->animUpdate = &func_800A4EE0;
return; return;
} }
skelAnime->mtxUpdate = &func_800A4E38; skelAnime->animUpdate = &func_800A4E38;
} }
s32 SkelAnime_FrameUpdateMatrix(SkelAnime* skelAnime){ s32 SkelAnime_FrameUpdateMatrix(SkelAnime* skelAnime){
return skelAnime->mtxUpdate(skelAnime); return skelAnime->animUpdate(skelAnime);
} }
#ifdef NON_MATCHING #ifdef NON_MATCHING
@ -1347,27 +1431,28 @@ s32 func_800A4AD8(SkelAnime* skelAnime)
// close // close
void func_800A4C58(SkelAnime* skelAnime) void func_800A4C58(SkelAnime* skelAnime)
{ {
Vec3s sp38[98]; char pad[6];
f32 temp_f0; f32 temp_f0;
f32 temp_f2; f32 temp_f10;
s32 temp_f10; Vec3s sp38[97];
s32 temp_f8; 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) if ((skelAnime->unk_01 & 1) != 0)
{ {
temp_f8 = (s32) skelAnime->animCurrentFrame; temp_f8 = (s32) skelAnime->animCurrentFrame;
temp_f10 = temp_f8; temp_f10 = temp_f8;
temp_f8 = temp_f8 + 1; temp_f8++;
temp_f2 = skelAnime->animCurrentFrame - (f32) temp_f10; temp_f2 = skelAnime->animCurrentFrame - temp_f10;
if (temp_f8 >= (s32) skelAnime->unk_14) if (temp_f8 >= (s32) skelAnime->unk_14)
{ {
temp_f8 = 0; temp_f8 = 0;
} }
func_800A1D8C(skelAnime->animCurrent, temp_f8, skelAnime->limbCount, sp38); 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); skelAnime->unk_28 -= skelAnime->unk_2C * (R_UPDATE_RATE * 0.33333334f);
temp_f0 = skelAnime->unk_28; temp_f0 = skelAnime->unk_28;
@ -1670,6 +1755,7 @@ s32 func_800A56C8(SkelAnime *skelAnime, f32 arg1)
return func_800A4478(skelAnime, arg1, 1.0f); return func_800A4478(skelAnime, arg1, 1.0f);
} }
// SkelAnime_Free
void func_800A56F0(SkelAnime *skelAnime, s32 arg1) void func_800A56F0(SkelAnime *skelAnime, s32 arg1)
{ {
if (skelAnime->actorDrawTbl != NULL) if (skelAnime->actorDrawTbl != NULL)
@ -1688,7 +1774,8 @@ void func_800A56F0(SkelAnime *skelAnime, s32 arg1)
osSyncPrintf("morf_joint あきまへん!!\n"); // "morf_joint Akimane !!" 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; s32 i;
for(i = 0; i < skelAnime->limbCount; i++) for(i = 0; i < skelAnime->limbCount; i++)

View file

@ -336,7 +336,7 @@ static void EnWallmas_StandStart(EnWallmas *this)
static void EnWallmas_WalkStart(EnWallmas *this) static void EnWallmas_WalkStart(EnWallmas *this)
{ {
func_800A529C(&this->skelAnime, &D_060041F4, 3.0f, &this->actor); func_800A529C(&this->skelAnime, &D_060041F4, 3.0f);
this->actionFunc = (ActorFunc)&EnWallmas_Walk; this->actionFunc = (ActorFunc)&EnWallmas_Walk;
this->actor.speedXZ = 3.0f; this->actor.speedXZ = 3.0f;
} }

View file

@ -394,4 +394,7 @@ D_06008688 = 0x06008688;
D_04049210 = 0x04049210; D_04049210 = 0x04049210;
// z_obj_bombiwa // z_obj_bombiwa
D_060009E0 = 0x060009E0; D_060009E0 = 0x060009E0;
// z_skelanime
link_animetion_segment = 0x07000000;