diff --git a/progress/progress_core2.svg b/progress/progress_core2.svg index b9156c87..7da36df2 100644 --- a/progress/progress_core2.svg +++ b/progress/progress_core2.svg @@ -17,7 +17,7 @@ core2 - 77.5826% - 77.5826% + 77.7638% + 77.7638% \ No newline at end of file diff --git a/progress/progress_total.svg b/progress/progress_total.svg index 567b518c..1eb624d9 100644 --- a/progress/progress_total.svg +++ b/progress/progress_total.svg @@ -9,7 +9,7 @@ - + @@ -17,7 +17,7 @@ Banjo-Kazooie (us.v10) - 81.9298% - 81.9298% + 82.0338% + 82.0338% \ No newline at end of file diff --git a/src/core2/code_BE2C0.c b/src/core2/code_BE2C0.c index 44ed94f5..66dbc5c6 100644 --- a/src/core2/code_BE2C0.c +++ b/src/core2/code_BE2C0.c @@ -3,6 +3,14 @@ #include "variables.h" +#define LENGTH_SQ_VEC4F(v) (v[0]*v[0] + v[1]*v[1] + v[2]*v[2] + v[3]*v[3]) +/* public */ + + +/* .data */ +extern s32 D_80371ED0[3]; + +/* .code */ #pragma GLOBAL_ASM("asm/nonmatchings/core2/code_BE2C0/func_80345250.s") #pragma GLOBAL_ASM("asm/nonmatchings/core2/code_BE2C0/func_80345274.s") @@ -11,15 +19,91 @@ #pragma GLOBAL_ASM("asm/nonmatchings/core2/code_BE2C0/func_803454D0.s") -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_BE2C0/func_80345630.s") +void func_80345630(f32 arg0[4]){ + arg0[0] = arg0[1] = arg0[2] = 0.0f; + arg0[3] = 1.0f; +} +void func_80345650(f32[4], f32[4], f32[4], f32); #pragma GLOBAL_ASM("asm/nonmatchings/core2/code_BE2C0/func_80345650.s") -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_BE2C0/func_803458E4.s") -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_BE2C0/func_80345A44.s") +void func_803458E4(f32 arg0[4], f32 arg1[4], f32 arg2[4], f32 arg3) { + f32 var_f0; + f32 var_f2; + f32 sp20[4]; + + sp20[0] = arg1[0]-arg2[0]; + sp20[1] = arg1[1]-arg2[1]; + sp20[2] = arg1[2]-arg2[2]; + sp20[3] = arg1[3]-arg2[3]; + var_f0 = LENGTH_SQ_VEC4F(sp20); + + sp20[0] = arg1[0]+arg2[0]; + sp20[1] = arg1[1]+arg2[1]; + sp20[2] = arg1[2]+arg2[2]; + sp20[3] = arg1[3]+arg2[3]; + var_f2 = LENGTH_SQ_VEC4F(sp20); + + if (var_f0 <= var_f2) { + func_80345650(arg0, arg1, arg2, arg3); + return; + } + sp20[0] = -arg2[0]; + sp20[1] = -arg2[1]; + sp20[2] = -arg2[2]; + sp20[3] = -arg2[3]; + func_80345650(arg0, arg1, sp20, arg3); + +} + + +void func_80345A44(f32 arg0[4], f32 arg1[4][4]) { + f32 temp_f0; + f32 temp_f2; + s32 temp_a0; + s32 temp_a2; + s32 var_a0; + + + temp_f0 = arg1[0][0] + arg1[1][1] + arg1[2][2]; + if (temp_f0 > 0.0) { + temp_f2 = gu_sqrtf(temp_f0 + 1.0); + arg0[3] = temp_f2 * 0.5; + temp_f2 = (0.5 / temp_f2); + arg0[0] = (arg1[1][2] - arg1[2][1]) * temp_f2; + arg0[1] = (arg1[2][0] - arg1[0][2]) * temp_f2; + arg0[2] = (arg1[0][1] - arg1[1][0]) * temp_f2; + } + else{ + var_a0 = 0; + if (arg1[var_a0][var_a0] < arg1[1][1]) { + var_a0 = 1; + } + if (arg1[var_a0][var_a0] < arg1[2][2]) { + var_a0 = 2; + } + temp_a0 = D_80371ED0[var_a0]; + temp_a2 = D_80371ED0[temp_a0]; + + temp_f2 = gu_sqrtf((arg1[var_a0][var_a0] - (arg1[temp_a0][temp_a0] + arg1[temp_a2][temp_a2])) + 1.0); + arg0[var_a0] = temp_f2 * 0.5; + temp_f2 = (0.5 / temp_f2); + arg0[3] = (arg1[temp_a0][temp_a2] - arg1[temp_a2][temp_a0]) * temp_f2; + arg0[temp_a0] = (arg1[var_a0][temp_a0] + arg1[temp_a0][var_a0]) * temp_f2; + arg0[temp_a2] = (arg1[var_a0][temp_a2] + arg1[temp_a2][var_a0]) * temp_f2; + } +} + + +void func_80345C78(s32 arg0, f32 arg1[3]) { + mlMtxIdent(); + mlMtxRotYaw(arg1[1]); + mlMtxRotPitch(arg1[0]); + mlMtxRotRoll(arg1[2]); + func_80345A44(arg0, func_80251488()); +} -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_BE2C0/func_80345C78.s") void func_80345CD4(f32 arg0[4], f32 arg1[4]){ mlMtxIdent(); @@ -29,4 +113,30 @@ void func_80345CD4(f32 arg0[4], f32 arg1[4]){ func_80345A44(arg0, func_80251488()); } -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_BE2C0/func_80345D30.s") +void func_80345D30(f32 arg0[4], f32 arg1[4], f32 arg2[4]) { + f32 sp1C[3]; + f32 sp10[3]; + f32 sp4[3]; + + arg0[3] = arg1[3]*arg2[3] - (arg1[0]*arg2[0] + arg1[1]*arg2[1] + arg1[2]*arg2[2]); + + sp10[0] = arg1[0] * arg2[3]; + sp10[1] = arg1[1] * arg2[3]; + sp10[2] = arg1[2] * arg2[3]; + + sp4[0] = arg2[0] * arg1[3]; + sp4[1] = arg2[1] * arg1[3]; + sp4[2] = arg2[2] * arg1[3]; + + sp1C[0] = (arg1[1] * arg2[2]) - (arg1[2]*arg2[1]); + sp1C[1] = (arg1[2] * arg2[0]) - (arg1[0]*arg2[2]); + sp1C[2] = (arg1[0] * arg2[1]) - (arg1[1]*arg2[0]); + + arg0[0] = sp10[0] + sp4[0]; + arg0[1] = sp10[1] + sp4[1]; + arg0[2] = sp10[2] + sp4[2]; + + arg0[0] = arg0[0] + sp1C[0]; + arg0[1] = arg0[1] + sp1C[1]; + arg0[2] = arg0[2] + sp1C[2]; +} diff --git a/src/core2/code_BEF20.c b/src/core2/code_BEF20.c index ca239ab9..a839511c 100644 --- a/src/core2/code_BEF20.c +++ b/src/core2/code_BEF20.c @@ -20,10 +20,6 @@ f32 D_80385FEC; u8 D_80385FF0[0xB]; f32 D_80386000[0xE]; //timescores s32 D_80386038; -u64 D_80386040; -u16 D_80386048[0xB]; //timescores_truncated -u8 D_80386060[5]; //saved item array -s32 D_80386068; void func_80345EB0(enum item_e item){ if(func_802FAFE8(item)){ @@ -61,7 +57,7 @@ s32 func_80345FB4(enum item_e item, s32 diff, s32 arg2){\ s32 sp30; s32 sp2C; s32 sp28; - s32 sp24; + s32 sp24; //without this var newVal is too high, but sp1C is correct s32 newVal; oldVal = D_80385F30[item]; @@ -82,7 +78,7 @@ s32 func_80345FB4(enum item_e item, s32 diff, s32 arg2){\ newVal = MAX(0, D_80385F30[item] + diff); D_80385F30[item] = newVal; - sp34 = (func_8031FF1C(BKPROG_B9_DOUBLE_HEALTH))? 2 : 1 ; + sp34 = ((func_8031FF1C(BKPROG_B9_DOUBLE_HEALTH))? 2 : 1); D_80385F30[ITEM_15_HEALTH_TOTAL] = MIN(sp34*8, D_80385F30[ITEM_15_HEALTH_TOTAL]); D_80385F30[ITEM_14_HEALTH]= MIN(D_80385F30[ITEM_15_HEALTH_TOTAL], D_80385F30[ITEM_14_HEALTH]); D_80385F30[ITEM_17_AIR] = MIN(3600, D_80385F30[ITEM_17_AIR]); @@ -106,7 +102,7 @@ s32 func_80345FB4(enum item_e item, s32 diff, s32 arg2){\ sp38 = 0; break; } - if(sp38){ + if(sp38 != 0){ D_80385F30[item] = MIN(sp38, D_80385F30[item]); } if(!arg2){ @@ -116,8 +112,8 @@ s32 func_80345FB4(enum item_e item, s32 diff, s32 arg2){\ } sp3C = item_empty(item); - if(item < 6 && sp3C) - D_80385F30[item + ITEM_6_HOURGLASS] = 0; + if(item < ITEM_6_HOURGLASS && sp3C) + D_80385F30[item + ITEM_6_HOURGLASS] = FALSE; switch(item){ case ITEM_14_HEALTH: @@ -136,7 +132,7 @@ s32 func_80345FB4(enum item_e item, s32 diff, s32 arg2){\ func_8025A6EC(SFX_AIR_METER_DROPPING, 28000); } else{ - func_8030E760(0x3e9, 1.2f, 28000); + func_8030E760(SFX_3E9_UNKNOWN, 1.2f, 28000); } } break; @@ -420,10 +416,8 @@ s32 itemscore_noteScores_get(enum level_e lvl_id){ return D_80385FF0[lvl_id]; } -#ifndef NONMATCHING -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_BEF20/func_80346F44.s") -#else void func_80346F44(s32 *size, void **ptr) { + static u64 D_80386040; s32 var_s0; *size = sizeof(u64); @@ -436,7 +430,6 @@ void func_80346F44(s32 *size, void **ptr) { } } } -#endif void itemscore_noteScoress_maxAll(void) { s32 i; @@ -469,6 +462,7 @@ u16 itemscore_timeScores_get(enum level_e level_id) { } void itemscore_timeScores_getSizeAndPtr(s32 *size, void **ptr) { + static u16 D_80386048[0xB]; //timescores_truncated s32 i; *size = 0xB*sizeof(s16); @@ -481,6 +475,8 @@ void itemscore_timeScores_getSizeAndPtr(s32 *size, void **ptr) { //itemscore_getSavedItemArray void func_80347630(s32 *size, u8 **buffer){ + static u8 D_80386060[5]; //saved item array + D_80386060[0] = item_getCount(ITEM_1C_MUMBO_TOKEN); D_80386060[1] = item_getCount(ITEM_D_EGGS); D_80386060[2] = item_getCount(ITEM_F_RED_FEATHER); @@ -581,6 +577,8 @@ void func_80347A70(void){ D_80386038 = 0; } +s32 D_80386068; + void func_80347A7C(void){ func_80320748(); D_80386068 = item_getCount(ITEM_16_LIFE);