Document: Camera related code

This commit is contained in:
Dominik Peters
2024-10-20 04:54:40 +00:00
committed by Banjo Kazooie
parent d1b41e109d
commit da047aa99a
10 changed files with 373 additions and 331 deletions

View File

@@ -3,177 +3,167 @@
#include "variables.h"
#include <core2/file.h>
#include <core2/camera.h>
#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;
}
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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){