Merge pull request #438 from gamemasterplc/main

Properly fix sqrtf constants
This commit is contained in:
Liam Coleman 2024-11-09 15:55:56 -06:00 committed by GitHub
commit afb776544c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 29 additions and 32 deletions

View file

@ -1089,7 +1089,7 @@ config.libs = [
"m435Dll", # Darts of Doom "m435Dll", # Darts of Doom
objects={ objects={
Object(NonMatching, "REL/m435Dll/main.c"), Object(NonMatching, "REL/m435Dll/main.c"),
Object(Matching, "REL/m435Dll/sequence.c"), Object(NonMatching, "REL/m435Dll/sequence.c"),
}, },
), ),
Rel( Rel(
@ -1103,7 +1103,7 @@ config.libs = [
"m437Dll", # Balloon of Doom "m437Dll", # Balloon of Doom
objects={ objects={
Object(NonMatching, "REL/m437Dll/main.c"), Object(NonMatching, "REL/m437Dll/main.c"),
Object(Matching, "REL/m437Dll/sequence.c"), Object(NonMatching, "REL/m437Dll/sequence.c"),
}, },
), ),
Rel( Rel(
@ -1230,7 +1230,7 @@ config.libs = [
"m456Dll", # Take a Breather "m456Dll", # Take a Breather
objects={ objects={
Object(NonMatching, "REL/m456Dll/main.c"), Object(NonMatching, "REL/m456Dll/main.c"),
Object(Matching, "REL/m456Dll/stage.c"), Object(NonMatching, "REL/m456Dll/stage.c"),
}, },
), ),
Rel( Rel(

View file

@ -10,17 +10,19 @@
#ifdef __MWERKS__ #ifdef __MWERKS__
extern inline float sqrtf(float x) extern inline float sqrtf(float x)
{ {
volatile float y; static const double _half = .5;
if(x > 0.0f) static const double _three = 3.0;
{ volatile float y;
double guess = __frsqrte((double)x); // returns an approximation to if (x > 0.0f)
guess = 0.5*guess*(3.0 - guess*guess*x); // now have 12 sig bits {
guess = 0.5*guess*(3.0 - guess*guess*x); // now have 24 sig bits double guess = __frsqrte((double)x); // returns an approximation to
guess = 0.5*guess*(3.0 - guess*guess*x); // now have 32 sig bits guess = _half*guess*(_three - guess*guess*x); // now have 12 sig bits
y=(float)(x*guess); guess = _half*guess*(_three - guess*guess*x); // now have 24 sig bits
return y; guess = _half*guess*(_three - guess*guess*x); // now have 32 sig bits
} y = (float)(x*guess);
return x; return y ;
}
return x;
} }
#else #else
float sqrtf(float x); float sqrtf(float x);

View file

@ -1,8 +1,5 @@
#ifndef _REL_SQRT_CONSTS #ifndef _REL_SQRT_CONSTS
#define _REL_SQRT_CONSTS #define _REL_SQRT_CONSTS
const double __fakeHalf = 0.5;
const double __fakeThree = 3.0;
#endif #endif

View file

@ -1,6 +1,6 @@
#include "REL/executor.h" #include "REL/executor.h"
#include "dolphin/os.h" #include "dolphin/os.h"
#include "rel_sqrt_consts.h" #include "math.h"
void ObjectSetup(void) { void ObjectSetup(void) {
OSReport("minigame dll setup\n"); OSReport("minigame dll setup\n");

View file

@ -1,5 +1,5 @@
#include "REL/board_executor.h" #include "REL/board_executor.h"
#include "rel_sqrt_consts.h" #include "math.h"
static void ObjectSetup(void) { static void ObjectSetup(void) {
BoardObjectSetup(BoardCreate, BoardDestroy); BoardObjectSetup(BoardCreate, BoardDestroy);

View file

@ -15,7 +15,6 @@
#include "game/wipe.h" #include "game/wipe.h"
#include "math.h" #include "math.h"
#include "rel_sqrt_consts.h"
#include "data_num/title.h" #include "data_num/title.h"

View file

@ -16,7 +16,7 @@
#include "game/wipe.h" #include "game/wipe.h"
#include "dolphin.h" #include "dolphin.h"
#include "rel_sqrt_consts.h" #include "math.h"
#include "string.h" #include "string.h"
typedef struct { typedef struct {

View file

@ -1,5 +1,5 @@
#include "REL/m446Dll.h" #include "REL/m446Dll.h"
#include "rel_sqrt_consts.h" #include "math.h"
#include "game/audio.h" #include "game/audio.h"
#include "game/frand.h" #include "game/frand.h"

View file

@ -11,7 +11,7 @@
#include "game/window.h" #include "game/window.h"
#include "game/wipe.h" #include "game/wipe.h"
#include "rel_sqrt_consts.h" #include "math.h"
typedef struct { typedef struct {
/* 0x00 */ s16 unk00; /* 0x00 */ s16 unk00;

View file

@ -14,6 +14,7 @@
#include "math.h" #include "math.h"
#include "REL/modeltestDll.h" #include "REL/modeltestDll.h"
#include "math.h"
// -------------------------------------------------------------------------- // // -------------------------------------------------------------------------- //
@ -28,8 +29,6 @@ s32 lbl_1_data_0[8] = {
DATA_MAKE_NUM(DATADIR_MARIOMOT, 0x04), DATA_MAKE_NUM(DATADIR_MARIOMOT, 0x04),
}; };
const f64 unk_rodata_0 = 0.5;
const f64 unk_rodata_8 = 3.0;
omObjData *lbl_1_bss_9A4; omObjData *lbl_1_bss_9A4;
omObjData *lbl_1_bss_9A0; omObjData *lbl_1_bss_9A0;

View file

@ -8,7 +8,7 @@
#include "game/gamework_data.h" #include "game/gamework_data.h"
#include "game/flag.h" #include "game/flag.h"
#include "game/chrman.h" #include "game/chrman.h"
#include "rel_sqrt_consts.h" #include "math.h"
#include "REL/executor.h" #include "REL/executor.h"
#include "game/board/main.h" #include "game/board/main.h"

View file

@ -12,7 +12,7 @@
#include "game/sprite.h" #include "game/sprite.h"
#include "game/wipe.h" #include "game/wipe.h"
#include "rel_sqrt_consts.h" #include "math.h"
typedef struct { typedef struct {
/* 0x00 */ s16 id; /* 0x00 */ s16 id;

View file

@ -5,7 +5,7 @@
#include "game/pad.h" #include "game/pad.h"
#include "game/process.h" #include "game/process.h"
#include "game/wipe.h" #include "game/wipe.h"
#include "rel_sqrt_consts.h" #include "math.h"
#include "REL/present.h" #include "REL/present.h"

View file

@ -3,7 +3,7 @@
#include "game/gamework_data.h" #include "game/gamework_data.h"
#include "game/printfunc.h" #include "game/printfunc.h"
#include "game/pad.h" #include "game/pad.h"
#include "rel_sqrt_consts.h" #include "math.h"
s32 lbl_1_data_0 = 100; s32 lbl_1_data_0 = 100;
s32 lbl_1_bss_0[192]; s32 lbl_1_bss_0[192];

View file

@ -14,8 +14,8 @@
#include "game/pad.h" #include "game/pad.h"
#include "game/printfunc.h" #include "game/printfunc.h"
#include "game/wipe.h" #include "game/wipe.h"
#include "math.h"
#include "rel_sqrt_consts.h"
// MSM Definitions // MSM Definitions
static s8 *msmSeGetIndexPtr(s16 datano); static s8 *msmSeGetIndexPtr(s16 datano);

View file

@ -9,7 +9,7 @@
#include "game/window.h" #include "game/window.h"
#include "game/wipe.h" #include "game/wipe.h"
#include "rel_sqrt_consts.h" #include "math.h"
typedef struct StaffData { typedef struct StaffData {
/* 0x00 */ u32 unk_00; /* 0x00 */ u32 unk_00;

View file

@ -5,7 +5,7 @@
#include "game/pad.h" #include "game/pad.h"
#include "game/wipe.h" #include "game/wipe.h"
#include "rel_sqrt_consts.h" #include "math.h"
static void SubchrMain(void); static void SubchrMain(void);