Remove core.h, SDL2->SDL3, Makefile cleanup, ansi C, 80 char.
This commit is contained in:
+37
-35
@@ -7,77 +7,79 @@
|
||||
#include <math.h>
|
||||
#include <string.h> /* memset */
|
||||
|
||||
float AbsoluteValue(float Real32)
|
||||
float absolute_value(float real32)
|
||||
{
|
||||
float Result = fabs(Real32);
|
||||
return Result;
|
||||
float result = fabs(real32);
|
||||
return result;
|
||||
}
|
||||
|
||||
int RoundFloatToInt(float Real32)
|
||||
int round_float_to_int(float real32)
|
||||
{
|
||||
int Result = (int)roundf(Real32);
|
||||
return Result;
|
||||
int result = (int)roundf(real32);
|
||||
return result;
|
||||
}
|
||||
|
||||
int FloorFloatToInt(float Real32)
|
||||
int floor_float_to_int(float real32)
|
||||
{
|
||||
int Result = (int)floorf(Real32);
|
||||
return Result;
|
||||
int result = (int)floorf(real32);
|
||||
return result;
|
||||
}
|
||||
|
||||
float Sin(float Angle)
|
||||
float hm_sin(float angle)
|
||||
{
|
||||
float Result = sinf(Angle);
|
||||
return Result;
|
||||
float result = sinf(angle);
|
||||
return result;
|
||||
}
|
||||
|
||||
float Cos(float Angle)
|
||||
float hm_cos(float angle)
|
||||
{
|
||||
float Result = cosf(Angle);
|
||||
return Result;
|
||||
float result = cosf(angle);
|
||||
return result;
|
||||
}
|
||||
|
||||
float ATan2(float Y, float X)
|
||||
float hm_atan2(float y, float x)
|
||||
{
|
||||
float Result = atan2f(Y, X);
|
||||
return Result;
|
||||
float result = atan2f(y, x);
|
||||
return result;
|
||||
}
|
||||
|
||||
struct bit_scan_result {
|
||||
int Found;
|
||||
unsigned int Index;
|
||||
int found;
|
||||
unsigned int index;
|
||||
};
|
||||
|
||||
static struct bit_scan_result FindLeastSignificantSetBit(unsigned int Value)
|
||||
static struct bit_scan_result
|
||||
find_least_significant_set_bit(unsigned int value)
|
||||
{
|
||||
struct bit_scan_result Result;
|
||||
memset(&Result, 0, sizeof(Result));
|
||||
/* TODO: */
|
||||
struct bit_scan_result result;
|
||||
memset(&result, 0, sizeof(result));
|
||||
|
||||
#if COMPILER_MSVC
|
||||
unsigned long Index;
|
||||
Result.Found = _BitScanForward(&Index, Value);
|
||||
Result.Index = (unsigned int)Index;
|
||||
unsigned long index;
|
||||
result.Found = _BitScanForward(&index, value);
|
||||
result.index = (unsigned int)index;
|
||||
#elif COMPILER_CLANG
|
||||
Result.Index = __builtin_ffsll(Value); /* NOTE: It is a GCC function,
|
||||
result.index = __builtin_ffsll(value); /* NOTE: It is a GCC function,
|
||||
but is supported by clang
|
||||
compiler.
|
||||
https://gcc.gnu.org/onlinedocs/gcc/Bit-Operation-Builtins.html*/
|
||||
if(Result.Index) {
|
||||
Result.Found = 1;
|
||||
if(Result.Index > 0)
|
||||
Result.Index--;
|
||||
if(result.index) {
|
||||
result.found = 1;
|
||||
if(result.index > 0)
|
||||
result.index--;
|
||||
}
|
||||
#else
|
||||
for(unsigned int Test = 0; Test < 32; Test++) {
|
||||
if(Value & (1 << Test)) {
|
||||
Result.Index = Test;
|
||||
Result.Found = 1;
|
||||
if(value & (1 << Test)) {
|
||||
result.index = Test;
|
||||
result.Found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return Result;
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user