Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
stars_burst.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_090004C0_343500[];
5extern Gfx D_090005E0_343620[];
6
7u8 D_E0042780[] = {
8 254, 172, 172,
9 254, 172, 213,
10 254, 180, 154,
11 213, 180, 254,
12 180, 180, 254,
13 180, 221, 254,
14 180, 254, 254,
15 180, 254, 213,
16 180, 254, 180,
17 213, 254, 180,
18 254, 254, 180,
19 254, 213, 172,
20};
21
25void stars_burst_appendGfx(void* effect);
26
28 s32 arg0,
29 f32 arg1,
30 f32 arg2,
31 f32 arg3,
32 f32 arg4,
33 f32 arg5,
34 s32 arg6
35) {
37 EffectBlueprint* bpPtr = &bp;
38 EffectInstance* effect;
39 StarsBurstFXData* part;
40 Matrix4f unused;
41 s32 numParts = arg6;
42 f32 temp;
43 s32 i;
44
45 if (arg6 != 0) {
46 numParts++;
47
48 bpPtr->init = stars_burst_init;
51 bpPtr->unk_00 = 0;
52 bpPtr->renderUI = NULL;
53 bpPtr->effectID = EFFECT_STARS_BURST;
54
55 effect = create_effect_instance(bpPtr);
56 effect->numParts = numParts;
57 part = effect->data.starsBurst = general_heap_malloc(numParts * sizeof(*part));
58 ASSERT(effect->data.starsBurst != NULL);
59
60 part->unk_00 = arg0;
61 part->unk_04 = arg1;
62 part->unk_08 = arg2;
63 part->unk_0C = arg3;
64 part->unk_34 = 0;
65 part->unk_30 = 30;
66 part->unk_2C = 255;
67
68 part++;
69 for (i = 1; i < numParts; i++, part++) {
70 temp = rand_int(10) * 0.25f + 5.0f;
71
72 part->unk_00 = arg0;
73 part->unk_04 = arg1;
74 part->unk_08 = arg2;
75 part->unk_0C = arg3;
76 part->unk_10 = cos_deg(arg5 + (i & 2) * (i / 2) * 4) * sin_deg(arg4);
77 part->unk_14 = sin_deg(arg5 + (i & 2) * (i / 2) * 4);
78 part->unk_18 = cos_deg(arg5 + (i & 2) * (i / 2) * 4) * cos_deg(arg4);
79 part->unk_28 = temp;
80 part->unk_24 = temp / 10.0;
81 }
82 }
83}
84
86}
87
89 StarsBurstFXData* part = effect->data.starsBurst;
90 s32 unk_30;
91 s32 i;
92
93 part->unk_30--;
94 part->unk_34++;
95
96 if (part->unk_30 < 0) {
97 remove_effect(effect);
98 return;
99 }
100
101 unk_30 = part->unk_30;
102 if (unk_30 < 10) {
103 part->unk_2C *= 0.8;
104 }
105
106 part++;
107 for (i = 1; i < effect->numParts; i++, part++) {
108 part->unk_04 += part->unk_28 * part->unk_10;
109 part->unk_08 += part->unk_28 * part->unk_14;
110 part->unk_0C += part->unk_28 * part->unk_18;
111 part->unk_28 *= 0.9;
112 if (unk_30 < 10) {
113 part->unk_24 += part->unk_28 / 10.0;
114 }
115 }
116}
117
119 RenderTask renderTask;
120 RenderTask* retTask;
121
122 renderTask.appendGfx = stars_burst_appendGfx;
123 renderTask.appendGfxArg = effect;
124 renderTask.dist = 0;
126
127 retTask = queue_render_task(&renderTask);
129}
130
131void stars_burst_appendGfx(void* effect) {
132 StarsBurstFXData* part = ((EffectInstance*)effect)->data.starsBurst;
133 Gfx* dlist = D_090005E0_343620;
134 s32 unk_2C;
135 Matrix4f sp18;
136 Matrix4f sp58;
137 s32 baseIdx;
138 s32 i;
139
140 gDPPipeSync(gMainGfxPos++);
141 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
142 gSPDisplayList(gMainGfxPos++, D_090004C0_343500);
143
144 unk_2C = part->unk_2C;
145
146 baseIdx = (part->unk_34 - 1) * 3;
147 baseIdx %= 36;
148
149 part++;
150 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) {
151 s32 rIdx = baseIdx + i * 3;
152 s32 gIdx = baseIdx + 1 + i * 3;
153 s32 bIdx = baseIdx + 2 + i * 3;
154
155 gDPSetPrimColor(gMainGfxPos++, 0, 0, D_E0042780[rIdx % 36], D_E0042780[gIdx % 36], D_E0042780[bIdx % 36], unk_2C);
156
157 guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C);
158 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
159 guMtxCatF(sp58, sp18, sp18);
160 guScaleF(sp58, part->unk_24, part->unk_24, 1.0f);
161 guMtxCatF(sp58, sp18, sp18);
163
164 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
165 gSPDisplayList(gMainGfxPos++, dlist);
166 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
167 }
168}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define rand_int
#define cos_deg
#define create_effect_instance
#define guScaleF
struct StarsBurstFXData * starsBurst
Definition effects.h:2497
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ 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
void stars_burst_render(EffectInstance *effect)
void stars_burst_init(EffectInstance *effect)
Definition stars_burst.c:85
Gfx D_090004C0_343500[]
u8 D_E0042780[]
Definition stars_burst.c:7
Gfx D_090005E0_343620[]
void stars_burst_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, s32 arg6)
Definition stars_burst.c:27
void stars_burst_update(EffectInstance *effect)
Definition stars_burst.c:88
void stars_burst_appendGfx(void *effect)
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