1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-05 22:00:15 +00:00

ovl_bg_haka_ship OK (#712)

* 2 non matchings left

* decompiled ovl_Bg_Haka_Ship

* review suggestions

* parent/child (Actor*)

* removed unneeded cast

* removed DECR

* review 2 suggestions, removed some redundant parentheses
This commit is contained in:
emilybrooks 2021-03-10 17:02:22 -07:00 committed by GitHub
parent 80d0b2785d
commit 7c5ae8cc03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 207 additions and 804 deletions

View file

@ -14,22 +14,20 @@ void BgHakaShip_Init(Actor* thisx, GlobalContext* globalCtx);
void BgHakaShip_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgHakaShip_Update(Actor* thisx, GlobalContext* globalCtx);
void BgHakaShip_Draw(Actor* thisx, GlobalContext* globalCtx);
void BgHakaShip_ChildUpdatePosition(BgHakaShip* this, GlobalContext* globalCtx);
void BgHakaShip_WaitForSong(BgHakaShip* this, GlobalContext* globalCtx);
void BgHakaShip_CutsceneStationary(BgHakaShip* this, GlobalContext* globalCtx);
void BgHakaShip_Move(BgHakaShip* this, GlobalContext* globalCtx);
void BgHakaShip_SetupCrash(BgHakaShip* this, GlobalContext* globalCtx);
void BgHakaShip_CrashShake(BgHakaShip* this, GlobalContext* globalCtx);
void BgHakaShip_CrashFall(BgHakaShip* this, GlobalContext* globalCtx);
void func_8087F27C(BgHakaShip* this, GlobalContext* globalCtx);
void func_8087F2D8(BgHakaShip* this, GlobalContext* globalCtx);
void func_8087F364(BgHakaShip* this, GlobalContext* globalCtx);
void func_8087F400(BgHakaShip* this, GlobalContext* globalCtx);
void func_8087F5C8(BgHakaShip* this, GlobalContext* globalCtx);
void func_8087F624(BgHakaShip* this, GlobalContext* globalCtx);
void func_8087F6B4(BgHakaShip* this, GlobalContext* globalCtx);
extern Gfx D_06005A70[];
extern Gfx D_0600D330[];
extern CollisionHeader D_0600E408;
extern Gfx D_0600E910[];
extern CollisionHeader D_0600ED7C;
extern UNK_TYPE D_06005A70;
extern UNK_TYPE D_0600D330;
extern UNK_TYPE D_0600E408;
extern UNK_TYPE D_0600E910;
extern UNK_TYPE D_0600ED7C;
/*
const ActorInit Bg_Haka_Ship_InitVars = {
ACTOR_BG_HAKA_SHIP,
ACTORCAT_BG,
@ -41,25 +39,203 @@ const ActorInit Bg_Haka_Ship_InitVars = {
(ActorFunc)BgHakaShip_Update,
(ActorFunc)BgHakaShip_Draw,
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Ship/BgHakaShip_Init.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Ship/BgHakaShip_Destroy.s")
static InitChainEntry sInitChain[] = {
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP),
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Ship/func_8087F27C.s")
void BgHakaShip_Init(Actor* thisx, GlobalContext* globalCtx) {
BgHakaShip* this = THIS;
s32 pad;
CollisionHeader* colHeader = NULL;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Ship/func_8087F2D8.s")
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
DynaPolyActor_Init(&this->dyna, 1);
this->switchFlag = (thisx->params >> 8) & 0xFF;
this->dyna.actor.params &= 0xFF;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Ship/func_8087F364.s")
if (this->dyna.actor.params == 0) {
CollisionHeader_GetVirtual(&D_0600E408, &colHeader);
this->counter = 8;
this->actionFunc = BgHakaShip_WaitForSong;
} else {
CollisionHeader_GetVirtual(&D_0600ED7C, &colHeader);
this->actionFunc = BgHakaShip_ChildUpdatePosition;
}
this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, colHeader);
this->dyna.actor.world.rot.y = this->dyna.actor.shape.rot.y - 0x4000;
this->yOffset = 0;
if (this->dyna.actor.params == 0 &&
Actor_SpawnAsChild(&globalCtx->actorCtx, &this->dyna.actor, globalCtx, ACTOR_BG_HAKA_SHIP,
this->dyna.actor.world.pos.x + -10.0f, this->dyna.actor.world.pos.y + 82.0f,
this->dyna.actor.world.pos.z, 0, 0, 0, 1) == NULL) {
Actor_Kill(&this->dyna.actor);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Ship/func_8087F400.s")
void BgHakaShip_Destroy(Actor* thisx, GlobalContext* globalCtx) {
BgHakaShip* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Ship/func_8087F5C8.s")
DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
func_800F89E8(&this->bellSoundPos);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Ship/func_8087F624.s")
void BgHakaShip_ChildUpdatePosition(BgHakaShip* this, GlobalContext* globalCtx) {
Actor* parent = this->dyna.actor.parent;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Ship/func_8087F6B4.s")
if (parent != NULL && parent->update != NULL) {
this->dyna.actor.world.pos.x = parent->world.pos.x + -10.0f;
this->dyna.actor.world.pos.y = parent->world.pos.y + 82.0f;
this->dyna.actor.world.pos.z = parent->world.pos.z;
} else {
this->dyna.actor.parent = NULL;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Ship/BgHakaShip_Update.s")
void BgHakaShip_WaitForSong(BgHakaShip* this, GlobalContext* globalCtx) {
if (Flags_GetSwitch(globalCtx, this->switchFlag)) {
if (this->counter) {
this->counter--;
}
if (this->counter == 0) {
this->counter = 130;
this->actionFunc = BgHakaShip_CutsceneStationary;
osSyncPrintf("シーン 外輪船 ... アァクション!!\n");
func_800800F8(globalCtx, 0xD3E, 999, &this->dyna.actor, 0);
}
}
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka_Ship/BgHakaShip_Draw.s")
void BgHakaShip_CutsceneStationary(BgHakaShip* this, GlobalContext* globalCtx) {
if (this->counter) {
this->counter--;
}
this->yOffset = sinf(this->counter * (M_PI / 25)) * 6144.0f;
if (this->counter == 0) {
this->counter = 50;
this->actionFunc = BgHakaShip_Move;
}
}
void BgHakaShip_Move(BgHakaShip* this, GlobalContext* globalCtx) {
f32 distanceFromHome;
Actor* child;
if (this->counter) {
this->counter--;
}
if (this->counter == 0) {
this->counter = 50;
}
this->dyna.actor.world.pos.y = (sinf(this->counter * (M_PI / 25)) * 50.0f) + this->dyna.actor.home.pos.y;
distanceFromHome = this->dyna.actor.home.pos.x - this->dyna.actor.world.pos.x;
if (distanceFromHome > 7650.0f) {
this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x - 7650.0f;
this->dyna.actor.speedXZ = 0.0f;
}
if (distanceFromHome > 7600.0f && !Gameplay_InCsMode(globalCtx)) {
this->counter = 40;
this->dyna.actor.speedXZ = 0.0f;
func_8010B680(globalCtx, 0x5071, NULL);
this->actionFunc = BgHakaShip_SetupCrash;
} else {
Math_StepToF(&this->dyna.actor.speedXZ, 4.0f, 0.2f);
}
child = this->dyna.actor.child;
if (child != NULL && child->update != NULL) {
child->shape.rot.z += ((655.0f / 13.0f) * this->dyna.actor.speedXZ);
} else {
this->dyna.actor.child = NULL;
}
this->yOffset = sinf(this->counter * (M_PI / 25)) * 6144.0f;
}
void BgHakaShip_SetupCrash(BgHakaShip* this, GlobalContext* globalCtx) {
if (this->counter) {
this->counter--;
}
if (this->counter == 0) {
this->counter = 40;
this->actionFunc = BgHakaShip_CrashShake;
}
Math_ScaledStepToS(&this->yOffset, 0, 128);
}
void BgHakaShip_CrashShake(BgHakaShip* this, GlobalContext* globalCtx) {
if (this->counter != 0) {
this->counter--;
}
this->dyna.actor.world.pos.y = this->counter % 4 * 3 - 6 + this->dyna.actor.home.pos.y;
if (!this->counter) {
this->dyna.actor.gravity = -1.0f;
this->actionFunc = BgHakaShip_CrashFall;
}
func_8002F974(&this->dyna.actor, NA_SE_EV_BLOCKSINK - SFX_FLAG);
}
void BgHakaShip_CrashFall(BgHakaShip* this, GlobalContext* globalCtx) {
Actor* child;
if (this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y > 2000.0f) {
Actor_Kill(&this->dyna.actor);
child = this->dyna.actor.child;
if (child != NULL && child->update != NULL) {
Actor_Kill(child);
}
} else {
Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCKSINK - SFX_FLAG);
if ((this->dyna.actor.home.pos.y - this->dyna.actor.world.pos.y > 500.0f) && func_8004356C(&this->dyna)) {
Gameplay_TriggerVoidOut(globalCtx);
}
}
}
void BgHakaShip_Update(Actor* thisx, GlobalContext* globalCtx) {
BgHakaShip* this = THIS;
this->actionFunc(this, globalCtx);
if (this->dyna.actor.params == 0) {
Actor_MoveForward(&this->dyna.actor);
}
}
void BgHakaShip_Draw(Actor* thisx, GlobalContext* globalCtx) {
BgHakaShip* this = THIS;
f32 angleTemp;
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 528);
func_80093D18(globalCtx->state.gfxCtx);
if (this->dyna.actor.params == 0) {
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 534),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, D_0600D330);
angleTemp = this->yOffset * (M_PI / 0x8000);
Matrix_Translate(-3670.0f, 620.0f, 1150.0f, MTXMODE_APPLY);
Matrix_RotateZ(angleTemp, MTXMODE_APPLY);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 547),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, D_06005A70);
Matrix_Translate(0.0f, 0.0f, -2300.0f, MTXMODE_APPLY);
Matrix_RotateZ(-(2.0f * angleTemp), MTXMODE_APPLY);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 556),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, D_06005A70);
} else {
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 562),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, D_0600E910);
}
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_haka_ship.c", 568);
if (this->actionFunc == BgHakaShip_CutsceneStationary || this->actionFunc == BgHakaShip_Move) {
s32 pad;
Vec3f sp2C;
sp2C.x = this->dyna.actor.world.pos.x + -367.0f;
sp2C.y = this->dyna.actor.world.pos.y + 62.0f;
sp2C.z = this->dyna.actor.world.pos.z;
SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->mf_11D60, &sp2C, &this->bellSoundPos);
func_80078914(&this->bellSoundPos, NA_SE_EV_SHIP_BELL - SFX_FLAG);
}
}

View file

@ -11,9 +11,10 @@ typedef void (*BgHakaShipActionFunc)(struct BgHakaShip*, GlobalContext*);
typedef struct BgHakaShip {
/* 0x0000 */ DynaPolyActor dyna;
/* 0x0164 */ BgHakaShipActionFunc actionFunc;
/* 0x0168 */ char unk_168[0x2];
/* 0x016A */ char unk_16A[0x2];
/* 0x016C */ Vec3f unk_16C;
/* 0x0168 */ u8 counter;
/* 0x0169 */ u8 switchFlag;
/* 0x016A */ s16 yOffset;
/* 0x016C */ Vec3f bellSoundPos;
} BgHakaShip; // size = 0x0178
extern const ActorInit Bg_Haka_Ship_InitVars;