Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
stars_spread.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000440_360E70[];
5extern Gfx D_090004F0_360F20[];
6
10void stars_spread_appendGfx(void* effect);
11
13 s32 arg0,
14 f32 arg1,
15 f32 arg2,
16 f32 arg3,
17 s32 arg4,
18 s32 arg5
19) {
21 EffectInstance* effect;
23 s32 i;
24
25 arg4++;
26
30 bp.unk_00 = 0;
31 bp.renderUI = NULL;
32 bp.effectID = EFFECT_STARS_SPREAD;
33
34 effect = create_effect_instance(&bp);
35 effect->numParts = arg4;
36 part = effect->data.starsSpread = general_heap_malloc(arg4 * sizeof(*part));
37 ASSERT(effect->data.starsSpread != NULL);
38
39 mem_clear(part, arg4 * sizeof(*part));
40
41 part->unk_24 = arg5;
42 part->unk_28 = 0;
43 part->unk_2C = arg5;
44 part->unk_00 = arg0;
45 part->unk_04 = arg1;
46 part->unk_08 = arg2;
47 part->unk_0C = arg3;
48
49 part++;
50 for (i = 1; i < arg4; i++, part++) {
51 part->unk_04 = 0;
52 part->unk_08 = 0;
53 part->unk_0C = 0;
54 part->unk_10 = sin_deg((i - 1) * 360 / (arg4 - 1)) * 8.0;
55 part->unk_14 = cos_deg((i - 1) * 360 / (arg4 - 1)) * 8.0;
56 part->unk_18 = 0;
57 part->unk_1C = 0;
58 part->unk_20 = 20.0f;
59 part->unk_30 = 1.0f;
60 }
61}
62
65
67 StarsSpreadFXData* part = effect->data.starsSpread;
68 s32 unk_24;
69 s32 unk_2C;
70 s32 i;
71
72 part->unk_28++;
73 part->unk_24--;
74
75 if (part->unk_24 < 0) {
76 remove_effect(effect);
77 return;
78 }
79
80 unk_24 = part->unk_24;
81 unk_2C = part->unk_2C;
82
83 part++;
84 for (i = 1; i < effect->numParts; i++, part++) {
85 if (unk_24 >= 6) {
86 part->unk_10 *= 0.8;
87 part->unk_14 *= 0.8;
88 part->unk_18 *= 0.8;
89 }
90
91 if (unk_24 < 5) {
92 part->unk_20 *= 0.8;
93 part->unk_10 *= 0.7;
94 part->unk_14 *= 0.7;
95 part->unk_18 *= 0.7;
96 }
97
98 if (unk_24 * 2 < unk_2C) {
99 part->unk_30 += -part->unk_30 * 0.2;
100 }
101
102 part->unk_04 += part->unk_10;
103 part->unk_08 += part->unk_14;
104 part->unk_0C = 0;
105 part->unk_1C += part->unk_20;
106 }
107}
108
110 RenderTask renderTask;
111 RenderTask* retTask;
112
114 renderTask.appendGfxArg = effect;
115 renderTask.dist = 0;
117
118 retTask = queue_render_task(&renderTask);
120}
121
122void stars_spread_appendGfx(void* effect) {
123 StarsSpreadFXData* part = ((EffectInstance*)effect)->data.starsSpread;
124 Gfx* dlist = D_090004F0_360F20;
125 Matrix4f sp18;
126 Matrix4f sp58;
127 s32 i;
128
129 gDPPipeSync(gMainGfxPos++);
130 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
131 gSPDisplayList(gMainGfxPos++, D_09000440_360E70);
132
133 guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C);
134 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
135 guMtxCatF(sp58, sp18, sp18);
137
138 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
139 gDPSetPrimColor(gMainGfxPos++, 0, 0, 220, 220, 40, 230);
140
141 part++;
142 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) {
143 guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C);
144 guRotateF(sp58, part->unk_1C, 0.0f, 0.0f, 1.0f);
145 guMtxCatF(sp58, sp18, sp18);
146 guScaleF(sp58, part->unk_30, part->unk_30, 1.0f);
147 guMtxCatF(sp58, sp18, sp18);
149
150 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
151 gSPDisplayList(gMainGfxPos++, dlist);
152 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
153 }
154
155 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
156}
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 cos_deg
#define create_effect_instance
#define mem_clear
#define guScaleF
struct StarsSpreadFXData * starsSpread
Definition effects.h:2509
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_PASS_THROUGH
Definition enums.h:3306
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
void stars_spread_render(EffectInstance *effect)
void stars_spread_init(EffectInstance *effect)
void stars_spread_update(EffectInstance *effect)
void stars_spread_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, s32 arg4, s32 arg5)
Gfx D_090004F0_360F20[]
void stars_spread_appendGfx(void *effect)
Gfx D_09000440_360E70[]
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