Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
lil_oink.c
Go to the documentation of this file.
1#include "common.h"
2#include "effects_internal.h"
3
4void lil_oink_appendGfx(void* effect);
5void lil_oink_init(EffectInstance* effect);
8
9extern Gfx D_09002D70_401FC0[];
10extern Gfx D_09002DD8_402028[];
11extern Gfx D_09002E70_4020C0[];
12extern Gfx D_09002E98_4020E8[];
13extern Gfx D_09002F30_402180[];
14extern Gfx D_09002FC8_402218[];
15extern Gfx D_09003060_4022B0[];
16extern Gfx D_090030F8_402348[];
17extern Gfx D_09003190_4023E0[];
18extern Gfx D_09003228_402478[];
19extern Gfx D_090032C0_402510[];
20extern Gfx D_09003358_4025A8[];
21extern Gfx D_09003370_4025C0[];
22extern Gfx D_09003388_4025D8[];
23
36
49
50s8 lil_oink_AnimateGfxSelect[] = { 1, 2, 1, 0 };
51
52EffectInstance* lil_oink_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5) {
54 EffectInstance* effect;
55 LilOinkFXData* data;
56 s32 numParts = 1;
57 s32 i;
58
59 bp.unk_00 = 0;
63 bp.renderUI = NULL;
64 bp.effectID = EFFECT_LIL_OINK;
65
66 effect = create_effect_instance(&bp);
67 effect->numParts = numParts;
68 data = effect->data.lilOink = general_heap_malloc(numParts * sizeof(*data));
69 ASSERT(data != NULL);
70
71 data->lifetime = 0;
72 data->timeLeft = 1000;
73
74 for (i = 0; i < MAX_LIL_OINKS; i++) {
75 data->x[i] = 0.0f;
76 data->y[i] = 0.0f;
77 data->z[i] = 0.0f;
78 data->rot[i] = 0.0f;
79 data->flags[i] = 0;
80 data->anim[i] = LIL_OINK_ANIM_1;
81 data->gfxFrame[i] = 1;
82 data->jumpOffset[i] = 0.0f;
83 data->animTime[i] = 0;
84 }
85
86 return effect;
87}
88
90}
91
93 LilOinkFXData* data = effect->data.lilOink;
94 s32 i;
95
96 data->lifetime++;
97
98 for (i = 0; i < MAX_LIL_OINKS; i++) {
99 s32 time = data->animTime[i];
100 s32 animDone = FALSE;
101
102 switch (data->anim[i]) {
103 case LIL_OINK_ANIM_0:
104 animDone = TRUE;
105 break;
106 case LIL_OINK_ANIM_1:
107 data->gfxFrame[i] = 1;
108 animDone = TRUE;
109 break;
110 case LIL_OINK_ANIM_3:
112 data->rot[i] = data->rot[i] + sin_deg(time * 10);
113 if (time >= 36) {
114 animDone = TRUE;
115 data->animTime[i] = 0;
116 }
117 break;
118 case LIL_OINK_ANIM_2:
120 data->jumpOffset[i] = sin_deg(time * 20) * 2.0f;
121 animDone = TRUE;
122 if (time >= 9) {
123 data->jumpOffset[i] = 0.0f;
124 data->animTime[i] = 0;
125 }
126 break;
127 case LIL_OINK_ANIM_4:
129 data->jumpOffset[i] = sin_deg(time * 20) * 4.0f;
130 if (!(time < 9)) {
131 animDone = TRUE;
132 data->jumpOffset[i] = 0.0f;
133 data->animTime[i] = 0;
134 }
135 break;
136 case LIL_OINK_ANIM_5:
137 default:
139 data->jumpOffset[i] = sin_deg(time * 5) * 12.0f;
140 if (!(time < 36)) {
141 animDone = TRUE;
142 data->jumpOffset[i] = 0.0f;
143 data->animTime[i] = 0;
144 }
145 break;
146 }
147 data->animTime[i]++;
148 if (animDone) {
149 if (data->flags[i] & LIL_OINK_FLAG_ANIM_CHANGED) {
150 data->flags[i] &= ~LIL_OINK_FLAG_ANIM_CHANGED;
151 data->animTime[i] = 0;
152 data->anim[i] = data->nextAnim[i];
153 }
154 }
155 }
156}
157
159 RenderTask renderTask;
160 RenderTask* retTask;
161
162 renderTask.appendGfx = lil_oink_appendGfx;
163 renderTask.appendGfxArg = effect;
164 renderTask.dist = 10;
166
167 retTask = queue_render_task(&renderTask);
169}
170
171void lil_oink_appendGfx(void* effect) {
172 Matrix4f mtxTransform;
173 EffectInstance* eff = effect;
174 LilOinkFXData* data = eff->data.lilOink;
175 s32 angle = data->lifetime * 30;
176 s32 i;
177
178 gDPPipeSync(gMainGfxPos++);
179 gSPSegment(gMainGfxPos++, 0x9, VIRTUAL_TO_PHYSICAL(eff->graphics->data));
180
181 gSPDisplayList(gMainGfxPos++, D_09002D70_401FC0);
182 gSPLookAt(gMainGfxPos++, &gDisplayContext->lookAt);
183
184 for (i = 0; i < MAX_LIL_OINKS; i++) {
185 if (data->flags[i] & LIL_OINK_FLAG_VISIBLE) {
186 guPositionF(mtxTransform, 0.0f, 180.0f - data->rot[i], 0.0f, 1.0f,
187 data->x[i], data->y[i] + data->jumpOffset[i], data->z[i]);
189
191 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
192 gSPDisplayList(gMainGfxPos++, D_E0114718[data->type[i]]);
193 if (data->type[i] == LIL_OINK_TYPE_SILVER || data->type[i] == LIL_OINK_TYPE_GOLD) {
194 f32 shineVariation = sin_deg(angle) * 63.0f;
195 s8 primColor = shineVariation + 63.0f;
196
197 gDPSetPrimColor(gMainGfxPos++, 0, 0, primColor, primColor, primColor, 0);
198 }
199 gSPDisplayList(gMainGfxPos++, lil_oink_FramesGfx[data->type[i]][data->gfxFrame[i]]);
200 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
201 }
202 angle += 20;
203 }
204}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define general_heap_malloc
#define queue_render_task
#define guMtxF2L
#define sin_deg
#define guPositionF
#define create_effect_instance
u8 gfxFrame[11]
Definition effects.h:2278
f32 x[11]
Definition effects.h:2271
f32 jumpOffset[11]
Definition effects.h:2279
f32 y[11]
Definition effects.h:2272
@ LIL_OINK_FLAG_ANIM_CHANGED
Definition effects.h:2242
@ LIL_OINK_FLAG_VISIBLE
Definition effects.h:2241
struct LilOinkFXData * lilOink
Definition effects.h:2588
f32 z[11]
Definition effects.h:2273
#define MAX_LIL_OINKS
Definition effects.h:2238
@ LIL_OINK_TYPE_PINK
Definition effects.h:2248
@ LIL_OINK_TYPE_SILVER
Definition effects.h:2254
@ LIL_OINK_TYPE_GOLD
Definition effects.h:2255
@ LIL_OINK_TYPE_QUESTION
Definition effects.h:2253
@ LIL_OINK_TYPE_BLACK
Definition effects.h:2246
@ LIL_OINK_TYPE_STAR
Definition effects.h:2252
@ LIL_OINK_TYPE_PIKACHU
Definition effects.h:2249
@ LIL_OINK_TYPE_FLOWER
Definition effects.h:2251
@ LIL_OINK_TYPE_SHROOM
Definition effects.h:2250
@ LIL_OINK_TYPE_WHITE
Definition effects.h:2247
s8 animTime[11]
Definition effects.h:2280
s32 flags[11]
Definition effects.h:2270
f32 rot[11]
Definition effects.h:2274
@ LIL_OINK_ANIM_0
Definition effects.h:2259
@ LIL_OINK_ANIM_2
Definition effects.h:2261
@ LIL_OINK_ANIM_4
Definition effects.h:2263
@ LIL_OINK_ANIM_3
Definition effects.h:2262
@ LIL_OINK_ANIM_1
Definition effects.h:2260
@ LIL_OINK_ANIM_5
Definition effects.h:2264
struct EffectGraphics * graphics
Definition effects.h:2606
u8 type[11]
Definition effects.h:2275
EffectData data
Definition effects.h:2605
s8 nextAnim[11]
Definition effects.h:2276
u8 anim[11]
Definition effects.h:2277
#define ASSERT(condition)
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
void lil_oink_render(EffectInstance *effect)
Definition lil_oink.c:158
Gfx D_09003358_4025A8[]
Gfx D_09003388_4025D8[]
Gfx D_090032C0_402510[]
Gfx D_09002E98_4020E8[]
Gfx D_09003228_402478[]
EffectInstance * lil_oink_main(s32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, s32 arg5)
Definition lil_oink.c:52
void lil_oink_appendGfx(void *effect)
Definition lil_oink.c:171
Gfx D_09002F30_402180[]
Gfx D_09003190_4023E0[]
Gfx D_09003370_4025C0[]
Gfx D_09003060_4022B0[]
Gfx * D_E0114718[]
Definition lil_oink.c:37
Gfx D_09002E70_4020C0[]
Gfx D_09002DD8_402028[]
Gfx D_09002D70_401FC0[]
void lil_oink_init(EffectInstance *effect)
Definition lil_oink.c:89
Gfx * lil_oink_FramesGfx[][3]
Definition lil_oink.c:24
void lil_oink_update(EffectInstance *effect)
Definition lil_oink.c:92
Gfx D_09002FC8_402218[]
s8 lil_oink_AnimateGfxSelect[]
Definition lil_oink.c:50
Gfx D_090030F8_402348[]
#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 *)
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16