mirror of
https://github.com/zeldaret/oot.git
synced 2025-08-07 06:40:15 +00:00
Decompiled ovl_Bg_Haka (#346)
* Progress * match func_8087B7E8 * combine into else if * match func_8087B938 * reorder condition to be more readable * SFX macros * clang fmt * func_8087BAAC and func_8087BAE4 * match BgHaka_Draw * attempt to remove dependency on asm data * match file and remove asm * reorder comparison * clang format * use bitwise not * merge upstream * fix ZAP2 * Update src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * Update src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * Update src/overlays/actors/ovl_Bg_Haka/z_bg_haka.c Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * implement fig's suggestions Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
This commit is contained in:
parent
01122ed3e8
commit
dfaa4dc0cb
14 changed files with 136 additions and 499 deletions
|
@ -20,7 +20,7 @@ void func_8087B7E8(BgHaka* this, GlobalContext* globalCtx);
|
|||
void func_8087B938(BgHaka* this, GlobalContext* globalCtx);
|
||||
void func_8087BAAC(BgHaka* this, GlobalContext* globalCtx);
|
||||
void func_8087BAE4(BgHaka* this, GlobalContext* globalCtx);
|
||||
/*
|
||||
|
||||
const ActorInit Bg_Haka_InitVars = {
|
||||
ACTOR_BG_HAKA,
|
||||
ACTORTYPE_BG,
|
||||
|
@ -32,21 +32,140 @@ const ActorInit Bg_Haka_InitVars = {
|
|||
(ActorFunc)BgHaka_Update,
|
||||
(ActorFunc)BgHaka_Draw,
|
||||
};
|
||||
*/
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka/BgHaka_Init.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka/BgHaka_Destroy.s")
|
||||
static InitChainEntry sInitChain[] = {
|
||||
ICHAIN_F32(minVelocityY, 0, ICHAIN_CONTINUE),
|
||||
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka/func_8087B758.s")
|
||||
extern UNK_TYPE D_06000428;
|
||||
extern Gfx D_060001B0[];
|
||||
extern Gfx D_060002A8[];
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka/func_8087B7E8.s")
|
||||
void BgHaka_Init(Actor* thisx, GlobalContext* globalCtx) {
|
||||
BgHaka* this = THIS;
|
||||
s32 pad;
|
||||
s32 sp24 = 0;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka/func_8087B938.s")
|
||||
Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
|
||||
DynaPolyInfo_SetActorMove(&this->dyna, 0);
|
||||
DynaPolyInfo_Alloc(&D_06000428, &sp24);
|
||||
this->dyna.dynaPolyId = DynaPolyInfo_RegisterActor(globalCtx, &globalCtx->colCtx.dyna, &this->dyna.actor, sp24);
|
||||
this->actionFunc = func_8087B7E8;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka/func_8087BAAC.s")
|
||||
void BgHaka_Destroy(Actor* thisx, GlobalContext* globalCtx) {
|
||||
BgHaka* this = THIS;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka/func_8087BAE4.s")
|
||||
DynaPolyInfo_Free(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka/BgHaka_Update.s")
|
||||
void func_8087B758(BgHaka* this, Player* player) {
|
||||
Vec3f sp1C;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Haka/BgHaka_Draw.s")
|
||||
func_8002DBD0(&this->dyna.actor, &sp1C, &player->actor.posRot.pos);
|
||||
if (fabsf(sp1C.x) < 34.6f && sp1C.z > -112.8f && sp1C.z < -36.0f) {
|
||||
player->stateFlags2 |= 0x200;
|
||||
}
|
||||
}
|
||||
|
||||
void func_8087B7E8(BgHaka* this, GlobalContext* globalCtx) {
|
||||
Player* player = PLAYER;
|
||||
|
||||
if (this->dyna.unk_150 != 0.0f) {
|
||||
if (globalCtx->sceneNum == SCENE_SPOT02 && LINK_IS_CHILD && !gSaveContext.nightFlag) {
|
||||
this->dyna.unk_150 = 0.0f;
|
||||
player->stateFlags2 &= ~0x10;
|
||||
if (!Gameplay_InCsMode(globalCtx)) {
|
||||
func_8010B680(globalCtx, 0x5073, NULL);
|
||||
this->dyna.actor.params = 100;
|
||||
this->actionFunc = func_8087BAE4;
|
||||
}
|
||||
} else if (0.0f < this->dyna.unk_150 ||
|
||||
(globalCtx->sceneNum == SCENE_SPOT06 && LINK_IS_CHILD && !Flags_GetSwitch(globalCtx, 0x23))) {
|
||||
this->dyna.unk_150 = 0.0f;
|
||||
player->stateFlags2 &= ~0x10;
|
||||
} else {
|
||||
this->dyna.actor.posRot.rot.y = this->dyna.actor.shape.rot.y + 0x8000;
|
||||
this->actionFunc = func_8087B938;
|
||||
}
|
||||
}
|
||||
func_8087B758(this, player);
|
||||
}
|
||||
|
||||
void func_8087B938(BgHaka* this, GlobalContext* globalCtx) {
|
||||
Player* player = PLAYER;
|
||||
s32 sp38;
|
||||
|
||||
this->dyna.actor.speedXZ += 0.05f;
|
||||
this->dyna.actor.speedXZ = CLAMP_MAX(this->dyna.actor.speedXZ, 1.5f);
|
||||
sp38 = Math_ApproxF(&this->dyna.actor.minVelocityY, 60.0f, this->dyna.actor.speedXZ);
|
||||
this->dyna.actor.posRot.pos.x =
|
||||
Math_Sins(this->dyna.actor.posRot.rot.y) * this->dyna.actor.minVelocityY + this->dyna.actor.initPosRot.pos.x;
|
||||
this->dyna.actor.posRot.pos.z =
|
||||
Math_Coss(this->dyna.actor.posRot.rot.y) * this->dyna.actor.minVelocityY + this->dyna.actor.initPosRot.pos.z;
|
||||
if (sp38 != 0) {
|
||||
this->dyna.unk_150 = 0.0f;
|
||||
player->stateFlags2 &= ~0x10;
|
||||
if (this->dyna.actor.params == 1) {
|
||||
func_80078884(NA_SE_SY_CORRECT_CHIME);
|
||||
} else if (gSaveContext.nightFlag && globalCtx->sceneNum == SCENE_SPOT02) {
|
||||
Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_POH, this->dyna.actor.initPosRot.pos.x,
|
||||
this->dyna.actor.initPosRot.pos.y, this->dyna.actor.initPosRot.pos.z, 0,
|
||||
this->dyna.actor.shape.rot.y, 0, 1);
|
||||
}
|
||||
this->actionFunc = func_8087BAAC;
|
||||
}
|
||||
func_8002F974(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG);
|
||||
}
|
||||
|
||||
void func_8087BAAC(BgHaka* this, GlobalContext* globalCtx) {
|
||||
Player* player = PLAYER;
|
||||
|
||||
if (this->dyna.unk_150 != 0.0f) {
|
||||
this->dyna.unk_150 = 0.0f;
|
||||
player->stateFlags2 &= ~0x10;
|
||||
}
|
||||
}
|
||||
|
||||
void func_8087BAE4(BgHaka* this, GlobalContext* globalCtx) {
|
||||
Player* player = PLAYER;
|
||||
s32 pad;
|
||||
|
||||
if (this->dyna.actor.params != 0) {
|
||||
this->dyna.actor.params -= 1;
|
||||
}
|
||||
if (this->dyna.unk_150 != 0.0f) {
|
||||
this->dyna.unk_150 = 0.0f;
|
||||
player->stateFlags2 &= ~0x10;
|
||||
}
|
||||
if (this->dyna.actor.params == 0) {
|
||||
this->actionFunc = func_8087B7E8;
|
||||
}
|
||||
func_8087B758(this, player);
|
||||
}
|
||||
|
||||
void BgHaka_Update(Actor* thisx, GlobalContext* globalCtx) {
|
||||
BgHaka* this = THIS;
|
||||
|
||||
this->actionFunc(this, globalCtx);
|
||||
}
|
||||
|
||||
void BgHaka_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
||||
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
|
||||
Gfx* dispRefs[4];
|
||||
|
||||
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, "../z_bg_haka.c", 401);
|
||||
func_80093D18(globalCtx->state.gfxCtx);
|
||||
func_80093D84(globalCtx->state.gfxCtx);
|
||||
|
||||
gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka.c", 406),
|
||||
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPDisplayList(gfxCtx->polyOpa.p++, D_060001B0);
|
||||
Matrix_Translate(0.0f, 0.0f, thisx->minVelocityY * 10.0f, MTXMODE_APPLY);
|
||||
gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_haka.c", 416),
|
||||
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPDisplayList(gfxCtx->polyXlu.p++, D_060002A8);
|
||||
|
||||
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, "../z_bg_haka.c", 421);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue