Fix some compilation warnings/errors
This commit is contained in:
parent
644ff23e11
commit
4464084525
@ -110,7 +110,7 @@ struct Uniform
|
||||
int pos, size;
|
||||
int type;
|
||||
|
||||
inline bool operator <(const Uniform& rhs)
|
||||
inline bool operator <(const Uniform& rhs) const
|
||||
{
|
||||
return pos < rhs.pos;
|
||||
}
|
||||
|
@ -985,7 +985,7 @@ DEF_COMMAND(format5)
|
||||
if (opdesc >= 32)
|
||||
{
|
||||
int which;
|
||||
for (which; which < 32; which ++)
|
||||
for (which = 0; which < 32; which ++)
|
||||
if (!(g_opdescIsMad & BIT(which)))
|
||||
break;
|
||||
if (which == 32)
|
||||
@ -1364,7 +1364,8 @@ DEF_DIRECTIVE(end)
|
||||
insertPaddingNop();
|
||||
lastWasEnd = false;
|
||||
}
|
||||
else if (elem.type == SE_PROC || elem.type == SE_FOR || elem.type == SE_IF && BUF.size() > 0)
|
||||
|
||||
else if (elem.type == SE_PROC || elem.type == SE_FOR || (elem.type == SE_IF && BUF.size() > 0))
|
||||
{
|
||||
u32 p = BUF.size();
|
||||
u32 lastOpcode = BUF[p-1] >> 26;
|
||||
|
@ -1,21 +1,41 @@
|
||||
#include "picasso.h"
|
||||
|
||||
// !! Taken from ctrulib !!
|
||||
u32 f32tof24(float vf)
|
||||
static inline uint32_t floatrawbits(float f)
|
||||
{
|
||||
if (!vf) return 0;
|
||||
union { float f; uint32_t i; } s;
|
||||
s.f = f;
|
||||
return s.i;
|
||||
}
|
||||
|
||||
union { float f; u32 v; } q;
|
||||
q.f=vf;
|
||||
// f24 has:
|
||||
// - 1 sign bit
|
||||
// - 7 exponent bits
|
||||
// - 16 mantissa bits
|
||||
uint32_t f32tof24(float f)
|
||||
{
|
||||
uint32_t i = floatrawbits(f);
|
||||
|
||||
u8 s = q.v>>31;
|
||||
u32 exp = ((q.v>>23) & 0xFF) - 0x40;
|
||||
u32 man = (q.v>>7) & 0xFFFF;
|
||||
uint32_t mantissa = (i << 9) >> 9;
|
||||
int32_t exponent = (i << 1) >> 24;
|
||||
uint32_t sign = (i << 0) >> 31;
|
||||
|
||||
if (exp >= 0)
|
||||
return man | (exp<<16) | (s<<23);
|
||||
else
|
||||
return s<<23;
|
||||
// Truncate mantissa
|
||||
mantissa >>= 7;
|
||||
|
||||
// Re-bias exponent
|
||||
exponent = exponent - 127 + 63;
|
||||
if (exponent < 0)
|
||||
{
|
||||
// Underflow: flush to zero
|
||||
return sign << 23;
|
||||
}
|
||||
else if (exponent > 0x7F)
|
||||
{
|
||||
// Overflow: saturate to infinity
|
||||
return (sign << 23) | (0x7F << 16);
|
||||
}
|
||||
|
||||
return (sign << 23) | (exponent << 16) | mantissa;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
|
Loading…
Reference in New Issue
Block a user