diff --git a/include/math.h b/include/math.h index a50d4178ce..316bc57102 100644 --- a/include/math.h +++ b/include/math.h @@ -9,7 +9,7 @@ #define FLT_MAX 340282346638528859811704183484516925440.0f #define SHT_MAX 32767.0f #define SHT_MINV (1.0f / SHT_MAX) -#define DEGTORAD(x) (x * M_PI / 180.0f) +#define DEGTORAD(x) ((x) * (M_PI / 180.0f)) typedef union { struct { diff --git a/include/variables.h b/include/variables.h index 531ab0eafb..31443e6a81 100644 --- a/include/variables.h +++ b/include/variables.h @@ -4061,7 +4061,8 @@ extern Gfx D_04075B30[]; extern Gfx D_04076BC0[]; extern Gfx D_04077480[]; extern UNK_TYPE D_04079B10; -extern UNK_TYPE D_0407AB10; +extern Gfx D_0407AB10[]; +extern Gfx D_0407AB58[]; extern UNK_TYPE D_0407AFB0; extern Gfx D_0407D590[]; extern UNK_TYPE D_0407D650; diff --git a/spec b/spec index 8ffdf7aa66..b959f40dd2 100644 --- a/spec +++ b/spec @@ -1272,7 +1272,7 @@ beginseg name "ovl_En_Encount2" compress include "build/src/overlays/actors/ovl_En_Encount2/z_en_encount2.o" - include "build/data/ovl_En_Encount2/ovl_En_Encount2.reloc.o" + include "build/src/overlays/actors/ovl_En_Encount2/ovl_En_Encount2_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c index 81a89ecf29..b61b73c58b 100644 --- a/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c +++ b/src/overlays/actors/ovl_En_Encount2/z_en_encount2.c @@ -13,7 +13,7 @@ void EnEncount2_Idle(EnEncount2* this, GlobalContext* globalCtx); void EnEncount2_Popped(EnEncount2* this, GlobalContext* globalCtx); void EnEncount2_Die(EnEncount2* this, GlobalContext* globalCtx); void EnEncount2_SetIdle(EnEncount2* this); -void EnEncount2_InitParticles(EnEncount2* this, Vec3f* vec, s16 fadeDelay); +void EnEncount2_InitParticles(EnEncount2* this, Vec3f* pos, s16 fadeDelay); void EnEncount2_UpdateParticles(EnEncount2* this, GlobalContext* globalCtx); void EnEncount2_DrawParticles(EnEncount2* this, GlobalContext* globalCtx); @@ -104,7 +104,7 @@ void EnEncount2_Init(Actor* thisx, GlobalContext* globalCtx) { BgCheck_RelocateMeshHeader(&D_06002420, &colHeader); this->dyna.bgId = BgCheck_AddActorMesh(globalCtx, &globalCtx->colCtx.dyna, &this->dyna, colHeader); ActorShape_Init(&this->dyna.actor.shape, 0.0f, func_800B3FC0, 25.0f); - this->dyna.actor.colChkInfo.mass = 0xFF; + this->dyna.actor.colChkInfo.mass = MASS_IMMOVABLE; Collider_InitAndSetJntSph(globalCtx, &this->collider, &this->dyna.actor, &sJntSphInit, &this->colElement); this->dyna.actor.targetMode = 6; @@ -138,7 +138,7 @@ void EnEncount2_Destroy(Actor* thisx, GlobalContext* globalCtx) { } void EnEncount2_SetIdle(EnEncount2* this) { - this->isPopped = 0; + this->isPopped = false; this->actionFunc = EnEncount2_Idle; } @@ -148,7 +148,7 @@ void EnEncount2_Idle(EnEncount2* this, GlobalContext* globalCtx) { Math_ApproachF(&this->scale, 0.1f, 0.3f, 0.01f); if ((this->collider.base.acFlags & AC_HIT) && (this->dyna.actor.colChkInfo.damageEffect == 0xE)) { this->dyna.actor.colChkInfo.health = 0; - this->isPopped = 1; + this->isPopped = true; this->actionFunc = EnEncount2_Popped; } } @@ -162,7 +162,7 @@ void EnEncount2_Popped(EnEncount2* this, GlobalContext* globalCtx) { Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, curPos.x, curPos.y, curPos.z, 255, 255, 200, CLEAR_TAG_LARGE_EXPLOSION); - for (i = 0; i != 100; ++i) { + for (i = 0; i < ARRAY_COUNT(this->particles) / 2; ++i) { EnEncount2_InitParticles(this, &curPos, 10); } @@ -202,21 +202,21 @@ void EnEncount2_Update(Actor* thisx, GlobalContext* globalCtx) { void EnEncount2_Draw(Actor* thisx, GlobalContext* globalCtx) { EnEncount2* this = THIS; - if (this->isPopped != 1) { + if (this->isPopped != true) { func_800BDFC0(globalCtx, D_06000A00); func_800BDFC0(globalCtx, D_06000D78); } EnEncount2_DrawParticles(this, globalCtx); } -void EnEncount2_InitParticles(EnEncount2* this, Vec3f* vec, s16 fadeDelay) { +void EnEncount2_InitParticles(EnEncount2* this, Vec3f* pos, s16 fadeDelay) { s16 i; EnEncount2Particle* sPtr = this->particles; - for (i = 0; i < 200; ++i) { + for (i = 0; i < ARRAY_COUNT(this->particles); i++, sPtr++) { if (!sPtr->enabled) { - sPtr->enabled = 1; - sPtr->pos = *vec; + sPtr->enabled = true; + sPtr->pos = *pos; sPtr->alphaFadeDelay = fadeDelay; sPtr->alpha = 0xFF; @@ -231,7 +231,6 @@ void EnEncount2_InitParticles(EnEncount2* this, Vec3f* vec, s16 fadeDelay) { sPtr->scale = (Rand_ZeroFloat(1.0f) * 0.5f) + 2.0f; return; } - sPtr++; } } @@ -239,7 +238,7 @@ void EnEncount2_UpdateParticles(EnEncount2* this, GlobalContext* globalCtx) { s32 i; EnEncount2Particle* sPtr = this->particles; - for (i = 0; i < 200; i += 2) { + for (i = 0; i < ARRAY_COUNT(this->particles); i++, sPtr++) { if (sPtr->enabled) { sPtr->pos.x += sPtr->vel.x; sPtr->pos.y += sPtr->vel.y; @@ -247,24 +246,7 @@ void EnEncount2_UpdateParticles(EnEncount2* this, GlobalContext* globalCtx) { sPtr->vel.x += sPtr->accel.x; sPtr->vel.y += sPtr->accel.y; sPtr->vel.z += sPtr->accel.z; - if (sPtr->alphaFadeDelay != 0) { - sPtr->alphaFadeDelay--; - } else { - sPtr->alpha -= 10; - if (sPtr->alpha < 10) { - sPtr->enabled = 0; - } - } - } - sPtr++; - if (sPtr->enabled) { - sPtr->pos.x += sPtr->vel.x; - sPtr->pos.y += sPtr->vel.y; - sPtr->pos.z += sPtr->vel.z; - sPtr->vel.x += sPtr->accel.x; - sPtr->vel.y += sPtr->accel.y; - sPtr->vel.z += sPtr->accel.z; if (sPtr->alphaFadeDelay != 0) { sPtr->alphaFadeDelay--; } else { @@ -274,8 +256,34 @@ void EnEncount2_UpdateParticles(EnEncount2* this, GlobalContext* globalCtx) { } } } - sPtr++; } } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_En_Encount2/EnEncount2_DrawParticles.s") +void EnEncount2_DrawParticles(EnEncount2* this, GlobalContext* globalCtx) { + s16 i; + EnEncount2Particle* sPtr; + GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + + OPEN_DISPS(gfxCtx); + sPtr = this->particles; + func_8012C28C(gfxCtx); + func_8012C2DC(globalCtx->state.gfxCtx); + for (i = 0; i < ARRAY_COUNT(this->particles); i++, sPtr++) { + if (sPtr->enabled) { + SysMatrix_InsertTranslation(sPtr->pos.x, sPtr->pos.y, sPtr->pos.z, MTXMODE_NEW); + Matrix_Scale(sPtr->scale, sPtr->scale, sPtr->scale, MTXMODE_APPLY); + POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); + gSPSegment(POLY_XLU_DISP++, 0x08, Lib_SegmentedToVirtual(&D_04079B10)); + gSPDisplayList(POLY_XLU_DISP++, D_0407AB10); + gDPPipeSync(POLY_XLU_DISP++); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(POLY_XLU_DISP++, 250, 180, 255, sPtr->alpha); + SysMatrix_InsertMatrix(&globalCtx->mf_187FC, MTXMODE_APPLY); + SysMatrix_InsertZRotation_f(DEGTORAD(globalCtx->state.frames * 20.0f), MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), + G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPDisplayList(POLY_XLU_DISP++, D_0407AB58); + } + } + CLOSE_DISPS(gfxCtx); +}