mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Replace specialized swap C functions with a templatized version.
git-svn-id: https://svn.eduke32.com/eduke32@6257 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
adf62d216c
commit
0d6842800b
2 changed files with 44 additions and 17 deletions
|
@ -123,13 +123,6 @@ static inline int32_t scale(int32_t eax, int32_t edx, int32_t ecx)
|
|||
return dw(tabledivide64(numer, ecx));
|
||||
}
|
||||
|
||||
static FORCE_INLINE void swapptr(void *a, void *b)
|
||||
{
|
||||
intptr_t const t = *(intptr_t*) a;
|
||||
*(intptr_t*) a = *(intptr_t*) b;
|
||||
*(intptr_t*) b = t;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t sqr(int32_t a) { return a * a; }
|
||||
|
||||
#if defined(__GNUC__) && defined(GEKKO)
|
||||
|
@ -177,18 +170,42 @@ EDUKE32_GENERATE_PRAGMAS EDUKE32_SCALER_PRAGMA(32)
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
template <typename T>
|
||||
static FORCE_INLINE void swap(T * const a, T * const b)
|
||||
{
|
||||
T const t = *a;
|
||||
*a = *b;
|
||||
*b = t;
|
||||
}
|
||||
#define swapptr swap
|
||||
extern "C" {
|
||||
#else
|
||||
static FORCE_INLINE void swapptr(void *a, void *b)
|
||||
{
|
||||
intptr_t const t = *(intptr_t*) a;
|
||||
*(intptr_t*) a = *(intptr_t*) b;
|
||||
*(intptr_t*) b = t;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef pragmas_have_swaps
|
||||
#ifdef __cplusplus
|
||||
#define swapchar swap
|
||||
#define swapshort swap
|
||||
#define swaplong swap
|
||||
#define swapfloat swap
|
||||
#define swapdouble swap
|
||||
#define swap64bit swap
|
||||
#else
|
||||
static FORCE_INLINE void swapchar(void *a, void *b)
|
||||
{
|
||||
char const t = *(char *)b;
|
||||
*(char *)b = *(char *)a;
|
||||
*(char *)a = t;
|
||||
}
|
||||
static FORCE_INLINE void swapchar2(void *a, void *b, int32_t s)
|
||||
{
|
||||
swapchar(a, b);
|
||||
swapchar((char *)a + 1, (char *)b + s);
|
||||
}
|
||||
static FORCE_INLINE void swapshort(void *a, void *b)
|
||||
{
|
||||
int16_t const t = *(int16_t *)b;
|
||||
|
@ -220,6 +237,12 @@ static FORCE_INLINE void swap64bit(void *a, void *b)
|
|||
*(uint64_t *)a = t;
|
||||
}
|
||||
#endif
|
||||
static FORCE_INLINE void swapchar2(void *a, void *b, int32_t s)
|
||||
{
|
||||
swapchar((char *)a, (char *)b);
|
||||
swapchar((char *)a + 1, (char *)b + s);
|
||||
}
|
||||
#endif
|
||||
|
||||
static FORCE_INLINE char readpixel(void *s) { return *(char *)s; }
|
||||
static FORCE_INLINE void drawpixel(void *s, char a) { *(char *)s = a; }
|
||||
|
|
|
@ -11381,7 +11381,7 @@ static void EditWallData(int16_t wallnum)
|
|||
|
||||
static void EditSpriteData(int16_t spritenum)
|
||||
{
|
||||
int32_t col=0, row=0, rowmax=4, i = -1;
|
||||
int32_t col=0, row=0, rowmax=4;
|
||||
int32_t xpos = 8, ypos = ydim-STATUS2DSIZ+48;
|
||||
|
||||
med_editval = 0;
|
||||
|
@ -11478,7 +11478,8 @@ static void EditSpriteData(int16_t spritenum)
|
|||
sizeof(sprite[spritenum].z), BZ_MAX, 1); //2147483647L,-2147483648L
|
||||
break;
|
||||
case 3:
|
||||
i = sprite[spritenum].sectnum;
|
||||
{
|
||||
int16_t i = sprite[spritenum].sectnum;
|
||||
handlemed(0, "Sectnum", "Sectnum", &sprite[spritenum].sectnum,
|
||||
sizeof(sprite[spritenum].sectnum), numsectors-1, 0);
|
||||
if (i != sprite[spritenum].sectnum)
|
||||
|
@ -11487,8 +11488,10 @@ static void EditSpriteData(int16_t spritenum)
|
|||
changespritesect(spritenum,i);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
i = sprite[spritenum].statnum;
|
||||
{
|
||||
int16_t i = sprite[spritenum].statnum;
|
||||
handlemed(0, "Statnum", "Statnum", &sprite[spritenum].statnum,
|
||||
sizeof(sprite[spritenum].statnum), MAXSTATUS-1, 0);
|
||||
if (i != sprite[spritenum].statnum)
|
||||
|
@ -11498,6 +11501,7 @@ static void EditSpriteData(int16_t spritenum)
|
|||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
|
@ -11522,7 +11526,7 @@ static void EditSpriteData(int16_t spritenum)
|
|||
break;
|
||||
case 4:
|
||||
{
|
||||
i = Bsprintf(med_disptext,"(X,Y)repeat: %d, %d",
|
||||
int32_t i = Bsprintf(med_disptext,"(X,Y)repeat: %d, %d",
|
||||
TrackerCast(sprite[spritenum].xrepeat),
|
||||
TrackerCast(sprite[spritenum].yrepeat));
|
||||
for (; i < med_dispwidth; i++) med_disptext[i] = ' ';
|
||||
|
@ -11539,7 +11543,7 @@ static void EditSpriteData(int16_t spritenum)
|
|||
break;
|
||||
case 5:
|
||||
{
|
||||
i = Bsprintf(med_disptext,"(X,Y)offset: %d, %d",
|
||||
int32_t i = Bsprintf(med_disptext,"(X,Y)offset: %d, %d",
|
||||
TrackerCast(sprite[spritenum].xoffset),
|
||||
TrackerCast(sprite[spritenum].yoffset));
|
||||
for (; i < med_dispwidth; i++) med_disptext[i] = ' ';
|
||||
|
|
Loading…
Reference in a new issue