Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
cloud_trail.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_090000E0_32ED30[];
5extern Gfx D_090001B8_32EE08[];
6
10void cloud_trail_appendGfx(void* effect);
11
12void cloud_trail_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3) {
14 EffectInstance* effect;
15 CloudTrailFXData* part;
16 s32 numParts = 1;
17 s32 i;
18
19 bp.unk_00 = 0;
23 bp.renderUI = NULL;
24 bp.effectID = EFFECT_CLOUD_TRAIL;
25
26 effect = create_effect_instance(&bp);
27 effect->numParts = 1;
28 part = general_heap_malloc(numParts * sizeof(*part));
29 effect->data.cloudTrail = part;
30
31 ASSERT(effect->data.cloudTrail != NULL);
32
33 mem_clear(part, numParts * sizeof(*part));
34
35 for (i = 0; i < numParts; i++, part++) {
36 part->alive = 1;
37 part->unk_04 = arg0;
38 part->unk_40 = 0;
39 part->unk_44 = 0;
40 part->unk_0C = arg1;
41 part->unk_10 = arg2;
42 part->unk_14 = arg3;
43 part->unk_1C = 1.0f;
44 part->unk_20 = 1.0f;
45 part->unk_24 = 1.0f;
46 part->alpha = -1;
47 part->unk_28 = (rand_int(10) * 0.03) + 1.4;
48 part->unk_2C = (rand_int(10) * 0.03) + 1.5;
49 part->unk_30 = effect_rand_int(60);
50 part->unk_04 = arg0;
51 part->lifetime = 15;
52 part->unk_38 = 2.0f;
53 part->unk_3C = -0.5f;
54 part->unk_18 = effect_rand_int(360);
55 part->alpha = -1;
56 }
57}
58
60}
61
63 CloudTrailFXData* part = effect->data.cloudTrail;
64 s32 cond = FALSE;
65 s32 i;
66
67 for (i = 0; i < effect->numParts; i++, part++) {
68 if (part->alive) {
69 part->lifetime--;
70 if (part->lifetime <= 0) {
71 part->alive = FALSE;
72 } else {
73 cond = TRUE;
74 part->unk_30 = clamp_angle(part->unk_30 + 12.0f);
75 part->unk_1C = part->unk_28 + sin_deg(part->unk_30) * 0.1;
76 part->unk_20 = part->unk_2C + cos_deg(part->unk_30) * 0.1;
77
78 if (part->unk_04 == 0 && (part->lifetime == 5 && gPlayerStatus.actionState == ACTION_STATE_IDLE)) {
79 part->lifetime++;
80 return;
81 }
82
83 part->alpha -= 15;
84 part->unk_3C += part->unk_40;
85 part->unk_38 += part->unk_3C;
86 part->unk_10 += part->unk_38;
87 part->unk_28 += 0.14;
88 part->unk_2C *= 0.94;
89
90 if (part->unk_38 < 0.0f) {
91 part->unk_3C = 0.0f;
92 part->unk_38 = 0.0f;
93 }
94 }
95 }
96 }
97
98 if (!cond) {
99 remove_effect(effect);
100 }
101}
102
104 RenderTask renderTask;
105 RenderTask* retTask;
106
107 renderTask.appendGfx = cloud_trail_appendGfx;
108 renderTask.appendGfxArg = effect;
109 renderTask.dist = 0;
111
112 retTask = queue_render_task(&renderTask);
114}
115
116void cloud_trail_appendGfx(void* effect) {
117 EffectInstance* effectTemp = effect;
118 CloudTrailFXData* part = effectTemp->data.cloudTrail;
119 Matrix4f sp20;
120 Matrix4f sp60;
121 s32 i;
122
123 gDPPipeSync(gMainGfxPos++);
124 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(effectTemp->graphics->data));
125 gSPDisplayList(gMainGfxPos++, D_090000E0_32ED30);
126
127 for (i = 0; i < effectTemp->numParts; i++, part++) {
128 if (part->alive) {
129 guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f,
130 part->unk_0C, part->unk_10, part->unk_14);
131 guScaleF(sp60, part->unk_1C, part->unk_20, part->unk_24);
132 guMtxCatF(sp60, sp20, sp20);
133 guRotateF(sp60, part->unk_18, 0.0f, 0.0f, 1.0f);
134 guMtxCatF(sp60, sp20, sp20);
136
137 gDPSetPrimColor(gMainGfxPos++, 0, 0, 112, 96, 24, part->alpha);
139 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
140 gSPDisplayList(gMainGfxPos++, D_090001B8_32EE08);
141 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
142 }
143 }
144 gDPPipeSync(gMainGfxPos++);
145}
void cloud_trail_update(EffectInstance *effect)
Definition cloud_trail.c:62
void cloud_trail_init(EffectInstance *effect)
Definition cloud_trail.c:59
Gfx D_090000E0_32ED30[]
void cloud_trail_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3)
Definition cloud_trail.c:12
void cloud_trail_appendGfx(void *effect)
Gfx D_090001B8_32EE08[]
void cloud_trail_render(EffectInstance *effect)
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define guMtxCatF
#define remove_effect
#define rand_int
#define guPositionF
#define clamp_angle
#define cos_deg
#define create_effect_instance
#define mem_clear
#define guScaleF
struct EffectGraphics * graphics
Definition effects.h:2606
struct CloudTrailFXData * cloudTrail
Definition effects.h:2475
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
s32 effect_rand_int(s32)
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_PASS_THROUGH
Definition enums.h:3306
@ ACTION_STATE_IDLE
Definition enums.h:2426
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
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