mirror of
https://github.com/zeldaret/oot.git
synced 2025-08-06 06:10:21 +00:00
En_Stream (vortex) 7/8 matching, 1 equivalent (#512)
* EnStream_Init OK * func_80B0B7A0 OK * EnStream_Destroy OK * EnStream_Update OK * Make func_80B0B7A0 take this instead of thisx like other SetupActions * func_80B0BAC8 OK * func_80B0B934 OK * func_80B0B81C not OK, but very close and I give up * EnStream_Draw OK * Delete unused ASM and do a little cleanup * Provide better names for functions * Make the file buildable when NONMATCHING is used * Flip comparisons in EnStream_SuckPlayer as per review * NONMATCHING -> NON_MATCHING * Remove & for function pointers * Type D_06000950 and remove the & in Draw * Remove unnecessary "struct" * Remove unnecessary forward declaration * Make func_80B0B81C take Vec3f*, not PosRot* * Use the generated reloc when NON_MATCHING * Move func_80B0B81C forward declare to the else block
This commit is contained in:
parent
f05a584dea
commit
3062045acd
11 changed files with 118 additions and 325 deletions
|
@ -14,10 +14,10 @@ void EnStream_Init(Actor* thisx, GlobalContext* globalCtx);
|
|||
void EnStream_Destroy(Actor* thisx, GlobalContext* globalCtx);
|
||||
void EnStream_Update(Actor* thisx, GlobalContext* globalCtx);
|
||||
void EnStream_Draw(Actor* thisx, GlobalContext* globalCtx);
|
||||
void EnStream_WaitForPlayer(EnStream* this, GlobalContext* globalCtx);
|
||||
|
||||
extern UNK_TYPE D_06000950;
|
||||
extern Gfx D_06000950[];
|
||||
|
||||
/*
|
||||
const ActorInit En_Stream_InitVars = {
|
||||
ACTOR_EN_STREAM,
|
||||
ACTORTYPE_BG,
|
||||
|
@ -29,19 +29,118 @@ const ActorInit En_Stream_InitVars = {
|
|||
(ActorFunc)EnStream_Update,
|
||||
(ActorFunc)EnStream_Draw,
|
||||
};
|
||||
*/
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Stream/func_80B0B7A0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Stream/EnStream_Init.s")
|
||||
static InitChainEntry sInitChain[] = {
|
||||
ICHAIN_VEC3F_DIV1000(scale, 20, ICHAIN_STOP),
|
||||
};
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Stream/EnStream_Destroy.s")
|
||||
void EnStream_SetupAction(EnStream* this, EnStreamActionFunc actionFunc) {
|
||||
this->actionFunc = actionFunc;
|
||||
}
|
||||
|
||||
void EnStream_Init(Actor* thisx, GlobalContext* globalCtx) {
|
||||
EnStream* this = THIS;
|
||||
|
||||
this->unk_150 = thisx->params & 0xFF;
|
||||
Actor_ProcessInitChain(thisx, sInitChain);
|
||||
if ((this->unk_150 != 0) && (this->unk_150 == 1)) {
|
||||
thisx->scale.y = 0.01f;
|
||||
}
|
||||
EnStream_SetupAction(this, EnStream_WaitForPlayer);
|
||||
}
|
||||
|
||||
void EnStream_Destroy(Actor* thisx, GlobalContext* globalCtx) {
|
||||
}
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
// regalloc differences, checks if the player is range of the vortex
|
||||
s32 func_80B0B81C(Vec3f* vortexPosRot, Vec3f* playerPosRot, Vec3f* posDifference, f32 vortexYScale) {
|
||||
s32 ret = 0;
|
||||
f32 smallConstant = 28;
|
||||
f32 lowerBounds = 0 * vortexYScale * 50;
|
||||
f32 upperBounds = 160 * vortexYScale * 50;
|
||||
f32 xzDist;
|
||||
|
||||
posDifference->x = playerPosRot->x - vortexPosRot->x;
|
||||
posDifference->y = playerPosRot->y - vortexPosRot->y;
|
||||
posDifference->z = playerPosRot->z - vortexPosRot->z;
|
||||
xzDist = sqrtf(SQ(posDifference->x) + SQ(posDifference->z));
|
||||
if (lowerBounds <= posDifference->y && posDifference->y <= upperBounds) {
|
||||
posDifference->y = posDifference->y - lowerBounds;
|
||||
if (xzDist <= (((75 - smallConstant) * (posDifference->y / (upperBounds - lowerBounds))) + 28)) {
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
if ((posDifference->y <= lowerBounds) && (xzDist <= 28)) {
|
||||
ret = 2;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
s32 func_80B0B81C(Vec3f* vortexPos, Vec3f* playerPos, Vec3f* posDifference, f32 vortexYScale);
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Stream/func_80B0B81C.s")
|
||||
#endif
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Stream/func_80B0B934.s")
|
||||
void EnStream_SuckPlayer(EnStream* this, GlobalContext* globalCtx) {
|
||||
Player* player = PLAYER;
|
||||
s32 pad48;
|
||||
Vec3f posDifference;
|
||||
f32 xzDist;
|
||||
f32 yDistWithOffset;
|
||||
s32 pad30;
|
||||
s32 pad2C;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Stream/func_80B0BAC8.s")
|
||||
if (func_80B0B81C(&this->actor.posRot.pos, &player->actor.posRot.pos, &posDifference, this->actor.scale.y) != 0) {
|
||||
xzDist = sqrtf(SQ(posDifference.x) + SQ(posDifference.z));
|
||||
yDistWithOffset = player->actor.posRot.pos.y - (this->actor.posRot.pos.y - 90.0f);
|
||||
player->windDirection = Math_atan2f(-posDifference.x, -posDifference.z) * 10430.378f;
|
||||
if (xzDist > 3.0f) {
|
||||
Math_SmoothScaleMaxMinF(&player->windSpeed, 3.0f, 0.5f, xzDist, 0.0f);
|
||||
} else {
|
||||
player->windSpeed = 0.0f;
|
||||
Math_SmoothScaleMaxMinF(&player->actor.posRot.pos.x, this->actor.posRot.pos.x, 0.5f, 3.0f, 0.0f);
|
||||
Math_SmoothScaleMaxMinF(&player->actor.posRot.pos.z, this->actor.posRot.pos.z, 0.5f, 3.0f, 0.0f);
|
||||
}
|
||||
if (yDistWithOffset > 0.0f) {
|
||||
Math_SmoothScaleMaxMinF(&player->actor.velocity.y, -3.0f, 0.7f, yDistWithOffset, 0.0f);
|
||||
if (posDifference.y < -70.0f) {
|
||||
player->stateFlags2 |= 0x80000000;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
EnStream_SetupAction(this, EnStream_WaitForPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Stream/EnStream_Update.s")
|
||||
void EnStream_WaitForPlayer(EnStream* this, GlobalContext* globalCtx) {
|
||||
Player* player = PLAYER;
|
||||
s16 pad;
|
||||
Vec3f temp;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Stream/EnStream_Draw.s")
|
||||
if (func_80B0B81C(&this->actor.posRot.pos, &player->actor.posRot.pos, &temp, this->actor.scale.y) != 0) {
|
||||
EnStream_SetupAction(this, EnStream_SuckPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
void EnStream_Update(Actor* thisx, GlobalContext* globalCtx) {
|
||||
EnStream* this = THIS;
|
||||
|
||||
this->actionFunc(this, globalCtx);
|
||||
func_8002F948(thisx, NA_SE_EV_WHIRLPOOL - SFX_FLAG);
|
||||
}
|
||||
|
||||
void EnStream_Draw(Actor* thisx, GlobalContext* globalCtx) {
|
||||
u32 multipliedFrames;
|
||||
u32 frames = globalCtx->gameplayFrames;
|
||||
|
||||
OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_stream.c", 295);
|
||||
func_80093D84(globalCtx->state.gfxCtx);
|
||||
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_stream.c", 299),
|
||||
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
multipliedFrames = frames * 20;
|
||||
gSPSegment(POLY_XLU_DISP++, 0x08,
|
||||
Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, frames * 30, -multipliedFrames, 0x40, 0x40, 1,
|
||||
multipliedFrames, -multipliedFrames, 0x40, 0x40));
|
||||
gSPDisplayList(POLY_XLU_DISP++, D_06000950);
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_stream.c", 310);
|
||||
}
|
||||
|
|
|
@ -6,9 +6,13 @@
|
|||
|
||||
struct EnStream;
|
||||
|
||||
typedef void (*EnStreamActionFunc)(struct EnStream*, GlobalContext*);
|
||||
|
||||
typedef struct EnStream {
|
||||
/* 0x0000 */ Actor actor;
|
||||
/* 0x014C */ char unk_14C[0xC];
|
||||
/* 0x014C */ EnStreamActionFunc actionFunc;
|
||||
/* 0x0150 */ s32 unk_150;
|
||||
/* 0x0154 */ char unk_154[0x4];
|
||||
} EnStream; // size = 0x0158
|
||||
|
||||
extern const ActorInit En_Stream_InitVars;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue