From 14edee83be689bf0cbde70d1718b31e2b6119bdc Mon Sep 17 00:00:00 2001 From: Banjo Kazooie Date: Mon, 7 Nov 2022 15:46:41 -0600 Subject: [PATCH] core1/code_13680.c done --- README.md | 2 +- progress/progress_core1.svg | 6 +-- progress/progress_total.svg | 4 +- src/core1/code_13680.c | 16 +++----- src/core1/code_7F60.c | 82 ++++++++++++++++++++----------------- subyaml/core1.us.v10.yaml | 2 +- 6 files changed, 58 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 7da0ccf0..a5e9f92c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# banjo (93.0880%) +# banjo (93.1411%) diff --git a/progress/progress_core1.svg b/progress/progress_core1.svg index 978a524a..fb0890ba 100644 --- a/progress/progress_core1.svg +++ b/progress/progress_core1.svg @@ -9,7 +9,7 @@ - + @@ -17,7 +17,7 @@ core1 - 86.8247% - 86.8247% + 87.1908% + 87.1908% \ No newline at end of file diff --git a/progress/progress_total.svg b/progress/progress_total.svg index 4086d049..346b3d83 100644 --- a/progress/progress_total.svg +++ b/progress/progress_total.svg @@ -17,7 +17,7 @@ Banjo-Kazooie (us.v10) - 93.0880% - 93.0880% + 93.1411% + 93.1411% \ No newline at end of file diff --git a/src/core1/code_13680.c b/src/core1/code_13680.c index a381154d..020048e4 100644 --- a/src/core1/code_13680.c +++ b/src/core1/code_13680.c @@ -23,13 +23,9 @@ s32 spriteGetFrameCount(BKSprite *this){ return this->frameCnt; } -#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_13680/spriteGetFramePtr.s") -// //NONMATCHING bad RegAlloc -/*BKSpriteFrame *spriteGetFramePtr(BKSprite *this, u32 frame){ - u32 f_data; - u32 *f_array = this + 1; - - - f_data = (u32)(f_array + this->frameCnt) + f_array[frame]; - return f_data; -}//*/ \ No newline at end of file +BKSpriteFrame *spriteGetFramePtr(BKSprite *this, u32 frame) +{ + BKSpriteFrame * new_var; + new_var = this->offsets[frame] + ((s32) ((*this).offsets + this->frameCnt)); + return new_var; +} diff --git a/src/core1/code_7F60.c b/src/core1/code_7F60.c index 1ea93121..fde6cb71 100644 --- a/src/core1/code_7F60.c +++ b/src/core1/code_7F60.c @@ -86,49 +86,57 @@ void func_80245F34(f32 *arg0, f32 *arg1, f32 *arg2) { *arg2 *= inv_len; } -#ifndef NONMATCHING -void func_80245FB8(f32 mf[4][4], u16 *perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale); -#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_7F60/func_80245FB8.s") -#else void func_80245FB8(float mf[4][4], u16 *perspNorm, float fovy, float aspect, float near, float far, float scale) { - float cot; - f32 tmp; - int i, j; - - near = (near < 1) ? 1 : near; - far = (far < near + 100) ? near + 100 : far; - tmp = ((2 * near * far) / (near - far)); - if( ( tmp*scale > 32767) || (tmp*scale < -32767)) { - tmp = ((tmp*scale > 32767) ? 32767.0f : -32767.0f); - near = (-(tmp/scale) * far) / ((2 * far) - (tmp/scale)); + float cot; + float tmp; + int i; + int j; + near = (near < 1.0f) ? (1.0f) : (near); + far = (far < (near + 100.0f)) ? (near + 100.0f) : (far); + tmp = ((2 * near) * far) / (near - far); + if (((tmp * scale) > 32767) || ((tmp * scale) < (-32767))) + { + tmp = ((tmp * scale) > 32767) ? (32767) : (-32767); + near = ((-(tmp / scale)) * far) / ((2 * far) - (tmp / scale)); + } + guMtxIdentF(mf); + fovy *= BAD_DTOR; + cot = cosf(fovy / 2) / sinf(fovy / 2); + mf[0][0] = cot / aspect; + mf[1][1] = cot; + mf[2][2] = (near + far) / (near - far); + mf[2][3] = -1; + if (!far) + { + } + mf[3][2] = ((2 * near) * far) / (near - far); + mf[3][3] = 0; + for (i = 0; i < 4; i++) + { + for (j = 0; j < 4; j++) + { + mf[i][j] *= scale; } - guMtxIdentF(mf); - fovy *= 3.1415926 / 180.0; - cot = cosf (fovy/2) / sinf (fovy/2); - mf[0][0] = cot / aspect; - mf[1][1] = cot; - mf[2][2] = (near + far) / (near - far); - mf[2][3] = -1; - mf[3][2] = ((2 * near * far) / (near - far)); - mf[3][3] = 0; + } - for (i=0; i<4; i++) - for (j=0; j<4; j++) - mf[i][j] *= scale; - - if (perspNorm != (u16 *) NULL) { - if ((near + far)<=2.0) { - *perspNorm = (u16) 0xFFFF; - } else { - *perspNorm = (u16) ((2.0*65536.0)/(near + far)); - if (*perspNorm<=0) - *perspNorm = (u16) 0x0001; - } - } + if (perspNorm != ((u16 *) 0)) + { + if ((near + far) <= 2.0) + { + *perspNorm = (u16) 0xFFFF; + } + else + { + *perspNorm = (u16) ((2.0 * 65536.0) / (near + far)); + if ((*perspNorm) <= 0) + { + *perspNorm = (u16) 0x0001; + } + } + } } -#endif void guPerspective(Mtx *m, u16 *perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale) { diff --git a/subyaml/core1.us.v10.yaml b/subyaml/core1.us.v10.yaml index edcb0c18..c650c264 100644 --- a/subyaml/core1.us.v10.yaml +++ b/subyaml/core1.us.v10.yaml @@ -52,7 +52,7 @@ segments: - [0x11AC0, c, code_11AC0] - [0x12F10, c, code_12F10] #DONE - [0x13640, c, code_13640] #DONE - - [0x13680, c, code_13680] + - [0x13680, c, code_13680] #DONE - [0x136D0, c, code_136D0] - [0x13990, c, code_13990] - [0x155F0, hasm, code_155F0] #DONE