summaryrefslogtreecommitdiff
path: root/src/code/db_camera.c
diff options
context:
space:
mode:
authorkrimtonz <33664508+krimtonz@users.noreply.github.com>2020-12-06 16:39:47 -0600
committerGitHub <noreply@github.com>2020-12-06 17:39:47 -0500
commit321388673b4a3e763d23dec16e08e9c513869de4 (patch)
treee43235b424e19e6f3563e73d484a7afe41365aa4 /src/code/db_camera.c
parentdadee87f9423fd7b06ec088bf4bde5f768598d3c (diff)
decompile z_camera (#398)
* cleanup * name camera action functions * decompile a few small functions, name a few Camera struct members * decompile camera data, decompile a few camera functions * Split ASM for code_800BB0A0 * removing code_800BB0A0.s * PR Requests, Camera WIP * remove #define NON_MATCHING from db_camera * rename code_8007BF90.c to z_olib.c, rename functions in z_olib.c * camera wip * rename some struct memebers, some decomp wip * pr updates * camera wip * name some fields in Camera Struct, being making sense of Camera_Update * Camera WIP * wip * wip * add z64camera.h header, begin creating CameraSetting macros * wip * wip * wip * wip * migrate camera bss to c * match a couple functions in db_camera * match some small db_camera functions * wip * migrate db_camera rodata, match a few functions * remote db_camera.rodata.s * match some of db_camera * identify types of some unknown data pieces * some small wip * Match Camera_Init, some function changes, some struct name changes. Change unk_C0 and unk_CC to floats from Vec3fs * add naming for a few more Camera struct members * wip * match func_80043F94 * Match Camera_Jump1 * document some of Camera_Jump1 * wip * match Camera_Jump3 * Match Camera_Update, FeelsAmazing * wip * wip * match Camera_SetParam * minor cleanup * wip * wip * match Camera_KeepOn0 * some documentation, modify some matching functions to match style of others. * match Camera_Demo1 * match camera_demo9 * document Camera_Demo1 and Camera_Demo9 * wip * Match camera_battle4 * match camera_unique2 * Match Camera_Unique3 * match camera_special6 * match Camera_Special5 * wip * document camera_special6 * naming updates * match camera_Unique1 * match Camera_Unique0 * wip * Match Camera_CalcUpFromPitchYawRoll * match func_80045508 * document Camera_Battle4 * document several camera functions, move camera data to separate file * rename phi/theta to pitch/yaw * wip * uniq9 wip * Camera_Unqiue9 OK * document Camera_Unique9 * name unk_160 in camera struct * wip * wip * minor updates * fix conflicts * wip * wip * Olib updates * wip * wip * rename most Math3D functions, few matches, documentation * wip * document most of math3d * wip * wip * wip * pr updates * Match Camera_Fixed4 * match func_80058E8C * pr updates * add missing comment block finalizer * Merge math3dupdates * match Camera_ChangeSetting * Match Camera_ChangeMode * match func_80058148 * Match Camera_Special9 * decompile the rest of camera data * match Camera_Demo5 * name a few camera functions in z_play * match func_80046CB4, some work on other fucntions * wip * impove some non matchings * fix function rename * match func_800588B4 * match Camera_Subj4 * wip * Camera_Demo3 matching, Camera_Battle1 big progress * Camera_Normal2 OK * wip * match Camera_Parallel1 * normalize some things across functions * match Camera_Normal1 * Match Camera_Normal3 * some cleanup * more cleanup * more cleanup , match Camera_CalcDefaultPitch * data formatting * Match Camera_Jump2 * document Camera_Jump2 * Match Camera_KeepOn3 * document some of Camera_KeepOn3 * improve some non_matchings * match func_80045C74 and func_800460A8 * code cleanup, documentation * match Camera_KeepOn1 * Match Camera_Subj3 * Match Camera_Battle1 * remove non_matching from func_80044adc and func_80046e20 * name several members of Battle1 * more documentation on Battle1 * cleanup * renaming Camera_Vec3fScaleXYZFactor to Camera_Vec3fTranslateByUnitVector * reorganize update structs, remove final references to params, remove CameraParams union * implement camera enums into player * Renaming Camera_GetDir to Camera_GetInputDir, Camera_GetRealDir to Camera_GetCamDir, etc, implement camera enum's into player * remove non-global camera variables from variables.h * clean up some variable declarations * finish pr comment updates * fix some warnings * data formatting * finish commenting on data * delete unused asm * remove asm Co-authored-by: fig <fig02srl@gmail.com>
Diffstat (limited to 'src/code/db_camera.c')
-rw-r--r--src/code/db_camera.c266
1 files changed, 241 insertions, 25 deletions
diff --git a/src/code/db_camera.c b/src/code/db_camera.c
index fc97d1ebd..d29093583 100644
--- a/src/code/db_camera.c
+++ b/src/code/db_camera.c
@@ -1,24 +1,96 @@
#include "global.h"
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B3B50.s")
+extern GlobalContext* D_80161100;
+extern s32 D_8012CED8;
+extern s32 D_8012CED4;
+extern s32 D_8012CED0;
+extern char D_801612D0[0x1A];
+extern char D_801612EA;
+extern DBCamera* D_80161108;
+extern s16 D_80161148;
+extern s16 D_8016114A;
+extern s16 D_8016111A;
+extern s16 D_8016110C;
+
+typedef struct {
+ char state;
+ s16 mode;
+ CutsceneCameraPoint* eyePoints;
+ CutsceneCameraPoint* atPoints;
+ s16 frameCnt;
+ s16 csPointsCnt;
+} DBCSEditorSlot;
+
+extern DBCSEditorSlot sDbgEditorSlots[];
+extern char sDbgEditorStates[];
+
+// DbgCamera_Vec3fVecSphGeoAdd
+Vec3f* func_800B3B50(Vec3f* dest, Vec3f* a, VecSph* b) {
+ Vec3f copy, vecB;
+ OLib_VecSphGeoToVec3f(&vecB, b);
+
+ copy.x = a->x + vecB.x;
+ copy.y = a->y + vecB.y;
+ copy.z = a->z + vecB.z;
+
+ *dest = copy;
+ return dest;
+}
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B3BD4.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B3DF8.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B3EBC.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B3EFC.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B3F38.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B3F54.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B3F94.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B3FF4.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B404C.s")
+void func_800B3EBC(Vec3s* src, Vec3f* dest) {
+ dest->x = src->x;
+ dest->y = src->y;
+ dest->z = src->z;
+}
+
+void func_800B3EFC(Vec3f* src, Vec3s* dest) {
+ dest->x = src->x;
+ dest->y = src->y;
+ dest->z = src->z;
+}
+
+void func_800B3F38(Vec3f* src, Vec3f* dest) {
+ dest->x = src->x;
+ dest->y = src->y;
+ dest->z = src->z;
+}
+
+void func_800B3F54(Vec3s* src, Vec3f* dest) {
+ dest->x = src->x;
+ dest->y = src->y;
+ dest->z = src->z;
+}
+
+void func_800B3F94(PosRot* arg0, Vec3f* arg1, Vec3s* arg2) {
+ VecSph sp28;
+ Vec3f sp1C;
+
+ OLib_Vec3fDiffToVecSphGeo(&sp28, &arg0->pos, arg1);
+ sp28.yaw -= arg0->rot.y;
+ OLib_VecSphGeoToVec3f((Vec3f*)&sp1C, &sp28);
+ func_800B3EFC(&sp1C, arg2);
+}
+
+void func_800B3FF4(PosRot* arg0, Vec3f* arg1, Vec3f* arg2) {
+ VecSph sp28;
+ Vec3f sp1C;
+
+ func_800B3F38(arg1, &sp1C);
+ OLib_Vec3fToVecSphGeo(&sp28, &sp1C);
+ sp28.yaw += arg0->rot.y;
+ func_800B3B50(arg2, arg0, &sp28);
+}
+
+void func_800B404C(s32 arg0, Vec3s* arg1, Vec3f* arg2) {
+ Vec3f sp1C;
+
+ func_800B3EBC(arg1, &sp1C);
+ func_800B3FF4(arg0, &sp1C, arg2);
+}
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B4088.s")
@@ -30,7 +102,25 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B44E0.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B4920.s")
+/**
+ * Prints individual csSlot point information
+ */
+void func_800B4920(char* varName, s16 pointCnt, CutsceneCameraPoint* csPoints) {
+ s32 i;
+ CutsceneCameraPoint* csPoint;
+
+ osSyncPrintf("@@@static SplinedatZ %s[] = {\n", varName);
+ for (i = 0, csPoint = csPoints; i < pointCnt; i++, csPoint++) {
+ osSyncPrintf("@@@ /* key frame %2d */ {\n", i);
+ osSyncPrintf("@@@ /* code */ %d,\n", csPoint->continueFlag);
+ osSyncPrintf("@@@ /* z */ %d,\n", csPoint->cameraRoll);
+ osSyncPrintf("@@@ /* T */ %d,\n", csPoint->nextPointFrame);
+ osSyncPrintf("@@@ /* zoom */ %f,\n", csPoint->viewAngle);
+ osSyncPrintf("@@@ /* pos */ { %d, %d, %d }\n", csPoint->pos.x, csPoint->pos.y, csPoint->pos.z);
+ osSyncPrintf("@@@ },\n");
+ }
+ osSyncPrintf("@@@};\n@@@\n");
+}
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B4A68.s")
@@ -40,28 +130,154 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B4B20.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B4D58.s")
+void DbgCamera_Init(DBCamera* dbCamera, Camera* camera) {
+ dbCamera->unk_10C6.x = dbCamera->unk_10C6.y = dbCamera->unk_10C6.z = 0;
+ dbCamera->unk_44 = 0;
+ dbCamera->unk_00 = 0;
+ dbCamera->unk_34 = 0;
+ dbCamera->unk_3C = 0;
+ dbCamera->unk_38 = -1;
+ dbCamera->unk_40 = -1;
+ dbCamera->unk_4C = 0;
+ dbCamera->fov = 0.0f;
+ dbCamera->unk_50 = 0.0f;
+ D_80161100 = camera->globalCtx;
+ dbCamera->unk_7C = 0;
+ dbCamera->unk_7E = -1;
+ dbCamera->unk_80 = 1;
+ dbCamera->unk_82 = 0;
+ dbCamera->unk_84 = 0;
+ dbCamera->unk_86 = 0;
+ dbCamera->unk_78 = 0;
+ dbCamera->unk_7A = 0;
+ dbCamera->unk_10C0.x = 0;
+ dbCamera->unk_10C0.y = 0;
+ dbCamera->unk_10C0.z = 0;
+ dbCamera->unk_6C = dbCamera->unk_70 = dbCamera->unk_74 = 0;
+}
+
+void DbgCamera_Enable(DBCamera* dbCamera, Camera* camera) {
+ dbCamera->at = camera->at;
+ dbCamera->eye = camera->eye;
+ dbCamera->up = camera->up;
+ dbCamera->fov = camera->fov;
+ dbCamera->unk_4C = 0;
+ dbCamera->unk_80 = 1;
+ dbCamera->unk_82 = 0;
+ dbCamera->unk_84 = 0;
+ dbCamera->unk_86 = 1;
+ dbCamera->unk_88 = 1;
+ dbCamera->unk_78 = 0;
+ dbCamera->unk_7A = 0;
+ dbCamera->unk_50 = 0.0f;
+ func_800B4088(dbCamera, camera);
+}
+
+#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/DbgCamera_Update.s")
+
+s32 func_800B8730(void) {
+ s32 temp_v1;
+ void* phi_v0;
+ s32 phi_v1;
+
+ for (phi_v1 = 0; phi_v1 < 0x1A; phi_v1++) {
+ if (D_801612D0[phi_v1] != 'O') {
+ return phi_v1 + 'A';
+ }
+ }
+ return '?';
+}
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B4DE4.s")
+#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B87D8.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B4E7C.s")
+/**
+ * Clears a DBCSEditorSlot
+ */
+void func_800B8978(s32 editorSlot, s32 free) {
+
+ if (sDbgEditorSlots[editorSlot].state != '?') {
+ sDbgEditorStates[sDbgEditorSlots[editorSlot].state] = 'X';
+ }
+ if (free) {
+ DebugArena_FreeDebug(sDbgEditorSlots[editorSlot].atPoints, "../db_camera.c", 2784);
+ DebugArena_FreeDebug(sDbgEditorSlots[editorSlot].eyePoints, "../db_camera.c", 2785);
+ }
+ sDbgEditorSlots[editorSlot].state = '?';
+ sDbgEditorSlots[editorSlot].atPoints = NULL;
+ sDbgEditorSlots[editorSlot].eyePoints = NULL;
+ sDbgEditorSlots[editorSlot].mode = 0;
+ sDbgEditorSlots[editorSlot].frameCnt = 0;
+ sDbgEditorSlots[editorSlot].csPointsCnt = 0;
+}
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B8730.s")
+#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B8A0C.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B87D8.s")
+extern s32 D_801612EC;
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B8978.s")
+s32 func_800B8BA4(void) {
+ return D_801612EC;
+}
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B8A0C.s")
+#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B8BB0.s")
+
+#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B8DB0.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B8BA4.s")
+void func_800B8F30(char* arg0) {
+ Mempak_DeleteFile(2, *arg0);
+}
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B8F58.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B9060.s")
+/**
+ * Prints cs editor slot inforation
+ */
+void func_800B9060(s32 arg0) {
+ DBCSEditorSlot* csSlot;
+ s32 i;
+
+ Audio_PlaySoundGeneral(NA_SE_SY_GET_RUPY, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
+ osSyncPrintf("@@@\n@@@\n@@@/* ****** spline point data ** start here ***** */\n@@@\n");
+ for (i = 0, csSlot = sDbgEditorSlots; i < 0xF; i++, csSlot++) {
+ if (csSlot->csPointsCnt != 0) {
+ if (i != 0) {
+ osSyncPrintf("@@@\n@@@/* ** %d ** */\n@@@\n", i);
+ }
+ func_800B4920("Lookat", csSlot->csPointsCnt, csSlot->atPoints);
+ func_800B4920("Position", csSlot->csPointsCnt, csSlot->eyePoints);
+ osSyncPrintf("@@@static short nPoints = %d;\n@@@\n", csSlot->csPointsCnt);
+ osSyncPrintf("@@@static short nFrames = %d;\n@@@\n", csSlot->frameCnt);
+ osSyncPrintf("@@@static short Mode = %d;\n@@@\n", csSlot->mode);
+ }
+ }
+ osSyncPrintf("@@@\n@@@\n@@@/* ****** spline point data ** finish! ***** */\n@@@\n");
+}
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B91B0.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B958C.s")
+/**
+ * Initalizes the custscene editor
+ */
+void DbgCamera_FirstInit(Camera* camera, DBCamera* dbCamera) {
+ s32 temp_s0;
+ u32 temp_v0;
+ u32 phi_v0;
+ s32 i;
+ char* p;
+
+ D_801612EA = '*';
+ for (p = D_801612D0; p < &D_801612D0[0x1A]; p++) {
+ *p = 'X';
+ }
+
+ for (i = 0; i < 0xF; i++) {
+ func_800B8978(i, 0);
+ }
+
+ D_80161108 = dbCamera;
+ D_8016110C = 0;
+ D_80161148 = 0;
+ D_8016114A = -1;
+ D_8016111A = 0;
+}
#pragma GLOBAL_ASM("asm/non_matchings/code/db_camera/func_800B9638.s")