Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
breaking_junk.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
7void breaking_junk_appendGfx(void* effect);
8
9extern Gfx D_09000400_403FF0[];
10extern Gfx D_090005A8_404198[];
11extern Gfx D_090005C8_4041B8[];
12extern Gfx D_090005E8_4041D8[];
13extern Gfx D_09000608_4041F8[];
14
16
18
19EffectInstance* breaking_junk_main(s32 arg0, f32 x, f32 y, f32 z, f32 scale, s32 time) {
21 EffectBlueprint* bpPtr = &bp;
22 EffectInstance* effect;
24 s32 numParts = 6;
25 u32 g;
26 s32 i;
27
28 bp.unk_00 = 0;
32 bp.renderUI = NULL;
33 bp.effectID = EFFECT_BREAKING_JUNK;
34
35 effect = create_effect_instance(bpPtr);
36 effect->numParts = numParts;
37
38 data = effect->data.breakingJunk = general_heap_malloc(numParts * sizeof(*data));
39
40 ASSERT(effect->data.breakingJunk != NULL);
41
42 data->unk_00 = arg0;
43 data->lifeTime = 0;
44 if (time <= 0) {
45 data->timeLeft = 1000;
46 } else {
47 data->timeLeft = time;
48 }
49 data->primA = 255;
50
51 for (i = 0; i < effect->numParts; i++, data++) {
52 data->pos.x = x;
53 data->pos.y = y;
54 data->pos.z = z;
55 data->vel.x = (rand_int(10) - 5) * 0.5;
56 data->vel.y = (rand_int(5) + 1) * 0.8;
57 data->vel.z = (rand_int(10) - 5) * 0.5;
58 data->scale = scale;
59 data->primR = data->envR = rand_int(255);
60 g = rand_int(255 - data->envR);
61 data->primG = data->envG = g;
62 data->primB = data->envB = (255 - g) - data->envR;
63 data->primR += 168;
64 data->primG += 168;
65 data->primB += 168;
66 if (data->primR > 255) {
67 data->primR = 255;
68 }
69 if (data->primG > 255) {
70 data->primG = 255;
71 }
72 if (data->primB > 255) {
73 data->primB = 255;
74 }
75 data->envR = data->envR * 0.6;
76 data->envG = data->envG * 0.6;
77 data->envB = data->envB * 0.6;
78 data->rot = rand_int(359);
79 }
80 return effect;
81}
82
85
87 BreakingJunkFXData* data = effect->data.breakingJunk;
88 s32 i;
89
90 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
91 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
92 data->timeLeft = 16;
93 }
94 if (data->timeLeft < 1000) {
95 data->timeLeft--;
96 }
97
98 data->lifeTime++;
99 if (data->timeLeft < 0) {
100 remove_effect(effect);
101 return;
102 }
103
104 if (data->timeLeft < 8) {
105 data->primA = data->timeLeft * 32;
106 }
107
108 for (i = 0; i < effect->numParts; i++, data++) {
109 data->vel.y -= 0.5;
110 data->pos.x += data->vel.x;
111 data->pos.y += data->vel.y;
112 data->pos.z += data->vel.z;
113 if (data->pos.y < 0.0f && data->vel.y < 0.0f) {
114 data->pos.y = 0.0f;
115 data->vel.y *= -0.7;
116 }
117 data->rot += (((i & 1) * 2) - 1) * 14;
118 }
119}
120
122 RenderTask renderTask;
123 RenderTask* retTask;
124
126 renderTask.appendGfxArg = effect;
127 renderTask.dist = 10;
129
130 retTask = queue_render_task(&renderTask);
132}
133
134void breaking_junk_appendGfx(void* effect) {
135 Matrix4f sp20, sp60;
136 BreakingJunkFXData* data = ((EffectInstance*)effect)->data.breakingJunk;
137 s32 alpha = data->primA;
138 s32 i;
139
140 gDPPipeSync(gMainGfxPos++);
141 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
142 gSPDisplayList(gMainGfxPos++, D_E01187C0[0]);
143
144 for (i = 0; i < ((EffectInstance*)effect)->numParts; i++, data++) {
145 guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].curYaw, 0.0f, data->scale * 0.5, data->pos.x, data->pos.y, data->pos.z);
146 guRotateF(sp60, data->rot, 0.0f, 0.0f, 1.0f);
147 guMtxCatF(sp60, sp20, sp20);
149 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
150 gDPSetPrimColor(gMainGfxPos++, 0, 0, data->primR, data->primG, data->primB, alpha);
151 gDPSetEnvColor(gMainGfxPos++, data->envR, data->envG, data->envB, data->envA);
152 gSPDisplayList(gMainGfxPos++, D_E01187B0[(u32)i % ARRAY_COUNT(D_E01187B0)]);
153 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
154 }
155
156 gDPPipeSync(gMainGfxPos++);
157}
Gfx D_090005E8_4041D8[]
EffectInstance * breaking_junk_main(s32 arg0, f32 x, f32 y, f32 z, f32 scale, s32 time)
Gfx * D_E01187C0[]
void breaking_junk_update(EffectInstance *effect)
Gfx D_090005C8_4041B8[]
Gfx D_09000608_4041F8[]
void breaking_junk_init(EffectInstance *effect)
Gfx D_090005A8_404198[]
Gfx * D_E01187B0[]
Gfx D_09000400_403FF0[]
void breaking_junk_appendGfx(void *effect)
void breaking_junk_render(EffectInstance *effect)
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 rand_int
#define guPositionF
#define create_effect_instance
struct BreakingJunkFXData * breakingJunk
Definition effects.h:2590
EffectData data
Definition effects.h:2605
#define ASSERT(condition)
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
#define ARRAY_COUNT(arr)
Definition macros.h:40
#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