mirror of
https://gitlab.com/ryandwyer/perfect-dark
synced 2026-08-13 20:14:45 -04:00
Use inline floor and ceil instructions
This commit is contained in:
@@ -82,8 +82,6 @@
|
||||
build/ROMID/game/acosfasinf.o (section); \
|
||||
build/ROMID/game/game_096b20.o (section); \
|
||||
build/ROMID/game/quaternion.o (section); \
|
||||
build/ROMID/game/floor.o (section); \
|
||||
build/ROMID/game/ceil.o (section); \
|
||||
build/ROMID/game/game_097aa0.o (section); \
|
||||
build/ROMID/game/invitems.o (section); \
|
||||
build/ROMID/game/bondgun.o (section); \
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
#include <ultra64.h>
|
||||
#include "constants.h"
|
||||
#include "bss.h"
|
||||
#include "data.h"
|
||||
#include "types.h"
|
||||
|
||||
f32 ceilf(f32 value)
|
||||
{
|
||||
f32 fvalue;
|
||||
|
||||
if (value <= 0) {
|
||||
return (s32)value;
|
||||
}
|
||||
|
||||
fvalue = (s32)value;
|
||||
|
||||
if (value == fvalue) {
|
||||
return fvalue;
|
||||
}
|
||||
|
||||
return fvalue + 1;
|
||||
}
|
||||
|
||||
s32 ceil(f32 value)
|
||||
{
|
||||
s32 ivalue;
|
||||
|
||||
if (value <= 0) {
|
||||
return value;
|
||||
}
|
||||
|
||||
ivalue = value;
|
||||
|
||||
if (ivalue == value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return ivalue + 1;
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
#include <ultra64.h>
|
||||
#include "constants.h"
|
||||
#include "bss.h"
|
||||
#include "data.h"
|
||||
#include "types.h"
|
||||
|
||||
f32 floorf(f32 value)
|
||||
{
|
||||
f32 fvalue;
|
||||
|
||||
if (value >= 0) {
|
||||
return (s32)value;
|
||||
}
|
||||
|
||||
fvalue = (s32)value;
|
||||
|
||||
if (value == fvalue) {
|
||||
return fvalue;
|
||||
}
|
||||
|
||||
return fvalue - 1;
|
||||
}
|
||||
|
||||
s32 floor(f32 value)
|
||||
{
|
||||
s32 ivalue;
|
||||
|
||||
if (value >= 0) {
|
||||
return value;
|
||||
}
|
||||
|
||||
ivalue = value;
|
||||
|
||||
if (value == ivalue) {
|
||||
return ivalue;
|
||||
}
|
||||
|
||||
return ivalue - 1;
|
||||
}
|
||||
+1
-1
@@ -151,7 +151,7 @@ static f32 skyClamp(f32 value, f32 min, f32 max)
|
||||
|
||||
static f32 skyRound(f32 value)
|
||||
{
|
||||
f32 ret;
|
||||
s32 ret;
|
||||
__asm__ ("round.w.s %0, %1" : "=f"(ret) : "f"(value));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ static char *frMenuTextTimeTakenValue(struct menuitem *item)
|
||||
mins++;
|
||||
}
|
||||
|
||||
sprintf(g_StringPointer, "%dm %2ds\n", mins, (s32)ceilf(secs));
|
||||
sprintf(g_StringPointer, "%dm %2ds\n", mins, ceil(secs));
|
||||
return g_StringPointer;
|
||||
} else {
|
||||
sprintf(g_StringPointer, "%s%s%2.2fs\n", "", "", secs);
|
||||
@@ -1713,7 +1713,7 @@ static char *dtMenuTextTimeTakenValue(struct menuitem *item)
|
||||
mins++;
|
||||
}
|
||||
|
||||
sprintf(g_StringPointer, "%dm %2ds\n", mins, (s32)ceilf(secs));
|
||||
sprintf(g_StringPointer, "%dm %2ds\n", mins, ceil(secs));
|
||||
return g_StringPointer;
|
||||
} else {
|
||||
sprintf(g_StringPointer, "%s%s%2.2fs\n", "", "", secs);
|
||||
@@ -1831,7 +1831,7 @@ static char *htMenuTextTimeTakenValue(struct menuitem *item)
|
||||
mins++;
|
||||
}
|
||||
|
||||
sprintf(g_StringPointer, "%dm %2ds\n", mins, (s32)ceilf(secs));
|
||||
sprintf(g_StringPointer, "%dm %2ds\n", mins, ceil(secs));
|
||||
return g_StringPointer;
|
||||
} else {
|
||||
sprintf(g_StringPointer, "%s%s%2.2fs\n", "", "", secs);
|
||||
|
||||
+13
-2
@@ -4,7 +4,18 @@
|
||||
#include "data.h"
|
||||
#include "types.h"
|
||||
|
||||
f32 ceilf(f32 value);
|
||||
s32 ceil(f32 value);
|
||||
static inline f32 ceilf(f32 value)
|
||||
{
|
||||
s32 ret;
|
||||
__asm__ ("ceil.w.s %0, %1" : "=f"(ret) : "f"(value));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline s32 ceil(f32 value)
|
||||
{
|
||||
s32 ret;
|
||||
__asm__ ("ceil.w.s %0, %1" : "=f"(ret) : "f"(value));
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,18 @@
|
||||
#include "data.h"
|
||||
#include "types.h"
|
||||
|
||||
f32 floorf(f32 value);
|
||||
s32 floor(f32 value);
|
||||
static inline f32 floorf(f32 value)
|
||||
{
|
||||
s32 ret;
|
||||
__asm__ ("floor.w.s %0, %1" : "=f"(ret) : "f"(value));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline s32 floor(f32 value)
|
||||
{
|
||||
s32 ret;
|
||||
__asm__ ("floor.w.s %0, %1" : "=f"(ret) : "f"(value));
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user