Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
huff_puff_breath.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000400_3D84C0[];
5extern Gfx D_090005E8_3D86A8[];
6extern Gfx D_09000628_3D86E8[];
7
10
14void huff_puff_breath_appendGfx(void* effect);
15
16EffectInstance* huff_puff_breath_main(s32 type, f32 posX, f32 posY, f32 posZ, f32 angle, f32 speed, f32 scale, s32 timeLeft) {
17 EffectBlueprint effectBp;
18 EffectInstance* effect;
20 s32 numParts = 1;
21
22 effectBp.init = huff_puff_breath_init;
25 effectBp.unk_00 = 0;
26 effectBp.renderUI = NULL;
27 effectBp.effectID = EFFECT_HUFF_PUFF_BREATH;
28
29 effect = create_effect_instance(&effectBp);
30 effect->numParts = numParts;
31
32 data = effect->data.huffPuffBreath = general_heap_malloc(numParts * sizeof(*data));
33 ASSERT(data != NULL);
34
35 data->type = type;
36 data->lifeTime = 0;
37 if (timeLeft <= 0) {
38 data->timeLeft = 1000;
39 } else {
40 data->timeLeft = timeLeft;
41 }
42
43 data->primCol.a = 0;
44 data->pos.x = posX;
45 data->pos.y = posY;
46 data->pos.z = posZ;
47 data->scale = scale;
48 data->primCol.r = 255;
49 data->primCol.g = 255;
50 data->primCol.b = 255;
51 data->envCol.r = 255;
52 data->envCol.g = 230;
53 data->envCol.b = 50;
54 data->envCol.a = 255;
55 data->angle = angle;
56 data->speedY = 0;
57 data->speedX = speed;
58 data->texOffsetX = rand_int(32);
59 data->texOffsetY = rand_int(16);
60 data->primCol.r = 255;
61 data->primCol.g = 255;
62 data->primCol.b = 150;
63 data->envCol.r = 215;
64 data->envCol.g = 210;
65 data->envCol.b = 10;
66
67 return effect;
68}
69
72
75 s32 temp_a2;
76
77 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
78 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
79 data->timeLeft = 16;
80 }
81 if (data->timeLeft < 1000) {
82 data->timeLeft--;
83 }
84 temp_a2 = ++data->lifeTime;
85
86 if (data->timeLeft < 0) {
87 remove_effect(effect);
88 return;
89 }
90 if (data->timeLeft < 16) {
91 data->primCol.a = data->timeLeft * 16;
92 }
93 if (temp_a2 < 16) {
94 data->primCol.a = (temp_a2 * 16) + 15;
95 }
96 data->texOffsetX += data->speedX;
97 if (data->texOffsetX >= 256.0f) {
98 data->texOffsetX -= 256.0f;
99 }
100 if (data->texOffsetX < 0.0f) {
101 data->texOffsetX += 256.0f;
102 }
103 data->texOffsetY += data->speedY;
104 if (data->texOffsetY >= 256.0f) {
105 data->texOffsetY -= 256.0f;
106 }
107 if (data->texOffsetY < 0.0f) {
108 data->texOffsetY += 256.0f;
109 }
110}
111
113 RenderTask renderTask;
114 RenderTask* retTask;
115
117 renderTask.appendGfxArg = effect;
118 renderTask.dist = 10;
120
121 retTask = queue_render_task(&renderTask);
122}
123
124void func_E00DC2FC(void) {
125}
126
127void huff_puff_breath_appendGfx(void* effect) {
128 HuffPuffBreathFXData* data = ((EffectInstance*)effect)->data.huffPuffBreath;
129 Camera* camera = &gCameras[gCurrentCameraID];
130 s32 alpha = data->primCol.a;
131 s32 unk_00 = data->type;
132 s32 uls = data->texOffsetX * 4.0f;
133 s32 ult = data->texOffsetY * 4.0f;
134 Matrix4f sp18;
135 Matrix4f sp58;
136
137 gDPPipeSync(gMainGfxPos++);
138 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
139
140 guTranslateF(sp18, data->pos.x, data->pos.y, data->pos.z);
141 guRotateF(sp58, data->angle, 0.0f, 0.0f, 1.0f);
142 guMtxCatF(sp58, sp18, sp18);
143 guScaleF(sp58, data->scale, data->scale, data->scale);
144 guMtxCatF(sp58, sp18, sp18);
146
147 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
148 gSPMatrix(gMainGfxPos++, camera->mtxBillboard, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
149 gDPSetPrimColor(gMainGfxPos++, 0, 0, data->primCol.r, data->primCol.g, data->primCol.b, alpha);
150 gDPSetEnvColor(gMainGfxPos++, data->envCol.r, data->envCol.g, data->envCol.b, data->envCol.a);
151 gSPDisplayList(gMainGfxPos++, D_E00DC648[unk_00]);
152 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, uls, ult, uls + 31 * 4, ult + 15 * 4);
153 gSPDisplayList(gMainGfxPos++, D_E00DC640[unk_00]);
154 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
155}
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 rand_int
#define create_effect_instance
#define guScaleF
struct HuffPuffBreathFXData * huffPuffBreath
Definition effects.h:2574
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
void huff_puff_breath_init(EffectInstance *effect)
void huff_puff_breath_update(EffectInstance *effect)
Gfx * D_E00DC648[]
Gfx * D_E00DC640[]
void huff_puff_breath_render(EffectInstance *effect)
Gfx D_09000400_3D84C0[]
void func_E00DC2FC(void)
EffectInstance * huff_puff_breath_main(s32 type, f32 posX, f32 posY, f32 posZ, f32 angle, f32 speed, f32 scale, s32 timeLeft)
void huff_puff_breath_appendGfx(void *effect)
Gfx D_090005E8_3D86A8[]
Gfx D_09000628_3D86E8[]
#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