Merge pull request #58 from gamemasterplc/main

Finish matching hsfman.c
This commit is contained in:
gamemasterplc 2023-12-27 14:32:34 -06:00 committed by GitHub
commit 6ffbc782d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 11 deletions

View file

@ -174,19 +174,18 @@ cflags_runtime = [
cflags_rel = [ cflags_rel = [
*cflags_base, *cflags_base,
"-O0,p", "-O0,p",
"-enum int",
"-char unsigned", "-char unsigned",
"-fp_contract off", "-fp_contract off",
"-sdata 0", "-sdata 0",
"-sdata2 0", "-sdata2 0",
"-pool off", "-pool off",
"-DMATH_EXPORT_CONST",
] ]
# Game flags # Game flags
cflags_game = [ cflags_game = [
*cflags_base, *cflags_base,
"-O0,p", "-O0,p",
"-enum int",
"-char unsigned", "-char unsigned",
"-fp_contract off", "-fp_contract off",
] ]
@ -247,7 +246,7 @@ config.libs = [
Object(Matching, "game/sprput.c"), Object(Matching, "game/sprput.c"),
Object(Matching, "game/hsfload.c"), Object(Matching, "game/hsfload.c"),
Object(NonMatching, "game/hsfdraw.c"), Object(NonMatching, "game/hsfdraw.c"),
Object(NonMatching, "game/hsfman.c"), Object(Matching, "game/hsfman.c"),
Object(NonMatching, "game/hsfmotion.c"), Object(NonMatching, "game/hsfmotion.c"),
Object(NonMatching, "game/hsfanim.c"), Object(NonMatching, "game/hsfanim.c"),
Object(NonMatching, "game/hsfex.c"), Object(NonMatching, "game/hsfex.c"),

View file

@ -3,6 +3,7 @@
#define M_PI 3.141592653589793 #define M_PI 3.141592653589793
#ifdef MATH_EXPORT_CONST
extern inline float sqrtf(float x) extern inline float sqrtf(float x)
{ {
static const double _half=.5; static const double _half=.5;
@ -19,7 +20,22 @@ extern inline float sqrtf(float x)
} }
return x; return x;
} }
#else
extern inline float sqrtf(float x)
{
volatile float y;
if(x > 0.0f)
{
double guess = __frsqrte((double)x); // returns an approximation to
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
guess = 0.5*guess*(3.0 - guess*guess*x); // now have 32 sig bits
y=(float)(x*guess);
return y;
}
return x;
}
#endif
double atan(double x); double atan(double x);
double copysign(double x, double y); double copysign(double x, double y);
double cos(double x); double cos(double x);

View file

@ -325,7 +325,7 @@ s16 Hu3DModelCreate(void *arg0) {
} }
} }
if (var_r30 == 0x200) { if (var_r30 == 0x200) {
OSReport("Error: Not Found %s for MipMapSet\n"); OSReport("Error: Create Model Over!\n");
return -1; return -1;
} }
var_r31->hsfData = LoadHSF(arg0); var_r31->hsfData = LoadHSF(arg0);
@ -380,7 +380,7 @@ s16 Hu3DModelCreate(void *arg0) {
PSMTXIdentity(var_r31->unk_F0); PSMTXIdentity(var_r31->unk_F0);
layerNum[0] += 1; layerNum[0] += 1;
HuMemDCFlush(HEAP_DATA); HuMemDCFlush(HEAP_DATA);
if ((var_r31->hsfData->sceneCnt != 0) && ((var_r31->hsfData->scene->start != 0.0f) || (var_r31->hsfData->scene->end != 0.0f))) { if ((var_r31->hsfData->sceneCnt != 0) && ((var_r31->hsfData->scene->start) || (var_r31->hsfData->scene->end))) {
Hu3DFogSet(var_r31->hsfData->scene->start, var_r31->hsfData->scene->end, var_r31->hsfData->scene->color.r, var_r31->hsfData->scene->color.g, var_r31->hsfData->scene->color.b); Hu3DFogSet(var_r31->hsfData->scene->start, var_r31->hsfData->scene->end, var_r31->hsfData->scene->color.r, var_r31->hsfData->scene->color.g, var_r31->hsfData->scene->color.b);
} }
return var_r30; return var_r30;
@ -1569,8 +1569,7 @@ void Hu3DLLightColorSet(s16 dataIndex, s16 lightIndex, u8 r, u8 g, u8 b, u8 a) {
inline void Hu3DLightPosSetV(LightData *light, Vec* pos, Vec* aim) { inline void Hu3DLightPosSetV(LightData *light, Vec* pos, Vec* aim) {
light->unk_1C = *pos; light->unk_1C = *pos;
PSVECSubtract(aim, pos, &light->unk_28); PSVECNormalize(aim, &light->unk_28);
PSVECNormalize(&light->unk_28, &light->unk_28);
} }
void Hu3DGLightPosSetV(s16 index, Vec* pos, Vec* aim) { void Hu3DGLightPosSetV(s16 index, Vec* pos, Vec* aim) {
@ -1772,7 +1771,7 @@ s16 Hu3DLightSet(ModelData* arg0, Mtx *arg1, Mtx *arg2, f32 arg8) {
if (var_r29->unk_00 != -1) { if (var_r29->unk_00 != -1) {
lightSet(var_r29, var_r30, arg2, arg1, arg8); lightSet(var_r29, var_r30, arg2, arg1, arg8);
var_r28 |= var_r30; var_r28 |= var_r30;
var_r30 *= 2; var_r30 <<= 1;
} }
} }
if ((arg0->attr & 0x1000) != 0) { if ((arg0->attr & 0x1000) != 0) {
@ -1781,7 +1780,7 @@ s16 Hu3DLightSet(ModelData* arg0, Mtx *arg1, Mtx *arg2, f32 arg8) {
var_r29 = &Hu3DLocalLight[arg0->unk_38[i]]; var_r29 = &Hu3DLocalLight[arg0->unk_38[i]];
lightSet(var_r29, var_r30, arg2, arg1, arg8); lightSet(var_r29, var_r30, arg2, arg1, arg8);
var_r28 |= var_r30; var_r28 |= var_r30;
var_r30 *= 2; var_r30 <<= 1;
} }
} }
} }
@ -2038,7 +2037,7 @@ s16 Hu3DProjectionCreate(void *arg0, f32 arg8, f32 arg9, f32 argA) {
var_r31->unk_2C.x = -1.0f; var_r31->unk_2C.x = -1.0f;
var_r31->unk_2C.y = 1.0f; var_r31->unk_2C.y = 1.0f;
var_r31->unk_2C.z = 0.0f; var_r31->unk_2C.z = 0.0f;
C_MTXLightPerspective(var_r31->unk_68, arg8, 1.2f, 0.5f, 20.0f, 0.5f, 0.5f); C_MTXLightPerspective(var_r31->unk_68, arg8, 1.2f, 0.5f, -0.5f, 0.5f, 0.5f);
PSVECNormalize(&var_r31->unk_2C, &var_r31->unk_2C); PSVECNormalize(&var_r31->unk_2C, &var_r31->unk_2C);
var_r31->unk_00 = 0x80; var_r31->unk_00 = 0x80;
Hu3DProjectionNum++; Hu3DProjectionNum++;