Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
blast.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4void blast_init(EffectInstance* effect);
5void blast_update(EffectInstance* effect);
6void blast_render(EffectInstance* effect);
7void blast_appendGfx(void* effect);
8
9extern Gfx D_09001300_37ECD0[];
10extern Gfx D_09001378_37ED48[];
11extern Gfx D_090013F0_37EDC0[];
12extern Gfx D_09001468_37EE38[];
13extern Gfx D_090014E0_37EEB0[];
14extern Gfx D_09001558_37EF28[];
15extern Gfx D_090015D0_37EFA0[];
16extern Gfx D_09001648_37F018[];
17extern Gfx D_090016C0_37F090[];
18extern Gfx D_09001738_37F108[];
19extern Gfx D_090017B0_37F180[];
20
26
27void blast_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) {
29 EffectBlueprint* bpPtr = &bp;
30 EffectInstance* effect;
31 BlastFXData* part;
32 s32 numParts = 1;
33 s32 randInt;
34
35 bp.init = blast_init;
38 bp.unk_00 = 0;
39 bp.renderUI = NULL;
40 bp.effectID = EFFECT_BLAST;
41
42 effect = create_effect_instance(bpPtr);
43 effect->numParts = numParts;
44
45 part = effect->data.blast = general_heap_malloc(numParts * sizeof(*part));
46
47 ASSERT(effect->data.blast != NULL);
48
49 mem_clear(part, numParts * sizeof(*part));
50
51 part->timeLeft = arg5;
52 part->unk_18 = 0;
53 part->unk_1C = arg5;
54 part->unk_20 = 0;
55 part->unk_00 = arg0;
56 part->pos.x = arg1;
57 part->pos.y = arg2;
58 part->pos.z = arg3;
59 part->unk_10 = arg4;
60 part->unk_24 = 0;
61
62 part->unk_28 = arg0 == 0 ? 0 : 40.0;
63}
64
66}
67
69 BlastFXData* part = effect->data.blast;
70
71 part->unk_20 = part->unk_18++ * 9.0f / part->unk_1C;
72 part->timeLeft--;
73
74 if (part->timeLeft < 0) {
75 remove_effect(effect);
76 return;
77 }
78
79 part->unk_24 += part->unk_28;
80}
81
83 RenderTask renderTask;
84 RenderTask* retTask;
85
86 renderTask.appendGfx = blast_appendGfx;
87 renderTask.appendGfxArg = effect;
88 renderTask.dist = 0;
90
91 retTask = queue_render_task(&renderTask);
93}
94
95void blast_appendGfx(void *effect) {
96 Matrix4f sp18;
97 Matrix4f sp58;
98 Matrix4f sp98;
99 Gfx* dlist = D_090017B0_37F180;
100 BlastFXData* data = ((EffectInstance*) effect)->data.blast;
101 s32 unk_20 = data->unk_20;
102 f32 t = 256.0f;
103 s32 envAlpha = (data->unk_20 - unk_20) * t;
104
105 gDPPipeSync(gMainGfxPos++);
106 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
107 gSPDisplayList(gMainGfxPos++, D_09001300_37ECD0);
108 gSPDisplayList(gMainGfxPos++, D_E007C510[unk_20]);
109
110 guTranslateF(sp18, data->pos.x, data->pos.y, data->pos.z);
111 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
112 guMtxCatF(sp58, sp18, sp98);
113 guScaleF(sp18, data->unk_10, data->unk_10, 1.0f);
114 guMtxCatF(sp18, sp98, sp98);
115 guRotateF(sp18, data->unk_24, 0.0f, 0.0f, 1.0f);
116 guMtxCatF(sp18, sp98, sp98);
118
120 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
121
122 if (data->unk_20 > 4.0f) {
123 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 255, 127);
124 } else {
125 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 128, 127);
126 }
127 t = !(s32)t; // required to match
128 gDPSetEnvColor(gMainGfxPos++, 255, 255, 139, envAlpha);
129
130 gSPDisplayList(gMainGfxPos++, dlist);
131 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
132}
Gfx D_09001738_37F108[]
void blast_update(EffectInstance *effect)
Definition blast.c:68
void blast_appendGfx(void *effect)
Definition blast.c:95
Gfx * D_E007C510[]
Definition blast.c:21
Gfx D_09001468_37EE38[]
Gfx D_09001378_37ED48[]
Gfx D_090016C0_37F090[]
void blast_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
Definition blast.c:27
Gfx D_090015D0_37EFA0[]
Gfx D_090017B0_37F180[]
void blast_render(EffectInstance *effect)
Definition blast.c:82
void blast_init(EffectInstance *effect)
Definition blast.c:65
Gfx D_09001648_37F018[]
Gfx D_090014E0_37EEB0[]
Gfx D_09001558_37EF28[]
Gfx D_09001300_37ECD0[]
Gfx D_090013F0_37EDC0[]
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 create_effect_instance
#define mem_clear
#define guScaleF
struct BlastFXData * blast
Definition effects.h:2526
EffectData data
Definition effects.h:2605
Vec3f pos
Definition effects.h:1062
#define ASSERT(condition)
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_PASS_THROUGH
Definition enums.h:3306
#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