diff --git a/README.md b/README.md
index aa4cbeb3..a1d19a39 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# banjo (90.8234%)
+# banjo (90.8926%)
diff --git a/include/2.0L/PR/gu.h b/include/2.0L/PR/gu.h
index aa83ba08..404088a8 100644
--- a/include/2.0L/PR/gu.h
+++ b/include/2.0L/PR/gu.h
@@ -37,7 +37,7 @@
#define FTOFIX32(x) (long)((x) * (float)0x00010000)
#define FIX32TOF(x) ((float)(x) * (1.0f / (float)0x00010000))
-#define FTOFRAC8(x) ((int) MIN(((x) * (128.0f)), 127.0f) & 0xff)
+#define FTOFRAC8(x) ((int) MIN(((x) * (128.0)), 127.0) & 0xff)
#define FILTER_WRAP 0
#define FILTER_CLAMP 1
diff --git a/progress/progress_core1.svg b/progress/progress_core1.svg
index 32a108e0..a58392ac 100644
--- a/progress/progress_core1.svg
+++ b/progress/progress_core1.svg
@@ -9,7 +9,7 @@
-
+
@@ -17,7 +17,7 @@
core1
- 82.6659%
- 82.6659%
+ 83.1424%
+ 83.1424%
\ No newline at end of file
diff --git a/progress/progress_total.svg b/progress/progress_total.svg
index 40eb9d39..228c61f1 100644
--- a/progress/progress_total.svg
+++ b/progress/progress_total.svg
@@ -17,7 +17,7 @@
Banjo-Kazooie (us.v10)
- 90.8234%
- 90.8234%
+ 90.8926%
+ 90.8926%
\ No newline at end of file
diff --git a/src/core1/code_0.c b/src/core1/code_0.c
index 4e719620..10555291 100644
--- a/src/core1/code_0.c
+++ b/src/core1/code_0.c
@@ -24,7 +24,7 @@ u64 D_8027BEF0;
extern u8 D_80286F90;
-extern u8 D_803A5D00[2][0x1ECC0];
+extern u16 D_803A5D00[2][0x1ECC0/2];
void func_8023DA20(s32 arg0){
bzero(&D_8027A130, &D_80286F90 - (u8*)&D_8027A130);
@@ -131,6 +131,7 @@ void func_8023DD0C(void){
s32 r;
s32 g;
s32 b;
+ u16 rgba;
if((func_8023DB5C() & 0x7f) == 0x11)
sns_write_payload_over_heap();
@@ -170,19 +171,20 @@ void func_8023DD0C(void){
|| !levelSpecificFlags_validateCRC1()
|| !func_80320240()
){
+ s32 offset;
//render weird CRC failure image
for(x= 0x1e; x< D_8027658C - 0x1e; x++){//L8023DEB4
+ g = x >> 3;
for(y = 0x14; y < 0xeb; y++){
b = ((func_8023DB5C() << 3) + y*y + x*x) >> 3;
- g = x >> 3;
r = y >> 3;
- *(u16*)&D_803A5D00[1][((D_80276588 - 0xff)/2 + y + x*D_80276588)*2] =
- *(u16*)&D_803A5D00[0][((D_80276588 - 0xff)/2 + y + x*D_80276588)*2] =
- _SHIFTL(b, 1, 5)
- | _SHIFTL(g, 6, 5)
- | _SHIFTL(r, 11, 5)
- | _SHIFTL(1, 0, 1 )
- ;
+ rgba = _SHIFTL(b, 1, 5);
+ rgba |= _SHIFTL(r, 11, 5 );
+ rgba |= _SHIFTL(g, 6, 5);
+ rgba |= _SHIFTL(1, 0, 1 );
+ offset = ((D_80276588 - 0xff)/2 + y + x*D_80276588);
+ D_803A5D00[0][offset] = rgba;
+ D_803A5D00[1][offset] = rgba;
}
}
}//L8023DF70
diff --git a/src/core1/code_31C0.c b/src/core1/code_31C0.c
index 5ed688c6..b39d114f 100644
--- a/src/core1/code_31C0.c
+++ b/src/core1/code_31C0.c
@@ -3,8 +3,6 @@
#include "variables.h"
-extern f64 D_80277640;
-
u8 D_8027EB10[0x200]; // Size based on the previous symbol's address
OSThread D_8027ED10;
@@ -27,97 +25,3 @@ void func_80240C30(void *arg)
osStartThread(func_8023E060());
while (1);
}
-
-static void _guMtxF2L(float mf[4][4], Mtx *m)
-{
- int i, j;
- int e1,e2;
- int *ai,*af;
-
-
- ai=(int *) &m->m[0][0];
- af=(int *) &m->m[2][0];
-
- for (i=0; i<4; i++)
- for (j=0; j<2; j++) {
- e1=FTOFIX32(mf[i][j*2]);
- e2=FTOFIX32(mf[i][j*2+1]);
- *(ai++) = ( e1 & 0xffff0000 ) | ((e2 >> 16)&0xffff);
- *(af++) = ((e1 << 16) & 0xffff0000) | (e2 & 0xffff);
- }
-}
-
-static void _guMtxIdentF(float mf[4][4])
-{
- int i, j;
-
- for (i=0; i<4; i++)
- for (j=0; j<4; j++)
- if (i == j) mf[i][j] = 1.0;
- else mf[i][j] = 0.0;
-}
-
-void guScaleF(float mf[4][4], float x, float y, float z)
-{
- _guMtxIdentF(mf);
-
- mf[0][0] = x;
- mf[1][1] = y;
- mf[2][2] = z;
- mf[3][3] = 1;
-}
-
-void func_80240E4C(f32 mf[4][4], LookAt *l, float xEye, float yEye, float zEye,
- float xAt, float yAt, float zAt,
- float xUp, float yUp, float zUp);
-#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_31C0/func_80240E4C.s")
-
-void func_8024128C (Mtx *m, LookAt *l, float xEye, float yEye, float zEye,
- float xAt, float yAt, float zAt,
- float xUp, float yUp, float zUp)
-{
- float mf[4][4];
-
- func_80240E4C(mf, l, xEye, yEye, zEye, xAt, yAt, zAt,
- xUp, yUp, zUp);
-
- guMtxF2L(mf, m);
-}
-
-void guScale(Mtx *m, float x, float y, float z)
-{
- float mf[4][4];
-
- guScaleF(mf, x, y, z);
- _guMtxF2L(mf, m);
-}
-
-void guRotateRPYF(f32 mf[4][4], f32 r, f32 p, f32 h) {
- static f32 dtor = 3.1415926 / 180.0;
- s32 pad;
- f32 sinp, sinh, sinr;
- f32 cosp, cosh, cosr;
-
- r *= dtor;
- p *= dtor;
- h *= dtor;
- sinr = sinf(r);
- cosr = cosf(r);
- sinp = sinf(p);
- cosp = cosf(p);
- sinh = sinf(h);
- cosh = cosf(h);
- guMtxIdentF(mf);
- mf[0][0] = cosp * cosh;
- mf[0][1] = cosp * sinh;
- mf[0][2] = -sinp;
-
- mf[1][0] = (sinr*sinp*cosh - cosr*sinh);
- mf[1][1] = (sinr*sinp*sinh + cosr*cosh);
- mf[1][2] = (sinr*cosp);
-
-
- mf[2][0] = (cosr*sinp*cosh + sinr*sinh);
- mf[2][1] = (cosr*sinp*sinh - sinr*cosh);
- mf[2][2] = (cosr*cosp);
-}
diff --git a/src/core1/code_3250.c b/src/core1/code_3250.c
new file mode 100644
index 00000000..c94acaa4
--- /dev/null
+++ b/src/core1/code_3250.c
@@ -0,0 +1,176 @@
+#include
+extern f32 gu_sqrtf(f32);
+
+static void _guMtxF2L(float mf[4][4], Mtx *m)
+{
+ int i, j;
+ int e1,e2;
+ int *ai,*af;
+
+
+ ai=(int *) &m->m[0][0];
+ af=(int *) &m->m[2][0];
+
+ for (i=0; i<4; i++)
+ for (j=0; j<2; j++) {
+ e1=FTOFIX32(mf[i][j*2]);
+ e2=FTOFIX32(mf[i][j*2+1]);
+ *(ai++) = ( e1 & 0xffff0000 ) | ((e2 >> 16)&0xffff);
+ *(af++) = ((e1 << 16) & 0xffff0000) | (e2 & 0xffff);
+ }
+}
+
+static void _guMtxIdentF(float mf[4][4])
+{
+ int i, j;
+
+ for (i=0; i<4; i++)
+ for (j=0; j<4; j++)
+ if (i == j) mf[i][j] = 1.0;
+ else mf[i][j] = 0.0;
+}
+
+void guScaleF(float mf[4][4], float x, float y, float z)
+{
+ _guMtxIdentF(mf);
+
+ mf[0][0] = x;
+ mf[1][1] = y;
+ mf[2][2] = z;
+ mf[3][3] = 1;
+}
+
+void guLookAtReflectF(float mf[4][4], LookAt *l,
+ float xEye, float yEye, float zEye,
+ float xAt, float yAt, float zAt,
+ float xUp, float yUp, float zUp)
+{
+ float len, xLook, yLook, zLook, xRight, yRight, zRight;
+
+ guMtxIdentF(mf);
+
+ xLook = xAt - xEye;
+ yLook = yAt - yEye;
+ zLook = zAt - zEye;
+
+ /* Negate because positive Z is behind us: */
+ len = -1.0 / gu_sqrtf (xLook*xLook + yLook*yLook + zLook*zLook);
+ xLook *= len;
+ yLook *= len;
+ zLook *= len;
+
+ /* Right = Up x Look */
+
+ xRight = yUp * zLook - zUp * yLook;
+ yRight = zUp * xLook - xUp * zLook;
+ zRight = xUp * yLook - yUp * xLook;
+ len = 1.0 / gu_sqrtf (xRight*xRight + yRight*yRight + zRight*zRight);
+ xRight *= len;
+ yRight *= len;
+ zRight *= len;
+
+ /* Up = Look x Right */
+
+ xUp = yLook * zRight - zLook * yRight;
+ yUp = zLook * xRight - xLook * zRight;
+ zUp = xLook * yRight - yLook * xRight;
+ len = 1.0 / gu_sqrtf (xUp*xUp + yUp*yUp + zUp*zUp);
+ xUp *= len;
+ yUp *= len;
+ zUp *= len;
+
+ /* reflectance vectors = Up and Right */
+
+ l->l[0].l.dir[0] = FTOFRAC8(xRight);
+ l->l[0].l.dir[1] = FTOFRAC8(yRight);
+ l->l[0].l.dir[2] = FTOFRAC8(zRight);
+ l->l[1].l.dir[0] = FTOFRAC8(xUp);
+ l->l[1].l.dir[1] = FTOFRAC8(yUp);
+ l->l[1].l.dir[2] = FTOFRAC8(zUp);
+ l->l[0].l.col[0] = 0x00;
+ l->l[0].l.col[1] = 0x00;
+ l->l[0].l.col[2] = 0x00;
+ l->l[0].l.pad1 = 0x00;
+ l->l[0].l.colc[0] = 0x00;
+ l->l[0].l.colc[1] = 0x00;
+ l->l[0].l.colc[2] = 0x00;
+ l->l[0].l.pad2 = 0x00;
+ l->l[1].l.col[0] = 0x00;
+ l->l[1].l.col[1] = 0x80;
+ l->l[1].l.col[2] = 0x00;
+ l->l[1].l.pad1 = 0x00;
+ l->l[1].l.colc[0] = 0x00;
+ l->l[1].l.colc[1] = 0x80;
+ l->l[1].l.colc[2] = 0x00;
+ l->l[1].l.pad2 = 0x00;
+
+ mf[0][0] = xRight;
+ mf[1][0] = yRight;
+ mf[2][0] = zRight;
+ mf[3][0] = -(xEye * xRight + yEye * yRight + zEye * zRight);
+
+ mf[0][1] = xUp;
+ mf[1][1] = yUp;
+ mf[2][1] = zUp;
+ mf[3][1] = -(xEye * xUp + yEye * yUp + zEye * zUp);
+
+ mf[0][2] = xLook;
+ mf[1][2] = yLook;
+ mf[2][2] = zLook;
+ mf[3][2] = -(xEye * xLook + yEye * yLook + zEye * zLook);
+
+ mf[0][3] = 0;
+ mf[1][3] = 0;
+ mf[2][3] = 0;
+ mf[3][3] = 1;
+}
+
+void guLookAtReflect (Mtx *m, LookAt *l, float xEye, float yEye, float zEye,
+ float xAt, float yAt, float zAt,
+ float xUp, float yUp, float zUp)
+{
+ float mf[4][4];
+
+ guLookAtReflectF(mf, l, xEye, yEye, zEye, xAt, yAt, zAt,
+ xUp, yUp, zUp);
+
+ guMtxF2L(mf, m);
+}
+
+void guScale(Mtx *m, float x, float y, float z)
+{
+ float mf[4][4];
+
+ guScaleF(mf, x, y, z);
+ _guMtxF2L(mf, m);
+}
+
+void guRotateRPYF(f32 mf[4][4], f32 r, f32 p, f32 h) {
+ static f32 dtor = 3.1415926 / 180.0;
+ s32 pad;
+ f32 sinp, sinh, sinr;
+ f32 cosp, cosh, cosr;
+
+ r *= dtor;
+ p *= dtor;
+ h *= dtor;
+ sinr = sinf(r);
+ cosr = cosf(r);
+ sinp = sinf(p);
+ cosp = cosf(p);
+ sinh = sinf(h);
+ cosh = cosf(h);
+ guMtxIdentF(mf);
+ mf[0][0] = cosp * cosh;
+ mf[0][1] = cosp * sinh;
+ mf[0][2] = -sinp;
+
+ mf[1][0] = (sinr*sinp*cosh - cosr*sinh);
+ mf[1][1] = (sinr*sinp*sinh + cosr*cosh);
+ mf[1][2] = (sinr*cosp);
+
+
+ mf[2][0] = (cosr*sinp*cosh + sinr*sinh);
+ mf[2][1] = (cosr*sinp*sinh - sinr*cosh);
+ mf[2][2] = (cosr*cosp);
+}
diff --git a/src/core1/code_9D30.c b/src/core1/code_9D30.c
index 921a09bf..aaaddad6 100644
--- a/src/core1/code_9D30.c
+++ b/src/core1/code_9D30.c
@@ -303,7 +303,62 @@ void draw_sprite_rgba16(s32 x, s32 y, BKSprite *sprite, s32 frame, bool alpha_en
}
}
+#ifndef NONMATCHING
#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_9D30/draw_sprite_i4.s")
+#else
+void draw_sprite_i4(s32 x, s32 y, BKSprite *sprite, s32 frame, bool aplha_enabled) {
+ BKSpriteFrame *frame_ptr;
+ BKSpriteTextureBlock *chunk_ptr;
+ s16 *temp_v0;
+ u8 *tmem;
+ s32 fb_x;
+ s32 fb_y;
+ s32 p1;
+ s32 p2;
+ u16 *framebuffer_ptr;
+ s32 txtr_y;
+ s32 i_chunk;
+ s32 txtr_x;
+ u16 *fb_pxl_ptr;
+
+ framebuffer_ptr = &D_803A5D00[D_802806EC][0];
+ frame_ptr = spriteGetFramePtr(sprite, frame);
+ if (!aplha_enabled) {
+ set_prim_color(0, 0, 0x80);
+ draw_prim_rect(x, y, frame_ptr->w, frame_ptr->h);
+ }
+ chunk_ptr = (BKSpriteTextureBlock *)(frame_ptr + 1);
+ for(i_chunk = 0; i_chunk < frame_ptr->chunkCnt; i_chunk++) {
+ for(tmem = (u8*)(chunk_ptr + 1); (s32)tmem % 8; tmem++);
+
+ for(txtr_y = 0; txtr_y < chunk_ptr->h; txtr_y++) {
+ for(txtr_x = 0; txtr_x < chunk_ptr->w; txtr_x += 2) {
+ fb_x = chunk_ptr->x + x + txtr_x;
+ if ((fb_x >= 0) && (fb_x < D_80276588)) {
+ fb_y = chunk_ptr->y + y + txtr_y;
+ if ((fb_y >= 0) && (fb_y < D_8027658C)) {
+ fb_pxl_ptr = framebuffer_ptr + fb_x + (fb_y * D_80276588);
+ p1 = (*tmem >> 4);
+ p2 = (*tmem & 0xF);
+ if (p1) {
+ *fb_pxl_ptr = (p1 << 0xC) | (p1 << 0x7) | (p1 << 0x2) | 1;
+ } else if (!aplha_enabled) {
+ *fb_pxl_ptr = 1;
+ }
+ if (p2) {
+ *(fb_pxl_ptr + 1) = (p2 << 0xC) | (p2 << 7) | (p2 << 2) | 1;
+ } else if (!aplha_enabled) {
+ *(fb_pxl_ptr + 1) = 1;
+ }
+ }
+ }
+ tmem++;
+ }
+ }
+ chunk_ptr = (BKSpriteTextureBlock *) tmem;
+ }
+}
+#endif
#ifndef NONMATCHING
#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_9D30/draw_sprite_ia4.s")
@@ -345,13 +400,13 @@ void draw_sprite_ia4(s32 x, s32 y, BKSprite *sprite, s32 frame, bool aplha_enabl
if ((fb_y >= 0) && (fb_y < D_8027658C)) {
fb_pxl_ptr = framebuffer_ptr + fb_x + (fb_y * D_80276588);
p1 = (*tmem >> 4);
- p2 = *tmem & 0xF;
+ p2 = (*tmem & 0xF);
p1_i = p1 & 0xE;
p1_a = p1 & 1;
p2_i = p2 & 0xE;
p2_a = p2 & 1;
- if (p1_a) {
- *fb_pxl_ptr = (p1_i << 0xC) | (p1_i << 7) | (p1_i << 2) | p1_a;
+ if (p1 & 1) {
+ *fb_pxl_ptr = (p1_i << 0xC) | (p1_i << 0x7) | (p1_i << 0x2) | (p1 & 1);
} else if (!aplha_enabled) {
*fb_pxl_ptr = 1;
}
diff --git a/src/core2/code_B1400.c b/src/core2/code_B1400.c
index 9889b056..47e05bc2 100644
--- a/src/core2/code_B1400.c
+++ b/src/core2/code_B1400.c
@@ -2,7 +2,6 @@
#include "functions.h"
#include "variables.h"
-extern void func_8024128C(Mtx *, s32, f32, f32, f32, f32, f32, f32, f32, f32, f32);
extern void func_802ED52C(s32, f32[3], f32);
extern void func_80252AF0(f32[3], f32[3], f32[3], f32, f32[3]);
extern void mlMtxRotate(f32, f32, f32);
@@ -973,7 +972,7 @@ int func_803391A4(Gfx **gfx, Mtx **mtx, f32 position[3], f32 arg3[3], f32 scale,
if(0.0f == spF4[2]){
spF4[2] = -0.1f;
}
- func_8024128C(*mtx, D_803837E0.unk400, D_803837E0.unk408[0], D_803837E0.unk408[1], D_803837E0.unk408[2], spF4[0], spF4[1], spF4[2], 0.0f, 1.0f, 0.0f);
+ guLookAtReflect(*mtx, D_803837E0.unk400, D_803837E0.unk408[0], D_803837E0.unk408[1], D_803837E0.unk408[2], spF4[0], spF4[1], spF4[2], 0.0f, 1.0f, 0.0f);
gSPLookAt((*gfx)++, D_803837E0.unk400);
osWritebackDCache(D_803837E0.unk400, sizeof(LookAt));
D_803837E0.unk400++;
diff --git a/subyaml/core1.us.v10.yaml b/subyaml/core1.us.v10.yaml
index ef23489e..2eda65a3 100644
--- a/subyaml/core1.us.v10.yaml
+++ b/subyaml/core1.us.v10.yaml
@@ -36,7 +36,8 @@ segments:
- [0x2BD0, c, code_2BD0]
- [0x2DA0, c, code_2DA0] #DONE
- [0x2FA0, c, code_2FA0] #DONE
- - [0x31C0, c, code_31C0]
+ - [0x31C0, c, code_31C0] #DONE
+ - [0x3250, c, code_3250] #DONE
- [0x3A70, c, code_3A70]
- [0x5650, c, code_5650]
- [0x7090, c, code_7090] #DONE
@@ -247,7 +248,7 @@ segments:
- [0x37D50, .data, code_1D00]
- [0x37E30, bin, data_37E30] #data Section
- [0x37E40, .data, code_2FA0]
- - [0x37E50, .data, code_31C0]
+ - [0x37E50, .data, code_3250]
- [0x37E60, .data, code_3A70]
- [0x37EA0, bin, data_37EA0] # .data, code_5650]
- [0x37EC0, bin, data_37EC0]
@@ -280,7 +281,7 @@ segments:
- [0x39B60, .data, done/io/vimodempallan1]
- [0x39B60, .data, done/io/vimodentsclan1]
- [0x39C00, bin, data_39C00] # .rodata, code_1D00]
- - [0x39C20, .rodata, code_31C0]
+ - [0x39C20, .rodata, code_3250]
- [0x39C30, bin, data_39C30] # .rodata, code_3A70]
- [0x39C40, .rodata, code_5650]
- [0x39CA0, .rodata, code_72B0]