Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
cam_api.c
Go to the documentation of this file.
1#include "common.h"
2
9
16
17API_CALLABLE(SetCamEnabled) {
18 Bytecode* args = script->ptrReadPos;
19 s32 id = evt_get_variable(script, *args++);
20 s32 enabled = evt_get_variable(script, *args++);
21
22 if (!enabled) {
24 } else {
25 gCameras[id].flags &= ~CAMERA_FLAG_DISABLED;
26 }
27 return ApiStatus_DONE2;
28}
29
30API_CALLABLE(SetCamNoDraw) {
31 Bytecode* args = script->ptrReadPos;
32 s32 id = evt_get_variable(script, *args++);
33 s32 enabled = evt_get_variable(script, *args++);
34
35 if (!enabled) {
37 } else {
38 gCameras[id].flags &= ~CAMERA_FLAG_NO_DRAW;
39 }
40 return ApiStatus_DONE2;
41}
42
43API_CALLABLE(SetCamPerspective) {
44 Bytecode* args = script->ptrReadPos;
45 s32 id = evt_get_variable(script, *args++);
46 s16 mode = evt_get_variable(script, *args++);
47 f32 vfov = evt_get_float_variable(script, *args++);
48 s16 nearClip = evt_get_variable(script, *args++);
49 s16 farClip = evt_get_variable(script, *args++);
50 Camera* camera = &gCameras[id];
51
52 camera->updateMode = mode;
53 camera->needsInit = TRUE;
54 camera->needsReinit = TRUE;
55
56 camera->vfov = vfov;
57 camera->farClip = farClip;
58 camera->nearClip = nearClip;
59 return ApiStatus_DONE2;
60}
61
62API_CALLABLE(SetCamUpdateMode) {
63 Bytecode* args = script->ptrReadPos;
64 s32 id = evt_get_variable(script, *args++);
65 s16 mode = evt_get_variable(script, *args++);
66 Camera* camera = &gCameras[id];
67
68 camera->updateMode = mode;
69 camera->needsInit = FALSE;
70 return ApiStatus_DONE2;
71}
72
73API_CALLABLE(GrabCamera) {
74 Bytecode* args = script->ptrReadPos;
75 Bytecode id = evt_get_variable(script, *args++);
76 Bytecode outVar1 = *args++;
77 Bytecode outVar2 = *args++;
78 Bytecode outVar3 = *args++;
79 Bytecode outVar4 = *args++;
80 f32 dx, dy, dz;
81
83 gCameras[id].needsInit = FALSE;
84 gCameras[id].params.interp.pitch = -round(gCameras[id].lookAt_pitch);
85 gCameras[id].params.interp.yaw = -gCameras[id].lookAt_yaw;
86 gCameras[id].params.interp.offsetY = 0;
87
91
92 gCameras[id].params.interp.dist = round(sqrtf(SQ(dx) + SQ(dy) + SQ(dz)));
93
97
98 evt_set_variable(script, outVar1, gCameras[id].params.interp.pitch);
99 evt_set_variable(script, outVar2, gCameras[id].params.interp.yaw);
100 evt_set_variable(script, outVar3, gCameras[id].params.interp.dist);
101 evt_set_variable(script, outVar4, gCameras[id].params.interp.offsetY);
102 return ApiStatus_DONE2;
103}
104
105API_CALLABLE(GetInterpCamDist) {
106 Bytecode* args = script->ptrReadPos;
107 Bytecode id = evt_get_variable(script, *args++);
108 Bytecode outVar = *args++;
109
110 evt_set_variable(script, outVar, gCameras[id].params.interp.dist);
111 return ApiStatus_DONE2;
112}
113
114API_CALLABLE(GetInterpCamOffsetY) {
115 Bytecode* args = script->ptrReadPos;
116 Bytecode id = evt_get_variable(script, *args++);
117 Bytecode outVar = *args++;
118
119 evt_set_variable(script, outVar, gCameras[id].params.interp.offsetY);
120 return ApiStatus_DONE2;
121}
122
123API_CALLABLE(SetInterpCamDist) {
124 Bytecode* args = script->ptrReadPos;
125 s32 id = evt_get_variable(script, *args++);
126 s32 dist = evt_get_variable(script, *args++);
127
128 gCameras[id].params.interp.dist = dist;
129 return ApiStatus_DONE2;
130}
131
132API_CALLABLE(SetInterpCamOffsetY) {
133 Bytecode* args = script->ptrReadPos;
134 s32 id = evt_get_variable(script, *args++);
135 s32 offsetY = evt_get_variable(script, *args++);
136
137 gCameras[id].params.interp.offsetY = offsetY;
138 return ApiStatus_DONE2;
139}
140
141API_CALLABLE(SetInterpCamParams) {
142 Bytecode* args = script->ptrReadPos;
143 s32 id = evt_get_variable(script, *args++);
144 s32 pitch = evt_get_variable(script, *args++);
145 s32 yaw = evt_get_variable(script, *args++);
146 s32 dist = evt_get_variable(script, *args++);
147 s32 offsetY = evt_get_variable(script, *args++);
148 Camera* camera = &gCameras[id];
149
150 camera->params.interp.pitch = pitch;
151 camera->params.interp.yaw = yaw;
152 camera->params.interp.dist = dist;
153 camera->params.interp.offsetY = offsetY;
154 return ApiStatus_DONE2;
155}
156
157API_CALLABLE(SetNoInterpCamParams) {
158 Bytecode* args = script->ptrReadPos;
159 s32 id = evt_get_variable(script, *args++);
160 b32 skipRecalc = evt_get_variable(script, *args++);
161 s32 dist = evt_get_variable(script, *args++);
162 s32 fovScale = evt_get_variable(script, *args++);
163 s32 pitch = evt_get_variable(script, *args++);
164 Camera* camera = &gCameras[id];
165
166 camera->params.basic.skipRecalc = skipRecalc;
167 camera->params.basic.dist = dist;
168 camera->params.basic.fovScale = fovScale;
169 camera->params.basic.pitch = pitch;
170 return ApiStatus_DONE2;
171}
172
173API_CALLABLE(SetCamViewport) {
174 Bytecode* args = script->ptrReadPos;
175 s32 id = evt_get_variable(script, *args++);
176 s32 x = evt_get_variable(script, *args++);
177 s32 y = evt_get_variable(script, *args++);
178 s16 width = evt_get_variable(script, *args++);
179 s16 height = evt_get_variable(script, *args++);
180
181 set_cam_viewport(id, x, y, width, height);
182 return ApiStatus_DONE2;
183}
184
185API_CALLABLE(SetCamBGColor) {
186 Bytecode* args = script->ptrReadPos;
187 s32 id = evt_get_variable(script, *args++);
188 s16 r = evt_get_variable(script, *args++);
189 s16 g = evt_get_variable(script, *args++);
190 s16 b = evt_get_variable(script, *args++);
191 Camera* camera = &gCameras[id];
192
193 camera->bgColor[0] = r;
194 camera->bgColor[1] = g;
195 camera->bgColor[2] = b;
196 return ApiStatus_DONE2;
197}
198
199API_CALLABLE(SetCamLookTarget) {
200 Bytecode* args = script->ptrReadPos;
201 s32 id = evt_get_variable(script, *args++);
202 s32 x = evt_get_variable(script, *args++);
203 s32 y = evt_get_variable(script, *args++);
204 s32 z = evt_get_variable(script, *args++);
205 Camera* camera = &gCameras[id];
206
207 camera->lookAt_obj_target.x = x;
208 camera->lookAt_obj_target.y = y;
209 camera->lookAt_obj_target.z = z;
210 return ApiStatus_DONE2;
211}
212
213API_CALLABLE(SetCamTarget) {
214 Bytecode* args = script->ptrReadPos;
215 s32 id = evt_get_variable(script, *args++);
216 s32 x = evt_get_variable(script, *args++);
217 s32 y = evt_get_variable(script, *args++);
218 s32 z = evt_get_variable(script, *args++);
219 Camera* camera = &gCameras[id];
220
221 camera->targetPos.x = x;
222 camera->targetPos.y = y;
223 camera->targetPos.z = z;
224 return ApiStatus_DONE2;
225}
226
227API_CALLABLE(InterpCamTargetPos) {
228 typedef struct CamInterpData {
229 /* 0x00 */ Camera* cam;
230 /* 0x04 */ s32 useTarget;
231 /* 0x08 */ Vec3f vel;
232 /* 0x14 */ s32 time;
233 } CamInterpData; // size = 0x18
234
235 Bytecode* args = script->ptrReadPos;
236 CamInterpData* data;
237 Camera* cam;
238
239 if (isInitialCall) {
240 s32 camID = evt_get_variable(script, *args++);
241 s32 useTarget = evt_get_variable(script, *args++);
242 s32 posX = evt_get_variable(script, *args++);
243 s32 posY = evt_get_variable(script, *args++);
244 s32 posZ = evt_get_variable(script, *args++);
245 s32 time = evt_get_variable(script, *args++);
246
247 data = heap_malloc(sizeof(*data));
248 script->userData = data;
249 cam = &gCameras[camID];
250 data->cam = cam;
251 data->useTarget = useTarget;
252 data->time = time;
253
254 switch (data->useTarget) {
255 case 0:
256 data->vel.x = (posX - cam->lookAt_obj_target.x) / data->time;
257 data->vel.y = (posY - cam->lookAt_obj_target.y) / data->time;
258 data->vel.z = (posZ - cam->lookAt_obj_target.z) / data->time;
259 break;
260 case 1:
261 data->vel.x = (posX - cam->targetPos.x) / data->time;
262 data->vel.y = (posY - cam->targetPos.y) / data->time;
263 data->vel.z = (posZ - cam->targetPos.z) / data->time;
264 break;
265 }
266 }
267
268 data = script->userData;
269 cam = data->cam;
270 switch (data->useTarget) {
271 case 0:
272 cam->lookAt_obj_target.x += data->vel.x;
273 cam->lookAt_obj_target.y += data->vel.y;
274 cam->lookAt_obj_target.z += data->vel.z;
275 break;
276 case 1:
277 cam->targetPos.x += data->vel.x;
278 cam->targetPos.y += data->vel.y;
279 cam->targetPos.z += data->vel.z;
280 break;
281 }
282
283 data->time--;
284 if (data->time == 0) {
285 heap_free(script->userData);
286 script->userData = NULL;
287 return ApiStatus_DONE2;
288 }
289 return ApiStatus_BLOCK;
290}
291
292API_CALLABLE(ShakeCam) {
293 Bytecode* args = script->ptrReadPos;
294 s32 camIndex = evt_get_variable(script, *args++);
295 s32 shakeMode = evt_get_variable(script, *args++);
296 s32 duration = evt_get_variable(script, *args++);
297 f32 magnitude = 2.0f * evt_get_float_variable(script, *args++);
298 Camera* camera = &gCameras[camIndex];
299 f32 scale;
300 f32 rumbleMagnitude;
301 s32 rumbleDuration;
302
303 if (isInitialCall) {
304 switch (shakeMode){
307 break;
309 duration *= 4;
310 break;
311 }
312
313 script->functionTempF[3] = 1.0f;
314 script->functionTemp[1] = duration;
315
317 if (magnitude > 10.0f) {
318 magnitude = 10.0f;
319 }
320
321 rumbleMagnitude = magnitude;
322 if (rumbleMagnitude > 6.0f) {
323 rumbleMagnitude = 6.0f;
324 }
325 rumbleMagnitude = rumbleMagnitude * 32.0f + 64.0f;
326
327 rumbleDuration = duration;
328
329 if (rumbleDuration < 5) {
330 rumbleDuration = 5;
331 }
332 start_rumble(rumbleMagnitude, (rumbleDuration & 0xFFFF) * 2);
333 }
334 }
335
336 camera->flags |= CAMERA_FLAG_SHAKING;
337 scale = script->functionTempF[3];
338 switch (shakeMode) {
340 guTranslateF(camera->mtxViewShaking, 0.0f, -scale * magnitude, 0.0f);
341 script->functionTempF[3] = -script->functionTempF[3];
342 break;
344 guRotateF(camera->mtxViewShaking, scale * magnitude, 0.0f, 0.0f, 1.0f);
345 script->functionTempF[3] = -script->functionTempF[3];
346 break;
348 guTranslateF(camera->mtxViewShaking, 0.0f, -scale * magnitude, 0.0f);
349 if ((script->functionTemp[1] < (duration * 2)) && (duration < script->functionTemp[1])) {
350 script->functionTempF[3] = script->functionTempF[3] * -0.8;
351 } else {
352 script->functionTempF[3] = -script->functionTempF[3];
353 }
354 break;
355 }
356
357 if (script->functionTemp[1] == 0) {
358 camera->flags &= ~CAMERA_FLAG_SHAKING;
359 return ApiStatus_DONE2;
360 }
361 script->functionTemp[1]--;
362 return ApiStatus_BLOCK;
363}
364
365void exec_ShakeCam1(s32 camID, s32 mode, s32 duration) {
366 Evt* script;
367
369 script->varTable[0] = camID;
370 script->varTable[1] = mode;
371 script->varTable[2] = duration;
372}
373
374void exec_ShakeCamX(s32 camID, s32 mode, s32 duration, f32 magnitude) {
375 Evt* script;
376
378 evt_set_variable(script, LVar0, camID);
379 evt_set_variable(script, LVar1, mode);
380 evt_set_variable(script, LVar2, duration);
381 evt_set_float_variable(script, LVar3, magnitude);
382}
383
384API_CALLABLE(SetCamLeadPlayer) {
385 Bytecode* args = script->ptrReadPos;
386 s32 id = evt_get_variable(script, *args++);
387 s32 enabled = evt_get_variable(script, *args++);
388 Camera* camera = &gCameras[id];
389
390 if (enabled) {
392 } else {
393 camera->flags &= ~CAMERA_FLAG_LEAD_PLAYER;
394 }
395 return ApiStatus_DONE2;
396}
397
398API_CALLABLE(EnableCameraFollowPlayerY) {
399 Camera* camera = &gCameras[CAM_DEFAULT];
400
401 camera->moveFlags &= ~CAMERA_MOVE_IGNORE_PLAYER_Y;
402 return ApiStatus_DONE2;
403}
404
405API_CALLABLE(DisableCameraFollowPlayerY) {
406 Camera* camera = &gCameras[CAM_DEFAULT];
407
409 return ApiStatus_DONE2;
410}
411
412API_CALLABLE(EnableCameraLeadingPlayer) {
413 Camera* camera = &gCameras[CAM_DEFAULT];
414
415 camera->flags &= ~CAMERA_FLAG_SUPRESS_LEADING;
416 return ApiStatus_DONE2;
417}
418
419API_CALLABLE(DisableCameraLeadingPlayer) {
420 Camera* camera = &gCameras[CAM_DEFAULT];
421
423 return ApiStatus_DONE2;
424}
425
426API_CALLABLE(SetCamLeadScale) {
427 Bytecode* args = script->ptrReadPos;
428 s32 id = evt_get_variable(script, *args++);
429 f32 value = evt_get_variable(script, *args++);
430 Camera* camera = &gCameras[id];
431
432 camera->leadAmtScale = (value / 100.0f);
433 return ApiStatus_DONE2;
434}
435
436API_CALLABLE(PanToTarget) {
437 Bytecode* args = script->ptrReadPos;
438 s32 id = evt_get_variable(script, *args++);
439 f32 panPhase = evt_get_float_variable(script, *args++);
440 s32 targetType = evt_get_variable(script, *args++);
441 Camera* camera = &gCameras[id];
442
443 camera->panActive = TRUE;
444 if (targetType != 0) {
445 camera->useOverrideSettings = TRUE;
446 camera->interpEasingParameter = panPhase;
447 } else {
448 camera->useOverrideSettings = FALSE;
449 camera->interpEasingParameter = 0.0f;
450 camera->moveSpeed = 1.0f;
451 }
452 return ApiStatus_DONE2;
453}
454
455API_CALLABLE(UseSettingsFrom) {
456 Bytecode* args = script->ptrReadPos;
457 s32 id = evt_get_variable(script, *args++);
458 Camera* camera = &gCameras[id];
459 f32 startX = evt_get_float_variable(script, *args++);
460 f32 startY = evt_get_float_variable(script, *args++);
461 f32 startZ = evt_get_float_variable(script, *args++);
462 f32 hitX, hitY, hitZ;
463 f32 hitDepth = 32767.0f;
464 f32 nx, ny, nz;
465 s32 hitID = test_ray_zones(startX, startY + 10.0f, startZ, 0.0f, -1.0f, 0.0f, &hitX, &hitY, &hitZ, &hitDepth,
466 &nx, &ny, &nz);
467
468 if (hitID > NO_COLLIDER) {
469 camera->overrideSettings = *gZoneCollisionData.colliderList[hitID].camSettings;
470 }
471 return ApiStatus_DONE2;
472}
473
474API_CALLABLE(LoadSettings) {
475 Bytecode* args = script->ptrReadPos;
476 s32 id = evt_get_variable(script, *args++);
477 Camera* camera = &gCameras[id];
478 CameraControlSettings* settings = (CameraControlSettings*) evt_get_variable(script, *args++);
479
480 camera->overrideSettings = *settings;
481 return ApiStatus_DONE2;
482}
483
484API_CALLABLE(SetCamType) {
485 Bytecode* args = script->ptrReadPos;
486 s32 id = evt_get_variable(script, *args++);
487 Camera* camera = &gCameras[id];
488 s32 controllerType = evt_get_variable(script, *args++);
489 s32 enabled = evt_get_variable(script, *args++);
490
491 camera->overrideSettings.flag = enabled;
492 camera->overrideSettings.type = controllerType;
493 return ApiStatus_DONE2;
494}
495
496API_CALLABLE(SetCamPitch) {
497 Bytecode* args = script->ptrReadPos;
498 s32 id = evt_get_variable(script, *args++);
499 Camera* camera = &gCameras[id];
500 f32 boomPitch = evt_get_float_variable(script, *args++);
501 f32 viewPitch = evt_get_float_variable(script, *args++);
502
503 camera->overrideSettings.boomPitch = boomPitch;
504 camera->overrideSettings.viewPitch = viewPitch;
505 return ApiStatus_DONE2;
506}
507
508API_CALLABLE(SetCamDistance) {
509 Bytecode* args = script->ptrReadPos;
510 s32 id = evt_get_variable(script, *args++);
511 Camera* camera = &gCameras[id];
512 f32 boomLength = evt_get_float_variable(script, *args++);
513
514 camera->overrideSettings.boomLength = boomLength;
515 return ApiStatus_DONE2;
516}
517
518API_CALLABLE(SetCamPosA) {
519 Bytecode* args = script->ptrReadPos;
520 s32 id = evt_get_variable(script, *args++);
521 Camera* camera = &gCameras[id];
522 f32 x = evt_get_float_variable(script, *args++);
523 f32 z = evt_get_float_variable(script, *args++);
524
525 camera->overrideSettings.points.three.Ax = x;
526 camera->overrideSettings.points.three.Az = z;
527 return ApiStatus_DONE2;
528}
529
530API_CALLABLE(SetCamPosB) {
531 Bytecode* args = script->ptrReadPos;
532 s32 id = evt_get_variable(script, *args++);
533 Camera* camera = &gCameras[id];
534 f32 x = evt_get_float_variable(script, *args++);
535 f32 z = evt_get_float_variable(script, *args++);
536
537 camera->overrideSettings.points.three.Bx = x;
538 camera->overrideSettings.points.three.Bz = z;
539 return ApiStatus_DONE2;
540}
541
542API_CALLABLE(SetCamPosC) {
543 Bytecode* args = script->ptrReadPos;
544 s32 id = evt_get_variable(script, *args++);
545 Camera* camera = &gCameras[id];
546 f32 y1 = evt_get_float_variable(script, *args++);
547 f32 y2 = evt_get_float_variable(script, *args++);
548
549 camera->overrideSettings.points.three.Cx = y1;
550 camera->overrideSettings.points.three.Cz = y2;
551 return ApiStatus_DONE2;
552}
553
554API_CALLABLE(SetPanTarget) {
555 Bytecode* args = script->ptrReadPos;
556 s32 id = evt_get_variable(script, *args++);
557 Camera* camera = &gCameras[id];
558 f32 x = evt_get_float_variable(script, *args++);
559 f32 y = evt_get_float_variable(script, *args++);
560 f32 z = evt_get_float_variable(script, *args++);
561
562 camera->movePos.x = x;
563 camera->movePos.y = y;
564 camera->movePos.z = z;
565 camera->panActive = TRUE;
566 return ApiStatus_DONE2;
567}
568
569API_CALLABLE(SetCamSpeed) {
570 Bytecode* args = script->ptrReadPos;
571 s32 id = evt_get_variable(script, *args++);
572 f32 speed = evt_get_float_variable(script, *args++);
573 Camera* camera = &gCameras[id];
574
575 camera->moveSpeed = speed;
576 return ApiStatus_DONE2;
577}
578
579API_CALLABLE(GetCamType) {
580 Bytecode* args = script->ptrReadPos;
581 s32 id = evt_get_variable(script, *args++);
582 Bytecode outVar1 = *args++;
583 Bytecode outVar2 = *args++;
584 Camera* camera = &gCameras[id];
585
586 evt_set_variable(script, outVar1, camera->overrideSettings.type);
587 evt_set_variable(script, outVar2, camera->overrideSettings.flag);
588 return ApiStatus_DONE2;
589}
590
591API_CALLABLE(GetCamPitch) {
592 Bytecode* args = script->ptrReadPos;
593 s32 id = evt_get_variable(script, *args++);
594 Bytecode outVar1 = *args++;
595 Bytecode outVar2 = *args++;
596 Camera* camera = &gCameras[id];
597
598 evt_set_float_variable(script, outVar1, camera->overrideSettings.boomPitch);
599 evt_set_float_variable(script, outVar2, camera->overrideSettings.viewPitch);
600 return ApiStatus_DONE2;
601}
602
603API_CALLABLE(GetCamDistance) {
604 Bytecode* args = script->ptrReadPos;
605 s32 id = evt_get_variable(script, *args++);
606 Bytecode outVar1 = *args++;
607 Camera* camera = &gCameras[id];
608
609 evt_set_float_variable(script, outVar1, camera->overrideSettings.boomLength);
610 return ApiStatus_DONE2;
611}
612
613API_CALLABLE(GetCamPosA) {
614 Bytecode* args = script->ptrReadPos;
615 s32 id = evt_get_variable(script, *args++);
616 Bytecode outVar1 = *args++;
617 Bytecode outVar2 = *args++;
618 Camera* camera = &gCameras[id];
619
620 evt_set_float_variable(script, outVar1, camera->overrideSettings.points.three.Ax);
621 evt_set_float_variable(script, outVar2, camera->overrideSettings.points.three.Az);
622 return ApiStatus_DONE2;
623}
624
625API_CALLABLE(GetCamPosB) {
626 Bytecode* args = script->ptrReadPos;
627 s32 id = evt_get_variable(script, *args++);
628 Bytecode outVar1 = *args++;
629 Bytecode outVar2 = *args++;
630 Camera* camera = &gCameras[id];
631
632 evt_set_float_variable(script, outVar1, camera->overrideSettings.points.three.Bx);
633 evt_set_float_variable(script, outVar2, camera->overrideSettings.points.three.Bz);
634 return ApiStatus_DONE2;
635}
636
637API_CALLABLE(GetCamPosC) {
638 Bytecode* args = script->ptrReadPos;
639 s32 id = evt_get_variable(script, *args++);
640 Bytecode outVar1 = *args++;
641 Bytecode outVar2 = *args++;
642 Camera* camera = &gCameras[id];
643
644 evt_set_float_variable(script, outVar1, camera->overrideSettings.points.three.Cx);
645 evt_set_float_variable(script, outVar2, camera->overrideSettings.points.three.Cz);
646 return ApiStatus_DONE2;
647}
648
649API_CALLABLE(GetCamPosition) {
650 Bytecode* args = script->ptrReadPos;
651 s32 id = evt_get_variable(script, *args++);
652 Bytecode outVar1 = *args++;
653 Bytecode outVar2 = *args++;
654 Bytecode outVar3 = *args++;
655 Camera* camera = &gCameras[id];
656
657 evt_set_float_variable(script, outVar1, camera->movePos.x);
658 evt_set_float_variable(script, outVar2, camera->movePos.y);
659 evt_set_float_variable(script, outVar3, camera->movePos.z);
660 return ApiStatus_DONE2;
661}
662
663API_CALLABLE(WaitForCam) {
664 Bytecode* args = script->ptrReadPos;
665 s32 id = evt_get_variable(script, *args++);
666 f32 endInterpValue = evt_get_float_variable(script, *args++);
667 Camera* camera = &gCameras[id];
668
669 if (isInitialCall || (endInterpValue > camera->interpAlpha)) {
670 return ApiStatus_BLOCK;
671 }
672 return ApiStatus_DONE2;
673}
674
675API_CALLABLE(SetCamProperties) {
676 f32 hitX, hitY, hitZ, hitDepth, nX, nY, nZ;
677 s32 zoneID;
678 Bytecode* args = script->ptrReadPos;
679 Camera* camera = &gCameras[evt_get_variable(script, *args++)];
680 f32 moveSpeed = evt_get_float_variable(script, *args++);
681 f32 posX = evt_get_float_variable(script, *args++);
682 f32 posY = evt_get_float_variable(script, *args++);
683 f32 posZ = evt_get_float_variable(script, *args++);
684 f32 boomLength = evt_get_float_variable(script, *args++);
685 f32 boomPitch = evt_get_float_variable(script, *args++);
686 f32 viewPitch = evt_get_float_variable(script, *args++);
687
688 if (isInitialCall) {
689 hitDepth = 32767.0f;
690 zoneID = test_ray_zones(posX, posY + 10.0f, posZ, 0.0f, -1.0f, 0.0f, &hitX, &hitY, &hitZ, &hitDepth, &nX, &nY, &nZ);
691 if (zoneID >= 0) {
692 camera->overrideSettings = *gZoneCollisionData.colliderList[zoneID].camSettings;
693 }
694
695 camera->movePos.x = posX;
696 camera->movePos.y = posY;
697 camera->movePos.z = posZ;
698 camera->overrideSettings.boomLength = boomLength;
699 camera->overrideSettings.boomPitch = boomPitch;
700 camera->overrideSettings.viewPitch = viewPitch;
701 camera->moveSpeed = moveSpeed;
702 camera->panActive = TRUE;
703 camera->useOverrideSettings = TRUE;
704 camera->interpEasingParameter = 0.0f;
705 return ApiStatus_BLOCK;
706 }
707
708 if (camera->interpAlpha < 1.0f) {
709 return ApiStatus_BLOCK;
710 }
711
712 return ApiStatus_DONE2;
713}
714
715API_CALLABLE(AdjustCam) {
716 f32 hitX, hitY, hitZ, hitDepth, nX, nY, nZ;
717 f32 posX, posY, posZ;
718 s32 zoneID;
719 Bytecode* args = script->ptrReadPos;
720 Camera* camera = &gCameras[evt_get_variable(script, *args++)];
721 f32 moveSpeed = evt_get_float_variable(script, *args++);
722 f32 deltaPosX = evt_get_float_variable(script, *args++);
723 f32 boomLength = evt_get_float_variable(script, *args++);
724 f32 boomPitch = evt_get_float_variable(script, *args++);
725 f32 viewPitch = evt_get_float_variable(script, *args++);
726 PlayerStatus* playerStatus = &gPlayerStatus;
727
728 if (isInitialCall) {
729 hitDepth = 32767.0f;
730 posX = playerStatus->pos.x;
731 posY = playerStatus->pos.y;
732 posZ = playerStatus->pos.z;
733 zoneID = test_ray_zones(posX, posY + 10.0f, posZ, 0.0f, -1.0f, 0.0f, &hitX, &hitY, &hitZ, &hitDepth, &nX, &nY, &nZ);
734 if (zoneID >= 0) {
735 camera->overrideSettings = *gZoneCollisionData.colliderList[zoneID].camSettings;
736 }
737
738 camera->movePos.x = posX + deltaPosX;
739 camera->movePos.y = posY;
740 camera->movePos.z = posZ;
741 camera->overrideSettings.boomLength = boomLength;
742 camera->overrideSettings.boomPitch = boomPitch;
743 camera->overrideSettings.viewPitch = viewPitch;
744 camera->moveSpeed = moveSpeed;
745 camera->panActive = TRUE;
746 camera->useOverrideSettings = TRUE;
747 camera->interpEasingParameter = 0.0f;
748 return ApiStatus_BLOCK;
749 }
750
751 if (camera->interpAlpha < 1.0f) {
752 return ApiStatus_BLOCK;
753 }
754
755 return ApiStatus_DONE2;
756}
757
758API_CALLABLE(ResetCam) {
759 Bytecode* args = script->ptrReadPos;
760 s32 id = evt_get_variable(script, *args++);
761 Camera* camera = &gCameras[id];
762 f32 moveSpeed = evt_get_float_variable(script, *args++);
763 PlayerStatus* playerStatus = &gPlayerStatus;
764
765 if (isInitialCall) {
766 f32 x = playerStatus->pos.x;
767 f32 y = playerStatus->pos.y;
768 f32 z = playerStatus->pos.z;
769 f32 hitX, hitY, hitZ;
770 f32 hitDepth = 32767.0f;
771 f32 nx, ny, nz;
772 s32 hitID;
773
774 hitID = test_ray_zones(x, y + 10.0f, z, 0.0f, -1.0f, 0.0f, &hitX, &hitY, &hitZ, &hitDepth,
775 &nx, &ny, &nz);
776
777 if (hitID > NO_COLLIDER) {
778 camera->overrideSettings = *gZoneCollisionData.colliderList[hitID].camSettings;
779 }
780
781 camera->movePos.x = x;
782 camera->movePos.y = y;
783 camera->movePos.z = z;
784 camera->moveSpeed = moveSpeed;
785 camera->panActive = TRUE;
786 camera->useOverrideSettings = TRUE;
787 camera->interpEasingParameter = 0.0f;
788 return ApiStatus_BLOCK;
789 }
790
791 if (camera->interpAlpha < 1.0f) {
792 return ApiStatus_BLOCK;
793 }
794
795 camera->panActive = TRUE;
796 camera->useOverrideSettings = FALSE;
797 camera->moveSpeed = 1.0f;
798 camera->interpEasingParameter = 0.0f;
799 return ApiStatus_DONE2;
800}
EvtScript ShakeCamX
Definition cam_api.c:10
void exec_ShakeCam1(s32 camID, s32 mode, s32 duration)
Definition cam_api.c:365
void exec_ShakeCamX(s32 camID, s32 mode, s32 duration, f32 magnitude)
Definition cam_api.c:374
EvtScript ShakeCam1
Definition cam_api.c:3
Collider * colliderList
s32 b32
Bytecode EvtScript[]
union CameraControlSettings::@14 points
#define guRotateF
#define sqrtf
#define guTranslateF
@ CAM_SHAKE_DECAYING_VERTICAL
Definition enums.h:1809
@ CAM_SHAKE_CONSTANT_VERTICAL
Definition enums.h:1807
@ CAM_SHAKE_ANGULAR_HORIZONTAL
Definition enums.h:1808
@ CAMERA_FLAG_DISABLED
Definition enums.h:4721
@ CAMERA_FLAG_NO_DRAW
Definition enums.h:4725
@ CAMERA_FLAG_LEAD_PLAYER
Definition enums.h:4722
@ CAMERA_FLAG_SUPRESS_LEADING
Definition enums.h:4728
@ CAMERA_FLAG_SHAKING
Definition enums.h:4723
@ CAM_UPDATE_INTERP_POS
Definition enums.h:4747
@ CONTEXT_WORLD
Definition enums.h:3529
@ CAMERA_MOVE_IGNORE_PLAYER_Y
Definition enums.h:4732
@ CAM_DEFAULT
Definition enums.h:1800
@ EVT_PRIORITY_1
Definition evt.h:152
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
@ EVT_GROUP_NEVER_PAUSE
Definition evt.h:142
@ EVT_GROUP_SHAKE_CAM
Definition evt.h:146
#define ApiStatus_BLOCK
Definition evt.h:116
void start_rumble(s32, s32)
Definition rumble.c:15
s32 test_ray_zones(f32 startX, f32 startY, f32 startZ, f32 dirX, f32 dirY, f32 dirZ, f32 *hitX, f32 *hitY, f32 *hitZ, f32 *hitDepth, f32 *nx, f32 *ny, f32 *nz)
Definition collision.c:866
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
f32 evt_set_float_variable(Evt *script, Bytecode var, f32 value)
Definition evt.c:1977
s32 round(f32)
Definition 43F0.c:572
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1847
s32 heap_free(void *ptr)
Definition heap.c:42
f32 evt_get_float_variable(Evt *script, Bytecode var)
Definition evt.c:1930
Evt * start_script_in_group(EvtScript *source, u8 priority, u8 initialState, u8 groupFlags)
void * heap_malloc(s32 size)
Definition heap.c:34
void set_cam_viewport(s16 id, s16 x, s16 y, s16 width, s16 height)
Definition cam_main.c:373
ApiStatus GetCamPosB(Evt *script, b32 isInitialCall)
ApiStatus SetCamPosA(Evt *script, b32 isInitialCall)
ApiStatus SetCamEnabled(Evt *script, b32 isInitialCall)
ApiStatus SetCamViewport(Evt *script, b32 isInitialCall)
ApiStatus ResetCam(Evt *script, b32 isInitialCall)
ApiStatus SetCamPitch(Evt *script, b32 isInitialCall)
ApiStatus GetCamPosA(Evt *script, b32 isInitialCall)
ApiStatus SetInterpCamOffsetY(Evt *script, b32 isInitialCall)
ApiStatus SetCamPosB(Evt *script, b32 isInitialCall)
ApiStatus GetCamPitch(Evt *script, b32 isInitialCall)
ApiStatus LoadSettings(Evt *script, b32 isInitialCall)
ApiStatus SetCamUpdateMode(Evt *script, b32 isInitialCall)
ApiStatus DisableCameraFollowPlayerY(Evt *script, b32 isInitialCall)
ApiStatus PanToTarget(Evt *script, b32 isInitialCall)
ApiStatus SetCamType(Evt *script, b32 isInitialCall)
ApiStatus GetInterpCamDist(Evt *script, b32 isInitialCall)
ApiStatus GrabCamera(Evt *script, b32 isInitialCall)
ApiStatus SetCamProperties(Evt *script, b32 isInitialCall)
ApiStatus GetCamType(Evt *script, b32 isInitialCall)
ApiStatus SetCamLeadScale(Evt *script, b32 isInitialCall)
ApiStatus InterpCamTargetPos(Evt *script, b32 isInitialCall)
ApiStatus SetCamLookTarget(Evt *script, b32 isInitialCall)
ApiStatus SetCamBGColor(Evt *script, b32 isInitialCall)
ApiStatus SetCamDistance(Evt *script, b32 isInitialCall)
ApiStatus AdjustCam(Evt *script, b32 isInitialCall)
ApiStatus SetInterpCamParams(Evt *script, b32 isInitialCall)
ApiStatus WaitForCam(Evt *script, b32 isInitialCall)
ApiStatus GetCamPosition(Evt *script, b32 isInitialCall)
ApiStatus EnableCameraFollowPlayerY(Evt *script, b32 isInitialCall)
ApiStatus GetCamDistance(Evt *script, b32 isInitialCall)
ApiStatus SetCamLeadPlayer(Evt *script, b32 isInitialCall)
ApiStatus ShakeCam(Evt *script, b32 isInitialCall)
ApiStatus SetNoInterpCamParams(Evt *script, b32 isInitialCall)
ApiStatus GetInterpCamOffsetY(Evt *script, b32 isInitialCall)
ApiStatus EnableCameraLeadingPlayer(Evt *script, b32 isInitialCall)
ApiStatus SetCamPosC(Evt *script, b32 isInitialCall)
ApiStatus SetCamTarget(Evt *script, b32 isInitialCall)
ApiStatus SetInterpCamDist(Evt *script, b32 isInitialCall)
ApiStatus UseSettingsFrom(Evt *script, b32 isInitialCall)
ApiStatus SetPanTarget(Evt *script, b32 isInitialCall)
ApiStatus SetCamSpeed(Evt *script, b32 isInitialCall)
ApiStatus SetCamNoDraw(Evt *script, b32 isInitialCall)
ApiStatus SetCamPerspective(Evt *script, b32 isInitialCall)
ApiStatus GetCamPosC(Evt *script, b32 isInitialCall)
ApiStatus DisableCameraLeadingPlayer(Evt *script, b32 isInitialCall)
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:213
#define Float(DOUBLE)
Definition macros.h:51
#define LVar2
Definition macros.h:150
#define LVar1
Definition macros.h:149
#define SetGroup(GROUP)
Sets the current thread's group. Group value meanings are currently not known.
Definition macros.h:519
#define SQ(x)
Definition macros.h:166
#define NO_COLLIDER
Definition macros.h:156
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:576
#define LVar3
Definition macros.h:151
#define LVar0
Definition macros.h:148
#define Return
Kills the current EVT thread.
Definition macros.h:217
Vec3f lookAt_obj
s16 bgColor[3]
Vec3f movePos
b16 needsReinit
Vec3f lookAt_obj_target
f32 interpEasingParameter
b16 useOverrideSettings
union Camera::@17 params
CameraControlSettings overrideSettings
Vec3f targetPos
Matrix4f mtxViewShaking
Vec3f lookAt_eye
f32 interpAlpha
f32 leadAmtScale
CollisionData gZoneCollisionData
Definition collision.c:36
GameStatus * gGameStatusPtr
Definition main_loop.c:32
Camera gCameras[4]
Definition cam_main.c:17
PlayerStatus gPlayerStatus
Definition 77480.c:39