1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-02-10 14:35:46 +00:00

changes asked by @louist103

Signed-off-by: angie <angheloalf95@gmail.com>
This commit is contained in:
angie 2021-01-30 02:28:19 -03:00
parent ef2f7e5a66
commit 0455594c8d
No known key found for this signature in database
GPG key ID: E5212BA1B6FEA700
2 changed files with 61 additions and 105 deletions

View file

@ -15,8 +15,8 @@ void EffDust_InitPosAndDistance(EffDust* this);
void EffDust_UpdateFunc_8099DB28(EffDust* this, GlobalContext* globalCtx); void EffDust_UpdateFunc_8099DB28(EffDust* this, GlobalContext* globalCtx);
void EffDust_UpdateFunc_8099DD74(EffDust* this, GlobalContext* globalCtx); void EffDust_UpdateFunc_8099DD74(EffDust* this, GlobalContext* globalCtx);
void EffDust_UpdateFunc_8099DFC0(EffDust* this, GlobalContext* globalCtx); void EffDust_UpdateFunc_8099DFC0(EffDust* this, GlobalContext* globalCtx);
void EffDust_DrawFunc_8099E4F4(EffDust* this, GlobalContext* globalCtx); void EffDust_DrawFunc_8099E4F4(Actor* thisx, GlobalContext* globalCtx);
void EffDust_DrawFunc_8099E784(EffDust* this, GlobalContext* globalCtx); void EffDust_DrawFunc_8099E784(Actor* thisx, GlobalContext* globalCtx);
const ActorInit Eff_Dust_InitVars = { const ActorInit Eff_Dust_InitVars = {
ACTOR_EFF_DUST, ACTOR_EFF_DUST,
@ -30,16 +30,18 @@ const ActorInit Eff_Dust_InitVars = {
(ActorFunc)EffDust_Draw, (ActorFunc)EffDust_Draw,
}; };
static Gfx* D_8099EB60[] = { 0xDF000000, 0x00000000, 0x00000000, 0x00000000 }; static Gfx D_8099EB60[] = {
gsSPEndDisplayList(),
};
enum DustEffect { Effect_0 = 0, Effect_1 = 1, Effect_2 = 2, Effect_3 = 3, Effect_4 = 4 }; enum DustEffect { Effect_0 = 0, Effect_1 = 1, Effect_2 = 2, Effect_3 = 3, Effect_4 = 4 };
void EffDust_setUpdateFunc(EffDust* this, EffDustActionFunc callback_updateFunc) { void EffDust_SetupAction(EffDust* this, EffDustActionFunc actionFunc) {
this->updateFunc = callback_updateFunc; this->updateFunc = actionFunc;
} }
void EffDust_setDrawFunc(EffDust* this, EffDustActionFunc callback_drawFunc) { void EffDust_SetupDraw(EffDust* this, EffDustDrawFunc drawFunc) {
this->drawFunc = callback_drawFunc; this->drawFunc = drawFunc;
} }
// Members initializer (?) // Members initializer (?)
@ -53,58 +55,51 @@ void EffDust_InitPosAndDistance(EffDust* this) {
this->distanceTraveled[i] = 1.0f; this->distanceTraveled[i] = 1.0f;
} }
this->index = 0; this->index = 0;
} }
void EffDust_Init(Actor* thisx, GlobalContext* globalCtx) { void EffDust_Init(Actor* thisx, GlobalContext* globalCtx) {
EffDust* this = THIS; EffDust* this = THIS;
enum DustEffect dust_effect; enum DustEffect dust_effect = this->actor.params;
dust_effect = this->actor.params;
EffDust_InitPosAndDistance(this); EffDust_InitPosAndDistance(this);
switch (dust_effect) { switch (dust_effect) {
case Effect_0: case Effect_0:
EffDust_setUpdateFunc(this, EffDust_UpdateFunc_8099DB28); EffDust_SetupAction(this, EffDust_UpdateFunc_8099DB28);
EffDust_setDrawFunc(this, EffDust_DrawFunc_8099E4F4); EffDust_SetupDraw(this, EffDust_DrawFunc_8099E4F4);
this->dy = 0.8f; this->dy = 0.8f;
this->dz = 0.8f; this->dz = 0.8f;
this->dx = 1.0f; this->dx = 1.0f;
this->scalingFactor = 0.1f; this->scalingFactor = 0.1f;
break; break;
case Effect_1: case Effect_1:
EffDust_setUpdateFunc(this, EffDust_UpdateFunc_8099DD74); EffDust_SetupAction(this, EffDust_UpdateFunc_8099DD74);
EffDust_setDrawFunc(this, EffDust_DrawFunc_8099E4F4); EffDust_SetupDraw(this, EffDust_DrawFunc_8099E4F4);
this->dx = 0.8f; this->dx = 0.8f;
this->dz = 0.8f; this->dz = 0.8f;
this->dy = 1.0f; this->dy = 1.0f;
this->scalingFactor = 0.5f; this->scalingFactor = 0.5f;
break; break;
case Effect_2: case Effect_2:
EffDust_setUpdateFunc(this, EffDust_UpdateFunc_8099DFC0); EffDust_SetupAction(this, EffDust_UpdateFunc_8099DFC0);
EffDust_setDrawFunc(this, EffDust_DrawFunc_8099E784); EffDust_SetupDraw(this, EffDust_DrawFunc_8099E784);
this->dx = 0.5f; this->dx = 0.5f;
this->scalingFactor = 15.0f; this->scalingFactor = 15.0f;
break; break;
case Effect_3: case Effect_3:
EffDust_setUpdateFunc(this, EffDust_UpdateFunc_8099DFC0); EffDust_SetupAction(this, EffDust_UpdateFunc_8099DFC0);
EffDust_setDrawFunc(this, EffDust_DrawFunc_8099E784); EffDust_SetupDraw(this, EffDust_DrawFunc_8099E784);
this->dx = 0.5f; this->dx = 0.5f;
this->scalingFactor = 10.0f; this->scalingFactor = 10.0f;
break; break;
case Effect_4: case Effect_4:
EffDust_setUpdateFunc(this, EffDust_UpdateFunc_8099DFC0); EffDust_SetupAction(this, EffDust_UpdateFunc_8099DFC0);
EffDust_setDrawFunc(this, EffDust_DrawFunc_8099E784); EffDust_SetupDraw(this, EffDust_DrawFunc_8099E784);
this->actor.room = -1; this->actor.room = -1;
this->dx = 0.5f; this->dx = 0.5f;
this->scalingFactor = 20.0f; this->scalingFactor = 20.0f;
break; break;
default: default:
SystemArena_FreeDebug(this, "../z_eff_dust.c", 202); SystemArena_FreeDebug(this, "../z_eff_dust.c", 202);
break; break;
@ -119,22 +114,15 @@ void EffDust_Destroy(Actor* thisx, GlobalContext* globalCtx) {
void EffDust_UpdateFunc_8099DB28(EffDust* this, GlobalContext* globalCtx) { void EffDust_UpdateFunc_8099DB28(EffDust* this, GlobalContext* globalCtx) {
s16 theta; s16 theta;
s16 fi; s16 fi;
f32* distanceTraveled = this->distanceTraveled;
f32* distanceTraveled;
s32 i; s32 i;
s32 j; s32 j;
distanceTraveled = this->distanceTraveled;
for (i = 0; i < 0x40; i++) { for (i = 0; i < 0x40; i++) {
if ((*distanceTraveled) < 1.0f) { if ((*distanceTraveled) < 1.0f) {
*distanceTraveled += 0.05f; *distanceTraveled += 0.05f;
} }
distanceTraveled++; distanceTraveled++;
// This won't match.
/*if (this->distanceTraveled[i] < 1.0f) {
this->distanceTraveled[i] += 0.05f;
}*/
} }
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
@ -155,22 +143,15 @@ void EffDust_UpdateFunc_8099DB28(EffDust* this, GlobalContext* globalCtx) {
void EffDust_UpdateFunc_8099DD74(EffDust* this, GlobalContext* globalCtx) { void EffDust_UpdateFunc_8099DD74(EffDust* this, GlobalContext* globalCtx) {
s16 theta; s16 theta;
s16 fi; s16 fi;
f32* distanceTraveled = this->distanceTraveled;
f32* distanceTraveled;
s32 i; s32 i;
s32 j; s32 j;
distanceTraveled = this->distanceTraveled;
for (i = 0; i < 0x40; i++) { for (i = 0; i < 0x40; i++) {
if ((*distanceTraveled) < 1.0f) { if ((*distanceTraveled) < 1.0f) {
*distanceTraveled += 0.03f; *distanceTraveled += 0.03f;
} }
distanceTraveled++; distanceTraveled++;
// This won't match.
/*if (this->distanceTraveled[i] < 1.0f) {
this->distanceTraveled[i] += 0.03f;
}*/
} }
for (j = 0; j < 2; j++) { for (j = 0; j < 2; j++) {
@ -190,20 +171,12 @@ void EffDust_UpdateFunc_8099DD74(EffDust* this, GlobalContext* globalCtx) {
void EffDust_UpdateFunc_8099DFC0(EffDust* this, GlobalContext* globalCtx) { void EffDust_UpdateFunc_8099DFC0(EffDust* this, GlobalContext* globalCtx) {
s16 theta; s16 theta;
Player* player = PLAYER;
Player* player; Actor* parent = this->actor.parent;
Actor* parent; f32* distanceTraveled = this->distanceTraveled;
f32* distanceTraveled;
s32 i; s32 i;
s32 j; s32 j;
player = PLAYER;
parent = this->actor.parent;
distanceTraveled = this->distanceTraveled;
if (parent == NULL || parent->update == NULL || !(player->stateFlags1 & 0x1000)) { if (parent == NULL || parent->update == NULL || !(player->stateFlags1 & 0x1000)) {
if (this->life != 0) { if (this->life != 0) {
this->life -= 1; this->life -= 1;
@ -284,52 +257,43 @@ void EffDust_Update(Actor* thisx, GlobalContext* globalCtx) {
this->updateFunc(this, globalCtx); this->updateFunc(this, globalCtx);
} }
void EffDust_DrawFunc_8099E4F4(EffDust* this, GlobalContext* globalCtx) { void EffDust_DrawFunc_8099E4F4(Actor* thisx, GlobalContext* globalCtx2) {
EffDust* this2; EffDust* this = THIS;
GlobalContext* globalCtx = globalCtx2;
GlobalContext* glb_ctx; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
GraphicsContext* gfx_ctx;
Vec3f* initialPositions; Vec3f* initialPositions;
f32* distanceTraveled; f32* distanceTraveled;
s32 i; s32 i;
f32 aux; f32 aux;
glb_ctx = globalCtx; OPEN_DISPS(gfxCtx, "../z_eff_dust.c", 425);
gfx_ctx = globalCtx->state.gfxCtx;
this2 = this;
OPEN_DISPS(gfx_ctx, "../z_eff_dust.c", 425); func_80093D18(gfxCtx);
func_80093D18(gfx_ctx);
gDPPipeSync(POLY_XLU_DISP++); gDPPipeSync(POLY_XLU_DISP++);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0x80, 0x80, 0x80, 0xFF); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0x80, 0x80, 0x80, 0xFF);
gDPSetEnvColor(POLY_XLU_DISP++, 0x80, 0x80, 0x80, 0x00); gDPSetEnvColor(POLY_XLU_DISP++, 0x80, 0x80, 0x80, 0x00);
initialPositions = this2->initialPositions; initialPositions = this->initialPositions;
distanceTraveled = this2->distanceTraveled; distanceTraveled = this->distanceTraveled;
gSPSegment(POLY_XLU_DISP++, 0x08, D_8099EB60); gSPSegment(POLY_XLU_DISP++, 0x08, D_8099EB60);
for (i = 0; i < 0x40; i++) { for (i = 0; i < 0x40; i++) {
if (*distanceTraveled < 1.0f) { if (*distanceTraveled < 1.0f) {
// Needed to match. // Needed to match.
if (!this2) {} if (!this) {}
aux = 1.0f - (*distanceTraveled * *distanceTraveled); aux = 1.0f - (*distanceTraveled * *distanceTraveled);
Matrix_Translate( Matrix_Translate(this->actor.world.pos.x + (initialPositions->x * ((this->dx * aux) + (1.0f - this->dx))),
this2->actor.world.pos.x + (initialPositions->x * ((this2->dx * aux) + (1.0f - this2->dx))), this->actor.world.pos.y + (initialPositions->y * ((this->dy * aux) + (1.0f - this->dy))),
this2->actor.world.pos.y + (initialPositions->y * ((this2->dy * aux) + (1.0f - this2->dy))), this->actor.world.pos.z + (initialPositions->z * ((this->dz * aux) + (1.0f - this->dz))),
this2->actor.world.pos.z + (initialPositions->z * ((this2->dz * aux) + (1.0f - this2->dz))), MTXMODE_NEW);
MTXMODE_NEW);
Matrix_Scale(this2->scalingFactor, this2->scalingFactor, this2->scalingFactor, MTXMODE_APPLY); Matrix_Scale(this->scalingFactor, this->scalingFactor, this->scalingFactor, MTXMODE_APPLY);
Matrix_Mult(&glb_ctx->mf_11DA0, MTXMODE_APPLY); Matrix_Mult(&globalCtx->mf_11DA0, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfx_ctx, "../z_eff_dust.c", 449), gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_dust.c", 449),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gEffFairySparklesDL)); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gEffFairySparklesDL));
} }
@ -343,30 +307,24 @@ void EffDust_DrawFunc_8099E4F4(EffDust* this, GlobalContext* globalCtx) {
if (1 != 0) {} if (1 != 0) {}
} }
CLOSE_DISPS(gfx_ctx, "../z_eff_dust.c", 458); CLOSE_DISPS(gfxCtx, "../z_eff_dust.c", 458);
} }
void EffDust_DrawFunc_8099E784(EffDust* this, GlobalContext* globalCtx) { void EffDust_DrawFunc_8099E784(Actor* thisx, GlobalContext* globalCtx) {
EffDust* this2; EffDust* this = THIS;
GlobalContext* glb_ctx; GlobalContext* globalCtx2;
GraphicsContext* gfx_ctx; GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
f32* distanceTraveled; f32* distanceTraveled;
Vec3f* initialPositions; Vec3f* initialPositions;
s32 i; s32 i;
f32 aux; f32 aux;
Player* player = PLAYER;
Player* player; OPEN_DISPS(gfxCtx, "../z_eff_dust.c", 472);
gfx_ctx = globalCtx->state.gfxCtx; globalCtx2 = globalCtx;
player = PLAYER;
OPEN_DISPS(gfx_ctx, "../z_eff_dust.c", 472); func_80093D18(gfxCtx);
glb_ctx = globalCtx;
func_80093D18(gfx_ctx);
gDPPipeSync(POLY_XLU_DISP++); gDPPipeSync(POLY_XLU_DISP++);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF);
@ -386,23 +344,22 @@ void EffDust_DrawFunc_8099E784(EffDust* this, GlobalContext* globalCtx) {
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0xFF, 0xFF, 0xFF, ((255.0f * (*distanceTraveled)))); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 0xFF, 0xFF, 0xFF, ((255.0f * (*distanceTraveled))));
// Needed to match. // Needed to match.
this2 = this; if (!this) {}
if (!this2) {}
aux = 1.0f - (*distanceTraveled * *distanceTraveled); aux = 1.0f - (*distanceTraveled * *distanceTraveled);
Matrix_Mult(&player->mf_9E0, MTXMODE_NEW); Matrix_Mult(&player->mf_9E0, MTXMODE_NEW);
Matrix_Translate(initialPositions->x * ((this2->dx * aux) + (1.0f - this2->dx)), Matrix_Translate(initialPositions->x * ((this->dx * aux) + (1.0f - this->dx)),
initialPositions->y * (1.0f - *distanceTraveled) + 320.0f, initialPositions->y * (1.0f - *distanceTraveled) + 320.0f,
initialPositions->z * (1.0f - *distanceTraveled) + -20.0f, MTXMODE_APPLY); initialPositions->z * (1.0f - *distanceTraveled) + -20.0f, MTXMODE_APPLY);
Matrix_Scale(*distanceTraveled * this2->scalingFactor, *distanceTraveled * this2->scalingFactor, Matrix_Scale(*distanceTraveled * this->scalingFactor, *distanceTraveled * this->scalingFactor,
*distanceTraveled * this2->scalingFactor, MTXMODE_APPLY); *distanceTraveled * this->scalingFactor, MTXMODE_APPLY);
func_800D1FD4(&glb_ctx->mf_11DA0); func_800D1FD4(&globalCtx2->mf_11DA0);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfx_ctx, "../z_eff_dust.c", 506), gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(gfxCtx, "../z_eff_dust.c", 506),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gEffFairySparklesDL)); gSPDisplayList(POLY_XLU_DISP++, SEGMENTED_TO_VIRTUAL(gEffFairySparklesDL));
} }
@ -411,10 +368,10 @@ void EffDust_DrawFunc_8099E784(EffDust* this, GlobalContext* globalCtx) {
distanceTraveled++; distanceTraveled++;
} }
CLOSE_DISPS(gfx_ctx, "../z_eff_dust.c", 515); CLOSE_DISPS(gfxCtx, "../z_eff_dust.c", 515);
} }
void EffDust_Draw(Actor* thisx, GlobalContext* globalCtx) { void EffDust_Draw(Actor* thisx, GlobalContext* globalCtx) {
EffDust* this = THIS; EffDust* this = THIS;
this->drawFunc(this, globalCtx); this->drawFunc(thisx, globalCtx);
} }

View file

@ -5,8 +5,8 @@
#include "global.h" #include "global.h"
struct EffDust; struct EffDust;
typedef void (*EffDustActionFunc)(struct EffDust *, GlobalContext *); typedef void (*EffDustActionFunc)(struct EffDust *, GlobalContext *);
typedef void (*EffDustDrawFunc)(Actor *, GlobalContext *);
typedef struct EffDust { typedef struct EffDust {
/* 0x0000 */ Actor actor; /* 0x0000 */ Actor actor;
@ -14,13 +14,12 @@ typedef struct EffDust {
/* 0x024C */ Vec3f initialPositions[0x40]; // array of position of each dust particle. /* 0x024C */ Vec3f initialPositions[0x40]; // array of position of each dust particle.
/* 0x054C */ u8 index; /* 0x054C */ u8 index;
/* 0x054D */ u8 life; // only considered if actor.params is 2, 3 or 4. /* 0x054D */ u8 life; // only considered if actor.params is 2, 3 or 4.
/* 0x054E */ char padding[0x02];
/* 0x0550 */ f32 dx; // normalized. 0.0f to 1.0f /* 0x0550 */ f32 dx; // normalized. 0.0f to 1.0f
/* 0x0554 */ f32 dy; // normalized. 0.0f to 1.0f /* 0x0554 */ f32 dy; // normalized. 0.0f to 1.0f
/* 0x0558 */ f32 dz; // normalized. 0.0f to 1.0f /* 0x0558 */ f32 dz; // normalized. 0.0f to 1.0f
/* 0x055C */ f32 scalingFactor; /* 0x055C */ f32 scalingFactor;
/* 0x0560 */ EffDustActionFunc updateFunc; // function to be called by EffDust_Update() /* 0x0560 */ EffDustActionFunc updateFunc;
/* 0x0560 */ EffDustActionFunc drawFunc; // function to be called by EffDust_Draw() /* 0x0560 */ EffDustDrawFunc drawFunc;
} EffDust; // size = 0x0568 } EffDust; // size = 0x0568