mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 14:52:01 +00:00
Eliminate many cases of duplication of compat.h's functionality.
git-svn-id: https://svn.eduke32.com/eduke32@6067 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
225be10f61
commit
26e740c0b7
11 changed files with 23 additions and 121 deletions
|
@ -31,53 +31,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#ifndef MULTIVOC_H_
|
||||
#define MULTIVOC_H_
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef UNREFERENCED_PARAMETER
|
||||
#define UNREFERENCED_PARAMETER(x) x = x
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define inline __inline
|
||||
#endif
|
||||
|
||||
#if defined __POWERPC__ || defined GEKKO
|
||||
static inline uint16_t SWAP16(uint16_t s) { return (s >> 8) | (s << 8); }
|
||||
static inline uint32_t SWAP32(uint32_t s)
|
||||
{
|
||||
return (s >> 24) | (s << 24) | ((s & 0xff00) << 8) | ((s & 0xff0000) >> 8);
|
||||
}
|
||||
#define LITTLE16(s) SWAP16(s)
|
||||
#define LITTLE32(s) SWAP32(s)
|
||||
#else
|
||||
#define LITTLE16
|
||||
#define LITTLE32
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE (1 == 1)
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE (!TRUE)
|
||||
#endif
|
||||
|
||||
#ifndef min
|
||||
#define min(x, y) ((x) < (y) ? (x) : (y))
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(x, y) ((x) > (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
#elif defined(__QNX__)
|
||||
#define strcasecmp stricmp
|
||||
#define strncasecmp strnicmp
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FMT_UNKNOWN,
|
||||
|
|
|
@ -22,11 +22,7 @@
|
|||
* Stub driver for no output
|
||||
*/
|
||||
|
||||
#include "inttypes.h"
|
||||
|
||||
#ifndef UNREFERENCED_PARAMETER
|
||||
# define UNREFERENCED_PARAMETER(x) x=x
|
||||
#endif
|
||||
#include "compat.h"
|
||||
|
||||
|
||||
int32_t NoSoundDrv_GetError(void)
|
||||
|
|
|
@ -115,7 +115,7 @@ static playbackstatus MV_GetNextVOCBlock(VoiceNode *voice)
|
|||
else
|
||||
blocklength = 0;
|
||||
// would need one byte pad at end of alloc'd region:
|
||||
// blocklength = LITTLE32(*(uint32_t *)(ptr + 1)) & 0x00ffffff;
|
||||
// blocklength = B_LITTLE32(*(uint32_t *)(ptr + 1)) & 0x00ffffff;
|
||||
|
||||
ptr += 4;
|
||||
|
||||
|
@ -186,7 +186,7 @@ end_of_data:
|
|||
// Repeat begin
|
||||
if (voice->LoopEnd == NULL)
|
||||
{
|
||||
voice->LoopCount = LITTLE16(*(uint16_t const *)ptr);
|
||||
voice->LoopCount = B_LITTLE16(*(uint16_t const *)ptr);
|
||||
voice->LoopStart = (char *)((intptr_t) ptr + blocklength);
|
||||
}
|
||||
ptr += blocklength;
|
||||
|
@ -216,7 +216,7 @@ end_of_data:
|
|||
// Extended block
|
||||
voice->bits = 8;
|
||||
voice->channels = 1;
|
||||
tc = LITTLE16(*(uint16_t const *)ptr);
|
||||
tc = B_LITTLE16(*(uint16_t const *)ptr);
|
||||
packtype = *(ptr + 2);
|
||||
voicemode = *(ptr + 3);
|
||||
ptr += blocklength;
|
||||
|
@ -224,10 +224,10 @@ end_of_data:
|
|||
|
||||
case 9 :
|
||||
// New sound data block
|
||||
samplespeed = LITTLE32(*(uint32_t const *)ptr);
|
||||
samplespeed = B_LITTLE32(*(uint32_t const *)ptr);
|
||||
BitsPerSample = (unsigned)*(ptr + 4);
|
||||
Channels = (unsigned)*(ptr + 5);
|
||||
Format = (unsigned)LITTLE16(*(uint16_t const *)(ptr + 6));
|
||||
Format = (unsigned)B_LITTLE16(*(uint16_t const *)(ptr + 6));
|
||||
|
||||
if ((BitsPerSample == 8) && (Channels == 1 || Channels == 2) && (Format == VOC_8BIT))
|
||||
{
|
||||
|
@ -342,8 +342,8 @@ int32_t MV_PlayWAV(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t loo
|
|||
|
||||
riff_header riff;
|
||||
memcpy(&riff, ptr, sizeof(riff_header));
|
||||
riff.file_size = LITTLE32(riff.file_size);
|
||||
riff.format_size = LITTLE32(riff.format_size);
|
||||
riff.file_size = B_LITTLE32(riff.file_size);
|
||||
riff.format_size = B_LITTLE32(riff.format_size);
|
||||
|
||||
if ((memcmp(riff.RIFF, "RIFF", 4) != 0) || (memcmp(riff.WAVE, "WAVE", 4) != 0) || (memcmp(riff.fmt, "fmt ", 4) != 0))
|
||||
{
|
||||
|
@ -353,16 +353,16 @@ int32_t MV_PlayWAV(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t loo
|
|||
|
||||
format_header format;
|
||||
memcpy(&format, ptr + sizeof(riff_header), sizeof(format_header));
|
||||
format.wFormatTag = LITTLE16(format.wFormatTag);
|
||||
format.nChannels = LITTLE16(format.nChannels);
|
||||
format.nSamplesPerSec = LITTLE32(format.nSamplesPerSec);
|
||||
format.nAvgBytesPerSec = LITTLE32(format.nAvgBytesPerSec);
|
||||
format.nBlockAlign = LITTLE16(format.nBlockAlign);
|
||||
format.nBitsPerSample = LITTLE16(format.nBitsPerSample);
|
||||
format.wFormatTag = B_LITTLE16(format.wFormatTag);
|
||||
format.nChannels = B_LITTLE16(format.nChannels);
|
||||
format.nSamplesPerSec = B_LITTLE32(format.nSamplesPerSec);
|
||||
format.nAvgBytesPerSec = B_LITTLE32(format.nAvgBytesPerSec);
|
||||
format.nBlockAlign = B_LITTLE16(format.nBlockAlign);
|
||||
format.nBitsPerSample = B_LITTLE16(format.nBitsPerSample);
|
||||
|
||||
data_header data;
|
||||
memcpy(&data, ptr + sizeof(riff_header) + riff.format_size, sizeof(data_header));
|
||||
data.size = LITTLE32(data.size);
|
||||
data.size = B_LITTLE32(data.size);
|
||||
|
||||
// Check if it's PCM data.
|
||||
if (format.wFormatTag != 1 || (format.nChannels != 1 && format.nChannels != 2) ||
|
||||
|
@ -476,7 +476,7 @@ int32_t MV_PlayVOC(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t loo
|
|||
voice->bits = 8;
|
||||
voice->channels = 1;
|
||||
voice->GetSound = MV_GetNextVOCBlock;
|
||||
voice->NextBlock = ptr + LITTLE16(*(uint16_t *)(ptr + 0x14));
|
||||
voice->NextBlock = ptr + B_LITTLE16(*(uint16_t *)(ptr + 0x14));
|
||||
voice->LoopCount = 0;
|
||||
voice->BlockLength = 0;
|
||||
voice->PitchScale = PITCH_GetScale(pitchoffset);
|
||||
|
|
|
@ -106,7 +106,7 @@ static wavefmt_t FX_DetectFormat(char const * const ptr, uint32_t length)
|
|||
|
||||
wavefmt_t fmt = FMT_UNKNOWN;
|
||||
|
||||
switch (LITTLE32(*(int32_t const *)ptr))
|
||||
switch (B_LITTLE32(*(int32_t const *)ptr))
|
||||
{
|
||||
case 'C' + ('r' << 8) + ('e' << 16) + ('a' << 24): // Crea
|
||||
fmt = FMT_VOC;
|
||||
|
@ -115,7 +115,7 @@ static wavefmt_t FX_DetectFormat(char const * const ptr, uint32_t length)
|
|||
fmt = FMT_VORBIS;
|
||||
break;
|
||||
case 'R' + ('I' << 8) + ('F' << 16) + ('F' << 24): // RIFF
|
||||
switch (LITTLE32(*(int32_t const *)(ptr + 8)))
|
||||
switch (B_LITTLE32(*(int32_t const *)(ptr + 8)))
|
||||
{
|
||||
case 'C' + ('D' << 8) + ('X' << 16) + ('A' << 24): // CDXA
|
||||
fmt = FMT_XA;
|
||||
|
@ -127,7 +127,7 @@ static wavefmt_t FX_DetectFormat(char const * const ptr, uint32_t length)
|
|||
fmt = FMT_FLAC;
|
||||
break;
|
||||
default:
|
||||
switch (LITTLE32(*(int32_t const *)(ptr + 8)))
|
||||
switch (B_LITTLE32(*(int32_t const *)(ptr + 8)))
|
||||
{
|
||||
case 'W' + ('A' << 8) + ('V' << 16) + ('E' << 24): // WAVE
|
||||
fmt = FMT_WAV;
|
||||
|
|
|
@ -21,14 +21,6 @@
|
|||
#define kNumOfSGs 18
|
||||
#define TTYWidth 80
|
||||
|
||||
#ifndef max
|
||||
# define max(a,b) ( ((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef min
|
||||
# define min(a,b) ( ((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
/* ADPCM */
|
||||
#define XA_DATA_START (0x44-48)
|
||||
|
||||
|
|
|
@ -73,13 +73,6 @@
|
|||
#define EDUKE32_UNREACHABLE_SECTION(...) __VA_ARGS__
|
||||
#endif
|
||||
|
||||
#ifndef min
|
||||
#define min(x,y) ((x) < (y) ? (x) : (y))
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(x,y) ((x) > (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#if defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ || defined __bsdi__ || defined __DragonFly__
|
||||
# define EDUKE32_BSD
|
||||
#endif
|
||||
|
|
|
@ -66,12 +66,6 @@ static __inline int32_t _lrotl(int32_t i, int sh) { return (i >> (-sh)) | (i <<
|
|||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
#if !defined(max)
|
||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
#if !defined(min)
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#undef _inline
|
||||
|
|
|
@ -32,14 +32,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#define FALSE (!TRUE)
|
||||
#endif
|
||||
|
||||
#ifndef min
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef max
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
int32_t MUSIC_SoundDevice = -1;
|
||||
int32_t MUSIC_ErrorCode = MUSIC_Ok;
|
||||
|
||||
|
|
|
@ -35,11 +35,6 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
|
|||
typedef int boolean;
|
||||
typedef int errorcode;
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE ( 1 == 1 )
|
||||
#define FALSE ( !TRUE )
|
||||
#endif
|
||||
|
||||
enum STANDARD_ERRORS
|
||||
{
|
||||
Warning = -2,
|
||||
|
@ -47,17 +42,6 @@ enum STANDARD_ERRORS
|
|||
Success = 0
|
||||
};
|
||||
|
||||
#define BITSET( data, bit ) \
|
||||
( ( ( data ) & ( bit ) ) == ( bit ) )
|
||||
|
||||
#define ARRAY_LENGTH( array ) \
|
||||
( sizeof( array ) / sizeof( ( array )[ 0 ] ) )
|
||||
|
||||
#define WITHIN_BOUNDS( array, index ) \
|
||||
( ( 0 <= ( index ) ) && ( ( index ) < ARRAY_LENGTH( array ) ) )
|
||||
|
||||
#define FOREVER for( ; ; )
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define DEBUGGING 0
|
||||
#else
|
||||
|
|
|
@ -681,7 +681,7 @@ int StdRandomRange(int range);
|
|||
)
|
||||
|
||||
|
||||
#define SIZ(array) (sizeof(array)/sizeof(array[0]))
|
||||
#define SIZ ARRAY_SIZE
|
||||
|
||||
|
||||
//
|
||||
|
|
|
@ -28,15 +28,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
|
||||
#define TYPES_H
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
#ifndef TRUE
|
||||
#define TRUE (!FALSE)
|
||||
#endif
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
#include "compat.h"
|
||||
|
||||
#define OFF 0
|
||||
#define ON (!OFF)
|
||||
|
|
Loading…
Reference in a new issue