papermario/src/code_ef070_len_3400.c

516 lines
16 KiB
C
Raw Normal View History

2020-08-04 08:49:11 +02:00
#include "common.h"
ApiStatus SetCamEnabled(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
s32 enabled = get_variable(script, *args++);
2020-08-20 19:11:36 +02:00
if (!enabled) {
2020-11-06 01:30:17 +01:00
CAM(id)->flags |= 0x2;
} else {
2020-11-06 01:30:17 +01:00
CAM(id)->flags &= ~0x2;
}
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
ApiStatus SetCamFlag80(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
s32 enabled = get_variable(script, *args++);
2020-08-04 08:49:11 +02:00
if (!enabled) {
2020-11-06 01:30:17 +01:00
CAM(id)->flags |= 0x80;
} else {
2020-11-06 01:30:17 +01:00
CAM(id)->flags &= ~0x80;
}
return ApiStatus_DONE2;
}
ApiStatus SetCamPerspective(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
s16 mode = get_variable(script, *args++);
f32 vfov = get_float_variable(script, *args++);
s16 nearClip = get_variable(script, *args++);
s16 farClip = get_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
camera->farClip = farClip;
camera->mode = mode;
camera->unk_06 = 1;
camera->unk_08 = 1;
camera->vfov = vfov;
camera->nearClip = nearClip;
return ApiStatus_DONE2;
}
ApiStatus func_802CA90C(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
s16 mode = get_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
camera->mode = mode;
camera->unk_06 = 0;
return ApiStatus_DONE2;
}
2020-09-26 03:51:54 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", func_802CA988, ScriptInstance* script, s32 isInitialCall);
/*
ApiStatus func_802CA988(ScriptInstance* script, s32 isInitialCall) {
Bytecode* ptrReadPos = script->ptrReadPos;
Bytecode id = get_variable(script, *ptrReadPos++);
Bytecode outVar1 = *ptrReadPos++;
Bytecode outVar2 = *ptrReadPos++;
Bytecode outVar3 = *ptrReadPos++;
Bytecode outVar4 = *ptrReadPos++;
f32 temp1, temp2, temp3;
2020-08-20 19:11:36 +02:00
2020-11-06 01:30:17 +01:00
CAM(id)->mode = 2;
CAM(id)->unk_06 = 0;
CAM(id)->unk_1C = -round(CAM(id)->currentPitch);
CAM(id)->unk_1E = -CAM(id)->currentBlendedYawNegated;
2020-11-06 01:30:17 +01:00
temp1 = CAM(id)->lookAt_obj[0] - CAM(id)->lookAt_eye[0];
temp2 = CAM(id)->lookAt_obj[1] - CAM(id)->lookAt_eye[1];
temp3 = CAM(id)->lookAt_obj[2] - CAM(id)->lookAt_eye[2];
2020-11-06 01:30:17 +01:00
CAM(id)->unk_20 = round(sqrtf((temp1 * temp1) + (temp2 * temp2) + (temp3 * temp3)));
CAM(id)->unk_22 = 0;
CAM(id)->unk_54 = CAM(id)->lookAt_obj[0];
CAM(id)->unk_58 = CAM(id)->lookAt_obj[1];
CAM(id)->unk_5C = CAM(id)->lookAt_obj[2];
2020-11-06 01:30:17 +01:00
set_variable(script, outVar1, CAM(id)->unk_1C);
set_variable(script, outVar2, CAM(id)->unk_1E);
set_variable(script, outVar3, CAM(id)->unk_20);
set_variable(script, outVar4, CAM(id)->unk_22);
return ApiStatus_DONE2;
}
*/
2020-08-04 08:49:11 +02:00
ApiStatus SetCamViewport(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
s32 x = get_variable(script, *args++);
s32 y = get_variable(script, *args++);
s16 width = get_variable(script, *args++);
s16 height = get_variable(script, *args++);
set_cam_viewport(id, x, y, width, height);
return ApiStatus_DONE2;
}
ApiStatus func_802CABE8(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
s16 value1 = get_variable(script, *args++);
s32 value2 = get_variable(script, *args++);
s32 value3 = get_variable(script, *args++);
s16 value4 = get_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
camera->unk_22 = value4;
camera->unk_1C = value1;
camera->unk_1E = value2;
camera->unk_20 = value3;
return ApiStatus_DONE2;
}
ApiStatus func_802CACC0(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
s16 value1 = get_variable(script, *args++);
s32 value2 = get_variable(script, *args++);
s32 value3 = get_variable(script, *args++);
s16 zoomPercent = get_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
2020-08-04 08:49:11 +02:00
camera->zoomPercent = zoomPercent;
camera->unk_24 = value1;
camera->unk_26 = value2;
camera->unk_28 = value3;
return ApiStatus_DONE2;
}
ApiStatus SetCamBGColor(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
s16 r = get_variable(script, *args++);
s16 g = get_variable(script, *args++);
s16 b = get_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
camera->backgroundColor[0] = r;
camera->backgroundColor[1] = g;
camera->backgroundColor[2] = b;
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
ApiStatus func_802CAE50(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
s32 value1 = get_variable(script, *args++);
s32 value2 = get_variable(script, *args++);
s32 value3 = get_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
camera->unk_54 = value1;
camera->unk_58 = value2;
camera->unk_5C = value3;
return ApiStatus_DONE2;
}
ApiStatus SetCamTarget(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
s32 x = get_variable(script, *args++);
s32 y = get_variable(script, *args++);
s32 z = get_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
camera->targetPos.x = x;
camera->targetPos.y = y;
camera->targetPos.z = z;
return ApiStatus_DONE2;
}
2020-09-26 03:51:54 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", func_802CB008, ScriptInstance* script, s32 isInitialCall);
2020-08-04 08:49:11 +02:00
2020-09-26 03:51:54 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", ShakeCam, ScriptInstance* script, s32 isInitialCall);
2020-08-04 08:49:11 +02:00
2020-10-24 23:51:27 +02:00
void exec_ShakeCam1(s32 arg0, s32 arg1, s32 arg2) {
ScriptInstance* script;
2020-08-04 08:49:11 +02:00
2020-10-24 23:51:27 +02:00
script = start_script_in_group(&ShakeCam1, 1, 0, 4);
script->varTable[0] = arg0;
script->varTable[1] = arg1;
script->varTable[2] = arg2;
}
void exec_ShakeCamX(s32 arg0, s32 arg1, s32 arg2, f32 arg3) {
ScriptInstance* script;
script = start_script_in_group(&ShakeCamX, 1, 0, 4);
set_variable(script, SI_VAR(0), arg0);
set_variable(script, SI_VAR(1), arg1);
set_variable(script, SI_VAR(2), arg2);
set_float_variable(script, SI_VAR(3), arg3);
}
2020-08-04 08:49:11 +02:00
ApiStatus SetCamLeadPlayer(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
s32 enabled = get_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
if (enabled) {
camera->flags |= 0x4;
} else {
camera->flags &= ~0x4;
}
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
ApiStatus func_802CB710(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
f32 value = get_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
camera->unk_520 = (value / 100.0f);
return ApiStatus_DONE2;
}
ApiStatus PanToTarget(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
f32 panPhase = get_float_variable(script, *args++);
s32 targetType = get_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
camera->unk_506 = 1;
if (targetType != 0) {
camera->boolTargetPlayer = 1;
camera->panPhase = panPhase;
} else {
camera->boolTargetPlayer = 0;
camera->panPhase = 0.0f;
camera->moveSpeed = 1.0f;
}
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
2020-09-26 03:51:54 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", UseSettingsFrom, ScriptInstance* script, s32 isInitialCall);
2020-08-04 08:49:11 +02:00
2020-09-26 03:51:54 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", LoadSettings, ScriptInstance* script, s32 isInitialCall);
2020-08-04 08:49:11 +02:00
ApiStatus SetCamType(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
s32 controllerType = get_variable(script, *args++);
s32 enabled = get_variable(script, *args++);
camera->unk_500 = enabled;
camera->controllerType = controllerType;
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
ApiStatus SetCamPitch(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
f32 boomPitch = get_float_variable(script, *args++);
f32 viewPitch = get_float_variable(script, *args++);
camera->controllerBoomPitch = boomPitch;
camera->controllerViewPitch = viewPitch;
return ApiStatus_DONE2;
}
ApiStatus SetCamDistance(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
f32 boomLength = get_float_variable(script, *args++);
camera->controllerBoomLen = boomLength;
return ApiStatus_DONE2;
}
ApiStatus SetCamPosA(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
f32 x = get_float_variable(script, *args++);
f32 z = get_float_variable(script, *args++);
camera->posA.x = x;
camera->posA.z = z;
return ApiStatus_DONE2;
}
ApiStatus SetCamPosB(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
f32 x = get_float_variable(script, *args++);
f32 z = get_float_variable(script, *args++);
camera->posB.x = x;
camera->posB.z = z;
return ApiStatus_DONE2;
}
ApiStatus SetCamPosC(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
f32 y1 = get_float_variable(script, *args++);
f32 y2 = get_float_variable(script, *args++);
camera->posA.y = y1;
camera->posB.y = y2;
return ApiStatus_DONE2;
}
ApiStatus SetPanTarget(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
f32 x = get_float_variable(script, *args++);
f32 y = get_float_variable(script, *args++);
f32 z = get_float_variable(script, *args++);
camera->movePos.x = x;
camera->movePos.y = y;
camera->movePos.z = z;
camera->unk_506 = 1;
return ApiStatus_DONE2;
}
ApiStatus SetCamSpeed(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
f32 speed = get_float_variable(script, *args++);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
camera->moveSpeed = speed;
return ApiStatus_DONE2;
}
ApiStatus GetCamType(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
Bytecode outVar1 = *args++;
Bytecode outVar2 = *args++;
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
2020-08-04 08:49:11 +02:00
set_variable(script, outVar1, camera->controllerType);
set_variable(script, outVar2, camera->unk_500);
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
ApiStatus GetCamPitch(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
Bytecode outVar1 = *args++;
Bytecode outVar2 = *args++;
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
2020-08-04 08:49:11 +02:00
set_float_variable(script, outVar1, camera->controllerBoomPitch);
set_float_variable(script, outVar2, camera->controllerViewPitch);
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
ApiStatus GetCamDistance(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
Bytecode outVar1 = *args++;
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
2020-08-04 08:49:11 +02:00
set_float_variable(script, outVar1, camera->controllerBoomLen);
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
ApiStatus GetCamPosA(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
Bytecode outVar1 = *args++;
Bytecode outVar2 = *args++;
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
2020-08-04 08:49:11 +02:00
set_float_variable(script, outVar1, camera->posA.x);
set_float_variable(script, outVar2, camera->posA.z);
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
ApiStatus GetCamPosB(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
Bytecode outVar1 = *args++;
Bytecode outVar2 = *args++;
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
2020-08-04 08:49:11 +02:00
set_float_variable(script, outVar1, camera->posB.x);
set_float_variable(script, outVar2, camera->posB.z);
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
ApiStatus GetCamPosC(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
Bytecode outVar1 = *args++;
Bytecode outVar2 = *args++;
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
2020-08-04 08:49:11 +02:00
set_float_variable(script, outVar1, camera->posA.y);
set_float_variable(script, outVar2, camera->posB.y);
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
ApiStatus GetCamPosition(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
Bytecode outVar1 = *args++;
Bytecode outVar2 = *args++;
Bytecode outVar3 = *args++;
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
2020-08-04 08:49:11 +02:00
set_float_variable(script, outVar1, camera->movePos.x);
set_float_variable(script, outVar2, camera->movePos.y);
set_float_variable(script, outVar3, camera->movePos.z);
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
ApiStatus WaitForCam(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, args[0]);
f32 endInterpValue = get_float_variable(script, args[1]);
2020-09-25 23:18:09 +02:00
Camera* cameras = gCameras;
Camera* camera = &cameras[id];
if (isInitialCall || !(endInterpValue <= camera->sinInterpAlpha)) {
return ApiStatus_BLOCK;
}
return ApiStatus_DONE2;
}
2020-08-04 08:49:11 +02:00
2020-09-26 03:51:54 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", SetCamProperties, ScriptInstance* script, s32 isInitialCall);
2020-08-04 08:49:11 +02:00
2020-09-26 03:51:54 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", AdjustCam, ScriptInstance* script, s32 isInitialCall);
2020-08-04 08:49:11 +02:00
2020-09-26 03:51:54 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", ResetCam, ScriptInstance* script, s32 isInitialCall);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", func_802CCAC0);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", draw_anim_models);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", func_802CCCB0);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", LoadModelAnimation);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", func_802CCDAC);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", PlayModelAnimation);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", func_802CCEDC);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", ChangeModelAnimation);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", SetAnimModelPosition);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", GetAnimModelPosition);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", AddAnimModelPosition);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", SetAnimModelRotation);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", SetAnimModelScale);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", func_802CD348);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", func_802CD3C0);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", func_802CD418);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", func_802CD4B4);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", func_802CD57C);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", func_802CD5C0);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", func_802CD6E0);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", func_802CD7D8);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", func_802CD8F8);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_ef070_len_3400", func_802CD9F0);