ovl_Dm_Bal decompiled (#846)

* All functions match, data import problem present

* * importing succeed
* final clean up
* fixed warnings

* pr fixes

* pr review fixes

* PR review fix

* pr review fixes

* fixes

Co-authored-by: SonicDcer <noreply@github.com>
This commit is contained in:
Alejandro Asenjo 2022-06-19 20:13:25 -03:00 committed by GitHub
parent 1ce5d13677
commit f0c1e17fd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 178 additions and 25 deletions

3
spec
View File

@ -5162,8 +5162,7 @@ beginseg
name "ovl_Dm_Bal"
compress
include "build/src/overlays/actors/ovl_Dm_Bal/z_dm_bal.o"
include "build/data/ovl_Dm_Bal/ovl_Dm_Bal.data.o"
include "build/data/ovl_Dm_Bal/ovl_Dm_Bal.reloc.o"
include "build/src/overlays/actors/ovl_Dm_Bal/ovl_Dm_Bal_reloc.o"
endseg
beginseg

View File

@ -15,9 +15,9 @@ void DmBal_Destroy(Actor* thisx, GlobalContext* globalCtx);
void DmBal_Update(Actor* thisx, GlobalContext* globalCtx);
void DmBal_Draw(Actor* thisx, GlobalContext* globalCtx);
void func_80C1EAC4(DmBal* this);
void func_80C1EAD8(DmBal* this, GlobalContext* globalCtx);
#if 0
const ActorInit Dm_Bal_InitVars = {
ACTOR_DM_BAL,
ACTORCAT_NPC,
@ -30,31 +30,176 @@ const ActorInit Dm_Bal_InitVars = {
(ActorFunc)DmBal_Draw,
};
#endif
static AnimationInfo D_80C1F170[] = {
{ &object_bal_Anim_0005FC, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f },
{ &object_bal_Anim_000840, 1.5f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f },
{ &object_bal_Anim_000840, 1.5f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f },
{ &object_bal_Anim_00A7DC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -4.0f },
{ &object_bal_Anim_00B1E8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f },
{ &object_bal_Anim_00B604, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f },
{ &object_bal_Anim_00C498, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f },
{ &object_bal_Anim_00C8D8, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f },
{ &object_bal_Anim_00C8D8, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f },
{ &object_bal_Anim_00C498, 1.0f, 23.0f, 0.0f, ANIMMODE_ONCE, -8.0f },
{ &object_bal_Anim_00D530, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f },
{ &object_bal_Anim_000C78, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -2.0f },
{ &object_bal_Anim_00CB78, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -2.0f },
{ &object_bal_Anim_001804, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -2.0f },
};
extern UNK_TYPE D_060005FC;
extern UNK_TYPE D_06001804;
void DmBal_Init(Actor* thisx, GlobalContext* globalCtx) {
DmBal* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/DmBal_Init.s")
this->actor.targetMode = 1;
this->actor.uncullZoneForward = 3000.0f;
Actor_SetScale(&this->actor, 0.02f);
ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f);
SkelAnime_InitFlex(globalCtx, &this->skelAnime, &object_bal_Skel_00A6D0, &object_bal_Anim_0005FC, this->jointTable,
this->morphTable, OBJECT_BAL_LIMB_MAX);
Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 0.0f, 0.0f, 0.0f, 4);
this->timer = 60;
this->eyeIndex = 0;
this->unk_336 = 0;
func_80C1EAC4(this);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/DmBal_Destroy.s")
void DmBal_Destroy(Actor* thisx, GlobalContext* globalCtx) {
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EAC4.s")
void func_80C1EAC4(DmBal* this) {
this->actionFunc = func_80C1EAD8;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EAD8.s")
void func_80C1EAD8(DmBal* this, GlobalContext* globalCtx) {
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EAE8.s")
void func_80C1EAE8(DmBal* this, GlobalContext* globalCtx) {
static u16 D_80C1F2C0 = 0x63;
s32 actionIndex;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EC60.s")
if (Cutscene_CheckActorAction(globalCtx, 0x238)) {
actionIndex = Cutscene_GetActorActionIndex(globalCtx, 0x238);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1ED0C.s")
if (D_80C1F2C0 != globalCtx->csCtx.actorActions[actionIndex]->action) {
D_80C1F2C0 = globalCtx->csCtx.actorActions[actionIndex]->action;
switch (globalCtx->csCtx.actorActions[actionIndex]->action) {
case 1:
this->unk_336 = 0;
this->eyeIndex = 0;
Actor_ChangeAnimationByInfo(&this->skelAnime, D_80C1F170, 0);
break;
case 2:
this->unk_336 = 1;
Actor_ChangeAnimationByInfo(&this->skelAnime, D_80C1F170, 12);
break;
case 3:
Actor_ChangeAnimationByInfo(&this->skelAnime, D_80C1F170, 13);
break;
}
} else if (D_80C1F2C0 == 3) {
if (Animation_OnFrame(&this->skelAnime, 0.0f)) {
this->unk_336 = 1;
} else if (Animation_OnFrame(&this->skelAnime, 29.0f)) {
this->unk_336 = 0;
this->eyeIndex = 0;
}
}
Cutscene_ActorTranslateAndYaw(&this->actor, globalCtx, actionIndex);
this->actor.home.pos = this->actor.world.pos;
} else {
this->unk_336 = 0;
this->eyeIndex = 0;
D_80C1F2C0 = 0x63;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1ED64.s")
void func_80C1EC60(DmBal* this, GlobalContext* globalCtx) {
f32 temp_fv1_2;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/DmBal_Update.s")
this->unk_338 += 0x320;
this->unk_33A += 0x3E8;
this->scale.y = this->scale.z = Math_CosS(this->unk_338) * 0.1f + 1.0f;
temp_fv1_2 = (Math_SinS(this->unk_338) * 0.1f) + 1.0f;
this->scale.x = SQ(temp_fv1_2);
this->actor.world.pos.y = this->actor.home.pos.y + (Math_SinS(this->unk_338) * 25.0f);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1EF80.s")
void func_80C1ED0C(DmBal* this) {
if (this->unk_336 == 1) {
this->eyeIndex = 1;
} else if (this->timer >= 4) {
this->timer--;
} else if (this->timer != 0) {
this->eyeIndex = 1;
this->timer--;
} else {
this->eyeIndex = 0;
this->timer = 60;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/func_80C1F060.s")
void func_80C1ED64(DmBal* this, GlobalContext* globalCtx, Vec3f* arg2, Vec3f* arg3, f32 arg4) {
Actor* paper = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_PAPER, arg2->x, arg2->y, arg2->z, 0, 0, 0, 0);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Dm_Bal/DmBal_Draw.s")
if (paper != NULL) {
paper->velocity = *arg3;
paper->gravity = arg4;
}
}
Vec3f D_80C1F2C4 = { 0.0f, 9.0f, 0.0f };
void DmBal_Update(Actor* thisx, GlobalContext* globalCtx) {
s32 pad;
DmBal* this = THIS;
Vec3f sp3C;
Vec3f sp30;
if (Animation_OnFrame(&this->skelAnime, 29.0f) && (this->skelAnime.animation == &object_bal_Anim_001804)) {
sp3C = this->actor.world.pos;
sp30 = D_80C1F2C4;
sp3C.x += 7.0f * Math_SinS(this->actor.shape.rot.y);
sp3C.y += 2.5f;
sp3C.z += 7.0f * Math_CosS(this->actor.shape.rot.y);
sp30.x = Math_SinS(this->actor.shape.rot.y) * 5.0f;
sp30.z = Math_CosS(this->actor.shape.rot.y) * 5.0f;
func_80C1ED64(this, globalCtx, &sp3C, &sp30, -0.4f);
func_80C1ED64(this, globalCtx, &sp3C, &sp30, -0.5f);
}
this->actionFunc(this, globalCtx);
func_80C1EAE8(this, globalCtx);
func_80C1EC60(this, globalCtx);
func_80C1ED0C(this);
SkelAnime_Update(&this->skelAnime);
}
s32 DmBal_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) {
DmBal* this = THIS;
Vec3s rots;
if (limbIndex == 6) {
rots.x = Math_SinS(this->unk_33A) * 3640.0f;
rots.z = Math_CosS(this->unk_33A) * 3640.0f;
Matrix_RotateZYX(rots.x, 0, rots.z, MTXMODE_APPLY);
Matrix_Scale(this->scale.x, this->scale.y, this->scale.z, MTXMODE_APPLY);
Matrix_RotateZS(-rots.z, MTXMODE_APPLY);
Matrix_RotateXS(-rots.x, MTXMODE_APPLY);
}
return false;
}
void DmBal_PostLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) {
}
TexturePtr sEyeTextures[] = { object_bal_Tex_006050, object_bal_Tex_0094D0 };
void DmBal_Draw(Actor* thisx, GlobalContext* globalCtx) {
DmBal* this = THIS;
OPEN_DISPS(globalCtx->state.gfxCtx);
func_8012C28C(globalCtx->state.gfxCtx);
gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sEyeTextures[this->eyeIndex]));
SkelAnime_DrawFlexOpa(globalCtx, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount,
DmBal_OverrideLimbDraw, DmBal_PostLimbDraw, &this->actor);
CLOSE_DISPS(globalCtx->state.gfxCtx);
}

View File

@ -2,17 +2,26 @@
#define Z_DM_BAL_H
#include "global.h"
#include "objects/object_bal/object_bal.h"
struct DmBal;
typedef void (*DmBalActionFunc)(struct DmBal*, GlobalContext*);
typedef struct DmBal {
/* 0x0000 */ Actor actor;
/* 0x0144 */ char unk_144[0x44];
/* 0x0188 */ DmBalActionFunc actionFunc;
/* 0x018C */ char unk_18C[0x1B0];
} DmBal; // size = 0x33C
/* 0x000 */ Actor actor;
/* 0x144 */ SkelAnime skelAnime;
/* 0x188 */ DmBalActionFunc actionFunc;
/* 0x18C */ Vec3f scale;
/* 0x198 */ s32 eyeIndex;
/* 0x262 */ Vec3s jointTable[OBJECT_BAL_LIMB_MAX];
/* 0x19C */ Vec3s morphTable[OBJECT_BAL_LIMB_MAX];
/* 0x328 */ UNK_TYPE1 pad_328[12];
/* 0x334 */ s16 timer;
/* 0x336 */ s16 unk_336;
/* 0x338 */ s16 unk_338;
/* 0x33A */ s16 unk_33A;
} DmBal; /* size = 0x33C */
extern const ActorInit Dm_Bal_InitVars;

View File

@ -16997,8 +16997,8 @@
0x80C1ED0C:("func_80C1ED0C",),
0x80C1ED64:("func_80C1ED64",),
0x80C1EDE4:("DmBal_Update",),
0x80C1EF80:("func_80C1EF80",),
0x80C1F060:("func_80C1F060",),
0x80C1EF80:("DmBal_OverrideLimbDraw",),
0x80C1F060:("DmBal_PostLimbDraw",),
0x80C1F078:("DmBal_Draw",),
0x80C1F3D0:("EnPaper_Init",),
0x80C1F45C:("EnPaper_Destroy",),