diff --git a/spec b/spec index cb8ddd6c00..1717ef0db3 100644 --- a/spec +++ b/spec @@ -3585,8 +3585,7 @@ beginseg name "ovl_Obj_Lupygamelift" compress include "build/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.o" - include "build/data/ovl_Obj_Lupygamelift/ovl_Obj_Lupygamelift.data.o" - include "build/data/ovl_Obj_Lupygamelift/ovl_Obj_Lupygamelift.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Lupygamelift/ovl_Obj_Lupygamelift_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c index e6976c1779..697c73f6a1 100644 --- a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c +++ b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.c @@ -5,6 +5,7 @@ */ #include "z_obj_lupygamelift.h" +#include "objects/object_raillift/object_raillift.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) @@ -15,7 +16,11 @@ void ObjLupygamelift_Destroy(Actor* thisx, PlayState* play); void ObjLupygamelift_Update(Actor* thisx, PlayState* play); void ObjLupygamelift_Draw(Actor* thisx, PlayState* play); -#if 0 +void func_80AF04BC(ObjLupygamelift* this); +void func_80AF04D8(ObjLupygamelift* this, PlayState* play); +void func_80AF0514(ObjLupygamelift* this); +void func_80AF0530(ObjLupygamelift* this, PlayState* play); + const ActorInit Obj_Lupygamelift_InitVars = { ACTOR_OBJ_LUPYGAMELIFT, ACTORCAT_BG, @@ -28,35 +33,142 @@ const ActorInit Obj_Lupygamelift_InitVars = { (ActorFunc)ObjLupygamelift_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80AF0740[] = { +static InitChainEntry sInitChain[] = { ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneScale, 200, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 400, ICHAIN_CONTINUE), ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP), }; -#endif +void ObjLupygamelift_Init(Actor* thisx, PlayState* play) { + s32 pad; + ObjLupygamelift* this = THIS; + Path* path; + s32 params; -extern InitChainEntry D_80AF0740[]; + Actor_ProcessInitChain(thisx, sInitChain); + this->dyna.actor.scale.y = 0.15f; + this->dyna.actor.shape.rot.x = 0; + this->dyna.actor.world.rot.x = 0; + this->dyna.actor.shape.rot.z = 0; + this->dyna.actor.world.rot.z = 0; + this->timer = 0; + Actor_UpdateBgCheckInfo(play, thisx, 0.0f, 0.0f, 0.0f, 4); + ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawSquare, 0.0f); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(play, &this->dyna, &object_raillift_Colheader_0048D0); + this->targetSpeedXZ = thisx->home.rot.z * 0.1f; + if (this->targetSpeedXZ < 0.0f) { + this->targetSpeedXZ = -this->targetSpeedXZ; + } + this->dyna.actor.home.rot.x = 0; + this->dyna.actor.home.rot.y = 0; + this->dyna.actor.home.rot.z = 0; -extern UNK_TYPE D_060048D0; -extern UNK_TYPE D_060071B8; + path = &play->setupPathList[OBJLUPYGAMELIFT_GET_PATH(thisx)]; + this->pointIndex = OBJLUPYGAMELIFT_GET_7(thisx); + this->count = path->count; + if (this->pointIndex >= this->count) { + this->pointIndex = 0; + } + this->points = Lib_SegmentedToVirtual(path->points); + Actor_SpawnAsChild(&play->actorCtx, &this->dyna.actor, play, ACTOR_OBJ_ETCETERA, this->dyna.actor.world.pos.x, + this->dyna.actor.world.pos.y, this->dyna.actor.world.pos.z, this->dyna.actor.shape.rot.x, + this->dyna.actor.shape.rot.y, this->dyna.actor.shape.rot.z, 0); + if (OBJLUPYGAMELIFT_GET_C(thisx) != 0) { + params = 1; + } else { + params = 0; + } + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_GAMELUPY, this->dyna.actor.home.pos.x, this->dyna.actor.home.pos.y, + this->dyna.actor.home.pos.z, 0, 0, 0, params); + func_80AF04BC(this); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/ObjLupygamelift_Init.s") +void ObjLupygamelift_Destroy(Actor* thisx, PlayState* play) { + ObjLupygamelift* this = THIS; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/ObjLupygamelift_Destroy.s") + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/func_80AF0394.s") +void func_80AF0394(ObjLupygamelift* this) { + static f32 D_80AF0750 = 100.0f; + static f32 D_80AF0754 = 255.0f; + static f32 D_80AF0758 = 5.0f; + static f32 D_80AF075C = 10.0f; + static f32 D_80AF0760 = -240.0f; + static f32 D_80AF0764 = 30.0f; + f32 new_var = D_80AF0754 - D_80AF0750; + f32 new_var2 = D_80AF0764 - D_80AF0760; + f32 new_var3 = D_80AF075C - D_80AF0758; + f32 temp_fa0; + f32 phi_fa1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/func_80AF04BC.s") + temp_fa0 = this->dyna.actor.world.pos.y - D_80AF0760; + if (temp_fa0 < 0.0f) { + phi_fa1 = 0.0f; + } else if (new_var2 < temp_fa0) { + phi_fa1 = 1.0f; + } else { + phi_fa1 = temp_fa0 / new_var2; + } + this->dyna.actor.shape.shadowAlpha = D_80AF0754 - (phi_fa1 * new_var); + this->dyna.actor.shape.shadowScale = D_80AF075C - (phi_fa1 * new_var3); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/func_80AF04D8.s") +void func_80AF04BC(ObjLupygamelift* this) { + this->timer = 5; + this->actionFunc = func_80AF04D8; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/func_80AF0514.s") +void func_80AF04D8(ObjLupygamelift* this, PlayState* play) { + if (this->timer == 0) { + func_80AF0514(this); + } else { + this->timer--; + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/func_80AF0530.s") +void func_80AF0514(ObjLupygamelift* this) { + this->actionFunc = func_80AF0530; + this->dyna.actor.speedXZ = this->targetSpeedXZ; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/ObjLupygamelift_Update.s") +void func_80AF0530(ObjLupygamelift* this, PlayState* play) { + f32 step; + Vec3f target; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Lupygamelift/ObjLupygamelift_Draw.s") + target.x = this->points[this->pointIndex].x; + target.y = this->points[this->pointIndex].y; + target.z = this->points[this->pointIndex].z; + step = Math_Vec3f_StepTo(&this->dyna.actor.world.pos, &target, this->dyna.actor.speedXZ); + if (step > 30.0f) { + Math_SmoothStepToF(&this->dyna.actor.speedXZ, this->targetSpeedXZ, 0.5f, 5.0f, 0.1f); + } else if (step > 0.0f) { + Math_SmoothStepToF(&this->dyna.actor.speedXZ, 5.0f, 0.5f, 5.0f, 1.0f); + } else { + if (this->pointIndex < (this->count - 1)) { + this->pointIndex++; + } else { + this->pointIndex = 0; + } + } + if (this->dyna.actor.child->update == NULL) { + this->dyna.actor.child = NULL; + } else { + this->dyna.actor.child->world.pos.x = this->dyna.actor.world.pos.x; + this->dyna.actor.child->world.pos.y = this->dyna.actor.world.pos.y; + this->dyna.actor.child->world.pos.z = this->dyna.actor.world.pos.z; + } + func_80AF0394(this); +} + +void ObjLupygamelift_Update(Actor* thisx, PlayState* play) { + ObjLupygamelift* this = THIS; + + this->actionFunc(this, play); +} + +void ObjLupygamelift_Draw(Actor* thisx, PlayState* play) { + Gfx_DrawDListOpa(play, object_raillift_DL_0071B8); +} diff --git a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.h b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.h index 95232485ac..e2abd8be53 100644 --- a/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.h +++ b/src/overlays/actors/ovl_Obj_Lupygamelift/z_obj_lupygamelift.h @@ -3,16 +3,23 @@ #include "global.h" +#define OBJLUPYGAMELIFT_GET_PATH(thisx) ((thisx)->params & 0x7F) +#define OBJLUPYGAMELIFT_GET_7(thisx) (((thisx)->params >> 7) & 0x1F) +#define OBJLUPYGAMELIFT_GET_C(thisx) (((thisx)->params >> 0xC) & 1) + struct ObjLupygamelift; typedef void (*ObjLupygameliftActionFunc)(struct ObjLupygamelift*, PlayState*); typedef struct ObjLupygamelift { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; - /* 0x015C */ ObjLupygameliftActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x14]; -} ObjLupygamelift; // size = 0x174 + /* 0x000 */ DynaPolyActor dyna; + /* 0x15C */ ObjLupygameliftActionFunc actionFunc; + /* 0x160 */ f32 targetSpeedXZ; + /* 0x164 */ s32 count; + /* 0x168 */ s32 pointIndex; + /* 0x16C */ Vec3s* points; + /* 0x170 */ s16 timer; +} ObjLupygamelift; /* size = 0x174 */ extern const ActorInit Obj_Lupygamelift_InitVars; diff --git a/undefined_syms.txt b/undefined_syms.txt index fbdce5265e..d1c877b2f3 100644 --- a/undefined_syms.txt +++ b/undefined_syms.txt @@ -1520,11 +1520,6 @@ D_06000BA0 = 0x06000BA0; D_06000D10 = 0x06000D10; D_06000F00 = 0x06000F00; -// ovl_Obj_Lupygamelift - -D_060048D0 = 0x060048D0; -D_060071B8 = 0x060071B8; - // ovl_Obj_Mine D_06000030 = 0x06000030;