1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-06-07 17:11:50 +00:00

[iQue] Match libultra/gu (#2402)

* [iQue] Match libultra/gu

* Match sqrtf
This commit is contained in:
Tharo 2025-01-10 20:24:37 +00:00 committed by GitHub
parent 0f6c2f9e78
commit 62c0effccd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 28 deletions

View file

@ -1,7 +1,7 @@
#include "global.h" #include "global.h"
void guRotateF(f32 m[4][4], f32 a, f32 x, f32 y, f32 z) { void guRotateF(f32 m[4][4], f32 a, f32 x, f32 y, f32 z) {
static f32 D_80134D10 = M_PI / 180.0f; static f32 dtor = M_PI / 180.0f;
f32 sine; f32 sine;
f32 cosine; f32 cosine;
f32 ab; f32 ab;
@ -16,14 +16,15 @@ void guRotateF(f32 m[4][4], f32 a, f32 x, f32 y, f32 z) {
guNormalize(&x, &y, &z); guNormalize(&x, &y, &z);
a *= D_80134D10; a *= dtor;
sine = sinf(a); sine = sinf(a);
cosine = cosf(a); cosine = cosf(a);
ab = x * y * (1 - cosine); t = 1.0f - cosine;
bc = y * z * (1 - cosine); ab = x * y * t;
ca = z * x * (1 - cosine); bc = y * z * t;
ca = z * x * t;
guMtxIdentF(m); guMtxIdentF(m);
@ -38,15 +39,15 @@ void guRotateF(f32 m[4][4], f32 a, f32 x, f32 y, f32 z) {
#endif #endif
t = x * x; t = x * x;
m[0][0] = (1 - t) * cosine + t; m[0][0] = t + cosine * (1.0f - t);
m[2][1] = bc - xs; m[2][1] = bc - xs;
m[1][2] = bc + xs; m[1][2] = bc + xs;
t = y * y; t = y * y;
m[1][1] = (1 - t) * cosine + t; m[1][1] = t + cosine * (1.0f - t);
m[2][0] = ca + ys; m[2][0] = ca + ys;
m[0][2] = ca - ys; m[0][2] = ca - ys;
t = z * z; t = z * z;
m[2][2] = (1 - t) * cosine + t; m[2][2] = t + cosine * (1.0f - t);
m[1][0] = ab - zs; m[1][0] = ab - zs;
m[0][1] = ab + zs; m[0][1] = ab + zs;
} }

View file

@ -1,9 +0,0 @@
#include "global.h"
#ifndef __GNUC__
#define __builtin_sqrtf sqrtf
#endif
f32 sqrtf(f32 f) {
return __builtin_sqrtf(f);
}

9
src/libultra/gu/sqrtf.s Normal file
View file

@ -0,0 +1,9 @@
#include "ultra64/asm.h"
#include "ultra64/regdef.h"
.text
LEAF(sqrtf)
sqrt.s fv0, fa0
j ra
END(sqrtf)

View file

@ -1,25 +1,25 @@
#include "global.h" #include "global.h"
void guS2DInitBg(uObjBg* bg) { void guS2DInitBg(uObjBg* bg) {
u32 size; u16 tmem = (bg->b.imageFmt == G_IM_FMT_CI) ? 0x100 : 0x200;
s32 tmem = (bg->b.imageFmt == G_IM_FMT_CI) ? 0x100 : 0x200; u16 shift = 6 - bg->b.imageSiz;
u16 shift = (6 - bg->b.imageSiz); u32 tsize;
if (bg->b.imageLoad == G_BGLT_LOADBLOCK) { if (bg->b.imageLoad == G_BGLT_LOADBLOCK) {
bg->b.tmemW = bg->b.imageW >> shift; bg->b.tmemW = bg->b.imageW >> shift;
bg->b.tmemH = (tmem / bg->b.tmemW) * 4; bg->b.tmemH = (tmem / bg->b.tmemW) << 2;
bg->b.tmemSizeW = bg->b.tmemW * 2; bg->b.tmemSizeW = bg->b.tmemW << 1;
bg->b.tmemSize = bg->b.tmemH * bg->b.tmemSizeW; bg->b.tmemSize = bg->b.tmemH * bg->b.tmemSizeW;
bg->b.tmemLoadSH = (bg->b.tmemSize >> 1) - 1; bg->b.tmemLoadSH = (bg->b.tmemSize >> 1) - 1;
bg->b.tmemLoadTH = (0x7FF / bg->b.tmemW) + 1; bg->b.tmemLoadTH = GS_CALC_DXT(bg->b.tmemW);
} else { // G_BGLT_LOADTILE } else { // G_BGLT_LOADTILE
bg->b.tmemW = (bg->b.frameW >> shift) + 3; bg->b.tmemW = (bg->b.frameW >> shift) + 3;
bg->b.tmemH = (tmem / bg->b.tmemW) * 4; bg->b.tmemH = (tmem / bg->b.tmemW) << 2;
bg->b.tmemSizeW = (bg->b.imageW >> shift) * 2; bg->b.tmemSizeW = (bg->b.imageW >> shift) << 1;
size = bg->b.tmemH * bg->b.tmemSizeW; tsize = bg->b.tmemH * bg->b.tmemSizeW;
bg->b.tmemSize = (size >> 16); bg->b.tmemSize = tsize >> 16;
bg->b.tmemLoadSH = (size >> 0) & 0xFFFF; bg->b.tmemLoadSH = tsize & 0xFFFF;
bg->b.tmemLoadTH = bg->b.tmemH - 1; bg->b.tmemLoadTH = bg->b.tmemH - 1;
} }
} }