Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
rising_bubble.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000200_356730[];
5extern Gfx D_090002E8_356818[];
6extern Gfx D_09000308_356838[];
7extern Gfx D_090003F0_356920[];
8extern Gfx D_09000410_356940[];
9extern Gfx D_09000430_356960[];
10
12
16
19
23void rising_bubble_appendGfx(void* effect);
24
25void rising_bubble_main(s32 arg0, f32 posX, f32 posY, f32 posZ, f32 arg4) {
26 EffectBlueprint effectBp;
27 EffectInstance* effect;
29 s32 numParts = 1;
30
31 effectBp.unk_00 = 0;
32 effectBp.init = rising_bubble_init;
35 effectBp.renderUI = NULL;
36 effectBp.effectID = EFFECT_RISING_BUBBLE;
37
38 effect = create_effect_instance(&effectBp);
39 effect->numParts = numParts;
40 data = effect->data.risingBubble = general_heap_malloc(numParts * sizeof(*data));
41 ASSERT(data != NULL);
42
43 data->unk_00 = arg0;
44 data->pos.x = posX;
45 data->pos.y = posY;
46 data->pos.z = posZ;
47 data->unk_14 = 0;
48 data->lifeTime = 0;
49 if (arg4 != 0.0f) {
50 data->unk_10 = ((rand_int(3) * 0.1) + 0.7) * 0.4;
51 } else {
52 data->unk_10 = 1.0f;
53 }
54 data->timeLeft = 32;
55 data->unk_20 = rand_int(31);
56 data->unk_24 = posY + arg4;
57}
58
61
63 RisingBubbleFXData* data = effect->data.risingBubble;
64 s32 timeLeft = data->timeLeft;
65
66 if (data->pos.y >= data->unk_24) {
67 data->timeLeft--;
68 data->lifeTime++;
69
70 if (data->timeLeft < 0) {
71 remove_effect(effect);
72 return;
73 }
74
75 if (timeLeft >= 6) {
76 data->unk_14 += (120 - data->unk_14) * 0.3;
77 } else {
78 data->unk_14 = timeLeft * 20;
79 }
80
81 data->unk_20++;
82 if (data->unk_20 >= 32) {
83 data->unk_20 -= 32;
84 }
85
86 data->unk_10 += 0.1;
87 return;
88 }
89
90 data->unk_14 = 255;
91 data->lifeTime++;
92 data->pos.y += 2.0f;
93}
94
96 RenderTask renderTask;
97 RenderTask* retTask;
98
100 renderTask.appendGfxArg = effect;
101 renderTask.dist = 0;
103
104 retTask = queue_render_task(&renderTask);
106}
107
108void rising_bubble_appendGfx(void* effect) {
109 RisingBubbleFXData* data = ((EffectInstance*)effect)->data.risingBubble;
110 s32 lifeTime = data->lifeTime;
111 Matrix4f sp20;
112 Matrix4f sp60;
113
114 gDPPipeSync(gMainGfxPos++);
115 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
116
117 if (data->pos.y >= data->unk_24) {
118 s32 uls;
119 s32 ult;
120
121 gSPDisplayList(gMainGfxPos++, D_E0046614[0]);
122 gDPSetPrimColor(gMainGfxPos++, 0, 0, 127, 127, 127, data->unk_14);
123
124 uls = 0;
125 ult = data->unk_20;
126
127 gDPSetTileSize(gMainGfxPos++, 1,
128 (uls ) * 4, (ult ) * 4,
129 (uls + 32) * 4, (ult + 32) * 4);
130
131 guTranslateF(sp20, data->pos.x, data->pos.y, data->pos.z);
132 guScaleF(sp60, data->unk_10, 1.0f, data->unk_10);
133 guMtxCatF(sp60, sp20, sp20);
134 } else {
135 gSPDisplayList(gMainGfxPos++, D_E0046618[0]);
136 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 255, data->unk_14);
137 gDPSetEnvColor(gMainGfxPos++, 128, 128, 255, data->unk_14);
138
139 guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].curYaw, 0.0f, data->unk_10, data->pos.x, data->pos.y, data->pos.z);
140 }
141
143 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
144
145 if (data->pos.y >= data->unk_24) {
146 gSPDisplayList(gMainGfxPos++, D_E0046600[0]);
147 } else {
148 gSPDisplayList(gMainGfxPos++, D_E0046604[(lifeTime >> 1) & 3]);
149 }
150
151 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
152 gDPPipeSync(gMainGfxPos++);
153}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define queue_render_task
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define rand_int
#define guPositionF
#define create_effect_instance
#define guScaleF
struct RisingBubbleFXData * risingBubble
Definition effects.h:2499
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
void rising_bubble_update(EffectInstance *effect)
Gfx D_090003F0_356920[]
Gfx D_09000430_356960[]
Gfx * D_E0046600[]
Gfx D_090002E8_356818[]
void rising_bubble_main(s32 arg0, f32 posX, f32 posY, f32 posZ, f32 arg4)
void rising_bubble_init(EffectInstance *effect)
Gfx * D_E0046614[]
Gfx D_09000308_356838[]
Gfx * D_E0046618[]
void rising_bubble_appendGfx(void *effect)
Gfx D_09000410_356940[]
Gfx * D_E0046604[]
void rising_bubble_render(EffectInstance *effect)
Gfx D_09000200_356730[]
#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
s32 gCurrentCameraID
Definition cam_math.c:4
DisplayContext * gDisplayContext
Definition cam_main.c:16