| version 1.1 | | version 1.2 |
|---|
| | |
| #include "piggy.h" | | #include "piggy.h" |
| #include "text.h" | | #include "text.h" |
| #include "midiallg.h" | | #include "midiallg.h" |
| | | #include "altsound.h" |
| | | |
| #include "kconfig.h" | | #include "kconfig.h" |
| | | |
| | |
| int digi_driver_port = 0; | | int digi_driver_port = 0; |
| int digi_driver_irq = 0; | | int digi_driver_irq = 0; |
| int digi_driver_dma = 0; | | int digi_driver_dma = 0; |
| //int digi_midi_type = 0; // Midi driver type | | |
| //int digi_midi_port = 0; // Midi driver port | | |
| static int digi_max_channels = 8; | | static int digi_max_channels = 8; |
| //static int digi_driver_rate = 11025; // rate to use driver at | | |
| //static int digi_dma_buffersize = 4096; // size of the dma buffer to use (4k) | | |
| int digi_timer_rate = 9943; // rate for the timer to go off to handle the driver system (120 Hz) | | int digi_timer_rate = 9943; // rate for the timer to go off to handle the driver system (120 Hz) |
| int digi_lomem = 0; | | int digi_lomem = 0; |
| static int digi_volume = _DIGI_MAX_VOLUME; // Max volume | | static int digi_volume = _DIGI_MAX_VOLUME; // Max volume |
| //static int midi_volume = 128/2; // Max volume | | |
| //static int midi_system_initialized = 0; | | |
| //static int digi_system_initialized = 0; | | |
| static int timer_system_initialized = 0; | | static int timer_system_initialized = 0; |
| static int digi_sound_locks[MAX_SOUNDS]; | | |
| //char digi_last_midi_song[16] = ""; | | |
| //char digi_last_melodic_bank[16] = ""; | | |
| //char digi_last_drum_bank[16] = ""; | | |
| char *digi_driver_path = NULL; | | char *digi_driver_path = NULL; |
| | | static int digi_sound_locks[MAX_SOUNDS]; |
| | | |
| extern int midi_volume; | | |
| | | |
| //static void * lpInstruments = NULL; // pointer to the instrument file | | |
| //static int InstrumentSize = 0; | | |
| //static void * lpDrums = NULL; // pointer to the drum file | | |
| //static int DrumSize = 0; | | |
| | | |
| // handle for the initialized MIDI song | | extern int midi_volume; |
| //MIDI *SongHandle = NULL; | | |
| | | |
| #define SOF_USED 1 // Set if this sample is used | | #define SOF_USED 1 // Set if this sample is used |
| #define SOF_PLAYING 2 // Set if this sample is playing on a channel | | #define SOF_PLAYING 2 // Set if this sample is playing on a channel |
| | |
| void digi_reset_digi_sounds(); | | void digi_reset_digi_sounds(); |
| int verify_channel_not_used_by_soundobjects( int channel ); | | int verify_channel_not_used_by_soundobjects( int channel ); |
| | | |
| int digi_xlat_sound(int soundno) | | |
| { | | |
| if ( soundno < 0 ) return -1; | | |
| | | |
| if ( digi_lomem ) { | | |
| soundno = AltSounds[soundno]; | | |
| if ( soundno == 255 ) return -1; | | |
| } | | |
| return Sounds[soundno]; | | |
| } | | |
| | | |
| void digi_close() { | | void digi_close() { |
| if (!Digi_initialized) return; | | if (!Digi_initialized) return; |
| | | |
| | |
| | | |
| ubyte * digi_lock_sound_data( int soundnum ) | | ubyte * digi_lock_sound_data( int soundnum ) |
| { | | { |
| | | digi_sound *playsound; |
| int i; | | int i; |
| | | |
| if ( !Digi_initialized ) return NULL; | | if ( !Digi_initialized ) |
| if ( digi_driver_board <= 0 ) return NULL; | | return NULL; |
| | | if ( digi_driver_board <= 0 ) |
| | | return NULL; |
| | | |
| if ( digi_sound_locks[soundnum] == 0 ) { | | playsound = Sounddat(soundnum); |
| | | |
| | | if ( digi_sound_locks[soundnum] == 0 ) |
| | | { |
| digi_total_locks++; | | digi_total_locks++; |
| //mprintf(( 0, "Total sound locks = %d\n", digi_total_locks )); | | //mprintf(( 0, "Total sound locks = %d\n", digi_total_locks )); |
| i = dpmi_lock_region( GameSounds[soundnum].data, GameSounds[soundnum].len ); | | i = dpmi_lock_region( playsound->data, playsound->len ); |
| if ( !i ) Error( "Error locking sound %d\n", soundnum ); | | if ( !i ) |
| | | Error( "Error locking sound %d\n", soundnum ); |
| } | | } |
| | | |
| digi_sound_locks[soundnum]++; | | digi_sound_locks[soundnum]++; |
| return GameSounds[soundnum].data; | | return playsound->data; |
| } | | } |
| | | |
| void digi_unlock_sound_data( int soundnum ) | | void digi_unlock_sound_data( int soundnum ) |
| { | | { |
| | | digi_sound *playsound; |
| int i; | | int i; |
| | | |
| if ( !Digi_initialized ) return; | | if ( !Digi_initialized ) |
| if ( digi_driver_board <= 0 ) return; | | return; |
| | | if ( digi_driver_board <= 0 ) |
| | | return; |
| | | |
| Assert( digi_sound_locks[soundnum] > 0 ); | | Assert( digi_sound_locks[soundnum] > 0 ); |
| | | |
| if ( digi_sound_locks[soundnum] == 1 ) { | | playsound = Sounddat(soundnum); |
| | | |
| | | if ( digi_sound_locks[soundnum] == 1 ) |
| | | { |
| digi_total_locks--; | | digi_total_locks--; |
| //mprintf(( 0, "Total sound locks = %d\n", digi_total_locks )); | | //mprintf(( 0, "Total sound locks = %d\n", digi_total_locks )); |
| i = dpmi_unlock_region( GameSounds[soundnum].data, GameSounds[soundnum].len ); | | i = dpmi_unlock_region( playsound->data, playsound->len ); |
| if ( !i ) Error( "Error unlocking sound %d\n", soundnum ); | | if ( !i ) |
| | | Error( "Error unlocking sound %d\n", soundnum ); |
| } | | } |
| | | |
| digi_sound_locks[soundnum]--; | | digi_sound_locks[soundnum]--; |
| } | | } |
| | | |
| | |
| SoundNums[i] = -1; | | SoundNums[i] = -1; |
| } | | } |
| } | | } |
| for (i=0; i<MAX_SOUNDS; i++ ) { | | for (i=0; i<MAX_SOUNDS; i++ ) |
| Assert( digi_sound_locks[i] == 0 ); | | Assert( digi_sound_locks[i] == 0 ); |
| } | | } |
| } | | |
| | | |
| void reset_slots_on_channel( int channel ) { | | void reset_slots_on_channel( int channel ) { |
| int i; | | int i; |
| | |
| return ret_slot; | | return ret_slot; |
| } | | } |
| | | |
| CHANNEL digi_start_sound(int soundnum, int volume, int pan) { | | CHANNEL digi_start_sound(int soundnum, int volume, int pan) |
| | | { |
| int i; | | int i; |
| int channel; | | int channel; |
| int slot; | | int slot; |
| | |
| slot = get_free_slot(); | | slot = get_free_slot(); |
| | | |
| digi_lock_sound_data(soundnum); | | digi_lock_sound_data(soundnum); |
| channel = play_sample(&GameSounds[soundnum], volume, pan >> 8, 1000, 0); | | channel = play_sample(Sounddat(soundnum), volume, pan >> 8, 1000, 0); |
| if (channel < 0) { | | if (channel < 0) |
| | | { |
| mprintf(( 1, "NOT ENOUGH SOUND SLOTS!!!\n" )); | | mprintf(( 1, "NOT ENOUGH SOUND SLOTS!!!\n" )); |
| digi_unlock_sound_data(soundnum); | | digi_unlock_sound_data(soundnum); |
| return -1; | | return -1; |
| | |
| | | |
| // find slots pointing to just allocated channel and kill sounds on it | | // find slots pointing to just allocated channel and kill sounds on it |
| // (because they can't be playing right now) | | // (because they can't be playing right now) |
| for (i=0; i<digi_max_channels; i++ ) { | | for (i=0; i<digi_max_channels; i++ ) |
| if (SampleHandles[i] == channel) { | | if (SampleHandles[i] == channel) |
| | | { |
| SampleHandles[i] = INVALID_CHANNEL; | | SampleHandles[i] = INVALID_CHANNEL; |
| if (SoundNums[i] != -1) { | | if (SoundNums[i] != -1) |
| | | { |
| digi_unlock_sound_data(SoundNums[i]); | | digi_unlock_sound_data(SoundNums[i]); |
| SoundNums[i] = -1; | | SoundNums[i] = -1; |
| } | | } |
| } | | } |
| } | | |
| | | |
| // fill slot with data of just started sample | | // fill slot with data of just started sample |
| SampleHandles[slot] = channel; | | SampleHandles[slot] = channel; |
| | |
| { | | { |
| int i; | | int i; |
| | | |
| soundno = digi_xlat_sound(soundno); | | |
| | | |
| for (i = 0; i < DIGI_VOICES; i++) | | for (i = 0; i < DIGI_VOICES; i++) |
| if (voice_check(i) == &GameSounds[soundno]) | | if (voice_check(i) == Sounddat(soundno)) |
| return 1; | | return 1; |
| | | |
| return 0; | | return 0; |
| } | | } |
| | | |
| void digi_play_sample_once( int soundno, fix max_volume ) { | | void digi_play_sample_once( int soundno, fix max_volume ) |
| | | { |
| int i; | | int i; |
| | | |
| #ifdef NEWDEMO | | #ifdef NEWDEMO |
| if ( Newdemo_state == ND_STATE_RECORDING ) | | if ( Newdemo_state == ND_STATE_RECORDING ) |
| newdemo_record_sound( soundno ); | | newdemo_record_sound( soundno ); |
| #endif | | #endif |
| soundno = digi_xlat_sound(soundno); | | |
| | | |
| if (!Digi_initialized) return; | | // soundno = digi_xlat_sound(soundno); |
| if (digi_driver_board<1) return; | | |
| | | |
| if (soundno < 0 ) return; | | if (!Digi_initialized) |
| | | return; |
| | | if (digi_driver_board<1) |
| | | return; |
| | | if (digi_xlat_sound(soundno) < 0 ) |
| | | return; |
| | | |
| for (i = 0; i < DIGI_VOICES; i++) | | for (i = 0; i < DIGI_VOICES; i++) |
| if (voice_check(i) == &GameSounds[soundno]) | | if (voice_check(i) == Sounddat(soundno)) |
| deallocate_voice(i); | | deallocate_voice(i); |
| | | |
| digi_start_sound(soundno, max_volume, F0_5); | | digi_start_sound(soundno, max_volume, F0_5); |
| } | | } |
| | | |
| void digi_play_sample( int soundno, fix max_volume ) { | | void digi_play_sample( int soundno, fix max_volume ) |
| | | { |
| | | |
| #ifdef NEWDEMO | | #ifdef NEWDEMO |
| if ( Newdemo_state == ND_STATE_RECORDING ) | | if ( Newdemo_state == ND_STATE_RECORDING ) |
| newdemo_record_sound( soundno ); | | newdemo_record_sound( soundno ); |
| #endif | | #endif |
| soundno = digi_xlat_sound(soundno); | | |
| | | |
| if (!Digi_initialized) return; | | |
| if (digi_driver_board<1) return; | | |
| | | |
| if (soundno < 0 ) return; | | if (!Digi_initialized) |
| | | return; |
| | | if (digi_driver_board<1) |
| | | return; |
| | | if (digi_xlat_sound(soundno) < 0 ) |
| | | return; |
| | | |
| digi_start_sound(soundno, max_volume, F0_5); | | digi_start_sound(soundno, max_volume, F0_5); |
| } | | } |
| | |
| no_dups = 1; | | no_dups = 1; |
| | | |
| #ifdef NEWDEMO | | #ifdef NEWDEMO |
| if ( Newdemo_state == ND_STATE_RECORDING ) { | | if ( Newdemo_state == ND_STATE_RECORDING ) |
| | | { |
| if ( no_dups ) | | if ( no_dups ) |
| newdemo_record_sound_3d_once( soundno, angle, volume ); | | newdemo_record_sound_3d_once( soundno, angle, volume ); |
| else | | else |
| newdemo_record_sound_3d( soundno, angle, volume ); | | newdemo_record_sound_3d( soundno, angle, volume ); |
| } | | } |
| #endif | | #endif |
| soundno = digi_xlat_sound(soundno); | | |
| | | |
| if (!Digi_initialized) return; | | if (!Digi_initialized) |
| if (digi_driver_board<1) return; | | return; |
| if (soundno < 0 ) return; | | if (digi_driver_board<1) |
| | | return; |
| | | if (digi_xlat_sound(soundno) < 0 ) |
| | | return; |
| | | |
| if (volume < MIN_VOLUME ) return; | | if (volume < MIN_VOLUME ) |
| | | return; |
| | | |
| digi_start_sound(soundno, volume, angle); | | digi_start_sound(soundno, volume, angle); |
| } | | } |
| | | |
| //-killed- void digi_set_midi_volume( int mvolume ) | | |
| //-killed- { | | |
| //-killed- int old_volume = midi_volume; | | |
| //-killed- | | |
| //-killed- if ( mvolume > 127 ) | | |
| //-killed- midi_volume = 127; | | |
| //-killed- else if ( mvolume < 0 ) | | |
| //-killed- midi_volume = 0; | | |
| //-killed- else | | |
| //-killed- midi_volume = mvolume; | | |
| //-killed- | | |
| //-killed- if ( (digi_midi_type > 0) ) { | | |
| //-killed- if ( (old_volume < 1) && ( midi_volume > 1 ) ) { | | |
| //-killed- if (SongHandle == NULL ) | | |
| //-killed- digi_play_midi_song( digi_last_midi_song, digi_last_melodic_bank, digi_last_drum_bank, 1 ); | | |
| //-killed- } | | |
| //-killed- set_volume(-1, midi_volume * 2 + (midi_volume & 1)); | | |
| //-killed- } | | |
| //-killed- } | | |
| | | |
| void digi_set_digi_volume( int dvolume ) | | void digi_set_digi_volume( int dvolume ) |
| { | | { |
| dvolume = fixmuldiv( dvolume, _DIGI_MAX_VOLUME, 0x7fff); | | dvolume = fixmuldiv( dvolume, _DIGI_MAX_VOLUME, 0x7fff); |
| | |
| // mprintf(( 1, "Volume: 0x%x and 0x%x\n", digi_volume, midi_volume )); | | // mprintf(( 1, "Volume: 0x%x and 0x%x\n", digi_volume, midi_volume )); |
| } | | } |
| | | |
| //-killed- void digi_stop_current_song() | | |
| //-killed- { | | |
| //-killed- if (SongHandle) { | | |
| //-killed- destroy_midi(SongHandle); | | |
| //-killed- SongHandle = NULL; | | |
| //-killed- } | | |
| //-killed- } | | |
| //-killed- | | |
| //-killed- void digi_play_midi_song( char * filename, char * melodic_bank, char * drum_bank, int loop ) | | |
| //-killed- { | | |
| //-killed- //char fname[128]; | | |
| //-killed- | | |
| //-killed- if (!Digi_initialized) return; | | |
| //-killed- if ( digi_midi_type <= 0 ) return; | | |
| //-killed- | | |
| //-killed- digi_stop_current_song(); | | |
| //-killed- | | |
| //-killed- if ( filename == NULL ) return; | | |
| //-killed- | | |
| //-killed- strcpy( digi_last_midi_song, filename ); | | |
| //-killed- strcpy( digi_last_melodic_bank, melodic_bank ); | | |
| //-killed- strcpy( digi_last_drum_bank, drum_bank ); | | |
| //-killed- | | |
| //-killed- if ( midi_volume < 1 ) | | |
| //-killed- | | |
| //-killed- SongHandle = NULL; | | |
| //-killed- | | |
| //-killed- #if 0 /* needs bank loading to sound right */ | | |
| //-killed- if (midi_card <= 4) { /* FM cards */ | | |
| //-killed- int sl; | | |
| //-killed- sl = strlen( filename ); | | |
| //-killed- strcpy( fname, filename ); | | |
| //-killed- fname[sl-1] = 'q'; | | |
| //-killed- SongHandle = load_hmp(fname); | | |
| //-killed- } | | |
| //-killed- #endif | | |
| //-killed- | | |
| //-killed- if ( !SongHandle ) | | |
| //-killed- SongHandle = load_hmp(filename); | | |
| //-killed- | | |
| //-killed- if (SongHandle) { | | |
| //-killed- if (play_midi(SongHandle, loop)) { | | |
| //-killed- destroy_midi(SongHandle); | | |
| //-killed- SongHandle = NULL; | | |
| //-killed- } | | |
| //-killed- } | | |
| //-killed- if (!SongHandle) { | | |
| //-killed- mprintf( (1, "\nAllegro Error : %s", allegro_error )); | | |
| //-killed- } | | |
| //-killed- } | | |
| | | |
| void digi_get_sound_loc( vms_matrix * listener, vms_vector * listener_pos, int listener_seg, vms_vector * sound_pos, int sound_seg, fix max_volume, int *volume, int *pan, fix max_distance ) | | void digi_get_sound_loc( vms_matrix * listener, vms_vector * listener_pos, int listener_seg, vms_vector * sound_pos, int sound_seg, fix max_volume, int *volume, int *pan, fix max_distance ) |
| { | | { |
| vms_vector vector_to_sound; | | vms_vector vector_to_sound; |
| | |
| | | |
| void digi_start_sound_object(int i) | | void digi_start_sound_object(int i) |
| { | | { |
| if (!Digi_initialized) return; | | if (!Digi_initialized) |
| if (digi_driver_board<1) return; | | return; |
| | | if (digi_driver_board<1) |
| | | return; |
| | | |
| // this doesn't use digi_lock_sound because these sounds are | | // this doesn't use digi_lock_sound because these sounds are |
| // never unlocked, so we couldn't check if we unlocked all other sounds then | | // never unlocked, so we couldn't check if we unlocked all other sounds then |
| if (!dpmi_lock_region( GameSounds[SoundObjects[i].soundnum].data, GameSounds[SoundObjects[i].soundnum].len )) | | if (!dpmi_lock_region( Sounddat(SoundObjects[i].soundnum)->data, Sounddat(SoundObjects[i].soundnum)->len )) |
| Error( "Error locking sound object %d\n", SoundObjects[i].soundnum ); | | Error( "Error locking sound object %d\n", SoundObjects[i].soundnum ); |
| | | |
| SoundObjects[i].signature=next_signature++; | | SoundObjects[i].signature=next_signature++; |
| | | |
| SoundObjects[i].handle = play_sample(&GameSounds[SoundObjects[i].soundnum], | | SoundObjects[i].handle = play_sample(Sounddat(SoundObjects[i].soundnum), |
| fixmuldiv(SoundObjects[i].volume,digi_volume,F1_0), /* 0-255 */ | | fixmuldiv(SoundObjects[i].volume,digi_volume,F1_0), /* 0-255 */ |
| SoundObjects[i].pan >> 8, /* 0-255 */ | | SoundObjects[i].pan >> 8, /* 0-255 */ |
| 1000, | | 1000, |
| (SoundObjects[i].flags & SOF_PLAY_FOREVER) ? 1 : 0 | | (SoundObjects[i].flags & SOF_PLAY_FOREVER) ? 1 : 0 |
| ); | | ); |
| if (SoundObjects[i].handle < 0) { | | if (SoundObjects[i].handle < 0) |
| | | { |
| mprintf(( 1, "NOT ENOUGH SOUND SLOTS!!! (SoundObject)\n" )); | | mprintf(( 1, "NOT ENOUGH SOUND SLOTS!!! (SoundObject)\n" )); |
| //digi_unlock_sound(SoundObjects[i].soundnum); //never unlocked... | | //digi_unlock_sound(SoundObjects[i].soundnum); //never unlocked... |
| } else { | | } |
| | | else |
| | | { |
| SoundObjects[i].flags |= SOF_PLAYING; | | SoundObjects[i].flags |= SOF_PLAYING; |
| reset_slots_on_channel( SoundObjects[i].handle ); | | reset_slots_on_channel( SoundObjects[i].handle ); |
| } | | } |
| } | | } |
| | | |
| int digi_link_sound_to_object2( int org_soundnum, short objnum, int forever, fix max_volume, fix max_distance ) | | int digi_link_sound_to_object2( int soundnum, short objnum, int forever, fix max_volume, fix max_distance ) |
| { | | { |
| int i,volume,pan; | | int i,volume,pan; |
| object * objp; | | object * objp; |
| int soundnum; | | |
| | | |
| soundnum = digi_xlat_sound(org_soundnum); | | |
| | | |
| if ( max_volume < 0 ) return -1; | | |
| // if ( max_volume > F1_0 ) max_volume = F1_0; | | |
| | | |
| if (!Digi_initialized) return -1; | | if ( max_volume < 0 ) |
| if (soundnum < 0 ) return -1; | | return -1; |
| if (GameSounds[soundnum].data==NULL) { | | if (!Digi_initialized) |
| | | return -1; |
| | | if (digi_xlat_sound(soundnum) < 0 ) |
| | | return -1; |
| | | if (Sounddat(soundnum)->data==NULL) |
| | | { |
| Int3(); | | Int3(); |
| return -1; | | return -1; |
| } | | } |
| if ((objnum<0)||(objnum>Highest_object_index)) | | if ((objnum<0)||(objnum>Highest_object_index)) |
| return -1; | | return -1; |
| if (digi_driver_board<1) return -1; | | if (digi_driver_board<1) |
| | | return -1; |
| | | |
| | | |
| if ( !forever ) { | | if ( !forever ) |
| | | { |
| // Hack to keep sounds from building up... | | // Hack to keep sounds from building up... |
| digi_get_sound_loc( &Viewer->orient, &Viewer->pos, Viewer->segnum, &Objects[objnum].pos, Objects[objnum].segnum, max_volume,&volume, &pan, max_distance ); | | digi_get_sound_loc( &Viewer->orient, &Viewer->pos, Viewer->segnum, &Objects[objnum].pos, Objects[objnum].segnum, max_volume,&volume, &pan, max_distance ); |
| digi_play_sample_3d( org_soundnum, pan, volume, 0 ); | | digi_play_sample_3d( soundnum, pan, volume, 0 ); |
| return -1; | | return -1; |
| } | | } |
| | | |
| | |
| if (SoundObjects[i].flags==0) | | if (SoundObjects[i].flags==0) |
| break; | | break; |
| | | |
| if (i==MAX_SOUND_OBJECTS) { | | if (i==MAX_SOUND_OBJECTS) |
| | | { |
| mprintf((1, "Too many sound objects!\n" )); | | mprintf((1, "Too many sound objects!\n" )); |
| return -1; | | return -1; |
| } | | } |
| | |
| return digi_link_sound_to_object2( soundnum, objnum, forever, max_volume, 256*F1_0 ); | | return digi_link_sound_to_object2( soundnum, objnum, forever, max_volume, 256*F1_0 ); |
| } | | } |
| | | |
| int digi_link_sound_to_pos2( int org_soundnum, short segnum, short sidenum, vms_vector * pos, int forever, fix max_volume, fix max_distance ) | | int digi_link_sound_to_pos2( int soundnum, short segnum, short sidenum, vms_vector * pos, int forever, fix max_volume, fix max_distance ) |
| { | | { |
| int i, volume, pan; | | int i, volume, pan; |
| int soundnum; | | |
| | | |
| soundnum = digi_xlat_sound(org_soundnum); | | |
| | | |
| if ( max_volume < 0 ) return -1; | | if ( max_volume < 0 ) |
| // if ( max_volume > F1_0 ) max_volume = F1_0; | | return -1; |
| | | if (!Digi_initialized) |
| if (!Digi_initialized) return -1; | | return -1; |
| if (soundnum < 0 ) return -1; | | if (soundnum < 0 ) |
| if (GameSounds[soundnum].data==NULL) { | | return -1; |
| | | if (Sounddat(soundnum)->data==NULL) |
| | | { |
| Int3(); | | Int3(); |
| return -1; | | return -1; |
| } | | } |
| if (digi_driver_board<1) return -1; | | if (digi_driver_board<1) |
| | | return -1; |
| if ((segnum<0)||(segnum>Highest_segment_index)) | | if ((segnum<0)||(segnum>Highest_segment_index)) |
| return -1; | | return -1; |
| | | |
| if ( !forever ) { | | if ( !forever ) |
| | | { |
| // Hack to keep sounds from building up... | | // Hack to keep sounds from building up... |
| digi_get_sound_loc( &Viewer->orient, &Viewer->pos, Viewer->segnum, pos, segnum, max_volume, &volume, &pan, max_distance ); | | digi_get_sound_loc( &Viewer->orient, &Viewer->pos, Viewer->segnum, pos, segnum, max_volume, &volume, &pan, max_distance ); |
| digi_play_sample_3d( org_soundnum, pan, volume, 0 ); | | digi_play_sample_3d( soundnum, pan, volume, 0 ); |
| return -1; | | return -1; |
| } | | } |
| | | |
| | |
| if (SoundObjects[i].flags==0) | | if (SoundObjects[i].flags==0) |
| break; | | break; |
| | | |
| if (i==MAX_SOUND_OBJECTS) { | | if (i==MAX_SOUND_OBJECTS) |
| | | { |
| mprintf((1, "Too many sound objects!\n" )); | | mprintf((1, "Too many sound objects!\n" )); |
| return -1; | | return -1; |
| } | | } |
| | |
| { | | { |
| int i,killed; | | int i,killed; |
| | | |
| soundnum = digi_xlat_sound(soundnum); | | if (!Digi_initialized) |
| | | return; |
| if (!Digi_initialized) return; | | if (digi_driver_board<1) |
| if (digi_driver_board<1) return; | | return; |
| | | |
| killed = 0; | | killed = 0; |
| | | |
| for (i=0; i<MAX_SOUND_OBJECTS; i++ ) { | | for (i=0; i<MAX_SOUND_OBJECTS; i++ ) |
| if ( (SoundObjects[i].flags & SOF_USED) && (SoundObjects[i].flags & SOF_LINK_TO_POS) ) { | | { |
| if ((SoundObjects[i].lp_segnum == segnum) && (SoundObjects[i].soundnum==soundnum ) && (SoundObjects[i].lp_sidenum==sidenum) ) { | | if ( (SoundObjects[i].flags & SOF_USED) && (SoundObjects[i].flags & SOF_LINK_TO_POS) ) |
| if ( SoundObjects[i].flags & SOF_PLAYING ) { | | { |
| | | if ((SoundObjects[i].lp_segnum == segnum) && (SoundObjects[i].soundnum==soundnum ) && (SoundObjects[i].lp_sidenum==sidenum) ) |
| | | { |
| | | if ( SoundObjects[i].flags & SOF_PLAYING ) |
| | | { |
| deallocate_voice(SoundObjects[i].handle); | | deallocate_voice(SoundObjects[i].handle); |
| } | | } |
| SoundObjects[i].flags = 0; // Mark as dead, so some other sound can use this sound | | SoundObjects[i].flags = 0; // Mark as dead, so some other sound can use this sound |
| | |
| } | | } |
| // If this assert happens, it means that there were 2 sounds | | // If this assert happens, it means that there were 2 sounds |
| // that got deleted. Weird, get John. | | // that got deleted. Weird, get John. |
| if ( killed > 1 ) { | | if ( killed > 1 ) |
| | | { |
| mprintf( (1, "ERROR: More than 1 sounds were deleted from seg %d\n", segnum )); | | mprintf( (1, "ERROR: More than 1 sounds were deleted from seg %d\n", segnum )); |
| } | | } |
| } | | } |
| | |
| { | | { |
| int i,killed; | | int i,killed; |
| | | |
| if (!Digi_initialized) return; | | if (!Digi_initialized) |
| if (digi_driver_board<1) return; | | return; |
| | | if (digi_driver_board<1) |
| | | return; |
| | | |
| killed = 0; | | killed = 0; |
| | | |
| for (i=0; i<MAX_SOUND_OBJECTS; i++ ) { | | for (i=0; i<MAX_SOUND_OBJECTS; i++ ) |
| if ( (SoundObjects[i].flags & SOF_USED) && (SoundObjects[i].flags & SOF_LINK_TO_OBJ ) ) { | | { |
| if (SoundObjects[i].lo_objnum == objnum) { | | if ( (SoundObjects[i].flags & SOF_USED) && (SoundObjects[i].flags & SOF_LINK_TO_OBJ ) ) |
| if ( SoundObjects[i].flags & SOF_PLAYING ) { | | { |
| | | if (SoundObjects[i].lo_objnum == objnum) |
| | | { |
| | | if ( SoundObjects[i].flags & SOF_PLAYING ) |
| | | { |
| deallocate_voice(SoundObjects[i].handle ); | | deallocate_voice(SoundObjects[i].handle ); |
| } | | } |
| SoundObjects[i].flags = 0; // Mark as dead, so some other sound can use this sound | | SoundObjects[i].flags = 0; // Mark as dead, so some other sound can use this sound |
| | |
| } | | } |
| } | | } |
| } | | } |
| | | |
| // If this assert happens, it means that there were 2 sounds | | // If this assert happens, it means that there were 2 sounds |
| // that got deleted. Weird, get John. | | // that got deleted. Weird, get John. |
| if ( killed > 1 ) { | | if ( killed > 1 ) |
| | | { |
| mprintf( (1, "ERROR: More than 1 sounds were deleted from object %d\n", objnum )); | | mprintf( (1, "ERROR: More than 1 sounds were deleted from object %d\n", objnum )); |
| } | | } |
| } | | } |
| | |
| | | |
| if (!Digi_initialized) return; | | if (!Digi_initialized) return; |
| | | |
| // if ( digi_midi_type > 0 ) { | | |
| // if (SongHandle) { | | |
| // destroy_midi(SongHandle); | | |
| // SongHandle = NULL; | | |
| // } | | |
| // } | | |
| digi_midi_stop(); | | digi_midi_stop(); |
| | | |
| if (digi_driver_board>0) { | | if (digi_driver_board>0) { |