diff --git a/include/functions.h b/include/functions.h index 028b0dc488..33f1843e6c 100644 --- a/include/functions.h +++ b/include/functions.h @@ -863,8 +863,8 @@ Actor* Actor_RemoveFromTypeList(GlobalContext* globalCtx, ActorContext* actorCtx void Actor_FreeOverlay(ActorOverlay* entry); Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s16 sParm10); ActorInit* Actor_LoadOverlay(ActorContext* actorCtx, s16 index); -Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s16 variable, u32 cutscene, s32 param_12, Actor* parent); -Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s16 variable); +Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s32 variable, u32 cutscene, s32 param_12, Actor* parent); +Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z, s16 rotX, s16 rotY, s16 rotZ, s32 variable); void Actor_SpawnTransitionActors(GlobalContext* globalCtx, ActorContext* actorCtx); void func_800BB2D0(ActorContext* actorCtx, u16* param_2, GlobalContext* globalCtx); Actor* func_800BB498(ActorContext* actorCtx, Actor* actor, GlobalContext* globalCtx); diff --git a/spec b/spec index 2bb275eb5c..e4eee76b04 100644 --- a/spec +++ b/spec @@ -1819,8 +1819,7 @@ beginseg name "ovl_Obj_Makeoshihiki" compress include "build/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.o" - include "build/data/ovl_Obj_Makeoshihiki/ovl_Obj_Makeoshihiki.data.o" - include "build/data/ovl_Obj_Makeoshihiki/ovl_Obj_Makeoshihiki.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Makeoshihiki/ovl_Obj_Makeoshihiki_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c index 7bb2d14716..a704f2773c 100644 --- a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c +++ b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.c @@ -1,3 +1,9 @@ +/* + * File: z_obj_makeoshihiki.c + * Overlay: ovl_Obj_Makeoshihiki + * Description: Pushable Block Switch Flags Handler + */ + #include "z_obj_makeoshihiki.h" #define FLAGS 0x00000010 @@ -7,7 +13,6 @@ void ObjMakeoshihiki_Init(Actor* thisx, GlobalContext* globalCtx); void ObjMakeoshihiki_Update(Actor* thisx, GlobalContext* globalCtx); -#if 0 const ActorInit Obj_Makeoshihiki_InitVars = { ACTOR_OBJ_MAKEOSHIHIKI, ACTORCAT_PROP, @@ -20,12 +25,71 @@ const ActorInit Obj_Makeoshihiki_InitVars = { (ActorFunc)NULL, }; -#endif +s32 ObjMakeoshihiki_GetChildSpawnPointIndex(ObjMakeoshihiki* this, GlobalContext* globalCtx) { + s32 pad; + s32 pathIndexOffset1 = Flags_GetSwitch(globalCtx, OBJMAKEOSHIHIKI_GET_SWITCHFLAG_1(this)) ? 1 : 0; + s32 pathIndexOffset2 = Flags_GetSwitch(globalCtx, OBJMAKEOSHIHIKI_GET_SWITCHFLAG_2(this)) ? 2 : 0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Makeoshihiki/func_80972350.s") + return pathIndexOffset1 + pathIndexOffset2; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Makeoshihiki/func_809723C4.s") +void ObjMakeoshihiki_SetSwitchFlags(ObjMakeoshihiki* this, GlobalContext* globalCtx, s32 pathIndex) { + s32 pad; + s32 pad2; + s32 switchFlag1; + s32 switchFlag2; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Makeoshihiki/ObjMakeoshihiki_Init.s") + switchFlag2 = OBJMAKEOSHIHIKI_GET_SWITCHFLAG_2(this); + switchFlag1 = OBJMAKEOSHIHIKI_GET_SWITCHFLAG_1(this); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Makeoshihiki/ObjMakeoshihiki_Update.s") + if (pathIndex & 2) { + Actor_SetSwitchFlag(globalCtx, switchFlag2); + } else { + Actor_UnsetSwitchFlag(globalCtx, switchFlag2); + } + + if (pathIndex & 1) { + Actor_SetSwitchFlag(globalCtx, switchFlag1); + } else { + Actor_UnsetSwitchFlag(globalCtx, switchFlag1); + } +} + +void ObjMakeoshihiki_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjMakeoshihiki* this = THIS; + Vec3s* childPoint; + Path* path; + s32 childPointIndex; + + path = &globalCtx->setupPathList[OBJMAKEOSHIHIKI_GET_PATHLISTINDEX(this)]; + this->pathPoints = Lib_SegmentedToVirtual(path->points); + this->pathCount = path->count; + childPointIndex = ObjMakeoshihiki_GetChildSpawnPointIndex(this, globalCtx); + childPoint = &this->pathPoints[childPointIndex]; + if (Actor_SpawnAsChild(&globalCtx->actorCtx, &this->actor, globalCtx, ACTOR_OBJ_OSHIHIKI, childPoint->x, + childPoint->y, childPoint->z, 0, 0, 0, 0xFFF1) == NULL) { + Actor_MarkForDeath(&this->actor); + } +} + +void ObjMakeoshihiki_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjMakeoshihiki* this = THIS; + Actor* child; + s32 loopPathIndex; + Vec3f pathPointF; + + child = this->actor.child; + if (child != NULL) { + if (child->update == NULL) { + this->actor.child = NULL; + } else { + for (loopPathIndex = 0; loopPathIndex < this->pathCount; loopPathIndex++) { + Math_Vec3s_ToVec3f(&pathPointF, &this->pathPoints[loopPathIndex]); + if (Math3D_DistanceSquared(&this->actor.child->world.pos, &pathPointF) < SQ(0.5f)) { + ObjMakeoshihiki_SetSwitchFlags(this, globalCtx, loopPathIndex); + return; + } + } + } + } +} diff --git a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.h b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.h index 1bb0c98bb5..708da99d64 100644 --- a/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.h +++ b/src/overlays/actors/ovl_Obj_Makeoshihiki/z_obj_makeoshihiki.h @@ -5,9 +5,14 @@ struct ObjMakeoshihiki; +#define OBJMAKEOSHIHIKI_GET_PATHLISTINDEX(this) (((this)->actor.params >> 7) & 0x7F) +#define OBJMAKEOSHIHIKI_GET_SWITCHFLAG_1(this) ((this)->actor.home.rot.z & 0x7F) +#define OBJMAKEOSHIHIKI_GET_SWITCHFLAG_2(this) ((this)->actor.params & 0x7F) + typedef struct ObjMakeoshihiki { /* 0x000 */ Actor actor; - /* 0x144 */ char unk_144[0x8]; + /* 0x144 */ Vec3s* pathPoints; + /* 0x148 */ s32 pathCount; } ObjMakeoshihiki; // size = 0x14C extern const ActorInit Obj_Makeoshihiki_InitVars; diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 465d7dbbc8..524e2fd8ce 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -8054,8 +8054,8 @@ 0x80971B48:("EnKakasi_Update",), 0x80971CE0:("func_80971CE0",), 0x80971D20:("EnKakasi_Draw",), - 0x80972350:("func_80972350",), - 0x809723C4:("func_809723C4",), + 0x80972350:("ObjMakeoshihiki_GetChildSpawnPointIndex",), + 0x809723C4:("ObjMakeoshihiki_SetSwitchFlags",), 0x80972454:("ObjMakeoshihiki_Init",), 0x80972548:("ObjMakeoshihiki_Update",), 0x80972680:("OceffSpot_SetupAction",),