diff --git a/include/functions.h b/include/functions.h
index 084a1ff6..ba251cef 100644
--- a/include/functions.h
+++ b/include/functions.h
@@ -50,6 +50,8 @@ typedef void (* GenMethod_5)(s32, s32, s32, s32, s32);
out##_z = a##_z op b##_z;\
}
+#define LENGTH_SQ_VEC3F(v) (v[0]*v[0] + v[1]*v[1] + v[2]*v[2])
+
//known it uses "+" instead of "|" for fight/code_9D40.c, func_8039049C, case 6
#define FUNC_8030E624(sfx_e, vol, sample_rate) func_8030E624(\
_SHIFTL((vol*1023), 21, 11) + _SHIFTL(sample_rate >> 5, 11, 10) + _SHIFTL(sfx_e, 0, 11)\
diff --git a/include/structs.h b/include/structs.h
index e52ccd88..1b7369a0 100644
--- a/include/structs.h
+++ b/include/structs.h
@@ -877,4 +877,21 @@ typedef struct {
struct actor_marker_s *unk18;
}Struct81s;
+typedef struct {
+ enum actor_e actor_id;
+ struct actor_marker_s *marker;
+ f32 position[3];
+ void (*unk14)(struct actor_s *, struct actor_marker_s *);
+ struct actor_marker_s *unk18;
+}Struct82s;
+
+typedef struct {
+ f32 unk0;
+ f32 unk4;
+ f32 unk8[3];
+ s16 unk14[3];
+ u8 unk1A;
+ u8 pad1B[1];
+}Struct83s;
+
#endif
diff --git a/progress/progress_core2.svg b/progress/progress_core2.svg
index 204ef315..de510048 100644
--- a/progress/progress_core2.svg
+++ b/progress/progress_core2.svg
@@ -9,7 +9,7 @@
-
+
@@ -17,7 +17,7 @@
core2
- 78.2801%
- 78.2801%
+ 78.4831%
+ 78.4831%
\ No newline at end of file
diff --git a/progress/progress_total.svg b/progress/progress_total.svg
index d32e0b46..6b2bf19f 100644
--- a/progress/progress_total.svg
+++ b/progress/progress_total.svg
@@ -17,7 +17,7 @@
Banjo-Kazooie (us.v10)
- 82.3300%
- 82.3300%
+ 82.4464%
+ 82.4464%
\ No newline at end of file
diff --git a/src/core2/code_B9090.c b/src/core2/code_B9090.c
index 16801325..2fa140bb 100644
--- a/src/core2/code_B9090.c
+++ b/src/core2/code_B9090.c
@@ -2,13 +2,142 @@
#include "functions.h"
#include "variables.h"
+#define ABS(s) (((s) >= 0) ? (s) : -(s))
-#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_B9090/func_80340020.s")
+extern void func_80252CC4(f32[3], f32[3], f32, f32[3]);
-#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_B9090/func_80340200.s")
+/* .code */
+bool func_80340020(Struct83s *self, f32 position[3], f32 arg2[3], f32 arg3, f32 *arg4, BKVertexList *arg5, f32 arg6[3], f32 arg7[3]) {
+ f32 sp6C[3];
+ f32 sp60[3];
+ s32 i;
+ s32 j;
+ f32 sp34[3][3];
+ Vtx *var_a0;
-#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_B9090/func_80340690.s")
+ if (!self->unk1A) {
+ return FALSE;
+ }
+
+ self->unk1A = FALSE;
+ if (0.1 < ml_vec3f_distance(arg6, self->unk8)) {
+ return FALSE;
+ }
+ for(i = 0; i < 3; i++){
+ var_a0 = arg5->vtx_18 + self->unk14[i];
+ for(j = 0; j < 3; j++){
+ sp34[i][j] = var_a0->v.ob[j];
+ }
+ }
+ sp6C[0] = sp34[1][0] - sp34[0][0];
+ sp6C[1] = sp34[1][1] - sp34[0][1];
+ sp6C[2] = sp34[1][2] - sp34[0][2];
+ sp60[0] = sp34[2][0] - sp34[0][0];
+ sp60[1] = sp34[2][1] - sp34[0][1];
+ sp60[2] = sp34[2][2] - sp34[0][2];
+ arg7[0] = sp34[0][0] + (self->unk0 * sp6C[0]) + (self->unk4*sp60[0]);
+ arg7[1] = sp34[0][1] + (self->unk0 * sp6C[1]) + (self->unk4*sp60[1]);
+ arg7[2] = sp34[0][2] + (self->unk0 * sp6C[2]) + (self->unk4*sp60[2]);
+ mlMtxIdent();
+ func_80252C08(position, arg2, arg3, arg4);
+ func_8025235C(arg7, arg7);
+ return TRUE;
+}
-#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_B9090/func_803406B0.s")
+void func_80340200(Struct83s *self, f32 position[3], f32 arg2[3], f32 arg3, f32 arg4[3], s16 arg5[3], BKVertexList *arg6, f32 arg7[3]) {
+ f32 spAC[3];
+ f32 spA0[3];
+ f32 sp94[3];
+ f32 sp88[3];
+ f32 sp7C[3];
+ s32 j;
+ s32 var_v0;
+ Vtx *var_a0;
+ s32 temp_hi;
+ s32 temp_hi_2;
+ s32 var_a0_2;
+ f32 sp58[3];
+ f32 sp34[3][3];
+ f32 temp_f0_3;
+ f32 var_f0;
+ f32 var_f12;
-#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_B9090/func_803406D4.s")
+ self->unk8[0] = arg7[0];
+ self->unk8[1] = arg7[1];
+ self->unk8[2] = arg7[2];
+ mlMtxIdent();
+ func_80252CC4(position, arg2, arg3, arg4);
+ func_8025235C(sp94, arg7);
+ for(j = 0; j < 3; j++){
+ self->unk14[j] = arg5[j];
+ }
+
+ for(j = 0; j < 3; j++){
+ var_a0 = arg6->vtx_18 + self->unk14[j];
+ for(var_v0 = 0; var_v0 < 3; var_v0++){
+ sp34[j][var_v0] = (f32)var_a0->v.ob[var_v0];
+ }
+ }
+ spAC[0] = sp34[1][0] - sp34[0][0];
+ spAC[1] = sp34[1][1] - sp34[0][1];
+ spAC[2] = sp34[1][2] - sp34[0][2];
+
+ spA0[0] = sp34[2][0] - sp34[0][0];
+ spA0[1] = sp34[2][1] - sp34[0][1];
+ spA0[2] = sp34[2][2] - sp34[0][2];
+
+ sp58[0] = (spAC[1] * spA0[2]) - (spAC[2] * spA0[1]);
+ sp58[1] = (spAC[2] * spA0[0]) - (spAC[0] * spA0[2]);
+ sp58[2] = (spAC[0] * spA0[1]) - (spAC[1] * spA0[0]);
+
+ if ((100000.0f < sp58[0]) || (100000.0f < sp58[1]) || (100000.0f < sp58[2])
+ || ((sp58[0] < -100000.0f)) || (sp58[1] < -100000.0f) || (sp58[2] < -100000.0f)
+ ) {
+ sp58[0] /= 100000.0f;
+ sp58[1] /= 100000.0f;
+ sp58[2] /= 100000.0f;
+ }
+ if (gu_sqrtf(LENGTH_SQ_VEC3F(sp58)) < 0.001) {
+ self->unk1A = 0;
+ return;
+ }
+
+ var_a0_2 = 1;
+
+ var_f12 = ABS(sp58[0]);
+ var_f0 = ABS(sp58[1]);
+ var_a0_2 = (var_f0 < var_f12) ? 0 : 1;
+
+ var_f12 = ABS(sp58[2]);
+ var_f0 = ABS(sp58[var_a0_2]);
+ var_a0_2 = (var_f0 < var_f12) ? 2 : var_a0_2;
+
+ temp_hi = (var_a0_2 + 1) % 3;
+ temp_hi_2 = (var_a0_2 + 2) % 3;
+ sp88[0] = sp94[temp_hi] - sp34[0][temp_hi];
+ sp88[1] = spAC[temp_hi];
+ sp88[2] = spA0[temp_hi];
+
+ sp7C[0] = sp94[temp_hi_2] - sp34[0][temp_hi_2];
+ sp7C[1] = spAC[temp_hi_2];
+ sp7C[2] = spA0[temp_hi_2];
+
+ temp_f0_3 = (sp88[1] * sp7C[2]) - (sp7C[1]*sp88[2]);
+ self->unk0 = ((sp88[0] * sp7C[2]) - (sp7C[0] * sp88[2])) / temp_f0_3;
+ self->unk4 = ((sp88[1] * sp7C[0]) - (sp7C[1] * sp88[0])) / temp_f0_3;
+ self->unk1A = 1;
+}
+
+void func_80340690(Struct83s *self){
+ free(self);
+}
+
+Struct83s * func_803406B0(void){
+ Struct83s *self = malloc(sizeof(Struct83s));
+ self->unk1A = 0;
+ return self;
+}
+
+Struct83s * func_803406D4(Struct83s *self){
+ return (Struct83s *)defrag(self);
+}
diff --git a/src/core2/code_B9770.c b/src/core2/code_B9770.c
index e00d4f45..d3fb812e 100644
--- a/src/core2/code_B9770.c
+++ b/src/core2/code_B9770.c
@@ -17,9 +17,12 @@ extern s32 D_80371E7C;
/* .bss */
s16 *D_803858A0;
-
-f32 func_80340700(f32, f32, f32);
-#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_B9770/func_80340700.s")
+/* .code */
+f32 func_80340700(f32 value, f32 min, f32 max) {
+ return (value < min) ? min
+ : (max < value) ? max
+ : value;
+}
bool func_80340748(s32 arg0, s32 arg1, s32 arg2, s32 arg3){
return FALSE;
diff --git a/subyaml/core2.us.v10.yaml b/subyaml/core2.us.v10.yaml
index 6455c524..96b34571 100644
--- a/subyaml/core2.us.v10.yaml
+++ b/subyaml/core2.us.v10.yaml
@@ -345,7 +345,7 @@ segments:
- [0xB8070, c, code_B8070] #DONE
- [0xB8080, c, code_B8080]
- [0xB8860, c, code_B8860] #DONE
- - [0xB9090, c, code_B9090]
+ - [0xB9090, c, code_B9090] #DONE
- [0xB9770, c, code_B9770]
- [0xBD100, c, code_BD100] #DONE
- [0xBDCC0, c, code_BDCC0] #DONE
@@ -768,7 +768,8 @@ segments:
- [0xF1FD0, .rodata, string]
- [0xF1FF0, bin, code_B6C60]
- [0xF2000, .rodata, code_B6CE0]
- - [0xF2030, bin, data_F2030]
+ - [0xF2030, .rodata, code_B9090]
+ - [0xF2060, bin, data_F2060]
- [0xF20F0, .rodata, code_BD100]
- [0xF2110, .rodata, code_BDCC0]
- [0xF2130, .rodata, code_BE2C0]
diff --git a/symbol_addrs.core2.us.v10.txt b/symbol_addrs.core2.us.v10.txt
index caba9e3a..85fcc87f 100644
--- a/symbol_addrs.core2.us.v10.txt
+++ b/symbol_addrs.core2.us.v10.txt
@@ -452,6 +452,8 @@ D_80378F48 = 0x80378F48;
D_80378F60 = 0x80378F60;
D_80378F64 = 0x80378F64;
D_80378F68 = 0x80378F68;
+D_80378FC8 = 0x80378FC8;
+D_80378FCC = 0x80378FCC;
D_80379080 = 0x80379080;
D_80379084 = 0x80379084;
D_80379088 = 0x80379088;