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