mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-05 15:34:41 +00:00
z_skin OK and z_skin_awb decomped (one barely nonmatching) (#632)
* skin_awb some functions done * more matches * stuff * matching skins * closer? * less skin * skin * format * one thing * merge actor Co-authored-by: gns <adamkiddle23@gmail.com> Co-authored-by: petrie911 <pmontag@DESKTOP-LG8A167.localdomain>
This commit is contained in:
parent
a30b5bbb26
commit
5f552a369c
11 changed files with 255 additions and 880 deletions
|
@ -36,56 +36,64 @@ void func_800A57C0(MtxF* mtx, Struct_800A57C0* arg1, Struct_800A598C* arg2, Vtx*
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
// Regalloc, Stack
|
||||
void func_800A598C(GraphicsContext* gfxCtx, PSkinAwb* skin, s32 limbIndex, s32 arg3) {
|
||||
SkinLimb** limbs;
|
||||
s32 temp_1;
|
||||
SkinLimb** skeleton;
|
||||
SkinLimb* limb;
|
||||
Struct_800A5E28* data;
|
||||
Struct_800A598C* phi_s6;
|
||||
s32 temp_a0_2;
|
||||
SkinAvb* avb;
|
||||
Struct_800A598C* new_var;
|
||||
s32 temp_a0_2;
|
||||
f32 temp_f20;
|
||||
Struct_800A57C0* temp_v0;
|
||||
Struct_800A598C_2* temp_s3;
|
||||
Vtx* spEC;
|
||||
Struct_800A598C* temp_2;
|
||||
Vec3f spDC;
|
||||
Vec3f spD0;
|
||||
Struct_800A598C_2* phi_s0;
|
||||
|
||||
OPEN_DISPS(gfxCtx, "../z_skin.c", 254);
|
||||
|
||||
limbs = (SkinLimb**)SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment);
|
||||
limb = (SkinLimb*)SEGMENTED_TO_VIRTUAL(limbs[limbIndex]);
|
||||
data = (Struct_800A5E28*)SEGMENTED_TO_VIRTUAL(limb->segment);
|
||||
phi_s6 = &((Struct_800A598C*)SEGMENTED_TO_VIRTUAL(data->unk_4))[0];
|
||||
skeleton = (SkinLimb**)SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment);
|
||||
data = SEGMENTED_TO_VIRTUAL(((SkinLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]))->segment);
|
||||
temp_2 = (Struct_800A598C*)SEGMENTED_TO_VIRTUAL(data->unk_4);
|
||||
|
||||
avb = &skin->avbTbl[limbIndex];
|
||||
|
||||
spEC = avb->buf[avb->unk_0];
|
||||
new_var = &phi_s6[data->unk_2];
|
||||
while (phi_s6 < new_var) {
|
||||
temp_1 = data->unk_2;
|
||||
|
||||
for (phi_s6 = temp_2; phi_s6 < temp_2 + temp_1; phi_s6++) {
|
||||
temp_a0_2 = phi_s6->unk_2;
|
||||
temp_v0 = (Struct_800A57C0*)SEGMENTED_TO_VIRTUAL(phi_s6->unk_8);
|
||||
temp_s3 = (Struct_800A598C_2*)SEGMENTED_TO_VIRTUAL(phi_s6->unk_C);
|
||||
|
||||
if (temp_a0_2 == 1) {
|
||||
Vec3f spAC;
|
||||
|
||||
spAC.x = temp_s3[0].x;
|
||||
spAC.y = temp_s3[0].y;
|
||||
spAC.z = temp_s3[0].z;
|
||||
SkinMatrix_Vec3fMtxFMultXYZ(&D_801600C0[temp_s3[0].unk_0], &spAC, &spDC);
|
||||
} else if (arg3 == 1) {
|
||||
Struct_800A598C_2* temp_s0 = &temp_s3[phi_s6->unk_4];
|
||||
Vec3f spA0;
|
||||
spA0.x = temp_s0->x;
|
||||
spA0.y = temp_s0->y;
|
||||
spA0.z = temp_s0->z;
|
||||
SkinMatrix_Vec3fMtxFMultXYZ(&D_801600C0[temp_s0->unk_0], &spA0, &spDC);
|
||||
|
||||
phi_s0 = &temp_s3[phi_s6->unk_4];
|
||||
|
||||
spA0.x = phi_s0->x;
|
||||
spA0.y = phi_s0->y;
|
||||
spA0.z = phi_s0->z;
|
||||
SkinMatrix_Vec3fMtxFMultXYZ(&D_801600C0[phi_s0->unk_0], &spA0, &spDC);
|
||||
} else {
|
||||
Struct_800A598C_2* phi_s0 = &temp_s3[0];
|
||||
f32 phi_f26 = 0.0f;
|
||||
f32 phi_f24 = 0.0f;
|
||||
f32 phi_f22 = 0.0f;
|
||||
while (phi_s0 < &temp_s3[temp_a0_2]) {
|
||||
Vec3f sp88;
|
||||
f32 temp_f20 = phi_s0->unk_8 * 0.01f;
|
||||
Vec3f phi_f20;
|
||||
Vec3f sp88;
|
||||
|
||||
phi_f20.x = phi_f20.y = phi_f20.z = 0.0f;
|
||||
|
||||
for (phi_s0 = &temp_s3[0]; phi_s0 < &temp_s3[temp_a0_2]; phi_s0++) {
|
||||
temp_f20 = phi_s0->unk_8 * 0.01f;
|
||||
|
||||
sp88.x = phi_s0->x;
|
||||
sp88.y = phi_s0->y;
|
||||
sp88.z = phi_s0->z;
|
||||
|
@ -93,38 +101,30 @@ void func_800A598C(GraphicsContext* gfxCtx, PSkinAwb* skin, s32 limbIndex, s32 a
|
|||
spD0.x *= temp_f20;
|
||||
spD0.y *= temp_f20;
|
||||
spD0.z *= temp_f20;
|
||||
phi_f26 += spD0.x;
|
||||
phi_f24 += spD0.y;
|
||||
phi_f22 += spD0.z;
|
||||
phi_s0++;
|
||||
phi_f20.x += spD0.x;
|
||||
phi_f20.y += spD0.y;
|
||||
phi_f20.z += spD0.z;
|
||||
}
|
||||
spDC.x = phi_f26;
|
||||
spDC.y = phi_f24;
|
||||
spDC.z = phi_f22;
|
||||
spDC.x = phi_f20.x;
|
||||
spDC.y = phi_f20.y;
|
||||
spDC.z = phi_f20.z;
|
||||
}
|
||||
func_800A57C0(&D_801600C0[temp_s3[phi_s6->unk_4].unk_0], temp_v0, phi_s6, spEC, &spDC);
|
||||
phi_s6++;
|
||||
}
|
||||
gSPSegment(POLY_OPA_DISP++, 0x08, avb->buf[avb->unk_0]);
|
||||
if (avb->unk_0 == 0) {
|
||||
avb->unk_0 = 1;
|
||||
} else {
|
||||
avb->unk_0 = 0;
|
||||
}
|
||||
|
||||
avb->unk_0 = (avb->unk_0 == 0) ? 1 : 0;
|
||||
|
||||
CLOSE_DISPS(gfxCtx, "../z_skin.c", 344);
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin/func_800A598C.s")
|
||||
#endif
|
||||
|
||||
void func_800A5E28(GraphicsContext* gfxCtx, PSkinAwb* skin, s32 limbIndex, s32 arg3, s32 arg4) {
|
||||
SkinLimb** limbs;
|
||||
SkinLimb** skeleton;
|
||||
Struct_800A5E28* temp_t9;
|
||||
|
||||
OPEN_DISPS(gfxCtx, "../z_skin.c", 364);
|
||||
limbs = (SkinLimb**)SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment);
|
||||
temp_t9 = (Struct_800A5E28*)SEGMENTED_TO_VIRTUAL(((SkinLimb*)SEGMENTED_TO_VIRTUAL(limbs[limbIndex]))->segment);
|
||||
skeleton = SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment);
|
||||
temp_t9 = SEGMENTED_TO_VIRTUAL(((SkinLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]))->segment);
|
||||
if (!(arg4 & 1)) {
|
||||
func_800A598C(gfxCtx, skin, limbIndex, arg3);
|
||||
}
|
||||
|
@ -134,13 +134,13 @@ void func_800A5E28(GraphicsContext* gfxCtx, PSkinAwb* skin, s32 limbIndex, s32 a
|
|||
|
||||
void func_800A5F60(GraphicsContext* gfxCtx, PSkinAwb* skin, s32 limbIndex, Gfx* arg3, s32 arg4) {
|
||||
Gfx* gfx = arg3;
|
||||
SkinLimb** limbs;
|
||||
SkinLimb** skeleton;
|
||||
s32 pad;
|
||||
|
||||
OPEN_DISPS(gfxCtx, "../z_skin.c", 395);
|
||||
limbs = SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment);
|
||||
skeleton = SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment);
|
||||
if (arg3 == NULL) {
|
||||
gfx = (Gfx*)((SkinLimb*)SEGMENTED_TO_VIRTUAL(limbs[limbIndex]))->segment;
|
||||
gfx = ((SkinLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]))->segment;
|
||||
}
|
||||
if (gfx != NULL) {
|
||||
Mtx* mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &D_801600C0[limbIndex]);
|
||||
|
@ -158,7 +158,7 @@ void func_800A60D8(Actor* actor, GlobalContext* globalCtx, PSkinAwb* skin, SkinC
|
|||
s32 arg5, s32 arg6, s32 arg7) {
|
||||
s32 i;
|
||||
s32 dataType;
|
||||
SkinLimb** limbs;
|
||||
SkinLimb** skeleton;
|
||||
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
|
||||
s32 pad;
|
||||
|
||||
|
@ -166,9 +166,10 @@ void func_800A60D8(Actor* actor, GlobalContext* globalCtx, PSkinAwb* skin, SkinC
|
|||
if ((arg7 & 1) == 0) {
|
||||
func_800A6AC4(skin, &D_801600C0[0], actor, arg5);
|
||||
}
|
||||
limbs = SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment);
|
||||
skeleton = SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment);
|
||||
if ((arg7 & 2) == 0) {
|
||||
Mtx* mtx;
|
||||
|
||||
gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &skin->mtx);
|
||||
if (mtx == NULL) {
|
||||
|
@ -178,10 +179,11 @@ void func_800A60D8(Actor* actor, GlobalContext* globalCtx, PSkinAwb* skin, SkinC
|
|||
}
|
||||
for (i = 0; i < skin->skeletonHeader->limbCount; i++) {
|
||||
s32 phi_a0 = 1;
|
||||
|
||||
if (arg4 != NULL) {
|
||||
phi_a0 = arg4(actor, globalCtx, i, skin);
|
||||
}
|
||||
dataType = ((SkinLimb*)SEGMENTED_TO_VIRTUAL(limbs[i]))->unk_8;
|
||||
dataType = ((SkinLimb*)SEGMENTED_TO_VIRTUAL(skeleton[i]))->unk_8;
|
||||
if (dataType == 4 && phi_a0 == 1) {
|
||||
func_800A5E28(gfxCtx, skin, i, arg6, arg7);
|
||||
} else if (dataType == 0xB && phi_a0 == 1) {
|
||||
|
|
|
@ -1,11 +1,191 @@
|
|||
#include "global.h"
|
||||
#include "overlays/actors/ovl_En_fHG/z_en_fhg.h"
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_800A6460.s")
|
||||
void func_800A6460(GlobalContext* globalCtx, PSkinAwb* skin, s32 limbIndex) {
|
||||
s32 i;
|
||||
SkinLimb** skeleton = SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment);
|
||||
Struct_800A5E28* temp_v1 = SEGMENTED_TO_VIRTUAL(((SkinLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]))->segment);
|
||||
Struct_800A598C* temp_v0 = SEGMENTED_TO_VIRTUAL(temp_v1->unk_4);
|
||||
Struct_800A598C* phi_s0;
|
||||
Struct_800A57C0* temp_s1;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_800A663C.s")
|
||||
for (i = 0; i < 2; i++) {
|
||||
Vtx* temp2 = skin->avbTbl[limbIndex].buf[i];
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_800A6888.s")
|
||||
for (phi_s0 = temp_v0; phi_s0 < temp_v0 + temp_v1->unk_2; phi_s0++) {
|
||||
Struct_800A57C0* phi_s1 = SEGMENTED_TO_VIRTUAL(phi_s0->unk_8);
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_800A698C.s")
|
||||
for (temp_s1 = phi_s1; temp_s1 < phi_s1 + phi_s0->unk_0; temp_s1++) {
|
||||
Vtx* temp_t5_3 = &temp2[temp_s1->unk_0];
|
||||
|
||||
temp_t5_3->v.flag = 0;
|
||||
temp_t5_3->v.tc[0] = temp_s1->unk_2;
|
||||
temp_t5_3->v.tc[1] = temp_s1->unk_4;
|
||||
temp_t5_3->v.cn[3] = temp_s1->unk_9;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void func_800A663C(GlobalContext* globalCtx, PSkinAwb* skin, SkeletonHeader* skeletonHeader,
|
||||
AnimationHeader* animationHeader) {
|
||||
s32 limbCount;
|
||||
s32 i;
|
||||
SkinLimb** skeleton;
|
||||
SkeletonHeader* virtSkelHeader = SEGMENTED_TO_VIRTUAL(skeletonHeader);
|
||||
|
||||
skin->avbCount = virtSkelHeader->limbCount;
|
||||
skin->skeletonHeader = virtSkelHeader;
|
||||
|
||||
skeleton = SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment);
|
||||
limbCount = skin->skeletonHeader->limbCount;
|
||||
skin->avbTbl = ZeldaArena_MallocDebug(limbCount * sizeof(SkinAvb), "../z_skin_awb.c", 212);
|
||||
if (skin->avbTbl == NULL) {
|
||||
__assert("pskin_awb->avb_tbl != NULL", "../z_skin_awb.c", 214);
|
||||
}
|
||||
for (i = 0; i < limbCount; i++) {
|
||||
SkinAvb* avbEntry = &skin->avbTbl[i];
|
||||
SkinLimb* limb = SEGMENTED_TO_VIRTUAL(skeleton[i]);
|
||||
|
||||
if ((limb->unk_8 != 4) || (limb->segment == NULL)) {
|
||||
avbEntry->unk_0 = 0;
|
||||
|
||||
avbEntry->buf[0] = NULL;
|
||||
avbEntry->buf[1] = NULL;
|
||||
} else {
|
||||
Struct_800A5E28* temp_s1 = SEGMENTED_TO_VIRTUAL(((void)0, limb->segment));
|
||||
|
||||
avbEntry->unk_0 = 0;
|
||||
avbEntry->buf[0] = ZeldaArena_MallocDebug(temp_s1->unk_0 * sizeof(Vtx), "../z_skin_awb.c", 235);
|
||||
if (avbEntry->buf[0] == 0) {
|
||||
__assert("psavb->buf[0] != NULL", "../z_skin_awb.c", 237);
|
||||
}
|
||||
avbEntry->buf[1] = ZeldaArena_MallocDebug(temp_s1->unk_0 * sizeof(Vtx), "../z_skin_awb.c", 240);
|
||||
if (avbEntry->buf[1] == 0) {
|
||||
__assert("psavb->buf[1] != NULL", "../z_skin_awb.c", 242);
|
||||
}
|
||||
func_800A6460(globalCtx, skin, i);
|
||||
}
|
||||
if (1) {}
|
||||
}
|
||||
SkelAnime_InitSkin(globalCtx, &skin->skelAnime, skeletonHeader, animationHeader);
|
||||
}
|
||||
|
||||
void func_800A6888(GlobalContext* globalCtx, PSkinAwb* arg1) {
|
||||
s32 i;
|
||||
if (arg1->avbTbl != NULL) {
|
||||
for (i = 0; i < arg1->avbCount; i++) {
|
||||
if (arg1->avbTbl[i].buf[0] != 0) {
|
||||
ZeldaArena_FreeDebug(arg1->avbTbl[i].buf[0], "../z_skin_awb.c", 276);
|
||||
arg1->avbTbl[i].buf[0] = 0;
|
||||
}
|
||||
if (arg1->avbTbl[i].buf[1] != 0) {
|
||||
ZeldaArena_FreeDebug(arg1->avbTbl[i].buf[1], "../z_skin_awb.c", 280);
|
||||
arg1->avbTbl[i].buf[1] = 0;
|
||||
}
|
||||
}
|
||||
if (arg1->avbTbl != NULL) {
|
||||
ZeldaArena_FreeDebug(arg1->avbTbl, "../z_skin_awb.c", 286);
|
||||
}
|
||||
SkelAnime_Free(&arg1->skelAnime, globalCtx);
|
||||
}
|
||||
}
|
||||
|
||||
s32 func_800A698C(PSkinAwb* skin, SkinLimb** skeleton, MtxF* mf, u8 parentIndex, u8 limbIndex) {
|
||||
s32 pad;
|
||||
SkinLimb* limb = SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]);
|
||||
MtxF* mtx;
|
||||
s32 temp_ret;
|
||||
MtxF sp28;
|
||||
|
||||
if (parentIndex == 0xFF) {
|
||||
SkinMatrix_GetClear(&mtx);
|
||||
} else {
|
||||
mtx = &mf[(s32)parentIndex];
|
||||
}
|
||||
|
||||
SkinMatrix_MtxFMtxFMult(mtx, &mf[limbIndex], &sp28);
|
||||
SkinMatrix_MtxFCopy(&sp28, &mf[limbIndex]);
|
||||
|
||||
if (limb->child != 0xFF) {
|
||||
temp_ret = func_800A698C(skin, skeleton, mf, limbIndex, limb->child);
|
||||
if (temp_ret) { // func_800A698C only returns false
|
||||
return temp_ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (limb->sibling != 0xFF) {
|
||||
temp_ret = func_800A698C(skin, skeleton, mf, parentIndex, limb->sibling);
|
||||
if (temp_ret) { // func_800A698C only returns false
|
||||
return temp_ret;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
// Matches except for an `addiu s0, s0, 0`, which obviously does nothing.
|
||||
// Likely some indexing optimization I can't figure out.
|
||||
s32 func_800A6AC4(PSkinAwb* skin, MtxF* arg1, Actor* actor, s32 arg3) {
|
||||
s32 i;
|
||||
u32 zero = 0;
|
||||
f32 yRot;
|
||||
f32 xRot;
|
||||
f32 zRot;
|
||||
s32 temp_ret;
|
||||
f32 yTransl;
|
||||
f32 xTransl;
|
||||
f32 zTransl;
|
||||
SkinLimb** skeleton = SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment);
|
||||
Vec3s* jointRot = &skin->skelAnime.jointTable[0];
|
||||
|
||||
jointRot++;
|
||||
xRot = jointRot[0].x;
|
||||
yRot = jointRot[0].y;
|
||||
zRot = jointRot[0].z;
|
||||
|
||||
if (arg3 != 0) {
|
||||
|
||||
xTransl = jointRot[-1].x;
|
||||
yTransl = jointRot[-1].y;
|
||||
zTransl = jointRot[-1].z;
|
||||
|
||||
jointRot += zero;
|
||||
|
||||
if (arg3 == 0x23) {
|
||||
EnfHG* horse = (EnfHG*)actor;
|
||||
|
||||
yRot += horse->turnRot;
|
||||
}
|
||||
SkinMatrix_SetRotateRPYTranslate(arg1, xRot, yRot, zRot, xTransl, yTransl, zTransl);
|
||||
} else {
|
||||
SkinMatrix_SetRotateRPYTranslate(arg1, xRot, yRot, zRot, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
jointRot++;
|
||||
for (i = 1; i < skin->skeletonHeader->limbCount; i++) {
|
||||
SkinLimb* limb = SEGMENTED_TO_VIRTUAL(skeleton[i]);
|
||||
|
||||
xTransl = limb->jointPos.x;
|
||||
yTransl = limb->jointPos.y;
|
||||
zTransl = limb->jointPos.z;
|
||||
xRot = jointRot->x;
|
||||
yRot = jointRot->y;
|
||||
zRot = jointRot->z;
|
||||
jointRot++;
|
||||
SkinMatrix_SetRotateRPYTranslate(&arg1[i], xRot, yRot, zRot, xTransl, yTransl, zTransl);
|
||||
}
|
||||
|
||||
SkinMatrix_SetScaleRotateYRPTranslate(
|
||||
&skin->mtx, actor->scale.x, actor->scale.y, actor->scale.z, actor->shape.rot.x, actor->shape.rot.y,
|
||||
actor->shape.rot.z, actor->world.pos.x, actor->world.pos.y + (actor->shape.yOffset * actor->scale.y),
|
||||
actor->world.pos.z);
|
||||
|
||||
temp_ret = func_800A698C(skin, SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment), arg1, 0xFF, 0);
|
||||
if (!temp_ret) { // func_800A698C only returns false
|
||||
return temp_ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_skin_awb/func_800A6AC4.s")
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue