From 0261dc0a5c99ab87fed760c0cb81d1f7c4f9dc3b Mon Sep 17 00:00:00 2001 From: TrulyNaN <52424023+TrulyNaN@users.noreply.github.com> Date: Fri, 2 Jun 2023 00:25:03 -0400 Subject: [PATCH] ovl_Bg_F40_Swlift OK and documented. obj_f40_obj documented. (#1171) * Ported ovl_Bg_F40_Swlift to most recent zeldaret/master. * Ran formatter. * Attempt at fixing formatter problem. * Applied PR changes suggestions and added authors Co-authored-by: petrie911 Co-authored-by: Isghj5 Co-authored-by: Tom-Overton Co-authored-by: Derek-Hensley * More PR fixes. Put object_f40_obj unused descriptor as comments. Added another author. Co-authored-by: AngheloAlf * Fixed some effect of handling merge conflicts. Some early returns added and renames in object_f40_obj.xml --------- Co-authored-by: petrie911 Co-authored-by: Isghj5 Co-authored-by: Tom-Overton Co-authored-by: Derek-Hensley Co-authored-by: AngheloAlf --- assets/xml/objects/object_f40_obj.xml | 34 ++++--- spec | 4 +- .../actors/ovl_Bg_F40_Block/z_bg_f40_block.c | 4 +- .../actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c | 4 +- .../ovl_Bg_F40_Swlift/z_bg_f40_swlift.c | 91 ++++++++++++++++--- .../ovl_Bg_F40_Swlift/z_bg_f40_swlift.h | 7 +- 6 files changed, 109 insertions(+), 35 deletions(-) diff --git a/assets/xml/objects/object_f40_obj.xml b/assets/xml/objects/object_f40_obj.xml index 17e7210def..636a806826 100644 --- a/assets/xml/objects/object_f40_obj.xml +++ b/assets/xml/objects/object_f40_obj.xml @@ -1,17 +1,25 @@  + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/spec b/spec index a9d627634f..12fce05ce9 100644 --- a/spec +++ b/spec @@ -1637,9 +1637,7 @@ beginseg name "ovl_Bg_F40_Swlift" compress include "build/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.o" - include "build/data/ovl_Bg_F40_Swlift/ovl_Bg_F40_Swlift.data.o" - include "build/data/ovl_Bg_F40_Swlift/ovl_Bg_F40_Swlift.bss.o" - include "build/data/ovl_Bg_F40_Swlift/ovl_Bg_F40_Swlift.reloc.o" + include "build/src/overlays/actors/ovl_Bg_F40_Swlift/ovl_Bg_F40_Swlift_reloc.o" endseg beginseg 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 be1958cb4d..134e7227ac 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 @@ -229,7 +229,7 @@ void BgF40Block_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); - DynaPolyActor_LoadMesh(play, &this->dyna, &object_f40_obj_Colheader_004640); + DynaPolyActor_LoadMesh(play, &this->dyna, &gStoneTowerBlockCol); if (BGF40BLOCK_GET_PATH(&this->dyna.actor) != 0x3F) { this->path = &play->setupPathList[BGF40BLOCK_GET_PATH(&this->dyna.actor)]; @@ -373,5 +373,5 @@ void BgF40Block_Update(Actor* thisx, PlayState* play) { } void BgF40Block_Draw(Actor* thisx, PlayState* play) { - Gfx_DrawDListOpa(play, object_f40_obj_DL_0043D0); + Gfx_DrawDListOpa(play, gStoneTowerBlockDL); } diff --git a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c index 075f38607a..2c99197288 100644 --- a/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c +++ b/src/overlays/actors/ovl_Bg_F40_Flift/z_bg_f40_flift.c @@ -42,7 +42,7 @@ void BgF40Flift_Init(Actor* thisx, PlayState* play) { Actor_ProcessInitChain(&this->dyna.actor, sInitChain); DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); - DynaPolyActor_LoadMesh(play, &this->dyna, &object_f40_obj_Colheader_004240); + DynaPolyActor_LoadMesh(play, &this->dyna, &gStoneTowerTempleSquareElevatorCol); this->dyna.actor.params = 1; this->actionFunc = func_808D75F0; } @@ -91,5 +91,5 @@ void BgF40Flift_Update(Actor* thisx, PlayState* play) { } void BgF40Flift_Draw(Actor* thisx, PlayState* play) { - Gfx_DrawDListOpa(play, object_f40_obj_DL_004038); + Gfx_DrawDListOpa(play, gStoneTowerTempleSquareElevatorDL); } diff --git a/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c b/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c index 97fd3f068e..bf6244efe8 100644 --- a/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c +++ b/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.c @@ -5,6 +5,7 @@ */ #include "z_bg_f40_swlift.h" +#include "objects/object_f40_obj/object_f40_obj.h" #define FLAGS (ACTOR_FLAG_10) @@ -12,11 +13,13 @@ void BgF40Swlift_Init(Actor* thisx, PlayState* play); void BgF40Swlift_Destroy(Actor* thisx, PlayState* play); -void BgF40Swlift_Update(Actor* thisx, PlayState* play); +void BgF40Swlift_Update(Actor* thisx, PlayState* play2); void BgF40Swlift_Draw(Actor* thisx, PlayState* play); -#if 0 -ActorInit Bg_F40_Swlift_InitVars = { +static s32 sSwitchFlags[4] = { 0xFF, 0xFF, 0xFF, 0xFF }; +static s32 sHeights[4]; + +const ActorInit Bg_F40_Swlift_InitVars = { ACTOR_BG_F40_SWLIFT, ACTORCAT_BG, FLAGS, @@ -28,24 +31,86 @@ ActorInit Bg_F40_Swlift_InitVars = { (ActorFunc)BgF40Swlift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_8096F540[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneScale, 550, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 5000, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void BgF40Swlift_Init(Actor* thisx, PlayState* play) { + BgF40Swlift* this = THIS; + s32 index; + s32 pad; -extern InitChainEntry D_8096F540[]; + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS); + index = BG_F40_SWLIFT_GET_INDEX(thisx); + if ((index < 0) || (index >= 5)) { //! @bug An index greater than 3 will cause an out of bounds array access. + Actor_Kill(&this->dyna.actor); + return; + } -extern UNK_TYPE D_06003B08; -extern UNK_TYPE D_06003E80; + sHeights[index] = this->dyna.actor.world.pos.y; + sSwitchFlags[index] = BG_F40_SWLIFT_GET_SWITCHFLAG(thisx); + if (index != 0) { + Actor_Kill(&this->dyna.actor); + return; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Swlift/BgF40Swlift_Init.s") + DynaPolyActor_LoadMesh(play, &this->dyna, &gStoneTowerVerticallyOscillatingPlatformCol); + this->dyna.actor.params = 0; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Swlift/BgF40Swlift_Destroy.s") +void BgF40Swlift_Destroy(Actor* thisx, PlayState* play) { + BgF40Swlift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Swlift/BgF40Swlift_Update.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_F40_Swlift/BgF40Swlift_Draw.s") +void BgF40Swlift_Update(Actor* thisx, PlayState* play2) { + PlayState* play = play2; + BgF40Swlift* this = THIS; + s32 i; + + for (i = 1; i < ARRAY_COUNT(sSwitchFlags); i++) { + if ((sSwitchFlags[i] == 0xFF) || !Flags_GetSwitch(play, sSwitchFlags[i])) { + break; + } + } + + i--; + if (i != this->dyna.actor.params) { + f32 heightOffset; + + this->dyna.actor.params = -1; + heightOffset = (sHeights[i] - this->dyna.actor.world.pos.y) * 0.1f; + if (heightOffset > 0.0f) { + heightOffset = CLAMP(heightOffset, 0.5f, 15.0f); + } else { + heightOffset = CLAMP(heightOffset, -15.0f, -0.5f); + } + + if (Math_StepToF(&this->dyna.actor.speed, heightOffset, 1.0f) && (fabsf(heightOffset) <= 0.5f)) { + if (Math_StepToF(&this->dyna.actor.world.pos.y, sHeights[i], fabsf(this->dyna.actor.speed))) { + this->dyna.actor.params = i; + this->timer = 48; + this->dyna.actor.speed = 0.0f; + } + } else { + this->dyna.actor.world.pos.y += this->dyna.actor.speed; + } + } else { + if (this->timer == 0) { + this->timer = 48; + } + this->timer--; + this->dyna.actor.world.pos.y = + sHeights[this->dyna.actor.params] + (sin_rad(this->timer * (M_PI / 24.0f)) * 5.0f); + } +} + +void BgF40Swlift_Draw(Actor* thisx, PlayState* play) { + BgF40Swlift* this = THIS; + + Gfx_DrawDListOpa(play, gStoneTowerVerticallyOscillatingPlatformDL); +} diff --git a/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.h b/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.h index a687fc642a..e377b73e0d 100644 --- a/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.h +++ b/src/overlays/actors/ovl_Bg_F40_Swlift/z_bg_f40_swlift.h @@ -1,13 +1,16 @@ #ifndef Z_BG_F40_SWLIFT_H #define Z_BG_F40_SWLIFT_H +#define BG_F40_SWLIFT_GET_SWITCHFLAG(thisx) ((thisx)->params & 0xFF) +#define BG_F40_SWLIFT_GET_INDEX(thisx) (((thisx)->params >> 8) & 0xFF) + #include "global.h" struct BgF40Swlift; typedef struct BgF40Swlift { - /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x1C]; + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ s32 timer; } BgF40Swlift; // size = 0x160 #endif // Z_BG_F40_SWLIFT_H