ovl_Bg_Keikoku_Saku decompiled (#847)

* ovl_Bg_Keikoku_Saku decompiled

* reloc change

* BGKEIKOKUSAKU_GET_SWITCHFLAG name fix

* pr review fixes

* pr review fixes

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

3
spec
View File

@ -2891,8 +2891,7 @@ beginseg
name "ovl_Bg_Keikoku_Saku" name "ovl_Bg_Keikoku_Saku"
compress compress
include "build/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.o" include "build/src/overlays/actors/ovl_Bg_Keikoku_Saku/z_bg_keikoku_saku.o"
include "build/data/ovl_Bg_Keikoku_Saku/ovl_Bg_Keikoku_Saku.data.o" include "build/src/overlays/actors/ovl_Bg_Keikoku_Saku/ovl_Bg_Keikoku_Saku_reloc.o"
include "build/data/ovl_Bg_Keikoku_Saku/ovl_Bg_Keikoku_Saku.reloc.o"
endseg endseg
beginseg beginseg

View File

@ -5,6 +5,7 @@
*/ */
#include "z_bg_keikoku_saku.h" #include "z_bg_keikoku_saku.h"
#include "objects/object_keikoku_obj/object_keikoku_obj.h"
#define FLAGS 0x00000000 #define FLAGS 0x00000000
@ -15,7 +16,10 @@ void BgKeikokuSaku_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgKeikokuSaku_Update(Actor* thisx, GlobalContext* globalCtx); void BgKeikokuSaku_Update(Actor* thisx, GlobalContext* globalCtx);
void BgKeikokuSaku_Draw(Actor* thisx, GlobalContext* globalCtx); void BgKeikokuSaku_Draw(Actor* thisx, GlobalContext* globalCtx);
#if 0 void func_80A5389C(BgKeikokuSaku* this, GlobalContext* globalCtx);
void func_80A538E0(BgKeikokuSaku* this, GlobalContext* globalCtx);
void func_80A53994(BgKeikokuSaku* this, GlobalContext* globalCtx);
const ActorInit Bg_Keikoku_Saku_InitVars = { const ActorInit Bg_Keikoku_Saku_InitVars = {
ACTOR_BG_KEIKOKU_SAKU, ACTOR_BG_KEIKOKU_SAKU,
ACTORCAT_ITEMACTION, ACTORCAT_ITEMACTION,
@ -28,21 +32,71 @@ const ActorInit Bg_Keikoku_Saku_InitVars = {
(ActorFunc)BgKeikokuSaku_Draw, (ActorFunc)BgKeikokuSaku_Draw,
}; };
#endif void BgKeikokuSaku_Init(Actor* thisx, GlobalContext* globalCtx) {
s32 pad;
BgKeikokuSaku* this = THIS;
CollisionHeader* colHeader = NULL;
extern UNK_TYPE D_06001640; DynaPolyActor_Init(&this->dyna, 0);
extern UNK_TYPE D_06002300; CollisionHeader_GetVirtual(&object_keikoku_obj_Colheader_002300, &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader);
this->switchFlag = BGKEIKOKUSAKU_GET_SWITCHFLAG(thisx);
if (Flags_GetSwitch(globalCtx, this->switchFlag)) {
this->dyna.actor.world.pos.z = 2659.0f;
} else {
this->actionFunc = func_80A5389C;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/BgKeikokuSaku_Init.s") void BgKeikokuSaku_Destroy(Actor* thisx, GlobalContext* globalCtx) {
BgKeikokuSaku* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/BgKeikokuSaku_Destroy.s") DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/func_80A5389C.s") void func_80A5389C(BgKeikokuSaku* this, GlobalContext* globalCtx) {
if (Flags_GetSwitch(globalCtx, this->switchFlag)) {
this->actionFunc = func_80A538E0;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/func_80A538E0.s") void func_80A538E0(BgKeikokuSaku* this, GlobalContext* globalCtx) {
Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_METALGATE_OPEN - SFX_FLAG);
this->dyna.actor.world.pos.z -= 2.0f + BREG(8);
if (this->dyna.actor.world.pos.z < (BREG(9) + 2660.0f)) {
Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BRIDGE_OPEN_STOP);
this->timer = 30;
this->actionFunc = func_80A53994;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/func_80A53994.s") void func_80A53994(BgKeikokuSaku* this, GlobalContext* globalCtx) {
if (this->timer == 0) {
this->actionFunc = func_80A5389C;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/BgKeikokuSaku_Update.s") void BgKeikokuSaku_Update(Actor* thisx, GlobalContext* globalCtx) {
BgKeikokuSaku* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Keikoku_Saku/BgKeikokuSaku_Draw.s") if (this->timer) {
this->timer--;
}
this->dyna.actor.world.pos.x = BREG(5) + this->dyna.actor.home.pos.x;
this->dyna.actor.world.pos.y = BREG(6) + this->dyna.actor.home.pos.y;
this->dyna.actor.world.pos.z = BREG(7) + this->dyna.actor.home.pos.z;
this->dyna.actor.scale.x = (BREG(10) / 1000.0f) + 0.1f;
this->dyna.actor.scale.y = (BREG(11) / 1000.0f) + 0.1f;
this->dyna.actor.scale.z = (BREG(12) / 1000.0f) + 0.1f;
this->actionFunc(this, globalCtx);
}
void BgKeikokuSaku_Draw(Actor* thisx, GlobalContext* globalCtx) {
OPEN_DISPS(globalCtx->state.gfxCtx);
func_8012C2DC(globalCtx->state.gfxCtx);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, object_keikoku_obj_DL_001640);
CLOSE_DISPS(globalCtx->state.gfxCtx);
}

View File

@ -3,17 +3,18 @@
#include "global.h" #include "global.h"
#define BGKEIKOKUSAKU_GET_SWITCHFLAG(thisx) ((thisx)->params & 0x7F)
struct BgKeikokuSaku; struct BgKeikokuSaku;
typedef void (*BgKeikokuSakuActionFunc)(struct BgKeikokuSaku*, GlobalContext*); typedef void (*BgKeikokuSakuActionFunc)(struct BgKeikokuSaku*, GlobalContext*);
typedef struct BgKeikokuSaku { typedef struct BgKeikokuSaku {
/* 0x0000 */ Actor actor; /* 0x000 */ DynaPolyActor dyna;
/* 0x0144 */ char unk_144[0x18]; /* 0x15C */ BgKeikokuSakuActionFunc actionFunc;
/* 0x015C */ BgKeikokuSakuActionFunc actionFunc; /* 0x160 */ s16 switchFlag;
/* 0x0160 */ char unk_160[0x4]; /* 0x162 */ s16 timer;
} BgKeikokuSaku; // size = 0x164 } BgKeikokuSaku; // Size = 0x164
extern const ActorInit Bg_Keikoku_Saku_InitVars; extern const ActorInit Bg_Keikoku_Saku_InitVars;
#endif // Z_BG_KEIKOKU_SAKU_H #endif // Z_BG_KEIKOKU_SAKU_H

View File

@ -644,11 +644,6 @@ D_06012700 = 0x06012700;
D_06012728 = 0x06012728; D_06012728 = 0x06012728;
D_06012788 = 0x06012788; D_06012788 = 0x06012788;
// ovl_Bg_Keikoku_Saku
D_06001640 = 0x06001640;
D_06002300 = 0x06002300;
// ovl_Bg_Kin2_Bombwall // ovl_Bg_Kin2_Bombwall
D_06000128 = 0x06000128; D_06000128 = 0x06000128;