1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-06 06:10:21 +00:00

ovl_en_horse_zelda OK (#471)

* Decompiled en_horse_zelda

* Deleted some asm files I missed

* Replaced approximation with a fraction

* Turns out the f32 cast is unnecessary

* Converted coordinates to decimal, replaced actor struct padding with char arrays

* Properly converted to decimal

* Renamed actionIndex to action, replaced += 1 with ++
This commit is contained in:
emilybrooks 2020-11-24 01:38:08 -07:00 committed by GitHub
parent 013e2d90d3
commit 831804ad64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 228 additions and 688 deletions

View file

@ -15,7 +15,10 @@ void EnHorseZelda_Destroy(Actor* thisx, GlobalContext* globalCtx);
void EnHorseZelda_Update(Actor* thisx, GlobalContext* globalCtx);
void EnHorseZelda_Draw(Actor* thisx, GlobalContext* globalCtx);
/*
void func_80A6DCCC(EnHorseZelda* this, GlobalContext* globalCtx);
void func_80A6DDFC(EnHorseZelda* this, GlobalContext* globalCtx);
void func_80A6DC7C(EnHorseZelda* this);
const ActorInit En_Horse_Zelda_InitVars = {
ACTOR_EN_HORSE_ZELDA,
ACTORTYPE_BG,
@ -27,27 +30,220 @@ const ActorInit En_Horse_Zelda_InitVars = {
(ActorFunc)EnHorseZelda_Update,
(ActorFunc)EnHorseZelda_Draw,
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Horse_Zelda/func_80A6D8D0.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Horse_Zelda/func_80A6D918.s")
static AnimationHeader* sAnimationHeaders[] = { 0x06007148 };
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Horse_Zelda/EnHorseZelda_Init.s")
static f32 sAnimPlaybackSpeeds[] = { 0.66666666f };
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Horse_Zelda/EnHorseZelda_Destroy.s")
static ColliderCylinderInit_Set3 sCylinderInit = {
{ COLTYPE_UNK10, 0x00, 0x00, 0x39, COLSHAPE_CYLINDER },
{ 0x00, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, 0x00, 0x00, 0x01 },
{ 40, 100, 0, { 0, 0, 0 } },
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Horse_Zelda/func_80A6DC7C.s")
static ColliderJntSphItemInit sJntSphItemsInit[1] = {
{
{ 0x00, { 0x00000000, 0x00, 0x00 }, { 0x00000000, 0x00, 0x00 }, 0x00, 0x00, 0x01 },
{ 13, { { 0, 0, 0 }, 20 }, 100 },
},
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Horse_Zelda/func_80A6DCCC.s")
static ColliderJntSphInit sJntSphInit = {
{ COLTYPE_UNK10, 0x00, 0x09, 0x39, 0x12, COLSHAPE_JNTSPH },
1,
sJntSphItemsInit,
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Horse_Zelda/func_80A6DD14.s")
static CollisionCheckInfoInit sColChkInfoInit = { 0xA, 0x23, 0x64, 0xFE };
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Horse_Zelda/func_80A6DDFC.s")
typedef struct {
/* 0x0 */ Vec3s unk_0;
/* 0x6 */ u8 unk_6;
} unknownStruct; // size = 0x8
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Horse_Zelda/func_80A6DE38.s")
static unknownStruct D_80A6E240[] = {
{ -1682, -500, 12578, 0x07 }, { -3288, -500, 13013, 0x07 }, { -5142, -417, 11630, 0x07 },
{ -5794, -473, 9573, 0x07 }, { -6765, -500, 8364, 0x07 }, { -6619, -393, 6919, 0x07 },
{ -5193, 124, 5433, 0x07 }, { -2970, 2, 4537, 0x07 }, { -2949, -35, 4527, 0x07 },
{ -1907, -47, 2978, 0x07 }, { 2488, 294, 3628, 0x07 }, { 3089, 378, 4713, 0x07 },
{ 1614, -261, 7596, 0x07 }, { 754, -187, 9295, 0x07 },
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Horse_Zelda/EnHorseZelda_Update.s")
static InitChainEntry sInitChain[] = {
ICHAIN_F32(uncullZoneScale, 1200, ICHAIN_STOP),
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Horse_Zelda/func_80A6DFD4.s")
static EnHorseZeldaActionFunc sActionFuncs[] = {
func_80A6DCCC,
func_80A6DDFC,
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Horse_Zelda/EnHorseZelda_Draw.s")
extern SkeletonHeader D_06006B2C;
extern AnimationHeader D_06007148;
void func_80A6D8D0(unknownStruct* data, s32 index, Vec3f* vec) {
vec->x = data[index].unk_0.x;
vec->y = data[index].unk_0.y;
vec->z = data[index].unk_0.z;
}
void func_80A6D918(EnHorseZelda* this, GlobalContext* globalCtx) {
s32 pad;
Vec3f sp28;
s16 yawDiff;
func_80A6D8D0(D_80A6E240, this->unk_1EC, &sp28);
if (Math3D_Vec3f_DistXYZ(&sp28, &this->actor.posRot.pos) <= 400.0f) {
this->unk_1EC++;
if (this->unk_1EC >= 14) {
this->unk_1EC = 0;
func_80A6D8D0(D_80A6E240, 0, &sp28);
}
}
yawDiff = Math_Vec3f_Yaw(&this->actor.posRot.pos, &sp28) - this->actor.posRot.rot.y;
if (yawDiff >= 0x12D) {
this->actor.posRot.rot.y += 0x12C;
} else if (yawDiff < -0x12C) {
this->actor.posRot.rot.y -= 0x12C;
} else {
this->actor.posRot.rot.y += yawDiff;
}
this->actor.shape.rot.y = this->actor.posRot.rot.y;
if (func_8002DB8C(&this->actor, &PLAYER->actor) <= 300.0f) {
if (this->actor.speedXZ < 12.0f) {
this->actor.speedXZ += 1.0f;
} else {
this->actor.speedXZ -= 1.0f;
}
} else if (this->actor.speedXZ < D_80A6E240[this->unk_1EC].unk_6) {
this->actor.speedXZ += 0.5f;
} else {
this->actor.speedXZ -= 0.5f;
}
}
void EnHorseZelda_Init(Actor* thisx, GlobalContext* globalCtx) {
EnHorseZelda* this = THIS;
Actor_ProcessInitChain(&this->actor, sInitChain);
Actor_SetScale(&this->actor, 0.0115f);
this->actor.gravity = -3.5f;
ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawFunc_Squiggly, 20.0f);
this->actor.speedXZ = 0.0f;
this->actor.posRot2.pos = this->actor.posRot.pos;
this->action = 0;
this->actor.posRot2.pos.y += 70.0f;
func_800A663C(globalCtx, &this->skin, &D_06006B2C, &D_06007148);
this->animationIndex = 0;
SkelAnime_ChangeAnimDefaultStop(&this->skin.skelAnime, sAnimationHeaders[0]);
Collider_InitCylinder(globalCtx, &this->colliderCylinder);
Collider_SetCylinder_Set3(globalCtx, &this->colliderCylinder, &this->actor, &sCylinderInit);
Collider_InitJntSph(globalCtx, &this->colliderSphere);
Collider_SetJntSph(globalCtx, &this->colliderSphere, &this->actor, &sJntSphInit, &this->colliderSphereItem);
func_80061ED4(&this->actor.colChkInfo, NULL, &sColChkInfoInit);
this->animationIndex = 0;
func_80A6DC7C(this);
}
void EnHorseZelda_Destroy(Actor* thisx, GlobalContext* globalCtx) {
EnHorseZelda* this = THIS;
Collider_DestroyCylinder(globalCtx, &this->colliderCylinder);
Collider_DestroyJntSph(globalCtx, &this->colliderSphere);
func_800A6888(globalCtx, &this->skin);
}
void func_80A6DC7C(EnHorseZelda* this) {
this->action = 0;
this->animationIndex++;
if (this->animationIndex > 0) {
this->animationIndex = 0;
}
SkelAnime_ChangeAnimDefaultStop(&this->skin.skelAnime, sAnimationHeaders[this->animationIndex]);
}
void func_80A6DCCC(EnHorseZelda* this, GlobalContext* globalCtx) {
this->actor.speedXZ = 0.0f;
if (SkelAnime_FrameUpdateMatrix(&this->skin.skelAnime)) {
func_80A6DC7C(this);
}
}
void func_80A6DD14(EnHorseZelda* this) {
f32 sp34;
this->action = 1;
this->animationIndex = 0;
sp34 = this->actor.speedXZ / 6.0f;
Audio_PlaySoundGeneral(NA_SE_EV_HORSE_RUN, &this->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8);
SkelAnime_ChangeAnim(&this->skin.skelAnime, sAnimationHeaders[this->animationIndex],
sAnimPlaybackSpeeds[this->animationIndex] * sp34 * 1.5f, 0.0f,
SkelAnime_GetFrameCount(&sAnimationHeaders[this->animationIndex]->genericHeader), 2, 0.0f);
}
void func_80A6DDFC(EnHorseZelda* this, GlobalContext* globalCtx) {
func_80A6D918(this, globalCtx);
if (SkelAnime_FrameUpdateMatrix(&this->skin.skelAnime)) {
func_80A6DD14(this);
}
}
void func_80A6DE38(EnHorseZelda* this, GlobalContext* globalCtx) {
s32 pad;
CollisionPoly* sp38;
s32 pad2;
Vec3f sp28;
f32 sp24;
sp28.x = (Math_Sins(this->actor.shape.rot.y) * 30.0f) + this->actor.posRot.pos.x;
sp28.y = this->actor.posRot.pos.y + 60.0f;
sp28.z = (Math_Coss(this->actor.shape.rot.y) * 30.0f) + this->actor.posRot.pos.z;
this->unk_1F4 = func_8003C940(&globalCtx->colCtx, &sp38, &sp24, &sp28);
this->actor.shape.rot.x = Math_atan2f(this->actor.posRot.pos.y - this->unk_1F4, 30.0f) * (0x8000 / M_PI);
}
void EnHorseZelda_Update(Actor* thisx, GlobalContext* globalCtx) {
EnHorseZelda* this = THIS;
s32 pad;
sActionFuncs[this->action](this, globalCtx);
this->actor.speedXZ = 0.0f;
Actor_MoveForward(&this->actor);
func_8002E4B4(globalCtx, &this->actor, 20.0f, 55.0f, 100.0f, 0x1D);
this->actor.posRot2.pos = this->actor.posRot.pos;
this->actor.posRot2.pos.y += 70.0f;
Collider_CylinderUpdate(&this->actor, &this->colliderCylinder);
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderCylinder.base);
}
void func_80A6DFD4(EnHorseZelda* this, GlobalContext* globalCtx, ColliderJntSphItem* colliderSphereItem) {
Vec3f sp4C;
Vec3f sp40;
s32 pad;
s32 i;
for (i = 0; i < this->colliderSphere.count; i++) {
sp4C.x = this->colliderSphere.list[i].dim.modelSphere.center.x;
sp4C.y = this->colliderSphere.list[i].dim.modelSphere.center.y;
sp4C.z = this->colliderSphere.list[i].dim.modelSphere.center.z;
func_800A6408(colliderSphereItem, this->colliderSphere.list[i].dim.joint, &sp4C, &sp40);
this->colliderSphere.list[i].dim.worldSphere.center.x = sp40.x;
this->colliderSphere.list[i].dim.worldSphere.center.y = sp40.y;
this->colliderSphere.list[i].dim.worldSphere.center.z = sp40.z;
this->colliderSphere.list[i].dim.worldSphere.radius =
this->colliderSphere.list[i].dim.modelSphere.radius * this->colliderSphere.list[i].dim.scale;
}
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->colliderSphere.base);
}
void EnHorseZelda_Draw(Actor* thisx, GlobalContext* globalCtx) {
EnHorseZelda* this = THIS;
func_80A6DE38(this, globalCtx);
func_80093D18(globalCtx->state.gfxCtx);
func_800A6330(&this->actor, globalCtx, &this->skin, func_80A6DFD4, 1);
}

View file

@ -6,9 +6,21 @@
struct EnHorseZelda;
typedef void (*EnHorseZeldaActionFunc)(struct EnHorseZelda*, GlobalContext*);
typedef struct EnHorseZelda {
/* 0x0000 */ Actor actor;
/* 0x014C */ char unk_14C[0x15C];
/* 0x014C */ s32 action;
/* 0x0150 */ s32 animationIndex;
/* 0x0154 */ PSkinAwb skin;
/* 0x01E4 */ char unk_1E4[0x8];
/* 0x01EC */ s32 unk_1EC;
/* 0x01F0 */ char unk_1F0[0x4];
/* 0x01F4 */ f32 unk_1F4;
/* 0x01F8 */ char unk_1F8[0x4];
/* 0x01FC */ ColliderCylinder colliderCylinder;
/* 0x0248 */ ColliderJntSph colliderSphere;
/* 0x0268 */ ColliderJntSphItem colliderSphereItem;
} EnHorseZelda; // size = 0x02A8
extern const ActorInit En_Horse_Zelda_InitVars;