Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
peach_star_beam.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09004FE8_3EAF18[];
5extern Gfx D_09005090_3EAFC0[];
6extern Gfx D_090050F0_3EB020[];
7extern Gfx D_09005168_3EB098[];
8extern Gfx D_090051E0_3EB110[];
9extern Gfx D_09005258_3EB188[];
10extern Gfx D_090052D0_3EB200[];
11extern Gfx D_09005348_3EB278[];
12extern Gfx D_090053C0_3EB2F0[];
13extern Gfx D_09005438_3EB368[];
14extern Gfx D_090054B0_3EB3E0[];
15extern Gfx D_09005570_3EB4A0[];
16extern Gfx D_09005590_3EB4C0[];
17
19
21
26
31
35void peach_star_beam_appendGfx(void* effect);
36
37EffectInstance* peach_star_beam_main(s32 type, f32 x, f32 y, f32 z, f32 arg4, s32 duration) {
39 EffectInstance* effect;
41 s32 numParts = 1;
42 s32 i;
43
44 bp.unk_00 = 0;
48 bp.renderUI = NULL;
49 bp.effectID = EFFECT_PEACH_STAR_BEAM;
50
51 effect = create_effect_instance(&bp);
52 effect->numParts = numParts;
53 data = effect->data.peachStarBeam = general_heap_malloc(sizeof(*data));
54 ASSERT(effect->data.peachStarBeam != NULL);
55
56 data->type = type;
57 data->lifetime = 0;
58 if (duration <= 0) {
59 data->timeLeft = 1000;
60 } else {
61 data->timeLeft = duration;
62 }
63 data->beamAlpha = 224;
64 data->pos.x = x;
65 data->pos.y = y;
66 data->pos.z = z;
67 data->unk_3C = 255;
68 data->beamScale = arg4;
69 data->circleRadius = 80.0f;
70 data->twinkYOffset = 50.0f;
71 data->primR = 255;
72 data->primG = 255;
73 data->primB = 120;
74 data->envR = 255;
75 data->envG = 255;
76 data->envB = 255;
77 data->envA = 255;
78 data->rotSpeed = 5.0f;
79 data->rotAngle = 0;
80 data->circleCenter.x = x;
81 data->circleCenter.y = y + 50.0f;
82 data->circleCenter.z = z;
83
84 for (i = 0; i < ARRAY_COUNT(data->spirits); i++) {
85 PeachStarBeamSpirit* part = &data->spirits[i];
86
87 if (type == 0 && i == 0) {
88 part->flags = 0;
89 } else {
90 part->flags = 1;
91 }
92 }
93 return effect;
94}
95
98
100 PeachStarBeamFXData* data = effect->data.peachStarBeam;
101 f32 rotationAngle;
102 f32 radius;
103 f32 centerX;
104 f32 centerY;
105 f32 centerZ;
106 f32 spiritAngle;
107 s32 i;
108
109 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
110 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
111 data->timeLeft = 16;
112 }
113
114 if (data->timeLeft < 1000) {
115 data->timeLeft--;
116 }
117
118 data->lifetime++;
119 if (data->timeLeft < 0) {
120 remove_effect(effect);
121 return;
122 }
123
124 data->rotAngle += data->rotSpeed;
125 rotationAngle = data->rotAngle;
126 radius = data->circleRadius;
127 centerX = data->circleCenter.x;
128 centerY = data->circleCenter.y;
129 centerZ = data->circleCenter.z;
130
131 for (i = 0; i < ARRAY_COUNT(data->spirits); i++) {
132 PeachStarBeamSpirit* part = &data->spirits[i];
133
134 if (i == 0) {
135 part->pos.x = centerX;
136 part->pos.y = centerY + data->twinkYOffset;
137 part->pos.z = centerZ;
138 } else {
139 spiritAngle = rotationAngle + ((-360 + (360 * i)) / 7);
140 part->pos.x = centerX + radius * sin_deg(spiritAngle);
141 part->pos.y = centerY;
142 part->pos.z = centerZ + radius * cos_deg(spiritAngle);
143 }
144 if (!(part->flags & 2)) {
145 part->lockedPos.x = part->pos.x;
146 part->lockedPos.y = part->pos.y;
147 part->lockedPos.z = part->pos.z;
148 }
149 }
150}
151
153 RenderTask renderTask;
154 RenderTask* retTask;
155
157 renderTask.appendGfxArg = effect;
158 renderTask.dist = 10;
160
161 retTask = queue_render_task(&renderTask);
163}
164
165void peach_star_beam_appendGfx(void* effect) {
166 Matrix4f sp20, sp60;
167 Camera* camera = &gCameras[gCurrentCameraID];
168 PeachStarBeamFXData* data = ((EffectInstance*)effect)->data.peachStarBeam;
170 s32 alpha = data->beamAlpha;
171 f32 partX, partY, partZ;
172 s32 i;
173
174 gDPPipeSync(gMainGfxPos++);
175 gSPSegment(gMainGfxPos++, 0x9, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
176 gSPDisplayList(gMainGfxPos++, D_09005090_3EAFC0);
177
178 for (i = 0; i < ARRAY_COUNT(data->spirits); i++) {
179 part = &data->spirits[i];
180 if (part->flags & 1) {
181 if (part->flags & 2) {
182 partX = part->lockedPos.x;
183 partY = part->lockedPos.y;
184 partZ = part->lockedPos.z;
185 } else {
186 partX = part->pos.x;
187 partY = part->pos.y;
188 partZ = part->pos.z;
189 }
190
191 if (!(data->pos.z < partZ)) {
192 guPositionF(sp20, 0.0f, 0.0f, 0.0f, SPRITE_WORLD_SCALE_F, partX, partY, partZ);
194
196 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
197 gDPSetPrimColor(gMainGfxPos++, 0, 0, 128, 128, 128, 255);
198 gDPSetEnvColor(gMainGfxPos++, 128, 128, 128, 127);
199 gSPDisplayList(gMainGfxPos++, D_E010CA38[i]);
200 gSPDisplayList(gMainGfxPos++, D_E010CA18[i]);
201 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
202 }
203 }
204 }
205
206 guTranslateF(sp20, data->pos.x, data->pos.y - (((f32) (255 - data->unk_3C) * 400.0) / 255.0), data->pos.z);
207 guScaleF(sp60, data->beamScale * 0.4, data->beamScale * 0.4, data->beamScale * 0.4);
208 guMtxCatF(sp60, sp20, sp20);
210
212 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
213 gSPMatrix(gMainGfxPos++, camera->mtxBillboard, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
214 gDPSetPrimColor(gMainGfxPos++, 0, 0, data->primR, data->primG, data->primB, alpha);
215 gDPSetEnvColor(gMainGfxPos++, data->envR, data->envG, data->envB, data->envA);
216 gSPDisplayList(gMainGfxPos++, D_E010CA14[0]);
217 gSPDisplayList(gMainGfxPos++, D_E010CA10[0]);
218 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
219 gSPDisplayList(gMainGfxPos++, D_09005090_3EAFC0);
220
221 for (i = 0; i < ARRAY_COUNT(data->spirits); i++) {
222 part = &data->spirits[i];
223
224 if (part->flags & 1) {
225 if (part->flags & 2) {
226 partX = part->lockedPos.x;
227 partY = part->lockedPos.y;
228 partZ = part->lockedPos.z;
229 } else {
230 partX = part->pos.x;
231 partY = part->pos.y;
232 partZ = part->pos.z;
233 }
234
235 if (!(partZ <= data->pos.z)) {
236 guPositionF(sp20, 0.0f, 0.0f, 0.0f, 0.67f, partX, partY, partZ);
238
240 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
241 gDPSetPrimColor(gMainGfxPos++, 0, 0, 128, 128, 128, 255);
242 gDPSetEnvColor(gMainGfxPos++, 128, 128, 128, 127);
243 gSPDisplayList(gMainGfxPos++, D_E010CA38[i]);
244 gSPDisplayList(gMainGfxPos++, D_E010CA18[i]);
245 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
246 }
247 }
248 }
249}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
Vec3s pos
Definition demo_api.c:17
#define general_heap_malloc
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define guPositionF
#define cos_deg
#define create_effect_instance
#define guScaleF
struct PeachStarBeamFXData * peachStarBeam
Definition effects.h:2584
EffectData data
Definition effects.h:2605
PeachStarBeamSpirit spirits[8]
Definition effects.h:2182
#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
Gfx D_09005168_3EB098[]
void peach_star_beam_init(EffectInstance *effect)
Gfx * D_E010CA38[8]
Gfx D_090051E0_3EB110[]
Gfx * D_E010CA10[]
void peach_star_beam_update(EffectInstance *effect)
Gfx * D_E010CA14[]
Gfx D_09005570_3EB4A0[]
void peach_star_beam_appendGfx(void *effect)
Gfx D_090054B0_3EB3E0[]
Gfx D_09005348_3EB278[]
Gfx * D_E010CA18[8]
Gfx D_090050F0_3EB020[]
Gfx D_09005438_3EB368[]
void peach_star_beam_render(EffectInstance *effect)
Gfx D_09004FE8_3EAF18[]
Gfx D_090052D0_3EB200[]
Gfx D_09005590_3EB4C0[]
EffectInstance * peach_star_beam_main(s32 type, f32 x, f32 y, f32 z, f32 arg4, s32 duration)
Gfx D_090053C0_3EB2F0[]
Gfx D_09005258_3EB188[]
Gfx D_09005090_3EAFC0[]
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define SPRITE_WORLD_SCALE_F
Definition macros.h:139
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
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