Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
flower_splash.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000E08_32DCC8[];
5
9void flower_splash_appendGfx(void* effect);
10
12 Matrix4f transformMtx;
13 Matrix4f tempMtx;
14
15 guRotateF(transformMtx, effect->rot.x, 1.0f, 0.0f, 0.0f);
16 guRotateF(tempMtx, effect->rot.z, 0.0f, 0.0f, 1.0f);
17 guMtxCatF(tempMtx, transformMtx, transformMtx);
18 guRotateF(tempMtx, effect->rot.y, 0.0f, 1.0f, 0.0f);
19 guMtxCatF(transformMtx, tempMtx, transformMtx);
20 guScaleF(tempMtx, effect->scale.x, effect->scale.y, effect->scale.z);
21 guMtxCatF(tempMtx, transformMtx, transformMtx);
22 guTranslateF(tempMtx, effect->pos.x, effect->pos.y, effect->pos.z);
23 guMtxCatF(transformMtx, tempMtx, transformMtx);
24 guMtxF2L(transformMtx, &effect->transformMtx);
25}
26
28 effect->velScaleA *= 0.85;
29 effect->pos.x += effect->velScaleA * effect->vel.x;
30 effect->integrator[2] += effect->integrator[3];
31 effect->integrator[1] += effect->integrator[2];
32 effect->integrator[0] += effect->integrator[1];
33 effect->pos.y += effect->integrator[0];
34 effect->pos.z += effect->velScaleA * effect->vel.z;
35
36 if (effect->integrator[0] < 0.0f) {
37 effect->integrator[2] = 0.004f;
38 }
39
40 effect->rot.x -= 1.0f;
41 if (effect->rot.x < -100.0f) {
42 effect->rot.x = -100.0f;
43 }
44}
45
46void flower_splash_main(f32 posX, f32 posY, f32 posZ, f32 angle) {
48 EffectInstance* effect;
49 FlowerFXData* part;
50 s32 numParts = 5;
51 f32 partAngle;
52 s32 i;
53
57 bp.unk_00 = 0;
58 bp.renderUI = NULL;
59 bp.effectID = EFFECT_FLOWER_SPLASH;
60
61 effect = create_effect_instance(&bp);
62 effect->numParts = numParts;
63
64 part = effect->data.flowerSplash = general_heap_malloc(numParts * sizeof(*part));
65 ASSERT(effect->data.flowerSplash != NULL);
66
67 mem_clear(part, numParts * sizeof(*part));
68
69 for (i = 0; i < numParts; i++, part++) {
70 part->alive = TRUE;
71 part->rot.y = angle + (i * 72);
72 part->velScaleB = 0.29999998f;
73 part->visibilityAmt = 0.0f;
74 part->unk_7C = 0.0f;
75
76 part->pos.x = posX;
77 part->pos.y = posY;
78 part->pos.z = posZ;
79
80 part->scale.x = 1.0f;
81 part->scale.y = 1.0f;
82 part->scale.z = 1.0f;
83
84 part->primAlpha = 255;
85 part->timeLeft = 60;
86
87 part->rot.x = 0.0f;
88 part->rot.z = 0.0f;
89
90 part->integrator[0] = 1.75f;
91 part->integrator[1] = -0.08f;
92 part->integrator[2] = 0.0f;
93 part->integrator[3] = 0.0f;
94
95 part->velScaleA = -3.9f;
96 partAngle = clamp_angle(part->rot.y);
97 part->vel.x = sin_deg(partAngle);
98 part->vel.z = cos_deg(partAngle);
99 }
100}
101
104
106 FlowerFXData* data = effect->data.flowerSplash;
107 s32 anyAlive = FALSE;
108 s32 i;
109
110 for (i = 0; i < effect->numParts; i++, data++) {
111 if (data->alive) {
112 data->timeLeft--;
113 if (data->timeLeft <= 0) {
114 data->alive = FALSE;
115 } else {
116 anyAlive = TRUE;
119 }
120 }
121 }
122
123 if (!anyAlive) {
124 remove_effect(effect);
125 }
126}
127
129 RenderTask renderTask;
130 RenderTask* retTask;
131
133 renderTask.appendGfxArg = effect;
134 renderTask.dist = 0;
136
137 retTask = queue_render_task(&renderTask);
139}
140
142 remove_effect(effect);
143}
144
145void flower_splash_appendGfx(void* effect) {
146 EffectInstance* effectTemp = effect;
147 FlowerFXData* data = effectTemp->data.flowerSplash;
148 s32 i;
149
150 gDPPipeSync(gMainGfxPos++);
151 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(effectTemp->graphics->data));
152
153 for (i = 0; i < effectTemp->numParts; i++, data++) {
154 if (data->alive) {
155 Gfx* dlist = D_09000E08_32DCC8;
156
158
159 gDPSetPrimColor(gMainGfxPos++, 0, 0, 112, 96, 24, data->primAlpha);
161 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
162 gSPDisplayList(gMainGfxPos++, dlist);
163 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
164 }
165 }
166 gDPPipeSync(gMainGfxPos++);
167}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define clamp_angle
#define cos_deg
#define create_effect_instance
#define mem_clear
#define guScaleF
f32 integrator[4]
Definition effects.h:77
Vec3f rot
Definition effects.h:71
f32 velScaleA
Definition effects.h:73
struct FlowerFXData * flowerSplash
Definition effects.h:2472
struct EffectGraphics * graphics
Definition effects.h:2606
Mtx transformMtx
Definition effects.h:72
s16 timeLeft
Definition effects.h:65
f32 visibilityAmt
Definition effects.h:75
Vec3f scale
Definition effects.h:70
Vec3f pos
Definition effects.h:69
f32 velScaleB
Definition effects.h:74
EffectData data
Definition effects.h:2605
VecXZf vel
Definition effects.h:78
#define ASSERT(condition)
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_PASS_THROUGH
Definition enums.h:3306
void flower_splash_init(EffectInstance *effect)
void flower_splash_render(EffectInstance *effect)
void flower_splash_appendGfx(void *effect)
Gfx D_09000E08_32DCC8[]
void flower_splash_update_part(FlowerFXData *effect)
void flower_splash_update(EffectInstance *effect)
void flower_splash_main(f32 posX, f32 posY, f32 posZ, f32 angle)
void flower_splash_update_part_transform(FlowerFXData *effect)
void flower_splash_dispose(EffectInstance *effect)
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
void(* renderUI)(EffectInstance *effectInst)
Definition effects.h:2655
void(* init)(EffectInstance *effectInst)
Definition effects.h:2652
void(* update)(EffectInstance *effectInst)
Definition effects.h:2653
void(* renderWorld)(EffectInstance *effectInst)
Definition effects.h:2654
void * appendGfxArg
void(* appendGfx)(void *)
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16