Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
breaking_junk.c File Reference

Go to the source code of this file.

Functions

void breaking_junk_init (EffectInstance *effect)
 
void breaking_junk_update (EffectInstance *effect)
 
void breaking_junk_render (EffectInstance *effect)
 
void breaking_junk_appendGfx (void *effect)
 
EffectInstancebreaking_junk_main (s32 arg0, f32 x, f32 y, f32 z, f32 scale, s32 time)
 

Variables

Gfx D_09000400_403FF0 []
 
Gfx D_090005A8_404198 []
 
Gfx D_090005C8_4041B8 []
 
Gfx D_090005E8_4041D8 []
 
Gfx D_09000608_4041F8 []
 
Gfx * D_E01187B0 [] = { D_090005A8_404198, D_090005C8_4041B8, D_090005E8_4041D8, D_09000608_4041F8 }
 
Gfx * D_E01187C0 [] = { D_09000400_403FF0 }
 

Function Documentation

◆ breaking_junk_init()

void breaking_junk_init ( EffectInstance * effect)

Definition at line 83 of file breaking_junk.c.

83 {
84}

Referenced by breaking_junk_main().

◆ breaking_junk_update()

void breaking_junk_update ( EffectInstance * effect)

Definition at line 86 of file breaking_junk.c.

86 {
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}
#define remove_effect
struct BreakingJunkFXData * breakingJunk
Definition effects.h:2590
EffectData data
Definition effects.h:2605
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517

Referenced by breaking_junk_main().

◆ breaking_junk_render()

void breaking_junk_render ( EffectInstance * effect)

Definition at line 121 of file breaking_junk.c.

121 {
122 RenderTask renderTask;
123 RenderTask* retTask;
124
126 renderTask.appendGfxArg = effect;
127 renderTask.dist = 10;
129
130 retTask = queue_render_task(&renderTask);
132}
void breaking_junk_appendGfx(void *effect)
#define queue_render_task
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
void * appendGfxArg
void(* appendGfx)(void *)

Referenced by breaking_junk_main().

◆ breaking_junk_appendGfx()

void breaking_junk_appendGfx ( void * effect)

Definition at line 134 of file breaking_junk.c.

134 {
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_E01187C0[]
Gfx * D_E01187B0[]
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guMtxCatF
#define guPositionF
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
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

Referenced by breaking_junk_render().

◆ breaking_junk_main()

EffectInstance * breaking_junk_main ( s32 arg0,
f32 x,
f32 y,
f32 z,
f32 scale,
s32 time )

Definition at line 19 of file breaking_junk.c.

19 {
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}
void breaking_junk_update(EffectInstance *effect)
void breaking_junk_init(EffectInstance *effect)
void breaking_junk_render(EffectInstance *effect)
#define general_heap_malloc
#define rand_int
#define create_effect_instance
#define ASSERT(condition)
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

Variable Documentation

◆ D_09000400_403FF0

Gfx D_09000400_403FF0[]
extern

◆ D_090005A8_404198

Gfx D_090005A8_404198[]
extern

◆ D_090005C8_4041B8

Gfx D_090005C8_4041B8[]
extern

◆ D_090005E8_4041D8

Gfx D_090005E8_4041D8[]
extern

◆ D_09000608_4041F8

Gfx D_09000608_4041F8[]
extern

◆ D_E01187B0

Definition at line 15 of file breaking_junk.c.

Gfx D_090005E8_4041D8[]
Gfx D_090005C8_4041B8[]
Gfx D_09000608_4041F8[]
Gfx D_090005A8_404198[]

Referenced by breaking_junk_appendGfx().

◆ D_E01187C0

Gfx* D_E01187C0[] = { D_09000400_403FF0 }

Definition at line 17 of file breaking_junk.c.

Gfx D_09000400_403FF0[]

Referenced by breaking_junk_appendGfx().