Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
debuff.c File Reference

Go to the source code of this file.

Functions

void debuff_init (EffectInstance *effect)
 
void debuff_update (EffectInstance *effect)
 
void debuff_render (EffectInstance *effect)
 
void debuff_appendGfx (void *effect)
 
EffectInstancedebuff_main (s32 type, f32 x, f32 y, f32 z)
 

Variables

Gfx D_09000240_364E40 []
 
Gfx D_090002E8_364EE8 []
 
Gfx * D_E00628C0 [] = { D_090002E8_364EE8 }
 
Gfx * D_E00628C4 [] = { D_09000240_364E40 }
 

Function Documentation

◆ debuff_init()

void debuff_init ( EffectInstance * effect)

Definition at line 82 of file debuff.c.

82 {
83}

Referenced by debuff_main().

◆ debuff_update()

void debuff_update ( EffectInstance * effect)

Definition at line 85 of file debuff.c.

85 {
86 DebuffFXData* data = effect->data.debuff;
87 s32 time;
88 s32 i;
89
90 data->lifetime++;
91 data->timeLeft--;
92 if (data->timeLeft < 0) {
93 remove_effect(effect);
94 return;
95 }
96
97 time = data->lifetime;
98
99 if (time > 10) {
100 data->alpha *= 0.9;
101 }
102
103 data++;
104 for (i = 1; i < effect->numParts; i++, data++) {
105 if (time > 10) {
106 data->scaleY += (1.0 - data->scaleY) * 0.1;
107 data->scaleX += (2.4f - data->scaleX) * 0.1;
108 data->unk_30 += ((100.0f - data->unk_30) * 0.07) * 0.2;
109 }
110 if (time < 10) {
111 data->scaleY += (7.0f - data->scaleY) * 0.05;
112 data->scaleX += (1.0f - data->scaleX) * 0.1;
113 data->unk_30 += ((10.0f - data->unk_30) * 0.05) * 0.6;
114 }
115 data->pos.x = cos_deg(data->rotZ + 90.0f) * data->unk_30;
116 data->pos.y = sin_deg(data->rotZ + 90.0f) * data->unk_30;
117 }
118}
#define sin_deg
#define remove_effect
#define cos_deg
struct DebuffFXData * debuff
Definition effects.h:2513
EffectData data
Definition effects.h:2605
Vec3f pos
Definition effects.h:723

Referenced by debuff_main().

◆ debuff_render()

void debuff_render ( EffectInstance * effect)

Definition at line 120 of file debuff.c.

120 {
121 RenderTask renderTask;
122 RenderTask* retTask;
123
124 renderTask.appendGfx = debuff_appendGfx;
125 renderTask.appendGfxArg = effect;
126 renderTask.dist = 0;
128
129 retTask = queue_render_task(&renderTask);
131}
void debuff_appendGfx(void *effect)
Definition debuff.c:133
#define queue_render_task
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_PASS_THROUGH
Definition enums.h:3306
void * appendGfxArg
void(* appendGfx)(void *)

Referenced by debuff_main().

◆ debuff_appendGfx()

void debuff_appendGfx ( void * effect)

Definition at line 133 of file debuff.c.

133 {
134 EffectInstance* eff = (EffectInstance*)effect;
135 DebuffFXData* data = eff->data.debuff;
136 Gfx* dlist = D_E00628C0[0];
137 Gfx* dlist2 = D_E00628C4[0];
138 Matrix4f mtxTranslate;
139 Matrix4f mtxRotate;
140 Matrix4f mtxTransform;
141 s32 i;
142
143 gDPPipeSync(gMainGfxPos++);
144 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(eff->graphics->data));
145 gSPDisplayList(gMainGfxPos++, dlist2);
146
147 guTranslateF(mtxTranslate, data->pos.x, data->pos.y, data->pos.z);
148 guRotateF(mtxRotate, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
149 guMtxCatF(mtxRotate, mtxTranslate, mtxTransform);
151
152 gSPMatrix(gMainGfxPos++,
153 &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
154 gDPSetPrimColor(gMainGfxPos++, 0, 0, data->primCol.r, data->primCol.g, data->primCol.b, data->alpha);
155 gDPSetEnvColor(gMainGfxPos++, data->envCol.r, data->envCol.g, data->envCol.b, 0);
156
157 data++;
158 for (i = 1; i < eff->numParts; i++, data++) {
159 guTranslateF(mtxTranslate, data->pos.x, data->pos.y, data->pos.z);
160 guRotateF(mtxRotate, data->rotZ, 0.0f, 0.0f, 1.0f);
161 guMtxCatF(mtxRotate, mtxTranslate, mtxTranslate);
162 guScaleF(mtxRotate, data->scaleX, data->scaleY, 1.0f);
163 guMtxCatF(mtxRotate, mtxTranslate, mtxTranslate);
165
166 gSPMatrix(gMainGfxPos++,
167 &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
168 gSPDisplayList(gMainGfxPos++, dlist);
169 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
170 }
171
172 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
173 gDPPipeSync(gMainGfxPos++);
174}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
Gfx * D_E00628C0[]
Definition debuff.c:7
Gfx * D_E00628C4[]
Definition debuff.c:8
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define guScaleF
Color_RGB8 envCol
Definition effects.h:735
Color_RGB8 primCol
Definition effects.h:734
struct EffectGraphics * graphics
Definition effects.h:2606
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
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

Referenced by debuff_render().

◆ debuff_main()

EffectInstance * debuff_main ( s32 type,
f32 x,
f32 y,
f32 z )

Definition at line 15 of file debuff.c.

15 {
17 EffectInstance* effect;
18 DebuffFXData* data;
19 s32 numParts = 8;
20 s32 i;
21
22 bp.unk_00 = 0;
23 bp.init = debuff_init;
26 bp.renderUI = NULL;
27 bp.effectID = EFFECT_DEBUFF;
28
29 effect = create_effect_instance(&bp);
30 effect->numParts = numParts;
31
32 effect->data.debuff = data = general_heap_malloc(numParts * sizeof(*data));
33
34 ASSERT(data != NULL);
35
36 mem_clear(data, numParts * sizeof(*data));
37
38 data->timeLeft = 30;
39 data->lifetime = 0;
40 data->type = type;
41 data->pos.x = x;
42 data->pos.y = y;
43 data->pos.z = z;
44 data->alpha = 255;
45
46 if (type == 0) {
47 data->envCol.r = 20;
48 data->primCol.r = 20;
49 data->envCol.g = 21;
50 data->primCol.g = 21;
51 data->envCol.b = 242;
52 data->primCol.b = 242;
53 } else {
54 data->envCol.r = 200;
55 data->primCol.r = 200;
56 data->envCol.g = 21;
57 data->primCol.g = 21;
58 data->envCol.b = 212;
59 data->primCol.b = 212;
60 }
61
62 data++;
63 for (i = 1; i < numParts; i++, data++) {
64 s32 angle = ((i - 1) * 360) / (numParts - 1);
65 f32 temp2 = 1.0f;
66
67 data->pos.x = cos_deg(angle + 90.0f);
68 data->pos.y = sin_deg(angle + 90.0f);
69 data->pos.z = 0.0f;
70 data->unk_10 = 0.0f;
71 data->unk_14 = 0.0f;
72 data->unk_18 = 0.0f;
73 data->scaleY = 0.1f;
74 data->scaleX = 0.1f;
75 data->unk_30 = temp2;
76 data->rotZ = angle;
77 }
78
79 return effect;
80}
void debuff_init(EffectInstance *effect)
Definition debuff.c:82
void debuff_render(EffectInstance *effect)
Definition debuff.c:120
void debuff_update(EffectInstance *effect)
Definition debuff.c:85
#define general_heap_malloc
#define create_effect_instance
#define mem_clear
#define ASSERT(condition)
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

Variable Documentation

◆ D_09000240_364E40

Gfx D_09000240_364E40[]
extern

◆ D_090002E8_364EE8

Gfx D_090002E8_364EE8[]
extern

◆ D_E00628C0

Gfx* D_E00628C0[] = { D_090002E8_364EE8 }

Definition at line 7 of file debuff.c.

Gfx D_090002E8_364EE8[]

Referenced by debuff_appendGfx().

◆ D_E00628C4

Gfx* D_E00628C4[] = { D_09000240_364E40 }

Definition at line 8 of file debuff.c.

Gfx D_09000240_364E40[]

Referenced by debuff_appendGfx().