mirror of
https://github.com/zeldaret/mm.git
synced 2026-07-08 13:26:14 -04:00
Split effect headers and a bit of cleanup (#1482)
* split * bss * z64eff_ss_dead.h * clean eff_blure * eff_shield_particle cleanup * tire?mark * and more cleanup * format * forgot to remove this * review * EffectBlureDrawMode enum * review * review * bss
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
#include "prevent_bss_reordering.h"
|
||||
#include "global.h"
|
||||
#include "fault.h"
|
||||
#include "libc64/fixed_point.h"
|
||||
#include "libc64/sprintf.h"
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "prevent_bss_reordering.h"
|
||||
#include "z64collision_check.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "z64actor.h"
|
||||
#include "z64effect.h"
|
||||
#include "z64malloc.h"
|
||||
#include "global.h"
|
||||
|
||||
typedef s32 (*ColChkResetFunc)(struct PlayState*, Collider*);
|
||||
typedef void (*ColChkBloodFunc)(struct PlayState*, Collider*, Vec3f*);
|
||||
|
||||
+64
-45
@@ -1,10 +1,19 @@
|
||||
#include "z64eff_blure.h"
|
||||
|
||||
#include "libc/stdbool.h"
|
||||
#include "gfx.h"
|
||||
#include "macros.h"
|
||||
#include "sys_matrix.h"
|
||||
#include "z64effect_ss.h"
|
||||
#include "global.h"
|
||||
|
||||
#include "objects/gameplay_keep/gameplay_keep.h"
|
||||
|
||||
void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2) {
|
||||
EffectBlureElement* elem;
|
||||
s32 numElements;
|
||||
s32 pad;
|
||||
|
||||
//! FAKE
|
||||
if (this) {}
|
||||
if (this) {}
|
||||
|
||||
@@ -16,7 +25,7 @@ void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2) {
|
||||
elem = &this->elements[this->numElements];
|
||||
elem->state = 1;
|
||||
|
||||
if (!(this->flags & 2)) {
|
||||
if (!(this->flags & EFFECT_BLURE_FLAG_2)) {
|
||||
elem->p1.x = p1->x;
|
||||
elem->p1.y = p1->y;
|
||||
elem->p1.z = p1->z;
|
||||
@@ -35,16 +44,16 @@ void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2) {
|
||||
Vec3f sp44;
|
||||
Vec3f sp38;
|
||||
|
||||
sp16C.x = ((f32)(elem - 1)->p2.x + (f32)(elem - 1)->p1.x) * 0.5f;
|
||||
sp16C.y = ((f32)(elem - 1)->p2.y + (f32)(elem - 1)->p1.y) * 0.5f;
|
||||
sp16C.z = ((f32)(elem - 1)->p2.z + (f32)(elem - 1)->p1.z) * 0.5f;
|
||||
sp160.x = (p1->x + p2->x) * 0.5f;
|
||||
sp160.y = (p1->y + p2->y) * 0.5f;
|
||||
sp160.z = (p1->z + p2->z) * 0.5f;
|
||||
sp16C.x = ((f32)(elem - 1)->p2.x + (f32)(elem - 1)->p1.x) / 2.0f;
|
||||
sp16C.y = ((f32)(elem - 1)->p2.y + (f32)(elem - 1)->p1.y) / 2.0f;
|
||||
sp16C.z = ((f32)(elem - 1)->p2.z + (f32)(elem - 1)->p1.z) / 2.0f;
|
||||
sp160.x = (p1->x + p2->x) / 2.0f;
|
||||
sp160.y = (p1->y + p2->y) / 2.0f;
|
||||
sp160.z = (p1->z + p2->z) / 2.0f;
|
||||
|
||||
Math_Vec3f_Diff(&sp160, &sp16C, &sp154);
|
||||
scale = Math3D_Vec3fMagnitude(&sp154);
|
||||
if (!(fabsf(scale) < 0.008f)) {
|
||||
if (!IS_ZERO(scale)) {
|
||||
scale = 1.0f / scale;
|
||||
Math_Vec3f_Scale(&sp154, scale);
|
||||
|
||||
@@ -72,15 +81,14 @@ void EffectBlure_AddVertex(EffectBlure* this, Vec3f* p1, Vec3f* p2) {
|
||||
|
||||
void EffectBlure_AddSpace(EffectBlure* this) {
|
||||
EffectBlureElement* elem;
|
||||
s32 numElements;
|
||||
s32 pad;
|
||||
|
||||
if (this != NULL) {
|
||||
numElements = this->numElements;
|
||||
if (numElements >= ARRAY_COUNT(this->elements)) {
|
||||
if (this->numElements >= ARRAY_COUNT(this->elements)) {
|
||||
return;
|
||||
}
|
||||
|
||||
elem = &this->elements[numElements];
|
||||
elem = &this->elements[this->numElements];
|
||||
elem->state = 0;
|
||||
elem->timer = 1;
|
||||
|
||||
@@ -118,7 +126,7 @@ void EffectBlure_Init1(void* thisx, void* initParamsx) {
|
||||
|
||||
EffectBlure_InitElements(this);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (i = 0; i < EFFECT_BLURE_COLOR_COUNT; i++) {
|
||||
this->p1StartColor[i] = initParams->p1StartColor[i];
|
||||
this->p2StartColor[i] = initParams->p2StartColor[i];
|
||||
this->p1EndColor[i] = initParams->p1EndColor[i];
|
||||
@@ -131,7 +139,7 @@ void EffectBlure_Init1(void* thisx, void* initParamsx) {
|
||||
this->flags = 0;
|
||||
this->addAngleChange = 0;
|
||||
this->addAngle = 0;
|
||||
this->drawMode = 0;
|
||||
this->drawMode = EFF_BLURE_DRAW_MODE_SIMPLE;
|
||||
this->altPrimColor.r = 0;
|
||||
this->altPrimColor.g = 0;
|
||||
this->altPrimColor.b = 0;
|
||||
@@ -153,7 +161,7 @@ void EffectBlure_Init2(void* thisx, void* initParamsx) {
|
||||
|
||||
EffectBlure_InitElements(this);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (i = 0; i < EFFECT_BLURE_COLOR_COUNT; i++) {
|
||||
this->p1StartColor[i] = initParams->p1StartColor[i];
|
||||
this->p2StartColor[i] = initParams->p2StartColor[i];
|
||||
this->p1EndColor[i] = initParams->p1EndColor[i];
|
||||
@@ -270,8 +278,8 @@ void EffectBlure_UpdateFlags(EffectBlureElement* elem) {
|
||||
f32 sp2C;
|
||||
|
||||
if (((elem - 1)->state == 0) || ((elem + 1)->state == 0)) {
|
||||
elem->flags &= ~3;
|
||||
elem->flags |= 2;
|
||||
elem->flags &= ~(EFFECT_BLURE_ELEMENT_FLAG_1 | EFFECT_BLURE_ELEMENT_FLAG_2);
|
||||
elem->flags |= EFFECT_BLURE_ELEMENT_FLAG_2;
|
||||
} else {
|
||||
Math_Vec3s_DiffToVec3f(&sp64, &elem->p1, &prev->p1);
|
||||
Math_Vec3s_DiffToVec3f(&sp58, &elem->p2, &prev->p2);
|
||||
@@ -280,14 +288,14 @@ void EffectBlure_UpdateFlags(EffectBlureElement* elem) {
|
||||
|
||||
if (Math3D_AngleBetweenVectors(&sp64, &sp4C, &sp34) || Math3D_AngleBetweenVectors(&sp58, &sp40, &sp30) ||
|
||||
Math3D_AngleBetweenVectors(&sp4C, &sp40, &sp2C)) {
|
||||
elem->flags &= ~3;
|
||||
elem->flags &= ~(EFFECT_BLURE_ELEMENT_FLAG_1 | EFFECT_BLURE_ELEMENT_FLAG_2);
|
||||
elem->flags |= 0;
|
||||
} else if ((sp34 <= -0.5f) || (sp30 <= -0.5f) || (sp2C <= 0.7071f)) {
|
||||
elem->flags &= ~3;
|
||||
elem->flags &= ~(EFFECT_BLURE_ELEMENT_FLAG_1 | EFFECT_BLURE_ELEMENT_FLAG_2);
|
||||
elem->flags |= 0;
|
||||
} else {
|
||||
elem->flags &= ~3;
|
||||
elem->flags |= 1;
|
||||
elem->flags &= ~(EFFECT_BLURE_ELEMENT_FLAG_1 | EFFECT_BLURE_ELEMENT_FLAG_2);
|
||||
elem->flags |= EFFECT_BLURE_ELEMENT_FLAG_1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -337,7 +345,8 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3
|
||||
|
||||
vec1->x = (sp30.x * 0.5f * mode4Param * ratio) + elem->p1.x;
|
||||
vec1->y = (sp30.y * 0.5f * mode4Param * ratio) + elem->p1.y;
|
||||
if (1) {} // Necessary to match
|
||||
//! FAKE
|
||||
if (1) {}
|
||||
vec1->z = (sp30.z * 0.5f * mode4Param * ratio) + elem->p1.z;
|
||||
|
||||
vec2->x = -(sp30.x * 0.5f * mode4Param * ratio) + elem->p2.x;
|
||||
@@ -356,7 +365,7 @@ void EffectBlure_GetComputedValues(EffectBlure* this, s32 index, f32 ratio, Vec3
|
||||
break;
|
||||
}
|
||||
|
||||
if (this->flags & 0x10) {
|
||||
if (this->flags & EFFECT_BLURE_FLAG_10) {
|
||||
color1->r = color1->g = color1->b = color1->a = 255;
|
||||
color2->r = color2->g = color2->b = color2->a = 255;
|
||||
} else {
|
||||
@@ -511,7 +520,7 @@ void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* this, EffectBlureElem
|
||||
Math_Vec3s_ToVec3f(&sp18C, &sp1EC);
|
||||
Math_Vec3s_ToVec3f(&sp180, &sp1E4);
|
||||
|
||||
if ((elem->flags & 3) == 2) {
|
||||
if ((elem->flags & (EFFECT_BLURE_ELEMENT_FLAG_1 | EFFECT_BLURE_ELEMENT_FLAG_2)) == EFFECT_BLURE_ELEMENT_FLAG_2) {
|
||||
Math_Vec3f_Diff(&sp18C, &sp1CC, &sp1B4);
|
||||
Math_Vec3f_Diff(&sp180, &sp1C0, &sp1A8);
|
||||
} else {
|
||||
@@ -529,7 +538,8 @@ void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* this, EffectBlureElem
|
||||
Math_Vec3f_Scale(&sp1B4, 0.5f);
|
||||
Math_Vec3f_Scale(&sp1A8, 0.5f);
|
||||
|
||||
if (((elem + 1)->flags & 3) == 2) {
|
||||
if (((elem + 1)->flags & (EFFECT_BLURE_ELEMENT_FLAG_1 | EFFECT_BLURE_ELEMENT_FLAG_2)) ==
|
||||
EFFECT_BLURE_ELEMENT_FLAG_2) {
|
||||
Math_Vec3f_Diff(&sp18C, &sp1CC, &sp174);
|
||||
Math_Vec3f_Diff(&sp180, &sp1C0, &sp168);
|
||||
} else {
|
||||
@@ -651,15 +661,15 @@ void EffectBlure_DrawSmooth(EffectBlure* this2, GraphicsContext* gfxCtx) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->elements[0].flags &= ~3;
|
||||
this->elements[0].flags |= 2;
|
||||
this->elements[0].flags &= ~(EFFECT_BLURE_ELEMENT_FLAG_1 | EFFECT_BLURE_ELEMENT_FLAG_2);
|
||||
this->elements[0].flags |= EFFECT_BLURE_ELEMENT_FLAG_2;
|
||||
|
||||
for (elem = &this->elements[1]; elem < this->elements + this->numElements - 1; elem++) {
|
||||
EffectBlure_UpdateFlags(elem);
|
||||
}
|
||||
|
||||
this->elements[this->numElements - 1].flags &= ~3;
|
||||
this->elements[this->numElements - 1].flags |= 2;
|
||||
this->elements[this->numElements - 1].flags &= ~(EFFECT_BLURE_ELEMENT_FLAG_1 | EFFECT_BLURE_ELEMENT_FLAG_2);
|
||||
this->elements[this->numElements - 1].flags |= EFFECT_BLURE_ELEMENT_FLAG_2;
|
||||
|
||||
EffectBlure_SetupSmooth(this, gfxCtx);
|
||||
SkinMatrix_SetTranslate(&spDC, this->elements[0].p2.x, this->elements[0].p2.y, this->elements[0].p2.z);
|
||||
@@ -677,10 +687,18 @@ void EffectBlure_DrawSmooth(EffectBlure* this2, GraphicsContext* gfxCtx) {
|
||||
if ((elem->state == 0) || ((elem + 1)->state == 0)) {
|
||||
continue;
|
||||
}
|
||||
if ((((elem->flags & 3) == 0) && (((elem + 1)->flags & 3) == 0)) ||
|
||||
(((elem->flags & 3) == 2) && (((elem + 1)->flags & 3) == 0)) ||
|
||||
(((elem->flags & 3) == 0) && (((elem + 1)->flags & 3) == 2)) ||
|
||||
(((elem->flags & 3) == 2) && (((elem + 1)->flags & 3) == 2))) {
|
||||
if ((((elem->flags & (EFFECT_BLURE_ELEMENT_FLAG_1 | EFFECT_BLURE_ELEMENT_FLAG_2)) == 0) &&
|
||||
(((elem + 1)->flags & (EFFECT_BLURE_ELEMENT_FLAG_1 | EFFECT_BLURE_ELEMENT_FLAG_2)) == 0)) ||
|
||||
(((elem->flags & (EFFECT_BLURE_ELEMENT_FLAG_1 | EFFECT_BLURE_ELEMENT_FLAG_2)) ==
|
||||
EFFECT_BLURE_ELEMENT_FLAG_2) &&
|
||||
(((elem + 1)->flags & (EFFECT_BLURE_ELEMENT_FLAG_1 | EFFECT_BLURE_ELEMENT_FLAG_2)) == 0)) ||
|
||||
(((elem->flags & (EFFECT_BLURE_ELEMENT_FLAG_1 | EFFECT_BLURE_ELEMENT_FLAG_2)) == 0) &&
|
||||
(((elem + 1)->flags & (EFFECT_BLURE_ELEMENT_FLAG_1 | EFFECT_BLURE_ELEMENT_FLAG_2)) ==
|
||||
EFFECT_BLURE_ELEMENT_FLAG_2)) ||
|
||||
(((elem->flags & (EFFECT_BLURE_ELEMENT_FLAG_1 | EFFECT_BLURE_ELEMENT_FLAG_2)) ==
|
||||
EFFECT_BLURE_ELEMENT_FLAG_2) &&
|
||||
(((elem + 1)->flags & (EFFECT_BLURE_ELEMENT_FLAG_1 | EFFECT_BLURE_ELEMENT_FLAG_2)) ==
|
||||
EFFECT_BLURE_ELEMENT_FLAG_2))) {
|
||||
EffectBlure_DrawElemNoInterpolation(this, elem, i, gfxCtx);
|
||||
} else {
|
||||
EffectBlure_DrawElemHermiteInterpolation(this, elem, i, gfxCtx);
|
||||
@@ -723,12 +741,13 @@ void EffectBlure_SetupSimpleAlt(GraphicsContext* gfxCtx, EffectBlure* this, Vtx*
|
||||
CLOSE_DISPS(gfxCtx);
|
||||
}
|
||||
|
||||
void (*sSetupHandlers[])(GraphicsContext* gfxCtx, EffectBlure* this, Vtx* vtx) = {
|
||||
EffectBlure_SetupSimple,
|
||||
EffectBlure_SetupSimpleAlt,
|
||||
};
|
||||
typedef void (*SetupHandler)(GraphicsContext* gfxCtx, EffectBlure* this, Vtx* vtx);
|
||||
|
||||
s32 D_801AE268 = 0; // unused
|
||||
SetupHandler sSetupHandlers[EFF_BLURE_DRAW_MODE_MAX] = {
|
||||
EffectBlure_SetupSimple, // EFF_BLURE_DRAW_MODE_SIMPLE
|
||||
EffectBlure_SetupSimpleAlt, // EFF_BLURE_DRAW_MODE_SIMPLE_ALT_COLORS
|
||||
NULL, // EFF_BLURE_DRAW_MODE_SMOOTH
|
||||
};
|
||||
|
||||
void EffectBlure_DrawSimpleVertices(GraphicsContext* gfxCtx, EffectBlure* this, Vtx* vtx) {
|
||||
Mtx* mtx;
|
||||
@@ -754,7 +773,7 @@ void EffectBlure_DrawSimpleVertices(GraphicsContext* gfxCtx, EffectBlure* this,
|
||||
j = 0;
|
||||
|
||||
for (i = 0; i < this->numElements - 1; i++, j += 4) {
|
||||
if (this->drawMode == 1) {
|
||||
if (this->drawMode == EFF_BLURE_DRAW_MODE_SIMPLE_ALT_COLORS) {
|
||||
alphaRatio = (f32)this->elements[i].timer / (f32)this->elemDuration;
|
||||
gDPSetPrimColor(POLY_XLU_DISP++, 0x00, 0x80, this->altPrimColor.r, this->altPrimColor.g,
|
||||
this->altPrimColor.b, this->altPrimColor.a * (1.0f - alphaRatio));
|
||||
@@ -764,7 +783,7 @@ void EffectBlure_DrawSimpleVertices(GraphicsContext* gfxCtx, EffectBlure* this,
|
||||
gSPVertex(POLY_XLU_DISP++, &vtx[j], 4, 0);
|
||||
gSP2Triangles(POLY_XLU_DISP++, 0, 1, 3, 0, 0, 3, 2, 0);
|
||||
|
||||
if (!(this->flags & 4)) {
|
||||
if (!(this->flags & EFFECT_BLURE_FLAG_4)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -833,7 +852,7 @@ void EffectBlure_DrawSimple(EffectBlure* this2, GraphicsContext* gfxCtx) {
|
||||
Color_RGBA8 sp60;
|
||||
|
||||
if (this->numElements >= 2) {
|
||||
vtxCount = this->numElements * 4;
|
||||
vtxCount = this->numElements * ARRAY_COUNT(D_801AE26C);
|
||||
|
||||
vtx = GRAPH_ALLOC(gfxCtx, vtxCount * sizeof(Vtx));
|
||||
if (vtx == NULL) {
|
||||
@@ -841,14 +860,14 @@ void EffectBlure_DrawSimple(EffectBlure* this2, GraphicsContext* gfxCtx) {
|
||||
}
|
||||
|
||||
vtxIter = vtx;
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (i = 0; i < ARRAY_COUNT(D_801AE26C); i++) {
|
||||
vtxIter->v = D_801AE26C[i];
|
||||
vtxIter++;
|
||||
}
|
||||
|
||||
if (this->numElements >= 2) {
|
||||
for (elem = this->elements; elem < this->elements + this->numElements - 2; elem++) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (i = 0; i < ARRAY_COUNT(D_801AE2AC); i++) {
|
||||
vtxIter->v = D_801AE2AC[i];
|
||||
vtxIter++;
|
||||
}
|
||||
@@ -1019,7 +1038,7 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (this->drawMode < 2) {
|
||||
} else if (this->drawMode <= EFF_BLURE_DRAW_MODE_SIMPLE_ALT_COLORS) {
|
||||
EffectBlure_DrawSimple(this, gfxCtx);
|
||||
} else {
|
||||
EffectBlure_DrawSmooth(this, gfxCtx);
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#include "z64eff_shield_particle.h"
|
||||
#include "z64effect.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "vt.h"
|
||||
|
||||
@@ -175,7 +178,7 @@ void EffectShieldParticle_Draw(void* thisx, GraphicsContext* gfxCtx) {
|
||||
MtxF sp104;
|
||||
MtxF spC4;
|
||||
MtxF sp84;
|
||||
f32 temp1 = (elem->endX + elem->startX) * 0.5f;
|
||||
f32 temp1 = (elem->endX + elem->startX) / 2.0f;
|
||||
f32 temp2 = elem->endX - elem->startX;
|
||||
f32 temp3 = (temp2 * (1.0f / 64.0f)) / 0.02f;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "z64eff_spark.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "objects/gameplay_keep/gameplay_keep.h"
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "z64eff_ss_dead.h"
|
||||
#include "global.h"
|
||||
|
||||
void func_800AE2A0(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) {
|
||||
@@ -19,7 +20,7 @@ void func_800AE2A0(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) {
|
||||
gDPSetFogColor(displayListHead++, color->r, color->g, color->b, color->a);
|
||||
}
|
||||
|
||||
gSPFogPosition(displayListHead++, 0, (s16)(absCos * 3000.0f) + 1500);
|
||||
gSPFogPosition(displayListHead++, 0, TRUNCF_BINANG(absCos * 3000.0f) + 1500);
|
||||
|
||||
POLY_OPA_DISP = displayListHead;
|
||||
|
||||
@@ -37,7 +38,7 @@ void func_800AE434(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) {
|
||||
|
||||
gDPPipeSync(displayListHead++);
|
||||
gDPSetFogColor(displayListHead++, color->r, color->g, color->b, color->a);
|
||||
gSPFogPosition(displayListHead++, 0, (s16)(2800.0f * fabsf(cos)) + 1700);
|
||||
gSPFogPosition(displayListHead++, 0, TRUNCF_BINANG(2800.0f * fabsf(cos)) + 1700);
|
||||
|
||||
POLY_OPA_DISP = displayListHead;
|
||||
|
||||
@@ -74,7 +75,7 @@ void func_800AE5E4(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) {
|
||||
gDPSetFogColor(displayListHead++, color->r, color->g, color->b, color->a);
|
||||
}
|
||||
|
||||
gSPFogPosition(displayListHead++, 0, (s16)(absCos * 3000.0f) + 1500);
|
||||
gSPFogPosition(displayListHead++, 0, TRUNCF_BINANG(absCos * 3000.0f) + 1500);
|
||||
|
||||
POLY_XLU_DISP = displayListHead;
|
||||
|
||||
@@ -92,7 +93,7 @@ void func_800AE778(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) {
|
||||
|
||||
gDPPipeSync(displayListHead++);
|
||||
gDPSetFogColor(displayListHead++, color->r, color->g, color->b, color->a);
|
||||
gSPFogPosition(displayListHead++, 0, (s16)(2800.0f * fabsf(cos)) + 1700);
|
||||
gSPFogPosition(displayListHead++, 0, TRUNCF_BINANG(2800.0f * fabsf(cos)) + 1700);
|
||||
|
||||
POLY_XLU_DISP = displayListHead;
|
||||
|
||||
|
||||
+14
-12
@@ -1,3 +1,5 @@
|
||||
#include "z64eff_tire_mark.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "objects/gameplay_keep/gameplay_keep.h"
|
||||
|
||||
@@ -59,8 +61,8 @@ void func_800AE930(CollisionContext* colCtx, EffectTireMark* this, Vec3f* pos, f
|
||||
|
||||
if ((func_80179798(&sp84, &sp90, &sp54, &sp60, &sp6C, &sp30) != 0) &&
|
||||
(func_80179798(&sp84, &sp90, &sp3C, &sp48, &sp78, &sp30) != 0)) {
|
||||
if (!(spAC->flags & 2)) {
|
||||
spAC->flags |= 1;
|
||||
if (!(spAC->flags & EFFECT_TIRE_MARK_ELEMENT_FLAG_2)) {
|
||||
spAC->flags |= EFFECT_TIRE_MARK_ELEMENT_FLAG_1;
|
||||
}
|
||||
|
||||
spA8 = &this->elements[this->numElements];
|
||||
@@ -76,8 +78,8 @@ void func_800AE930(CollisionContext* colCtx, EffectTireMark* this, Vec3f* pos, f
|
||||
this->numElements++;
|
||||
|
||||
spAC = &this->elements[this->numElements - 1];
|
||||
if (!(spAC->flags & 2)) {
|
||||
spAC->flags |= 1;
|
||||
if (!(spAC->flags & EFFECT_TIRE_MARK_ELEMENT_FLAG_2)) {
|
||||
spAC->flags |= EFFECT_TIRE_MARK_ELEMENT_FLAG_1;
|
||||
}
|
||||
|
||||
//! FAKE:
|
||||
@@ -93,8 +95,8 @@ void func_800AE930(CollisionContext* colCtx, EffectTireMark* this, Vec3f* pos, f
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(spAC->flags & 2)) {
|
||||
spAC->flags |= 1;
|
||||
if (!(spAC->flags & EFFECT_TIRE_MARK_ELEMENT_FLAG_2)) {
|
||||
spAC->flags |= EFFECT_TIRE_MARK_ELEMENT_FLAG_1;
|
||||
}
|
||||
|
||||
spA8 = &this->elements[this->numElements];
|
||||
@@ -108,8 +110,8 @@ void func_800AE930(CollisionContext* colCtx, EffectTireMark* this, Vec3f* pos, f
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(spAC->flags & 2)) {
|
||||
spAC->flags |= 1;
|
||||
if (!(spAC->flags & EFFECT_TIRE_MARK_ELEMENT_FLAG_2)) {
|
||||
spAC->flags |= EFFECT_TIRE_MARK_ELEMENT_FLAG_1;
|
||||
}
|
||||
|
||||
spA8 = &this->elements[this->numElements];
|
||||
@@ -125,7 +127,7 @@ void func_800AE930(CollisionContext* colCtx, EffectTireMark* this, Vec3f* pos, f
|
||||
void func_800AEF44(EffectTireMark* this) {
|
||||
EffectTireMarkElement* elem = &this->elements[this->numElements - 1];
|
||||
|
||||
elem->flags |= 2;
|
||||
elem->flags |= EFFECT_TIRE_MARK_ELEMENT_FLAG_2;
|
||||
}
|
||||
|
||||
void EffectTireMark_InitElement(EffectTireMarkElement* elem) {
|
||||
@@ -255,15 +257,15 @@ void EffectTireMark_Draw(void* thisx, GraphicsContext* gfxCtx) {
|
||||
|
||||
EffectTireMark_SetVertices(vtx, elem, i, 255);
|
||||
|
||||
if ((elem - 1)->flags & 1) {
|
||||
if (!(elem->flags & 1)) {
|
||||
if ((elem - 1)->flags & EFFECT_TIRE_MARK_ELEMENT_FLAG_1) {
|
||||
if (!(elem->flags & EFFECT_TIRE_MARK_ELEMENT_FLAG_1)) {
|
||||
s32 requiredScopeTemp;
|
||||
|
||||
vtx[i * 2 + 0].v.tc[0] = 0;
|
||||
vtx[i * 2 + 0].v.tc[1] = 0;
|
||||
vtx[i * 2 + 1].v.tc[0] = 0;
|
||||
vtx[i * 2 + 1].v.tc[1] = 1024;
|
||||
} else if ((i >= 2) && !((elem - 2)->flags & 1)) {
|
||||
} else if ((i >= 2) && !((elem - 2)->flags & EFFECT_TIRE_MARK_ELEMENT_FLAG_1)) {
|
||||
vtx[i * 2 - 2].v.tc[0] = 0;
|
||||
vtx[i * 2 - 2].v.tc[1] = 0;
|
||||
vtx[i * 2 - 1].v.tc[0] = 0;
|
||||
|
||||
+50
-2
@@ -1,8 +1,50 @@
|
||||
#include "z64effect.h"
|
||||
#include "global.h"
|
||||
|
||||
#define SPARK_COUNT 3
|
||||
#define BLURE_COUNT 25
|
||||
#define SHIELD_PARTICLE_COUNT 3
|
||||
#define TIRE_MARK_COUNT 15
|
||||
|
||||
#define TOTAL_EFFECT_COUNT SPARK_COUNT + BLURE_COUNT + SHIELD_PARTICLE_COUNT + TIRE_MARK_COUNT
|
||||
|
||||
typedef struct EffectStatus {
|
||||
/* 0x0 */ u8 active;
|
||||
/* 0x1 */ u8 unk1;
|
||||
/* 0x2 */ u8 unk2;
|
||||
} EffectStatus; // size = 0x3
|
||||
|
||||
typedef struct EffectContext {
|
||||
/* 0x0000 */ struct PlayState* play;
|
||||
struct {
|
||||
EffectStatus status;
|
||||
EffectSpark effect;
|
||||
} /* 0x0004 */ sparks[SPARK_COUNT];
|
||||
struct {
|
||||
EffectStatus status;
|
||||
EffectBlure effect;
|
||||
} /* 0x0E5C */ blures[BLURE_COUNT];
|
||||
struct {
|
||||
EffectStatus status;
|
||||
EffectShieldParticle effect;
|
||||
} /* 0x388C */ shieldParticles[SHIELD_PARTICLE_COUNT];
|
||||
struct {
|
||||
EffectStatus status;
|
||||
EffectTireMark effect;
|
||||
} /* 0x3DF0 */ tireMarks[TIRE_MARK_COUNT];
|
||||
} EffectContext; // size = 0x98E0
|
||||
|
||||
EffectContext sEffectContext;
|
||||
|
||||
EffectInfo sEffectInfoTable[] = {
|
||||
typedef struct EffectInfo {
|
||||
/* 0x00 */ u32 size;
|
||||
/* 0x04 */ void (*init)(void* effect, void* initParams);
|
||||
/* 0x08 */ void (*destroy)(void* effect);
|
||||
/* 0x0C */ s32 (*update)(void* effect);
|
||||
/* 0x10 */ void (*draw)(void* effect, struct GraphicsContext* gfxCtx);
|
||||
} EffectInfo; // size = 0x14
|
||||
|
||||
EffectInfo sEffectInfoTable[EFFECT_MAX] = {
|
||||
{
|
||||
sizeof(EffectSpark),
|
||||
EffectSpark_Init,
|
||||
@@ -116,7 +158,7 @@ void Effect_Init(PlayState* play) {
|
||||
sEffectContext.play = play;
|
||||
}
|
||||
|
||||
void Effect_Add(PlayState* play, s32* pIndex, s32 type, u8 arg3, u8 arg4, void* initParams) {
|
||||
void Effect_Add(PlayState* play, s32* pIndex, EffectType type, u8 arg3, u8 arg4, void* initParams) {
|
||||
u32 slotFound;
|
||||
s32 i;
|
||||
void* effect = NULL;
|
||||
@@ -138,6 +180,7 @@ void Effect_Add(PlayState* play, s32* pIndex, s32 type, u8 arg3, u8 arg4, void*
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EFFECT_BLURE1:
|
||||
case EFFECT_BLURE2:
|
||||
for (i = 0; i < BLURE_COUNT; i++) {
|
||||
@@ -150,6 +193,7 @@ void Effect_Add(PlayState* play, s32* pIndex, s32 type, u8 arg3, u8 arg4, void*
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EFFECT_SHIELD_PARTICLE:
|
||||
for (i = 0; i < SHIELD_PARTICLE_COUNT; i++) {
|
||||
if (sEffectContext.shieldParticles[i].status.active == false) {
|
||||
@@ -161,6 +205,7 @@ void Effect_Add(PlayState* play, s32* pIndex, s32 type, u8 arg3, u8 arg4, void*
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EFFECT_TIRE_MARK:
|
||||
for (i = 0; i < TIRE_MARK_COUNT; i++) {
|
||||
if (sEffectContext.tireMarks[i].status.active == false) {
|
||||
@@ -172,6 +217,9 @@ void Effect_Add(PlayState* play, s32* pIndex, s32 type, u8 arg3, u8 arg4, void*
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (slotFound) {
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
#include "global.h"
|
||||
#include "z64effect_ss.h"
|
||||
|
||||
#include "tha.h"
|
||||
#include "loadfragment.h"
|
||||
#include "z64malloc.h"
|
||||
#include "global.h"
|
||||
|
||||
void EffectSS_ResetEntry(EffectSs* particle);
|
||||
|
||||
EffectSsInfo sEffectSsInfo = { NULL, 0, 0 };
|
||||
|
||||
@@ -9,11 +14,11 @@ void EffectSS_Init(PlayState* play, s32 numEntries) {
|
||||
EffectSs* effectsSs;
|
||||
EffectSsOverlay* overlay;
|
||||
|
||||
sEffectSsInfo.data_table = (EffectSs*)THA_AllocTailAlign16(&play->state.tha, numEntries * sizeof(EffectSs));
|
||||
sEffectSsInfo.dataTable = (EffectSs*)THA_AllocTailAlign16(&play->state.tha, numEntries * sizeof(EffectSs));
|
||||
sEffectSsInfo.searchIndex = 0;
|
||||
sEffectSsInfo.size = numEntries;
|
||||
|
||||
for (effectsSs = &sEffectSsInfo.data_table[0]; effectsSs < &sEffectSsInfo.data_table[sEffectSsInfo.size];
|
||||
for (effectsSs = &sEffectSsInfo.dataTable[0]; effectsSs < &sEffectSsInfo.dataTable[sEffectSsInfo.size];
|
||||
effectsSs++) {
|
||||
EffectSS_ResetEntry(effectsSs);
|
||||
}
|
||||
@@ -31,12 +36,12 @@ void EffectSS_Clear(PlayState* play) {
|
||||
EffectSsOverlay* overlay;
|
||||
void* addr;
|
||||
|
||||
sEffectSsInfo.data_table = NULL;
|
||||
sEffectSsInfo.dataTable = NULL;
|
||||
sEffectSsInfo.searchIndex = 0;
|
||||
sEffectSsInfo.size = 0;
|
||||
|
||||
//! @bug: Effects left in the table are not properly deleted, as data_table was just set to NULL and size to 0
|
||||
for (effectsSs = &sEffectSsInfo.data_table[0]; effectsSs < &sEffectSsInfo.data_table[sEffectSsInfo.size];
|
||||
//! @bug: Effects left in the table are not properly deleted, as dataTable was just set to NULL and size to 0
|
||||
for (effectsSs = &sEffectSsInfo.dataTable[0]; effectsSs < &sEffectSsInfo.dataTable[sEffectSsInfo.size];
|
||||
effectsSs++) {
|
||||
EffectSS_Delete(effectsSs);
|
||||
}
|
||||
@@ -55,7 +60,7 @@ void EffectSS_Clear(PlayState* play) {
|
||||
}
|
||||
|
||||
EffectSs* EffectSS_GetTable() {
|
||||
return sEffectSsInfo.data_table;
|
||||
return sEffectSsInfo.dataTable;
|
||||
}
|
||||
|
||||
void EffectSS_Delete(EffectSs* effectSs) {
|
||||
@@ -103,7 +108,7 @@ s32 EffectSS_FindFreeSpace(s32 priority, s32* tableEntry) {
|
||||
i = sEffectSsInfo.searchIndex;
|
||||
foundFree = false;
|
||||
while (true) {
|
||||
if (sEffectSsInfo.data_table[i].life == -1) {
|
||||
if (sEffectSsInfo.dataTable[i].life == -1) {
|
||||
foundFree = true;
|
||||
break;
|
||||
}
|
||||
@@ -130,8 +135,8 @@ s32 EffectSS_FindFreeSpace(s32 priority, s32* tableEntry) {
|
||||
i = sEffectSsInfo.searchIndex;
|
||||
while (true) {
|
||||
// Equal priority should only be considered "lower" if flag 0 is set
|
||||
if ((priority <= sEffectSsInfo.data_table[i].priority) &&
|
||||
!((priority == sEffectSsInfo.data_table[i].priority) && (sEffectSsInfo.data_table[i].flags & 1))) {
|
||||
if ((priority <= sEffectSsInfo.dataTable[i].priority) &&
|
||||
!((priority == sEffectSsInfo.dataTable[i].priority) && (sEffectSsInfo.dataTable[i].flags & 1))) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -157,7 +162,7 @@ void EffectSS_Copy(PlayState* play, EffectSs* effectsSs) {
|
||||
if (FrameAdvance_IsEnabled(&play->state) != true) {
|
||||
if (EffectSS_FindFreeSpace(effectsSs->priority, &index) == 0) {
|
||||
sEffectSsInfo.searchIndex = index + 1;
|
||||
sEffectSsInfo.data_table[index] = *effectsSs;
|
||||
sEffectSsInfo.dataTable[index] = *effectsSs;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,19 +204,19 @@ void EffectSs_Spawn(PlayState* play, s32 type, s32 priority, void* initData) {
|
||||
|
||||
if (initInfo->init != NULL) {
|
||||
// Delete the previous effect in the slot, in case the slot wasn't free
|
||||
EffectSS_Delete(&sEffectSsInfo.data_table[index]);
|
||||
EffectSS_Delete(&sEffectSsInfo.dataTable[index]);
|
||||
|
||||
sEffectSsInfo.data_table[index].type = type;
|
||||
sEffectSsInfo.data_table[index].priority = priority;
|
||||
sEffectSsInfo.dataTable[index].type = type;
|
||||
sEffectSsInfo.dataTable[index].priority = priority;
|
||||
|
||||
if (initInfo->init(play, index, &sEffectSsInfo.data_table[index], initData) == 0) {
|
||||
EffectSS_ResetEntry(&sEffectSsInfo.data_table[index]);
|
||||
if (initInfo->init(play, index, &sEffectSsInfo.dataTable[index], initData) == 0) {
|
||||
EffectSS_ResetEntry(&sEffectSsInfo.dataTable[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EffectSS_UpdateParticle(PlayState* play, s32 index) {
|
||||
EffectSs* particle = &sEffectSsInfo.data_table[index];
|
||||
EffectSs* particle = &sEffectSsInfo.dataTable[index];
|
||||
|
||||
if (particle->update != NULL) {
|
||||
particle->velocity.x += particle->accel.x;
|
||||
@@ -230,22 +235,22 @@ void EffectSS_UpdateAllParticles(PlayState* play) {
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < sEffectSsInfo.size; i++) {
|
||||
if (sEffectSsInfo.data_table[i].life > -1) {
|
||||
sEffectSsInfo.data_table[i].life--;
|
||||
if (sEffectSsInfo.dataTable[i].life > -1) {
|
||||
sEffectSsInfo.dataTable[i].life--;
|
||||
|
||||
if (sEffectSsInfo.data_table[i].life < 0) {
|
||||
EffectSS_Delete(&sEffectSsInfo.data_table[i]);
|
||||
if (sEffectSsInfo.dataTable[i].life < 0) {
|
||||
EffectSS_Delete(&sEffectSsInfo.dataTable[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (sEffectSsInfo.data_table[i].life > -1) {
|
||||
if (sEffectSsInfo.dataTable[i].life > -1) {
|
||||
EffectSS_UpdateParticle(play, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EffectSS_DrawParticle(PlayState* play, s32 index) {
|
||||
EffectSs* entry = &sEffectSsInfo.data_table[index];
|
||||
EffectSs* entry = &sEffectSsInfo.dataTable[index];
|
||||
|
||||
if (entry->draw != NULL) {
|
||||
entry->draw(play, index, entry);
|
||||
@@ -260,14 +265,14 @@ void EffectSS_DrawAllParticles(PlayState* play) {
|
||||
Lights_Draw(lights, play->state.gfxCtx);
|
||||
|
||||
for (i = 0; i < sEffectSsInfo.size; i++) {
|
||||
if (sEffectSsInfo.data_table[i].life > -1) {
|
||||
if ((sEffectSsInfo.data_table[i].pos.x > BGCHECK_Y_MAX) ||
|
||||
(sEffectSsInfo.data_table[i].pos.x < BGCHECK_Y_MIN) ||
|
||||
(sEffectSsInfo.data_table[i].pos.y > BGCHECK_Y_MAX) ||
|
||||
(sEffectSsInfo.data_table[i].pos.y < BGCHECK_Y_MIN) ||
|
||||
(sEffectSsInfo.data_table[i].pos.z > BGCHECK_Y_MAX) ||
|
||||
(sEffectSsInfo.data_table[i].pos.z < BGCHECK_Y_MIN)) {
|
||||
EffectSS_Delete(&sEffectSsInfo.data_table[i]);
|
||||
if (sEffectSsInfo.dataTable[i].life > -1) {
|
||||
if ((sEffectSsInfo.dataTable[i].pos.x > BGCHECK_Y_MAX) ||
|
||||
(sEffectSsInfo.dataTable[i].pos.x < BGCHECK_Y_MIN) ||
|
||||
(sEffectSsInfo.dataTable[i].pos.y > BGCHECK_Y_MAX) ||
|
||||
(sEffectSsInfo.dataTable[i].pos.y < BGCHECK_Y_MIN) ||
|
||||
(sEffectSsInfo.dataTable[i].pos.z > BGCHECK_Y_MAX) ||
|
||||
(sEffectSsInfo.dataTable[i].pos.z < BGCHECK_Y_MIN)) {
|
||||
EffectSS_Delete(&sEffectSsInfo.dataTable[i]);
|
||||
} else {
|
||||
EffectSS_DrawParticle(play, i);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "z64effect.h"
|
||||
#include "z64effect_ss.h"
|
||||
#include "segment_symbols.h"
|
||||
|
||||
// Init Vars and linker symbol declarations (used in the table below)
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#define DEFINE_EFFECT_SS_UNSET(_enumValue) { 0 },
|
||||
|
||||
EffectSsOverlay gParticleOverlayTable[] = {
|
||||
EffectSsOverlay gParticleOverlayTable[EFFECT_SS_MAX] = {
|
||||
#include "tables/effect_ss_table.h"
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#include "z64effect_ss.h"
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "overlays/effects/ovl_Effect_En_Ice_Block/z_eff_en_ice_block.h"
|
||||
#include "overlays/effects/ovl_Effect_Ss_Blast/z_eff_ss_blast.h"
|
||||
#include "overlays/effects/ovl_Effect_Ss_Bomb2/z_eff_ss_bomb2.h"
|
||||
@@ -177,7 +180,7 @@ void func_800B13D8(Vec3f* srcPos, f32 randScale, Vec3f* newPos, Vec3f* velocity,
|
||||
s16 randAngle;
|
||||
f32 rand = Rand_ZeroOne() * randScale;
|
||||
|
||||
randAngle = (Rand_ZeroOne() * 65536.0f);
|
||||
randAngle = Rand_ZeroOne() * 0x10000;
|
||||
|
||||
*newPos = *srcPos;
|
||||
|
||||
@@ -235,13 +238,13 @@ void EffectSsKirakira_SpawnDispersed(PlayState* play, Vec3f* pos, Vec3f* velocit
|
||||
|
||||
Math_Vec3f_Copy(&initParams.pos, pos);
|
||||
Math_Vec3f_Copy(&initParams.velocity, velocity);
|
||||
initParams.velocity.y = ((Rand_ZeroOne() * initParams.velocity.y) + initParams.velocity.y) * 0.5f;
|
||||
initParams.velocity.y = ((Rand_ZeroOne() * initParams.velocity.y) + initParams.velocity.y) / 2.0f;
|
||||
Math_Vec3f_Copy(&initParams.accel, accel);
|
||||
initParams.accel.y = ((Rand_ZeroOne() * initParams.accel.y) + initParams.accel.y) * 0.5f;
|
||||
initParams.accel.y = ((Rand_ZeroOne() * initParams.accel.y) + initParams.accel.y) / 2.0f;
|
||||
initParams.life = life;
|
||||
initParams.updateMode = 0;
|
||||
initParams.rotSpeed = 0x1518;
|
||||
initParams.yaw = Rand_ZeroOne() * 16384.0f;
|
||||
initParams.yaw = Rand_ZeroOne() * 0x4000;
|
||||
initParams.scale = scale;
|
||||
initParams.primColor = *primColor;
|
||||
initParams.envColor = *envColor;
|
||||
@@ -260,7 +263,7 @@ void EffectSsKirakira_SpawnFocused(PlayState* play, Vec3f* pos, Vec3f* velocity,
|
||||
initParams.life = life;
|
||||
initParams.updateMode = 1;
|
||||
initParams.rotSpeed = 0x1518;
|
||||
initParams.yaw = Rand_ZeroOne() * 16384.0f;
|
||||
initParams.yaw = Rand_ZeroOne() * 0x4000;
|
||||
initParams.scale = scale;
|
||||
Color_RGBA8_Copy(&initParams.primColor, primColor);
|
||||
Color_RGBA8_Copy(&initParams.envColor, envColor);
|
||||
|
||||
Reference in New Issue
Block a user