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

Go to the source code of this file.

Data Structures

struct  ShimmerParticle
 
struct  ShimmerEmitter
 

Macros

#define NUM_PARTICLES   56
 

Functions

 INCLUDE_IMG ("ui/status/shimmer_particle.png", ui_status_shimmer_particle_png)
 
void star_power_shimmer_start (s32 emitterIdx, f32 x, f32 y, f32 scale)
 
void star_power_shimmer_init (void)
 
void star_power_shimmer_update (void)
 
void star_power_shimmer_draw (void)
 

Variables

Vp ShimmerViewport
 
u8 AnimatedScale []
 
Vec2b InitialVelocities [56]
 
BSS ShimmerEmitter ShimmerEmitters [1]
 

Data Structure Documentation

◆ ShimmerParticle

struct ShimmerParticle
Data Fields
u8 alive
s8 timeLeft
u8 lifetime
Color_RGBA8 rgba
s8 animTime
Vec2f pos
Vec2f vel
f32 scale

◆ ShimmerEmitter

struct ShimmerEmitter
Data Fields
ShimmerParticle particles[1+56]

Macro Definition Documentation

◆ NUM_PARTICLES

#define NUM_PARTICLES   56

Definition at line 18 of file status_star_shimmer.c.

Function Documentation

◆ INCLUDE_IMG()

INCLUDE_IMG ( "ui/status/shimmer_particle.png" ,
ui_status_shimmer_particle_png  )

◆ star_power_shimmer_start()

void star_power_shimmer_start ( s32 emitterIdx,
f32 x,
f32 y,
f32 scale )

Definition at line 51 of file status_star_shimmer.c.

51 {
52 ShimmerEmitter* emitter = &ShimmerEmitters[emitterIdx];
53 ShimmerParticle* particle = &emitter->particles[0];
54 s32 numParticles = ARRAY_COUNT(emitter->particles);
55 s32 j;
56
57 if (emitterIdx < ARRAY_COUNT(ShimmerEmitters)) {
58 particle->alive = TRUE;
59 particle->pos.x = x;
60 particle->pos.y = y;
61 particle->scale = scale;
62 particle->timeLeft = 40;
63 particle->lifetime = 0;
64 particle = &emitter->particles[1];
65
66 for (j = 1; j < numParticles; j++, particle++) {
67 particle->animTime = (s32) (-((f32) j) * 0.0f) - 1;
68 }
69 }
70}
#define ARRAY_COUNT(arr)
Definition macros.h:40
BSS ShimmerEmitter ShimmerEmitters[1]
ShimmerParticle particles[1+56]

Referenced by update_status_bar().

◆ star_power_shimmer_init()

void star_power_shimmer_init ( void )

Definition at line 72 of file status_star_shimmer.c.

72 {
73 s32 i;
74
75 for (i = 0; i < ARRAY_COUNT(ShimmerEmitters); i++) {
76 ShimmerEmitters[i].particles[0].alive = FALSE;
77 }
78}

Referenced by initialize_status_bar().

◆ star_power_shimmer_update()

void star_power_shimmer_update ( void )

Definition at line 80 of file status_star_shimmer.c.

80 {
81 ShimmerEmitter* emitter;
82 ShimmerParticle* particle;
83 s32 emitterTimeLeft;
84 f32 emitterX;
85 f32 emitterY;
86 s32 i, j;
87
88 for (i = 0; i < ARRAY_COUNT(ShimmerEmitters); i++, emitter++) {
89 emitter = &ShimmerEmitters[i];
90
91 if (!emitter->particles[0].alive) {
92 continue;
93 }
94
95 emitter->particles[0].timeLeft--;
96 emitter->particles[0].lifetime++;
97
98 if (emitter->particles[0].timeLeft < 0) {
99 emitter->particles[0].alive = FALSE;
100 continue;
101 }
102
103 emitterTimeLeft = emitter->particles[0].timeLeft;
104 emitterX = emitter->particles[0].pos.x;
105 emitterY = emitter->particles[0].pos.y;
106
107 particle = &emitter->particles[1];
108 for (j = 1; j < ARRAY_COUNT(emitter->particles); j++, particle++) {
109 particle->animTime++;
110 if (particle->animTime >= ARRAY_COUNT(AnimatedScale)) {
111 if (emitterTimeLeft < 30) {
112 particle->animTime = -31;
113 } else {
114 particle->animTime = 0;
115 }
116 }
117
118 if (particle->animTime < 0) {
119 continue;
120 }
121
122 if (particle->animTime == 0) {
123 f32 initialVelX = InitialVelocities[j - 1].x;
124 f32 initialVelY = InitialVelocities[j - 1].y;
125 s8 t = 127;
126
127 particle->vel.x = initialVelX * 0.1;
128 particle->vel.y = -initialVelY * 0.1;
129 particle->pos.x = emitterX;
130 particle->pos.y = emitterY;
131 particle->scale = 1.0f;
132 particle->rgba.r = rand_int(t);
133 particle->rgba.g = rand_int(t - particle->rgba.r);
134 particle->rgba.b = rand_int(t - particle->rgba.g - particle->rgba.r);
135 particle->rgba.a = 255;
136 particle->rgba.r += 128;
137 particle->rgba.g += 128;
138 particle->rgba.b += 128;
139 }
140
141 particle->pos.x += particle->vel.x;
142 particle->pos.y += particle->vel.y;
143 particle->vel.x *= 0.92;
144 particle->vel.y *= 0.92;
145 particle->scale = (f32) AnimatedScale[particle->animTime] * 0.04;
146 }
147 }
148}
#define rand_int
u8 AnimatedScale[]
Vec2b InitialVelocities[56]

Referenced by update_status_bar().

◆ star_power_shimmer_draw()

void star_power_shimmer_draw ( void )

Definition at line 151 of file status_star_shimmer.c.

151 {
152 Matrix4f viewMtx, transformMtx;
153 ShimmerEmitter* emitter;
154 ShimmerParticle* particle;
155 f32 emitterScale;
156 s32 i, j;
157
158 gDPPipeSync(gMainGfxPos++);
159 gSPSegment(gMainGfxPos++, 0x00, 0x00000000);
160 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
161 gSPViewport(gMainGfxPos++, &ShimmerViewport);
162
163 guOrthoF(viewMtx, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, -100.0f, 100.0f, 1.0f);
165
166 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
167 gSPDisplayList(gMainGfxPos++, D_80109710); // setup texture
168 gDPSetEnvColor(gMainGfxPos++, 127, 127, 127, 127);
169
170 for (i = 0; i < ARRAY_COUNT(ShimmerEmitters); i++, emitter++) {
171 emitter = &ShimmerEmitters[i];
172
173 if (emitter->particles[0].alive) {
174 emitterScale = emitter->particles[0].scale;
175
176 particle = &emitter->particles[1];
177 for (j = 1; j < ARRAY_COUNT(emitter->particles); j++, particle++) {
178 if (particle->animTime >= 0) {
179 guPositionF(transformMtx, 0.0f, 0.0f, gGameStatusPtr->frameCounter * 10, particle->scale * emitterScale,
180 particle->pos.x, particle->pos.y, 0.0f);
182
184 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
185 gDPSetPrimColor(gMainGfxPos++, 0, 80 - particle->animTime, particle->rgba.r, particle->rgba.g, particle->rgba.b, particle->rgba.a);
186 gSPDisplayList(gMainGfxPos++, D_801097D8); // draw particle
187 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
188 }
189 }
190 }
191 }
192}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guOrthoF
#define guMtxF2L
#define guPositionF
#define SCREEN_WIDTH
Definition macros.h:109
#define SCREEN_HEIGHT
Definition macros.h:110
Vp ShimmerViewport
GameStatus * gGameStatusPtr
Definition main_loop.c:32
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16

Referenced by update_status_bar().

Variable Documentation

◆ ShimmerViewport

Vp ShimmerViewport
Initial value:
= {
.vp = {
.vscale = { 640, 480, 511, 0 },
.vtrans = { 640, 480, 511, 0 }
}
}

Definition at line 6 of file status_star_shimmer.c.

6 {
7 .vp = {
8 .vscale = { 640, 480, 511, 0 },
9 .vtrans = { 640, 480, 511, 0 }
10 }
11};

Referenced by star_power_shimmer_draw().

◆ AnimatedScale

u8 AnimatedScale[]
Initial value:
= {
40, 90, 81, 72, 65, 59, 53, 47, 43, 38, 34, 31, 28, 25, 22, 20, 18, 16, 15, 13, 12, 10, 9, 8, 7, 7, 6, 5, 5, 4
}

Definition at line 20 of file status_star_shimmer.c.

20 {
21 40, 90, 81, 72, 65, 59, 53, 47, 43, 38, 34, 31, 28, 25, 22, 20, 18, 16, 15, 13, 12, 10, 9, 8, 7, 7, 6, 5, 5, 4
22};

Referenced by star_power_shimmer_update().

◆ InitialVelocities

Vec2b InitialVelocities[56]
Initial value:
= {
{ 247, 105 }, { 239, 87 }, { 17, 87 }, { 9, 105 }, { 0, 122 }, { 230, 69 }, { 26, 69 }, { 221, 52 }, { 35, 52 },
{ 202, 49 }, { 186, 255 }, { 200, 241 }, { 0, 200 }, { 56, 241 }, { 70, 255 }, { 54, 49 }, { 196, 222 },
{ 239, 191 }, { 17, 191 }, { 60, 222 }, { 85, 13 }, { 74, 46 }, { 99, 27 }, { 93, 43 }, { 12, 33 }, { 12, 22 },
{ 24, 22 }, { 24, 33 }, { 12, 10 }, { 24, 10 }, { 24, 45 }, { 232, 33 }, { 232, 22 }, { 232, 45 }, { 113, 40 },
{ 193, 203 }, { 190, 183 }, { 182, 46 }, { 163, 43 }, { 35, 182 }, { 52, 173 }, { 12, 45 }, { 244, 22 },
{ 244, 33 }, { 232, 10 }, { 244, 10 }, { 244, 45 }, { 204, 173 }, { 221, 182 }, { 186, 164 }, { 171, 13 },
{ 157, 27 }, { 143, 40 }, { 63, 203 }, { 66, 183 }, { 70, 164 }
}

Definition at line 24 of file status_star_shimmer.c.

24 {
25 { 247, 105 }, { 239, 87 }, { 17, 87 }, { 9, 105 }, { 0, 122 }, { 230, 69 }, { 26, 69 }, { 221, 52 }, { 35, 52 },
26 { 202, 49 }, { 186, 255 }, { 200, 241 }, { 0, 200 }, { 56, 241 }, { 70, 255 }, { 54, 49 }, { 196, 222 },
27 { 239, 191 }, { 17, 191 }, { 60, 222 }, { 85, 13 }, { 74, 46 }, { 99, 27 }, { 93, 43 }, { 12, 33 }, { 12, 22 },
28 { 24, 22 }, { 24, 33 }, { 12, 10 }, { 24, 10 }, { 24, 45 }, { 232, 33 }, { 232, 22 }, { 232, 45 }, { 113, 40 },
29 { 193, 203 }, { 190, 183 }, { 182, 46 }, { 163, 43 }, { 35, 182 }, { 52, 173 }, { 12, 45 }, { 244, 22 },
30 { 244, 33 }, { 232, 10 }, { 244, 10 }, { 244, 45 }, { 204, 173 }, { 221, 182 }, { 186, 164 }, { 171, 13 },
31 { 157, 27 }, { 143, 40 }, { 63, 203 }, { 66, 183 }, { 70, 164 }
32};

Referenced by star_power_shimmer_update().

◆ ShimmerEmitters