diff --git a/decompressed.us.v10.yaml b/decompressed.us.v10.yaml index 7afa4d99..5e43eef3 100644 --- a/decompressed.us.v10.yaml +++ b/decompressed.us.v10.yaml @@ -610,7 +610,7 @@ segments: - [0xF856D0, c, bs/walk] #DONE - [0xF867D0, c, bs/walrus] #DONE - [0xF88350, c, bs/washy] #DONE - - [0xF88710, c, code_32DB0] #DONE + - [0xF88710, c, nc/cameranodelist] #DONE - [0xF88BB0, c, code_33250] #DONE - [0xF88BB0, c, code_33310] #DONE - [0xF89050, c, code_336F0] #DONE @@ -1193,7 +1193,7 @@ segments: - [0x1044540, .rodata, bs/walk] - [0x10445D0, .rodata, bs/walrus] - [0x1044630, .rodata, bs/washy] - - [0x1044690, .rodata, code_32DB0] + - [0x1044690, .rodata, nc/cameranodelist] - [0x10446E0, .rodata, code_33F90] - [0x1044700, .rodata, code_34310] - [0x1044710, .rodata, code_34790] @@ -1460,7 +1460,7 @@ segments: - [0x1048560, .bss, bs/walk] - [0x1048560, .bss, bs/walrus] - [0x1048560, .bss, bs/washy] - - [0x1048560, .bss, code_32DB0] + - [0x1048560, .bss, nc/cameranodelist] - [0x1048560, .bss, code_33C30] - [0x1048560, .bss, code_33D40] - [0x1048560, .bss, code_34310] diff --git a/src/core2/code_32DB0.c b/src/core2/code_32DB0.c deleted file mode 100644 index ed137701..00000000 --- a/src/core2/code_32DB0.c +++ /dev/null @@ -1,171 +0,0 @@ -#include -#include "functions.h" -#include "variables.h" - -typedef struct { - s32 unk0:24; - s32 unk3:8; - s32 unk4; -} Struct_Core2_32DB0_0s; - -void func_802B9E00(s32 arg0); -s32 func_802B9EA8(s32 arg0); -void func_802B9EBC(s32 arg0, s32 arg1); - -/* .bss */ -Struct_Core2_32DB0_0s D_8037D5E0[0x46]; - -/* .code */ -void func_802B9D40(void){ - int i; - for(i = 0; i< 0x46; i++){ - D_8037D5E0[i].unk3 = 0; - } -} - -void func_802B9D80(void){ - int i; - - for(i=0; i< 0x46; i++){ - if(func_802B9EA8(i)) - func_802B9E00(i); - } -} - -void func_802B9DD0(s32 arg0){ - D_8037D5E0[arg0].unk3 = 1; - D_8037D5E0[arg0].unk0 = 0; - -} - -void func_802B9E00(s32 arg0){ - func_802B9EBC(arg0, 0); - D_8037D5E0[arg0].unk3 = 0; -} - -s32 func_802B9E34(s32 arg0){ - return D_8037D5E0[arg0].unk4; -} - -s32 func_802B9E48(s32 arg0){ - return D_8037D5E0[arg0].unk4; -} - -s32 func_802B9E5C(s32 arg0){ - return D_8037D5E0[arg0].unk4; -} - -s32 func_802B9E70(s32 arg0){ - return D_8037D5E0[arg0].unk4; -} - -s32 func_802B9E84(void){ - return 0x46; -} - -s32 func_802B9E8C(s32 arg0){ - return D_8037D5E0[arg0].unk0; -} - -s32 func_802B9EA8(s32 arg0){ - return D_8037D5E0[arg0].unk3; -} - -void func_802B9EBC(s32 arg0, s32 arg1){ - if(arg1 == D_8037D5E0[arg0].unk0) - return; - switch(D_8037D5E0[arg0].unk0){ - case 4:// L802B9F08 - func_802BA214(D_8037D5E0[arg0].unk4); - break; - case 3:// L802B9F18 - func_802BA398(D_8037D5E0[arg0].unk4); - break; - case 1:// L802B9F28 - func_802BA76C(D_8037D5E0[arg0].unk4); - break; - case 2:// L802B9F38 - func_802BAA88(D_8037D5E0[arg0].unk4); - break; - case 0:// L802B9F40 - break; - } - D_8037D5E0[arg0].unk0 = arg1; - switch (arg1) - { - case 4:// L802B9F80 - D_8037D5E0[arg0].unk4 = func_802BA1E0(); - break; - case 3:// L802B9F90 - D_8037D5E0[arg0].unk4 = func_802BA2F4(); - break; - case 1:// L802B9FA0 - D_8037D5E0[arg0].unk4 = func_802BA6D4(); - break; - case 2:// L802B9FB0 - D_8037D5E0[arg0].unk4 = func_802BAA40(); - break; - case 0:// L802B9FBC - break; - } - -} - -void func_802B9FD0(Struct61s *file_ptr, s32 arg1){ - u8 sp27; - func_802B9DD0(arg1); - func_8034B040(file_ptr, 2, &sp27); - func_802B9EBC(arg1, sp27); - switch(func_802B9E8C(arg1)){ - case 4:// L802BA030 - func_802BA244(file_ptr, func_802B9E34(arg1)); - break; - case 3:// L802BA04C - func_802BA550(file_ptr, func_802B9E48(arg1)); - break; - case 1:// L802BA068 - func_802BA93C(file_ptr, func_802B9E5C(arg1)); - break; - case 2:// L802BA084 - func_802BAB3C(file_ptr, func_802B9E70(arg1)); - break; - case 0:// L802BA098 - break; - } -} - -void func_802BA0AC(Struct61s *file_ptr){ - s16 sp26; - func_802B9D80(); - func_802B9D40(); - while(!func_8034AF98(file_ptr, 0)){ - if(func_8034B220(file_ptr, 1, &sp26)) - func_802B9FD0(file_ptr, sp26); - } - -} - -void func_802BA128(void){ - int i; - for(i = 0; i< 0x46; i++){ - if(D_8037D5E0[i].unk3){ - switch(D_8037D5E0[i].unk0){ - case 4:// L802BA17C - D_8037D5E0[i].unk4 = defrag(D_8037D5E0[i].unk4); - break; - case 3:// L802BA18C - D_8037D5E0[i].unk4 = defrag(D_8037D5E0[i].unk4); - break; - case 1:// L802BA19C - D_8037D5E0[i].unk4 = defrag(D_8037D5E0[i].unk4); - break; - case 2:// L802BA1AC - D_8037D5E0[i].unk4 = defrag(D_8037D5E0[i].unk4); - break; - case 0:// L802BA1B8 - break; - } - } - } -} - diff --git a/src/core2/code_33250.c b/src/core2/code_33250.c index 55fce822..2ead0d11 100644 --- a/src/core2/code_33250.c +++ b/src/core2/code_33250.c @@ -26,8 +26,8 @@ void func_802BA23C(s32 *arg0, s32 arg1){ } void func_802BA244(Struct61s *file_ptr, s32 *arg1){ - while(!func_8034AF98(file_ptr, 0)){ - func_8034B150(file_ptr, 1, arg1); + while(!file_isNextByteExpected(file_ptr, 0)){ + file_getWord_ifExpected(file_ptr, 1, arg1); } } diff --git a/src/core2/code_33310.c b/src/core2/code_33310.c index 874a8870..8d17326b 100644 --- a/src/core2/code_33310.c +++ b/src/core2/code_33310.c @@ -130,23 +130,23 @@ void func_802BA530(Struct_core2_33310 *arg0, bool arg1){ } void func_802BA550(Struct61s *file_ptr, Struct_core2_33310 *arg1){ - while(!func_8034AF98(file_ptr, 0)){ - if(!func_8034B108(file_ptr, 1, arg1->unk0, 3)){ - if(func_8034AF98(file_ptr, 2)){ - func_8034AD20(file_ptr, &arg1->unkC); - func_8034AD20(file_ptr, &arg1->unk10); + 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); } - else if(func_8034AF98(file_ptr, 3)){ - func_8034AD20(file_ptr, &arg1->unk14); - func_8034AD20(file_ptr, &arg1->unk18); + else if(file_isNextByteExpected(file_ptr, 3)){ + file_getFloat(file_ptr, &arg1->unk14); + file_getFloat(file_ptr, &arg1->unk18); } - else if(func_8034AF98(file_ptr, 6)){ - func_8034AD20(file_ptr, &arg1->unk1C); - func_8034AD20(file_ptr, &arg1->unk20); + else if(file_isNextByteExpected(file_ptr, 6)){ + file_getFloat(file_ptr, &arg1->unk1C); + file_getFloat(file_ptr, &arg1->unk20); } else{ - if(!func_8034B108(file_ptr, 4, arg1->unk24, 3)){ - func_8034B150(file_ptr, 5, &arg1->unk30); + if(!file_getNFloats_ifExpected(file_ptr, 4, arg1->unk24, 3)){ + file_getWord_ifExpected(file_ptr, 5, &arg1->unk30); } } }//L802BA654 diff --git a/src/core2/code_336F0.c b/src/core2/code_336F0.c index 8a907452..670c11f1 100644 --- a/src/core2/code_336F0.c +++ b/src/core2/code_336F0.c @@ -115,18 +115,18 @@ void func_802BA91C(Struct_core2_336F0 *arg0, s32 arg1){ } void func_802BA93C(Struct61s *file_ptr, Struct_core2_336F0 *arg1){ - while(!func_8034AF98(file_ptr, 0)){ - if(!func_8034B108(file_ptr, 1, arg1->unk0, 3)){ - if(func_8034AF98(file_ptr, 2)){ - func_8034AD20(file_ptr, &arg1->unkC); - func_8034AD20(file_ptr, &arg1->unk10); + 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); } - else if(func_8034AF98(file_ptr, 3)){ - func_8034AD20(file_ptr, &arg1->unk14); - func_8034AD20(file_ptr, &arg1->unk18); + else if(file_isNextByteExpected(file_ptr, 3)){ + file_getFloat(file_ptr, &arg1->unk14); + file_getFloat(file_ptr, &arg1->unk18); } - else if(!func_8034B108(file_ptr, 4, arg1->unk1C, 3)){ - func_8034B150(file_ptr, 5, &arg1->unk28); + else if(!file_getNFloats_ifExpected(file_ptr, 4, arg1->unk1C, 3)){ + file_getWord_ifExpected(file_ptr, 5, &arg1->unk28); } }//L802BAA0C } diff --git a/src/core2/code_33AB0.c b/src/core2/code_33AB0.c index 16840018..4e95af12 100644 --- a/src/core2/code_33AB0.c +++ b/src/core2/code_33AB0.c @@ -44,9 +44,9 @@ void func_802BAB1C(Struct_core2_33AB0_0 *this, f32 src[3]){ } void func_802BAB3C(Struct61s *file_ptr, Struct_core2_33AB0_0 *arg1){ - while(!func_8034AF98(file_ptr, 0)){ - if(!func_8034B108(file_ptr, 1, arg1->unk0, 3)){ - func_8034B108(file_ptr, 2, arg1->unkC, 3); + while(!file_isNextByteExpected(file_ptr, 0)){ + if(!file_getNFloats_ifExpected(file_ptr, 1, arg1->unk0, 3)){ + file_getNFloats_ifExpected(file_ptr, 2, arg1->unkC, 3); }//L802BAA0C } } diff --git a/src/core2/code_33D40.c b/src/core2/code_33D40.c index 073d6ae2..2c7465e4 100644 --- a/src/core2/code_33D40.c +++ b/src/core2/code_33D40.c @@ -35,17 +35,17 @@ void func_802BADAC(void){ func_8024CE18(D_8037D830); } -void func_802BADDC(s32 arg0){ +void func_802BADDC(s32 camera_node_index){ UNK_TYPE(s32) sp1C; - sp1C = func_802B9E70(arg0); + sp1C = func_802B9E70(camera_node_index); func_802BAAA8(sp1C, D_8037D820); func_802BAAF4(sp1C, D_8037D830); } -void set_camera_to_node(s32 arg0){ +void set_camera_to_node(s32 camera_node_index){ func_802BBC58(3); - func_802BADDC(arg0); + func_802BADDC(camera_node_index); } void func_802BAE4C(void){ diff --git a/src/core2/code_5C870.c b/src/core2/code_5C870.c index b7538321..2d34ef8b 100644 --- a/src/core2/code_5C870.c +++ b/src/core2/code_5C870.c @@ -587,7 +587,7 @@ s32 game_defrag(void){ glspline_defrag(); func_80288470(); func_802F1320(); - func_802BA128(); + ncCameraNodeList_defrag(); modelRender_defrag(); func_8028FB68(); partEmitMgr_defrag(); diff --git a/src/core2/code_6A4B0.c b/src/core2/code_6A4B0.c index 33cd497a..64599b98 100644 --- a/src/core2/code_6A4B0.c +++ b/src/core2/code_6A4B0.c @@ -27,41 +27,37 @@ Gfx D_803689D0[] = { gsSPEndDisplayList() }; - - - /* .code */ void func_802F1440(Struct_Core2_6A4B0_2 *arg0, Gfx **gfx, Mtx **mtx, Vtx **vtx) { - Vtx *sp9C; + Vtx *vtx_start; Vtx *i_vtx; s32 var_s3; s32 sp54; s32 sp50; s32 sp4C; - s16 *temp_v0_2; - static s32 D_80368A10[6] = {0x60, 0x840, 0x60, 0x840, 0x840, 0x60}; - static s32 D_80368A28[6] = {0x60, 0x60, 0x860, 0x60, 0x860, 0x860}; + static s32 s_values[6] = {0x60, 0x840, 0x60, 0x840, 0x840, 0x60}; + static s32 t_values[6] = {0x60, 0x60, 0x860, 0x60, 0x860, 0x860}; if (!arg0->unk10) { func_8024C7B8(gfx, mtx); } gSPDisplayList((*gfx)++, D_803689D0); - i_vtx = sp9C = *vtx; + i_vtx = vtx_start = *vtx; for(sp4C = 0; sp4C < 6; sp4C++){ for(sp50 = 0; sp50 < 9; sp50++){ for(sp54 = 0; sp54 < 2; sp54++){ for(var_s3 = 0; var_s3 < 3; var_s3++){ - temp_v0_2 = func_802F1804(arg0, sp50, sp4C, sp54, var_s3); - i_vtx->n.ob[0] = temp_v0_2[0]; - i_vtx->n.ob[1] = temp_v0_2[1]; - i_vtx->n.ob[2] = temp_v0_2[2]; + s16 *position = func_802F1804(arg0, sp50, sp4C, sp54, var_s3); + i_vtx->n.ob[0] = position[0]; + i_vtx->n.ob[1] = position[1]; + i_vtx->n.ob[2] = position[2]; i_vtx->n.flag = 0; - i_vtx->n.tc[0] = D_80368A10[sp54 * 3 + var_s3]; - i_vtx->n.tc[1] = D_80368A28[sp54 * 3 + var_s3]; + i_vtx->n.tc[0] = s_values[sp54 * 3 + var_s3]; + i_vtx->n.tc[1] = t_values[sp54 * 3 + var_s3]; i_vtx->n.n[0] = -1; i_vtx->n.n[1] = -1; i_vtx->n.n[2] = -1; @@ -72,13 +68,13 @@ void func_802F1440(Struct_Core2_6A4B0_2 *arg0, Gfx **gfx, Mtx **mtx, Vtx **vtx) } } *vtx = i_vtx; - i_vtx = sp9C; + i_vtx = vtx_start; var_s3 = 0; gSPVertex((*gfx)++, osVirtualToPhysical(i_vtx), 16, 0); for(sp4C = 0; sp4C < 6; sp4C++){ for(sp50 = 0; sp50 < 9; sp50++){ - s16 *temp_v0_2 = arg0->tmem_ptr + (0x20*sp50 + 1) + (0x20*sp4C + 0xC)*framebuffer_width; - gDPLoadTextureTile((*gfx)++, osVirtualToPhysical(temp_v0_2), G_IM_FMT_RGBA, G_IM_SIZ_16b, framebuffer_width, 0, 0, 0, 33, 33, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); + s16 *tmem = arg0->tmem_ptr + (0x20*sp50 + 1) + (0x20*sp4C + 0xC)*framebuffer_width; + gDPLoadTextureTile((*gfx)++, osVirtualToPhysical(tmem), G_IM_FMT_RGBA, G_IM_SIZ_16b, framebuffer_width, 0, 0, 0, 33, 33, 0, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMIRROR | G_TX_CLAMP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); for(sp54 = 0; sp54 < 2; sp54++){ gSP1Triangle((*gfx)++, var_s3, var_s3 + 1, var_s3 + 2, 0); var_s3 += 3; diff --git a/src/core2/code_7AF80.c b/src/core2/code_7AF80.c index 71703127..c457ad8d 100644 --- a/src/core2/code_7AF80.c +++ b/src/core2/code_7AF80.c @@ -878,10 +878,10 @@ void func_803045D8(void){} void func_803045E0(Cube *cube, Struct61s* file_ptr) { s32 sp2C[3]; - while(!func_8034AF98(file_ptr, 1)) { - if (func_8034B190(file_ptr, 0, sp2C, 3)) { - func_8034ADB4(file_ptr, sp2C, 3); - } else if (!func_8034B190(file_ptr, 2, &sp2C, 3) && func_8034AF98(file_ptr, 3) + while(!file_isNextByteExpected(file_ptr, 1)) { + if (file_getNWords_ifExpected(file_ptr, 0, sp2C, 3)) { + file_getNWords(file_ptr, sp2C, 3); + } else if (!file_getNWords_ifExpected(file_ptr, 2, &sp2C, 3) && file_isNextByteExpected(file_ptr, 3) ) { cube_fromFile(file_ptr, cube); } @@ -895,8 +895,8 @@ void cubeList_fromFile(Struct61s *file_ptr) { Cube *cube; //should be cube NodeProp *iPtr; - func_8034B190(file_ptr, 1, sp50, 3); - func_8034ADB4(file_ptr, sp44, 3); + file_getNWords_ifExpected(file_ptr, 1, sp50, 3); + file_getNWords(file_ptr, sp44, 3); for(sp5C[0] = sp50[0]; sp5C[0] <= sp44[0]; sp5C[0]++){ for(sp5C[1] = sp50[1]; sp5C[1] <= sp44[1]; sp5C[1]++){ for(sp5C[2] = sp50[2]; sp5C[2] <= sp44[2]; sp5C[2]++){ @@ -904,7 +904,7 @@ void cubeList_fromFile(Struct61s *file_ptr) { } } } - func_8034AF98(file_ptr, 0); + file_isNextByteExpected(file_ptr, 0); bitfield_setAll(D_8036A9E0, 0); for(sp5C[0] = sp50[0]; sp5C[0] <= sp44[0]; sp5C[0]++){ for(sp5C[1] = sp50[1]; sp5C[1] <= sp44[1]; sp5C[1]++){ diff --git a/src/core2/code_9BD0.c b/src/core2/code_9BD0.c index 69298234..5eef2d32 100644 --- a/src/core2/code_9BD0.c +++ b/src/core2/code_9BD0.c @@ -59,40 +59,40 @@ void func_80290BC0(s32 arg0){ } int func_80290D48(void){ - int sp2C; + int camera_node_index; s32 sp28; s32 sp24; s32 sp20; s32 sp1C; - sp2C = func_802903CC(); - if(sp2C == -1 || !func_802B9EA8(sp2C)){ + camera_node_index = func_802903CC(); + if(camera_node_index == -1 || !ncCameraNodeList_nodeIsValid(camera_node_index)){ func_80290BC0(0); return FALSE; } sp1C = bs_getState(); - switch(func_802B9E8C(sp2C)){ + switch(ncCameraNodeList_getNodeType(camera_node_index)){ case 4: - sp28 = func_802B9E34(sp2C); + sp28 = func_802B9E34(camera_node_index); sp24 = func_802BA234(sp28); func_80290BC0(sp24); return FALSE; case 3: //L80290DD8 - if(bsBeeFly_inSet(sp1C) && !func_802BA4D0(func_802B9E48(sp2C))){ + if(bsBeeFly_inSet(sp1C) && !func_802BA4D0(func_802B9E48(camera_node_index))){ return FALSE; } func_802BD0D8(0x11); - func_802BF798(sp2C); + func_802BF798(camera_node_index); func_80291488(0x9); return TRUE; case 1://L80290E28 - if(bsBeeFly_inSet(sp1C) && !func_802BA89C(func_802B9E5C(sp2C))){ + if(bsBeeFly_inSet(sp1C) && !func_802BA89C(func_802B9E5C(camera_node_index))){ return FALSE; } func_802BD0D8(0x8); - func_802BF9B8(sp2C); + func_802BF9B8(camera_node_index); func_80291488(0x9); return TRUE; default://L80290E7C diff --git a/src/core2/code_A5BC0.c b/src/core2/code_A5BC0.c index 8958d5c5..28124623 100644 --- a/src/core2/code_A5BC0.c +++ b/src/core2/code_A5BC0.c @@ -865,18 +865,18 @@ void cube_fromFile(Struct61s *file_ptr, Cube *cube) { s32 temp_v0_5; cube_free(cube); - if (func_8034B040(file_ptr, 0xA, &sp46)) { + if (file_getByte_ifExpected(file_ptr, 0xA, &sp46)) { func_8032E784(cube, sp46); cube->prop1Ptr = (NodeProp*) malloc(sp46 * sizeof(NodeProp)); temp_v0 = (NodeProp*) malloc(sp46 * sizeof(NodeProp)); - func_8034B080(file_ptr, 0xB, temp_v0, cube->prop1Cnt * sizeof(NodeProp)); + file_getNBytes_ifExpected(file_ptr, 0xB, temp_v0, cube->prop1Cnt * sizeof(NodeProp)); func_8032E7E8(temp_v0, cube, sp46); - } else if (func_8034B040(file_ptr, 6, &sp46)) { + } else if (file_getByte_ifExpected(file_ptr, 6, &sp46)) { func_8032E784(cube, sp46); cube->prop1Ptr = (OtherNode*) malloc(sp46 * sizeof(OtherNode)); temp_v0 = (OtherNode*) malloc(sp46 * sizeof(OtherNode)); - func_8034B080(file_ptr, 7, temp_v0, cube->prop1Cnt * sizeof(OtherNode)); + file_getNBytes_ifExpected(file_ptr, 7, temp_v0, cube->prop1Cnt * sizeof(OtherNode)); for(var_v1_3 = temp_v0; var_v1_3 < (OtherNode*)&temp_v0[sp46]; var_v1_3++){ if(var_v1_3->unk4_0 && !var_v1_3->unkC_0){ var_v1_3->unk4_17 = 0; @@ -886,7 +886,7 @@ void cube_fromFile(Struct61s *file_ptr, Cube *cube) { func_8032E7E8(temp_v0, cube, sp46); } - if (func_8034B040(file_ptr, 8, &sp47)) { + if (file_getByte_ifExpected(file_ptr, 8, &sp47)) { sp34 = func_803203FC(1) + func_803203FC(2) + func_803203FC(0x1F); if ((sp34) && gcparade_8031B4CC()) { @@ -897,7 +897,7 @@ void cube_fromFile(Struct61s *file_ptr, Cube *cube) { } cube->prop2Cnt = sp47; cube->prop2Ptr = (Prop *) malloc(sp47 * sizeof(Prop)); - func_8034B080(file_ptr, 9, cube->prop2Ptr, cube->prop2Cnt * sizeof(Prop)); + file_getNBytes_ifExpected(file_ptr, 9, cube->prop2Ptr, cube->prop2Cnt * sizeof(Prop)); for(var_v1_2 = cube->prop2Ptr; var_v1_2 < cube->prop2Ptr + sp47; var_v1_2++){ var_v1_2->unk8_4 = 1; if (var_v1_2->unk8_1) { diff --git a/src/core2/code_AC520.c b/src/core2/code_AC520.c index 46c5de67..ab77304a 100644 --- a/src/core2/code_AC520.c +++ b/src/core2/code_AC520.c @@ -190,11 +190,11 @@ void func_80333B78(Struct61s *file_ptr){ s32 sp38[3]; s32 indx; func_803335F4(); - while(!func_8034AF98(file_ptr, 0)){ - if( func_8034AF98(file_ptr, 1) - && func_8034B108(file_ptr, 2, sp4C, 3) - && func_8034B108(file_ptr, 3, sp44, 2) - && func_8034B190(file_ptr, 4, sp38, 3) + while(!file_isNextByteExpected(file_ptr, 0)){ + if( file_isNextByteExpected(file_ptr, 1) + && file_getNFloats_ifExpected(file_ptr, 2, sp4C, 3) + && file_getNFloats_ifExpected(file_ptr, 3, sp44, 2) + && file_getNWords_ifExpected(file_ptr, 4, sp38, 3) ){ indx = func_8033383C(); func_80333A94(indx, sp4C); @@ -211,14 +211,14 @@ s32 func_80333C78(s32 arg0){ for(iPtr = beginPtr; iPtr < endPtr; iPtr++){ if(iPtr->unk34){ - func_8034AF98(arg0, 1); - func_8034B108(arg0, 2, &iPtr->unk0, 3); - func_8034B108(arg0, 3, &iPtr->unk18, 2); - func_8034B190(arg0, 4, &iPtr->unk28, 3); + file_isNextByteExpected(arg0, 1); + file_getNFloats_ifExpected(arg0, 2, &iPtr->unk0, 3); + file_getNFloats_ifExpected(arg0, 3, &iPtr->unk18, 2); + file_getNWords_ifExpected(arg0, 4, &iPtr->unk28, 3); } } - return func_8034AF98(arg0, 0); + return file_isNextByteExpected(arg0, 0); } void func_80333D48(BKVertexList *arg0, f32 position[3], f32 rotation[3], f32 scale, f32 arg4[3], BKVertexList *arg5) { diff --git a/src/core2/code_AD5B0.c b/src/core2/code_AD5B0.c index 1caf8185..c2f2bd36 100644 --- a/src/core2/code_AD5B0.c +++ b/src/core2/code_AD5B0.c @@ -147,7 +147,7 @@ void func_80334910(void) { func_80287D70(); animcache_free(); func_802BC10C(); - func_802B9D80(); + ncCameraNodeList_free(); func_802F1388(); func_802F10A4(); partEmitMgr_free(); @@ -225,7 +225,7 @@ void func_80334B20(enum map_e arg0, s32 arg1, s32 arg2) { func_80287C58(); func_80344C50(); func_8033F9C0(); - func_802B9D40(); + ncCameraNodeList_init(); func_802BC044(); partEmitMgr_init(); func_802F1104(); @@ -386,18 +386,18 @@ void func_80335140(enum map_e map_id) { func_80254008(); fp = func_8034AB6C(map_id); //LevelSetupFile_Open - while (func_8034AF98(fp, 0) == 0) { - if (func_8034AF98(fp, 2)) { + while (file_isNextByteExpected(fp, 0) == 0) { + if (file_isNextByteExpected(fp, 2)) { - } else if (func_8034AF98(fp, 1)) { + } else if (file_isNextByteExpected(fp, 1)) { cubeList_fromFile(fp); - } else if (func_8034AF98(fp, 3)) { - func_802BA0AC(fp); - } else if (func_8034AF98(fp, 4)) { + } else if (file_isNextByteExpected(fp, 3)) { + ncCameraNodeList_fromFile(fp); + } else if (file_isNextByteExpected(fp, 4)) { func_80333B78(fp); } } - func_8034AAB0(fp); //file close + file_close(fp); //file close } void func_8033520C(s32 arg0){ diff --git a/src/core2/code_AEDA0.c b/src/core2/code_AEDA0.c index 7569b2b8..2681703a 100644 --- a/src/core2/code_AEDA0.c +++ b/src/core2/code_AEDA0.c @@ -244,9 +244,9 @@ void spriteRender_drawWithSegment(Gfx **gfx, Vtx **vtx, BKSprite *sprite, u32 fr pixel_size_nibbles = 1; } else if (sprite->type & SPRITE_TYPE_CI8) { pixel_size_nibbles = 2; - } else if (sprite->type & 0x40){ + } else if (sprite->type & SPRITE_TYPE_I8){ pixel_size_nibbles = 2; - } else if (sprite->type & 0x100){ + } else if (sprite->type & SPRITE_TYPE_IA8){ pixel_size_nibbles = 2; } else if (sprite->type & SPRITE_TYPE_RGBA16) { pixel_size_nibbles = 4; diff --git a/src/core2/code_C3B20.c b/src/core2/code_C3B20.c index 899139ae..7c853352 100644 --- a/src/core2/code_C3B20.c +++ b/src/core2/code_C3B20.c @@ -6,14 +6,14 @@ -void func_8034AE08(Struct61s *arg0, void *arg1, s32 arg2); +void __file_read(Struct61s *file, void *arg1, s32 arg2); /* .code */ -void func_8034AAB0(Struct61s * arg0){ - if(arg0->unk14 == 2){ - assetcache_release(arg0->unk0); +void file_close(Struct61s * file){ + if(file->unk14 == 2){ + assetcache_release(file->unk0); } - free(arg0); + free(file); } Struct61s *func_8034AAF4(enum asset_e asset_id) { @@ -70,192 +70,192 @@ Struct61s *func_8034AC04(void){ return this; } -void func_8034AC5C(Struct61s *arg0, void **arg1, s32 *size){ - *size = ((u32)arg0->unkC - (u32)arg0->unk8); - *arg1 = realloc(arg0->unk8, *size); - arg0->unk8 = NULL; - func_8034AAB0(arg0); +void file_realloc(Struct61s *file, void **arg1, s32 *size){ + *size = ((u32)file->unkC - (u32)file->unk8); + *arg1 = realloc(file->unk8, *size); + file->unk8 = NULL; + file_close(file); } -void func_8034ACAC(Struct61s *arg0, u8 *arg1){ - func_8034AE08(arg0, arg1, 1); +void file_getByte(Struct61s *file, u8 *arg1){ + __file_read(file, arg1, 1); } -void func_8034ACCC(Struct61s *arg0, u8 *arg1, s32 cnt){ +void file_getNBytes(Struct61s *file, u8 *arg1, s32 cnt){ while(cnt > 0){ - func_8034ACAC(arg0, arg1); + file_getByte(file, arg1); cnt--; arg1++; } } -void func_8034AD20(Struct61s *arg0, f32 *arg1){ - func_8034AE08(arg0, arg1, 4); +void file_getFloat(Struct61s *file, f32 *arg1){ + __file_read(file, arg1, 4); } -void func_8034AD40(Struct61s *arg0, f32 *arg1, s32 cnt){ +void file_getNFloat(Struct61s *file, f32 *arg1, s32 cnt){ while(cnt > 0){ - func_8034AD20(arg0, arg1); + file_getFloat(file, arg1); cnt--; arg1++; } } -void func_8034AD94(Struct61s *arg0, s32 *arg1){ - func_8034AE08(arg0, arg1, 4); +void file_getWord(Struct61s *file, s32 *arg1){ + __file_read(file, arg1, 4); } -void func_8034ADB4(Struct61s *arg0, s32 *arg1, s32 cnt){ +void file_getNWords(Struct61s *file, s32 *arg1, s32 cnt){ while(cnt > 0){ - func_8034AD94(arg0, arg1); + file_getWord(file, arg1); cnt--; arg1++; } } -void func_8034AE08(Struct61s *arg0, void *arg1, s32 arg2) { +void __file_read(Struct61s *file, void *dst, s32 len) { u32 curr_offset; u32 capacity; u32 end_ptr; u32 var_v0; - if (arg0->unk14 == 2) { //read asset - memcpy(arg1, arg0->unk4, arg2); - arg0->unk4 = (void *) ((u32)arg0->unk4 + arg2); + if (file->unk14 == 2) { //read asset + memcpy(dst, file->unk4, len); + file->unk4 = (void *) ((u32)file->unk4 + len); } - else if (arg0->unk14 == 3) { //read bin??? - memcpy(arg1, arg0->unkC, arg2); - arg0->unkC = (void *) ((u32)arg0->unkC + arg2); + else if (file->unk14 == 3) { //read bin??? + memcpy(dst, file->unkC, len); + file->unkC = (void *) ((u32)file->unkC + len); } - else if (arg0->unk14 == 4) { // write bin??? - if ((u8*)arg0->unk10 < (u8*)arg0->unkC + arg2) { - curr_offset = (u8*)arg0->unkC - (u8*)arg0->unk8; - capacity = ((u8*)arg0->unk10 - (u8*)arg0->unk8)*2; - while (((u8*)arg0->unk8 + capacity) < (u8*)arg0->unkC + arg2) { + else if (file->unk14 == 4) { // write bin??? + if ((u8*)file->unk10 < (u8*)file->unkC + len) { + curr_offset = (u8*)file->unkC - (u8*)file->unk8; + capacity = ((u8*)file->unk10 - (u8*)file->unk8)*2; + while (((u8*)file->unk8 + capacity) < (u8*)file->unkC + len) { capacity *= 2; } - var_v0 = realloc(arg0->unk8, capacity); - arg0->unk8 = var_v0; - arg0->unkC = var_v0 + curr_offset; - arg0->unk10 = var_v0 + capacity; + var_v0 = realloc(file->unk8, capacity); + file->unk8 = var_v0; + file->unkC = var_v0 + curr_offset; + file->unk10 = var_v0 + capacity; } - memcpy(arg0->unkC, arg1, arg2); - arg0->unkC = (u32)arg0->unkC + arg2; + memcpy(file->unkC, dst, len); + file->unkC = (u32)file->unkC + len; } } -void func_8034AF24(Struct61s *arg0, s16 *arg1){ - func_8034AE08(arg0, arg1, sizeof(s16)); +void file_getShort(Struct61s *file, s16 *arg1){ + __file_read(file, arg1, sizeof(s16)); } -void func_8034AF44(Struct61s *arg0, s16 *arg1, s32 cnt){ +void file_getNShorts(Struct61s *file, s16 *arg1, s32 cnt){ while(cnt > 0){ - func_8034AF24(arg0, arg1); + file_getShort(file, arg1); cnt--; arg1++; } } -bool func_8034AF98(Struct61s *arg0, s32 arg1) { +bool file_isNextByteExpected(Struct61s *file, s32 arg1) { u8 sp1F; sp1F = arg1; - if ((arg0->unk14 == 1) || (arg0->unk14 == 4)) { - func_8034ACAC(arg0, &sp1F); + if ((file->unk14 == 1) || (file->unk14 == 4)) { + file_getByte(file, &sp1F); return 1; } - if (arg0->unk7C == -1) { - func_8034ACAC(arg0, &sp1F); + if (file->unk7C == -1) { + file_getByte(file, &sp1F); if (arg1 == sp1F) { return 1; } - arg0->unk7C = sp1F; + file->unk7C = sp1F; return 0; } - if (arg1 == arg0->unk7C) { - arg0->unk7C = -1; + if (arg1 == file->unk7C) { + file->unk7C = -1; return 1; } return 0; } -bool func_8034B040(Struct61s * arg0, s32 arg1, u8 *arg2){ - if(!func_8034AF98(arg0, arg1)){ +bool file_getByte_ifExpected(Struct61s * file, s32 arg1, u8 *arg2){ + if(!file_isNextByteExpected(file, arg1)){ return FALSE; } else{ - func_8034ACAC(arg0, arg2); + file_getByte(file, arg2); return TRUE; } } -bool func_8034B080(Struct61s * arg0, s32 arg1, u8 *arg2, s32 arg3){ - if(!func_8034AF98(arg0, arg1)){ +bool file_getNBytes_ifExpected(Struct61s * file, s32 arg1, u8 *arg2, s32 n){ + if(!file_isNextByteExpected(file, arg1)){ return FALSE; } else{ - func_8034ACCC(arg0, arg2, arg3); + file_getNBytes(file, arg2, n); return TRUE; } } -bool func_8034B0C8(Struct61s * arg0, s32 arg1, f32 *arg2){ - if(!func_8034AF98(arg0, arg1)){ +bool file_getFloat_ifExpected(Struct61s * file, s32 arg1, f32 *arg2){ + if(!file_isNextByteExpected(file, arg1)){ return FALSE; } else{ - func_8034AD20(arg0, arg2); + file_getFloat(file, arg2); return TRUE; } } -bool func_8034B108(Struct61s * arg0, s32 arg1, f32 *arg2, s32 arg3){ - if(!func_8034AF98(arg0, arg1)){ +bool file_getNFloats_ifExpected(Struct61s * file, s32 arg1, f32 *arg2, s32 n){ + if(!file_isNextByteExpected(file, arg1)){ return FALSE; } else{ - func_8034AD40(arg0, arg2, arg3); + file_getNFloat(file, arg2, n); return TRUE; } } -bool func_8034B150(Struct61s * arg0, s32 arg1, s32 *arg2){ - if(!func_8034AF98(arg0, arg1)){ +bool file_getWord_ifExpected(Struct61s * file, s32 arg1, s32 *arg2){ + if(!file_isNextByteExpected(file, arg1)){ return FALSE; } else{ - func_8034AD94(arg0, arg2); + file_getWord(file, arg2); return TRUE; } } -bool func_8034B190(Struct61s * arg0, s32 arg1, s32 *arg2, s32 arg3){ - if(!func_8034AF98(arg0, arg1)){ +bool file_getNWords_ifExpected(Struct61s * file, s32 arg1, s32 *arg2, s32 n){ + if(!file_isNextByteExpected(file, arg1)){ return FALSE; } else{ - func_8034ADB4(arg0, arg2, arg3); + file_getNWords(file, arg2, n); return TRUE; } } -bool func_8034B1D8(Struct61s * arg0, s32 arg1, void *arg2, s32 arg3){ - if(!func_8034AF98(arg0, arg1)){ +bool file_get_ifExpected(Struct61s * file, s32 arg1, void *dst, s32 size){ + if(!file_isNextByteExpected(file, arg1)){ return FALSE; } else{ - func_8034AE08(arg0, arg2, arg3); + __file_read(file, dst, size); return TRUE; } } -bool func_8034B220(Struct61s * arg0, s32 arg1, s16 *arg2){ - if(!func_8034AF98(arg0, arg1)){ +bool file_getShort_ifExpected(Struct61s * file, s32 expected, s16 *dst){ + if(!file_isNextByteExpected(file, expected)){ return FALSE; } else{ - func_8034AF24(arg0, arg2); + file_getShort(file, dst); return TRUE; } } -bool func_8034B260(Struct61s * arg0, s32 arg1, s16 *arg2, s32 arg3){ - if(!func_8034AF98(arg0, arg1)){ +bool file_getNShorts_ifExpected(Struct61s * file, s32 expected, s16 *dst, s32 n){ + if(!file_isNextByteExpected(file, expected)){ return FALSE; } else{ - func_8034AF44(arg0, arg2, arg3); + file_getNShorts(file, dst, n); return TRUE; } } diff --git a/src/core2/modelRender.c b/src/core2/modelRender.c index 5e0a471c..b28dd5d2 100644 --- a/src/core2/modelRender.c +++ b/src/core2/modelRender.c @@ -1423,11 +1423,17 @@ void func_8033A298(bool arg0){ } } +/* moderRender_preDraw() sets a generic 1 argument function that will + * be called immediately prior to the model being drawn + */ void modelRender_preDraw(GenMethod_1 func, s32 arg){ modelRenderCallback.pre_method = func; modelRenderCallback.pre_arg = arg; } +/* moderRender_postDraw() sets a generic 1 argument function that will + * be called immediately after to the model has been drawn + */ void modelRender_postDraw(GenMethod_1 func, s32 arg){ modelRenderCallback.post_method = func; modelRenderCallback.post_arg = arg; diff --git a/src/core2/nc/cameranodelist.c b/src/core2/nc/cameranodelist.c new file mode 100644 index 00000000..1041f01a --- /dev/null +++ b/src/core2/nc/cameranodelist.c @@ -0,0 +1,180 @@ +#include +#include "functions.h" +#include "variables.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); + +/* .bss */ +Struct_Core2_32DB0_0s ncCameraNodeList[NC_CAMERA_NODE_LIST_CAPACITY]; + +/* .code */ +void ncCameraNodeList_init(void){ + int i; + for(i = 0; i< NC_CAMERA_NODE_LIST_CAPACITY; i++){ + ncCameraNodeList[i].valid = FALSE; + } +} + +void ncCameraNodeList_free(void){ + int 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; + +} + +void __ncCameraNodeList_removeNode(s32 camera_node_index){ + func_802B9EBC(camera_node_index, 0); + ncCameraNodeList[camera_node_index].valid = 0; +} + +//ncCameraNodeList_getdata_ptr_type4 +s32 func_802B9E34(s32 camera_node_index){ + return ncCameraNodeList[camera_node_index].data_ptr; +} + +//ncCameraNodeList_getdata_ptr_type3 +s32 func_802B9E48(s32 camera_node_index){ + return ncCameraNodeList[camera_node_index].data_ptr; +} + +//ncCameraNodeList_getdata_ptr_type1 +s32 func_802B9E5C(s32 camera_node_index){ + return ncCameraNodeList[camera_node_index].data_ptr; +} + +//ncCameraNodeList_getdata_ptr_type2 +s32 func_802B9E70(s32 camera_node_index){ + return ncCameraNodeList[camera_node_index].data_ptr; +} + +s32 ncCameraNodeList_capacity(void){ + return NC_CAMERA_NODE_LIST_CAPACITY; +} + +s32 ncCameraNodeList_getNodeType(s32 camera_node_index){ + return ncCameraNodeList[camera_node_index].type; +} + +s32 ncCameraNodeList_nodeIsValid(s32 camera_node_index){ + return ncCameraNodeList[camera_node_index].valid; +} + +void func_802B9EBC(s32 camera_node_index, s32 arg1){ + if(arg1 == ncCameraNodeList[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); + break; + case 3:// L802B9F18 + func_802BA398(ncCameraNodeList[camera_node_index].data_ptr); + break; + case 1:// L802B9F28 + func_802BA76C(ncCameraNodeList[camera_node_index].data_ptr); + break; + case 2:// L802B9F38 + func_802BAA88(ncCameraNodeList[camera_node_index].data_ptr); + break; + case 0:// L802B9F40 + break; + } + ncCameraNodeList[camera_node_index].type = arg1; + + //init new camera node data_ptr + switch (arg1) + { + 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 = func_802BAA40(); + break; + case 0:// L802B9FBC + break; + } + +} + +void __ncCameraNodeList_nodeFromFile(Struct61s *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)); + break; + case 3:// L802BA04C + func_802BA550(file_ptr, func_802B9E48(arg1)); + break; + case 1:// L802BA068 + func_802BA93C(file_ptr, func_802B9E5C(arg1)); + break; + case 2:// L802BA084 + func_802BAB3C(file_ptr, func_802B9E70(arg1)); + break; + case 0:// L802BA098 + break; + } +} + +void ncCameraNodeList_fromFile(Struct61s *file_ptr){ + s16 sp26; + ncCameraNodeList_free(); + ncCameraNodeList_init(); + while(!file_isNextByteExpected(file_ptr, 0)){ + if(file_getShort_ifExpected(file_ptr, 1, &sp26)) + __ncCameraNodeList_nodeFromFile(file_ptr, sp26); + } + +} + +void ncCameraNodeList_defrag(void){ + 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); + break; + case 3:// L802BA18C + ncCameraNodeList[i].data_ptr = defrag(ncCameraNodeList[i].data_ptr); + break; + case 1:// L802BA19C + ncCameraNodeList[i].data_ptr = defrag(ncCameraNodeList[i].data_ptr); + break; + case 2:// L802BA1AC + ncCameraNodeList[i].data_ptr = defrag(ncCameraNodeList[i].data_ptr); + break; + case 0:// L802BA1B8 + break; + } + } + } +} +