Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
flower_trail.c File Reference

Go to the source code of this file.

Functions

void flower_trail_init (EffectInstance *effect)
 
void flower_trail_update (EffectInstance *effect)
 
void flower_trail_render (EffectInstance *effect)
 
void flower_trail_appendGfx (void *effect)
 
void flower_trail_update_part_transform (FlowerFXData *effect)
 
void flower_trail_update_part (FlowerFXData *effect)
 
void flower_trail_main (s32 triggeredByNpc, f32 posX, f32 posY, f32 posZ, f32 angle, f32 direction)
 
void flower_trail_dispose (EffectInstance *effect)
 

Variables

Gfx D_09000E20_32DCE0 []
 
Gfx D_09000E38_32DCF8 []
 

Function Documentation

◆ flower_trail_init()

void flower_trail_init ( EffectInstance * effect)

Definition at line 118 of file flower_trail.c.

118 {
119}

Referenced by flower_trail_main().

◆ flower_trail_update()

void flower_trail_update ( EffectInstance * effect)

Definition at line 121 of file flower_trail.c.

121 {
122 FlowerFXData* part = effect->data.flowerTrail;
123 s32 anyAlive = FALSE;
124 s32 i;
125
126 for (i = 0; i < effect->numParts; i++, part++) {
127 if (part->alive) {
128 part->timeLeft--;
129 if (part->timeLeft <= 0) {
130 part->alive = FALSE;
131 } else {
132 anyAlive = TRUE;
135 }
136 }
137 }
138
139 if (!anyAlive) {
140 remove_effect(effect);
141 }
142}
#define remove_effect
struct FlowerFXData * flowerTrail
Definition effects.h:2473
s16 timeLeft
Definition effects.h:65
EffectData data
Definition effects.h:2605
void flower_trail_update_part(FlowerFXData *effect)
void flower_trail_update_part_transform(FlowerFXData *effect)

Referenced by flower_trail_main().

◆ flower_trail_render()

void flower_trail_render ( EffectInstance * effect)

Definition at line 144 of file flower_trail.c.

144 {
145 RenderTask renderTask;
146 RenderTask* queuedTaskPtr;
147
149 renderTask.appendGfxArg = effect;
150 renderTask.dist = 0;
152
153 queuedTaskPtr = queue_render_task(&renderTask);
155}
#define queue_render_task
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_PASS_THROUGH
Definition enums.h:3306
void flower_trail_appendGfx(void *effect)
void * appendGfxArg
void(* appendGfx)(void *)

Referenced by flower_trail_main().

◆ flower_trail_appendGfx()

void flower_trail_appendGfx ( void * effect)

Definition at line 161 of file flower_trail.c.

161 {
162 EffectInstance* effect = argEffect;
163 FlowerFXData* part = effect->data.flowerTrail;
164 Gfx* dlist;
165 s32 i;
166
167 gDPPipeSync(gMainGfxPos++);
168 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(effect->graphics->data));
169
170 for (i = 0; i < effect->numParts; i++, part++) {
171 if (part->alive) {
172 if (part->useAltColor) {
173 dlist = D_09000E20_32DCE0;
174 } else {
175 dlist = D_09000E38_32DCF8;
176 }
177
179
180 gDPPipeSync(gMainGfxPos++);
181 gDPSetPrimColor(gMainGfxPos++, 0, 0, 112, 96, 24, part->primAlpha);
183 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
184 gSPDisplayList(gMainGfxPos++, dlist);
185 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
186 }
187 }
188 gDPPipeSync(gMainGfxPos++);
189}
Mtx matrixStack[0x200]
s8 useAltColor
Definition effects.h:67
struct EffectGraphics * graphics
Definition effects.h:2606
Mtx transformMtx
Definition effects.h:72
Gfx D_09000E20_32DCE0[]
Gfx D_09000E38_32DCF8[]
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16

Referenced by flower_trail_render().

◆ flower_trail_update_part_transform()

void flower_trail_update_part_transform ( FlowerFXData * effect)

Definition at line 12 of file flower_trail.c.

12 {
13 Matrix4f transformMtx;
14 Matrix4f tempMtx;
15
16 guRotateF(transformMtx, effect->rot.x, 1.0f, 0.0f, 0.0f);
17 guRotateF(tempMtx, effect->rot.z, 0.0f, 0.0f, 1.0f);
18 guMtxCatF(tempMtx, transformMtx, transformMtx);
19 guRotateF(tempMtx, effect->rot.y, 0.0f, 1.0f, 0.0f);
20 guMtxCatF(transformMtx, tempMtx, transformMtx);
21 guScaleF(tempMtx, effect->scale.x, effect->scale.y, effect->scale.z);
22 guMtxCatF(tempMtx, transformMtx, transformMtx);
23 guTranslateF(tempMtx, effect->pos.x, effect->pos.y, effect->pos.z);
24 guMtxCatF(transformMtx, tempMtx, transformMtx);
25 guMtxF2L(transformMtx, &effect->transformMtx);
26}
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define guScaleF
Vec3f rot
Definition effects.h:71
Vec3f scale
Definition effects.h:70
Vec3f pos
Definition effects.h:69

Referenced by flower_trail_update().

◆ flower_trail_update_part()

void flower_trail_update_part ( FlowerFXData * effect)

Definition at line 28 of file flower_trail.c.

28 {
29 if (!effect->triggeredByNpc && effect->visibilityAmt != 0.0f && gPlayerStatus.actionState == ACTION_STATE_IDLE) {
30 effect->timeLeft++;
31 return;
32 }
33
34 effect->primAlpha -= 12;
35 effect->integrator[2] += effect->integrator[3];
36 effect->integrator[1] += effect->integrator[2];
37 effect->integrator[0] += effect->integrator[1];
38 effect->rot.z += effect->integrator[0] * effect->velScaleA;
39 effect->pos.x -= effect->integrator[0] * effect->velScaleB * effect->vel.x;
40 effect->pos.z -= effect->integrator[0] * effect->velScaleB * effect->vel.z;
41
42 if (effect->integrator[0] < 0.0f) {
43 effect->visibilityAmt = 0.0f;
44 }
45}
f32 integrator[4]
Definition effects.h:77
f32 velScaleA
Definition effects.h:73
u16 triggeredByNpc
Definition effects.h:64
f32 visibilityAmt
Definition effects.h:75
f32 velScaleB
Definition effects.h:74
VecXZf vel
Definition effects.h:78
@ ACTION_STATE_IDLE
Definition enums.h:2426
PlayerStatus gPlayerStatus
Definition 77480.c:39

Referenced by flower_trail_update().

◆ flower_trail_main()

void flower_trail_main ( s32 triggeredByNpc,
f32 posX,
f32 posY,
f32 posZ,
f32 angle,
f32 direction )

Definition at line 47 of file flower_trail.c.

47 {
49 EffectInstance* effect;
50 FlowerFXData* part;
51 s32 numParts = 1;
52 f32 partAngle;
53 f32 angleOffset;
54 s32 i;
55
59 bp.unk_00 = 0;
60 bp.renderUI = NULL;
61 bp.effectID = EFFECT_FLOWER_TRAIL;
62
63 effect = create_effect_instance(&bp);
64 effect->numParts = numParts;
65
66 part = effect->data.flowerTrail = general_heap_malloc(numParts * sizeof(*part));
67 ASSERT(effect->data.flowerTrail != NULL);
68
69 mem_clear(part, numParts * sizeof(*part));
70
71 for (i = 0; i < numParts; i++, part++) {
72 part->alive = TRUE;
73 part->triggeredByNpc = triggeredByNpc;
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
86 part->visibilityAmt = 1.0f;
87 part->velScaleB = 5.4f;
88 if (direction != 0.0f) {
89 part->velScaleA = -10.0f;
90 } else {
91 part->velScaleA = 10.0f;
92 }
93
94 part->integrator[0] = 0.5f;
95 part->integrator[1] = -0.07f;
96 part->integrator[2] = 0.003f;
97 part->integrator[3] = 0;
98
99 part->timeLeft = 15;
100 part->rot.y = angle;
101 part->rot.x = 0.0f;
102 part->rot.z = 0.0f;
103 part->useAltColor = (rand_int(100) >> 4) & 1;
104
105 if (direction != 0.0f) {
106 angleOffset = -90.0f;
107 partAngle = clamp_angle(angle + angleOffset);
108 } else {
109 angleOffset = 90.0f;
110 partAngle = clamp_angle(angle + angleOffset);
111 }
112
113 part->vel.x = sin_deg(partAngle);
114 part->vel.z = cos_deg(partAngle);
115 }
116}
#define general_heap_malloc
#define sin_deg
#define rand_int
#define clamp_angle
#define cos_deg
#define create_effect_instance
#define mem_clear
#define ASSERT(condition)
void flower_trail_render(EffectInstance *effect)
void flower_trail_update(EffectInstance *effect)
void flower_trail_init(EffectInstance *effect)
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

◆ flower_trail_dispose()

void flower_trail_dispose ( EffectInstance * effect)

Definition at line 157 of file flower_trail.c.

157 {
158 remove_effect(effect);
159}

Variable Documentation

◆ D_09000E20_32DCE0

Gfx D_09000E20_32DCE0[]
extern

Referenced by flower_trail_appendGfx().

◆ D_09000E38_32DCF8

Gfx D_09000E38_32DCF8[]
extern

Referenced by flower_trail_appendGfx().