diff --git a/spec b/spec index 07c26f3143..bf0af4694e 100644 --- a/spec +++ b/spec @@ -3373,8 +3373,7 @@ beginseg name "ovl_Bg_Open_Shutter" compress include "build/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.o" - include "build/data/ovl_Bg_Open_Shutter/ovl_Bg_Open_Shutter.data.o" - include "build/data/ovl_Bg_Open_Shutter/ovl_Bg_Open_Shutter.reloc.o" + include "build/src/overlays/actors/ovl_Bg_Open_Shutter/ovl_Bg_Open_Shutter_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c index e830f738b4..f69282987e 100644 --- a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c +++ b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.c @@ -5,6 +5,7 @@ */ #include "z_bg_open_shutter.h" +#include "objects/object_open_obj/object_open_obj.h" #include "z64rumble.h" #define FLAGS (ACTOR_FLAG_10) @@ -20,7 +21,11 @@ void func_80ACAD88(BgOpenShutter* this, PlayState* play); void func_80ACAE5C(BgOpenShutter* this, PlayState* play); void func_80ACAEF0(BgOpenShutter* this, PlayState* play); -#if 0 +typedef enum { + /* 0x1 */ BGOPENSHUTTER_DOOR_OPEN = 1, + /* 0x2 */ BGOPENSHUTTER_DOOR_CLOSED, +} BGOpenShutterDoorState; + const ActorInit Bg_Open_Shutter_InitVars = { ACTOR_BG_OPEN_SHUTTER, ACTORCAT_DOOR, @@ -33,35 +38,151 @@ const ActorInit Bg_Open_Shutter_InitVars = { (ActorFunc)BgOpenShutter_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80ACB140[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 350, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 350, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +f32 func_80ACAB10(PlayState* play, Actor* actor, f32 arg2, f32 arg3, f32 arg4) { + Player* player = GET_PLAYER(play); + Vec3f point; + Vec3f offset; -extern InitChainEntry D_80ACB140[]; + point.x = player->actor.world.pos.x; + point.y = player->actor.world.pos.y + arg2; + point.z = player->actor.world.pos.z; -extern UNK_TYPE D_060003E8; -extern UNK_TYPE D_06001640; + Actor_OffsetOfPointInActorCoords(actor, &offset, &point); + if ((arg3 < fabsf(offset.x)) || (arg4 < fabsf(offset.y))) { + return FLT_MAX; + } else { + return offset.z; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/func_80ACAB10.s") +s8 func_80ACABA8(BgOpenShutter* this, PlayState* play) { + Player* player = GET_PLAYER(play); + f32 temp_fv0; + s16 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/func_80ACABA8.s") + if (!Player_InCsMode(&play->state) && (this->dyna.actor.xzDistToPlayer < 100.0f)) { + temp_fv0 = func_80ACAB10(play, &this->dyna.actor, 0.0f, 65.0f, 15.0f); + if (fabsf(temp_fv0) < 50.0f) { + temp_v0 = player->actor.shape.rot.y - this->dyna.actor.shape.rot.y; + if (temp_fv0 > 0.0f) { + temp_v0 = (0x8000 - temp_v0); + } + if (ABS_ALT(temp_v0) < 0x3000) { + if (temp_fv0 > 1.0f) { + return 1; + } + if (temp_fv0 < -1.0f) { + return -1; + } + } + } + } + return 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/BgOpenShutter_Init.s") +void BgOpenShutter_Init(Actor* thisx, PlayState* play) { + BgOpenShutter* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/BgOpenShutter_Destroy.s") + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_open_obj_Colheader_001640); + this->actionFunc = func_80ACAD88; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/func_80ACAD88.s") +void BgOpenShutter_Destroy(Actor* thisx, PlayState* play) { + BgOpenShutter* this = THIS; + s32 params = BGOPENSHUTTER_GET_A(thisx); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/func_80ACAE5C.s") + play->doorCtx.transitionActorList[params].id = -play->doorCtx.transitionActorList[params].id; + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/func_80ACAEF0.s") +void func_80ACAD88(BgOpenShutter* this, PlayState* play) { + s32 quake; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/BgOpenShutter_Update.s") + if (this->unk_15C != 0) { + Player* player = GET_PLAYER(play); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Open_Shutter/BgOpenShutter_Draw.s") + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + func_800DFFAC(play->cameraPtrs[0], &this->dyna.actor, player->unk_3BA, 0.0f, 12, 15, 10); + this->unk_164 = 0; + this->actionFunc = func_80ACAE5C; + this->dyna.actor.velocity.y = 0.0f; + } else { + Player* player = GET_PLAYER(play); + + quake = func_80ACABA8(this, play); + if (quake > 0) { + player->doorType = 2; + player->doorDirection = quake; + player->doorActor = &this->dyna.actor; + func_80122F28(player); + } + } +} + +void func_80ACAE5C(BgOpenShutter* this, PlayState* play) { + Math_StepToF(&this->dyna.actor.velocity.y, 15.0f, 3.0f); + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y + 120.0f, + this->dyna.actor.velocity.y)) { + this->unk_164++; + } + if (this->unk_164 >= 10) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + this->actionFunc = func_80ACAEF0; + } +} + +void func_80ACAEF0(BgOpenShutter* this, PlayState* play) { + s32 pad; + s16 quake; + + Math_StepToF(&this->dyna.actor.velocity.y, 20.0f, 8.0f); + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, this->dyna.actor.velocity.y)) { + this->dyna.actor.floorHeight = this->dyna.actor.home.pos.y; + Actor_SpawnFloorDustRing(play, &this->dyna.actor, &this->dyna.actor.world.pos, 60.0f, 10, 8.0f, 500, 10, true); + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BIGWALL_BOUND); + quake = Quake_Add(Play_GetCamera(play, CAM_ID_MAIN), 3); + Quake_SetSpeed(quake, -0x7F18); + Quake_SetQuakeValues(quake, 2, 0, 0, 0); + Quake_SetCountdown(quake, 10); + Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 180, 20, 100); + this->unk_15C = 0; + this->actionFunc = func_80ACAD88; + } +} + +void BgOpenShutter_Update(Actor* thisx, PlayState* play2) { + BgOpenShutter* this = THIS; + PlayState* play = play2; + s32 index; + + if (Cutscene_CheckActorAction(play, 0x7C)) { + index = Cutscene_GetActorActionIndex(play, 0x7C); + if (play->csCtx.actorActions[index]->action == BGOPENSHUTTER_DOOR_OPEN) { + if (this->actionFunc == func_80ACAD88) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_OPEN); + this->actionFunc = func_80ACAE5C; + this->dyna.actor.velocity.y = 0.0f; + } + this->unk_164 = 0; + } else if (play->csCtx.actorActions[index]->action == BGOPENSHUTTER_DOOR_CLOSED) { + if (this->actionFunc == func_80ACAE5C) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_SLIDE_DOOR_CLOSE); + this->actionFunc = func_80ACAEF0; + } + } + } + this->actionFunc(this, play); +} + +void BgOpenShutter_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_open_obj_DL_0003E8); +} diff --git a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.h b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.h index 2c00a57355..fdf2791e13 100644 --- a/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.h +++ b/src/overlays/actors/ovl_Bg_Open_Shutter/z_bg_open_shutter.h @@ -3,15 +3,17 @@ #include "global.h" +#define BGOPENSHUTTER_GET_A(thisx) ((u16)((thisx)->params) >> 0xA) + struct BgOpenShutter; typedef void (*BgOpenShutterActionFunc)(struct BgOpenShutter*, PlayState*); typedef struct BgOpenShutter { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x1C]; - /* 0x0160 */ BgOpenShutterActionFunc actionFunc; - /* 0x0164 */ char unk_164[0x4]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s16 unk_15C; + /* 0x160 */ BgOpenShutterActionFunc actionFunc; + /* 0x164 */ s32 unk_164; } BgOpenShutter; // size = 0x168 extern const ActorInit Bg_Open_Shutter_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index d1c877b2f3..94e29323fa 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -640,12 +640,6 @@ D_06000798 = 0x06000798; D_06000098 = 0x06000098; -// ovl_Bg_Open_Shutter - -D_060003E8 = 0x060003E8; -D_06001640 = 0x06001640; - - // ovl_Bg_Sinkai_Kabe D_06000048 = 0x06000048;