Commit c344c7e1 authored by Libretro-Admin's avatar Libretro-Admin
Browse files
parent 20a9181c
...@@ -285,72 +285,6 @@ float Q_atof(const char *str) ...@@ -285,72 +285,6 @@ float Q_atof(const char *str)
return val * sign; return val * sign;
} }
/*
============================================================================
BYTE ORDER FUNCTIONS
============================================================================
*/
qboolean bigendien;
short (*BigShort) (short l);
short (*LittleShort) (short l);
int (*BigLong) (int l);
int (*LittleLong) (int l);
float (*BigFloat) (float l);
float (*LittleFloat) (float l);
short ShortSwap(short l)
{
byte b1 = l & 255;
byte b2 = (l >> 8) & 255;
return (b1 << 8) + b2;
}
short ShortNoSwap(short l)
{
return l;
}
int LongSwap(int l)
{
byte b1 = l & 255;
byte b2 = (l >> 8) & 255;
byte b3 = (l >> 16) & 255;
byte b4 = (l >> 24) & 255;
return ((int)b1 << 24) + ((int)b2 << 16) + ((int)b3 << 8) + b4;
}
int
LongNoSwap(int l)
{
return l;
}
float FloatSwap(float f)
{
union {
float f;
byte b[4];
} dat1, dat2;
dat1.f = f;
dat2.b[0] = dat1.b[3];
dat2.b[1] = dat1.b[2];
dat2.b[2] = dat1.b[1];
dat2.b[3] = dat1.b[0];
return dat2.f;
}
float FloatNoSwap(float f)
{
return f;
}
/* /*
============================================================================== ==============================================================================
...@@ -1156,35 +1090,8 @@ COM_Init ...@@ -1156,35 +1090,8 @@ COM_Init
================ ================
*/ */
union swaptest {
byte b[2];
short s;
} swaptest;
void COM_Init(void) void COM_Init(void)
{ {
swaptest.b[0] = 1;
swaptest.b[1] = 0;
// set the byte swapping variables in a portable manner
if (swaptest.s == 1) {
bigendien = false;
BigShort = ShortSwap;
LittleShort = ShortNoSwap;
BigLong = LongSwap;
LittleLong = LongNoSwap;
BigFloat = FloatSwap;
LittleFloat = FloatNoSwap;
} else {
bigendien = true;
BigShort = ShortNoSwap;
LittleShort = ShortSwap;
BigLong = LongNoSwap;
LittleLong = LongSwap;
BigFloat = FloatNoSwap;
LittleFloat = FloatSwap;
}
Cvar_RegisterVariable(&registered); Cvar_RegisterVariable(&registered);
#ifdef NQ_HACK #ifdef NQ_HACK
Cvar_RegisterVariable(&cmdline); Cvar_RegisterVariable(&cmdline);
......
...@@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <retro_inline.h>
#include "qtypes.h" #include "qtypes.h"
#include "shell.h" #include "shell.h"
...@@ -94,16 +95,50 @@ void InsertLinkAfter(link_t *l, link_t *after); ...@@ -94,16 +95,50 @@ void InsertLinkAfter(link_t *l, link_t *after);
#define Q_MINLONG ((int)0x80000000) #define Q_MINLONG ((int)0x80000000)
#define Q_MINFLOAT ((int)0x7fffffff) #define Q_MINFLOAT ((int)0x7fffffff)
//============================================================================ /*
* ========================================================================
extern qboolean bigendien; * BYTE ORDER FUNCTIONS
* ========================================================================
*/
extern short (*BigShort) (short l); static INLINE short bswap16(short s)
extern short (*LittleShort) (short l); {
extern int (*BigLong) (int l); return ((s & 255) << 8) | ((s >> 8) & 255);
extern int (*LittleLong) (int l); }
extern float (*BigFloat) (float l); static INLINE int bswap32(int l)
extern float (*LittleFloat) (float l); {
return
(((l >> 0) & 255) << 24)
| (((l >> 8) & 255) << 16)
| (((l >> 16) & 255) << 8)
| (((l >> 24) & 255) << 0);
}
#ifdef MSB_FIRST
static INLINE short BigShort(short s) { return s; }
static INLINE int BigLong(int l) { return l; }
static INLINE float BigFloat(float f) { return f; }
static INLINE short LittleShort(short s) { return bswap16(s); }
static INLINE int LittleLong(int l) { return bswap32(l); }
static INLINE float LittleFloat(float f)
{
union { float f; int l; } u = { .f = f };
u.l = bswap32(u.l);
return u.f;
}
#else
static INLINE short BigShort(short s) { return bswap16(s); }
static INLINE int BigLong(int l) { return bswap32(l); }
static INLINE float BigFloat(float f)
{
union { float f; int l; } u = { .f = f };
u.l = bswap32(u.l);
return u.f;
}
static INLINE short LittleShort(short s) { return s; }
static INLINE int LittleLong(int l) { return l; }
static INLINE float LittleFloat(float f) { return f; }
#endif
//============================================================================ //============================================================================
......
...@@ -320,16 +320,14 @@ static int mp3_decode(snd_stream_t *stream, byte *buf, int len) ...@@ -320,16 +320,14 @@ static int mp3_decode(snd_stream_t *stream, byte *buf, int len)
sample = 0x7FFF; sample = 0x7FFF;
else else
sample >>= (MAD_F_FRACBITS + 1 - 16); sample >>= (MAD_F_FRACBITS + 1 - 16);
if (bigendien) #ifdef MSB_FIRST
{ *buf++ = (sample >> 8) & 0xFF;
*buf++ = (sample >> 8) & 0xFF; *buf++ = sample & 0xFF;
*buf++ = sample & 0xFF; #else
} /* assumed LITTLE_ENDIAN. */
else /* assumed LITTLE_ENDIAN. */ *buf++ = sample & 0xFF;
{ *buf++ = (sample >> 8) & 0xFF;
*buf++ = sample & 0xFF; #endif
*buf++ = (sample >> 8) & 0xFF;
}
i++; i++;
} }
p->cursamp++; p->cursamp++;
......
...@@ -157,7 +157,11 @@ static int S_VORBIS_CodecReadStream (snd_stream_t *stream, int bytes, void *buff ...@@ -157,7 +157,11 @@ static int S_VORBIS_CodecReadStream (snd_stream_t *stream, int bytes, void *buff
*/ */
res = ov_read( (OggVorbis_File *)stream->priv, ptr, rem, res = ov_read( (OggVorbis_File *)stream->priv, ptr, rem,
#if !defined(VORBIS_USE_TREMOR) #if !defined(VORBIS_USE_TREMOR)
bigendien, #ifdef MSB_FIRST
1, /* endianness - 1 for big endian, 0 for little */
#else
0, /* endianness - 1 for big endian, 0 for little */
#endif
VORBIS_SAMPLEWIDTH, VORBIS_SAMPLEWIDTH,
VORBIS_SIGNED_DATA, VORBIS_SIGNED_DATA,
#endif /* ! VORBIS_USE_TREMOR */ #endif /* ! VORBIS_USE_TREMOR */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment