Introduce better fix to fake 0.5 and 3.0 double constants
Uses a new rel_sqrt_consts.h file
This commit is contained in:
parent
fa82e1e788
commit
c2506716d2
14 changed files with 70 additions and 76 deletions
|
|
@ -8,10 +8,11 @@ Sections:
|
|||
|
||||
REL/board_executor.c:
|
||||
.text start:0x00000000 end:0x000000E0
|
||||
.rodata start:0x00000000 end:0x00000010
|
||||
|
||||
REL/w01Dll/main.c:
|
||||
.text start:0x000000E0 end:0x00009D00
|
||||
.rodata start:0x00000000 end:0x00000198
|
||||
.rodata start:0x00000010 end:0x00000198
|
||||
.data start:0x00000000 end:0x00000658
|
||||
.bss start:0x00000000 end:0x00000708
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@ Sections:
|
|||
|
||||
REL/board_executor.c:
|
||||
.text start:0x00000000 end:0x000000E0
|
||||
.rodata start:0x00000000 end:0x00000010
|
||||
|
||||
REL/w02Dll/main.c:
|
||||
.text start:0x000000E0 end:0x00001254
|
||||
.rodata start:0x00000000 end:0x00000038
|
||||
.rodata start:0x00000010 end:0x00000038
|
||||
.data start:0x00000000 end:0x000002A8
|
||||
.bss start:0x00000000 end:0x00000050
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@ Sections:
|
|||
|
||||
REL/board_executor.c:
|
||||
.text start:0x00000000 end:0x000000E0
|
||||
.rodata start:0x00000000 end:0x00000010
|
||||
|
||||
REL/w03Dll/main.c:
|
||||
.text start:0x000000E0 end:0x000012C8
|
||||
.rodata start:0x00000000 end:0x00000038
|
||||
.rodata start:0x00000010 end:0x00000038
|
||||
.data start:0x00000000 end:0x00000280
|
||||
.bss start:0x00000000 end:0x00000028
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@ Sections:
|
|||
|
||||
REL/board_executor.c:
|
||||
.text start:0x00000000 end:0x000000E0
|
||||
.rodata start:0x00000000 end:0x00000010
|
||||
|
||||
REL/w04Dll/main.c:
|
||||
.text start:0x000000E0 end:0x000012FC
|
||||
.rodata start:0x00000000 end:0x00000040
|
||||
.rodata start:0x00000010 end:0x00000040
|
||||
.data start:0x00000000 end:0x00000298
|
||||
.bss start:0x00000000 end:0x00000038
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@ Sections:
|
|||
|
||||
REL/board_executor.c:
|
||||
.text start:0x00000000 end:0x000000E0
|
||||
.rodata start:0x00000000 end:0x00000010
|
||||
|
||||
REL/w05Dll/main.c:
|
||||
.text start:0x000000E0 end:0x000013D4
|
||||
.rodata start:0x00000000 end:0x00000048
|
||||
.rodata start:0x00000010 end:0x00000048
|
||||
.data start:0x00000000 end:0x00000150
|
||||
.bss start:0x00000000 end:0x00000028
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@ Sections:
|
|||
|
||||
REL/board_executor.c:
|
||||
.text start:0x00000000 end:0x000000E0
|
||||
.rodata start:0x00000000 end:0x00000010
|
||||
|
||||
REL/w06Dll/main.c:
|
||||
.text start:0x000000E0 end:0x00000D70
|
||||
.rodata start:0x00000000 end:0x00000040
|
||||
.rodata start:0x00000010 end:0x00000040
|
||||
.data start:0x00000000 end:0x000001A8
|
||||
.bss start:0x00000000 end:0x00000018
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,11 @@ Sections:
|
|||
|
||||
REL/board_executor.c:
|
||||
.text start:0x00000000 end:0x000000E0
|
||||
.rodata start:0x00000000 end:0x00000010
|
||||
|
||||
REL/w10Dll/main.c:
|
||||
.text start:0x000000E0 end:0x00000AEC
|
||||
.rodata start:0x00000000 end:0x00000038
|
||||
.rodata start:0x00000010 end:0x00000038
|
||||
.data start:0x00000000 end:0x00000078
|
||||
.bss start:0x00000000 end:0x00000038
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,10 @@ Sections:
|
|||
|
||||
REL/board_executor.c:
|
||||
.text start:0x00000000 end:0x000000E0
|
||||
.rodata start:0x00000000 end:0x00000010
|
||||
|
||||
REL/w21Dll/main.c:
|
||||
.text start:0x000000E0 end:0x00000678
|
||||
.rodata start:0x00000000 end:0x00000030
|
||||
.rodata start:0x00000010 end:0x00000030
|
||||
.data start:0x00000000 end:0x00000034
|
||||
.bss start:0x00000000 end:0x0000000E
|
||||
|
|
|
|||
|
|
@ -7,8 +7,9 @@ Sections:
|
|||
|
||||
REL/board_executor.c:
|
||||
.text start:0x00000000 end:0x000000E0
|
||||
.rodata start:0x00000000 end:0x00000010
|
||||
|
||||
REL/w21Dll/main.c:
|
||||
.text start:0x000000E0 end:0x000003E0
|
||||
.rodata start:0x00000000 end:0x00000018
|
||||
.rodata start:0x00000010 end:0x00000018
|
||||
.data start:0x00000000 end:0x00000010
|
||||
|
|
|
|||
|
|
@ -7,24 +7,6 @@
|
|||
#define _MATH_INLINE static inline
|
||||
#endif
|
||||
|
||||
#ifdef MATH_EXPORT_CONST
|
||||
extern inline float sqrtf(float x)
|
||||
{
|
||||
static const double _half=.5;
|
||||
static const double _three=3.0;
|
||||
volatile float y;
|
||||
if(x > 0.0f)
|
||||
{
|
||||
double guess = __frsqrte((double)x); // returns an approximation to
|
||||
guess = _half*guess*(_three - guess*guess*x); // now have 12 sig bits
|
||||
guess = _half*guess*(_three - guess*guess*x); // now have 24 sig bits
|
||||
guess = _half*guess*(_three - guess*guess*x); // now have 32 sig bits
|
||||
y=(float)(x*guess);
|
||||
return y;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
#else
|
||||
extern inline float sqrtf(float x)
|
||||
{
|
||||
volatile float y;
|
||||
|
|
@ -39,7 +21,6 @@ extern inline float sqrtf(float x)
|
|||
}
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
|
||||
double atan(double x);
|
||||
double copysign(double x, double y);
|
||||
|
|
|
|||
8
include/rel_sqrt_consts.h
Normal file
8
include/rel_sqrt_consts.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef _REL_SQRT_CONSTS
|
||||
#define _REL_SQRT_CONSTS
|
||||
|
||||
const double __fakeHalf = 0.5;
|
||||
const double __fakeThree = 3.0;
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
#include "REL/board_executor.h"
|
||||
#include "rel_sqrt_consts.h"
|
||||
|
||||
static void InitBoard(void) {
|
||||
BoardCommonInit(BoardCreate, BoardDestroy);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include "game/thpmain.h"
|
||||
#include "game/msm.h"
|
||||
#include "math.h"
|
||||
#include "rel_sqrt_consts.h"
|
||||
|
||||
#define HU_PAD_BTN_ALL (HuPadBtn[0] | HuPadBtn[1] | HuPadBtn[2] | HuPadBtn[3])
|
||||
#define HU_PAD_BTNDOWN_ALL (HuPadBtnDown[0] | HuPadBtnDown[1] | HuPadBtnDown[2] | HuPadBtnDown[3])
|
||||
|
|
@ -387,22 +388,16 @@ void fn_1_1178(void)
|
|||
}
|
||||
|
||||
void fn_1_152C(void) {
|
||||
Point3d temp_f0;
|
||||
Point3d temp_f0_4;
|
||||
Point3d temp_f0_7;
|
||||
Point3d sp8;
|
||||
Vec pos;
|
||||
Vec offset;
|
||||
Vec dir;
|
||||
Vec y_offset;
|
||||
|
||||
f32 temp_f31;
|
||||
s32 var_r30;
|
||||
s8 temp_r31;
|
||||
f32 z_rot;
|
||||
s8 stick_pos;
|
||||
|
||||
if ((HuPadBtnDown[0] & 0x800)) {
|
||||
if (lbl_1_bss_0 != 0) {
|
||||
var_r30 = 0;
|
||||
} else {
|
||||
var_r30 = 1;
|
||||
}
|
||||
lbl_1_bss_0 = var_r30;
|
||||
lbl_1_bss_0 = (lbl_1_bss_0) ? 0 : 1;
|
||||
}
|
||||
if (lbl_1_bss_0 != 0) {
|
||||
lbl_1_bss_3C[0].y += 0.1f * HuPadStkX[0];
|
||||
|
|
@ -412,42 +407,42 @@ void fn_1_152C(void) {
|
|||
if (lbl_1_bss_1C[0] < 100.0f) {
|
||||
lbl_1_bss_1C[0] = 100.0f;
|
||||
}
|
||||
temp_f0.x = lbl_1_bss_24[0].x + (lbl_1_bss_1C[0] * (sin((M_PI * lbl_1_bss_3C[0].y) / 180.0) * cos((M_PI * lbl_1_bss_3C[0].x) / 180.0)));
|
||||
temp_f0.y = (lbl_1_bss_24[0].y + (lbl_1_bss_1C[0] * -sin((M_PI * lbl_1_bss_3C[0].x) / 180.0)));
|
||||
temp_f0.z = (lbl_1_bss_24[0].z + (lbl_1_bss_1C[0] * (cos((M_PI * lbl_1_bss_3C[0].y) / 180.0) * cos((M_PI * lbl_1_bss_3C[0].x) / 180.0))));
|
||||
temp_f0_4.x = lbl_1_bss_24[0].x - temp_f0.x;
|
||||
temp_f0_4.y = lbl_1_bss_24[0].y - temp_f0.y;
|
||||
temp_f0_4.z = lbl_1_bss_24[0].z - temp_f0.z;
|
||||
temp_f0_7.x = (sin((M_PI * lbl_1_bss_3C[0].y) / 180.0) * sin((M_PI * lbl_1_bss_3C[0].x) / 180.0));
|
||||
temp_f0_7.y = cos((M_PI * lbl_1_bss_3C[0].x) / 180.0);
|
||||
temp_f0_7.z = (cos((M_PI * lbl_1_bss_3C[0].y) / 180.0) * sin((M_PI * lbl_1_bss_3C[0].x) / 180.0));
|
||||
temp_f31 = lbl_1_bss_3C[0].z;
|
||||
sp8.x = temp_f0_7.x * (temp_f0_4.x * temp_f0_4.x + (1.0f - temp_f0_4.x * temp_f0_4.x) * cos((M_PI * temp_f31) / 180.0))
|
||||
+ temp_f0_7.y * (temp_f0_4.x * temp_f0_4.y * (1.0f - cos((M_PI * temp_f31) / 180.0)) - temp_f0_4.z * sin((M_PI * temp_f31) / 180.0))
|
||||
+ temp_f0_7.z * (temp_f0_4.x * temp_f0_4.z * (1.0f - cos((M_PI * temp_f31) / 180.0)) + temp_f0_4.y * sin((M_PI * temp_f31) / 180.0));
|
||||
pos.x = lbl_1_bss_24[0].x + (lbl_1_bss_1C[0] * (sin((M_PI * lbl_1_bss_3C[0].y) / 180.0) * cos((M_PI * lbl_1_bss_3C[0].x) / 180.0)));
|
||||
pos.y = (lbl_1_bss_24[0].y + (lbl_1_bss_1C[0] * -sin((M_PI * lbl_1_bss_3C[0].x) / 180.0)));
|
||||
pos.z = (lbl_1_bss_24[0].z + (lbl_1_bss_1C[0] * (cos((M_PI * lbl_1_bss_3C[0].y) / 180.0) * cos((M_PI * lbl_1_bss_3C[0].x) / 180.0))));
|
||||
offset.x = lbl_1_bss_24[0].x - pos.x;
|
||||
offset.y = lbl_1_bss_24[0].y - pos.y;
|
||||
offset.z = lbl_1_bss_24[0].z - pos.z;
|
||||
dir.x = (sin((M_PI * lbl_1_bss_3C[0].y) / 180.0) * sin((M_PI * lbl_1_bss_3C[0].x) / 180.0));
|
||||
dir.y = cos((M_PI * lbl_1_bss_3C[0].x) / 180.0);
|
||||
dir.z = (cos((M_PI * lbl_1_bss_3C[0].y) / 180.0) * sin((M_PI * lbl_1_bss_3C[0].x) / 180.0));
|
||||
z_rot = lbl_1_bss_3C[0].z;
|
||||
y_offset.x = dir.x * (offset.x * offset.x + (1.0f - offset.x * offset.x) * cos((M_PI * z_rot) / 180.0))
|
||||
+ dir.y * (offset.x * offset.y * (1.0f - cos((M_PI * z_rot) / 180.0)) - offset.z * sin((M_PI * z_rot) / 180.0))
|
||||
+ dir.z * (offset.x * offset.z * (1.0f - cos((M_PI * z_rot) / 180.0)) + offset.y * sin((M_PI * z_rot) / 180.0));
|
||||
|
||||
sp8.y = temp_f0_7.y * (temp_f0_4.y * temp_f0_4.y + (1.0f - temp_f0_4.y * temp_f0_4.y) * cos((M_PI * temp_f31) / 180.0))
|
||||
+ temp_f0_7.x * (temp_f0_4.x * temp_f0_4.y * (1.0f - cos((M_PI * temp_f31) / 180.0)) + temp_f0_4.z * sin((M_PI * temp_f31) / 180.0))
|
||||
+ temp_f0_7.z * (temp_f0_4.y * temp_f0_4.z * (1.0f - cos((M_PI * temp_f31) / 180.0)) - temp_f0_4.x * sin((M_PI * temp_f31) / 180.0));
|
||||
y_offset.y = dir.y * (offset.y * offset.y + (1.0f - offset.y * offset.y) * cos((M_PI * z_rot) / 180.0))
|
||||
+ dir.x * (offset.x * offset.y * (1.0f - cos((M_PI * z_rot) / 180.0)) + offset.z * sin((M_PI * z_rot) / 180.0))
|
||||
+ dir.z * (offset.y * offset.z * (1.0f - cos((M_PI * z_rot) / 180.0)) - offset.x * sin((M_PI * z_rot) / 180.0));
|
||||
|
||||
sp8.z = temp_f0_7.z * (temp_f0_4.z * temp_f0_4.z + (1.0f - temp_f0_4.z * temp_f0_4.z) * cos((M_PI * temp_f31) / 180.0))
|
||||
+ (temp_f0_7.x * (temp_f0_4.x * temp_f0_4.z * (1.0 - cos((M_PI * temp_f31) / 180.0)) - temp_f0_4.y * sin((M_PI * temp_f31) / 180.0))
|
||||
+ temp_f0_7.y * (temp_f0_4.y * temp_f0_4.z * (1.0 - cos((M_PI * temp_f31) / 180.0)) + temp_f0_4.x * sin((M_PI * temp_f31) / 180.0)));
|
||||
y_offset.z = dir.z * (offset.z * offset.z + (1.0f - offset.z * offset.z) * cos((M_PI * z_rot) / 180.0))
|
||||
+ (dir.x * (offset.x * offset.z * (1.0 - cos((M_PI * z_rot) / 180.0)) - offset.y * sin((M_PI * z_rot) / 180.0))
|
||||
+ dir.y * (offset.y * offset.z * (1.0 - cos((M_PI * z_rot) / 180.0)) + offset.x * sin((M_PI * z_rot) / 180.0)));
|
||||
|
||||
PSVECCrossProduct(&temp_f0_7, &temp_f0_4, &temp_f0_4);
|
||||
PSVECNormalize(&temp_f0_4, &temp_f0_4);
|
||||
temp_r31 = (HuPadSubStkX[0] & 0xF8);
|
||||
if (temp_r31 != 0) {
|
||||
lbl_1_bss_24[0].x += 0.05f * (temp_f0_4.x * temp_r31);
|
||||
lbl_1_bss_24[0].y += 0.05f * (temp_f0_4.y * temp_r31);
|
||||
lbl_1_bss_24[0].z += 0.05f * (temp_f0_4.z * temp_r31);
|
||||
PSVECCrossProduct(&dir, &offset, &offset);
|
||||
PSVECNormalize(&offset, &offset);
|
||||
stick_pos = (HuPadSubStkX[0] & 0xF8);
|
||||
if (stick_pos != 0) {
|
||||
lbl_1_bss_24[0].x += 0.05f * (offset.x * stick_pos);
|
||||
lbl_1_bss_24[0].y += 0.05f * (offset.y * stick_pos);
|
||||
lbl_1_bss_24[0].z += 0.05f * (offset.z * stick_pos);
|
||||
}
|
||||
PSVECNormalize(&sp8, &temp_f0_4);
|
||||
temp_r31 = -(HuPadSubStkY[0] & 0xF8);
|
||||
if (temp_r31 != 0) {
|
||||
lbl_1_bss_24[0].x += 0.05f * (temp_f0_4.x * temp_r31);
|
||||
lbl_1_bss_24[0].y += 0.05f * (temp_f0_4.y * temp_r31);
|
||||
lbl_1_bss_24[0].z += 0.05f * (temp_f0_4.z * temp_r31);
|
||||
PSVECNormalize(&y_offset, &offset);
|
||||
stick_pos = -(HuPadSubStkY[0] & 0xF8);
|
||||
if (stick_pos != 0) {
|
||||
lbl_1_bss_24[0].x += 0.05f * (offset.x * stick_pos);
|
||||
lbl_1_bss_24[0].y += 0.05f * (offset.y * stick_pos);
|
||||
lbl_1_bss_24[0].z += 0.05f * (offset.z * stick_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -496,13 +491,13 @@ static BOOL TitleProc(void)
|
|||
{
|
||||
float scale;
|
||||
float scale_time;
|
||||
s32 sp8[32];
|
||||
s32 y_offset[32];
|
||||
s16 i;
|
||||
Hu3DModelAttrReset(titleModel[0], 1);
|
||||
Hu3DModelAttrReset(titleModel[1], 1);
|
||||
HuSprAttrReset(titleGroup, 0, SPRITE_ATTR_HIDDEN);
|
||||
HuSprAttrReset(titleGroup, 1, SPRITE_ATTR_HIDDEN);
|
||||
OSReport(">>>>>>>>MSM_SE_SEL_01 %d\n", msmSeGetEntryID(2092, sp8));
|
||||
OSReport(">>>>>>>>MSM_SE_SEL_01 %d\n", msmSeGetEntryID(2092, y_offset));
|
||||
OSReport(">>>>>>>>SE Num %d\n", msmSeGetNumPlay(0));
|
||||
HuAudSStreamPlay(20);
|
||||
WipeCreate(WIPE_MODE_IN, WIPE_TYPE_NORMAL, 30);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "game/pad.h"
|
||||
#include "game/wipe.h"
|
||||
|
||||
#include "math.h"
|
||||
#include "rel_sqrt_consts.h"
|
||||
|
||||
static void SubchrMain(void);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue