mirror of
https://github.com/zeldaret/mm.git
synced 2024-11-23 04:49:45 +00:00
Danpei movebg (#1429)
* Bg_Danpei_Movebg OK * Cleanup * PR comments * Couple small things * Address the nit * Flags --------- Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
This commit is contained in:
parent
dd73e644cf
commit
e6a69dfb2b
3
spec
3
spec
@ -3445,8 +3445,7 @@ beginseg
|
||||
name "ovl_Bg_Danpei_Movebg"
|
||||
compress
|
||||
include "$(BUILD_DIR)/src/overlays/actors/ovl_Bg_Danpei_Movebg/z_bg_danpei_movebg.o"
|
||||
include "$(BUILD_DIR)/data/ovl_Bg_Danpei_Movebg/ovl_Bg_Danpei_Movebg.data.o"
|
||||
include "$(BUILD_DIR)/data/ovl_Bg_Danpei_Movebg/ovl_Bg_Danpei_Movebg.reloc.o"
|
||||
include "$(BUILD_DIR)/src/overlays/actors/ovl_Bg_Danpei_Movebg/ovl_Bg_Danpei_Movebg_reloc.o"
|
||||
endseg
|
||||
|
||||
beginseg
|
||||
|
@ -6,15 +6,29 @@
|
||||
|
||||
#include "z_bg_danpei_movebg.h"
|
||||
|
||||
#include "objects/object_d_lift/object_d_lift.h"
|
||||
|
||||
#define FLAGS (ACTOR_FLAG_10)
|
||||
|
||||
#define THIS ((BgDanpeiMovebg*)thisx)
|
||||
|
||||
#define DANPEI_MOVEBG_FLAG_4 (1 << 2)
|
||||
#define DANPEI_MOVEBG_FLAG_8 (1 << 3)
|
||||
#define DANPEI_MOVEBG_FLAG_10 (1 << 4)
|
||||
|
||||
void BgDanpeiMovebg_Init(Actor* thisx, PlayState* play);
|
||||
void BgDanpeiMovebg_Destroy(Actor* thisx, PlayState* play);
|
||||
void BgDanpeiMovebg_Update(Actor* thisx, PlayState* play);
|
||||
|
||||
#if 0
|
||||
void func_80AF6EA8(BgDanpeiMovebg* this, PlayState* play);
|
||||
void func_80AF70FC(BgDanpeiMovebg* this, PlayState* play);
|
||||
void func_80AF74CC(Actor* thisx, PlayState* play);
|
||||
u16 func_80AF705C(BgDanpeiMovebg* this, u16 flags);
|
||||
void func_80AF71FC(BgDanpeiMovebg* this, PlayState* play);
|
||||
void func_80AF72F8(BgDanpeiMovebg* this, PlayState* play);
|
||||
void func_80AF7354(BgDanpeiMovebg* this, PlayState* play);
|
||||
void func_80AF746C(BgDanpeiMovebg* this, PlayState* play);
|
||||
|
||||
ActorInit Bg_Danpei_Movebg_InitVars = {
|
||||
/**/ ACTOR_BG_DANPEI_MOVEBG,
|
||||
/**/ ACTORCAT_BG,
|
||||
@ -27,38 +41,190 @@ ActorInit Bg_Danpei_Movebg_InitVars = {
|
||||
/**/ NULL,
|
||||
};
|
||||
|
||||
// static InitChainEntry sInitChain[] = {
|
||||
static InitChainEntry D_80AF753C[] = {
|
||||
static u16 D_80AF7530[] = { OBJECT_D_LIFT, OBJECT_DANPEI_OBJECT };
|
||||
|
||||
static Gfx* D_80AF7534[] = { gDampeGraveBrownElevatorDL };
|
||||
|
||||
static CollisionHeader* D_80AF7538[] = { &gDampeGraveBrownElevatorCol };
|
||||
|
||||
static InitChainEntry sInitChain[] = {
|
||||
ICHAIN_F32(uncullZoneScale, 1500, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneDownward, 1100, ICHAIN_CONTINUE),
|
||||
ICHAIN_F32(uncullZoneForward, 1000, ICHAIN_CONTINUE),
|
||||
ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
#endif
|
||||
s32 func_80AF6DE0(PlayState* this, ActorPathing* actorPathing) {
|
||||
Actor* actor = actorPathing->actor;
|
||||
s32 ret = false;
|
||||
|
||||
extern InitChainEntry D_80AF753C[];
|
||||
if (actorPathing->distSqToCurPoint < SQ(actor->speed)) {
|
||||
ret = true;
|
||||
} else {
|
||||
actor->world.rot.x = actorPathing->rotToCurPoint.x;
|
||||
actor->world.rot.y = actorPathing->rotToCurPoint.y;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF6DE0.s")
|
||||
void BgDanpeiMovebg_Init(Actor* thisx, PlayState* play) {
|
||||
BgDanpeiMovebg* this = THIS;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/BgDanpeiMovebg_Init.s")
|
||||
DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS);
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF6EA8.s")
|
||||
this->objectSlot = SubS_GetObjectSlot(D_80AF7530[BGDANPEIMOVEBG_GET_TYPE(thisx)], play);
|
||||
if (this->objectSlot <= OBJECT_SLOT_NONE) {
|
||||
Actor_Kill(&this->dyna.actor);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/BgDanpeiMovebg_Destroy.s")
|
||||
this->actionFunc = func_80AF6EA8;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/BgDanpeiMovebg_Update.s")
|
||||
void func_80AF6EA8(BgDanpeiMovebg* this, PlayState* play) {
|
||||
Actor* thisx = &this->dyna.actor;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF705C.s")
|
||||
if (SubS_IsObjectLoaded(this->objectSlot, play)) {
|
||||
gSegments[6] = OS_K0_TO_PHYSICAL(play->objectCtx.slots[this->objectSlot].segment);
|
||||
this->dyna.actor.objectSlot = this->objectSlot;
|
||||
this->dyna.actor.draw = func_80AF74CC;
|
||||
Actor_ProcessInitChain(thisx, sInitChain);
|
||||
DynaPolyActor_LoadMesh(play, &this->dyna, D_80AF7538[BGDANPEIMOVEBG_GET_TYPE(thisx)]);
|
||||
this->dList = D_80AF7534[BGDANPEIMOVEBG_GET_TYPE(thisx)];
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF70FC.s")
|
||||
if (BGDANPEIMOVEBG_GET_TYPE(thisx) == 0) {
|
||||
this->dyna.actor.gravity = 0.0f;
|
||||
this->dyna.actor.speed = 1.0f;
|
||||
SubS_ActorPathing_Init(play, &thisx->world.pos, thisx, &this->actorPath, play->setupPathList,
|
||||
BGDANPEIMOVEBG_GET_PATH_INDEX(thisx), 0, 0, 0, 0);
|
||||
this->actionFunc = func_80AF70FC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF71FC.s")
|
||||
void BgDanpeiMovebg_Destroy(Actor* thisx, PlayState* play) {
|
||||
BgDanpeiMovebg* this = THIS;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF72F8.s")
|
||||
DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF7354.s")
|
||||
void BgDanpeiMovebg_Update(Actor* thisx, PlayState* play) {
|
||||
BgDanpeiMovebg* this = THIS;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF746C.s")
|
||||
this->actionFunc(this, play);
|
||||
this->prevFlags = this->flags;
|
||||
this->flags &= ~DANPEI_MOVEBG_FLAG_1;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Bg_Danpei_Movebg/func_80AF74CC.s")
|
||||
u16 func_80AF705C(BgDanpeiMovebg* this, u16 flags) {
|
||||
u16 newFlags = flags & ~(DANPEI_MOVEBG_FLAG_4 | DANPEI_MOVEBG_FLAG_8 | DANPEI_MOVEBG_FLAG_10);
|
||||
|
||||
if (DynaPolyActor_IsActorOnTop(&this->dyna) && (this->flags & DANPEI_MOVEBG_FLAG_1)) {
|
||||
newFlags |= DANPEI_MOVEBG_FLAG_4;
|
||||
}
|
||||
if (DynaPolyActor_IsPlayerOnTop(&this->dyna)) {
|
||||
if (gSaveContext.save.playerForm == PLAYER_FORM_DEKU) {
|
||||
newFlags |= DANPEI_MOVEBG_FLAG_8;
|
||||
} else {
|
||||
newFlags |= DANPEI_MOVEBG_FLAG_10;
|
||||
}
|
||||
}
|
||||
return newFlags;
|
||||
}
|
||||
|
||||
void func_80AF70FC(BgDanpeiMovebg* this, PlayState* play) {
|
||||
this->flags = func_80AF705C(this, this->flags);
|
||||
if (this->flags & (DANPEI_MOVEBG_FLAG_4 | DANPEI_MOVEBG_FLAG_8)) {
|
||||
if (this->flags & DANPEI_MOVEBG_FLAG_4) {
|
||||
this->flags |= DANPEI_MOVEBG_FLAG_2;
|
||||
}
|
||||
this->actionFunc = func_80AF71FC;
|
||||
} else if (this->flags & DANPEI_MOVEBG_FLAG_10) {
|
||||
if (!(this->prevFlags & DANPEI_MOVEBG_FLAG_10)) {
|
||||
Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_SINK_WOOD_FLOOR);
|
||||
}
|
||||
Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y - 8.0f, 1.0f, 2.0f, 0.01f);
|
||||
} else {
|
||||
if (this->prevFlags & DANPEI_MOVEBG_FLAG_10) {
|
||||
Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_REBOUND_WOOD_FLOOR);
|
||||
}
|
||||
Math_SmoothStepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 1.0f, 2.0f, 0.01f);
|
||||
}
|
||||
}
|
||||
|
||||
void func_80AF71FC(BgDanpeiMovebg* this, PlayState* play) {
|
||||
SubS_ActorPathing_Update(play, &this->actorPath, SubS_ActorPathing_ComputePointInfo, func_80AF6DE0,
|
||||
SubS_ActorPathing_MoveWithoutGravityReverse, SubS_ActorPathing_SetNextPoint);
|
||||
Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_PLATE_LIFT_LEVEL - SFX_FLAG);
|
||||
|
||||
if (this->actorPath.flags & ACTOR_PATHING_REACHED_END_TEMPORARY) {
|
||||
if (this->flags & DANPEI_MOVEBG_FLAG_2) {
|
||||
this->flags &= ~DANPEI_MOVEBG_FLAG_2;
|
||||
}
|
||||
this->actionFunc = func_80AF72F8;
|
||||
} else {
|
||||
this->flags = func_80AF705C(this, this->flags);
|
||||
if ((this->flags & DANPEI_MOVEBG_FLAG_10) ||
|
||||
CHECK_FLAG_ALL(this->flags, DANPEI_MOVEBG_FLAG_4 | DANPEI_MOVEBG_FLAG_8)) {
|
||||
this->actionFunc = func_80AF746C;
|
||||
} else if (!(this->flags & (DANPEI_MOVEBG_FLAG_4 | DANPEI_MOVEBG_FLAG_8 | DANPEI_MOVEBG_FLAG_10))) {
|
||||
this->actorPath.flags |= ACTOR_PATHING_MOVE_BACKWARDS;
|
||||
this->dyna.actor.speed = 2.0f;
|
||||
this->actionFunc = func_80AF7354;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void func_80AF72F8(BgDanpeiMovebg* this, PlayState* play) {
|
||||
this->flags = func_80AF705C(this, this->flags);
|
||||
if (!(this->flags & (DANPEI_MOVEBG_FLAG_4 | DANPEI_MOVEBG_FLAG_8 | DANPEI_MOVEBG_FLAG_10))) {
|
||||
this->actorPath.flags |= ACTOR_PATHING_MOVE_BACKWARDS;
|
||||
this->dyna.actor.speed = 2.0f;
|
||||
this->actionFunc = func_80AF7354;
|
||||
}
|
||||
}
|
||||
|
||||
void func_80AF7354(BgDanpeiMovebg* this, PlayState* play) {
|
||||
Actor_PlaySfx_Flagged(&this->dyna.actor, NA_SE_EV_PLATE_LIFT_LEVEL - SFX_FLAG);
|
||||
this->flags = func_80AF705C(this, this->flags);
|
||||
SubS_ActorPathing_Update(play, &this->actorPath, SubS_ActorPathing_ComputePointInfo, func_80AF6DE0,
|
||||
SubS_ActorPathing_MoveWithoutGravityReverse, SubS_ActorPathing_SetNextPoint);
|
||||
|
||||
if ((this->flags & DANPEI_MOVEBG_FLAG_10) ||
|
||||
CHECK_FLAG_ALL(this->flags, DANPEI_MOVEBG_FLAG_4 | DANPEI_MOVEBG_FLAG_8)) {
|
||||
this->actionFunc = func_80AF746C;
|
||||
} else if ((this->flags & (DANPEI_MOVEBG_FLAG_4 | DANPEI_MOVEBG_FLAG_8)) &&
|
||||
!CHECK_FLAG_ALL(this->flags, DANPEI_MOVEBG_FLAG_4 | DANPEI_MOVEBG_FLAG_8)) {
|
||||
this->actorPath.flags &= ~ACTOR_PATHING_MOVE_BACKWARDS;
|
||||
this->dyna.actor.speed = 1.0f;
|
||||
if (this->flags & DANPEI_MOVEBG_FLAG_4) {
|
||||
this->flags |= DANPEI_MOVEBG_FLAG_2;
|
||||
}
|
||||
this->actionFunc = func_80AF71FC;
|
||||
}
|
||||
|
||||
if (this->actorPath.flags & ACTOR_PATHING_REACHED_END_TEMPORARY) {
|
||||
this->actorPath.flags &= ~ACTOR_PATHING_MOVE_BACKWARDS;
|
||||
this->flags &= ~DANPEI_MOVEBG_FLAG_2;
|
||||
this->dyna.actor.speed = 1.0f;
|
||||
this->actionFunc = func_80AF70FC;
|
||||
}
|
||||
}
|
||||
|
||||
void func_80AF746C(BgDanpeiMovebg* this, PlayState* play) {
|
||||
this->flags = func_80AF705C(this, this->flags);
|
||||
if (!(this->flags & (DANPEI_MOVEBG_FLAG_8 | DANPEI_MOVEBG_FLAG_10))) {
|
||||
if (this->actorPath.flags & ACTOR_PATHING_MOVE_BACKWARDS) {
|
||||
this->actionFunc = func_80AF7354;
|
||||
} else {
|
||||
this->actionFunc = func_80AF71FC;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void func_80AF74CC(Actor* thisx, PlayState* play) {
|
||||
BgDanpeiMovebg* this = THIS;
|
||||
|
||||
if (this->dList != NULL) {
|
||||
Gfx_DrawDListOpa(play, this->dList);
|
||||
}
|
||||
}
|
||||
|
@ -7,12 +7,20 @@ struct BgDanpeiMovebg;
|
||||
|
||||
typedef void (*BgDanpeiMovebgActionFunc)(struct BgDanpeiMovebg*, PlayState*);
|
||||
|
||||
#define BGDANPEIMOVEBG_GET_PATH_INDEX(thisx) ((thisx)->params & 0x7F)
|
||||
#define BGDANPEIMOVEBG_GET_TYPE(thisx) (((thisx)->params >> 0xE) & 3)
|
||||
|
||||
#define DANPEI_MOVEBG_FLAG_1 (1 << 0)
|
||||
#define DANPEI_MOVEBG_FLAG_2 (1 << 1)
|
||||
|
||||
typedef struct BgDanpeiMovebg {
|
||||
/* 0x000 */ DynaPolyActor dyna;
|
||||
/* 0x15C */ BgDanpeiMovebgActionFunc actionFunc;
|
||||
/* 0x160 */ char unk_160[0x6C];
|
||||
/* 0x1CC */ u16 unk_1CC;
|
||||
/* 0x1CE */ char unk_1CE[0xA];
|
||||
/* 0x160 */ ActorPathing actorPath;
|
||||
/* 0x1CC */ u16 flags;
|
||||
/* 0x1CE */ u16 prevFlags;
|
||||
/* 0x1D0 */ Gfx* dList;
|
||||
/* 0x1D4 */ s8 objectSlot;
|
||||
} BgDanpeiMovebg; // size = 0x1D8
|
||||
|
||||
#endif // Z_BG_DANPEI_MOVEBG_H
|
||||
|
@ -1293,8 +1293,8 @@ void EnTk_Update(Actor* thisx, PlayState* play) {
|
||||
|
||||
if (platform != NULL) {
|
||||
if (platform->dyna.actor.id == ACTOR_BG_DANPEI_MOVEBG) {
|
||||
platform->unk_1CC |= 1;
|
||||
if (platform->unk_1CC & 2) {
|
||||
platform->flags |= DANPEI_MOVEBG_FLAG_1;
|
||||
if (platform->flags & DANPEI_MOVEBG_FLAG_2) {
|
||||
this->unk_2CA |= 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user