ovl_Dm_Char09 Decompiled (#996)

* progress

* progress

* 1 function left

* all functions matching

* data imported

* ovl_Dm_Char09 decompiled

* format

* sfx

* constants

* ovl_Dm_Char09 PR

* pr review

* pr review

* format

* csIndex back to temp until we know proper behav.
This commit is contained in:
Alejandro Asenjo 2022-08-15 15:20:03 -03:00 committed by GitHub
parent e44c98884b
commit e77b07296a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 209 additions and 23 deletions

3
spec
View File

@ -3157,8 +3157,7 @@ beginseg
name "ovl_Dm_Char09"
compress
include "build/src/overlays/actors/ovl_Dm_Char09/z_dm_char09.o"
include "build/data/ovl_Dm_Char09/ovl_Dm_Char09.data.o"
include "build/data/ovl_Dm_Char09/ovl_Dm_Char09.reloc.o"
include "build/src/overlays/actors/ovl_Dm_Char09/ovl_Dm_Char09_reloc.o"
endseg
beginseg

View File

@ -15,11 +15,9 @@ void DmChar09_Destroy(Actor* thisx, PlayState* play);
void DmChar09_Update(Actor* thisx, PlayState* play);
void DmChar09_Draw(Actor* thisx, PlayState* play);
void func_80AB1FDC(DmChar09* this, PlayState* play);
void func_80AB2258(DmChar09* this, PlayState* play);
void DmChar09_DoNothing(DmChar09* this, PlayState* play);
void func_80AB2268(DmChar09* this, PlayState* play);
#if 0
const ActorInit Dm_Char09_InitVars = {
ACTOR_DM_CHAR09,
ACTORCAT_ITEMACTION,
@ -32,28 +30,197 @@ const ActorInit Dm_Char09_InitVars = {
(ActorFunc)DmChar09_Draw,
};
#endif
static AnimationInfo sAnimationInfo[] = {
{ &object_bee_Anim_00005C, 1.0f, 0.0f, -1.0f, ANIMMODE_LOOP, 0.0f },
};
extern UNK_TYPE D_0600005C;
void DmChar09_ChangeAnim(SkelAnime* skelAnime, AnimationInfo* animationInfo, u16 animIndex) {
f32 frameCount;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/func_80AB1E10.s")
animationInfo += animIndex;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/DmChar09_Init.s")
if (animationInfo->frameCount < 0.0f) {
frameCount = Animation_GetLastFrame(animationInfo->animation);
} else {
frameCount = animationInfo->frameCount;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/DmChar09_Destroy.s")
Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed, animationInfo->startFrame,
frameCount, animationInfo->mode, animationInfo->morphFrames);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/func_80AB1FA0.s")
void DmChar09_Init(Actor* thisx, PlayState* play) {
DmChar09* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/func_80AB1FDC.s")
ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 19.0f);
SkelAnime_Init(play, &this->skelAnime, &object_bee_Skel_001398, &object_bee_Anim_00005C, this->jointTable,
this->morphTable, OBJECT_BEE_LIMB_MAX);
DmChar09_ChangeAnim(&this->skelAnime, sAnimationInfo, 0);
Actor_SetScale(&this->actor, 0.01f);
this->unk_228 = Rand_ZeroOne() * 65535.0f;
this->unk_22A = Rand_ZeroOne() * 65535.0f;
this->actionFunc = DmChar09_DoNothing;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/func_80AB2258.s")
void DmChar09_Destroy(Actor* thisx, PlayState* play) {
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/func_80AB2268.s")
void func_80AB1FA0(DmChar09* this, s32 arg1) {
Math_Vec3s_ToVec3f(&this->actor.world.pos, &this->unk_224[arg1]);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/func_80AB24BC.s")
void func_80AB1FDC(DmChar09* this, PlayState* play) {
Actor* thisx = &this->actor;
Vec3f sp58;
f32 sp54;
f32 phi_fa0;
f32 phi_fv0;
Vec3f sp40;
s32 phi_a1;
Vec3s* temp_v1;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/DmChar09_Update.s")
Math_Vec3f_Copy(&sp40, &thisx->world.pos);
Math_Vec3s_ToVec3f(&sp58, this->unk_224 + this->unk_21C + this->unk_220);
Math_Vec3f_Diff(&sp58, &thisx->world.pos, &thisx->velocity);
sp54 = Math3D_Vec3fMagnitude(&thisx->velocity);
if ((sp54 < (this->speed * 8.0f)) && (this->speed > 2.0f)) {
phi_fv0 = ((this->speed - 2.0f) * 0.1f) + 2.0f;
phi_fa0 = this->speed * 0.03f;
} else {
phi_fv0 = this->speed;
phi_fa0 = this->speed * 0.16f;
}
Math_StepToF(&thisx->speedXZ, phi_fv0, phi_fa0);
if ((thisx->speedXZ + 0.05f) < sp54) {
Math_Vec3f_Scale(&thisx->velocity, thisx->speedXZ / sp54);
thisx->world.pos.x += thisx->velocity.x;
thisx->world.pos.y += thisx->velocity.y;
thisx->world.pos.z += thisx->velocity.z;
} else {
this->unk_21C += this->unk_220;
thisx->speedXZ *= 0.4f;
phi_a1 = true;
if (((this->unk_21C >= this->unk_218) && (this->unk_220 > 0)) ||
((this->unk_21C <= 0) && (this->unk_220 < 0))) {
temp_v1 = this->unk_224 + this->unk_218;
if (((this->unk_224->x == temp_v1->x) && (this->unk_224->y == temp_v1->y)) &&
(this->unk_224->z == temp_v1->z)) {
this->unk_21C = 0;
this->unk_220 = 1;
} else {
phi_a1 = false;
this->actionFunc = func_80AB2268;
}
}
if (phi_a1) {
func_80AB1FA0(this, this->unk_21C);
}
}
Math_SmoothStepToS(&thisx->world.rot.y, Math_Vec3f_Yaw(&thisx->world.pos, &sp40) + 0x7FFF, 1, 0x7D0, 0);
thisx->shape.rot.y = thisx->world.rot.y;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/func_80AB25D8.s")
void DmChar09_DoNothing(DmChar09* this, PlayState* play) {
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Char09/DmChar09_Draw.s")
void func_80AB2268(DmChar09* this, PlayState* play) {
Path* path;
s32 pad;
s32 i;
s32 actionIndex;
s32 max = 0;
s32 pathnum;
u8 temp = false;
if (!DMCHAR09_GET_F(&this->actor)) {
if (play->csCtx.currentCsIndex == 1) {
temp = true;
}
} else if (play->csCtx.currentCsIndex == 0) {
temp = true;
}
if (Cutscene_CheckActorAction(play, 0x1F7) && temp) {
actionIndex = Cutscene_GetActorActionIndex(play, 0x1F7);
if (this->unk_22F != play->csCtx.actorActions[actionIndex]->action) {
this->unk_22F = play->csCtx.actorActions[actionIndex]->action;
switch (play->csCtx.actorActions[actionIndex]->action) {
case 2:
max = 0;
break;
case 3:
max = 1;
break;
case 4:
max = 2;
break;
case 5:
max = 3;
break;
}
if (play->csCtx.actorActions[actionIndex]->action >= 2) {
pathnum = DMCHAR09_GET_PATH(&this->actor);
path = &play->setupPathList[pathnum];
for (i = 0; i < max; i++) {
pathnum = path->unk1;
path = &play->setupPathList[pathnum];
}
this->unk_224 = Lib_SegmentedToVirtual(path->points);
this->unk_214 = path->count;
this->unk_21C = 0;
this->unk_218 = path->count - 1;
this->unk_220 = 1;
this->unk_22E = true;
this->speed = (u16)play->csCtx.actorActions[actionIndex]->rot.z * 0.00390625f;
this->actionFunc = func_80AB1FDC;
} else {
this->unk_22E = false;
this->actionFunc = DmChar09_DoNothing;
}
}
} else {
this->unk_22F = 0x63;
}
}
void func_80AB24BC(DmChar09* this, PlayState* play) {
this->unk_228 += 0xBB8;
this->unk_22A += 0x1388;
this->unk_204 = Math_SinS(this->unk_228) * 150.0f;
this->unk_208 = Math_SinS(this->unk_22A) * 150.0f;
this->unk_20C = Math_SinS(this->unk_228) * 150.0f;
}
void DmChar09_Update(Actor* thisx, PlayState* play) {
DmChar09* this = THIS;
SkelAnime_Update(&this->skelAnime);
this->actionFunc(this, play);
func_80AB2268(this, play);
func_80AB24BC(this, play);
if ((play->csCtx.state != 0) && this->unk_22E && DMCHAR09_GET_100(thisx)) {
Actor_PlaySfxAtPos(&this->actor, NA_SE_EV_POSTMAN_WALK + SFX_FLAG);
}
}
s32 DmChar09_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) {
DmChar09* this = THIS;
Matrix_Translate(this->unk_204, this->unk_208, this->unk_20C, MTXMODE_APPLY);
return false;
}
void DmChar09_Draw(Actor* thisx, PlayState* play) {
DmChar09* this = THIS;
if ((play->csCtx.state != 0) && this->unk_22E) {
func_8012C28C(play->state.gfxCtx);
func_8012C2DC(play->state.gfxCtx);
SkelAnime_DrawOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, DmChar09_OverrideLimbDraw, NULL,
&this->actor);
}
}

View File

@ -2,6 +2,11 @@
#define Z_DM_CHAR09_H
#include "global.h"
#include "objects/object_bee/object_bee.h"
#define DMCHAR09_GET_PATH(thisx) (((thisx)->params >> 4) & 0xF)
#define DMCHAR09_GET_100(thisx) ((thisx)->params & 0x100)
#define DMCHAR09_GET_F(thisx) ((thisx)->params & 0xF)
struct DmChar09;
@ -9,9 +14,24 @@ typedef void (*DmChar09ActionFunc)(struct DmChar09*, PlayState*);
typedef struct DmChar09 {
/* 0x000 */ Actor actor;
/* 0x144 */ char unk_144[0xBC];
/* 0x144 */ SkelAnime skelAnime;
/* 0x188 */ Vec3s jointTable[OBJECT_BEE_LIMB_MAX];
/* 0x1C4 */ Vec3s morphTable[OBJECT_BEE_LIMB_MAX];
/* 0x200 */ DmChar09ActionFunc actionFunc;
/* 0x204 */ char unk_204[0x2C];
/* 0x204 */ f32 unk_204;
/* 0x208 */ f32 unk_208;
/* 0x20C */ f32 unk_20C;
/* 0x210 */ f32 speed;
/* 0x214 */ s32 unk_214;
/* 0x218 */ s32 unk_218;
/* 0x21C */ s32 unk_21C;
/* 0x220 */ s32 unk_220;
/* 0x224 */ Vec3s* unk_224;
/* 0x228 */ s16 unk_228;
/* 0x22A */ s16 unk_22A;
/* 0x22C */ UNK_TYPE1 pad22C[2];
/* 0x22E */ u8 unk_22E;
/* 0x22F */ u8 unk_22F;
} DmChar09; // size = 0x230
extern const ActorInit Dm_Char09_InitVars;

View File

@ -11656,16 +11656,16 @@
0x80AB0E7C:("func_80AB0E7C",),
0x80AB0F90:("func_80AB0F90",),
0x80AB1124:("DmChar08_Draw",),
0x80AB1E10:("func_80AB1E10",),
0x80AB1E10:("DmChar09_ChangeAnim",),
0x80AB1EAC:("DmChar09_Init",),
0x80AB1F90:("DmChar09_Destroy",),
0x80AB1FA0:("func_80AB1FA0",),
0x80AB1FDC:("func_80AB1FDC",),
0x80AB2258:("func_80AB2258",),
0x80AB2258:("DmChar09_DoNothing",),
0x80AB2268:("func_80AB2268",),
0x80AB24BC:("func_80AB24BC",),
0x80AB2544:("DmChar09_Update",),
0x80AB25D8:("func_80AB25D8",),
0x80AB25D8:("DmChar09_OverrideLimbDraw",),
0x80AB261C:("DmChar09_Draw",),
0x80AB2790:("ObjTokeidai_GetTargetSunMoonPanelRotation",),
0x80AB27B4:("ObjTokeidai_SetupClockOrExteriorGear",),