Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
thunderbolt_ring.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_09000000_3B46A0[];
5extern Gfx D_090000C8_3B4768[];
6
10void thunderbolt_ring_appendGfx(void* effect);
11
12EffectInstance* thunderbolt_ring_main(s32 arg0, f32 posX, f32 posY, f32 posZ, f32 arg4, s32 lifeTime) {
13 EffectBlueprint effectBp;
14 EffectInstance* effect;
16 s32 numParts = 1;
17
18 effectBp.init = thunderbolt_ring_init;
21 effectBp.unk_00 = 0;
22 effectBp.renderUI = NULL;
23 effectBp.effectID = EFFECT_THUNDERBOLT_RING;
24
25 effect = create_effect_instance(&effectBp);
26 effect->numParts = numParts;
27
28 data = effect->data.thunderboltRing = general_heap_malloc(numParts * sizeof(*data));
29 ASSERT(data != NULL);
30
31 data->unk_00 = arg0;
32 data->lifeTime = 0;
33 if (lifeTime <= 0) {
34 data->timeLeft = 1000;
35 } else {
36 data->timeLeft = lifeTime;
37 }
38 data->unk_24 = 255;
39 data->pos.x = posX;
40 data->pos.y = posY;
41 data->pos.z = posZ;
42 data->unk_28 = arg4;
43 data->unk_18 = 255;
44 data->unk_1C = 230;
45 data->unk_20 = 50;
46 data->unk_30 = 0;
47 data->unk_2C = 1.0f;
48
49 return effect;
50}
51
54
57 s32 lifeTime;
58 s32 timeLeft;
59
60 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
61 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
62 data->timeLeft = 16;
63 }
64 if (data->timeLeft < 1000) {
65 data->timeLeft--;
66 }
67
68 timeLeft = data->timeLeft;
69 data->lifeTime++;
70 lifeTime = data->lifeTime;
71
72 if (timeLeft < 0) {
73 remove_effect(effect);
74 return;
75 }
76 if (timeLeft < 8) {
77 data->unk_2C += (8 - timeLeft) * 0.3;
78 }
79 if (lifeTime < 16) {
80 data->unk_24 = (lifeTime * 16) + 15;
81 }
82 if (timeLeft < 8) {
83 data->unk_24 = (timeLeft * 32) + 31;
84 }
85}
86
88 RenderTask renderTask;
89 RenderTask* retTask;
90
92 renderTask.appendGfxArg = effect;
93 renderTask.dist = 10;
95
96 retTask = queue_render_task(&renderTask);
97}
98
99void thunderbolt_ring_appendGfx(void* effect) {
100 ThunderboltRingFXData* data = ((EffectInstance*)effect)->data.thunderboltRing;
101 s32 lifeTime = data->lifeTime;
102 s32 unk_24 = data->unk_24;
103 f32 scaleY = 1.0f;
104 Gfx* savedGfxPos;
105 Gfx* savedGfxPos2;
106 Matrix4f sp20;
107 Matrix4f sp60;
108 s32 i;
109
110 gDPPipeSync(gMainGfxPos++);
111 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
112
113 guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].curYaw, 0.0f, data->unk_28, data->pos.x, data->pos.y, data->pos.z);
115
116 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
117 gSPDisplayList(gMainGfxPos++, D_09000000_3B46A0);
118
119 savedGfxPos = gMainGfxPos++;
120 savedGfxPos2 = gMainGfxPos;
121
122 for (i = 0; i < 5; i++) {
123 guRotateF(sp20, i * 72 + 90, 0.0f, 0.0f, 1.0f);
124 guScaleF(sp60, 1.0f, scaleY, 1.0f);
125 guMtxCatF(sp60, sp20, sp20);
126 guPositionF(sp60, 0.0f, 0.0f, 0.0f, 1.0f, 30.0f, 0.0f, 0.0f);
127 guMtxCatF(sp60, sp20, sp20);
129
130 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
131 gSPDisplayList(gMainGfxPos++, D_090000C8_3B4768);
132 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
133 }
134
135 gSPEndDisplayList(gMainGfxPos++);
136 gSPBranchList(savedGfxPos, gMainGfxPos);
137 gDPSetPrimColor(gMainGfxPos++, 0, 0, data->unk_18, data->unk_1C, data->unk_20, unk_24);
138 gDPSetEnvColor(gMainGfxPos++, 255, 255, 255, 0);
139
140 for (i = 0; i < data->unk_30 + 1; i++) {
141 f32 angle = lifeTime * 8 + i * 180 / (data->unk_30 + 1);
142 f32 temp = (f32) (i + 1) + cos_deg(angle) * 0.1;
143
144 guPositionF(sp20, 0.0f, 0.0f, i * 36, temp * data->unk_2C, 0.0f, 0.0f, 0.0f);
146
147 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
148 gSPDisplayList(gMainGfxPos++, savedGfxPos2);
149 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
150 }
151
152 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
153 gDPPipeSync(gMainGfxPos++);
154}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define guRotateF
#define queue_render_task
#define guMtxF2L
#define guMtxCatF
#define remove_effect
#define guPositionF
#define cos_deg
#define create_effect_instance
#define guScaleF
EffectData data
Definition effects.h:2605
struct ThunderboltRingFXData * thunderboltRing
Definition effects.h:2552
#define ASSERT(condition)
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
#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 *)
void thunderbolt_ring_render(EffectInstance *effect)
EffectInstance * thunderbolt_ring_main(s32 arg0, f32 posX, f32 posY, f32 posZ, f32 arg4, s32 lifeTime)
void thunderbolt_ring_update(EffectInstance *effect)
void thunderbolt_ring_init(EffectInstance *effect)
void thunderbolt_ring_appendGfx(void *effect)
Gfx D_09000000_3B46A0[]
Gfx D_090000C8_3B4768[]
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