diff --git a/include/functions.h b/include/functions.h index b2bdd99865..980a2937b9 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1591,7 +1591,7 @@ void func_800EDF24(void); // func_800EDF24 void func_800EDF78(Actor* actor, GlobalContext* ctxt, int iParm3); // func_800EDF78 void func_800EE0CC(Actor* actor, GlobalContext* ctxt, int iParm3); // func_800EE0CC void func_800EE1D8(void); // func_800EE1D8 -void func_800EE200(void); // func_800EE200 +u32 func_800EE200(GlobalContext* ctxt, u32 uParm2); // func_800EE200 u32 func_800EE29C(GlobalContext* ctxt, u32 uParm2); // func_800EE29C u32 func_800EE2F4(GlobalContext* ctxt); // func_800EE2F4 void func_800EE320(GlobalContext* ctxt, s16 index); // func_800EE320 diff --git a/include/variables_overlay.h b/include/variables_overlay.h index bebf551fd4..4b4dbfecf0 100644 --- a/include/variables_overlay.h +++ b/include/variables_overlay.h @@ -11618,7 +11618,7 @@ extern UNK_TYPE4 D_80B6DB88; // D_80B6DB88 extern OverlayRelocationSection bgSinkaiKabeOverlayInfo; // D_80B6DB90 extern u32 bgSinkaiKabeOverlayRelocations[13]; // D_80B6DBA4 extern u32 bgSinkaiKabeOverlayInfoOffset; // D_80B6DBDC -extern UNK_TYPE1 D_80B6DF80; // D_80B6DF80 +extern UNK_TYPE1 Bg_Haka_Curtain_InitVars; // Bg_Haka_Curtain_InitVars extern UNK_TYPE1 D_80B6DFA0; // D_80B6DFA0 extern OverlayRelocationSection bgHakaCurtainOverlayInfo; // D_80B6DFB0 extern u32 bgHakaCurtainOverlayRelocations[22]; // D_80B6DFC4 diff --git a/include/z64cutscene.h b/include/z64cutscene.h index 482fb964f0..586bc2f906 100644 --- a/include/z64cutscene.h +++ b/include/z64cutscene.h @@ -5,7 +5,7 @@ #include typedef struct { - /* 0x00 */ UNK_TYPE1 pad0[0x2]; + /* 0x00 */ u16 unk0; /* 0x02 */ u16 startFrame; /* 0x04 */ u16 endFrame; /* 0x06 */ UNK_TYPE1 pad6[0x2A]; diff --git a/linker_scripts/code_script.txt b/linker_scripts/code_script.txt index cad6f2f53e..e9f33b144a 100644 --- a/linker_scripts/code_script.txt +++ b/linker_scripts/code_script.txt @@ -5681,8 +5681,9 @@ SECTIONS ovl_Bg_Haka_Curtain : AT(RomLocation) { build/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.o(.text) - build/asm/ovl_Bg_Haka_Curtain_data.o(.data) - build/asm/ovl_Bg_Haka_Curtain_rodata.o(.rodata) + build/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.o(.data) + build/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.o(.rodata) + build/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain_overlay.o(.ovl) } SegmentEnd = .; SegmentSize = SegmentEnd - SegmentStart; diff --git a/linker_scripts/object_script.txt b/linker_scripts/object_script.txt index ece99d548f..a2065bb146 100644 --- a/linker_scripts/object_script.txt +++ b/linker_scripts/object_script.txt @@ -13,6 +13,10 @@ D_0E000140 = 0x0E000140; D_0E0001C8 = 0x0E0001C8; D_0E0002C8 = 0x0E0002C8; +/* bg_haka_curtain */ +D_06001410 = 0x06001410; +D_06001588 = 0x06001588; + /* obj_hana */ D_06000500 = 0x06000500; diff --git a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c index b6148b7245..8831e6d655 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c +++ b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.c @@ -9,7 +9,16 @@ void BgHakaCurtain_Destroy(Actor* thisx, GlobalContext* globalCtx); void BgHakaCurtain_Update(Actor* thisx, GlobalContext* globalCtx); void BgHakaCurtain_Draw(Actor* thisx, GlobalContext* globalCtx); -/* +void func_80B6DC98(BgHakaCurtain* this); +void func_80B6DCAC(BgHakaCurtain* this, GlobalContext* globalCtx); +void func_80B6DCEC(BgHakaCurtain* this); +void func_80B6DD00(BgHakaCurtain* this, GlobalContext* globalCtx); +void func_80B6DD5C(BgHakaCurtain* this); +void func_80B6DD70(BgHakaCurtain* this, GlobalContext* globalCtx); +void func_80B6DD9C(BgHakaCurtain* this, GlobalContext* globalCtx); +void func_80B6DEA8(BgHakaCurtain* this, GlobalContext* globalCtx); +void func_80B6DE80(BgHakaCurtain* this); + const ActorInit Bg_Haka_Curtain_InitVars = { ACTOR_BG_HAKA_CURTAIN, ACTORTYPE_BG, @@ -21,32 +30,106 @@ const ActorInit Bg_Haka_Curtain_InitVars = { (ActorFunc)BgHakaCurtain_Update, (ActorFunc)BgHakaCurtain_Draw }; -*/ -GLOBAL_ASM("asm/non_matchings/ovl_Bg_Haka_Curtain_0x80B6DBE0/BgHakaCurtain_Init.asm") +static InitChainEntry D_80B6DFA0[] = { + ICHAIN_F32(unkFC, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(unk100, 700, ICHAIN_CONTINUE), + ICHAIN_F32(unk104, 600, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), +}; -GLOBAL_ASM("asm/non_matchings/ovl_Bg_Haka_Curtain_0x80B6DBE0/BgHakaCurtain_Destroy.asm") +extern BgMeshHeader D_06001588; +extern UNK_TYPE D_06001410; -GLOBAL_ASM("asm/non_matchings/ovl_Bg_Haka_Curtain_0x80B6DBE0/func_80B6DC98.asm") +void BgHakaCurtain_Init(Actor* thisx, GlobalContext* globalCtx) { + BgHakaCurtain* this = THIS; -GLOBAL_ASM("asm/non_matchings/ovl_Bg_Haka_Curtain_0x80B6DBE0/func_80B6DCAC.asm") + Actor_ProcessInitChain(&this->dyna.actor, D_80B6DFA0); + BcCheck3_BgActorInit(&this->dyna, 1); + BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06001588); + if (Actor_GetRoomCleared(globalCtx, this->dyna.actor.room)) { + func_80B6DE80(this); + return; + } + func_80B6DC98(this); +} -GLOBAL_ASM("asm/non_matchings/ovl_Bg_Haka_Curtain_0x80B6DBE0/func_80B6DCEC.asm") +void BgHakaCurtain_Destroy(Actor* thisx, GlobalContext* globalCtx) { + BgHakaCurtain* this = THIS; -GLOBAL_ASM("asm/non_matchings/ovl_Bg_Haka_Curtain_0x80B6DBE0/func_80B6DD00.asm") + BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId); +} -GLOBAL_ASM("asm/non_matchings/ovl_Bg_Haka_Curtain_0x80B6DBE0/func_80B6DD5C.asm") +void func_80B6DC98(BgHakaCurtain* this) { + this->actionFunc = func_80B6DCAC; +} -GLOBAL_ASM("asm/non_matchings/ovl_Bg_Haka_Curtain_0x80B6DBE0/func_80B6DD70.asm") +void func_80B6DCAC(BgHakaCurtain* this, GlobalContext* globalCtx) { + if (Actor_GetRoomCleared(globalCtx, this->dyna.actor.room)) { + func_80B6DCEC(this); + } +} -GLOBAL_ASM("asm/non_matchings/ovl_Bg_Haka_Curtain_0x80B6DBE0/func_80B6DD80.asm") +void func_80B6DCEC(BgHakaCurtain* this) { + this->actionFunc = func_80B6DD00; +} -GLOBAL_ASM("asm/non_matchings/ovl_Bg_Haka_Curtain_0x80B6DBE0/func_80B6DD9C.asm") +void func_80B6DD00(BgHakaCurtain* this, GlobalContext* globalCtx) { + if (ActorCutscene_GetCanPlayNext(this->dyna.actor.cutscene)) { + ActorCutscene_StartAndSetUnkLinkFields(this->dyna.actor.cutscene, &this->dyna.actor); + func_80B6DD5C(this); + return; + } + ActorCutscene_SetIntentToPlay(this->dyna.actor.cutscene); +} -GLOBAL_ASM("asm/non_matchings/ovl_Bg_Haka_Curtain_0x80B6DBE0/func_80B6DE80.asm") +void func_80B6DD5C(BgHakaCurtain* this) { + this->actionFunc = func_80B6DD70; +} -GLOBAL_ASM("asm/non_matchings/ovl_Bg_Haka_Curtain_0x80B6DBE0/func_80B6DEA8.asm") +void func_80B6DD70(BgHakaCurtain* this, GlobalContext* globalCtx) { +} -GLOBAL_ASM("asm/non_matchings/ovl_Bg_Haka_Curtain_0x80B6DBE0/BgHakaCurtain_Update.asm") +void func_80B6DD80(BgHakaCurtain* this) { + this->actionFunc = func_80B6DD9C; + this->dyna.actor.velocity.y = 0.0f; +} -GLOBAL_ASM("asm/non_matchings/ovl_Bg_Haka_Curtain_0x80B6DBE0/BgHakaCurtain_Draw.asm") +void func_80B6DD9C(BgHakaCurtain* this, GlobalContext* globalCtx) { + if (this->dyna.actor.currPosRot.pos.y < this->dyna.actor.initPosRot.pos.y + 150.0f - 30.0f) { + Lib_StepTowardsCheck_f(&this->dyna.actor.velocity.y, 1.6f, 0.12f); + } else { + Lib_StepTowardsCheck_f(&this->dyna.actor.velocity.y, 0.8f, 0.05f); + } + this->dyna.actor.currPosRot.pos.y += this->dyna.actor.velocity.y; + if (this->dyna.actor.initPosRot.pos.y + 150.0f < this->dyna.actor.currPosRot.pos.y) { + func_80B6DE80(this); + return; + } + func_800B9010(&this->dyna.actor, 0x218D); +} + +void func_80B6DE80(BgHakaCurtain* this) { + this->actionFunc = func_80B6DEA8; + this->dyna.actor.currPosRot.pos.y = this->dyna.actor.initPosRot.pos.y + 150.0f; +} + +void func_80B6DEA8(BgHakaCurtain* this, GlobalContext* globalCtx) { +} + +void BgHakaCurtain_Update(Actor* thisx, GlobalContext* globalCtx) { + BgHakaCurtain* this = THIS; + CsCmdActorAction* actorAction; + + if (func_800EE29C(globalCtx, 0x1D5)) { + actorAction = globalCtx->csCtx.actorActions[func_800EE200(globalCtx, 0x1D5)]; + if (actorAction->startFrame == globalCtx->csCtx.frames && actorAction->unk0 == 2) { + func_80B6DD80(this); + } + } + this->actionFunc(this, globalCtx); +} + +void BgHakaCurtain_Draw(Actor* thisx, GlobalContext* globalCtx) { + func_800BDFC0(globalCtx, &D_06001410); +} diff --git a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.h b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.h index 6e41aa1f58..c9aea2ceb0 100644 --- a/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.h +++ b/src/overlays/actors/ovl_Bg_Haka_Curtain/z_bg_haka_curtain.h @@ -5,9 +5,11 @@ struct BgHakaCurtain; +typedef void (*BgHakaCurtainActionFunc)(struct BgHakaCurtain*, GlobalContext*); + typedef struct BgHakaCurtain { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x1C]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ BgHakaCurtainActionFunc actionFunc; } BgHakaCurtain; // size = 0x160 extern const ActorInit Bg_Haka_Curtain_InitVars; diff --git a/tables/variables.txt b/tables/variables.txt index ae3e27ca91..55fb59b7a3 100644 --- a/tables/variables.txt +++ b/tables/variables.txt @@ -16590,7 +16590,7 @@ 0x80B6DB90:("bgSinkaiKabeOverlayInfo","OverlayRelocationSection","",0x14), 0x80B6DBA4:("bgSinkaiKabeOverlayRelocations","u32","[13]",0x34), 0x80B6DBDC:("bgSinkaiKabeOverlayInfoOffset","u32","",0x4), - 0x80B6DF80:("D_80B6DF80","UNK_TYPE1","",0x1), + 0x80B6DF80:("Bg_Haka_Curtain_InitVars","UNK_TYPE1","",0x1), 0x80B6DFA0:("D_80B6DFA0","UNK_TYPE1","",0x1), 0x80B6DFB0:("bgHakaCurtainOverlayInfo","OverlayRelocationSection","",0x14), 0x80B6DFC4:("bgHakaCurtainOverlayRelocations","u32","[22]",0x58),