diff --git a/linker_scripts/code_script.txt b/linker_scripts/code_script.txt index 29d971da32..1a72423413 100644 --- a/linker_scripts/code_script.txt +++ b/linker_scripts/code_script.txt @@ -5468,9 +5468,9 @@ SECTIONS ovl_Dm_Char07 : AT(RomLocation) { build/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.o(.text) - build/asm/overlays/ovl_Dm_Char07_data.o(.data) + build/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.o(.data) build/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.o(.rodata) - build/asm/overlays/ovl_Dm_Char07_rodata.o(.rodata) + build/src/overlays/actors/ovl_Dm_Char07/z_dm_char07_overlay.o(.ovl) } SegmentEnd = .; SegmentSize = SegmentEnd - SegmentStart; diff --git a/linker_scripts/object_script.txt b/linker_scripts/object_script.txt index ff89653f5b..1367a93157 100644 --- a/linker_scripts/object_script.txt +++ b/linker_scripts/object_script.txt @@ -179,6 +179,25 @@ D_06007750 = 0x06007750; D_0600A390 = 0x0600A390; D_0600A490 = 0x0600A490; +/* dm_char07 */ +D_06000100 = 0x06000100; +D_06000240 = 0x06000240; +D_06000650 = 0x06000650; +D_06000790 = 0x06000790; +D_06000B80 = 0x06000B80; +D_06000CC0 = 0x06000CC0; +D_060010D0 = 0x060010D0; +D_06001210 = 0x06001210; +D_060015E0 = 0x060015E0; +D_060016B8 = 0x060016B8; +D_06002BA0 = 0x06002BA0; +D_06002CD0 = 0x06002CD0; +D_06006688 = 0x06006688; +D_060076A0 = 0x060076A0; +D_06007918 = 0x06007918; +D_060105F8 = 0x060105F8; +D_06010D68 = 0x06010D68; + /* obj_lightswitch */ D_06000C20 = 0x6000C20; D_06000420 = 0x6000420; diff --git a/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c b/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c index e2a754e175..260c6ec172 100644 --- a/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c +++ b/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.c @@ -1,3 +1,9 @@ +/* + * File: z_dm_char07.c + * Overlay: Dm_Char07 + * Description: Different Milk Bar Objects (Stage, Credits Stage, Spotlights, Dishes) + */ + #include "z_dm_char07.h" #define FLAGS 0x00000030 @@ -9,7 +15,8 @@ void DmChar07_Destroy(Actor* thisx, GlobalContext* globalCtx); void DmChar07_Update(Actor* thisx, GlobalContext* globalCtx); void DmChar07_Draw(Actor* thisx, GlobalContext* globalCtx); -/* +void DmChar07_DoNothing(DmChar07* this, GlobalContext* globalCtx); + const ActorInit Dm_Char07_InitVars = { ACTOR_DM_CHAR07, ACTORCAT_ITEMACTION, @@ -21,16 +28,141 @@ const ActorInit Dm_Char07_InitVars = { (ActorFunc)DmChar07_Update, (ActorFunc)DmChar07_Draw, }; -*/ -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Char07_0x80AAE9C0/func_80AAE9C0.asm") +extern Gfx D_06000100[]; +extern Gfx D_06000240[]; +extern Gfx D_06000650[]; +extern Gfx D_06000790[]; +extern Gfx D_06000B80[]; +extern Gfx D_06000CC0[]; +extern Gfx D_060010D0[]; +extern Gfx D_06001210[]; +extern Gfx D_060015E0[]; +extern Gfx D_060016B8[]; +extern Gfx D_06002BA0[]; +extern Gfx D_06002CD0[]; +extern CollisionHeader D_06006688; +extern Gfx D_060076A0[]; +extern Gfx D_06007918[]; +extern AnimatedMaterial D_060105F8; +extern Gfx D_06010D68[]; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Char07_0x80AAE9C0/DmChar07_Init.asm") +void DmChar07_SetupAction(DmChar07* this, DmChar07ActionFunc actionFunc) { + this->actionFunc = actionFunc; +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Char07_0x80AAE9C0/DmChar07_Destroy.asm") +void DmChar07_Init(Actor* thisx, GlobalContext* globalCtx) { + DmChar07* this = THIS; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Char07_0x80AAE9C0/func_80AAEABC.asm") + this->isStage = 0; + Actor_SetScale(&this->dyna.actor, 1.0f); + this->spotlightFlags = DMCHAR07_GET_SPOTLIGHTFLAGS(thisx); + thisx->params = DMCHAR07_GET_TYPE(thisx); + if (this->dyna.actor.params == DMCHAR07_STAGE) { + Actor_SetScale(&this->dyna.actor, 0.1f); + this->isStage = 1; + BcCheck3_BgActorInit(&this->dyna, 0); + BgCheck3_LoadMesh(globalCtx, &this->dyna, &D_06006688); + } else { + Actor_SetScale(&this->dyna.actor, 1.0f); + } + DmChar07_SetupAction(this, DmChar07_DoNothing); +} -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Char07_0x80AAE9C0/DmChar07_Update.asm") +void DmChar07_Destroy(Actor* thisx, GlobalContext* globalCtx) { + DmChar07* this = THIS; -#pragma GLOBAL_ASM("./asm/non_matchings/overlays/ovl_Dm_Char07_0x80AAE9C0/DmChar07_Draw.asm") + if (this->isStage) { + BgCheck_RemoveActorMesh(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + } +} + +void DmChar07_DoNothing(DmChar07* this, GlobalContext* globalCtx) { +} + +void DmChar07_Update(Actor* thisx, GlobalContext* globalCtx) { + DmChar07* this = THIS; + + this->actionFunc(this, globalCtx); +} + +void DmChar07_Draw(Actor* thisx, GlobalContext* globalCtx) { + DmChar07* this = THIS; + s32 pad; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + switch (this->dyna.actor.params) { + case DMCHAR07_STAGE: + gSPDisplayList(POLY_OPA_DISP++, D_06002CD0); + break; + case DMCHAR07_CREDITS_STAGE: + AnimatedMat_Draw(globalCtx, Lib_SegmentedToVirtual(&D_060105F8)); + gSPDisplayList(POLY_OPA_DISP++, D_06007918); + gSPDisplayList(POLY_OPA_DISP++, D_06000240); + gSPDisplayList(POLY_OPA_DISP++, D_06000790); + gSPDisplayList(POLY_OPA_DISP++, D_06000CC0); + gSPDisplayList(POLY_OPA_DISP++, D_06001210); + gSPDisplayList(POLY_OPA_DISP++, D_060016B8); + break; + case DMCHAR07_SPOTLIGHTS: + if (this->spotlightFlags & DMCHAR07_STAGE_RIGHT_SPOTLIGHT) { + gSPDisplayList(POLY_OPA_DISP++, D_06000240); + } + if (this->spotlightFlags & DMCHAR07_UPSTAGE_RIGHT_SPOTLIGHT) { + gSPDisplayList(POLY_OPA_DISP++, D_06000790); + } + if (this->spotlightFlags & DMCHAR07_STAGE_CENTER_SPOTLIGHT) { + gSPDisplayList(POLY_OPA_DISP++, D_06000CC0); + } + if (this->spotlightFlags & DMCHAR07_UPSTAGE_LEFT_SPOTLIGHT) { + gSPDisplayList(POLY_OPA_DISP++, D_06001210); + } + if (this->spotlightFlags & DMCHAR07_DOWNSTAGE_CENTER_SPOTLIGHT) { + gSPDisplayList(POLY_OPA_DISP++, D_060016B8); + } + break; + case DMCHAR07_DISHES: + gSPDisplayList(POLY_OPA_DISP++, D_06010D68); + break; + } + + func_8012C2DC(globalCtx->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + switch (this->dyna.actor.params) { + case DMCHAR07_STAGE: + gSPDisplayList(POLY_XLU_DISP++, D_06002BA0); + break; + case DMCHAR07_CREDITS_STAGE: + gSPDisplayList(POLY_XLU_DISP++, D_060076A0); + gSPDisplayList(POLY_XLU_DISP++, D_06000100); + gSPDisplayList(POLY_XLU_DISP++, D_06000650); + gSPDisplayList(POLY_XLU_DISP++, D_06000B80); + gSPDisplayList(POLY_XLU_DISP++, D_060010D0); + gSPDisplayList(POLY_XLU_DISP++, D_060015E0); + break; + case DMCHAR07_SPOTLIGHTS: + if (this->spotlightFlags & DMCHAR07_STAGE_RIGHT_SPOTLIGHT) { + gSPDisplayList(POLY_OPA_DISP++, D_06000100); + } + if (this->spotlightFlags & DMCHAR07_UPSTAGE_RIGHT_SPOTLIGHT) { + gSPDisplayList(POLY_OPA_DISP++, D_06000650); + } + if (this->spotlightFlags & DMCHAR07_STAGE_CENTER_SPOTLIGHT) { + gSPDisplayList(POLY_OPA_DISP++, D_06000B80); + } + if (this->spotlightFlags & DMCHAR07_UPSTAGE_LEFT_SPOTLIGHT) { + gSPDisplayList(POLY_OPA_DISP++, D_060010D0); + } + if (this->spotlightFlags & DMCHAR07_DOWNSTAGE_CENTER_SPOTLIGHT) { + gSPDisplayList(POLY_OPA_DISP++, D_060015E0); + } + break; + case DMCHAR07_DISHES: + break; + } + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.h b/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.h index a10ba75ef5..5586f047ef 100644 --- a/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.h +++ b/src/overlays/actors/ovl_Dm_Char07/z_dm_char07.h @@ -5,9 +5,31 @@ struct DmChar07; +typedef void (*DmChar07ActionFunc)(struct DmChar07*, GlobalContext*); + +#define DMCHAR07_GET_SPOTLIGHTFLAGS(thisx) (((thisx)->params >> 8) & 0x1F) +#define DMCHAR07_GET_TYPE(thisx) ((thisx)->params & 0xFF) + +#define DMCHAR07_STAGE_RIGHT_SPOTLIGHT 1 // Deku spotlight +#define DMCHAR07_UPSTAGE_RIGHT_SPOTLIGHT 2 // Goron spotlight +#define DMCHAR07_STAGE_CENTER_SPOTLIGHT 4 // Human spotlight +#define DMCHAR07_UPSTAGE_LEFT_SPOTLIGHT 8 // Zora spotlight +#define DMCHAR07_DOWNSTAGE_CENTER_SPOTLIGHT 16 + +typedef enum { + /* 0 */ DMCHAR07_STAGE, + /* 1 */ DMCHAR07_CREDITS_STAGE, + /* 2 */ DMCHAR07_SPOTLIGHTS, + /* 3 */ DMCHAR07_DISHES +} DmChar07Type; + typedef struct DmChar07 { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x178]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ char pad15C[0x14C]; + /* 0x2A8 */ DmChar07ActionFunc actionFunc; + /* 0x2AC */ char pad2AC[0xD]; + /* 0x2B9 */ u8 spotlightFlags; + /* 0x2BA */ u8 isStage; } DmChar07; // size = 0x2BC extern const ActorInit Dm_Char07_InitVars; diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.c b/src/overlays/actors/ovl_En_Toto/z_en_toto.c index 7233fe49ac..cad6f9968f 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.c +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.c @@ -487,7 +487,7 @@ s32 func_80BA42BC(EnToto* this, GlobalContext* globalCtx) { } } func_80122744(globalCtx, this->unk2BC, phi_s0, end - phi_s0); - this->unk2C4 = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DM_CHAR07, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0xF02); + this->spotlights = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_DM_CHAR07, 0.0f, 0.0f, 0.0f, 0, 0, 0, 0xF02); return 0; } @@ -532,8 +532,8 @@ s32 func_80BA4530(EnToto* this, GlobalContext* globalCtx) { func_80BA3C88(this); if (player->base.world.pos.z > -270.0f) { - if (this->unk2C4 != NULL) { - Actor_MarkForDeath(this->unk2C4); + if (this->spotlights != NULL) { + Actor_MarkForDeath(this->spotlights); } this->unk2B6 = 1; return this->text->unk1; @@ -639,8 +639,8 @@ s32 func_80BA4A00(EnToto* this, GlobalContext* globalCtx) { Actor_MarkForDeath(actor); actor = actor->next; } - if (this->unk2C4 != NULL) { - Actor_MarkForDeath(this->unk2C4); + if (this->spotlights != NULL) { + Actor_MarkForDeath(this->spotlights); } func_800B7298(globalCtx, 0, 0x45); if (this->unk2B3 == 0xF) { diff --git a/src/overlays/actors/ovl_En_Toto/z_en_toto.h b/src/overlays/actors/ovl_En_Toto/z_en_toto.h index 04a76da1d6..59451c56c5 100644 --- a/src/overlays/actors/ovl_En_Toto/z_en_toto.h +++ b/src/overlays/actors/ovl_En_Toto/z_en_toto.h @@ -38,7 +38,7 @@ typedef struct EnToto { /* 0x2B7 */ u8 unk2B7; /* 0x2B8 */ EnTotoText* text; /* 0x2BC */ char unk2BC[0x8]; // Some z_player_lib struct size 0x8 more info from func_80122744 and func_80122760 - /* 0x2C4 */ Actor* unk2C4; + /* 0x2C4 */ Actor* spotlights; /* 0x2C8 */ s32 pad2C8; } EnToto; // size = 0x2CC diff --git a/tables/functions.txt b/tables/functions.txt index c4cc4e9aed..0319a07822 100644 --- a/tables/functions.txt +++ b/tables/functions.txt @@ -11636,10 +11636,10 @@ 0x80AAE6F0:("func_80AAE6F0",), 0x80AAE854:("DmChar06_Update",), 0x80AAE878:("DmChar06_Draw",), - 0x80AAE9C0:("func_80AAE9C0",), + 0x80AAE9C0:("DmChar07_SetupAction",), 0x80AAE9CC:("DmChar07_Init",), 0x80AAEA84:("DmChar07_Destroy",), - 0x80AAEABC:("func_80AAEABC",), + 0x80AAEABC:("DmChar07_DoNothing",), 0x80AAEACC:("DmChar07_Update",), 0x80AAEAF0:("DmChar07_Draw",), 0x80AAF050:("func_80AAF050",),