1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-08-06 06:10:21 +00:00

ovl_Bg_Hidan_Rock OK (#657)

* void BgHidanRock_Init(Actor *thisx, GlobalContext *globalCtx)

Signed-off-by: angie <angheloalf95@gmail.com>

* small functions

Signed-off-by: angie <angheloalf95@gmail.com>

* BgHidanRock_Destroy

Signed-off-by: angie <angheloalf95@gmail.com>

* BgHidanRock_Update

Signed-off-by: angie <angheloalf95@gmail.com>

* BgHidanRock_Draw

Signed-off-by: angie <angheloalf95@gmail.com>

* func_8088B69C

Signed-off-by: angie <angheloalf95@gmail.com>

* func_8088B79C

Signed-off-by: angie <angheloalf95@gmail.com>

* func_8088B990

Signed-off-by: angie <angheloalf95@gmail.com>

* func_8088B268 and move data

Signed-off-by: angie <angheloalf95@gmail.com>

* func_8088BC40

Signed-off-by: angie <angheloalf95@gmail.com>

* erase reloc

Signed-off-by: angie <angheloalf95@gmail.com>

* a bit of cleanup

Signed-off-by: angie <angheloalf95@gmail.com>

* ups

Signed-off-by: angie <angheloalf95@gmail.com>

* another bit of cleanup

Signed-off-by: angie <angheloalf95@gmail.com>

* Changes requested by @petrie911

Signed-off-by: Anghelo <angheloalf95@gmail.com>

* More changes requested by @petrie911

Signed-off-by: angie <angheloalf95@gmail.com>

* fix some types

Signed-off-by: angie <angheloalf95@gmail.com>
This commit is contained in:
Anghelo Carvajal 2021-02-12 17:33:03 -05:00 committed by GitHub
parent d373661acd
commit 0b2a4e9d7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 351 additions and 1162 deletions

View file

@ -9,13 +9,27 @@ void BgHidanRock_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgHidanRock_Update(Actor* thisx, GlobalContext* globalCtx);
void BgHidanRock_Draw(Actor* thisx, GlobalContext* globalCtx);
extern UNK_TYPE D_0600C100;
extern UNK_TYPE D_0600C1F0;
extern UNK_TYPE D_0600CA10;
extern UNK_TYPE D_0600CB80;
extern UNK_TYPE D_0600DF78;
void func_8088B24C(BgHidanRock* this);
void func_8088B268(BgHidanRock* this, GlobalContext* globalCtx);
void func_8088B5F4(BgHidanRock* this, GlobalContext* globalCtx);
void func_8088B634(BgHidanRock* this, GlobalContext* globalCtx);
void func_8088B69C(BgHidanRock* this, GlobalContext* globalCtx);
void func_8088B79C(BgHidanRock* this, GlobalContext* globalCtx);
void func_8088B90C(BgHidanRock* this, GlobalContext* globalCtx);
void func_8088B954(BgHidanRock* this, GlobalContext* globalCtx);
void func_8088B990(BgHidanRock* this, GlobalContext* globalCtx);
void func_8088BC40(GlobalContext* globalCtx, BgHidanRock* this);
extern Gfx D_0600C100[];
extern Gfx D_0600C1F0[];
extern Gfx D_0600CA10[];
extern CollisionHeader* D_0600CB80;
extern CollisionHeader* D_0600DF78;
static Vec3f D_8088BF60 = { 3310.0f, 120.0f, 0.0f };
/*
const ActorInit Bg_Hidan_Rock_InitVars = {
ACTOR_BG_HIDAN_ROCK,
ACTORCAT_BG,
@ -47,31 +61,336 @@ static ColliderCylinderInit D_8088BF8C = {
},
{ 45, 77, -40, { 3310, 120, 0 } },
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/BgHidanRock_Init.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/BgHidanRock_Destroy.s")
static InitChainEntry sInitChain[] = {
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE),
ICHAIN_F32_DIV1000(gravity, -600, ICHAIN_STOP),
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B24C.s")
void BgHidanRock_Init(Actor* thisx, GlobalContext* globalCtx) {
BgHidanRock* this = THIS;
s32 pad;
CollisionHeader* colHeader = NULL;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B268.s")
Actor_ProcessInitChain(thisx, sInitChain);
DynaPolyActor_Init(&this->dyna, DPM_PLAYER);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B5F4.s")
this->type = thisx->params & 0xFF;
this->unk_169 = 0;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B634.s")
thisx->params = ((thisx->params) >> 8) & 0xFF;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B69C.s")
Collider_InitCylinder(globalCtx, &this->collider);
Collider_SetCylinder(globalCtx, &this->collider, thisx, &D_8088BF8C);
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B79C.s")
if (this->type == 0) {
if (Flags_GetSwitch(globalCtx, thisx->params)) {
Math_Vec3f_Copy(&thisx->home.pos, &D_8088BF60);
Math_Vec3f_Copy(&thisx->world.pos, &D_8088BF60);
this->timer = 60;
this->actionFunc = func_8088B5F4;
} else {
this->actionFunc = func_8088B268;
}
thisx->flags |= 0x30;
CollisionHeader_GetVirtual(&D_0600CB80, &colHeader);
} else {
CollisionHeader_GetVirtual(&D_0600DF78, &colHeader);
this->collider.dim.pos.x = thisx->home.pos.x;
this->collider.dim.pos.y = thisx->home.pos.y;
this->collider.dim.pos.z = thisx->home.pos.z;
this->actionFunc = func_8088B634;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B90C.s")
this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader);
this->timer = 0;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B954.s")
void BgHidanRock_Destroy(Actor* thisx, GlobalContext* globalCtx) {
BgHidanRock* this = THIS;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B990.s")
DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
Collider_DestroyCylinder(globalCtx, &this->collider);
func_800F89E8(&this->unk_170);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/BgHidanRock_Update.s")
void func_8088B24C(BgHidanRock* this) {
this->dyna.actor.flags |= 0x30;
this->actionFunc = func_8088B990;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088BC40.s")
void func_8088B268(BgHidanRock* this, GlobalContext* globalCtx) {
static f32 D_8088BFC0 = 0.0f;
f32 sp2C;
s32 temp_v1;
s32 frame;
Player* player = PLAYER;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/BgHidanRock_Draw.s")
if (this->dyna.unk_150 != 0.0f) {
if (this->timer == 0) {
if (D_8088BFC0 == 0.0f) {
if (this->dyna.unk_150 > 0.0f) {
D_8088BFC0 += 0.01f;
} else {
D_8088BFC0 -= 0.01f;
}
}
this->dyna.actor.speedXZ += 0.05f;
this->dyna.actor.speedXZ = CLAMP_MAX(this->dyna.actor.speedXZ, 2.0f);
if (D_8088BFC0 > 0.0f) {
temp_v1 = Math_StepToF(&D_8088BFC0, 20.0f, this->dyna.actor.speedXZ);
} else {
temp_v1 = Math_StepToF(&D_8088BFC0, -20.0f, this->dyna.actor.speedXZ);
}
this->dyna.actor.world.pos.x = (Math_SinS(this->dyna.unk_158) * D_8088BFC0) + this->dyna.actor.home.pos.x;
this->dyna.actor.world.pos.z = (Math_CosS(this->dyna.unk_158) * D_8088BFC0) + this->dyna.actor.home.pos.z;
if (temp_v1) {
player->stateFlags2 &= ~0x10;
this->dyna.unk_150 = 0.0f;
this->dyna.actor.home.pos.x = this->dyna.actor.world.pos.x;
this->dyna.actor.home.pos.z = this->dyna.actor.world.pos.z;
D_8088BFC0 = 0.0f;
this->dyna.actor.speedXZ = 0.0f;
this->timer = 5;
}
func_8002F974(&this->dyna.actor, NA_SE_EV_ROCK_SLIDE - SFX_FLAG);
} else {
player->stateFlags2 &= ~0x10;
this->dyna.unk_150 = 0.0f;
if (this->timer != 0) {
this->timer--;
}
}
} else {
this->timer = 0;
}
sp2C = this->dyna.actor.world.pos.z - D_8088BF60.z;
if (sp2C < 0.5f) {
Flags_SetSwitch(globalCtx, this->dyna.actor.params);
Math_Vec3f_Copy(&this->dyna.actor.home.pos, &D_8088BF60);
this->dyna.actor.world.pos.x = D_8088BF60.x;
this->dyna.actor.world.pos.z = D_8088BF60.z;
this->dyna.actor.speedXZ = 0.0f;
D_8088BFC0 = 0.0f;
player->stateFlags2 &= ~0x10;
this->actionFunc = func_8088B79C;
}
frame = globalCtx->gameplayFrames & 0xFF;
if (globalCtx->gameplayFrames & 0x100) {
this->unk_16C = 0.0f;
} else if (frame < 128) {
this->unk_16C = sinf(frame * (4 * 0.001f * M_PI)) * 19.625f;
} else if (frame < 230) {
this->unk_16C = 19.625f;
} else {
this->unk_16C -= 1.0f;
this->unk_16C = CLAMP_MIN(this->unk_16C, 0.0f);
}
if (sp2C < 100.0f) {
this->unk_16C = CLAMP_MAX(this->unk_16C, 6.125f);
}
}
void func_8088B5F4(BgHidanRock* this, GlobalContext* globalCtx) {
if (this->timer != 0) {
this->timer--;
}
if (this->timer == 0) {
func_8088B24C(this);
}
}
void func_8088B634(BgHidanRock* this, GlobalContext* globalCtx) {
if (func_8004356C(&this->dyna)) {
this->timer = 20;
this->dyna.actor.world.rot.y = Camera_GetCamDirYaw(ACTIVE_CAM) + 0x4000;
this->actionFunc = func_8088B69C;
}
}
void func_8088B69C(BgHidanRock* this, GlobalContext* globalCtx) {
if (this->timer != 0) {
this->timer--;
}
if (this->timer != 0) {
this->dyna.actor.world.pos.x =
this->dyna.actor.home.pos.x + 5.0f * Math_SinS(this->dyna.actor.world.rot.y + this->timer * 0x4000);
this->dyna.actor.world.pos.z =
this->dyna.actor.home.pos.z + 5.0f * Math_CosS(this->dyna.actor.world.rot.y + this->timer * 0x4000);
} else {
this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x;
this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z;
func_8088B24C(this);
}
if (!(this->timer % 4)) {
func_800AA000(this->dyna.actor.xyzDistToPlayerSq, 0xB4, 0x0A, 0x64);
Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_SHAKE);
}
}
void func_8088B79C(BgHidanRock* this, GlobalContext* globalCtx) {
this->timer--;
if (this->dyna.actor.bgCheckFlags & 2) {
if (this->type == 0) {
this->timer = 60;
this->actionFunc = func_8088B5F4;
} else {
this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y - 15.0f;
this->actionFunc = func_8088B90C;
this->dyna.actor.flags &= ~0x30;
}
Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND);
Audio_PlayActorSound2(
&this->dyna.actor,
SurfaceType_GetSfx(&globalCtx->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) + 0x800);
}
this->unk_16C -= 0.5f;
this->unk_16C = CLAMP_MIN(this->unk_16C, 0.0f);
if (this->type == 0) {
if (func_8004356C(&this->dyna)) {
if (this->unk_169 == 0) {
this->unk_169 = 3;
}
Camera_ChangeSetting(globalCtx->cameraPtrs[0], 0x30);
} else if (!func_8004356C(&this->dyna)) {
if (this->unk_169 != 0) {
Camera_ChangeSetting(globalCtx->cameraPtrs[0], 3);
}
this->unk_169 = 0;
}
}
}
void func_8088B90C(BgHidanRock* this, GlobalContext* globalCtx) {
if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 1.0f) != 0) {
this->actionFunc = func_8088B634;
}
}
void func_8088B954(BgHidanRock* this, GlobalContext* globalCtx) {
if (this->timer != 0) {
this->timer--;
}
if (this->timer == 0) {
this->actionFunc = func_8088B79C;
this->dyna.actor.velocity.y = 0.0f;
}
}
void func_8088B990(BgHidanRock* this, GlobalContext* globalCtx) {
Player* player = PLAYER;
this->timer++;
if (this->dyna.unk_150 != 0.0f) {
this->dyna.actor.speedXZ = 0.0f;
player->stateFlags2 &= ~0x10;
}
if ((this->type == 0 && (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 1820.0f,
0.25f, 20.0f, 0.5f) < 0.1f)) ||
((this->type != 0) && (Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 480.0,
0.25f, 20.0f, 0.5f) < 0.1f))) {
if (this->type == 0) {
Audio_PlayActorSound2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND);
}
this->timer = 20;
this->actionFunc = func_8088B954;
}
this->unk_16C = (this->dyna.actor.world.pos.y + 50.0f - this->dyna.actor.home.pos.y + 40.0f) / 80.0f;
if (this->type == 0) {
if (func_8004356C(&this->dyna)) {
if (this->unk_169 == 0) {
this->unk_169 = 3;
}
Camera_ChangeSetting(globalCtx->cameraPtrs[0], 0x30);
} else if (!func_8004356C(&this->dyna)) {
if (this->unk_169 != 0) {
Camera_ChangeSetting(globalCtx->cameraPtrs[0], 3);
}
this->unk_169 = 0;
}
}
}
void BgHidanRock_Update(Actor* thisx, GlobalContext* globalCtx) {
BgHidanRock* this = THIS;
this->actionFunc(this, globalCtx);
if (this->actionFunc == func_8088B79C) {
Actor_MoveForward(&this->dyna.actor);
Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 0.0f, 0.0f, 0.0f, 4);
}
if (this->unk_16C > 0.0f) {
this->collider.dim.height = D_8088BF8C.dim.height * this->unk_16C;
CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &this->collider.base);
}
}
void func_8088BC40(GlobalContext* globalCtx, BgHidanRock* this) {
static UNK_PTR D_8088BFC4[] = { 0x06012120, 0x060128A0, 0x06013020, 0x060137A0,
0x06013F20, 0x060146A0, 0x06014E20, 0x060155A0 };
s32 pad;
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_rock.c", 808);
POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x14);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x01, 255, 255, 0, 150);
gDPSetEnvColor(POLY_XLU_DISP++, 255, 0, 0, 255);
if (this->type == 0) {
Matrix_Translate(D_8088BF60.x, D_8088BF60.y - 40.0f, D_8088BF60.z, MTXMODE_NEW);
} else {
Matrix_Translate(this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.y - 40.0f, this->dyna.actor.home.pos.z,
MTXMODE_NEW);
}
Matrix_RotateRPY(0, Camera_GetCamDirYaw(ACTIVE_CAM) + 0x8000, 0, MTXMODE_APPLY);
Matrix_Translate(-10.5f, 0.0f, 0.0f, MTXMODE_APPLY);
Matrix_Scale(6.0f, this->unk_16C, 6.0f, MTXMODE_APPLY);
gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8088BFC4[globalCtx->gameplayFrames & 7]));
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_bg_hidan_rock.c", 853),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, D_0600CA10);
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_rock.c", 857);
}
void BgHidanRock_Draw(Actor* thisx, GlobalContext* globalCtx) {
BgHidanRock* this = THIS;
s32 pad;
if (this->type == 0) {
Gfx_DrawDListOpa(globalCtx, D_0600C100);
} else {
Gfx_DrawDListOpa(globalCtx, D_0600C1F0);
}
if (this->unk_16C > 0.0f) {
if (this->type == 0) {
SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->mf_11D60, &D_8088BF60, &this->unk_170);
} else {
SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->mf_11D60, &this->dyna.actor.home.pos, &this->unk_170);
}
func_80078914(&this->unk_170, NA_SE_EV_FIRE_PILLAR - SFX_FLAG);
func_8088BC40(globalCtx, this);
}
}

View file

@ -6,9 +6,17 @@
struct BgHidanRock;
typedef void (*BgHidanRockActionFunc)(struct BgHidanRock*, GlobalContext*);
typedef struct BgHidanRock {
/* 0x0000 */ Actor actor;
/* 0x014C */ char unk_14C[0x7C];
/* 0x0000 */ DynaPolyActor dyna;
/* 0x0164 */ BgHidanRockActionFunc actionFunc;
/* 0x0168 */ u8 type;
/* 0x0169 */ u8 unk_169;
/* 0x016A */ s16 timer;
/* 0x016C */ f32 unk_16C;
/* 0x0170 */ Vec3f unk_170;
/* 0x017C */ ColliderCylinder collider;
} BgHidanRock; // size = 0x01C8
extern const ActorInit Bg_Hidan_Rock_InitVars;