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
34 bp.init = blast_init;
37 bp.unk_00 = 0;
38 bp.renderUI = nullptr;
39 bp.effectID = EFFECT_BLAST;
40
41 effect = create_effect_instance(bpPtr);
42 effect->numParts = numParts;
43
44 part = effect->data.blast = general_heap_malloc(numParts * sizeof(*part));
45
46 ASSERT(effect->data.blast != nullptr);
47
48 mem_clear(part, numParts * sizeof(*part));
49
50 part->timeLeft = arg5;
51 part->unk_18 = 0;
52 part->unk_1C = arg5;
53 part->unk_20 = 0;
54 part->unk_00 = arg0;
55 part->pos.x = arg1;
56 part->pos.y = arg2;
57 part->pos.z = arg3;
58 part->unk_10 = arg4;
59 part->unk_24 = 0;
60
61 part->unk_28 = arg0 == 0 ? 0 : 40.0;
62}
63
65}
66
68 BlastFXData* part = effect->data.blast;
69
70 part->unk_20 = part->unk_18++ * 9.0f / part->unk_1C;
71 part->timeLeft--;
72
73 if (part->timeLeft < 0) {
74 remove_effect(effect);
75 return;
76 }
77
78 part->unk_24 += part->unk_28;
79}
80
82 RenderTask renderTask;
83 RenderTask* retTask;
84
85 renderTask.appendGfx = blast_appendGfx;
86 renderTask.appendGfxArg = effect;
87 renderTask.dist = 0;
89
90 retTask = queue_render_task(&renderTask);
92}
93
94void blast_appendGfx(void* effect) {
95 Matrix4f sp18;
96 Matrix4f sp58;
97 Matrix4f sp98;
98 Gfx* dlist = D_090017B0_37F180;
99 BlastFXData* data = ((EffectInstance*) effect)->data.blast;
100 s32 unk_20 = data->unk_20;
101 f32 t = 256.0f;
102 s32 envAlpha = (data->unk_20 - unk_20) * t;
103
104 gDPPipeSync(gMainGfxPos++);
105 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->shared->graphics));
106 gSPDisplayList(gMainGfxPos++, D_09001300_37ECD0);
107 gSPDisplayList(gMainGfxPos++, D_E007C510[unk_20]);
108
109 guTranslateF(sp18, data->pos.x, data->pos.y, data->pos.z);
110 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
111 guMtxCatF(sp58, sp18, sp98);
112 guScaleF(sp18, data->unk_10, data->unk_10, 1.0f);
113 guMtxCatF(sp18, sp98, sp98);
114 guRotateF(sp18, data->unk_24, 0.0f, 0.0f, 1.0f);
115 guMtxCatF(sp18, sp98, sp98);
117
119 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
120
121 if (data->unk_20 > 4.0f) {
122 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 255, 127);
123 } else {
124 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 128, 127);
125 }
126 t = !(s32)t; // required to match
127 gDPSetEnvColor(gMainGfxPos++, 255, 255, 139, envAlpha);
128
129 gSPDisplayList(gMainGfxPos++, dlist);
130 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
131}
Gfx D_09001738_37F108[]
void blast_update(EffectInstance *effect)
Definition blast.c:67
void blast_appendGfx(void *effect)
Definition blast.c:94
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:81
void blast_init(EffectInstance *effect)
Definition blast.c:64
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
EffectInstanceDataPtr data
Definition effects.h:2605
struct BlastFXData * blast
Definition effects.h:2526
Vec3f pos
Definition effects.h:1062
#define ASSERT(condition)
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3352
@ RENDER_MODE_PASS_THROUGH
Definition enums.h:3340
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:46
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(* renderScene)(EffectInstance *effectInst)
Definition effects.h:2654
void * appendGfxArg
void(* appendGfx)(void *)
Camera gCameras[4]
Definition cam_main.c:16
Gfx * gMainGfxPos
Definition cam_main.c:14
u16 gMatrixListPos
Definition main_loop.c:44
s32 gCurrentCameraID
Definition cam_math.c:5
DisplayContext * gDisplayContext
Definition cam_main.c:15