Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
snaking_static.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
7void snaking_static_appendGfx(void* effect);
8
9extern Gfx D_09001000_3B3D90[];
10extern Gfx D_090010F8_3B3E88[];
11
12EffectInstance* snaking_static_main(s32 type, f32 posX, f32 posY, f32 posZ, f32 scale, s32 timeLeft) {
13 EffectBlueprint effectBp;
14 EffectInstance* effect;
16 s32 numParts = 22;
17 s32 i;
18
19 effectBp.init = snaking_static_init;
22 effectBp.unk_00 = 0;
23 effectBp.renderUI = NULL;
24 effectBp.effectID = EFFECT_SNAKING_STATIC;
25
26 effect = create_effect_instance(&effectBp);
27 effect->numParts = numParts;
28
29 data = effect->data.snakingStatic = general_heap_malloc(numParts * sizeof(*data));
30 ASSERT(data != NULL);
31
32 data->type = type;
33 data->lifeTime = 0;
34
35 if (timeLeft <= 0) {
36 data->timeLeft = 1000;
37 } else {
38 data->timeLeft = timeLeft;
39 }
40
41 data->unk_24 = 0;
42 data->pos.x = posX;
43 data->pos.y = posY;
44 data->pos.z = posZ;
45 data->scale = scale;
46
47 data->unk_18 = 255;
48 data->unk_1C = 230;
49 data->unk_20 = 0;
50
51 data->envCol.r = 255;
52 data->envCol.g = 255;
53 data->envCol.b = 255;
54
55 data++;
56 for(i = 1; i < numParts; i++, data++) {
57 data->timeLeft = 20;
58 data->unk_3C = (i - 1) * 360 / (numParts - 1);
59 data->lifeTime = 0;
60 data->pos.x = 0;
61 data->pos.y = 0;
62 data->unk_34 = 1.0f;
63 data->unk_40 = i & 15;
64 }
65
66 return effect;
67
68}
69
72
75 f32 tempOffsetY;
76 f32 tempOffsetX;
77 f32 tempPosX;
78 f32 tempPosY;
79 s32 lifeTime;
80 s32 timeLeft;
81 s32 i;
82
83 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
84 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
85 data->timeLeft = 16;
86 }
87
88 if (data->timeLeft < 1000) {
89 data->timeLeft--;
90 }
91
92 timeLeft = data->timeLeft;
93 data->lifeTime++;
94 lifeTime = data->lifeTime;
95
96 if (timeLeft < 0) {
97 remove_effect(effect);
98 return;
99 }
100 if (timeLeft < 16) {
101 data->unk_24 = timeLeft * 16;
102 }
103 if (lifeTime < 16) {
104 data->unk_24 = (lifeTime * 16) + 15;
105 }
106
107 data++;
108 for (i = 1; i < effect->numParts; i += 3, data += 3) {
109 if (data->lifeTime >= data->timeLeft) {
110 data->timeLeft = rand_int(50) + 20;
111 data->lifeTime = 0;
112 data->unk_3C = rand_int(360);
113 data->pos.x = 0.0f;
114 data->pos.y = 0.0f;
115 }
116 if (rand_int(100) < 51) {
117 tempPosX = data->pos.x;
118 tempPosY = data->pos.y;
119 tempOffsetX = rand_int(16) - 8;
120 tempOffsetY = rand_int(16) - 8;
121 data[2] = data[1];
122 data[1] = data[0];
123 data->pos.x = tempPosX + tempOffsetX;
124 data->pos.y = tempPosY + tempOffsetY;
125 data->unk_3C = atan2(0.0f, 0.0f, tempOffsetX, tempOffsetY);
126 if (tempOffsetX != 0.0f || tempOffsetY != 0.0f) {
127 data->unk_34 = sqrtf((tempOffsetX * tempOffsetX) + (tempOffsetY * tempOffsetY));
128 } else {
129 data->unk_34 = 0.0f;
130 }
131 }
132 data->unk_24 = (sin_deg(((data->lifeTime * 180) / data->timeLeft)) * 1024.0f);
133 if (data->unk_24 >= 256) {
134 data->unk_24 = 255;
135 }
136 data->lifeTime++;
137 }
138 data = effect->data.snakingStatic;
139 data++;
140 for (i = 1; i < effect->numParts; i++, data++) {
141 data->unk_40 = rand_int(15);
142 }
143}
144
146 RenderTask renderTask;
147 RenderTask* retTask;
148
150 renderTask.appendGfxArg = effect;
151 renderTask.dist = 10;
153
154 retTask = queue_render_task(&renderTask);
156}
157
158void func_E00AE544(void) {
159}
160
161void snaking_static_appendGfx(void* effect) {
162 EffectInstance* effectTemp = effect;
163 SnakingStaticFXData* data = effectTemp->data.snakingStatic;
164 Camera* camera = &gCameras[gCurrentCameraID];
165 Matrix4f sp18, sp58;
166 s32 lifeTime = data->lifeTime;
167 s32 unk_24 = data->unk_24;
168 s32 primR = data->unk_18;
169 s32 primG = data->unk_1C;
170 s32 primB = data->unk_20;
171 s32 i;
172
173 gDPPipeSync(gMainGfxPos++);
174 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
175
176 guTranslateF(sp18, data->pos.x, data->pos.y, data->pos.z);
177 guScaleF(sp58, data->scale, data->scale, data->scale);
178 guMtxCatF(sp58, sp18, sp18);
180
182 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
183 gSPMatrix(gMainGfxPos++, camera->mtxBillboard, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
184 gDPSetEnvColor(gMainGfxPos++, data->envCol.r, data->envCol.g, data->envCol.b, 0);
185 gSPDisplayList(gMainGfxPos++, D_09001000_3B3D90);
186
187 data++;
188 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, data++) {
189 gDPSetPrimColor(gMainGfxPos++, 0, 0, primR, primG, primB, (data->unk_24 * unk_24) / 255);
190 guTranslateF(sp18, data->pos.x, data->pos.y, 0.0f);
191 guRotateF(sp58, data->unk_3C, 0.0f, 0.0f, 1.0f);
192 guMtxCatF(sp58, sp18, sp18);
193 guScaleF(sp58, data->unk_34 * 0.0625f, data->unk_34 * 0.0625f, 1.0f);
194 guMtxCatF(sp58, sp18, sp18);
196
198 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
199 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, data->unk_40 * 64, 0, (data->unk_40 * 64) | 0x3C, 0x007C);
200 gDPSetTileSize(gMainGfxPos++, 1, (lifeTime * 12), 0, ((lifeTime * 3) + 0x1F) * 4, 0x007C);
201
202 gSPDisplayList(gMainGfxPos++, D_090010F8_3B3E88);
203 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
204 }
205 gDPSetAlphaCompare(gMainGfxPos++, G_AC_NONE);
206 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
207}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define sqrtf
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define rand_int
#define atan2
#define create_effect_instance
#define guScaleF
struct SnakingStaticFXData * snakingStatic
Definition effects.h:2551
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
Gfx D_09001000_3B3D90[]
void snaking_static_render(EffectInstance *effect)
EffectInstance * snaking_static_main(s32 type, f32 posX, f32 posY, f32 posZ, f32 scale, s32 timeLeft)
void snaking_static_appendGfx(void *effect)
void snaking_static_update(EffectInstance *)
void func_E00AE544(void)
Gfx D_090010F8_3B3E88[]
void snaking_static_init(EffectInstance *effect)
Mtx * mtxBillboard
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 *)
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