diff --git a/rott/fx_man.h b/rott/fx_man.h index 8b2a6ed..e74b55a 100644 --- a/rott/fx_man.h +++ b/rott/fx_man.h @@ -80,6 +80,9 @@ int FX_SoundActive( int handle ); int FX_StopSound( int handle ); int FX_StopAllSounds( void ); +int FX_SetXY(int handle, int x, int y); +int FX_AllSoundsRTP(void); + #if 0 int FX_StartDemandFeedPlayback( void ( *function )( char **ptr, unsigned long *length ), int rate, int pitchoffset, int vol, int left, int right, diff --git a/rott/fx_mixer.c b/rott/fx_mixer.c index 173ef42..473ecc3 100644 --- a/rott/fx_mixer.c +++ b/rott/fx_mixer.c @@ -44,6 +44,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static struct { sound_t *sfx; + int x, y; } channels[MAX_CHANNELS]; static int FX_Installed = 0; @@ -209,7 +210,7 @@ int FX_StopSound(int handle) channels[handle].sfx->count--; } - channels[handle].sfx = NULL; + memset(&channels[handle], 0, sizeof(channels[handle])); } return FX_Ok; @@ -407,6 +408,16 @@ int FX_Play(int handle, int sndnum, int pitchoffset, int angle, int distance, return -1; } +int FX_SetXY(int handle, int x, int y) +{ + CHECK_HANDLE(handle); + + channels[handle].x = x; + channels[handle].y = y; + + return FX_Ok; +} + int FX_SetPitch(int handle, int pitchoffset) { return FX_Ok; @@ -433,3 +444,25 @@ int FX_StopAllSounds(void) return FX_Ok; } + +int FX_AllSoundsRTP(void) +{ + int i; + + for (i = 0; i < MAX_CHANNELS; i++) + { + if (FX_SoundActive(i)) + { + if (channels[i].x | channels[i].y) + { + SD_PanRTP(i, channels[i].x, channels[i].y); + } + } + else + { + FX_StopSound(i); + } + } + + return FX_Ok; +} diff --git a/rott/rt_playr.c b/rott/rt_playr.c index 669dfe7..51bfa10 100644 --- a/rott/rt_playr.c +++ b/rott/rt_playr.c @@ -5938,6 +5938,8 @@ void T_Player (objtype *ob) } #endif + // [FG] update all sound pannings relative to the player + SD_AllSoundsRTP(); } diff --git a/rott/rt_sound.c b/rott/rt_sound.c index f93672d..a0f2514 100644 --- a/rott/rt_sound.c +++ b/rott/rt_sound.c @@ -413,6 +413,8 @@ int SD_PlaySoundRTP ( int sndnum, int x, int y ) voice = SD_PlayIt ( sndnum, angle, distance, pitch ); + FX_SetXY(voice, x, y); + return voice; } @@ -499,12 +501,19 @@ void SD_PanRTP ( int handle, int x, int y ) status = FX_Pan3D ( handle, angle, distance ); + FX_SetXY(handle, x, y); + if (status != FX_Ok) { //TODO: This code does nothing. } } +void SD_AllSoundsRTP(void) +{ + FX_AllSoundsRTP(); +} + //*************************************************************************** // // SD_SetPan - set the pan of a sample diff --git a/rott/rt_sound.h b/rott/rt_sound.h index d8a3b74..a1ecbf2 100644 --- a/rott/rt_sound.h +++ b/rott/rt_sound.h @@ -508,6 +508,7 @@ int SD_Play3D ( int sndnum, int angle, int distance ); int SD_PlayPitchedSound ( int sndnum, int volume, int pitch ); void SD_SetSoundPitch ( int sndnum, int pitch ); boolean SD_SoundOkay ( int sndnum ); +void SD_AllSoundsRTP(void); //*************************************************************************** //