Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
cold_breath.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09002000_3DB100[];
5extern Gfx D_09002200_3DB300[];
6extern Gfx D_09002220_3DB320[];
7extern Gfx D_09002240_3DB340[];
8extern Gfx D_09002260_3DB360[];
9extern Gfx D_09002280_3DB380[];
10extern Gfx D_090022A0_3DB3A0[];
11
17
21
22s8 D_E00DE858[] = {
23 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26 0xF8, 0xF1, 0xEB, 0xE6, 0xE2, 0xDE, 0xDB, 0xD9, 0xD8, 0xD7,
27 0xD6, 0xD5, 0xD4, 0xD3, 0xD2, 0xD1, 0xD0, 0xCF, 0xCE, 0xCD,
28 0xCC, 0xCB, 0xCA, 0xC9, 0xC8, 0xC7, 0xC6, 0xC5, 0xC4, 0xC3,
29 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32 0x00, 0x00
33};
34
35u8 D_E00DE8B4[] = {
36 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31,
37 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
38 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
39 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
40 0x34, 0x37, 0x39, 0x3C, 0x3E, 0x41, 0x43, 0x46, 0x48, 0x4B,
41 0x4D, 0x50, 0x52, 0x55, 0x57, 0x5A, 0x5C, 0x5F, 0x61, 0x64,
42 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31,
43 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
44 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
45 0x00, 0x00
46};
47
48u8 D_E00DE910[] = {
49 0x00, 0x14, 0x28, 0x3C, 0x50, 0x64, 0x78, 0x8C, 0xA0, 0xB4,
50 0xBE, 0xC3, 0xD2, 0xD0, 0xD3, 0xD6, 0xD9, 0xDC, 0xDF, 0xE2,
51 0xE5, 0xE8, 0xEB, 0xEE, 0xF1, 0xF4, 0xF7, 0xFA, 0xFD, 0xFF,
52 0x00, 0x14, 0x28, 0x3C, 0x50, 0x64, 0x78, 0x8C, 0xA0, 0xB4,
53 0xBE, 0xC3, 0xD2, 0xD0, 0xD3, 0xD6, 0xD9, 0xDC, 0xDF, 0xE2,
54 0xE5, 0xE8, 0xEB, 0xEE, 0xF1, 0xF4, 0xF7, 0xFA, 0xFD, 0xFF,
55 0x00, 0x14, 0x28, 0x3C, 0x50, 0x64, 0x78, 0x8C, 0xA0, 0xB4,
56 0xBE, 0xC3, 0xD2, 0xD0, 0xD3, 0xD6, 0xD9, 0xDC, 0xDF, 0xE2,
57 0xE5, 0xE8, 0xEB, 0xEE, 0xF1, 0xF4, 0xF7, 0xFA, 0xFD, 0xFF,
58 0x00, 0x00
59};
60
61u8 D_E00DE96C[] = {
62 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
63 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
64 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
65 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
66 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13,
67 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D,
68 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4,
69 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4,
70 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4,
71 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
72};
73
77void cold_breath_appendGfx(void* effect);
78
79EffectInstance* cold_breath_main(s32 type, f32 posX, f32 posY, f32 posZ, f32 scale, s32 duration) {
81 EffectInstance* effect;
82 ColdBreathFXData* data;
83 s32 numParts = 1;
84
88 bp.unk_00 = 0;
89 bp.renderUI = NULL;
90 bp.effectID = EFFECT_COLD_BREATH;
91
92 effect = create_effect_instance(&bp);
93 effect->numParts = numParts;
94 data = effect->data.coldBreath = general_heap_malloc(numParts * sizeof(*data));
95 ASSERT(effect->data.coldBreath != NULL);
96
97 data->type = type;
98 data->lifetime = 0;
99 if (duration <= 0) {
100 data->timeLeft = 1000;
101 } else {
102 data->timeLeft = duration;
103 }
104 data->primCol.a = 255;
105 data->pos.x = posX;
106 data->pos.y = posY;
107 data->pos.z = posZ;
108 data->scale = scale;
109 data->primCol.r = 255;
110 data->primCol.g = 255;
111 data->primCol.b = 255;
112 data->envCol.r = 255;
113 data->envCol.g = 255;
114 data->envCol.b = 255;
115 data->envCol.a = 255;
116 data->unk_38 = 0;
117 data->unk_3C = 0;
118
119 return effect;
120}
121
123}
124
126 ColdBreathFXData* data = effect->data.coldBreath;
127 s32 type = data->type;
128
129 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
130 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
131 data->timeLeft = 16;
132 }
133
134 if (data->timeLeft < 1000) {
135 data->timeLeft--;
136 }
137
138 data->lifetime++;
139
140 if (data->timeLeft < 0) {
141 remove_effect(effect);
142 return;
143 }
144 if (data->timeLeft < 16) {
145 data->primCol.a = data->timeLeft * 16;
146 }
147
148 if (type < 2) {
149 if (type >= 0) {
150 data->unk_3C += 0.02;
151 }
152 }
153
154 data->pos.y += data->unk_3C;
155
156 if (data->unk_3C > 0.5) {
157 data->unk_3C = 0.5f;
158 }
159 if (data->unk_3C < -1.5) {
160 data->unk_3C = -1.5f;
161 }
162
163 data->unk_38 += 1.0f;
164}
165
167 RenderTask renderTask;
168 RenderTask* retTask;
169
170 renderTask.appendGfx = cold_breath_appendGfx;
171 renderTask.appendGfxArg = effect;
172 renderTask.dist = 6;
174
175 retTask = queue_render_task(&renderTask);
177}
178
179void cold_breath_appendGfx(void* effect) {
180 ColdBreathFXData* data = ((EffectInstance*)effect)->data.coldBreath;
181 Camera* camera = &gCameras[gCurrentCameraID];
182 s32 unk14 = data->lifetime;
183 s32 unk24 = data->primCol.a;
184 s32 unk00 = data->type;
185 Matrix4f sp20;
186 Matrix4f sp60;
187 s32 unkIndex;
188 f32 temp1;
189 f32 temp2;
190 f32 temp3;
191 f32 temp_f32;
192 s32 temp_s32;
193 s32 envAlpha;
194 s32 cond;
195
196 gDPPipeSync(gMainGfxPos++);
197 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
198
199 guTranslateF(sp20, data->pos.x, data->pos.y, data->pos.z);
200 guScaleF(sp60, data->scale, data->scale, data->scale);
201 guMtxCatF(sp60, sp20, sp20);
203
204 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
205 gSPMatrix(gMainGfxPos++, camera->mtxBillboard, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
206 gDPSetPrimColor(gMainGfxPos++, 0, 0, data->primCol.r, data->primCol.g, data->primCol.b, 0.5 * unk24);
207 gDPSetAlphaDither(gMainGfxPos++, G_AD_NOISE);
208 gSPDisplayList(gMainGfxPos++, D_E00DE84C[unk00]);
209
210 unkIndex = (unk14 < 30 ? unk14 : 29) + unk00 * 30;
211 temp1 = D_E00DE96C[unkIndex];
212 temp2 = D_E00DE8B4[unkIndex];
213 temp3 = D_E00DE858[unkIndex];
214
215 guPositionF(sp20, 0.0f, 0.0f, -temp1, temp2 * 0.01f, temp3, 0.0f, 0.0f);
217 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
218
219 temp_f32 = D_E00DE910[unkIndex] * 5.0f / 256.0f;
220 temp_s32 = temp_f32;
221 envAlpha = (temp_f32 - temp_s32) * 256.0f;
222
223 cond = temp_s32 >= 4;
224 if (temp_s32 < 5) {
225 if (cond) {
226 gDPSetTileSize(gMainGfxPos++, 1, 0, 0, 0, 0);
227 } else {
228 gDPSetTileSize(gMainGfxPos++, 1, 0, 0, 31 << 2, 127 << 2);
229 }
230 gDPSetEnvColor(gMainGfxPos++, data->envCol.r, data->envCol.g, data->envCol.b, envAlpha);
231 gSPDisplayList(gMainGfxPos++, D_E00DE810[unk00][temp_s32]);
232 }
233
234 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
235 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
236 gDPSetAlphaDither(gMainGfxPos++, G_AD_DISABLE);
237 gDPPipeSync(gMainGfxPos++);
238}
Gfx * D_E00DE810[][5]
Definition cold_breath.c:12
void cold_breath_update(EffectInstance *effect)
Gfx * D_E00DE84C[]
Definition cold_breath.c:18
Gfx D_09002280_3DB380[]
Gfx D_09002220_3DB320[]
EffectInstance * cold_breath_main(s32 type, f32 posX, f32 posY, f32 posZ, f32 scale, s32 duration)
Definition cold_breath.c:79
u8 D_E00DE96C[]
Definition cold_breath.c:61
u8 D_E00DE8B4[]
Definition cold_breath.c:35
void cold_breath_init(EffectInstance *effect)
Gfx D_09002240_3DB340[]
s8 D_E00DE858[]
Definition cold_breath.c:22
Gfx D_09002000_3DB100[]
Gfx D_090022A0_3DB3A0[]
Gfx D_09002200_3DB300[]
u8 D_E00DE910[]
Definition cold_breath.c:48
Gfx D_09002260_3DB360[]
void cold_breath_appendGfx(void *effect)
void cold_breath_render(EffectInstance *effect)
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 guPositionF
#define create_effect_instance
#define guScaleF
struct ColdBreathFXData * coldBreath
Definition effects.h:2575
Color4i primCol
Definition effects.h:1990
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
@ 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
Mtx * mtxBillboard
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