summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaide <34639600+Kelebek1@users.noreply.github.com>2022-03-29 20:59:59 +0100
committerGitHub <noreply@github.com>2022-03-29 20:59:59 +0100
commitcdc475bea9b7fd8bef375dce3c7d36c2efff8e1d (patch)
tree3436116aa0f39374f92eda5ac3b577c60c8aa6a6 /src
parent036a68cb3e3477b31a29ee377ad81a012897327e (diff)
Bg_F40_Block (#754)
Diffstat (limited to 'src')
-rw-r--r--src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c347
-rw-r--r--src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h10
2 files changed, 329 insertions, 28 deletions
diff --git a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c
index 769118e69..1e8c369fb 100644
--- a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c
+++ b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.c
@@ -5,6 +5,7 @@
*/
#include "z_bg_f40_block.h"
+#include "objects/object_f40_obj/object_f40_obj.h"
#define FLAGS (ACTOR_FLAG_10)
@@ -15,7 +16,16 @@ void BgF40Block_Destroy(Actor* thisx, GlobalContext* globalCtx);
void BgF40Block_Update(Actor* thisx, GlobalContext* globalCtx);
void BgF40Block_Draw(Actor* thisx, GlobalContext* globalCtx);
-#if 0
+void func_80BC41AC(BgF40Block* this, GlobalContext* globalCtx);
+void func_80BC4228(BgF40Block* this, GlobalContext* globalCtx);
+void func_80BC4344(BgF40Block* this, GlobalContext* globalCtx);
+void func_80BC4380(BgF40Block* this, GlobalContext* globalCtx);
+void func_80BC43CC(BgF40Block* this, GlobalContext* globalCtx);
+void func_80BC4448(BgF40Block* this, GlobalContext* globalCtx);
+void func_80BC44F4(BgF40Block* this, GlobalContext* globalCtx);
+void func_80BC4530(BgF40Block* this, GlobalContext* globalCtx);
+void func_80BC457C(BgF40Block* this, GlobalContext* globalCtx);
+
const ActorInit Bg_F40_Block_InitVars = {
ACTOR_BG_F40_BLOCK,
ACTORCAT_BG,
@@ -28,55 +38,340 @@ const ActorInit Bg_F40_Block_InitVars = {
(ActorFunc)BgF40Block_Draw,
};
-// static InitChainEntry sInitChain[] = {
-static InitChainEntry D_80BC4668[] = {
+static Vec3f D_80BC4620[] = {
+ { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f, 1.0f },
+ { -1.0f, 0.0f, 0.0f }, { 0.0f, -1.0f, 0.0f }, { 0.0f, 0.0f, -1.0f },
+};
+
+static InitChainEntry sInitChain[] = {
ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE),
ICHAIN_F32(uncullZoneScale, 400, ICHAIN_CONTINUE),
ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_CONTINUE),
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP),
};
-#endif
+s32 func_80BC3980(BgF40Block* this, GlobalContext* globalCtx) {
+ Vec3s* points;
+
+ this->unk_160 = 0;
+ this->unk_164 = 0;
+
+ if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) {
+ this->path = &globalCtx->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)];
+ if (this->path != NULL) {
+ points = Lib_SegmentedToVirtual(this->path->points);
+
+ this->dyna.actor.world.pos.x = points->x;
+ this->dyna.actor.world.pos.y = points->y;
+ this->dyna.actor.world.pos.z = points->z;
+ }
+ } else {
+ this->path = NULL;
+ }
+
+ return false;
+}
+
+s32 func_80BC3A2C(BgF40Block* this, GlobalContext* globalCtx) {
+ Vec3s* points;
+
+ this->unk_160 = this->path->count - 1;
+ this->unk_164 = this->path->count - 1;
+
+ if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) {
+ this->path = &globalCtx->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)];
+ if (this->path != NULL) {
+ points = Lib_SegmentedToVirtual(this->path->points);
+ points += this->unk_164;
+
+ this->dyna.actor.world.pos.x = points->x;
+ this->dyna.actor.world.pos.y = points->y;
+ this->dyna.actor.world.pos.z = points->z;
+ }
+ } else {
+ this->path = NULL;
+ }
+
+ return false;
+}
+
+s32 func_80BC3B00(BgF40Block* this) {
+ s32 pad;
+ Path* path;
+ Vec3s* points;
+ Vec3f sp28;
+ Vec3f sp24;
+
+ if (this->path == NULL) {
+ return true;
+ }
+
+ if (this->unk_160 == this->unk_164) {
+ return true;
+ }
+
+ path = this->path;
+ points = Lib_SegmentedToVirtual(path->points);
+ points += this->unk_164;
+
+ sp28.x = points->x;
+ sp28.y = points->y;
+ sp28.z = points->z;
+
+ if (this->unk_168 == 6) {
+ sp24.x = sp28.x - this->dyna.actor.world.pos.x;
+ sp24.y = sp28.y - this->dyna.actor.world.pos.y;
+ sp24.z = sp28.z - this->dyna.actor.world.pos.z;
+
+ if (sp24.x > 10.0f) {
+ this->unk_168 = 0;
+ }
+
+ if (sp24.y > 10.0f) {
+ this->unk_168 = 1;
+ }
+
+ if (sp24.z > 10.0f) {
+ this->unk_168 = 2;
+ }
+
+ if (sp24.x < -10.0f) {
+ this->unk_168 = 3;
+ }
+
+ if (sp24.y < -10.0f) {
+ this->unk_168 = 4;
+ }
+
+ if (sp24.z < -10.0f) {
+ this->unk_168 = 5;
+ }
+ }
+
+ if (Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &sp28, this->dyna.actor.speedXZ) <= 0.0f) {
+ this->unk_168 = 6;
+ this->unk_160 = this->unk_164;
+ return true;
+ }
+ return false;
+}
+
+s32 func_80BC3CA4(BgF40Block* this) {
+ if (this->dyna.actor.cutscene == -1) {
+ return true;
+ }
+
+ if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) {
+ ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor);
+ return true;
+ }
+
+ ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene);
+ return false;
+}
+
+s32 func_80BC3D08(BgF40Block* this, GlobalContext* globalCtx, s32 arg2) {
+ CollisionPoly* sp54;
+ Vec3f sp48;
+ Vec3f sp3C;
+ Vec3f sp30;
+
+ if (this->unk_168 == 6) {
+ return false;
+ }
+
+ if (arg2 != 0) {
+ sp48.x =
+ (D_80BC4620[this->unk_168].x * ((800.0f * this->dyna.actor.scale.x) - (this->dyna.actor.speedXZ * 0.5f))) +
+ this->dyna.actor.world.pos.x;
+ sp48.y =
+ (D_80BC4620[this->unk_168].y * ((800.0f * this->dyna.actor.scale.y) - (this->dyna.actor.speedXZ * 0.5f))) +
+ this->dyna.actor.world.pos.y;
+ sp48.z =
+ (D_80BC4620[this->unk_168].z * ((800.0f * this->dyna.actor.scale.z) - (this->dyna.actor.speedXZ * 0.5f))) +
+ this->dyna.actor.world.pos.z;
+
+ sp3C.x = (D_80BC4620[this->unk_168].x * this->dyna.actor.speedXZ) + sp48.x;
+ sp3C.y = (D_80BC4620[this->unk_168].y * this->dyna.actor.speedXZ) + sp48.y;
+ sp3C.z = (D_80BC4620[this->unk_168].z * this->dyna.actor.speedXZ) + sp48.z;
+ } else {
+ sp3C.x = (D_80BC4620[this->unk_168].x * 800.0f * this->dyna.actor.scale.x) + this->dyna.actor.world.pos.x;
+ sp3C.y = (D_80BC4620[this->unk_168].y * 800.0f * this->dyna.actor.scale.y) + this->dyna.actor.world.pos.y;
+ sp3C.z = (D_80BC4620[this->unk_168].z * 800.0f * this->dyna.actor.scale.z) + this->dyna.actor.world.pos.z;
+
+ sp48.x = sp3C.x - (D_80BC4620[this->unk_168].x * this->dyna.actor.speedXZ * 1.5f);
+ sp48.y = sp3C.y - (D_80BC4620[this->unk_168].y * this->dyna.actor.speedXZ * 1.5f);
+ sp48.z = sp3C.z - (D_80BC4620[this->unk_168].z * this->dyna.actor.speedXZ * 1.5f);
+ }
+
+ if (BgCheck_AnyLineTest1(&globalCtx->colCtx, &sp48, &sp3C, &sp30, &sp54, true)) {
+ if (arg2 == 0) {
+ this->dyna.actor.world.pos.x -= sp3C.x - sp30.x;
+ this->dyna.actor.world.pos.y -= sp3C.y - sp30.y;
+ this->dyna.actor.world.pos.z -= sp3C.z - sp30.z;
+ }
+ return true;
+ }
+
+ return false;
+}
+
+void func_80BC4038(BgF40Block* this) {
+ s32 temp = this->unk_160;
+
+ this->unk_160 = this->unk_164;
+ this->unk_164 = temp;
+ this->unk_168 = 6;
+}
+
+void BgF40Block_Init(Actor* thisx, GlobalContext* globalCtx) {
+ BgF40Block* this = THIS;
+
+ Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
+ DynaPolyActor_Init(&this->dyna, 1);
+ DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &object_f40_obj_Colheader_004640);
+
+ if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) {
+ this->path = &globalCtx->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)];
+ } else {
+ this->path = NULL;
+ }
-extern InitChainEntry D_80BC4668[];
+ if (this->path != NULL) {
+ if (Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) {
+ this->actionFunc = func_80BC4530;
+ this->dyna.actor.speedXZ = 40.0f;
+ func_80BC3A2C(this, globalCtx);
+ } else {
+ this->actionFunc = func_80BC4380;
+ this->dyna.actor.speedXZ = 20.0f;
+ func_80BC3980(this, globalCtx);
+ }
+ } else {
+ this->actionFunc = func_80BC457C;
+ }
+ this->unk_168 = 6;
+}
-extern UNK_TYPE D_060043D0;
-extern UNK_TYPE D_06004640;
+void BgF40Block_Destroy(Actor* thisx, GlobalContext* globalCtx) {
+ BgF40Block* this = THIS;
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3980.s")
+ DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId);
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3A2C.s")
+void func_80BC41AC(BgF40Block* this, GlobalContext* globalCtx) {
+ if (func_80BC3D08(this, globalCtx, 1)) {
+ if (!Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) {
+ func_80BC4038(this);
+ this->actionFunc = func_80BC44F4;
+ }
+ } else {
+ this->actionFunc = func_80BC4344;
+ }
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3B00.s")
+void func_80BC4228(BgF40Block* this, GlobalContext* globalCtx) {
+ if (func_80BC3B00(this)) {
+ this->dyna.actor.speedXZ = 20.0f;
+ if (this->unk_160 < (this->path->count - 1)) {
+ this->unk_164 = this->unk_160 + 1;
+ } else {
+ this->actionFunc = func_80BC4530;
+ ActorCutscene_Stop(this->dyna.actor.cutscene);
+ Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_C);
+ }
+ }
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3CA4.s")
+ if (func_80BC3D08(this, globalCtx, 0)) {
+ ActorCutscene_Stop(this->dyna.actor.cutscene);
+ this->actionFunc = func_80BC41AC;
+ Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_F);
+ return;
+ }
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC3D08.s")
+ switch (this->unk_168) {
+ case 0:
+ case 3:
+ func_800B9010(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_MOVE_X - SFX_FLAG);
+ break;
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4038.s")
+ case 1:
+ case 4:
+ func_800B9010(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_MOVE_Y - SFX_FLAG);
+ break;
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Init.s")
+ case 2:
+ case 5:
+ func_800B9010(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_MOVE_Z - SFX_FLAG);
+ break;
+ }
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Destroy.s")
+void func_80BC4344(BgF40Block* this, GlobalContext* globalCtx) {
+ if (func_80BC3CA4(this)) {
+ this->actionFunc = func_80BC4228;
+ }
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC41AC.s")
+void func_80BC4380(BgF40Block* this, GlobalContext* globalCtx) {
+ if (Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) {
+ this->actionFunc = func_80BC4344;
+ }
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4228.s")
+void func_80BC43CC(BgF40Block* this, GlobalContext* globalCtx) {
+ if (func_80BC3D08(this, globalCtx, 1)) {
+ if (Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) {
+ func_80BC4038(this);
+ this->actionFunc = func_80BC4344;
+ }
+ } else {
+ this->actionFunc = func_80BC44F4;
+ }
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4344.s")
+void func_80BC4448(BgF40Block* this, GlobalContext* globalCtx) {
+ if (func_80BC3B00(this)) {
+ this->dyna.actor.speedXZ = 40.0f;
+ if (this->unk_160 > 0) {
+ this->unk_164 = this->unk_160 - 1;
+ } else {
+ this->actionFunc = func_80BC4380;
+ ActorCutscene_Stop(this->dyna.actor.cutscene);
+ Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_C);
+ }
+ }
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4380.s")
+ if (func_80BC3D08(this, globalCtx, 0)) {
+ ActorCutscene_Stop(this->dyna.actor.cutscene);
+ this->actionFunc = func_80BC43CC;
+ Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_STOP_F);
+ }
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC43CC.s")
+void func_80BC44F4(BgF40Block* this, GlobalContext* globalCtx) {
+ if (func_80BC3CA4(this)) {
+ this->actionFunc = func_80BC4448;
+ }
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4448.s")
+void func_80BC4530(BgF40Block* this, GlobalContext* globalCtx) {
+ if (!Flags_GetSwitch(globalCtx, BGF40BLOCK_GET_SWITCHFLAG(&this->dyna.actor))) {
+ this->actionFunc = func_80BC44F4;
+ }
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC44F4.s")
+void func_80BC457C(BgF40Block* this, GlobalContext* globalCtx) {
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC4530.s")
+void BgF40Block_Update(Actor* thisx, GlobalContext* globalCtx) {
+ BgF40Block* this = THIS;
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/func_80BC457C.s")
+ this->actionFunc(this, globalCtx);
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Update.s")
+ Math_Vec3f_Copy(&this->dyna.actor.focus.pos, &this->dyna.actor.world.pos);
+}
-#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Block/BgF40Block_Draw.s")
+void BgF40Block_Draw(Actor* thisx, GlobalContext* globalCtx) {
+ Gfx_DrawDListOpa(globalCtx, object_f40_obj_DL_0043D0);
+}
diff --git a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h
index 92b1d1e9e..cf9dfb03b 100644
--- a/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h
+++ b/src/overlays/actors/ovl_Bg_F40_Block/z_bg_f40_block.h
@@ -7,9 +7,15 @@ struct BgF40Block;
typedef void (*BgF40BlockActionFunc)(struct BgF40Block*, GlobalContext*);
+#define BGF40BLOCK_GET_PATH(thisx) (((thisx)->params & 0x1FC) >> 2)
+#define BGF40BLOCK_GET_SWITCHFLAG(thisx) (((thisx)->params & 0xFE00) >> 9)
+
typedef struct BgF40Block {
- /* 0x0000 */ Actor actor;
- /* 0x0144 */ char unk_144[0x28];
+ /* 0x0000 */ DynaPolyActor dyna;
+ /* 0x015C */ Path* path;
+ /* 0x0160 */ s32 unk_160;
+ /* 0x0164 */ s32 unk_164;
+ /* 0x0168 */ s32 unk_168;
/* 0x016C */ BgF40BlockActionFunc actionFunc;
} BgF40Block; // size = 0x170