Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
smoke_ring.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09002950_32B7F0[];
5extern Gfx D_09002B40_32B9E0[];
6extern Gfx D_09002B60_32BA00[];
7
8s8 D_E002E740[] = {
9 0, 1, 2, 26, 3, 27, 4, 28,
10 5, 29, 6, 22, 38, 71, 87, 103, -1
11};
12
14
18void smoke_ring_appendGfx(void* effect);
19
20void smoke_ring_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3) {
22 EffectBlueprint* bpPtr = &bp;
23 EffectInstance* effect;
24 SmokeRingFXData* part;
25 s32 numParts;
26 f32 factor;
27 s32 i;
28
29 switch (arg0) {
30 case 0:
31 numParts = 7;
32 factor = 14.0f;
33 break;
34 case 1:
35 numParts = 9;
36 factor = 28.0f;
37 break;
38 default:
39 numParts = 11;
40 factor = 42.0f;
41 break;
42 }
43
44 bpPtr->init = smoke_ring_init;
47 bpPtr->unk_00 = 0;
48 bpPtr->renderUI = NULL;
49 bpPtr->effectID = EFFECT_SMOKE_RING;
50
51 effect = create_effect_instance(bpPtr);
52 effect->numParts = numParts;
53 part = effect->data.smokeRing = general_heap_malloc(numParts * sizeof(*part));
54 ASSERT(effect->data.smokeRing != NULL);
55
56 mem_clear(part, numParts * sizeof(*part));
57
58 part->unk_38 = 0;
59 part->unk_3C = 0;
60 part->unk_00 = arg0;
61 part->unk_04 = arg1;
62 part->unk_08 = arg2;
63 part->unk_0C = arg3;
64
65 part++;
66 for (i = 1; i < numParts; i++, part++) {
67 f32 angle = (i - 1) * 360 / (numParts - 1);
68
69 part->unk_10 = -3.0f;
70 part->unk_14 = 0.19999999f;
71 part->unk_18 = 0;
72 part->unk_1C = 0;
73 part->unk_20 = 1.75f;
74 part->unk_24 = -0.16f;
75 part->unk_28 = 0;
76 part->unk_2C = 0;
77 part->unk_04 = -sin_deg(angle) * factor;
78 part->unk_08 = -cos_deg(angle) * factor;
79 part->unk_0C = 0;
80 part->unk_30 = sin_deg(angle);
81 part->unk_34 = cos_deg(angle);
82 }
83}
84
86}
87
89 SmokeRingFXData* part = effect->data.smokeRing;
90 s32 i;
91
92 part->unk_40 = D_E002E754[part->unk_38][part->unk_3C++];
93
94 if (part->unk_40 < 0) {
95 remove_effect(effect);
96 return;
97 }
98
99 part++;
100 for (i = 1; i < effect->numParts; i++, part++) {
101 part->unk_18 += part->unk_1C;
102 part->unk_14 += part->unk_18;
103 part->unk_10 += part->unk_14;
104 part->unk_04 += part->unk_10 * part->unk_30;
105 part->unk_08 += part->unk_10 * part->unk_34;
106 }
107}
108
110 RenderTask renderTask;
111 RenderTask* retTask;
112
113 renderTask.appendGfx = smoke_ring_appendGfx;
114 renderTask.appendGfxArg = effect;
115 renderTask.dist = 0;
117
118 retTask = queue_render_task(&renderTask);
119}
120
121void smoke_ring_appendGfx(void* effect) {
122 SmokeRingFXData* part = ((EffectInstance*)effect)->data.smokeRing;
123 s32 temp_s5 = part->unk_40 & 7;
124 s32 envAlpha = (part->unk_40 & 0x38) * 4;
125 s32 spD8 = part->unk_40 & 0x40;
126 s32 temp_a3;
127 Gfx* dlist;
128 Matrix4f sp18;
129 Matrix4f sp58;
130 Matrix4f sp98;
131 s32 i;
132
133 if (part->unk_00 != 0) {
134 dlist = D_09002B60_32BA00;
135 } else {
136 dlist = D_09002B40_32B9E0;
137 }
138
139 gDPPipeSync(gMainGfxPos++);
140 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
141 gSPDisplayList(gMainGfxPos++, D_09002950_32B7F0);
142
143 guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C);
144 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
145 guMtxCatF(sp58, sp18, sp98);
147
148 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
149 gDPSetPrimColor(gMainGfxPos++, 0, 0, 238, 220, 215, 160);
150 gDPSetEnvColor(gMainGfxPos++, 0, 0, 0, envAlpha);
151 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE,
152 (temp_s5 * 32 ) * 4, 0,
153 (temp_s5 * 32 + 0x1F) * 4, 31 * 4);
154
155 temp_a3 = temp_s5 * 32 + 32;
156
157 if (spD8 != 0) {
158 gDPSetTileSize(gMainGfxPos++, 1,
159 (temp_a3 ) * 4, 32 * 4,
160 (temp_a3 + 31) * 4, 63 * 4);
161 } else {
162 gDPSetTileSize(gMainGfxPos++, 1,
163 (temp_a3 ) * 4, 0,
164 (temp_a3 + 31) * 4, 31 * 4);
165 }
166
167 part++;
168 for (i = 1; i < ((EffectInstance*)effect)->numParts; i++, part++) {
169 guTranslateF(sp18, part->unk_04, part->unk_08, part->unk_0C);
171
172 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
173 gSPDisplayList(gMainGfxPos++, dlist);
174 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
175 }
176
177 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
178 gDPPipeSync(gMainGfxPos++);
179}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define guTranslateF
#define guMtxCatF
#define remove_effect
#define cos_deg
#define create_effect_instance
#define mem_clear
struct SmokeRingFXData * smokeRing
Definition effects.h:2487
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ RENDER_MODE_PASS_THROUGH
Definition enums.h:3306
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
s8 * D_E002E754[]
Definition smoke_ring.c:13
void smoke_ring_appendGfx(void *effect)
Definition smoke_ring.c:121
void smoke_ring_render(EffectInstance *effect)
Definition smoke_ring.c:109
void smoke_ring_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3)
Definition smoke_ring.c:20
Gfx D_09002950_32B7F0[]
void smoke_ring_init(EffectInstance *effect)
Definition smoke_ring.c:85
void smoke_ring_update(EffectInstance *effect)
Definition smoke_ring.c:88
Gfx D_09002B40_32B9E0[]
s8 D_E002E740[]
Definition smoke_ring.c:8
Gfx D_09002B60_32BA00[]
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