a little syncing with uhexen2.

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@460 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Ozkan Sezer 2011-06-12 12:25:22 +00:00
parent 03bbe29d44
commit 701ae6882c
5 changed files with 25 additions and 28 deletions

View file

@ -470,7 +470,7 @@ float Q_atof (const char *str)
============================================================================ ============================================================================
*/ */
qboolean bigendien; qboolean host_bigendian;
short (*BigShort) (short l); short (*BigShort) (short l);
short (*LittleShort) (short l); short (*LittleShort) (short l);
@ -1229,22 +1229,13 @@ void COM_Init (void)
N U X I N U X I
*/ */
if ( *(char *)&i == 0x12 ) if ( *(char *)&i == 0x12 )
bigendien = true; host_bigendian = true;
else if ( *(char *)&i == 0x78 ) else if ( *(char *)&i == 0x78 )
bigendien = false; host_bigendian = false;
else /* if ( *(char *)&i == 0x34 ) */ else /* if ( *(char *)&i == 0x34 ) */
Sys_Error ("Unsupported endianism."); Sys_Error ("Unsupported endianism.");
if (bigendien == false) if (host_bigendian)
{
BigShort = ShortSwap;
LittleShort = ShortNoSwap;
BigLong = LongSwap;
LittleLong = LongNoSwap;
BigFloat = FloatSwap;
LittleFloat = FloatNoSwap;
}
else /* we are big endian: */
{ {
BigShort = ShortNoSwap; BigShort = ShortNoSwap;
LittleShort = ShortSwap; LittleShort = ShortSwap;
@ -1253,6 +1244,15 @@ void COM_Init (void)
BigFloat = FloatNoSwap; BigFloat = FloatNoSwap;
LittleFloat = FloatSwap; LittleFloat = FloatSwap;
} }
else /* assumed LITTLE_ENDIAN. */
{
BigShort = ShortSwap;
LittleShort = ShortNoSwap;
BigLong = LongSwap;
LittleLong = LongNoSwap;
BigFloat = FloatSwap;
LittleFloat = FloatNoSwap;
}
if (COM_CheckParm("-fitz")) if (COM_CheckParm("-fitz"))
fitzmode = true; fitzmode = true;

View file

@ -85,7 +85,7 @@ void InsertLinkAfter (link_t *l, link_t *after);
//============================================================================ //============================================================================
extern qboolean bigendien; extern qboolean host_bigendian;
extern short (*BigShort) (short l); extern short (*BigShort) (short l);
extern short (*LittleShort) (short l); extern short (*LittleShort) (short l);

View file

@ -295,13 +295,13 @@ 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) if (host_bigendian)
{ {
*buf++ = (sample >> 8) & 0xFF; *buf++ = (sample >> 8) & 0xFF;
*buf++ = sample & 0xFF; *buf++ = sample & 0xFF;
} }
else else /* assumed LITTLE_ENDIAN. */
{ /* LITTLE_ENDIAN */ {
*buf++ = sample & 0xFF; *buf++ = sample & 0xFF;
*buf++ = (sample >> 8) & 0xFF; *buf++ = (sample >> 8) & 0xFF;
} }

View file

@ -31,8 +31,9 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/shm.h> #include <sys/shm.h>
#include <sys/wait.h> #include <sys/wait.h>
// FIXME: <sys/soundcard.h> is "by the book" but we should take care of /* FIXME: <sys/soundcard.h> is by the book, but we might
// <soundcard.h>, <linux/soundcard.h> and <machine/soundcard.h> someday. * have to take care of <soundcard.h>, <linux/soundcard.h>
* and <machine/soundcard.h> someday. */
#include <sys/soundcard.h> #include <sys/soundcard.h>
#include <errno.h> #include <errno.h>
@ -53,8 +54,8 @@ qboolean SNDDMA_Init (dma_t *dma)
unsigned long sz; unsigned long sz;
struct audio_buf_info info; struct audio_buf_info info;
if (bigendien) FORMAT_S16 = AFMT_S16_BE; if (host_bigendian) FORMAT_S16 = AFMT_S16_BE;
else FORMAT_S16 = AFMT_S16_LE; else FORMAT_S16 = AFMT_S16_LE;
tmp = COM_CheckParm("-ossdev"); tmp = COM_CheckParm("-ossdev");
if (tmp != 0 && tmp < com_argc - 1) if (tmp != 0 && tmp < com_argc - 1)

View file

@ -35,8 +35,6 @@
#define OGG_SAMPLEWIDTH 2 #define OGG_SAMPLEWIDTH 2
#define OGG_SIGNED_DATA 1 #define OGG_SIGNED_DATA 1
static int ogg_bigendian = 0;
/* CALLBACK FUNCTIONS: */ /* CALLBACK FUNCTIONS: */
static int ovc_fclose (void *f) static int ovc_fclose (void *f)
@ -60,8 +58,6 @@ static const ov_callbacks ovc_qfs =
static qboolean S_OGG_CodecInitialize (void) static qboolean S_OGG_CodecInitialize (void)
{ {
ogg_bigendian = (bigendien == true) ? 1 : 0;
ogg_codec.initialized = true;
return true; return true;
} }
@ -120,7 +116,7 @@ static snd_stream_t *S_OGG_CodecOpenStream (const char *filename)
static int S_OGG_CodecReadStream (snd_stream_t *stream, int bytes, void *buffer) static int S_OGG_CodecReadStream (snd_stream_t *stream, int bytes, void *buffer)
{ {
int section; /* FIXME: handle section changes! */ int section; /* FIXME: handle section changes */
int cnt, res, rem; int cnt, res, rem;
char * ptr; char * ptr;
@ -128,7 +124,7 @@ static int S_OGG_CodecReadStream (snd_stream_t *stream, int bytes, void *buffer)
ptr = (char *) buffer; ptr = (char *) buffer;
while (1) while (1)
{ {
res = ov_read((OggVorbis_File *) stream->priv, ptr, rem, ogg_bigendian, res = ov_read((OggVorbis_File *) stream->priv, ptr, rem, host_bigendian,
OGG_SAMPLEWIDTH, OGG_SIGNED_DATA, &section); OGG_SAMPLEWIDTH, OGG_SIGNED_DATA, &section);
if (res <= 0) if (res <= 0)
break; break;
@ -156,7 +152,7 @@ static int S_OGG_CodecRewindStream (snd_stream_t *stream)
snd_codec_t ogg_codec = snd_codec_t ogg_codec =
{ {
CODECTYPE_OGG, CODECTYPE_OGG,
false, true, /* always available. */
"ogg", "ogg",
S_OGG_CodecInitialize, S_OGG_CodecInitialize,
S_OGG_CodecShutdown, S_OGG_CodecShutdown,