Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
snowflake.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4s32 D_E001C5E0 = 0;
5
6extern Gfx D_09000900_331800[];
7extern Gfx D_090009E8_3318E8[];
8
12void snowflake_appendGfx(void* effect);
13
14void snowflake_main(f32 x, f32 y, f32 z, s32 arg3) {
16 EffectInstance* effect;
17 SnowflakeFXData* part;
18 s32 numParts = 1;
19 f32 phi_f4;
20
21 bp.unk_00 = 0;
25 bp.renderUI = NULL;
26 bp.effectID = EFFECT_SNOWFLAKE;
27
28 effect = create_effect_instance(&bp);
29 effect->numParts = 1;
30 part = effect->data.snowflake = general_heap_malloc(numParts * sizeof(*part));
31
32 ASSERT(effect->data.snowflake != NULL);
33
34 part->pos.x = x;
35 part->pos.y = y;
36 part->pos.z = z;
37 part->unk_0C = 0;
38 part->unk_10 = -3.0f;
39 part->unk_14 = 0;
40 part->unk_18 = 0;
41 part->unk_1C = 0;
42 part->unk_20 = 3.0f;
43 if (D_E001C5E0 != 0) {
44 phi_f4 = -10.0f;
45 } else {
46 phi_f4 = 10.0f;
47 }
48 part->unk_24 = phi_f4;
49 part->unk_28 = arg3;
50
51 D_E001C5E0++;
52 if (D_E001C5E0 >= 2) {
53 D_E001C5E0 = 0;
54 }
55}
56
58}
59
61 SnowflakeFXData* data = effect->data.snowflake;
62
63 data->unk_28--;
64 if (data->unk_28 < 0) {
65 remove_effect(effect);
66 return;
67 }
68
69 data->pos.x += data->unk_0C;
70 data->pos.y += data->unk_10;
71 data->pos.z += data->unk_14;
72 data->unk_18 += data->unk_20;
73 if (data->unk_18 < 10.0f) {
74 data->unk_18 = 10.0f;
75 data->unk_20 = -data->unk_20;
76 }
77 if (data->unk_18 > 45.0f) {
78 data->unk_18 = 45.0f;
79 data->unk_20 = -data->unk_20;
80 }
81 data->unk_1C += data->unk_24;
82}
83
85 PlayerStatus* playerStatus = &gPlayerStatus;
86 SnowflakeFXData* data = effect->data.snowflake;
87 RenderTask renderTask;
88 RenderTask* renderTaskPtr = &renderTask;
89 RenderTask* retTask;
90 f32 effectPos = data->pos.x;
91 f32 playerPos = playerStatus->pos.x;
92
93 if (effectPos - playerPos > 200) {
94 data->pos.x = effectPos - 400;
95 } else {
96 if (playerPos - effectPos > 200) {
97 data->pos.x = effectPos + 400;
98 }
99 }
100
101 effectPos = data->pos.z;
102 playerPos = playerStatus->pos.z;
103 if (effectPos - playerPos > 200) {
104 data->pos.z = effectPos - 400;
105 } else {
106 if (playerPos - effectPos > 200) {
107 data->pos.z = effectPos + 400;
108 }
109 }
110
111 renderTaskPtr->appendGfx = &snowflake_appendGfx;
112 renderTaskPtr->appendGfxArg = effect;
113 renderTaskPtr->dist = 0;
114 renderTaskPtr->renderMode = RENDER_MODE_CLOUD_NO_ZCMP;
115
116 retTask = queue_render_task(renderTaskPtr);
118}
119
120void snowflake_appendGfx(void* effect) {
121 Matrix4f sp18, sp58, sp98, spD8, sp118;
122 EffectInstance* effectTemp = effect;
123 SnowflakeFXData* data = effectTemp->data.snowflake;
124
125 gDPPipeSync(gMainGfxPos++);
126 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(effectTemp->graphics->data));
127 gSPDisplayList(gMainGfxPos++, D_09000900_331800);
128
129 guTranslateF(sp18, data->pos.x, data->pos.y, data->pos.z);
130 guRotateF(spD8, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
131 guMtxCatF(spD8, sp18, sp118);
133
134 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
135 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, 255);
136
137 guRotateF(sp58, data->unk_18, 1.0f, 0.0f, 0.0f);
138 guRotateF(sp98, data->unk_1C, 0.0f, 1.0f, 0.0f);
139 guMtxCatF(sp58, sp98, sp118);
141
142 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
143 gSPDisplayList(gMainGfxPos++, D_090009E8_3318E8);
144 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
145 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
146}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define create_effect_instance
struct SnowflakeFXData * snowflake
Definition effects.h:2478
struct EffectGraphics * graphics
Definition effects.h:2606
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 snowflake_appendGfx(void *effect)
Definition snowflake.c:120
Gfx D_09000900_331800[]
void snowflake_init(EffectInstance *effect)
Definition snowflake.c:57
void snowflake_update(EffectInstance *effect)
Definition snowflake.c:60
void snowflake_render(EffectInstance *effect)
Definition snowflake.c:84
s32 D_E001C5E0
Definition snowflake.c:4
Gfx D_090009E8_3318E8[]
void snowflake_main(f32 x, f32 y, f32 z, s32 arg3)
Definition snowflake.c:14
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
PlayerStatus gPlayerStatus
Definition 77480.c:39
s32 gCurrentCameraID
Definition cam_math.c:4
DisplayContext * gDisplayContext
Definition cam_main.c:16