From da047aa99a1c88aec46e24fa452cc20c2385e6cd Mon Sep 17 00:00:00 2001 From: Dominik Peters Date: Sun, 20 Oct 2024 04:54:40 +0000 Subject: [PATCH] Document: Camera related code --- include/core2/camera.h | 73 +++++++++++++ src/core2/code_33250.c | 29 ++--- src/core2/code_33310.c | 170 ++++++++++++++---------------- src/core2/code_336F0.c | 148 +++++++++++++------------- src/core2/code_33AB0.c | 44 ++++---- src/core2/code_9BD0.c | 8 +- src/core2/nc/cameranodelist.c | 192 ++++++++++++++++------------------ src/core2/nc/dynamicCam11.c | 20 ++-- src/core2/nc/dynamicCam8.c | 14 +-- src/core2/nc/staticCamera.c | 6 +- 10 files changed, 373 insertions(+), 331 deletions(-) create mode 100644 include/core2/camera.h diff --git a/include/core2/camera.h b/include/core2/camera.h new file mode 100644 index 00000000..9ac5d64f --- /dev/null +++ b/include/core2/camera.h @@ -0,0 +1,73 @@ +#ifndef _CAMERA_H_ +#define _CAMERA_H_ +#include +#include + +typedef struct { + s32 type: 24; + s32 valid: 8; + s32 data_ptr; +} CameraNode; + +typedef struct { + f32 position[3]; + f32 horizontalSpeed; + f32 verticalSpeed; + f32 rotation; + f32 accelaration; + f32 pitchYawRoll[3]; // 0 = pitch, 1 = yaw, 2 = roll + s32 unknownFlag; // unknown, some sort of flag value, is &'ed with 1, 2 and 4 +} CameraNodeType1; + +CameraNodeType1 *cameraNodeType1_init(); +void cameraNodeType1_free(CameraNodeType1 *this); +void cameraNodeType1_fromFile(File *file_ptr, CameraNodeType1 *this); +void cameraNodeType1_getPosition(CameraNodeType1 *this, f32 position[3]); +void cameraNodeType1_getHorizontalAndVerticalSpeed(CameraNodeType1 *this, f32 *horizontal_speed, f32 *vertical_speed); +void cameraNodeType1_getRotationAndAccelaration(CameraNodeType1 *this, f32 *rotation, f32 *accelaration); + +typedef struct { + f32 position[3]; + f32 pitchYawRoll[3]; // 0 = pitch, 1 = yaw, 2 = roll +} CameraNodeType2; + +CameraNodeType2 *cameraNodeType2_init(); +void cameraNodeType2_free(CameraNodeType2 *this); +void cameraNodeType2_fromFile(File *file_ptr, CameraNodeType2 *this); +void cameraNodeType2_getPosition(CameraNodeType2 *this, f32 position[3]); +/* + * Sets 0 to pitch, 1 to yaw and 2 to roll + */ +void cameraNodeType2_getPitchYawRoll(CameraNodeType2 *this, f32 pitch_yaw_roll[3]); + +typedef struct { + f32 position[3]; + f32 horizontalSpeed; + f32 verticalSpeed; + f32 rotation; + f32 accelaration; + f32 closeDistance; + f32 farDistance; + f32 pitchYawRoll[3]; // 0 = pitch, 1 = yaw, 2 = roll + s32 unknownFlag; +} CameraNodeType3; +CameraNodeType3 *cameraNodeType3_init(); +void cameraNodeType3_free(CameraNodeType3 *this); +void cameraNodeType3_fromFile(File *file_ptr, CameraNodeType3 *this); +void cameraNodeType3_getPosition(CameraNodeType3 *this, f32 position[3]); +void cameraNodeType3_getHorizontalAndVerticalSpeed(CameraNodeType3 *this, f32 *horizontal_speed, f32 *vertical_speed); +void cameraNodeType3_getRotationAndAccelaration(CameraNodeType3 *this, f32 *rotation, f32 *accelaration); +/* + * Sets 0 to pitch, 1 to yaw and 2 to roll + */ +void cameraNodeType3_getPositionWithPitchYawRoll(CameraNodeType3 *this, f32 pitch_yaw_roll[3]); +f32 cameraNodeType3_getCloseDistance(CameraNodeType3 *this); +f32 cameraNodeType3_getFarDistance(CameraNodeType3 *this); + +typedef struct { + s32 unknownFlag; +} CameraNodeType4; +CameraNodeType4 *cameraNodeType4_init(); +void cameraNodeType4_free(CameraNodeType4 *this); +void cameraNodeType4_fromFile(File *file_ptr, CameraNodeType4 *this); +#endif diff --git a/src/core2/code_33250.c b/src/core2/code_33250.c index 56d1d3c5..ef80ffc8 100644 --- a/src/core2/code_33250.c +++ b/src/core2/code_33250.c @@ -2,32 +2,35 @@ #include "functions.h" #include "variables.h" +#include #include -void func_802BA23C(s32 *arg0, s32 arg1); +static void __code33250_func_802BA23C(CameraNodeType4 *this, s32 arg1); /* .code */ -s32 * func_802BA1E0(void){ - s32 * sp1C = malloc(4); - func_802BA23C(sp1C, 1); - return sp1C; +CameraNodeType4 *cameraNodeType4_init(){ + CameraNodeType4 * this; + + this = malloc(sizeof(CameraNodeType4)); + __code33250_func_802BA23C(this, 1); + return this; } -void func_802BA214(s32 *arg0){ - free(arg0); +void cameraNodeType4_free(CameraNodeType4 *this){ + free(this); } -s32 func_802BA234(s32 *arg0){ - return *arg0; +s32 code33250_func_802BA234(CameraNodeType4 *this){ + return this->unknownFlag; } -void func_802BA23C(s32 *arg0, s32 arg1){ - *arg0 = arg1; +static void __code33250_func_802BA23C(CameraNodeType4 *this, s32 arg1){ + this->unknownFlag = arg1; } -void func_802BA244(File *file_ptr, s32 *arg1){ +void cameraNodeType4_fromFile(File *file_ptr, CameraNodeType4 *this){ while(!file_isNextByteExpected(file_ptr, 0)){ - file_getWord_ifExpected(file_ptr, 1, arg1); + file_getWord_ifExpected(file_ptr, 1, &this->unknownFlag); } } diff --git a/src/core2/code_33310.c b/src/core2/code_33310.c index 8290ac87..ce77fe92 100644 --- a/src/core2/code_33310.c +++ b/src/core2/code_33310.c @@ -3,154 +3,142 @@ #include "variables.h" #include +#include -typedef struct{ - f32 unk0[3]; - f32 unkC; - f32 unk10; - f32 unk14; - f32 unk18; - f32 unk1C; - f32 unk20; - f32 unk24[3]; - s32 unk30; -}Struct_core2_33310; - - -void func_802BA3E8(Struct_core2_33310 *arg0, f32 arg1[3]); -void func_802BA414(Struct_core2_33310 *arg0, f32 arg1); -void func_802BA428(Struct_core2_33310 *arg0, f32 arg1); -void func_802BA460(Struct_core2_33310 *arg0, f32 arg1[3]); -void func_802BA494(Struct_core2_33310 *arg0, f32 arg1, f32 arg2); -void func_802BA4BC(Struct_core2_33310 *arg0, f32 arg1, f32 arg2); -void func_802BA510(Struct_core2_33310 *arg0, bool arg1); -void func_802BA530(Struct_core2_33310 *arg0, bool arg1); +static void __cameraNodeType3_setPitchYawRoll(CameraNodeType3 *this, f32 pitch_yaw_roll[3]); +static void __cameraNodeType3_setFarDistance(CameraNodeType3 *this, f32 far_distance); +static void __cameraNodeType3_setCloseDistance(CameraNodeType3 *this, f32 close_distnace); +static void __cameraNodeType3_setPosition(CameraNodeType3 *this, f32 position[3]); +static void __cameraNodeType3_setHorizontalAndVerticalSpeed(CameraNodeType3 *this, f32 horizontal_speed, f32 vertical_speed); +static void __cameraNodeType3_setRotationAndAccelaration(CameraNodeType3 *this, f32 rotation, f32 accelaration); +static void __code33310_func_802BA510(CameraNodeType3 *this, bool arg1); +static void __code33310_func_802BA530(CameraNodeType3 *this, bool arg1); /* .code */ -void func_802BA2A0(Struct_core2_33310 *arg0, bool arg1, s32 arg2){ - if(arg1){ - arg0->unk30 |= arg2; +static void __code33310_func_802BA2A0(CameraNodeType3 *this, bool arg1, s32 arg2) { + if(arg1) { + this->unknownFlag |= arg2; } else{ - arg0->unk30 &= ~arg2; + this->unknownFlag &= ~arg2; } } -bool func_802BA2D0(Struct_core2_33310 *arg0, s32 arg1){ - if(arg0->unk30 & arg1) +bool __code33310_func_802BA2D0(CameraNodeType3 *this, s32 arg1) { + if(this->unknownFlag & arg1) return TRUE; return FALSE; } -Struct_core2_33310 *func_802BA2F4(void){ - Struct_core2_33310 * this; +CameraNodeType3 *cameraNodeType3_init() { + CameraNodeType3 * this; f32 sp20[3]; - this = (Struct_core2_33310 *)malloc(sizeof(Struct_core2_33310)); + this = (CameraNodeType3 *)malloc(sizeof(CameraNodeType3)); ml_vec3f_clear(sp20); - func_802BA460(this, sp20); - func_802BA3E8(this, sp20); - func_802BA494(this, 2.84f, 5.68f); - func_802BA4BC(this, 4.0f, 16.0f); - func_802BA428(this, 1000.0f); - func_802BA414(this, 1000.0f); - func_802BA530(this, FALSE); - func_802BA510(this, FALSE); + __cameraNodeType3_setPosition(this, sp20); + __cameraNodeType3_setPitchYawRoll(this, sp20); + __cameraNodeType3_setHorizontalAndVerticalSpeed(this, 2.84f, 5.68f); + __cameraNodeType3_setRotationAndAccelaration(this, 4.0f, 16.0f); + __cameraNodeType3_setCloseDistance(this, 1000.0f); + __cameraNodeType3_setFarDistance(this, 1000.0f); + __code33310_func_802BA530(this, FALSE); + __code33310_func_802BA510(this, FALSE); return this; } -void func_802BA398(Struct_core2_33310 *arg0){ - free(arg0); +void cameraNodeType3_free(CameraNodeType3 *this) { + free(this); } -void func_802BA3B8(Struct_core2_33310 *arg0, f32 arg1[3]){ - ml_vec3f_add(arg1, arg0->unk0, arg0->unk24); +void cameraNodeType3_getPositionWithPitchYawRoll(CameraNodeType3 *this, f32 pitch_yaw_roll[3]) { + ml_vec3f_add(pitch_yaw_roll, this->position, this->pitchYawRoll); } -void func_802BA3E8(Struct_core2_33310 *arg0, f32 arg1[3]){ - ml_vec3f_diff_copy(arg0->unk24, arg1, arg0->unk0); +static void __cameraNodeType3_setPitchYawRoll(CameraNodeType3 *this, f32 pitch_yaw_roll[3]) { + ml_vec3f_diff_copy(this->pitchYawRoll, pitch_yaw_roll, this->position); } -f32 func_802BA40C(Struct_core2_33310 *arg0){ - return arg0->unk20; +f32 cameraNodeType3_getFarDistance(CameraNodeType3 *this) { + return this->farDistance; } -void func_802BA414(Struct_core2_33310 *arg0, f32 arg1){ - arg0->unk20 = arg1; +static void __cameraNodeType3_setFarDistance(CameraNodeType3 *this, f32 far_distance) { + this->farDistance = far_distance; } -f32 func_802BA420(Struct_core2_33310 *arg0){ - return arg0->unk1C; +f32 cameraNodeType3_getCloseDistance(CameraNodeType3 *this) { + return this->closeDistance; } -void func_802BA428(Struct_core2_33310 *arg0, f32 arg1){ - arg0->unk1C = arg1; +static void __cameraNodeType3_setCloseDistance(CameraNodeType3 *this, f32 close_distance) { + this->closeDistance = close_distance; } -void func_802BA434(Struct_core2_33310 *arg0, f32 arg1[3]){ - ml_vec3f_copy(arg1, arg0->unk0); +void cameraNodeType3_getPosition(CameraNodeType3 *this, f32 position[3]) { + ml_vec3f_copy(position, this->position); } -void func_802BA460(Struct_core2_33310 *arg0, f32 arg1[3]){ - ml_vec3f_copy(arg0->unk0, arg1); +static void __cameraNodeType3_setPosition(CameraNodeType3 *this, f32 position[3]) { + ml_vec3f_copy(this->position, position); } -void func_802BA480(Struct_core2_33310 *arg0, f32 *arg1, f32 *arg2){ - *arg1 = arg0->unkC; - *arg2 = arg0->unk10; +void cameraNodeType3_getHorizontalAndVerticalSpeed(CameraNodeType3 *this, f32 *horizontal_speed, f32 *vertical_speed) { + *horizontal_speed = this->horizontalSpeed; + *vertical_speed = this->verticalSpeed; } -void func_802BA494(Struct_core2_33310 *arg0, f32 arg1, f32 arg2){ - arg0->unkC = arg1; - arg0->unk10 = arg2; +static void __cameraNodeType3_setHorizontalAndVerticalSpeed(CameraNodeType3 *this, f32 horizontal_speed, f32 vertical_speed) { + this->horizontalSpeed = horizontal_speed; + this->verticalSpeed = vertical_speed; } -void func_802BA4A8(Struct_core2_33310 *arg0, f32 *arg1, f32 *arg2){ - *arg1 = arg0->unk14; - *arg2 = arg0->unk18; +void cameraNodeType3_getRotationAndAccelaration(CameraNodeType3 *this, f32 *rotation, f32 *accelaration) { + *rotation = this->rotation; + *accelaration = this->accelaration; } -void func_802BA4BC(Struct_core2_33310 *arg0, f32 arg1, f32 arg2){ - arg0->unk14 = arg1; - arg0->unk18 = arg2; +static void __cameraNodeType3_setRotationAndAccelaration(CameraNodeType3 *this, f32 rotation, f32 accelaration) { + this->rotation = rotation; + this->accelaration = accelaration; } -bool func_802BA4D0(Struct_core2_33310 *arg0){ - return func_802BA2D0(arg0, 4); +bool code33310_func_802BA4D0(CameraNodeType3 *this) { + return __code33310_func_802BA2D0(this, 4); } -bool func_802BA4F0(Struct_core2_33310 *arg0){ - return func_802BA2D0(arg0, 1); +bool code33310_func_802BA4F0(CameraNodeType3 *this) { + return __code33310_func_802BA2D0(this, 1); } -void func_802BA510(Struct_core2_33310 *arg0, bool arg1){ - func_802BA2A0(arg0, arg1, 4); +static void __code33310_func_802BA510(CameraNodeType3 *this, bool arg1) { + __code33310_func_802BA2A0(this, arg1, 4); } -void func_802BA530(Struct_core2_33310 *arg0, bool arg1){ - func_802BA2A0(arg0, arg1, 1); +static void __code33310_func_802BA530(CameraNodeType3 *this, bool arg1) { + __code33310_func_802BA2A0(this, arg1, 1); } -void func_802BA550(File *file_ptr, Struct_core2_33310 *arg1){ - while(!file_isNextByteExpected(file_ptr, 0)){ - if(!file_getNFloats_ifExpected(file_ptr, 1, arg1->unk0, 3)){ - if(file_isNextByteExpected(file_ptr, 2)){ - file_getFloat(file_ptr, &arg1->unkC); - file_getFloat(file_ptr, &arg1->unk10); +void cameraNodeType3_fromFile(File *file_ptr, CameraNodeType3 *this) { + while(!file_isNextByteExpected(file_ptr, 0)) { + if(!file_getNFloats_ifExpected(file_ptr, 1, this->position, 3)) { + if(file_isNextByteExpected(file_ptr, 2)) { + file_getFloat(file_ptr, &this->horizontalSpeed); + file_getFloat(file_ptr, &this->verticalSpeed); } - else if(file_isNextByteExpected(file_ptr, 3)){ - file_getFloat(file_ptr, &arg1->unk14); - file_getFloat(file_ptr, &arg1->unk18); + else if(file_isNextByteExpected(file_ptr, 3)) { + file_getFloat(file_ptr, &this->rotation); + file_getFloat(file_ptr, &this->accelaration); } - else if(file_isNextByteExpected(file_ptr, 6)){ - file_getFloat(file_ptr, &arg1->unk1C); - file_getFloat(file_ptr, &arg1->unk20); + else if(file_isNextByteExpected(file_ptr, 6)) { + file_getFloat(file_ptr, &this->closeDistance); + file_getFloat(file_ptr, &this->farDistance); } else{ - if(!file_getNFloats_ifExpected(file_ptr, 4, arg1->unk24, 3)){ - file_getWord_ifExpected(file_ptr, 5, &arg1->unk30); + if(!file_getNFloats_ifExpected(file_ptr, 4, this->pitchYawRoll, 3)) { + file_getWord_ifExpected(file_ptr, 5, &this->unknownFlag); } } - }//L802BA654 + } } } diff --git a/src/core2/code_336F0.c b/src/core2/code_336F0.c index 8ab4922b..7802ccf2 100644 --- a/src/core2/code_336F0.c +++ b/src/core2/code_336F0.c @@ -4,132 +4,124 @@ #include "functions.h" #include "variables.h" +#include -typedef struct { - f32 unk0[3]; - f32 unkC; - f32 unk10; - f32 unk14; - f32 unk18; - f32 unk1C[3]; - s32 unk28; -} Struct_core2_336F0; -void func_802BA7B8(Struct_core2_336F0 *arg0, f32 arg1[3]); -void func_802BA808(Struct_core2_336F0 *arg0, f32 arg1[3]); -void func_802BA840(Struct_core2_336F0 *arg0, f32 arg1, f32 arg2); -void func_802BA868(Struct_core2_336F0 *arg0, f32 arg1, f32 arg2); -void func_802BA8DC(Struct_core2_336F0 *arg0, s32 arg1); -void func_802BA8FC(Struct_core2_336F0 *arg0, s32 arg1); -void func_802BA91C(Struct_core2_336F0 *arg0, s32 arg1); +static void __cameraNodeType1_setPosition(CameraNodeType1 *this, f32 position[3]); +static void __cameraNodeType1_func_802BA808(CameraNodeType1 *this, f32 arg1[3]); +static void __cameraNodeType1_setHorizontalAndVerticalSpeed(CameraNodeType1 *this, f32 horizontal_speed, f32 vertical_speed); +static void __cameraNodeType1_setRotationAndAccelaration(CameraNodeType1 *this, f32 rotation, f32 accelaration); +static void __code336F0_func_802BA8DC(CameraNodeType1 *this, s32 arg1); +static void __code336F0_func_802BA8FC(CameraNodeType1 *this, s32 arg1); +static void __code336F0_func_802BA91C(CameraNodeType1 *this, s32 arg1); -void func_802BA680(Struct_core2_336F0 *arg0, s32 arg1, s32 arg2){ - if(arg1){ - arg0->unk28 |= arg2; - }else{ - arg0->unk28 &= ~arg2; +static void __code336F0_func_802BA680(CameraNodeType1 *this, s32 arg1, s32 arg2) { + if(arg1) { + this->unknownFlag |= arg2; + } else{ + this->unknownFlag &= ~arg2; } } -bool func_802BA6B0(Struct_core2_336F0 *arg0, s32 arg1){ - if (arg0->unk28 & arg1) +static bool __code336F0_func_802BA6B0(CameraNodeType1 *this, s32 arg1) { + if (this->unknownFlag & arg1) return TRUE; return FALSE; } -Struct_core2_336F0 *func_802BA6D4(void){ - Struct_core2_336F0 *this; +CameraNodeType1 *cameraNodeType1_init() { + CameraNodeType1 *this; f32 sp20[3]; - this = (Struct_core2_336F0 *)malloc(sizeof(Struct_core2_336F0)); + this = (CameraNodeType1 *)malloc(sizeof(CameraNodeType1)); ml_vec3f_clear(sp20); - func_802BA7B8(this, sp20); - func_802BA808(this, sp20); - func_802BA840(this, 0.7f, 2.33f); - func_802BA868(this, 4.0f, 16.0f); - func_802BA8DC(this, 0); - func_802BA91C(this, 1); - func_802BA8FC(this, 0); + __cameraNodeType1_setPosition(this, sp20); + __cameraNodeType1_func_802BA808(this, sp20); + __cameraNodeType1_setHorizontalAndVerticalSpeed(this, 0.7f, 2.33f); + __cameraNodeType1_setRotationAndAccelaration(this, 4.0f, 16.0f); + __code336F0_func_802BA8DC(this, 0); + __code336F0_func_802BA91C(this, 1); + __code336F0_func_802BA8FC(this, 0); return this; } -void func_802BA76C(Struct_core2_336F0 *arg0){ - free(arg0); +void cameraNodeType1_free(CameraNodeType1 *this) { + free(this); } -void func_802BA78C(Struct_core2_336F0 *arg0, f32 arg1[3]){ - ml_vec3f_copy(arg1, arg0->unk0); +void cameraNodeType1_getPosition(CameraNodeType1 *this, f32 position[3]) { + ml_vec3f_copy(position, this->position); } -void func_802BA7B8(Struct_core2_336F0 *arg0, f32 arg1[3]){ - ml_vec3f_copy(arg0->unk0, arg1); +static void __cameraNodeType1_setPosition(CameraNodeType1 *this, f32 position[3]) { + ml_vec3f_copy(this->position, position); } -void func_802BA7D8(Struct_core2_336F0 *arg0, f32 arg1[3]){ - ml_vec3f_add(arg1, arg0->unk0, arg0->unk1C); +void code336F0_func_802BA7D8(CameraNodeType1 *this, f32 arg1[3]) { + ml_vec3f_add(arg1, this->position, this->pitchYawRoll); } -void func_802BA808(Struct_core2_336F0 *arg0, f32 arg1[3]){ - ml_vec3f_diff_copy(arg0->unk1C, arg1, arg0->unk0); +static void __cameraNodeType1_func_802BA808(CameraNodeType1 *this, f32 arg1[3]) { + ml_vec3f_diff_copy(this->pitchYawRoll, arg1, this->position); } -void func_802BA82C(Struct_core2_336F0 *arg0, f32 *arg1, f32 *arg2){ - *arg1 = arg0->unkC; - *arg2 = arg0->unk10; +void cameraNodeType1_getHorizontalAndVerticalSpeed(CameraNodeType1 *this, f32 *horizontal_speed, f32 *vertical_speed) { + *horizontal_speed = this->horizontalSpeed; + *vertical_speed = this->verticalSpeed; } -void func_802BA840(Struct_core2_336F0 *arg0, f32 arg1, f32 arg2){ - arg0->unkC = arg1; - arg0->unk10 = arg2; +static void __cameraNodeType1_setHorizontalAndVerticalSpeed(CameraNodeType1 *this, f32 horizontal_speed, f32 vertical_speed) { + this->horizontalSpeed = horizontal_speed; + this->verticalSpeed = vertical_speed; } -void func_802BA854(Struct_core2_336F0 *arg0, f32 *arg1, f32 *arg2){ - *arg1 = arg0->unk14; - *arg2 = arg0->unk18; +void cameraNodeType1_getRotationAndAccelaration(CameraNodeType1 *this, f32 *rotation, f32 *accelaration) { + *rotation = this->rotation; + *accelaration = this->accelaration; } -void func_802BA868(Struct_core2_336F0 *arg0, f32 arg1, f32 arg2){ - arg0->unk14 = arg1; - arg0->unk18 = arg2; +static void __cameraNodeType1_setRotationAndAccelaration(CameraNodeType1 *this, f32 rotation, f32 accelaration) { + this->rotation = rotation; + this->accelaration = accelaration; } -bool func_802BA87C(Struct_core2_336F0 *arg0){ - return func_802BA6B0(arg0, 1); +bool code336F0_func_802BA87C(CameraNodeType1 *this) { + return __code336F0_func_802BA6B0(this, 0x1); } -bool func_802BA89C(Struct_core2_336F0 *arg0){ - return func_802BA6B0(arg0, 4); +bool code336F0_func_802BA89C(CameraNodeType1 *this) { + return __code336F0_func_802BA6B0(this, 0x4); } -bool func_802BA8BC(Struct_core2_336F0 *arg0){ - return func_802BA6B0(arg0, 2); +bool code336F0_func_802BA8BC(CameraNodeType1 *this) { + return __code336F0_func_802BA6B0(this, 0x2); } -void func_802BA8DC(Struct_core2_336F0 *arg0, s32 arg1){ - func_802BA680(arg0, arg1, 1); +static void __code336F0_func_802BA8DC(CameraNodeType1 *this, s32 arg1) { + __code336F0_func_802BA680(this, arg1, 0x1); } -void func_802BA8FC(Struct_core2_336F0 *arg0, s32 arg1){ - func_802BA680(arg0, arg1, 4); +static void __code336F0_func_802BA8FC(CameraNodeType1 *this, s32 arg1) { + __code336F0_func_802BA680(this, arg1, 0x4); } -void func_802BA91C(Struct_core2_336F0 *arg0, s32 arg1){ - func_802BA680(arg0, arg1, 2); +static void __code336F0_func_802BA91C(CameraNodeType1 *this, s32 arg1) { + __code336F0_func_802BA680(this, arg1, 0x2); } -void func_802BA93C(File *file_ptr, Struct_core2_336F0 *arg1){ - while(!file_isNextByteExpected(file_ptr, 0)){ - if(!file_getNFloats_ifExpected(file_ptr, 1, arg1->unk0, 3)){ - if(file_isNextByteExpected(file_ptr, 2)){ - file_getFloat(file_ptr, &arg1->unkC); - file_getFloat(file_ptr, &arg1->unk10); +void cameraNodeType1_fromFile(File *file_ptr, CameraNodeType1 *this) { + while(!file_isNextByteExpected(file_ptr, 0)) { + if(!file_getNFloats_ifExpected(file_ptr, 1, this->position, 3)) { + if(file_isNextByteExpected(file_ptr, 2)) { + file_getFloat(file_ptr, &this->horizontalSpeed); + file_getFloat(file_ptr, &this->verticalSpeed); } - else if(file_isNextByteExpected(file_ptr, 3)){ - file_getFloat(file_ptr, &arg1->unk14); - file_getFloat(file_ptr, &arg1->unk18); + else if(file_isNextByteExpected(file_ptr, 3)) { + file_getFloat(file_ptr, &this->rotation); + file_getFloat(file_ptr, &this->accelaration); } - else if(!file_getNFloats_ifExpected(file_ptr, 4, arg1->unk1C, 3)){ - file_getWord_ifExpected(file_ptr, 5, &arg1->unk28); + else if(!file_getNFloats_ifExpected(file_ptr, 4, this->pitchYawRoll, 3)) { + file_getWord_ifExpected(file_ptr, 5, &this->unknownFlag); } }//L802BAA0C } diff --git a/src/core2/code_33AB0.c b/src/core2/code_33AB0.c index 85ed8322..cefd9826 100644 --- a/src/core2/code_33AB0.c +++ b/src/core2/code_33AB0.c @@ -3,51 +3,47 @@ #include "variables.h" #include +#include -typedef struct { - f32 position[3]; - f32 rotation[3]; -} CameraNodeType2; - -void ncCameraNodeType2_setPosition(CameraNodeType2 *this, f32 src[3]); -void ncCameraNodeType2_setRotation(CameraNodeType2 *this, f32 src[3]); +static void __cameraNodeType2_setPosition(CameraNodeType2 *this, f32 position[3]); +static void __cameraNodeType2_setPitchYawRoll(CameraNodeType2 *this, f32 pitch_yaw_roll[3]); /* .code */ -CameraNodeType2 *ncCameraNodeType2_new(void){ +CameraNodeType2 *cameraNodeType2_init() { CameraNodeType2 *this; f32 sp18[3]; this = (CameraNodeType2 *)malloc(sizeof(CameraNodeType2)); ml_vec3f_clear(sp18); - ncCameraNodeType2_setPosition(this, sp18); - ncCameraNodeType2_setRotation(this, sp18); + __cameraNodeType2_setPosition(this, sp18); + __cameraNodeType2_setPitchYawRoll(this, sp18); return this; } -void ncCameraNodeType2_free(CameraNodeType2 *this){ +void cameraNodeType2_free(CameraNodeType2 *this) { free(this); } -void ncCameraNodeType2_getPosition(CameraNodeType2 *this, f32 dst[3]){\ - ml_vec3f_copy(dst, this->position); +void cameraNodeType2_getPosition(CameraNodeType2 *this, f32 position[3]) { + ml_vec3f_copy(position, this->position); } -void ncCameraNodeType2_setPosition(CameraNodeType2 *this, f32 src[3]){ - ml_vec3f_copy(this->position, src); +void __cameraNodeType2_setPosition(CameraNodeType2 *this, f32 position[3]) { + ml_vec3f_copy(this->position, position); } -void ncCameraNodeType2_getRotation(CameraNodeType2 *this, f32 dst[3]){\ - ml_vec3f_copy(dst, this->rotation); +void cameraNodeType2_getPitchYawRoll(CameraNodeType2 *this, f32 pitch_yaw_roll[3]) {\ + ml_vec3f_copy(pitch_yaw_roll, this->pitchYawRoll); } -void ncCameraNodeType2_setRotation(CameraNodeType2 *this, f32 src[3]){ - ml_vec3f_copy(this->rotation, src); +void __cameraNodeType2_setPitchYawRoll(CameraNodeType2 *this, f32 pitch_yaw_roll[3]) { + ml_vec3f_copy(this->pitchYawRoll, pitch_yaw_roll); } -void ncCameraNodeType2_fromFile(File *file_ptr, CameraNodeType2 *arg1){ - while(!file_isNextByteExpected(file_ptr, 0)){ - if(!file_getNFloats_ifExpected(file_ptr, 1, arg1->position, 3)){ - file_getNFloats_ifExpected(file_ptr, 2, arg1->rotation, 3); - }//L802BAA0C +void cameraNodeType2_fromFile(File *file_ptr, CameraNodeType2 *this) { + while(!file_isNextByteExpected(file_ptr, 0)) { + if(!file_getNFloats_ifExpected(file_ptr, 1, &this->position, 3)) { + file_getNFloats_ifExpected(file_ptr, 2, &this->pitchYawRoll, 3); + } } } diff --git a/src/core2/code_9BD0.c b/src/core2/code_9BD0.c index b9473951..fa8b5fc0 100644 --- a/src/core2/code_9BD0.c +++ b/src/core2/code_9BD0.c @@ -75,12 +75,12 @@ int func_80290D48(void){ sp1C = bs_getState(); switch(ncCameraNodeList_getNodeType(camera_node_index)){ case 4: - sp28 = func_802B9E34(camera_node_index); - sp24 = func_802BA234(sp28); + sp28 = ncCameraNodeList_getCameraNodeType4(camera_node_index); + sp24 = code33250_func_802BA234(sp28); func_80290BC0(sp24); return FALSE; case 3: //L80290DD8 - if(bsBeeFly_inSet(sp1C) && !func_802BA4D0(func_802B9E48(camera_node_index))){ + if(bsBeeFly_inSet(sp1C) && !code33310_func_802BA4D0(ncCameraNodeList_getCameraNodeType3(camera_node_index))){ return FALSE; } ncDynamicCamera_setState(0x11); @@ -88,7 +88,7 @@ int func_80290D48(void){ func_80291488(0x9); return TRUE; case 1://L80290E28 - if(bsBeeFly_inSet(sp1C) && !func_802BA89C(func_802B9E5C(camera_node_index))){ + if(bsBeeFly_inSet(sp1C) && !code336F0_func_802BA89C(ncCameraNodeList_getCameraNodeType1(camera_node_index))){ return FALSE; } ncDynamicCamera_setState(0x8); diff --git a/src/core2/nc/cameranodelist.c b/src/core2/nc/cameranodelist.c index 03b6e2ee..9202d4f0 100644 --- a/src/core2/nc/cameranodelist.c +++ b/src/core2/nc/cameranodelist.c @@ -3,177 +3,167 @@ #include "variables.h" #include +#include #define NC_CAMERA_NODE_LIST_CAPACITY 0x46 -typedef struct { - s32 type:24; - s32 valid:8; - s32 data_ptr; -} Struct_Core2_32DB0_0s; - -void __ncCameraNodeList_removeNode(s32 arg0); -s32 ncCameraNodeList_nodeIsValid(s32 arg0); -void func_802B9EBC(s32 arg0, s32 arg1); +static void __ncCameraNodeList_removeNode(int camera_node_index); +s32 ncCameraNodeList_nodeIsValid(int camera_node_index); +static void __ncCameraNodeList_setCameraNodeType(int camera_node_index, s32 type); /* .bss */ -Struct_Core2_32DB0_0s ncCameraNodeList[NC_CAMERA_NODE_LIST_CAPACITY]; +CameraNode sNcCameraNodeList[NC_CAMERA_NODE_LIST_CAPACITY]; /* .code */ -void ncCameraNodeList_init(void){ +void ncCameraNodeList_init() { int i; - for(i = 0; i< NC_CAMERA_NODE_LIST_CAPACITY; i++){ - ncCameraNodeList[i].valid = FALSE; + for(i = 0; i< NC_CAMERA_NODE_LIST_CAPACITY; i++) { + sNcCameraNodeList[i].valid = FALSE; } } -void ncCameraNodeList_free(void){ +void ncCameraNodeList_free() { int i; - for(i=0; i< NC_CAMERA_NODE_LIST_CAPACITY; i++){ + for(i=0; i< NC_CAMERA_NODE_LIST_CAPACITY; i++) { if(ncCameraNodeList_nodeIsValid(i)) __ncCameraNodeList_removeNode(i); } } -void __ncCameraNodeList_addNode(s32 camera_node_index){ - ncCameraNodeList[camera_node_index].valid = TRUE; - ncCameraNodeList[camera_node_index].type = 0; +static void __ncCameraNodeList_addNode(int camera_node_index) { + sNcCameraNodeList[camera_node_index].valid = TRUE; + sNcCameraNodeList[camera_node_index].type = 0; } -void __ncCameraNodeList_removeNode(s32 camera_node_index){ - func_802B9EBC(camera_node_index, 0); - ncCameraNodeList[camera_node_index].valid = 0; +static void __ncCameraNodeList_removeNode(int camera_node_index) { + __ncCameraNodeList_setCameraNodeType(camera_node_index, 0); + sNcCameraNodeList[camera_node_index].valid = 0; } -//ncCameraNodeList_getdata_ptr_type4 -s32 func_802B9E34(s32 camera_node_index){ - return ncCameraNodeList[camera_node_index].data_ptr; +CameraNodeType4* ncCameraNodeList_getCameraNodeType4(int camera_node_index) { + return sNcCameraNodeList[camera_node_index].data_ptr; } -//ncCameraNodeList_getdata_ptr_type3 -s32 func_802B9E48(s32 camera_node_index){ - return ncCameraNodeList[camera_node_index].data_ptr; +CameraNodeType3* ncCameraNodeList_getCameraNodeType3(int camera_node_index) { + return sNcCameraNodeList[camera_node_index].data_ptr; } -//ncCameraNodeList_getdata_ptr_type1 -s32 func_802B9E5C(s32 camera_node_index){ - return ncCameraNodeList[camera_node_index].data_ptr; +CameraNodeType1* ncCameraNodeList_getCameraNodeType1(int camera_node_index) { + return sNcCameraNodeList[camera_node_index].data_ptr; } -//ncCameraNodeList_getdata_ptr_type2 -s32 func_802B9E70(s32 camera_node_index){ - return ncCameraNodeList[camera_node_index].data_ptr; +CameraNodeType2* ncCameraNodeList_getCameraNodeType2(int camera_node_index) { + return sNcCameraNodeList[camera_node_index].data_ptr; } -s32 ncCameraNodeList_capacity(void){ +s32 __ncCameraNodeList_capacity() { return NC_CAMERA_NODE_LIST_CAPACITY; } -s32 ncCameraNodeList_getNodeType(s32 camera_node_index){ - return ncCameraNodeList[camera_node_index].type; +s32 ncCameraNodeList_getNodeType(int camera_node_index) { + return sNcCameraNodeList[camera_node_index].type; } -s32 ncCameraNodeList_nodeIsValid(s32 camera_node_index){ - return ncCameraNodeList[camera_node_index].valid; +s32 ncCameraNodeList_nodeIsValid(int camera_node_index) { + return sNcCameraNodeList[camera_node_index].valid; } -void func_802B9EBC(s32 camera_node_index, s32 arg1){ - if(arg1 == ncCameraNodeList[camera_node_index].type) +static void __ncCameraNodeList_setCameraNodeType(int camera_node_index, s32 type) { + if(type == sNcCameraNodeList[camera_node_index].type) return; - //remove old cameraNodedata_ptr - switch(ncCameraNodeList[camera_node_index].type){ - case 4:// L802B9F08 - func_802BA214(ncCameraNodeList[camera_node_index].data_ptr); + + switch(sNcCameraNodeList[camera_node_index].type) { + case 4: + cameraNodeType4_free(sNcCameraNodeList[camera_node_index].data_ptr); break; - case 3:// L802B9F18 - func_802BA398(ncCameraNodeList[camera_node_index].data_ptr); + case 3: + cameraNodeType3_free(sNcCameraNodeList[camera_node_index].data_ptr); break; - case 1:// L802B9F28 - func_802BA76C(ncCameraNodeList[camera_node_index].data_ptr); + case 1: + cameraNodeType1_free(sNcCameraNodeList[camera_node_index].data_ptr); break; - case 2:// L802B9F38 - ncCameraNodeType2_free(ncCameraNodeList[camera_node_index].data_ptr); + case 2: + cameraNodeType2_free(sNcCameraNodeList[camera_node_index].data_ptr); break; - case 0:// L802B9F40 + case 0: break; } - ncCameraNodeList[camera_node_index].type = arg1; + sNcCameraNodeList[camera_node_index].type = type; - //init new camera node data_ptr - switch (arg1) + switch (type) { - case 4:// L802B9F80 - ncCameraNodeList[camera_node_index].data_ptr = func_802BA1E0(); - break; - case 3:// L802B9F90 - ncCameraNodeList[camera_node_index].data_ptr = func_802BA2F4(); - break; - case 1:// L802B9FA0 - ncCameraNodeList[camera_node_index].data_ptr = func_802BA6D4(); - break; - case 2:// L802B9FB0 - ncCameraNodeList[camera_node_index].data_ptr = ncCameraNodeType2_new(); - break; - case 0:// L802B9FBC - break; + case 4: + sNcCameraNodeList[camera_node_index].data_ptr = cameraNodeType4_init(); + break; + case 3: + sNcCameraNodeList[camera_node_index].data_ptr = cameraNodeType3_init(); + break; + case 1: + sNcCameraNodeList[camera_node_index].data_ptr = cameraNodeType1_init(); + break; + case 2: + sNcCameraNodeList[camera_node_index].data_ptr = cameraNodeType2_init(); + break; + case 0: + break; } } -void __ncCameraNodeList_nodeFromFile(File *file_ptr, s32 arg1){ - u8 sp27; - __ncCameraNodeList_addNode(arg1); - file_getByte_ifExpected(file_ptr, 2, &sp27); - func_802B9EBC(arg1, sp27); - switch(ncCameraNodeList_getNodeType(arg1)){ - case 4:// L802BA030 - func_802BA244(file_ptr, func_802B9E34(arg1)); +void __ncCameraNodeList_nodeFromFile(File *file_ptr, int camera_node_index) { + u8 camera_node_type; + __ncCameraNodeList_addNode(camera_node_index); + file_getByte_ifExpected(file_ptr, 2, &camera_node_type); + __ncCameraNodeList_setCameraNodeType(camera_node_index, camera_node_type); + switch(ncCameraNodeList_getNodeType(camera_node_index)) { + case 4: + cameraNodeType4_fromFile(file_ptr, ncCameraNodeList_getCameraNodeType4(camera_node_index)); break; - case 3:// L802BA04C - func_802BA550(file_ptr, func_802B9E48(arg1)); + case 3: + cameraNodeType3_fromFile(file_ptr, ncCameraNodeList_getCameraNodeType3(camera_node_index)); break; - case 1:// L802BA068 - func_802BA93C(file_ptr, func_802B9E5C(arg1)); + case 1: + cameraNodeType1_fromFile(file_ptr, ncCameraNodeList_getCameraNodeType1(camera_node_index)); break; - case 2:// L802BA084 - ncCameraNodeType2_fromFile(file_ptr, func_802B9E70(arg1)); + case 2: + cameraNodeType2_fromFile(file_ptr, ncCameraNodeList_getCameraNodeType2(camera_node_index)); break; - case 0:// L802BA098 + case 0: break; } } -void ncCameraNodeList_fromFile(File *file_ptr){ - s16 sp26; +void ncCameraNodeList_fromFile(File *file_ptr) { + s16 camera_node_index; ncCameraNodeList_free(); ncCameraNodeList_init(); - while(!file_isNextByteExpected(file_ptr, 0)){ - if(file_getShort_ifExpected(file_ptr, 1, &sp26)) - __ncCameraNodeList_nodeFromFile(file_ptr, sp26); + while(!file_isNextByteExpected(file_ptr, 0)) { + if(file_getShort_ifExpected(file_ptr, 1, &camera_node_index)) + __ncCameraNodeList_nodeFromFile(file_ptr, camera_node_index); } } -void ncCameraNodeList_defrag(void){ +void ncCameraNodeList_defrag() { int i; - for(i = 0; i< NC_CAMERA_NODE_LIST_CAPACITY; i++){ - if(ncCameraNodeList[i].valid){ - switch(ncCameraNodeList[i].type){ - case 4:// L802BA17C - ncCameraNodeList[i].data_ptr = defrag(ncCameraNodeList[i].data_ptr); + for(i = 0; i < NC_CAMERA_NODE_LIST_CAPACITY; i++) { + if(sNcCameraNodeList[i].valid) { + switch(sNcCameraNodeList[i].type) { + case 4: + sNcCameraNodeList[i].data_ptr = defrag(sNcCameraNodeList[i].data_ptr); break; - case 3:// L802BA18C - ncCameraNodeList[i].data_ptr = defrag(ncCameraNodeList[i].data_ptr); + case 3: + sNcCameraNodeList[i].data_ptr = defrag(sNcCameraNodeList[i].data_ptr); break; - case 1:// L802BA19C - ncCameraNodeList[i].data_ptr = defrag(ncCameraNodeList[i].data_ptr); + case 1: + sNcCameraNodeList[i].data_ptr = defrag(sNcCameraNodeList[i].data_ptr); break; - case 2:// L802BA1AC - ncCameraNodeList[i].data_ptr = defrag(ncCameraNodeList[i].data_ptr); + case 2: + sNcCameraNodeList[i].data_ptr = defrag(sNcCameraNodeList[i].data_ptr); break; - case 0:// L802BA1B8 + case 0: break; } } diff --git a/src/core2/nc/dynamicCam11.c b/src/core2/nc/dynamicCam11.c index ac325890..9b78cf65 100644 --- a/src/core2/nc/dynamicCam11.c +++ b/src/core2/nc/dynamicCam11.c @@ -2,8 +2,8 @@ #include "functions.h" #include "variables.h" -extern f32 func_802BA40C(void *); -extern f32 func_802BA420(void *); +extern f32 cameraNodeType3_getFarDistance(void *); +extern f32 cameraNodeType3_getCloseDistance(void *); /* .bss */ f32 D_8037DAC0[3]; @@ -74,17 +74,17 @@ void func_802BF798(void) { f32 sp28; s32 temp_v0; - temp_v0 = func_802B9E48(); - D_8037DAE4 = func_802BA4F0(temp_v0); - func_802BA3B8(temp_v0, &D_8037DAD0); - func_802BA434(temp_v0, &D_8037DAC0); - func_802BA480(temp_v0, &sp2C, &sp28); + temp_v0 = ncCameraNodeList_getCameraNodeType3(); + D_8037DAE4 = code33310_func_802BA4F0(temp_v0); + cameraNodeType3_getPositionWithPitchYawRoll(temp_v0, &D_8037DAD0); + cameraNodeType3_getPosition(temp_v0, &D_8037DAC0); + cameraNodeType3_getHorizontalAndVerticalSpeed(temp_v0, &sp2C, &sp28); func_802BE230(sp2C, sp28); - func_802BA4A8(temp_v0, &sp2C, &sp28); + cameraNodeType3_getRotationAndAccelaration(temp_v0, &sp2C, &sp28); func_802BE244(sp2C, sp28); D_8037DAE8 = sp2C; D_8037DAEC = sp28; - D_8037DAE0 = func_802BA420(temp_v0); - D_8037DADC = func_802BA40C(temp_v0); + D_8037DAE0 = cameraNodeType3_getCloseDistance(temp_v0); + D_8037DADC = cameraNodeType3_getFarDistance(temp_v0); D_8037DAE5 = 0; } diff --git a/src/core2/nc/dynamicCam8.c b/src/core2/nc/dynamicCam8.c index b3f2de07..6d5fc497 100644 --- a/src/core2/nc/dynamicCam8.c +++ b/src/core2/nc/dynamicCam8.c @@ -63,14 +63,14 @@ void ncDynamicCam8_func_802BF9B8(s32 arg0) { f32 sp28; s32 temp_s0; - temp_s0 = func_802B9E5C(arg0); - D_8037DB0C = func_802BA8BC(temp_s0); - D_8037DB0D = func_802BA87C(temp_s0); - func_802BA7D8(temp_s0, &D_8037DB00); - func_802BA78C(temp_s0, &D_8037DAF0); - func_802BA82C(temp_s0, &sp2C, &sp28); + temp_s0 = ncCameraNodeList_getCameraNodeType1(arg0); + D_8037DB0C = code336F0_func_802BA8BC (temp_s0); + D_8037DB0D = code336F0_func_802BA87C(temp_s0); + code336F0_func_802BA7D8(temp_s0, &D_8037DB00); + cameraNodeType1_getPosition(temp_s0, &D_8037DAF0); + cameraNodeType1_getHorizontalAndVerticalSpeed(temp_s0, &sp2C, &sp28); func_802BE230(sp2C, sp28); - func_802BA854(temp_s0, &sp2C, &sp28); + cameraNodeType1_getRotationAndAccelaration(temp_s0, &sp2C, &sp28); func_802BE244(sp2C, sp28); D_8037DB0E = 0; } diff --git a/src/core2/nc/staticCamera.c b/src/core2/nc/staticCamera.c index 8d72502b..ca78c846 100644 --- a/src/core2/nc/staticCamera.c +++ b/src/core2/nc/staticCamera.c @@ -41,9 +41,9 @@ void ncStaticCamera_update(void){ void __ncStaticCamera_setToNode(s32 camera_node_index){ UNK_TYPE(s32) sp1C; - sp1C = func_802B9E70(camera_node_index); - ncCameraNodeType2_getPosition(sp1C, ncStaticCameraPosition); - ncCameraNodeType2_getRotation(sp1C, ncStaticCameraRotation); + sp1C = ncCameraNodeList_getCameraNodeType2(camera_node_index); + cameraNodeType2_getPosition(sp1C, ncStaticCameraPosition); + cameraNodeType2_getPitchYawRoll(sp1C, ncStaticCameraRotation); } void ncStaticCamera_setToNode(s32 camera_node_index){