ovl_Bg_Hakugin_Elvpole OK (#970)

* decomp ovl_Bg_Hakugin_Elvpole, 1 nonmatching

* func_80ABD92C OK, minor cleanups

* format

* review fixes

* more cleanups
This commit is contained in:
chloe!! 2022-08-07 17:13:42 -06:00 committed by GitHub
parent 191e779189
commit db844b8ee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 103 additions and 13 deletions

3
spec
View File

@ -3219,8 +3219,7 @@ beginseg
name "ovl_Bg_Hakugin_Elvpole"
compress
include "build/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/z_bg_hakugin_elvpole.o"
include "build/data/ovl_Bg_Hakugin_Elvpole/ovl_Bg_Hakugin_Elvpole.data.o"
include "build/data/ovl_Bg_Hakugin_Elvpole/ovl_Bg_Hakugin_Elvpole.reloc.o"
include "build/src/overlays/actors/ovl_Bg_Hakugin_Elvpole/ovl_Bg_Hakugin_Elvpole_reloc.o"
endseg
beginseg

View File

@ -5,6 +5,7 @@
*/
#include "z_bg_hakugin_elvpole.h"
#include "objects/object_hakugin_obj/object_hakugin_obj.h"
#define FLAGS (ACTOR_FLAG_10)
@ -17,7 +18,6 @@ void BgHakuginElvpole_Draw(Actor* thisx, PlayState* play);
void func_80ABD92C(BgHakuginElvpole* this, PlayState* play);
#if 0
const ActorInit Bg_Hakugin_Elvpole_InitVars = {
ACTOR_BG_HAKUGIN_ELVPOLE,
ACTORCAT_BG,
@ -30,17 +30,104 @@ const ActorInit Bg_Hakugin_Elvpole_InitVars = {
(ActorFunc)BgHakuginElvpole_Draw,
};
#endif
void BgHakuginElvpole_Init(Actor* thisx, PlayState* play) {
s32 pad;
CollisionHeader* colHeader = NULL;
BgHakuginElvpole* this = THIS;
extern UNK_TYPE D_0600ACB8;
extern UNK_TYPE D_0600BF40;
Actor_SetScale(&this->dyna.actor, 0.1f);
this->actionFunc = func_80ABD92C;
DynaPolyActor_Init(&this->dyna, 0);
CollisionHeader_GetVirtual(&object_hakugin_obj_Colheader_00BF40, &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader);
this->unk_15C = 0;
this->unk_160 = false;
if ((BGHAKUGINELVPOLE_GET_SWITCHFLAG(&this->dyna.actor) != 0x7F) &&
Flags_GetSwitch(play, BGHAKUGINELVPOLE_GET_SWITCHFLAG(&this->dyna.actor))) {
this->unk_15E = 0x64;
} else {
this->unk_15E = -1;
this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 320.0f;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Elvpole/BgHakuginElvpole_Init.s")
void BgHakuginElvpole_Destroy(Actor* thisx, PlayState* play) {
BgHakuginElvpole* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Elvpole/BgHakuginElvpole_Destroy.s")
DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Elvpole/func_80ABD92C.s")
void func_80ABD92C(BgHakuginElvpole* this, PlayState* play) {
s32 pad;
s32 sp28 = false;
f32 var_fv1;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Elvpole/BgHakuginElvpole_Update.s")
if (this->unk_15E > 0) {
if ((this->dyna.actor.world.pos.y - this->dyna.actor.home.pos.y) < -120.0f) {
this->dyna.actor.world.pos.y += 4.0f;
sp28 = true;
} else if (this->unk_15E > 0) {
if (this->unk_15E == 100) {
Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP);
}
this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 120.0f;
//! FAKE:
if (1) {}
this->unk_15E--;
}
} else if (this->unk_15E == 0) {
if ((this->dyna.actor.world.pos.y - this->dyna.actor.home.pos.y) > -320.0f) {
this->dyna.actor.world.pos.y -= 4.0f;
sp28 = true;
} else {
this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 320.0f;
Flags_UnsetSwitch(play, BGHAKUGINELVPOLE_GET_SWITCHFLAG(&this->dyna.actor));
this->unk_15E = -1;
Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_STONEDOOR_STOP);
}
} else if ((BGHAKUGINELVPOLE_GET_SWITCHFLAG(&this->dyna.actor) != 0x7F) &&
Flags_GetSwitch(play, BGHAKUGINELVPOLE_GET_SWITCHFLAG(&this->dyna.actor))) {
this->unk_15E = 0x64;
this->unk_160 = true;
}
if (sp28 || (this->unk_15C & 7)) {
if (this->unk_15C & 1) {
var_fv1 = 1.0f;
} else {
var_fv1 = -1.0f;
}
this->unk_15C++;
this->dyna.actor.world.pos.x = (Math_SinS(this->unk_15C * 0x2000) * var_fv1) + this->dyna.actor.home.pos.x;
this->dyna.actor.world.pos.z = (Math_CosS(this->unk_15C * 0x2000) * var_fv1) + this->dyna.actor.home.pos.z;
func_800B9010(&this->dyna.actor, NA_SE_EV_PLATE_LIFT_LEVEL - SFX_FLAG);
} else {
this->unk_15C = 0;
}
if (this->unk_160) {
if (this->dyna.actor.cutscene == -1) {
this->unk_160 = false;
return;
} else if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) {
ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor);
this->unk_160 = false;
return;
}
ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Hakugin_Elvpole/BgHakuginElvpole_Draw.s")
void BgHakuginElvpole_Update(Actor* thisx, PlayState* play) {
BgHakuginElvpole* this = THIS;
this->actionFunc(this, play);
}
void BgHakuginElvpole_Draw(Actor* thisx, PlayState* play) {
OPEN_DISPS(play->state.gfxCtx);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
func_8012C28C(play->state.gfxCtx);
gSPDisplayList(POLY_OPA_DISP++, object_hakugin_obj_DL_00ACB8);
CLOSE_DISPS(play->state.gfxCtx);
}

View File

@ -5,11 +5,15 @@
struct BgHakuginElvpole;
#define BGHAKUGINELVPOLE_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F)
typedef void (*BgHakuginElvpoleActionFunc)(struct BgHakuginElvpole*, PlayState*);
typedef struct BgHakuginElvpole {
/* 0x000 */ Actor actor;
/* 0x144 */ char unk_144[0x20];
/* 0x000 */ DynaPolyActor dyna;
/* 0x15C */ s16 unk_15C;
/* 0x15E */ s16 unk_15E;
/* 0x160 */ u16 unk_160;
/* 0x164 */ BgHakuginElvpoleActionFunc actionFunc;
} BgHakuginElvpole; // size = 0x168