diff --git a/src/overlays/actors/ovl_En_An/z_en_an.c b/src/overlays/actors/ovl_En_An/z_en_an.c index 3ab31bfb8..5c5739d39 100644 --- a/src/overlays/actors/ovl_En_An/z_en_an.c +++ b/src/overlays/actors/ovl_En_An/z_en_an.c @@ -53,7 +53,34 @@ extern UNK_TYPE D_06012618; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_An/func_80B539CC.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_An/func_80B53A7C.s") +Actor* func_80B53A7C(EnAn* this, PlayState* play, u8 actorCategory, s16 actorId) { + Actor* foundActor = NULL; + + while (true) { + foundActor = SubS_FindActor(play, foundActor, actorCategory, actorId); + + if (foundActor == NULL) { + break; + } + + if ((this != (EnAn*)foundActor)) { + if ((foundActor->update != NULL) && !(foundActor->params & 0x8000)) { + break; + } + } + + if (foundActor->next == NULL) { + foundActor = NULL; + break; + } + + foundActor = foundActor->next; + } + + return foundActor; +} + +//#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_An/func_80B53A7C.s") #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_An/func_80B53B3C.s") @@ -159,9 +186,44 @@ extern UNK_TYPE D_06012618; #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_An/func_80B57B48.s") -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_An/EnAn_Init.s") +void EnAn_Init(Actor* thisx, PlayState* play) { + s32 pad; + EnAn* this = THIS; + s32 temp_v1; // sp1C + s32 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_An/EnAn_Destroy.s") + if (play->sceneId != SCENE_YADOYA) { + this->actor.params &= (s16)~0x8000; + } + + temp_v1 = ENAN_GET_8000(&this->actor); + temp_v0 = gSaveContext.save.saveInfo.weekEventReg[0x33] & 0x40; + + if (((temp_v0 == 0) && (temp_v1 == 1)) || ((temp_v0 != 0) && (temp_v1 == 0))) { + Actor_Kill(&this->actor); + return; + } + + if (temp_v1 == 0) { + if (func_80B53A7C(this, play, ACTORCAT_NPC, ACTOR_EN_AN) != NULL) { + Actor_Kill(&this->actor); + return; + } + } + + this->unk_214 = -0x80; + this->unk_3B8 = 0; + if (temp_v1 == 0) { + this->actor.room = -1; + } + this->actionFunc = func_80B577F0; +} + +void EnAn_Destroy(Actor* thisx, PlayState* play) { + EnAn* this = THIS; + + Collider_DestroyCylinder(play, &this->unk_190); +} #pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_An/EnAn_Update.s") diff --git a/src/overlays/actors/ovl_En_An/z_en_an.h b/src/overlays/actors/ovl_En_An/z_en_an.h index 7f1a11930..b0c036315 100644 --- a/src/overlays/actors/ovl_En_An/z_en_an.h +++ b/src/overlays/actors/ovl_En_An/z_en_an.h @@ -7,11 +7,20 @@ struct EnAn; typedef void (*EnAnActionFunc)(struct EnAn*, PlayState*); +#define ENAN_GET_8000(thisx) (((thisx)->params & 0x8000) >> 0xF) + typedef struct EnAn { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x44]; + /* 0x144 */ UNK_TYPE1 unk_144[0x44]; /* 0x188 */ EnAnActionFunc actionFunc; - /* 0x18C */ char unk_18C[0x23C]; + /* 0x18C */ UNK_TYPE1 unk_18C[0x4]; + /* 0x190 */ ColliderCylinder unk_190; + /* 0x1DC */ UNK_TYPE1 pad_1DC[0x214-0x1DC]; + /* 0x214 */ s8 unk_214; + /* 0x215 */ UNK_TYPE1 unk_215[0x3]; + /* 0x218 */ UNK_TYPE1 unk_218[0x3B8-0x218]; + /* 0x3B8 */ s32 unk_3B8; + /* 0x3BC */ UNK_TYPE1 unk_3BC[0x3C8-0x3BC]; } EnAn; // size = 0x3C8 #endif // Z_EN_AN_H