diff options
| author | Anghelo Carvajal <angheloalf95@gmail.com> | 2021-02-12 17:33:03 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-12 17:33:03 -0500 |
| commit | 0b2a4e9d7fd5448c5f7939714f177cc0c2faafef (patch) | |
| tree | 8a4f2821dbc29de30571b7c36d2596e69e6113a4 /src | |
| parent | d373661acd288b952dbb69824017307ac228501b (diff) | |
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>
Diffstat (limited to 'src')
| -rw-r--r-- | src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c | 361 | ||||
| -rw-r--r-- | src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.h | 12 |
2 files changed, 350 insertions, 23 deletions
diff --git a/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c b/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c index 3c7b9300e..43bed22a9 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c @@ -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), +}; + +void BgHidanRock_Init(Actor* thisx, GlobalContext* globalCtx) { + BgHidanRock* this = THIS; + s32 pad; + CollisionHeader* colHeader = NULL; + + Actor_ProcessInitChain(thisx, sInitChain); + DynaPolyActor_Init(&this->dyna, DPM_PLAYER); + + this->type = thisx->params & 0xFF; + this->unk_169 = 0; + + thisx->params = ((thisx->params) >> 8) & 0xFF; + + Collider_InitCylinder(globalCtx, &this->collider); + Collider_SetCylinder(globalCtx, &this->collider, thisx, &D_8088BF8C); + + 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; + } + + this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + this->timer = 0; +} + +void BgHidanRock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHidanRock* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + Collider_DestroyCylinder(globalCtx, &this->collider); + func_800F89E8(&this->unk_170); +} + +void func_8088B24C(BgHidanRock* this) { + this->dyna.actor.flags |= 0x30; + this->actionFunc = func_8088B990; +} + +void func_8088B268(BgHidanRock* this, GlobalContext* globalCtx) { + static f32 D_8088BFC0 = 0.0f; + f32 sp2C; + s32 temp_v1; + s32 frame; + Player* player = PLAYER; + + 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); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B24C.s") + 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); + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B268.s") +void func_8088BC40(GlobalContext* globalCtx, BgHidanRock* this) { + static UNK_PTR D_8088BFC4[] = { 0x06012120, 0x060128A0, 0x06013020, 0x060137A0, + 0x06013F20, 0x060146A0, 0x06014E20, 0x060155A0 }; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B5F4.s") + OPEN_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_rock.c", 808); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B634.s") + 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); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B69C.s") + 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); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B79C.s") + 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); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B90C.s") + 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); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B954.s") + CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_bg_hidan_rock.c", 857); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088B990.s") +void BgHidanRock_Draw(Actor* thisx, GlobalContext* globalCtx) { + BgHidanRock* this = THIS; + s32 pad; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/BgHidanRock_Update.s") + if (this->type == 0) { + Gfx_DrawDListOpa(globalCtx, D_0600C100); + } else { + Gfx_DrawDListOpa(globalCtx, D_0600C1F0); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/func_8088BC40.s") + 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); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Bg_Hidan_Rock/BgHidanRock_Draw.s") + func_80078914(&this->unk_170, NA_SE_EV_FIRE_PILLAR - SFX_FLAG); + func_8088BC40(globalCtx, this); + } +} diff --git a/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.h b/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.h index 48d4abb71..3161057a9 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.h +++ b/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.h @@ -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; |
