diff --git a/configure.py b/configure.py index ef7a908b..cc415c85 100644 --- a/configure.py +++ b/configure.py @@ -338,7 +338,7 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]: Object(Matching, "SB/Core/x/xutil.cpp"), Object(NonMatching, "SB/Core/x/xVec3.cpp"), Object(NonMatching, "SB/Game/zActionLine.cpp"), - Object(NonMatching, "SB/Game/zAnimList.cpp"), + Object(Equivalent, "SB/Game/zAnimList.cpp"), Object(NonMatching, "SB/Game/zAssetTypes.cpp"), Object(NonMatching, "SB/Game/zCamera.cpp"), Object(NonMatching, "SB/Game/zConditional.cpp"), diff --git a/src/SB/Core/x/xAnim.h b/src/SB/Core/x/xAnim.h index 7fc6867c..e84e446a 100644 --- a/src/SB/Core/x/xAnim.h +++ b/src/SB/Core/x/xAnim.h @@ -186,10 +186,11 @@ xAnimPlay* xAnimPoolAlloc(xMemPool* pool, void* object, xAnimTable* table, xModelInstance* modelInst); xAnimState* xAnimTableGetState(xAnimTable* table, const char* name); void xAnimTableAddTransition(xAnimTable* table, xAnimTransition* tran, const int8* source); +void xAnimTableAddFile(xAnimTable* table, xAnimFile* file, const char* states); xAnimState* xAnimTableGetStateID(xAnimTable* table, uint32 ID); void xAnimPlaySetState(xAnimSingle* single, xAnimState* state, float32 startTime); void xAnimPlayStartTransition(xAnimPlay* play, xAnimTransition* transition); void xAnimPlayUpdate(xAnimPlay* play, float32 timeDelta); void xAnimPlayEval(xAnimPlay* play); -#endif \ No newline at end of file +#endif diff --git a/src/SB/Game/zAnimList.cpp b/src/SB/Game/zAnimList.cpp index 492f97b4..c761aea1 100644 --- a/src/SB/Game/zAnimList.cpp +++ b/src/SB/Game/zAnimList.cpp @@ -6,52 +6,96 @@ #include "zAnimList.h" -extern int32 nals; -extern uint32* aids; // anim IDs (not AIDS, you fool) -extern xAnimTable** atbls; // anim tables -extern int32* anused; +int32 nals; +// NOTE (Square): I think these are Asset IDs, not Anim IDs +uint32* aids; // anim IDs (not AIDS, you fool) +xAnimTable** atbls; // anim tables +int32* anused; + +const char* astnames[2][10] = { + "stop0", "stop1", "stop2", "stop3", "stop4", "stop5", "stop6", "stop7", "stop8", "stop9", + "loop0", "loop1", "loop2", "loop3", "loop4", "loop5", "loop6", "loop7", "loop8", "loop9", +}; uint32 AlwaysConditional(xAnimTransition*, xAnimSingle*, void*) { return 1; } -#if 0 +// Equivalent +// Mostly an issue of scheduling. void zAnimListInit() { - int32 i; - uint32 size; - zAnimListAsset* zala; - st_PKR_ASSET_TOCINFO ainfo; - xAnimTable* atbl; - void* buf; - xAnimFile* afile; - int32 idle_exists; - int32 j; - xAnimFile* afile2; - // ALST = Animation list https://battlepedia.org/ALST nals = xSTAssetCountByType('ALST'); // 0x414C5354 - - if (!nals) + if (nals == 0) { return; } // << 2 is the same as multiplying by 4 // so it's just allocating size in bytes - aids = (uint32*)xMemAllocSize(nals * 4); - atbls = (xAnimTable**)xMemAllocSize(nals * 4); - anused = (int32*)xMemAllocSize(nals * 4); + aids = (uint32*)xMemAllocSize(nals * sizeof(int32)); + atbls = (xAnimTable**)xMemAllocSize(nals * sizeof(int32)); + anused = (int32*)xMemAllocSize(nals * sizeof(int32)); - for (i = 0; i < nals; i++) + for (int32 i = 0; i < nals; i++) { - for (j = 0; j < 10; j++) + uint32 size; + zAnimListAsset* zala = (zAnimListAsset*)xSTFindAssetByType('ALST', i, &size); + st_PKR_ASSET_TOCINFO ainfo; + xSTGetAssetInfoByType('ALST', i, &ainfo); + xAnimTable* atbl = xAnimTableNew("", NULL, 0); + + aids[i] = ainfo.aid; + atbls[i] = atbl; + anused[i] = 0; + + void* buf0 = xSTFindAsset(zala->ids[0], &size); + if (buf0) + { + xAnimFile* afile = xAnimFileNew(buf0, "", 0, NULL); + xAnimTableNewState(atbl, "idle", 0x10, 0, 1.0f, NULL, NULL, 0.0f, NULL, NULL, + xAnimDefaultBeforeEnter, NULL, NULL); + xAnimTableAddFile(atbl, afile, "idle"); + anused[i]++; + } + + for (int32 j = 1; j < 10; j++) { + if (zala->ids[j] == 0) + { + continue; + } + + void* buf = xSTFindAsset(zala->ids[j], &size); + if (!buf) + { + continue; + } + + xAnimFile* afile = xAnimFileNew(buf, "", 0, NULL); + if (buf0) + { + xAnimTableNewState(atbl, astnames[0][j], 0x20, 0, 1.0f, NULL, NULL, 0.0f, NULL, + NULL, xAnimDefaultBeforeEnter, NULL, NULL); + xAnimTableNewTransition(atbl, astnames[0][j], "idle", AlwaysConditional, NULL, 0x10, + 0, 0.0f, 0.0f, 0, 0, 0.0f, 0); + } + else + { + xAnimTableNewState(atbl, astnames[1][j], 0, 0, 1.0f, NULL, NULL, 0.0f, NULL, NULL, + xAnimDefaultBeforeEnter, NULL, NULL); + } + + xAnimTableAddFile(atbl, afile, astnames[0][j]); + xAnimTableNewState(atbl, astnames[1][j], 0, 0, 1.0f, NULL, NULL, 0.0f, NULL, NULL, + xAnimDefaultBeforeEnter, NULL, NULL); + xAnimTableAddFile(atbl, afile, astnames[1][j]); + anused[i]++; } } } -#endif void zAnimListExit() {