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

Go to the source code of this file.

Functions

void ice_shard_init (EffectInstance *effect)
 
void ice_shard_update (EffectInstance *effect)
 
void ice_shard_render (EffectInstance *effect)
 
void ice_shard_appendGfx (void *effect)
 
EffectInstanceice_shard_main (s32 type, f32 posX, f32 posY, f32 posZ, f32 scale, s32 duration)
 

Variables

Gfx D_09001000_3F9CC0 []
 
Gfx D_09001148_3F9E08 []
 
Gfx D_09001168_3F9E28 []
 
Gfx * D_E01108B0 [] = { D_09001148_3F9E08 }
 
Gfx * D_E01108B4 [] = { D_09001000_3F9CC0 }
 

Function Documentation

◆ ice_shard_init()

void ice_shard_init ( EffectInstance * effect)

Definition at line 72 of file ice_shard.c.

72 {
73}

Referenced by ice_shard_main().

◆ ice_shard_update()

void ice_shard_update ( EffectInstance * effect)

Definition at line 75 of file ice_shard.c.

75 {
76 IceShardFXData* data = effect->data.iceShard;
77 s32 type = data->type;
78
79 if (effect->flags & FX_INSTANCE_FLAG_DISMISS) {
80 effect->flags &= ~FX_INSTANCE_FLAG_DISMISS;
81 data->timeLeft = 16;
82 }
83
84 if (data->timeLeft < 1000) {
85 data->timeLeft--;
86 }
87
88 data->lifetime++;
89
90 if (data->timeLeft < 0) {
91 remove_effect(effect);
92 return;
93 }
94
95 if (data->timeLeft < 16) {
96 data->primCol.a = data->timeLeft * 16;
97 }
98
99 data->animFrame += data->animRate;
100
101 if (data->animFrame < 0.0f) {
102 data->animFrame += 1.0f;
103 }
104 if (data->animFrame > 1.0f) {
105 data->animFrame -= 1.0f;
106 }
107
108 data->vel.y += data->gravAccel;
109 data->pos.x += data->vel.x;
110 data->pos.y += data->vel.y;
111 data->pos.z += data->vel.z;
112 data->rot += data->angularVel;
113
114 if (type >= 2 && data->pos.y < 0.0f && data->vel.y < 0.0f) {
115 data->pos.y = 0.0f;
116 data->vel.y *= -0.7;
117 }
118}
#define remove_effect
Color4i primCol
Definition effects.h:2213
struct IceShardFXData * iceShard
Definition effects.h:2586
EffectData data
Definition effects.h:2605
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517

Referenced by ice_shard_main().

◆ ice_shard_render()

void ice_shard_render ( EffectInstance * effect)

Definition at line 120 of file ice_shard.c.

120 {
121 RenderTask renderTask;
122 RenderTask* retTask;
123
124 renderTask.appendGfx = ice_shard_appendGfx;
125 renderTask.appendGfxArg = effect;
126 renderTask.dist = 10;
128
129 retTask = queue_render_task(&renderTask);
131}
#define queue_render_task
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
void ice_shard_appendGfx(void *effect)
Definition ice_shard.c:133
void * appendGfxArg
void(* appendGfx)(void *)

Referenced by ice_shard_main().

◆ ice_shard_appendGfx()

void ice_shard_appendGfx ( void * effect)

Definition at line 133 of file ice_shard.c.

133 {
134 IceShardFXData* data = ((EffectInstance*)effect)->data.iceShard;
135 s32 alpha = data->primCol.a;
136 s32 type = data->type;
137 s32 texCoordS;
138 s32 texCoordT;
139 s32 envAlpha;
140 Matrix4f sp20;
141 Matrix4f unused;
142
143 gDPPipeSync(gMainGfxPos++);
144 gSPSegment(gMainGfxPos++, 0x09, VIRTUAL_TO_PHYSICAL(((EffectInstance*)effect)->graphics->data));
145
146 guPositionF(sp20, 0.0f, -gCameras[gCurrentCameraID].curYaw, 0.0f, data->scale, data->pos.x, data->pos.y, data->pos.z);
148
149 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
150
151 guRotateF(sp20, data->rot, 0.0f, 0.0f, 1.0f);
153
154 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
155 gSPDisplayList(gMainGfxPos++, D_E01108B4[0]);
156
157 texCoordS = (type % 2) * 32;
158 texCoordT = (s32) (data->animFrame * 4.0f) * 32;
159 envAlpha = (data->animFrame * 4.0f - (s32) data->animFrame * 4) * 256.0f;
160
161 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE,
162 (texCoordS ) * 4, (texCoordT ) * 4,
163 (texCoordS + 31) * 4, (texCoordT + 31) * 4);
164 gDPSetTileSize(gMainGfxPos++, 1,
165 (texCoordS ) * 4, (texCoordT + 32) * 4,
166 (texCoordS + 31) * 4, (texCoordT + 63) * 4);
167
168 gDPSetPrimColor(gMainGfxPos++, 0, 0, data->primCol.r, data->primCol.g, data->primCol.b, alpha);
169 gDPSetEnvColor(gMainGfxPos++, data->envCol.r, data->envCol.g, data->envCol.b, envAlpha);
170 gSPDisplayList(gMainGfxPos++, D_E01108B0[0]);
171 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
172
173 if (type % 2 == 1 && (s32) (data->animFrame * 4.0f) == 3) {
174 gDPSetPrimColor(gMainGfxPos++, 0, 0, data->primCol.r, data->primCol.g, data->primCol.b, alpha * envAlpha / 255);
175 gDPSetCombineMode(gMainGfxPos++, PM_CC_3C, PM_CC_3C);
176 gSPDisplayList(gMainGfxPos++, D_09001168_3F9E28);
177 }
178
179 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
180}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guPositionF
Color4i envCol
Definition effects.h:2214
Gfx D_09001168_3F9E28[]
Gfx * D_E01108B4[]
Definition ice_shard.c:9
Gfx * D_E01108B0[]
Definition ice_shard.c:8
#define PM_CC_3C
Definition macros.h:404
#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 ice_shard_render().

◆ ice_shard_main()

EffectInstance * ice_shard_main ( s32 type,
f32 posX,
f32 posY,
f32 posZ,
f32 scale,
s32 duration )

Definition at line 16 of file ice_shard.c.

23 {
25 EffectInstance* effect;
26 IceShardFXData* data;
27 s32 numParts = 1;
28
32 bp.unk_00 = 0;
33 bp.renderUI = NULL;
34 bp.effectID = EFFECT_ICE_SHARD;
35
36 effect = create_effect_instance(&bp);
37 effect->numParts = numParts;
38 data = effect->data.iceShard = general_heap_malloc(numParts * sizeof(*data));
39 ASSERT(effect->data.iceShard != NULL);
40
41 data->type = type;
42 data->lifetime = 0;
43 if (duration <= 0) {
44 data->timeLeft = 1000;
45 } else {
46 data->timeLeft = duration;
47 }
48 data->primCol.a = 255;
49 data->pos.x = posX;
50 data->pos.y = posY;
51 data->pos.z = posZ;
52 data->scale = scale;
53 data->primCol.r = 255;
54 data->primCol.g = 255;
55 data->primCol.b = 255;
56 data->envCol.r = 255;
57 data->envCol.g = 255;
58 data->envCol.b = 255;
59 data->envCol.a = 255;
60 data->animFrame = 0;
61 data->animRate = (rand_int(1) * 2 - 1) * 0.25 * (rand_int(4) * 0.1 + 0.1);
62 data->rot = rand_int(359);
63 data->vel.x = rand_int(10) - 5;
64 data->vel.y = rand_int(10) - 5;
65 data->vel.z = rand_int(10) - 5;
66 data->angularVel = rand_int(40) - 20;
67 data->gravAccel = -0.1f;
68
69 return effect;
70}
#define general_heap_malloc
#define rand_int
#define create_effect_instance
#define ASSERT(condition)
void ice_shard_render(EffectInstance *effect)
Definition ice_shard.c:120
void ice_shard_init(EffectInstance *effect)
Definition ice_shard.c:72
void ice_shard_update(EffectInstance *effect)
Definition ice_shard.c:75
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

Referenced by ice_pillar_update().

Variable Documentation

◆ D_09001000_3F9CC0

Gfx D_09001000_3F9CC0[]
extern

◆ D_09001148_3F9E08

Gfx D_09001148_3F9E08[]
extern

◆ D_09001168_3F9E28

Gfx D_09001168_3F9E28[]
extern

Referenced by ice_shard_appendGfx().

◆ D_E01108B0

Gfx* D_E01108B0[] = { D_09001148_3F9E08 }

Definition at line 8 of file ice_shard.c.

Gfx D_09001148_3F9E08[]

Referenced by ice_shard_appendGfx().

◆ D_E01108B4

Gfx* D_E01108B4[] = { D_09001000_3F9CC0 }

Definition at line 9 of file ice_shard.c.

Gfx D_09001000_3F9CC0[]

Referenced by ice_shard_appendGfx().