papermario/src/code_ef070_len_3400.c

342 lines
11 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) {
(&gCameras[id])->flags |= 0x2;
} else {
(&gCameras[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) {
(&gCameras[id])->flags |= 0x80;
} else {
(&gCameras[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++);
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++);
Camera* cameras = &gCameras;
Camera* camera = &cameras[id];
camera->mode = mode;
camera->unk_06 = 0;
return ApiStatus_DONE2;
}
INCLUDE_API_ASM("code_ef070_len_3400", func_802CA988);
/*
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;
f32 tempSqrt;
2020-08-20 19:11:36 +02:00
(&gCameras[id])->mode = 2;
(&gCameras[id])->unk_1C = -1 * round((&gCameras[id])->currentPitch);
(&gCameras[id])->unk_1E = -1 * (&gCameras[id])->currentBlendedYawNegated;
2020-08-20 19:11:36 +02:00
(&gCameras[id])->unk_06 = 0;
temp1 = (&gCameras[id])->lookAt_obj[0] - (&gCameras[id])->lookAt_eye[0];
temp2 = (&gCameras[id])->lookAt_obj[1] - (&gCameras[id])->lookAt_eye[1];
temp3 = (&gCameras[id])->lookAt_obj[2] - (&gCameras[id])->lookAt_eye[2];
tempSqrt = sqrtf((temp1 * temp1) + (temp2 * temp2) + (temp3 * temp3));
if (tempSqrt != tempSqrt) {
(&gCameras[id])->unk_20 = round(tempSqrt);
}
(&gCameras[id])->unk_22 = 0;
(&gCameras[id])->unk_54 = (&gCameras[id])->lookAt_obj[0];
(&gCameras[id])->unk_58 = (&gCameras[id])->lookAt_obj[1];
(&gCameras[id])->unk_5C = (&gCameras[id])->lookAt_obj[2];
set_variable(script, outVar1, (&gCameras[id])->unk_1C);
set_variable(script, outVar2, (&gCameras[id])->unk_1E);
set_variable(script, outVar3, (&gCameras[id])->unk_20);
set_variable(script, outVar4, (&gCameras[id])->unk_22);
return ApiStatus_DONE2;
}
*/
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", SetCamViewport);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", SetCamBGColor);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", SetCamTarget);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", ShakeCam);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_ef070_len_3400", exec_ShakeCam1);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_ef070_len_3400", exec_ShakeCamX);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", SetCamLeadPlayer);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", PanToTarget);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", UseSettingsFrom);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", LoadSettings);
2020-08-04 08:49:11 +02:00
ApiStatus SetCamType(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 id = get_variable(script, *args++);
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++);
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++);
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++);
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++);
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++);
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++);
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++);
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++;
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++;
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++;
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++;
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++;
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++;
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++;
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
INCLUDE_API_ASM("code_ef070_len_3400", WaitForCam);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", SetCamProperties);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", AdjustCam);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", ResetCam);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_ef070_len_3400", draw_anim_models);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", LoadModelAnimation);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", PlayModelAnimation);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", ChangeModelAnimation);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", SetAnimModelPosition);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", GetAnimModelPosition);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", AddAnimModelPosition);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", SetAnimModelRotation);
2020-08-04 08:49:11 +02:00
INCLUDE_API_ASM("code_ef070_len_3400", SetAnimModelScale);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_ef070_len_3400", func_802CD4B4);
2020-08-04 08:49:11 +02:00
INCLUDE_ASM("code_ef070_len_3400", func_802CD57C);