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

Go to the source code of this file.

Data Structures

struct  UnkBulbGlow
 

Macros

#define TMEM_ADDR(x)   (x / sizeof(u64))
 

Functions

void bulb_glow_init (EffectInstance *effect)
 
void bulb_glow_update (EffectInstance *effect)
 
void bulb_glow_render (EffectInstance *effect)
 
void bulb_glow_appendGfx (void *effect)
 
void bulb_glow_main (s32 arg0, f32 posX, f32 posY, f32 posZ, f32 arg4, EffectInstance **outEffect)
 
void func_E0078274 (void)
 

Variables

Gfx D_09001400_37C1D0 []
 
Gfx D_090014B8_37C288 []
 
Gfx D_09001570_37C340 []
 
Gfx D_09001618_37C3E8 []
 
Gfx D_090016C0_37C490 []
 
Gfx * D_E0078900 []
 
UnkBulbGlow D_E0078918 []
 
s32 D_E00789A8 = 0
 
Color_RGB8 D_E00789AC []
 

Data Structure Documentation

◆ UnkBulbGlow

struct UnkBulbGlow
Data Fields
s32 unk_00
s32 unk_04
f32 unk_08
f32 unk_0C
s32 unk_10
s32 unk_14

Macro Definition Documentation

◆ TMEM_ADDR

#define TMEM_ADDR ( x)    (x / sizeof(u64))

Definition at line 154 of file bulb_glow.c.

Referenced by bulb_glow_appendGfx().

Function Documentation

◆ bulb_glow_init()

void bulb_glow_init ( EffectInstance * effect)

Definition at line 90 of file bulb_glow.c.

90 {
91}

Referenced by bulb_glow_main().

◆ bulb_glow_update()

void bulb_glow_update ( EffectInstance * effect)

Definition at line 93 of file bulb_glow.c.

93 {
94 BulbGlowFXData* data = effect->data.bulbGlow;
95 s32 time;
96
97 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
98 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
99 data->timeLeft = 10;
100 }
101
102 data->lifetime++;
103
104 if (data->timeLeft < 100) {
105 data->timeLeft--;
106 }
107 if (data->timeLeft < 0) {
108 remove_effect(effect);
109 return;
110 }
111
112 time = data->lifetime;
113 if (data->type == 0) {
114 if (time < 11) {
115 data->brightness = (time * 6) + 4;
116 } else {
117 data->brightness = 64;
118 }
119
120 if (time & 1) {
121 data->brightness *= 0.6;
122 }
123
124 if (time >= 15) {
125 data->type = 4;
126 data->brightness = 127;
127 }
128 }
129}
#define remove_effect
struct BulbGlowFXData * bulbGlow
Definition effects.h:2524
EffectData data
Definition effects.h:2605
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517

Referenced by bulb_glow_main().

◆ bulb_glow_render()

void bulb_glow_render ( EffectInstance * effect)

Definition at line 131 of file bulb_glow.c.

131 {
132 BulbGlowFXData* data = effect->data.bulbGlow;
133 RenderTask renderTask;
134 RenderTask* renderTaskPtr = &renderTask;
135 RenderTask* retTask;
136
137 renderTask.appendGfxArg = effect;
138 renderTask.appendGfx = bulb_glow_appendGfx;
139 if (data->type == 5) {
140 renderTask.dist = 0;
141 renderTaskPtr->renderMode = RENDER_MODE_SURFACE_OPA;
142 } else {
143 renderTask.dist = -100;
144 renderTaskPtr->renderMode = RENDER_MODE_CLOUD_NO_ZCMP;
145 }
146
147 retTask = queue_render_task(renderTaskPtr);
149}
void bulb_glow_appendGfx(void *effect)
Definition bulb_glow.c:156
#define queue_render_task
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_SURFACE_OPA
Definition enums.h:3264
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
void * appendGfxArg
void(* appendGfx)(void *)

Referenced by bulb_glow_main().

◆ bulb_glow_appendGfx()

void bulb_glow_appendGfx ( void * effect)

Definition at line 156 of file bulb_glow.c.

156 {
157 BulbGlowFXData* data = ((EffectInstance*)effect)->data.bulbGlow;
158 f32 centerX;
159 f32 centerY;
160 s32 xMin;
161 s32 numRects;
162 s32 yMin;
163 s32 type;
164 s32 rectHeight;
165 s32 glowExtent;
166 s32 colorScale;
167 s32 brightness;
168 s32 yMax;
169 s32 xStart;
170 s32 xMax;
171 s32 isPointVisible;
172 s32 yStart;
173 UnkBulbGlow* temp_s1;
174 Color_RGB8* color;
175 s32 i;
176 s32 j;
177 u8 r, g, b;
178
179 brightness = data->brightness;
180 type = data->type;
181 if (brightness > 127) {
182 brightness = 127;
183 }
184
185 gDPPipeSync(gMainGfxPos++);
186 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
187
188 temp_s1 = &D_E0078918[type];
189 glowExtent = temp_s1->unk_10;
190 rectHeight = temp_s1->unk_14;
191
192 isPointVisible = is_point_visible(data->pos.x, data->pos.y, data->pos.z, data->depthQueryID, &centerX, &centerY);
193
194 if (type == 5) {
195 isPointVisible = TRUE;
196 }
197
198 if (!isPointVisible || centerX < 0.0f || centerY < 0.0f || centerX >= SCREEN_WIDTH || centerY >= SCREEN_HEIGHT) {
199 return;
200 }
201
202 gSPDisplayList(gMainGfxPos++, D_E0078900[type]);
203 color = &D_E00789AC[data->unk_20];
204 colorScale = brightness * 2;
205 r = color->r * colorScale / 255;
206 g = color->g * colorScale / 255;
207 b = color->b * colorScale / 255;
208
209 gDPSetPrimColor(gMainGfxPos++, 0, 0, r, g, b, 127);
210
211 xMin = centerX - glowExtent;
212 xMax = xMin + glowExtent * 2;
213 yMin = centerY - glowExtent;
214 yMax = yMin + glowExtent * 2;
215
216 xStart = 0;
217 if (xMin < 0) {
218 xStart = -xMin;
219 }
220 yStart = 0;
221 if (yMin < 0) {
222 yStart = -yMin;
223 }
224 if (xMax > SCREEN_WIDTH) {
225 xMax = SCREEN_WIDTH - 1;
226 }
227 if (yMax > SCREEN_HEIGHT) {
228 yMax = SCREEN_HEIGHT - 1;
229 }
230
231 numRects = (yMax - yMin) / rectHeight;
232
233 for (i = yStart / rectHeight; i < numRects; i++) {
234 s32 y = yMin + i * rectHeight;
235 if (y + rectHeight >= SCREEN_HEIGHT) {
236 break;
237 }
238
239 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE,
240 (s32) (xMin * temp_s1->unk_08) * 4,
241 (s32) (temp_s1->unk_04 * 20 - i * temp_s1->unk_14 * temp_s1->unk_0C) * 4,
242 (s32) (xMin * temp_s1->unk_08 + temp_s1->unk_00) * 4,
243 (s32) (temp_s1->unk_04 * 21 - i * temp_s1->unk_14 * temp_s1->unk_0C) * 4);
244
245 for (j = 0; j < 1; j++) {
246 gDPLoadMultiTile(gMainGfxPos++,
248 TMEM_ADDR(TMEM_SIZE/2), G_TX_RENDERTILE + 1, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, 0,
249 xMin + xStart, 0, xMax - 1, rectHeight - 1,
250 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 9, 8, G_TX_NOLOD, G_TX_NOLOD);
251 gSPTextureRectangle(gMainGfxPos++,
252 (xMin + xStart) * 4, y * 4,
253 xMax * 4, (y + rectHeight) * 4,
254 G_TX_RENDERTILE,
255 ((xMin + xStart) & 0x1FF) << 5, 0,
256 1 << 10, 1 << 10);
257 gDPPipeSync(gMainGfxPos++);
258 }
259 }
260}
UnkBulbGlow D_E0078918[]
Definition bulb_glow.c:24
Color_RGB8 D_E00789AC[]
Definition bulb_glow.c:35
Gfx * D_E0078900[]
Definition bulb_glow.c:20
#define TMEM_ADDR(x)
Definition bulb_glow.c:154
u16 * nuGfxCfb_ptr
Definition cam_main.c:14
#define is_point_visible
#define SCREEN_WIDTH
Definition macros.h:105
#define TMEM_SIZE
Definition macros.h:121
#define SCREEN_HEIGHT
Definition macros.h:106
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Gfx * gMainGfxPos
Definition cam_main.c:15

Referenced by bulb_glow_render().

◆ bulb_glow_main()

void bulb_glow_main ( s32 arg0,
f32 posX,
f32 posY,
f32 posZ,
f32 arg4,
EffectInstance ** outEffect )

Definition at line 50 of file bulb_glow.c.

50 {
52 EffectInstance* effect;
53 BulbGlowFXData* data;
54 s32 numParts = 1;
55
59 bp.unk_00 = 0;
60 bp.renderUI = NULL;
61 bp.effectID = EFFECT_BULB_GLOW;
62
63 effect = create_effect_instance(&bp);
64 effect->numParts = numParts;
65 data = effect->data.bulbGlow = general_heap_malloc(numParts * sizeof(*data));
66 ASSERT(effect->data.bulbGlow != NULL);
67
68 data->type = arg0 & 255;
69 if (arg0 < 256) {
70 data->timeLeft = 100;
71 } else {
72 data->timeLeft = 80;
73 }
74 data->lifetime = 0;
75 data->brightness = 127;
76 data->pos.x = posX;
77 data->pos.y = posY;
78 data->pos.z = posZ;
80
81 D_E00789A8++;
82 if (D_E00789A8 >= 16) {
83 D_E00789A8 = 0;
84 }
85
86 data->unk_20 = rand_int(7);
87 *outEffect = effect;
88}
void bulb_glow_update(EffectInstance *effect)
Definition bulb_glow.c:93
void bulb_glow_init(EffectInstance *effect)
Definition bulb_glow.c:90
s32 D_E00789A8
Definition bulb_glow.c:33
void bulb_glow_render(EffectInstance *effect)
Definition bulb_glow.c:131
#define general_heap_malloc
#define rand_int
#define create_effect_instance
#define ASSERT(condition)
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

Referenced by lightning_main().

◆ func_E0078274()

void func_E0078274 ( void )

Definition at line 151 of file bulb_glow.c.

151 {
152}

Variable Documentation

◆ D_09001400_37C1D0

Gfx D_09001400_37C1D0[]
extern

◆ D_090014B8_37C288

Gfx D_090014B8_37C288[]
extern

◆ D_09001570_37C340

Gfx D_09001570_37C340[]
extern

◆ D_09001618_37C3E8

Gfx D_09001618_37C3E8[]
extern

◆ D_090016C0_37C490

Gfx D_090016C0_37C490[]
extern

◆ D_E0078900

Gfx* D_E0078900[]
Initial value:
= {
}
Gfx D_09001400_37C1D0[]
Gfx D_09001570_37C340[]
Gfx D_090014B8_37C288[]
Gfx D_09001618_37C3E8[]
Gfx D_090016C0_37C490[]

Definition at line 20 of file bulb_glow.c.

Referenced by bulb_glow_appendGfx().

◆ D_E0078918

UnkBulbGlow D_E0078918[]
Initial value:
= {
{ 0x00000080, 0x00000080, 0.5f, 0.5f, 0x00000040, 0x00000004 },
{ 0x00000040, 0x00000040, 2.0f, 2.0f, 0x00000020, 0x00000010 },
{ 0x00000040, 0x00000040, 1.0f, 1.0f, 0x00000040, 0x00000008 },
{ 0x00000040, 0x00000040, 2.0f, 2.0f, 0x00000010, 0x00000010 },
{ 0x00000040, 0x00000040, 1.0f, 1.0f, 0x00000020, 0x00000010 },
{ 0x00000040, 0x00000040, 1.0f, 1.0f, 0x00000040, 0x00000008 },
}

Definition at line 24 of file bulb_glow.c.

24 {
25 { 0x00000080, 0x00000080, 0.5f, 0.5f, 0x00000040, 0x00000004 },
26 { 0x00000040, 0x00000040, 2.0f, 2.0f, 0x00000020, 0x00000010 },
27 { 0x00000040, 0x00000040, 1.0f, 1.0f, 0x00000040, 0x00000008 },
28 { 0x00000040, 0x00000040, 2.0f, 2.0f, 0x00000010, 0x00000010 },
29 { 0x00000040, 0x00000040, 1.0f, 1.0f, 0x00000020, 0x00000010 },
30 { 0x00000040, 0x00000040, 1.0f, 1.0f, 0x00000040, 0x00000008 },
31};

Referenced by bulb_glow_appendGfx().

◆ D_E00789A8

s32 D_E00789A8 = 0

Definition at line 33 of file bulb_glow.c.

Referenced by bulb_glow_main().

◆ D_E00789AC

Color_RGB8 D_E00789AC[]
Initial value:
= {
{ 255, 255, 255 },
{ 255, 255, 128 },
{ 255, 128, 255 },
{ 128, 255, 255 },
{ 255, 128, 128 },
{ 128, 255, 128 },
{ 128, 128, 255 },
}

Definition at line 35 of file bulb_glow.c.

35 {
36 { 255, 255, 255 },
37 { 255, 255, 128 },
38 { 255, 128, 255 },
39 { 128, 255, 255 },
40 { 255, 128, 128 },
41 { 128, 255, 128 },
42 { 128, 128, 255 },
43};

Referenced by bulb_glow_appendGfx().