Fixed Ryan's naughty coding. :)
authorSam Lantinga <slouken@libsdl.org>
Fri, 21 Feb 2003 17:11:56 +0000
changeset 218a21e382190a8
parent 217 74d2e4341a39
child 219 bd6222ab4598
Fixed Ryan's naughty coding. :)
effect_position.c
     1.1 --- a/effect_position.c	Fri Feb 21 16:56:52 2003 +0000
     1.2 +++ b/effect_position.c	Fri Feb 21 17:11:56 2003 +0000
     1.3 @@ -99,16 +99,19 @@
     1.4           *  1.0, and are therefore throwaways.
     1.5           */
     1.6      if (len % sizeof (Uint16) != 0) {
     1.7 -        *(ptr++) = (Uint8) (((float) *ptr) * args->distance_f);
     1.8 +        *ptr = (Uint8) (((float) *ptr) * args->distance_f);
     1.9 +        ptr++;
    1.10          len--;
    1.11      }
    1.12  
    1.13      for (i = 0; i < len; i += sizeof (Uint8) * 2) {
    1.14          /* must adjust the sample so that 0 is the center */
    1.15 -        *(ptr++) = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) 
    1.16 +        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) 
    1.17              * args->left_f) * args->distance_f) + 128);
    1.18 -        *(ptr++) = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) 
    1.19 +        ptr++;
    1.20 +        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) 
    1.21              * args->right_f) * args->distance_f) + 128);
    1.22 +        ptr++;
    1.23      }
    1.24  }
    1.25  
    1.26 @@ -137,9 +140,12 @@
    1.27           *  be sure not to overrun the audio buffer...
    1.28           */
    1.29      while (len % sizeof (Uint32) != 0) {
    1.30 -        *(ptr++) = d[l[*ptr]];
    1.31 -        if (args->channels == 2)
    1.32 -            *(ptr++) = d[r[*ptr]];
    1.33 +        *ptr = d[l[*ptr]];
    1.34 +        ptr++;
    1.35 +        if (args->channels > 1) {
    1.36 +            *ptr = d[r[*ptr]];
    1.37 +            ptr++;
    1.38 +        }
    1.39          len -= args->channels;
    1.40      }
    1.41  
    1.42 @@ -173,13 +179,16 @@
    1.43           *  1.0, and are therefore throwaways.
    1.44           */
    1.45      if (len % sizeof (Sint16) != 0) {
    1.46 -        *(ptr++) = (Sint8) (((float) *ptr) * args->distance_f);
    1.47 +        *ptr = (Sint8) (((float) *ptr) * args->distance_f);
    1.48 +        ptr++;
    1.49          len--;
    1.50      }
    1.51  
    1.52      for (i = 0; i < len; i += sizeof (Sint8) * 2) {
    1.53 -        *(ptr++) = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f);
    1.54 -        *(ptr++) = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f);
    1.55 +        *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f);
    1.56 +        ptr++;
    1.57 +        *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f);
    1.58 +        ptr++;
    1.59      }
    1.60  }
    1.61  
    1.62 @@ -204,9 +213,12 @@
    1.63  
    1.64  
    1.65      while (len % sizeof (Uint32) != 0) {
    1.66 -        *(ptr++) = d[l[*ptr]];
    1.67 -        if (args->channels > 1)
    1.68 -            *(ptr++) = d[r[*ptr]];
    1.69 +        *ptr = d[l[*ptr]];
    1.70 +        ptr++;
    1.71 +        if (args->channels > 1) {
    1.72 +            *ptr = d[r[*ptr]];
    1.73 +            ptr++;
    1.74 +        }
    1.75          len -= args->channels;
    1.76      }
    1.77  
    1.78 @@ -239,26 +251,16 @@
    1.79      int i;
    1.80  
    1.81      for (i = 0; i < len; i += sizeof (Uint16) * 2) {
    1.82 -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
    1.83 -        Sint16 sampl = (Sint16) (SDL_Swap16(*(ptr+0)) - 32768);
    1.84 -        Sint16 sampr = (Sint16) (SDL_Swap16(*(ptr+1)) - 32768);
    1.85 +        Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
    1.86 +        Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
    1.87          
    1.88          Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
    1.89                                      * args->distance_f) + 32768);
    1.90          Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
    1.91                                      * args->distance_f) + 32768);
    1.92  
    1.93 -        *(ptr++) = (Uint16) SDL_Swap16(swapl);
    1.94 -        *(ptr++) = (Uint16) SDL_Swap16(swapr);
    1.95 -#else
    1.96 -        Sint16 sampl = (Sint16) (*(ptr+0) - 32768);
    1.97 -        Sint16 sampr = (Sint16) (*(ptr+1) - 32768);
    1.98 -
    1.99 -        *(ptr++) = (Uint16) ((Sint16) (((float) sampl * args->left_f) 
   1.100 -                                    * args->distance_f) + 32768);
   1.101 -        *(ptr++) = (Uint16) ((Sint16) (((float) sampr * args->right_f) 
   1.102 -                                    * args->distance_f) + 32768);
   1.103 -#endif
   1.104 +        *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
   1.105 +        *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
   1.106      }
   1.107  }
   1.108  
   1.109 @@ -270,17 +272,12 @@
   1.110      int i;
   1.111  
   1.112      for (i = 0; i < len; i += sizeof (Sint16) * 2) {
   1.113 -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
   1.114 -        Sint16 swapl = (Sint16) ((((float) SDL_Swap16(*(ptr))) *
   1.115 +        Sint16 swapl = (Sint16) ((((float) SDL_SwapLE16(*(ptr+0))) *
   1.116                                      args->left_f) * args->distance_f);
   1.117 -        Sint16 swapr = (Sint16) ((((float) SDL_Swap16(*(ptr+1))) *
   1.118 +        Sint16 swapr = (Sint16) ((((float) SDL_SwapLE16(*(ptr+1))) *
   1.119                                      args->right_f) * args->distance_f);
   1.120 -        *(ptr++) = (Sint16) SDL_Swap16(swapl);
   1.121 -        *(ptr++) = (Sint16) SDL_Swap16(swapr);
   1.122 -#else
   1.123 -        *(ptr++) = (Sint16) ((((float) *ptr)*args->left_f)*args->distance_f);
   1.124 -        *(ptr++) = (Sint16) ((((float) *ptr)*args->right_f)*args->distance_f);
   1.125 -#endif
   1.126 +        *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
   1.127 +        *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
   1.128      }
   1.129  }
   1.130  
   1.131 @@ -292,26 +289,16 @@
   1.132      int i;
   1.133  
   1.134      for (i = 0; i < len; i += sizeof (Sint16) * 2) {
   1.135 -#if (SDL_BYTEORDER == SDL_LIL_ENDIAN)
   1.136 -        Sint16 sampl = (Sint16) (SDL_Swap16(*(ptr+0)) - 32768);
   1.137 -        Sint16 sampr = (Sint16) (SDL_Swap16(*(ptr+1)) - 32768);
   1.138 +        Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
   1.139 +        Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
   1.140          
   1.141          Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
   1.142                                      * args->distance_f) + 32768);
   1.143          Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
   1.144                                      * args->distance_f) + 32768);
   1.145  
   1.146 -        *(ptr++) = (Uint16) SDL_Swap16(swapl);
   1.147 -        *(ptr++) = (Uint16) SDL_Swap16(swapr);
   1.148 -#else
   1.149 -        Sint16 sampl = (Sint16) (*(ptr+0) - 32768);
   1.150 -        Sint16 sampr = (Sint16) (*(ptr+1) - 32768);
   1.151 -
   1.152 -        *(ptr++) = (Uint16) ((Sint16) (((float) sampl * args->left_f) 
   1.153 -                                    * args->distance_f) + 32768);
   1.154 -        *(ptr++) = (Uint16) ((Sint16) (((float) sampr * args->right_f) 
   1.155 -                                    * args->distance_f) + 32768);
   1.156 -#endif
   1.157 +        *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
   1.158 +        *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
   1.159      }
   1.160  }
   1.161  
   1.162 @@ -323,17 +310,12 @@
   1.163      int i;
   1.164  
   1.165      for (i = 0; i < len; i += sizeof (Sint16) * 2) {
   1.166 -#if (SDL_BYTEORDER == SDL_LIL_ENDIAN)
   1.167 -        Sint16 swapl = (Sint16) ((((float) SDL_Swap16(*(ptr))) *
   1.168 +        Sint16 swapl = (Sint16) ((((float) SDL_SwapBE16(*(ptr+0))) *
   1.169                                      args->left_f) * args->distance_f);
   1.170 -        Sint16 swapr = (Sint16) ((((float) SDL_Swap16(*(ptr+1))) *
   1.171 +        Sint16 swapr = (Sint16) ((((float) SDL_SwapBE16(*(ptr+1))) *
   1.172                                      args->right_f) * args->distance_f);
   1.173 -        *(ptr++) = (Sint16) SDL_Swap16(swapl);
   1.174 -        *(ptr++) = (Sint16) SDL_Swap16(swapr);
   1.175 -#else
   1.176 -        *(ptr++) = (Sint16) ((((float) *ptr)*args->left_f)*args->distance_f);
   1.177 -        *(ptr++) = (Sint16) ((((float) *ptr)*args->right_f)*args->distance_f);
   1.178 -#endif
   1.179 +        *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
   1.180 +        *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
   1.181      }
   1.182  }
   1.183