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

Go to the source code of this file.

Macros

#define PIRANHA_DMA_ENTRY(name)
 

Functions

void N make_vine_interpolation (LavaPiranhaVine *vine)
 
void N appendGfx_piranha_vines (void *data)
 
void N worker_render_piranha_vines (void)
 

Macro Definition Documentation

◆ PIRANHA_DMA_ENTRY

#define PIRANHA_DMA_ENTRY ( name)
Value:
(s32) world_model_anim_kzn_##name##_ROM_START,\
(s32) world_model_anim_kzn_##name##_ROM_END,\
(s32) world_model_anim_kzn_##name##_VRAM

Definition at line 5 of file part2.inc.c.

5#define PIRANHA_DMA_ENTRY(name) \
6 (s32) world_model_anim_kzn_##name##_ROM_START,\
7 (s32) world_model_anim_kzn_##name##_ROM_END,\
8 (s32) world_model_anim_kzn_##name##_VRAM

Function Documentation

◆ make_vine_interpolation()

void N make_vine_interpolation ( LavaPiranhaVine * vine)

Definition at line 50 of file part2.inc.c.

50 {
51 Evt dummyEvt;
52 Evt* dummyEvtPtr = &dummyEvt;
53 s32 args[4];
54 s32 count;
55
56 // setup dummy call to LoadPath
57 args[0] = 3 * vine->boneCount; // generate three output samples per input
58 args[1] = (s32) &vine->bonePos; // points
59 args[2] = vine->boneCount; // num vectors
60 args[3] = EASING_LINEAR;
61 dummyEvtPtr->ptrReadPos = args;
62 LoadPath(dummyEvtPtr, 1);
63
64 count = 0;
65 do {
66 GetNextPathPos(dummyEvtPtr, 1);
67 vine->points[count].x = evt_get_float_variable(dummyEvtPtr, LVar1);
68 vine->points[count].y = evt_get_float_variable(dummyEvtPtr, LVar2);
69 vine->points[count].z = evt_get_float_variable(dummyEvtPtr, LVar3);
70 count++;
71 } while (dummyEvtPtr->varTable[0] != 0);
72 vine->numPoints = count;
73}
@ EASING_LINEAR
Definition enums.h:510
f32 evt_get_float_variable(Evt *script, Bytecode var)
Definition evt.c:1930
ApiStatus LoadPath(Evt *script, b32 isInitialCall)
ApiStatus GetNextPathPos(Evt *script, b32 isInitialCall)
#define LVar2
Definition macros.h:150
#define LVar1
Definition macros.h:149
#define LVar3
Definition macros.h:151

Referenced by appendGfx_piranha_vines().

◆ appendGfx_piranha_vines()

void N appendGfx_piranha_vines ( void * data)

Definition at line 119 of file part2.inc.c.

119 {
120 Vtx_t* vtxBuffer;
121 Vtx_t* vtx;
122
123 f32 boneLength;
124 s32 boneCount;
125
126 f32 angle;
127 f32 nextAngle;
128 f32 curAngle1;
129 f32 curAngle2;
130
131 f32 alphaCoord;
132 f32 alphaFrac;
133 s32 nearest;
134
135 s32 numPoints;
136 s32 i, j;
137
138 f32 deltaX, deltaY;
139 f32 posX, posY, posZ;
140
141 if (N(VineRenderState) == -1) {
142 return;
143 }
144
145 if (N(VineRenderState) == 0) {
146 for (i = 0; i < NUM_VINES; i++) {
147 LavaPiranhaVine* vines = (LavaPiranhaVine*) evt_get_variable(NULL, MV_VinesData);
148 LavaPiranhaVine* vine = &vines[i];
149
150 switch (i) {
151 default:
152 return;
153 case 0:
154 boneCount = 9;
155 boneLength = 10.0f;
156 break;
157 case 1:
158 boneCount = 7;
159 boneLength = 8.0f;
160 break;
161 case 2:
162 boneCount = 7;
163 boneLength = 8.0f;
164 break;
165 case 3:
166 boneCount = 5;
167 boneLength = 8.0f;
168 break;
169 }
170
171 vine->boneCount = boneCount;
172 vine->boneLength = boneLength;
173
174 for (j = 0; j < boneCount; j++) {
175 if (j == (boneCount - 1)) {
176 vine->boneRot[j] += 90.0f;
177 } else {
178 curAngle1 = vine->boneRot[j];
179 nextAngle = vine->boneRot[j + 1];
180 if (nextAngle - curAngle1 > 180.0f) {
181 curAngle1 += 360.0f;
182 } else if (nextAngle - curAngle1 < -180.0f) {
183 nextAngle += 360.0f;
184 }
185 // average cur and next angles
186 vine->boneRot[j] = ((curAngle1 + nextAngle) / 2.0) + 90.0;
187 }
188 }
189
191 }
192
193 N(VineRenderState) = 1;
194 }
195
196 gDPPipeSync(gMainGfxPos++);
197 gSPDisplayList(gMainGfxPos++, N(lava_piranha_vine_gfx));
198
199 for (i = 0; i < NUM_VINES; i++) {
200 LavaPiranhaVine* vines = (LavaPiranhaVine*) evt_get_variable(NULL, MV_VinesData);
201 LavaPiranhaVine* vine = &vines[i];
202
203 boneLength = vine->boneLength;
204 boneCount = vine->boneCount;
205 numPoints = vine->numPoints;
206
207 // we'll build the vertex data and place it in the display list, so jump forward
208 // here and leave space behind for the gSPBranchList command followed by two vertices
209 // for each point in numPoints
210
211 vtxBuffer = (Vtx_t*)(gMainGfxPos + 1);
212 gSPBranchList(gMainGfxPos, &gMainGfxPos[1 + 2 * (2 * numPoints)]);
213 vtx = (Vtx_t*) (++gMainGfxPos);
214 gMainGfxPos = &gMainGfxPos[2 * (2 * numPoints)];
215
216 for (j = 0; j < numPoints; j++) {
217 posX = vine->points[j].x;
218 posY = vine->points[j].y;
219 posZ = vine->points[j].z;
220
221 alphaCoord = ((f32) j * boneCount) / numPoints;
222 nearest = (s32) alphaCoord;
223 alphaFrac = alphaCoord - (f32)nearest;
224
225 if (nearest + 1 >= boneCount) {
226 angle = vine->boneRot[boneCount - 1];
227 } else {
228 curAngle2 = vine->boneRot[nearest];
229 nextAngle = vine->boneRot[nearest + 1];
230 if (nextAngle - curAngle2 > 180.0f) {
231 nextAngle -= 360.0f;
232 }
233 if (nextAngle - curAngle2 < -180.0f) {
234 nextAngle += 360.0f;
235 }
236 angle = ((nextAngle - curAngle2) * alphaFrac) + curAngle2;
237 }
238
239 deltaX = sin_deg(angle) * boneLength;
240 deltaY = -cos_deg(angle) * boneLength;
241
242 vtx->ob[0] = posX + deltaX;
243 vtx->ob[1] = posY + deltaY;
244 vtx->ob[2] = posZ;
245 vtx->tc[0] = j * 0x140;
246 vtx->tc[1] = 0;
247 vtx->cn[0] = j * 50;
248 vtx->cn[1] = j * 120;
249 vtx->cn[2] = j * 30;
250 vtx++;
251
252 vtx->ob[0] = posX - deltaX;
253 vtx->ob[1] = posY - deltaY;
254 vtx->ob[2] = posZ;
255 vtx->tc[0] = j * 0x140;
256 vtx->tc[1] = 0x400;
257 vtx->cn[0] = j * 50;
258 vtx->cn[1] = j * 120;
259 vtx->cn[2] = j * 30;
260 vtx++;
261 }
262
263 for (j = 0; j < numPoints - 1; j++) {
264 gSPVertex(gMainGfxPos++, &vtxBuffer[2*j], 4, 0);
265 gSP2Triangles(gMainGfxPos++, 1, 0, 2, 0, 1, 2, 3, 0);
266 }
267 }
268
269 gDPPipeSync(gMainGfxPos++);
270}
#define sin_deg
#define cos_deg
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
@ NUM_VINES
Definition part1.inc.c:6
void N make_vine_interpolation(LavaPiranhaVine *vine)
Definition part2.inc.c:50
Gfx * gMainGfxPos
Definition cam_main.c:15

Referenced by worker_render_piranha_vines().

◆ worker_render_piranha_vines()

void N worker_render_piranha_vines ( void )

Definition at line 272 of file part2.inc.c.

272 {
273 RenderTask renderTask;
274
275 renderTask.appendGfx = &N(appendGfx_piranha_vines);
276 renderTask.appendGfxArg = 0;
277 renderTask.dist = 10;
279
280 queue_render_task(&renderTask);
281}
#define queue_render_task
@ RENDER_MODE_SURFACE_OPA
Definition enums.h:3264
void N appendGfx_piranha_vines(void *data)
Definition part2.inc.c:119
void * appendGfxArg
void(* appendGfx)(void *)