Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
floating_rock.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4extern Gfx D_090003A0_396490[];
5extern Gfx D_090003E0_3964D0[];
6extern Gfx D_09000410_396500[];
7extern Gfx D_09000450_396540[];
8
13
17void floating_rock_appendGfx(void* effect);
18
19EffectInstance* floating_rock_main(s32 type, f32 posX, f32 posY, f32 posZ, f32 floorY, f32 fallVelocity, f32 fallAccel, f32 scale, s32 duration) {
21 EffectInstance* effect;
23 s32 numParts = 1;
24
28 bp.unk_00 = 0;
29 bp.renderUI = NULL;
30 bp.effectID = EFFECT_FLOATING_ROCK;
31
32 effect = create_effect_instance(&bp);
33 effect->numParts = numParts;
34 data = effect->data.floatingRock = general_heap_malloc(numParts * sizeof(*data));
35 ASSERT(effect->data.floatingRock != NULL);
36
37 data->type = type;
38 data->pos.x = posX;
39 data->pos.y = posY;
40 data->pos.z = posZ;
41 data->floorY = floorY;
42 data->vel.y = fallVelocity;
43 data->fallAccel = fallAccel;
44 data->timeLeft = duration;
45 data->lifetime = 0;
46 data->vel.x = 0;
47 data->vel.z = 0;
48 data->rot.x = 0;
49 data->rot.y = rand_int(360);
50 data->rot.z = rand_int(360);
51 data->rotVel.x = 0.0f;
52 data->rotVel.z = 20.0f;
53 data->rotVel.y = -20.0f;
54
55 data->scale = 2.0f * scale;
56 data->alpha = 255;
57 data->unk_40 = 0;
58
59 return effect;
60}
61
64
66
68 FloatingRockFXData* data = effect->data.floatingRock;
69 s32 time;
70
71 data->timeLeft--;
72 data->lifetime++;
73 if (data->timeLeft < 0) {
74 remove_effect(effect);
75 return;
76 }
77
78 time = data->timeLeft;
79 if (data->pos.y != data->floorY) {
80 data->vel.y += data->fallAccel;
81 data->pos.y += data->vel.y;
82 data->rot.x += data->rotVel.x;
83 data->rot.z += data->rotVel.z;
84 data->rot.y += data->rotVel.y;
85 if (data->pos.y <= data->floorY) {
86 data->pos.y = data->floorY;
87 load_effect(EFFECT_DUST);
88 dust_main(2, data->pos.x, data->pos.y, data->pos.z, 20);
89 data->timeLeft = 30;
90 }
91 }
92
93 if (time < 10) {
94 data->alpha *= 0.8;
95 }
96}
97
99 FloatingRockFXData* effect76 = effect->data.floatingRock;
100 RenderTask renderTask;
101 RenderTask* retTask;
102
104 renderTask.appendGfxArg = effect;
105 renderTask.dist = effect76->pos.z;
107
108 retTask = queue_render_task(&renderTask);
110}
111
112void floating_rock_appendGfx(void* effect) {
113 FloatingRockFXData* data = ((EffectInstance*)effect)->data.floatingRock;
114 s32 alpha = data->alpha;
115 Matrix4f mtxTransform;
116
117 gDPPipeSync(gMainGfxPos++);
118 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
119
120 guPositionF(mtxTransform, data->rot.x, data->rot.z, data->rot.y, data->scale, data->pos.x, data->pos.y, data->pos.z);
122
123 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
124 gDPSetPrimColor(gMainGfxPos++, 0, 0, 215, 215, 110, alpha);
125
126 if (alpha != 255) {
127 gDPSetRenderMode(gMainGfxPos++, G_RM_AA_ZB_XLU_SURF, G_RM_AA_ZB_XLU_SURF2);
128 } else {
129 gDPSetRenderMode(gMainGfxPos++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2);
130 }
131
132 gSPDisplayList(gMainGfxPos++, D_09000450_396540);
133 gSPDisplayList(gMainGfxPos++, D_E0098510[data->type]);
134 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
135 gDPPipeSync(gMainGfxPos++);
136}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
EffectInstance * dust_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, s32 arg4)
Definition dust.c:15
#define general_heap_malloc
#define queue_render_task
#define guMtxF2L
#define remove_effect
#define rand_int
#define guPositionF
#define load_effect
#define create_effect_instance
EffectData data
Definition effects.h:2605
struct FloatingRockFXData * floatingRock
Definition effects.h:2540
#define ASSERT(condition)
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
void floating_rock_render(EffectInstance *effect)
Gfx D_090003E0_3964D0[]
Gfx D_090003A0_396490[]
void floating_rock_init(EffectInstance *effect)
Gfx * D_E0098510[]
Gfx D_09000450_396540[]
void floating_rock_update(EffectInstance *effect)
EffectInstance * floating_rock_main(s32 type, f32 posX, f32 posY, f32 posZ, f32 floorY, f32 fallVelocity, f32 fallAccel, f32 scale, s32 duration)
void floating_rock_appendGfx(void *effect)
EFFECT_DEF_DUST(dust_main)
Gfx D_09000410_396500[]
#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 *)
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16