Skip to content

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
ariahiro64 committed Sep 13, 2023
1 parent 397468f commit 5c7a4d1
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 5 deletions.
3 changes: 2 additions & 1 deletion include/config/config_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
// Disables AA (Improves console performance but causes visible seams between unconnected geometry).
//#define DISABLE_AA

// Use a folded polynomial instead of a lookup table. This has a speed boots and makes the calculation more precise.
// Use a folded polynomial instead of a lookup table. This has a speed boost and makes the calculation more precise.
// causes minor physics and camera inconsistancies
#define DISABLE_SIN_COS_LOOKUP_TABLE

// Fix annoying glitches (crashes and softlocks)
Expand Down
10 changes: 10 additions & 0 deletions src/code/sys_math.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "global.h"

#include "config.h"

f32 sFactorialTbl[] = { 1.0f, 1.0f, 2.0f, 6.0f, 24.0f, 120.0f, 720.0f,
5040.0f, 40320.0f, 362880.0f, 3628800.0f, 39916800.0f, 479001600.0f };

Expand Down Expand Up @@ -43,13 +45,21 @@ f32 Math_PowF(f32 base, s32 exp) {
* @return sin(angle)
*/
f32 Math_SinF(f32 angle) {
#ifdef DISABLE_SIN_COS_LOOKUP_TABLE
return (f32)(Math_SinS(RAD_TO_BINANG(angle)));
#else
return sins((s16)(angle * (0x7FFF / M_PI))) * SHT_MINV;
#endif
}

/**
* @param angle radians
* @return cos(angle)
*/
f32 Math_CosF(f32 angle) {
#ifdef DISABLE_SIN_COS_LOOKUP_TABLE
return (f32)(Math_CosS(RAD_TO_BINANG(angle)));
#else
return coss((s16)(angle * (0x7FFF / M_PI))) * SHT_MINV;
#endif
}
10 changes: 9 additions & 1 deletion src/libultra/gu/cosf.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include "ultra64.h"
#include "global.h"
#include "functions.h"

#include "config.h"

#ifndef DISABLE_SIN_COS_LOOKUP_TABLE
static const du P[] = {
{ 0x3FF00000, 0x00000000 }, { 0xBFC55554, 0xBC83656D }, { 0x3F8110ED, 0x3804C2A0 },
{ 0xBF29F6FF, 0xEEA56814 }, { 0x3EC5DBDF, 0x0E314BFE },
Expand All @@ -13,12 +17,15 @@ static const du pihi = { 0x400921FB, 0x50000000 };
static const du pilo = { 0x3E6110B4, 0x611A6263 };

static const fu zero = { 0x00000000 };

#endif
/**
* @param angle radians
* @return cos(angle)
*/
f32 cosf(f32 angle) {
#ifdef DISABLE_SIN_COS_LOOKUP_TABLE
return Math_CosF(angle);
#else
f32 absx;
f64 dx;
f64 xSq;
Expand Down Expand Up @@ -60,4 +67,5 @@ f32 cosf(f32 angle) {
}

return zero.f;
#endif
}
3 changes: 2 additions & 1 deletion src/libultra/gu/coss.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "global.h"
#include "functions.h"

#include "config.h"
/**
Expand All @@ -7,7 +8,7 @@
*/
s16 coss(u16 angle) {
#ifdef DISABLE_SIN_COS_LOOKUP_TABLE
return Math_CosS(angle) * 0x7FFF;
return Math_CosS(TRUNCF_BINANG((s16)angle))*0x7FFF;
#else
return sins(angle + 0x4000);
#endif
Expand Down
9 changes: 8 additions & 1 deletion src/libultra/gu/sinf.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "global.h"
#include "ultra64.h"
#include "functions.h"

#include "config.h"
#ifndef DISABLE_SIN_COS_LOOKUP_TABLE
static const du P[] = {
{ 0x3FF00000, 0x00000000 }, { 0xBFC55554, 0xBC83656D }, { 0x3F8110ED, 0x3804C2A0 },
{ 0xBF29F6FF, 0xEEA56814 }, { 0x3EC5DBDF, 0x0E314BFE },
Expand All @@ -13,12 +16,15 @@ static const du pihi = { 0x400921FB, 0x50000000 };
static const du pilo = { 0x3E6110B4, 0x611A6263 };

static const fu zero = { 0x00000000 };

#endif
/**
* @param angle radians
* @return sin(angle)
*/
f32 sinf(f32 angle) {
#ifdef DISABLE_SIN_COS_LOOKUP_TABLE
return Math_SinF(angle);
#else
f64 dx;
f64 xSq;
f64 polyApprox;
Expand Down Expand Up @@ -65,4 +71,5 @@ f32 sinf(f32 angle) {
return __libm_qnan_f;
}
return zero.f;
#endif
}
3 changes: 2 additions & 1 deletion src/libultra/gu/sins.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "ultra64.h"
#include "functions.h"

#include "config.h"
#ifndef DISABLE_SIN_COS_LOOKUP_TABLE
Expand All @@ -10,7 +11,7 @@
*/
s16 sins(u16 angle) {
#ifdef DISABLE_SIN_COS_LOOKUP_TABLE
return Math_SinS(angle) * 0x7FFF;
return Math_SinS(TRUNCF_BINANG((s16)angle))*0x7FFF;
#else
s16 value;

Expand Down

0 comments on commit 5c7a4d1

Please sign in to comment.