Fixes from Bugzilla #110.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 23 Jun 2006 09:07:19 +0000
changeset 330ffdb98273d59
parent 329 b03d336a000f
child 331 1f08ed9bccbc
Fixes from Bugzilla #110.
effect_position.c
     1.1 --- a/effect_position.c	Wed May 17 06:20:29 2006 +0000
     1.2 +++ b/effect_position.c	Fri Jun 23 09:07:19 2006 +0000
     1.3 @@ -622,9 +622,9 @@
     1.4                                      * args->distance_f) + 32768);
     1.5          Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
     1.6                                      * args->distance_f) + 32768);
     1.7 -        Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_f)
     1.8 +        Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
     1.9                                      * args->distance_f) + 32768);
    1.10 -        Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_f)
    1.11 +        Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
    1.12                                      * args->distance_f) + 32768);
    1.13  
    1.14  	switch (args->room_angle) {
    1.15 @@ -668,18 +668,18 @@
    1.16          Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768);
    1.17          Sint16 sampce = (Sint16) (SDL_SwapLE16(*(ptr+4)) - 32768);
    1.18          Sint16 sampwf = (Sint16) (SDL_SwapLE16(*(ptr+5)) - 32768);
    1.19 -        
    1.20 +
    1.21          Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
    1.22                                      * args->distance_f) + 32768);
    1.23          Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
    1.24                                      * args->distance_f) + 32768);
    1.25 -        Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_f)
    1.26 +        Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
    1.27                                      * args->distance_f) + 32768);
    1.28 -        Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_f)
    1.29 +        Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
    1.30                                      * args->distance_f) + 32768);
    1.31 -        Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->left_f)
    1.32 +        Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f)
    1.33                                      * args->distance_f) + 32768);
    1.34 -        Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->right_f)
    1.35 +        Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f)
    1.36                                      * args->distance_f) + 32768);
    1.37  
    1.38  	switch (args->room_angle) {
    1.39 @@ -1417,12 +1417,16 @@
    1.40          return(1);
    1.41  
    1.42      if (channels > 2) {
    1.43 +        /* left = right = 255 => angle = 0, to unregister effect as when channels = 2 */
    1.44      	/* left = 255 =>  angle = -90;  left = 0 => angle = +89 */
    1.45 -    	int angle = (int)left;
    1.46 -    	angle = 127 - angle;
    1.47 -	angle = -angle;
    1.48 -    	angle = angle * 90 / 128; /* Make it larger for more effect? */
    1.49 -	return( Mix_SetPosition(channel, angle, 0) );
    1.50 +        int angle = 0;
    1.51 +        if ((left != 255) || (right != 255)) {
    1.52 +	    angle = (int)left;
    1.53 +    	    angle = 127 - angle;
    1.54 +	    angle = -angle;
    1.55 +    	    angle = angle * 90 / 128; /* Make it larger for more effect? */
    1.56 +        }
    1.57 +        return( Mix_SetPosition(channel, angle, 0) );
    1.58      }
    1.59  
    1.60      f = get_position_effect_func(format, channels);
    1.61 @@ -1434,10 +1438,12 @@
    1.62          return(0);
    1.63  
    1.64          /* it's a no-op; unregister the effect, if it's registered. */
    1.65 -    if ((args->distance_u8 == 255) && (left == 255) &&
    1.66 -        (right == 255) && (args->in_use))
    1.67 -    {
    1.68 -        return(Mix_UnregisterEffect(channel, f));
    1.69 +    if ((args->distance_u8 == 255) && (left == 255) && (right == 255)) {
    1.70 +        if (args->in_use) {
    1.71 +            return(Mix_UnregisterEffect(channel, f));
    1.72 +        } else {
    1.73 +	  return(1);
    1.74 +        }
    1.75      }
    1.76  
    1.77      args->left_u8 = left;
    1.78 @@ -1474,10 +1480,12 @@
    1.79      distance = 255 - distance;  /* flip it to our scale. */
    1.80  
    1.81          /* it's a no-op; unregister the effect, if it's registered. */
    1.82 -    if ((distance == 255) && (args->left_u8 == 255) &&
    1.83 -        (args->right_u8 == 255) && (args->in_use))
    1.84 -    {
    1.85 -        return(Mix_UnregisterEffect(channel, f));
    1.86 +    if ((distance == 255) && (args->left_u8 == 255) && (args->right_u8 == 255)) {
    1.87 +        if (args->in_use) {
    1.88 +            return(Mix_UnregisterEffect(channel, f));
    1.89 +        } else {
    1.90 +            return(1);
    1.91 +        }
    1.92      }
    1.93  
    1.94      args->distance_u8 = distance;
    1.95 @@ -1513,8 +1521,13 @@
    1.96          return(0);
    1.97  
    1.98          /* it's a no-op; unregister the effect, if it's registered. */
    1.99 -    if ((!distance) && (!angle) && (args->in_use))
   1.100 -        return(Mix_UnregisterEffect(channel, f));
   1.101 +    if ((!distance) && (!angle)) {
   1.102 +        if (args->in_use) {
   1.103 +            return(Mix_UnregisterEffect(channel, f));
   1.104 +        } else {
   1.105 +	  return(1);
   1.106 +	}
   1.107 +    }
   1.108  
   1.109      if (channels == 2)
   1.110      {
   1.111 @@ -1547,8 +1560,8 @@
   1.112      args->right_rear_f = ((float) speaker_amplitude[3]) / 255.0f;
   1.113      args->center_u8 = speaker_amplitude[4];
   1.114      args->center_f = ((float) speaker_amplitude[4]) / 255.0f;
   1.115 -    args->lfe_u8 = 255;
   1.116 -    args->lfe_f = 255.0f;
   1.117 +    args->lfe_u8 = speaker_amplitude[5];
   1.118 +    args->lfe_f = ((float) speaker_amplitude[5]) / 255.0f;
   1.119      args->distance_u8 = distance;
   1.120      args->distance_f = ((float) distance) / 255.0f;
   1.121      args->room_angle = room_angle;