diff --git a/polymer/eduke32/build/include/pragmas.h b/polymer/eduke32/build/include/pragmas.h index 0ba83939f..ec3ef7780 100644 --- a/polymer/eduke32/build/include/pragmas.h +++ b/polymer/eduke32/build/include/pragmas.h @@ -162,10 +162,10 @@ FORCE_INLINE int32_t sqr(int32_t a) { return a * a; } // #define EDUKE32_SCALER_PRAGMA(a) \ - FORCE_INLINE int32_t mulscale##a(int32_t eax, int32_t edx) { return dw((qw(eax) * qw(edx)) >> by(a)); } \ + FORCE_INLINE int32_t mulscale##a(int32_t eax, int32_t edx) { return dw((qw(eax) * edx) >> by(a)); } \ FORCE_INLINE int32_t dmulscale##a(int32_t eax, int32_t edx, int32_t esi, int32_t edi) \ { \ - return dw(((qw(eax) * qw(edx)) + (qw(esi) * qw(edi))) >> by(a)); \ + return dw(((qw(eax) * edx) + (qw(esi) * edi)) >> by(a)); \ } EDUKE32_GENERATE_PRAGMAS EDUKE32_SCALER_PRAGMA(32) @@ -174,9 +174,9 @@ EDUKE32_GENERATE_PRAGMAS EDUKE32_SCALER_PRAGMA(32) FORCE_INLINE void swapchar(void *a, void *b) { - char const t = *((char *)b); - *((char *)b) = *((char *)a); - *((char *)a) = t; + char const t = *(char *)b; + *(char *)b = *(char *)a; + *(char *)a = t; } FORCE_INLINE void swapchar2(void *a, void *b, int32_t s) { @@ -185,37 +185,37 @@ FORCE_INLINE void swapchar2(void *a, void *b, int32_t s) } FORCE_INLINE void swapshort(void *a, void *b) { - int16_t const t = *((int16_t *)b); - *((int16_t *)b) = *((int16_t *)a); - *((int16_t *)a) = t; + int16_t const t = *(int16_t *)b; + *(int16_t *)b = *(int16_t *)a; + *(int16_t *)a = t; } FORCE_INLINE void swaplong(void *a, void *b) { - int32_t const t = *((int32_t *)b); - *((int32_t *)b) = *((int32_t *)a); - *((int32_t *)a) = t; + int32_t const t = *(int32_t *)b; + *(int32_t *)b = *(int32_t *)a; + *(int32_t *)a = t; } FORCE_INLINE void swapfloat(void *a, void *b) { - float const t = *((float *)b); - *((float *)b) = *((float *)a); - *((float *)a) = t; + float const t = *(float *)b; + *(float *)b = *(float *)a; + *(float *)a = t; } FORCE_INLINE void swapdouble(void *a, void *b) { - double const t = *((double *) b); - *((double *) b) = *((double *) a); - *((double *) a) = t; + double const t = *(double *)b; + *(double *)b = *(double *)a; + *(double *)a = t; } FORCE_INLINE void swap64bit(void *a, void *b) { - uint64_t const t = *((uint64_t *)b); - *((uint64_t *)b) = *((uint64_t *)a); - *((uint64_t *)a) = t; + uint64_t const t = *(uint64_t *)b; + *(uint64_t *)b = *(uint64_t *)a; + *(uint64_t *)a = t; } -FORCE_INLINE char readpixel(void *s) { return (*((char *)(s))); } -FORCE_INLINE void drawpixel(void *s, char a) { *((char *)(s)) = a; } +FORCE_INLINE char readpixel(void *s) { return *(char *)s; } +FORCE_INLINE void drawpixel(void *s, char a) { *(char *)s = a; } FORCE_INLINE int32_t klabs(int32_t a) { diff --git a/polymer/eduke32/build/src/pragmas.c b/polymer/eduke32/build/src/pragmas.c index a0f82c780..557c425ca 100644 --- a/polymer/eduke32/build/src/pragmas.c +++ b/polymer/eduke32/build/src/pragmas.c @@ -240,23 +240,38 @@ void clearbufbyte(void *d, int32_t c, int32_t a) void qinterpolatedown16(intptr_t bufptr, int32_t num, int32_t val, int32_t add) { - // gee, I wonder who could have provided this... - int32_t i, *lptr = (int32_t *)bufptr; - for (i=0; i>16); val += add; } + int32_t *lptr = (int32_t *)bufptr; + for (size_t i = 0, i_end = num; i < i_end; ++i) + { + lptr[i] = val>>16; + val += add; + } } void qinterpolatedown16short(intptr_t bufptr, int32_t num, int32_t val, int32_t add) { - // ...maybe the same person who provided this too? - int32_t i; int16_t *sptr = (int16_t *)bufptr; - for (i=0; i>16); val += add; } + int16_t *sptr = (int16_t *)bufptr; + for (size_t i = 0, i_end = num; i < i_end; ++i) + { + sptr[i] = val>>16; + val += add; + } } void clearbuf(void *d, int32_t c, int32_t a) { int32_t *p = (int32_t *)d; - while ((c--) > 0) *(p++) = a; +#if 0 + if (a == 0) + { + clearbufbyte(d, c<<2, 0); + return; + } +#endif + + while (c--) + *p++ = a; } void copybuf(const void *s, void *d, int32_t c) @@ -264,7 +279,8 @@ void copybuf(const void *s, void *d, int32_t c) const int32_t *p = (const int32_t *)s; int32_t *q = (int32_t *)d; - while ((c--) > 0) *(q++) = *(p++); + while (c--) + *q++ = *p++; } void swapbuf4(void *a, void *b, int32_t c) @@ -294,12 +310,13 @@ void clearbufbyte(void *D, int32_t c, int32_t a) } } -void copybufbyte(const void *S, void *D, int32_t c) +void copybufbyte(const void *s, void *d, int32_t c) { - const char *p = (const char *)S; - char *q = (char *)D; + const char *src = (const char *)s; + char *dst = (char *)d; - while ((c--) > 0) *(q++) = *(p++); + while (c--) + *dst++ = *src++; } @@ -346,12 +363,13 @@ void copybufreverse(const void *S, void *D, int32_t c) ); } #else -void copybufreverse(const void *S, void *D, int32_t c) +void copybufreverse(const void *s, void *d, int32_t c) { - const char *p = (const char *)S; - char *q = (char *)D; + const char *src = (const char *)s; + char *dst = (char *)d; - while ((c--) > 0) *(q++) = *(p--); + while (c--) + *dst++ = *src--; } #endif