effect_position.c
changeset 159 01490534f9fe
parent 138 4d0dc6b4985d
child 201 e55fb6b45559
equal deleted inserted replaced
158:954c719d0359 159:01490534f9fe
    28 #include <stdlib.h>
    28 #include <stdlib.h>
    29 #include <string.h>
    29 #include <string.h>
    30 
    30 
    31 #include "SDL.h"
    31 #include "SDL.h"
    32 #include "SDL_mixer.h"
    32 #include "SDL_mixer.h"
       
    33 #include "SDL_endian.h"
    33 
    34 
    34 #define __MIX_INTERNAL_EFFECT__
    35 #define __MIX_INTERNAL_EFFECT__
    35 #include "effects_internal.h"
    36 #include "effects_internal.h"
    36 
    37 
    37 /* profile code:
    38 /* profile code:
   140     }
   141     }
   141 
   142 
   142     p = (Uint32 *) ptr;
   143     p = (Uint32 *) ptr;
   143 
   144 
   144     for (i = 0; i < len; i += sizeof (Uint32)) {
   145     for (i = 0; i < len; i += sizeof (Uint32)) {
   145 #if (SDL_BYTE_ORDER == SDL_BIG_ENDIAN)
   146 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
   146         *(p++) = (d[l[(*p & 0xFF000000) >> 24]] << 24) |
   147         *(p++) = (d[l[(*p & 0xFF000000) >> 24]] << 24) |
   147                  (d[r[(*p & 0x00FF0000) >> 16]] << 16) |
   148                  (d[r[(*p & 0x00FF0000) >> 16]] << 16) |
   148                  (d[l[(*p & 0x0000FF00) >>  8]] <<  8) |
   149                  (d[l[(*p & 0x0000FF00) >>  8]] <<  8) |
   149                  (d[r[(*p & 0x000000FF)      ]]      ) ;
   150                  (d[r[(*p & 0x000000FF)      ]]      ) ;
   150 #else
   151 #else
   207     }
   208     }
   208 
   209 
   209     p = (Uint32 *) ptr;
   210     p = (Uint32 *) ptr;
   210 
   211 
   211     for (i = 0; i < len; i += sizeof (Uint32)) {
   212     for (i = 0; i < len; i += sizeof (Uint32)) {
   212 #if (SDL_BYTE_ORDER == SDL_BIG_ENDIAN)
   213 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
   213         *(p++) = (d[l[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) |
   214         *(p++) = (d[l[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) |
   214                  (d[r[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) |
   215                  (d[r[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) |
   215                  (d[l[((Sint16)(Sint8)((*p & 0x0000FF00) >>  8))+128]] <<  8) |
   216                  (d[l[((Sint16)(Sint8)((*p & 0x0000FF00) >>  8))+128]] <<  8) |
   216                  (d[r[((Sint16)(Sint8)((*p & 0x000000FF)      ))+128]]      ) ;
   217                  (d[r[((Sint16)(Sint8)((*p & 0x000000FF)      ))+128]]      ) ;
   217 #else
   218 #else
   233     volatile position_args *args = (volatile position_args *) udata;
   234     volatile position_args *args = (volatile position_args *) udata;
   234     Uint16 *ptr = (Uint16 *) stream;
   235     Uint16 *ptr = (Uint16 *) stream;
   235     int i;
   236     int i;
   236 
   237 
   237     for (i = 0; i < len; i += sizeof (Uint16) * 2) {
   238     for (i = 0; i < len; i += sizeof (Uint16) * 2) {
   238 #if (SDL_BYTE_ORDER == SDL_BIG_ENDIAN)
   239 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
   239         Uint16 swapl = (Uint16) ((((float) SDL_Swap16(*(ptr))) *
   240         Uint16 swapl = (Uint16) ((((float) SDL_Swap16(*(ptr))) *
   240                                     args->left_f) * args->distance_f);
   241                                     args->left_f) * args->distance_f);
   241         Uint16 swapr = (Uint16) (((float) SDL_Swap16(*(ptr+1))) *
   242         Uint16 swapr = (Uint16) ((((float) SDL_Swap16(*(ptr+1))) *
   242                                     args->right_f) * args->distance_f);
   243                                     args->right_f) * args->distance_f);
   243         *(ptr++) = (Uint16) SDL_Swap16(swapl);
   244         *(ptr++) = (Uint16) SDL_Swap16(swapl);
   244         *(ptr++) = (Uint16) SDL_Swap16(swapr);
   245         *(ptr++) = (Uint16) SDL_Swap16(swapr);
   245 #else
   246 #else
   246         *(ptr++) = (Uint16) ((((float) *ptr)*args->left_f)*args->distance_f);
   247         *(ptr++) = (Uint16) ((((float) *ptr)*args->left_f)*args->distance_f);
   255     volatile position_args *args = (volatile position_args *) udata;
   256     volatile position_args *args = (volatile position_args *) udata;
   256     Sint16 *ptr = (Sint16 *) stream;
   257     Sint16 *ptr = (Sint16 *) stream;
   257     int i;
   258     int i;
   258 
   259 
   259     for (i = 0; i < len; i += sizeof (Sint16) * 2) {
   260     for (i = 0; i < len; i += sizeof (Sint16) * 2) {
   260 #if (SDL_BYTE_ORDER == SDL_BIG_ENDIAN)
   261 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
   261         Sint16 swapl = (Sint16) ((((float) SDL_Swap16(*(ptr))) *
   262         Sint16 swapl = (Sint16) ((((float) SDL_Swap16(*(ptr))) *
   262                                     args->left_f) * args->distance_f);
   263                                     args->left_f) * args->distance_f);
   263         Sint16 swapr = (Sint16) (((float) SDL_Swap16(*(ptr+1))) *
   264         Sint16 swapr = (Sint16) ((((float) SDL_Swap16(*(ptr+1))) *
   264                                     args->right_f) * args->distance_f);
   265                                     args->right_f) * args->distance_f);
   265         *(ptr++) = (Sint16) SDL_Swap16(swapl);
   266         *(ptr++) = (Sint16) SDL_Swap16(swapl);
   266         *(ptr++) = (Sint16) SDL_Swap16(swapr);
   267         *(ptr++) = (Sint16) SDL_Swap16(swapr);
   267 #else
   268 #else
   268         *(ptr++) = (Sint16) ((((float) *ptr)*args->left_f)*args->distance_f);
   269         *(ptr++) = (Sint16) ((((float) *ptr)*args->left_f)*args->distance_f);
   277     volatile position_args *args = (volatile position_args *) udata;
   278     volatile position_args *args = (volatile position_args *) udata;
   278     Uint16 *ptr = (Uint16 *) stream;
   279     Uint16 *ptr = (Uint16 *) stream;
   279     int i;
   280     int i;
   280 
   281 
   281     for (i = 0; i < len; i += sizeof (Sint16) * 2) {
   282     for (i = 0; i < len; i += sizeof (Sint16) * 2) {
   282 #if (SDL_BYTE_ORDER == SDL_LIL_ENDIAN)
   283 #if (SDL_BYTEORDER == SDL_LIL_ENDIAN)
   283         Uint16 swapl = (Uint16) ((((float) SDL_Swap16(*(ptr))) *
   284         Uint16 swapl = (Uint16) ((((float) SDL_Swap16(*(ptr))) *
   284                                     args->left_f) * args->distance_f);
   285                                     args->left_f) * args->distance_f);
   285         Uint16 swapr = (Uint16) (((float) SDL_Swap16(*(ptr+1))) *
   286         Uint16 swapr = (Uint16) ((((float) SDL_Swap16(*(ptr+1))) *
   286                                     args->right_f) * args->distance_f);
   287                                     args->right_f) * args->distance_f);
   287         *(ptr++) = (Uint16) SDL_Swap16(swapl);
   288         *(ptr++) = (Uint16) SDL_Swap16(swapl);
   288         *(ptr++) = (Uint16) SDL_Swap16(swapr);
   289         *(ptr++) = (Uint16) SDL_Swap16(swapr);
   289 #else
   290 #else
   290         *(ptr++) = (Uint16) ((((float) *ptr)*args->left_f)*args->distance_f);
   291         *(ptr++) = (Uint16) ((((float) *ptr)*args->left_f)*args->distance_f);
   299     volatile position_args *args = (volatile position_args *) udata;
   300     volatile position_args *args = (volatile position_args *) udata;
   300     Sint16 *ptr = (Sint16 *) stream;
   301     Sint16 *ptr = (Sint16 *) stream;
   301     int i;
   302     int i;
   302 
   303 
   303     for (i = 0; i < len; i += sizeof (Sint16) * 2) {
   304     for (i = 0; i < len; i += sizeof (Sint16) * 2) {
   304 #if (SDL_BYTE_ORDER == SDL_LIL_ENDIAN)
   305 #if (SDL_BYTEORDER == SDL_LIL_ENDIAN)
   305         Sint16 swapl = (Sint16) ((((float) SDL_Swap16(*(ptr))) *
   306         Sint16 swapl = (Sint16) ((((float) SDL_Swap16(*(ptr))) *
   306                                     args->left_f) * args->distance_f);
   307                                     args->left_f) * args->distance_f);
   307         Sint16 swapr = (Sint16) (((float) SDL_Swap16(*(ptr+1))) *
   308         Sint16 swapr = (Sint16) ((((float) SDL_Swap16(*(ptr+1))) *
   308                                     args->right_f) * args->distance_f);
   309                                     args->right_f) * args->distance_f);
   309         *(ptr++) = (Sint16) SDL_Swap16(swapl);
   310         *(ptr++) = (Sint16) SDL_Swap16(swapl);
   310         *(ptr++) = (Sint16) SDL_Swap16(swapr);
   311         *(ptr++) = (Sint16) SDL_Swap16(swapr);
   311 #else
   312 #else
   312         *(ptr++) = (Sint16) ((((float) *ptr)*args->left_f)*args->distance_f);
   313         *(ptr++) = (Sint16) ((((float) *ptr)*args->left_f)*args->distance_f);