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

Go to the source code of this file.

Functions

void cloud_puff_init (EffectInstance *effect)
 
void cloud_puff_update (EffectInstance *effect)
 
void cloud_puff_render (EffectInstance *effect)
 
void cloud_puff_appendGfx (void *effect)
 
void cloud_puff_main (f32 x, f32 y, f32 z, f32 angle)
 

Variables

Gfx D_090000E0_32ED30 []
 
Gfx D_090001B8_32EE08 []
 

Function Documentation

◆ cloud_puff_init()

void cloud_puff_init ( EffectInstance * effect)

Definition at line 59 of file cloud_puff.c.

59 {
60}

Referenced by cloud_puff_main().

◆ cloud_puff_update()

void cloud_puff_update ( EffectInstance * effect)

Definition at line 62 of file cloud_puff.c.

62 {
63 CloudPuffFXData* part = effect->data.cloudPuff;
64 s32 cond = FALSE;
65 s32 i;
66
67 for (i = 0; i < effect->numParts; i++, part++) {
68 if (part->alive) {
69 part->timeLeft--;
70 if (part->timeLeft <= 0) {
71 part->alive = FALSE;
72 } else {
73 cond = TRUE;
74 part->rescalePhase = clamp_angle(part->rescalePhase + 12.0f);
75 part->scale.x = part->rescaleX + sin_deg(part->rescalePhase) * 0.1;
76 part->scale.y = part->rescaleY + cos_deg(part->rescalePhase) * 0.1;
77 part->radialVel *= 0.83;
78 part->pos.x += part->radialVel * part->dirX;
79 part->pos.z += part->radialVel * part->dirZ;
80 part->rescaleX += (7.5 - part->rescaleX) * 0.006;
81 part->accelY += part->jerkY;
82 part->velY += part->accelY;
83 part->pos.y += part->velY;
84 part->rescaleY *= 0.98;
85
86 if (part->timeLeft < 10) {
87 part->rescaleY *= 0.9;
88 }
89
90 if (part->timeLeft < 15) {
91 part->alpha -= 16;
92 }
93 }
94 }
95 }
96
97 if (!cond) {
98 remove_effect(effect);
99 }
100}
#define sin_deg
#define remove_effect
#define clamp_angle
#define cos_deg
struct CloudPuffFXData * cloudPuff
Definition effects.h:2474
EffectData data
Definition effects.h:2605

Referenced by cloud_puff_main().

◆ cloud_puff_render()

void cloud_puff_render ( EffectInstance * effect)

Definition at line 102 of file cloud_puff.c.

102 {
103 RenderTask renderTask;
104 RenderTask* retTask;
105
106 renderTask.appendGfx = cloud_puff_appendGfx;
107 renderTask.appendGfxArg = effect;
108 renderTask.dist = 0;
110
111 retTask = queue_render_task(&renderTask);
113}
void cloud_puff_appendGfx(void *effect)
Definition cloud_puff.c:115
#define queue_render_task
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_PASS_THROUGH
Definition enums.h:3306
void * appendGfxArg
void(* appendGfx)(void *)

Referenced by cloud_puff_main().

◆ cloud_puff_appendGfx()

void cloud_puff_appendGfx ( void * effect)

Definition at line 115 of file cloud_puff.c.

115 {
116 EffectInstance* effectTemp = effect;
117 CloudPuffFXData* part = effectTemp->data.cloudPuff;
118 Matrix4f sp20;
119 Matrix4f sp60;
120 s32 i;
121
122 gDPPipeSync(gMainGfxPos++);
123 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(effectTemp->graphics->data));
124 gSPDisplayList(gMainGfxPos++, D_090000E0_32ED30);
125
126 for (i = 0; i < effectTemp->numParts; i++, part++) {
127 if (part->alive) {
128 guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f,
129 part->pos.x, part->pos.y, part->pos.z);
130 guScaleF(sp60, part->scale.x, part->scale.y, part->scale.z);
131 guMtxCatF(sp60, sp20, sp20);
133
134 gDPSetPrimColor(gMainGfxPos++, 0, 0, 112, 96, 24, part->alpha);
136 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
137 gSPDisplayList(gMainGfxPos++, D_090001B8_32EE08);
138 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
139 }
140 }
141 gDPPipeSync(gMainGfxPos++);
142}
Gfx D_090000E0_32ED30[]
Gfx D_090001B8_32EE08[]
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guMtxF2L
#define guMtxCatF
#define guPositionF
#define guScaleF
struct EffectGraphics * graphics
Definition effects.h:2606
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Camera gCameras[4]
Definition cam_main.c:17
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
s32 gCurrentCameraID
Definition cam_math.c:4
DisplayContext * gDisplayContext
Definition cam_main.c:16

Referenced by cloud_puff_render().

◆ cloud_puff_main()

void cloud_puff_main ( f32 x,
f32 y,
f32 z,
f32 angle )

Definition at line 12 of file cloud_puff.c.

12 {
14 EffectInstance* effect;
15 f32 radialAngle;
16 CloudPuffFXData* part;
17 s32 numParts = 8;
18 s32 i;
19
20 bp.unk_00 = 0;
24 bp.renderUI = NULL;
25 bp.effectID = EFFECT_CLOUD_PUFF;
26
27 effect = create_effect_instance(&bp);
28 effect->numParts = numParts;
29 part = general_heap_malloc(numParts * sizeof(*part));
30 effect->data.cloudPuff = part;
31 ASSERT(effect->data.cloudPuff != NULL);
32
33 mem_clear(part, numParts * sizeof(*part));
34
35 for (i = 0; i < numParts; i++, part++) {
36 part->alive = TRUE;
37 part->unk_40 = 0;
38 part->pos.x = x;
39 part->pos.y = y;
40 part->pos.z = z;
41 part->scale.x = 1.0f;
42 part->scale.y = 1.0f;
43 part->scale.z = 1.0f;
44 part->alpha = 255;
45 part->rescaleX = (rand_int(10) * 0.03) + 1.0;
46 part->rescaleY = (rand_int(10) * 0.03) + 1.7;
47 part->rescalePhase = effect_rand_int(60);
48 part->timeLeft = 30;
49 part->velY = 0.5f;
50 part->accelY = -0.02f;
51 part->jerkY = 0.00005f;
52 part->radialVel = -3.9f;
53 radialAngle = clamp_angle(angle + i * 45);
54 part->dirX = sin_deg(radialAngle);
55 part->dirZ = cos_deg(radialAngle);
56 }
57}
void cloud_puff_update(EffectInstance *effect)
Definition cloud_puff.c:62
void cloud_puff_render(EffectInstance *effect)
Definition cloud_puff.c:102
void cloud_puff_init(EffectInstance *effect)
Definition cloud_puff.c:59
#define general_heap_malloc
#define rand_int
#define create_effect_instance
#define mem_clear
#define ASSERT(condition)
s32 effect_rand_int(s32)
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

Variable Documentation

◆ D_090000E0_32ED30

Gfx D_090000E0_32ED30[]
extern

Referenced by cloud_puff_appendGfx().

◆ D_090001B8_32EE08

Gfx D_090001B8_32EE08[]
extern

Referenced by cloud_puff_appendGfx().