From 0ecaecaa832326e3953f35a4553fab1ee5182099 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Mon, 29 Nov 2004 05:25:58 +0000 Subject: [PATCH] ripped object stuff out of digi.c, now using digiobj.c. get rid of a bunch of kludges, sound should be more true to original game now --- ChangeLog | 5 + arch/sdl/digi.c | 609 ++++++--------------------------------- arch/win32/midi.c | 35 ++- main/Makefile.am | 2 +- main/digi.h | 42 ++- main/{old => }/digiobj.c | 58 ++-- main/kludge.c | 37 +-- 7 files changed, 191 insertions(+), 597 deletions(-) rename main/{old => }/digiobj.c (96%) diff --git a/ChangeLog b/ChangeLog index 63bd8087..c2de9a78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2004-11-28 Bradley Bell + * arch/sdl/digi.c, arch/win32/midi.c, main/Makefile.am, + main/digiobj.c, main/digi.h, main/kludge.c, main/old/digiobj.c: + ripped object stuff out of digi.c, now using digiobj.c. get rid of + a bunch of kludges, sound should be more true to original game now + * acinclude.m4, cygconf: put sdl.m4 in acinclude.m4, to make autogen simpler diff --git a/arch/sdl/digi.c b/arch/sdl/digi.c index 5a2a2086..ebdaa52d 100644 --- a/arch/sdl/digi.c +++ b/arch/sdl/digi.c @@ -1,4 +1,4 @@ -/* $Id: digi.c,v 1.17 2004-11-28 05:16:38 btb Exp $ */ +/* $Id: digi.c,v 1.18 2004-11-29 05:25:58 btb Exp $ */ /* * * SDL digital audio support @@ -111,52 +111,6 @@ static const Uint8 mix8[] = 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, }; -#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_LINK_TO_OBJ 4 // Sound is linked to a moving object. If object dies, then finishes play and quits. -#define SOF_LINK_TO_POS 8 // Sound is linked to segment, pos -#define SOF_PLAY_FOREVER 16 // Play forever (or until level is stopped), otherwise plays once -#define SOF_PERMANANT 32 // Part of the level, like a waterfall or fan - -typedef struct sound_object { - short signature; // A unique signature to this sound - ubyte flags; // Used to tell if this slot is used and/or currently playing, and how long. -#ifdef _MSC_VER - ubyte pad; // needed for alignment -#endif - fix max_volume; // Max volume that this sound is playing at - fix max_distance; // The max distance that this sound can be heard at... - int volume; // Volume that this sound is playing at - int pan; // Pan value that this sound is playing at - int handle; // What handle this sound is playing on. Valid only if SOF_PLAYING is set. - short soundnum; // The sound number that is playing -#ifdef _MSC_VER - short pad2; // needed for alignment -#endif - int loop_start; // The start point of the loop. -1 means no loop - int loop_end; // The end point of the loop - union { - struct { - short segnum; // Used if SOF_LINK_TO_POS field is used - short sidenum; - vms_vector position; - }pos; - struct { - short objnum; // Used if SOF_LINK_TO_OBJ field is used - short objsignature; - }obj; - }link; -} sound_object; -#define lp_segnum link.pos.segnum -#define lp_sidenum link.pos.sidenum -#define lp_position link.pos.position - -#define lo_objnum link.obj.objnum -#define lo_objsignature link.obj.objsignature - -#define MAX_SOUND_OBJECTS 16 -sound_object SoundObjects[MAX_SOUND_OBJECTS]; -short next_signature=0; //added/changed on 980905 by adb to make sfx volume work, on 990221 by adb changed F1_0 to F1_0 / 2 #define SOUND_MAX_VOLUME (F1_0 / 2) @@ -164,8 +118,6 @@ short next_signature=0; int digi_volume = SOUND_MAX_VOLUME; //end edit by adb -int digi_lomem = 0; - static int digi_initialised = 0; struct sound_slot { @@ -182,7 +134,6 @@ struct sound_slot { } SoundSlots[MAX_SOUND_SLOTS]; static SDL_AudioSpec WaveSpec; -static int digi_sounds_initialized = 0; //added on 980905 by adb to add rotating/volume based sound kill system static int digi_max_channels = 16; @@ -285,18 +236,12 @@ void digi_close() SDL_CloseAudio(); } -/* Find the sound which actually equates to a sound number */ -int digi_xlat_sound(int soundno) +void digi_stop_all_channels() { - if ( soundno < 0 ) return -1; - - if ( digi_lomem ) { - soundno = AltSounds[soundno]; - if ( soundno == 255 ) return -1; - } - if (Sounds[soundno] == 255) return -1; + int i; - return Sounds[soundno]; + for (i = 0; i < MAX_SOUND_SLOTS; i++) + digi_stop_sound(i); } static int get_free_slot() @@ -308,7 +253,7 @@ static int get_free_slot() return -1; } -int digi_start_sound(int soundnum, fix volume, fix pan, int looping, int loop_start, int loop_end, int soundobj) +int digi_start_sound(short soundnum, fix volume, int pan, int looping, int loop_start, int loop_end, int persistent) { int ntries; int slot; @@ -360,468 +305,37 @@ TryNextChannel: return slot; } - //added on 980905 by adb to add sound kill system from original sos digi.c -void reset_sounds_on_channel( int channel ) -{ - int i; - - for (i=0; i= max(1,digi_get_max_channels()/4)) ) - return -1; -#endif - - SoundSlots[slot].soundno = SoundObjects[obj].soundnum; - SoundSlots[slot].samples = GameSounds[SoundObjects[obj].soundnum].data; - SoundSlots[slot].length = GameSounds[SoundObjects[obj].soundnum].length; - SoundSlots[slot].volume = fixmul(digi_volume, SoundObjects[obj].volume); - SoundSlots[slot].pan = SoundObjects[obj].pan; - SoundSlots[slot].position = 0; - SoundSlots[slot].looped = (SoundObjects[obj].flags & SOF_PLAY_FOREVER); - SoundSlots[slot].playing = 1; - - SoundObjects[obj].signature = next_signature++; - SoundObjects[obj].handle = slot; - - SoundObjects[obj].flags |= SOF_PLAYING; - //added on 980905 by adb to add sound kill system from original sos digi.c - reset_sounds_on_channel(slot); - //end edit by adb - - return 0; -} - - -// Play the given sound number. -// Volume is max at F1_0. -void digi_play_sample( int soundno, fix max_volume ) +// Returns the channel a sound number is playing on, or +// -1 if none. +int digi_find_channel(int soundno) { -#ifdef NEWDEMO - if ( Newdemo_state == ND_STATE_RECORDING ) - newdemo_record_sound( soundno ); -#endif - soundno = digi_xlat_sound(soundno); - - if (!digi_initialised) return; - - if (soundno < 0 ) return; - - digi_start_sound(soundno, max_volume, F0_5, 0, 0, 0, 0); -} - -// Play the given sound number. If the sound is already playing, -// restart it. -void digi_play_sample_once( int soundno, fix max_volume ) -{ - int i; - -#ifdef NEWDEMO - if ( Newdemo_state == ND_STATE_RECORDING ) - newdemo_record_sound( soundno ); -#endif - soundno = digi_xlat_sound(soundno); - - if (!digi_initialised) return; - - if (soundno < 0 ) return; - - for (i=0; i < MAX_SOUND_SLOTS; i++) - if (SoundSlots[i].soundno == soundno) - SoundSlots[i].playing = 0; - digi_start_sound(soundno, max_volume, F0_5, 0, 0, 0, 0); - -} - -void digi_play_sample_3d( int soundno, int angle, int volume, int no_dups ) // Volume from 0-0x7fff -{ - no_dups = 1; - -#ifdef NEWDEMO - if ( Newdemo_state == ND_STATE_RECORDING ) { - if ( no_dups ) - newdemo_record_sound_3d_once( soundno, angle, volume ); - else - newdemo_record_sound_3d( soundno, angle, volume ); - } -#endif - soundno = digi_xlat_sound(soundno); - - if (!digi_initialised) return; - if (soundno < 0 ) return; - - if (volume < MIN_VOLUME ) return; - digi_start_sound(soundno, volume, angle, 0, 0, 0, 0); -} - -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; - fix angle_from_ear, cosang,sinang; - fix distance; - fix path_distance; - - *volume = 0; - *pan = 0; - - max_distance = (max_distance*5)/4; // Make all sounds travel 1.25 times as far. - - // Warning: Made the vm_vec_normalized_dir be vm_vec_normalized_dir_quick and got illegal values to acos in the fang computation. - distance = vm_vec_normalized_dir_quick( &vector_to_sound, sound_pos, listener_pos ); - - if (distance < max_distance ) { - int num_search_segs = f2i(max_distance/20); - if ( num_search_segs < 1 ) num_search_segs = 1; - - path_distance = find_connected_distance(listener_pos, listener_seg, sound_pos, sound_seg, num_search_segs, WID_RENDPAST_FLAG ); - if ( path_distance > -1 ) { - *volume = max_volume - fixdiv(path_distance,max_distance); - //mprintf( (0, "Sound path distance %.2f, volume is %d / %d\n", f2fl(distance), *volume, max_volume )); - if (*volume > 0 ) { - angle_from_ear = vm_vec_delta_ang_norm(&listener->rvec,&vector_to_sound,&listener->uvec); - fix_sincos(angle_from_ear,&sinang,&cosang); - //mprintf( (0, "volume is %.2f\n", f2fl(*volume) )); - if (Config_channels_reversed) cosang *= -1; - *pan = (cosang + F1_0)/2; - } else { - *volume = 0; - } - } - } -} - -//hack to not start object when loading level -int Dont_start_sound_objects = 0; - -int digi_link_sound_to_object3( int org_soundnum, short objnum, int forever, fix max_volume, fix max_distance, int loop_start, int loop_end ) -{ - int i,volume,pan; - 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_initialised) return -1; - if (soundnum < 0 ) return -1; - if (GameSounds[soundnum].data==NULL) { - Int3(); - return -1; - } - if ((objnum<0)||(objnum>Highest_object_index)) + if (!digi_initialised) return -1; - if ( !forever ) { - // 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_play_sample_3d( org_soundnum, pan, volume, 0 ); + if (soundno < 0 ) return -1; - } -#ifdef NEWDEMO - if ( Newdemo_state == ND_STATE_RECORDING ) { - newdemo_record_link_sound_to_object3( org_soundnum, objnum, max_volume, max_distance, loop_start, loop_end ); - } -#endif - - for (i=0; iorient, &Viewer->pos, Viewer->segnum, - &objp->pos, objp->segnum, SoundObjects[i].max_volume, - &SoundObjects[i].volume, &SoundObjects[i].pan, SoundObjects[i].max_distance ); - - //if (!forever || SoundObjects[i].volume >= MIN_VOLUME) - digi_start_sound_object(i); - - // If it's a one-shot sound effect, and it can't start right away, then - // just cancel it and be done with it. - if ( (SoundObjects[i].handle < 0) && (!(SoundObjects[i].flags & SOF_PLAY_FOREVER)) ) { - SoundObjects[i].flags = 0; - return -1; - } - } - - return SoundObjects[i].signature; -} - - -int digi_link_sound_to_object2( int org_soundnum, short objnum, int forever, fix max_volume, fix max_distance ) -{ - return digi_link_sound_to_object3( org_soundnum, objnum, forever, max_volume, max_distance, -1, -1 ); -} - - -int digi_link_sound_to_object( int soundnum, short objnum, int forever, fix max_volume ) -{ 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 i, volume, pan; - 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_initialised) return -1; - if (soundnum < 0 ) return -1; - if (GameSounds[soundnum].data==NULL) { + if (GameSounds[soundno].data == NULL) + { Int3(); return -1; } - if ((segnum<0)||(segnum>Highest_segment_index)) - return -1; - - if ( !forever ) { - // 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_play_sample_3d( org_soundnum, pan, volume, 0 ); - return -1; - } - - for (i=0; iorient, &Viewer->pos, Viewer->segnum, - &SoundObjects[i].lp_position, SoundObjects[i].lp_segnum, - SoundObjects[i].max_volume, - &SoundObjects[i].volume, &SoundObjects[i].pan, SoundObjects[i].max_distance ); - - if (!forever || SoundObjects[i].volume >= MIN_VOLUME) - digi_start_sound_object(i); - - // If it's a one-shot sound effect, and it can't start right away, then - // just cancel it and be done with it. - if ( (SoundObjects[i].handle < 0) && (!(SoundObjects[i].flags & SOF_PLAY_FOREVER)) ) { - SoundObjects[i].flags = 0; - return -1; - } - } - - return SoundObjects[i].signature; -} - -int digi_link_sound_to_pos( int soundnum, short segnum, short sidenum, vms_vector * pos, int forever, fix max_volume ) -{ - return digi_link_sound_to_pos2( soundnum, segnum, sidenum, pos, forever, max_volume, F1_0 * 256 ); -} - -void digi_kill_sound_linked_to_segment( int segnum, int sidenum, int soundnum ) -{ - int i,killed; - - soundnum = digi_xlat_sound(soundnum); - - if (!digi_initialised) return; - - killed = 0; - - for (i=0; i 1 ) { - mprintf( (1, "ERROR: More than 1 sounds were deleted from seg %d\n", segnum )); - } -} - -void digi_kill_sound_linked_to_object( int objnum ) -{ - int i,killed; - - if (!digi_initialised) return; - - killed = 0; - - for (i=0; i 1 ) { - mprintf( (1, "ERROR: More than 1 sounds were deleted from object %d\n", objnum )); - } + //FIXME: not implemented + return -1; } -void digi_sync_sounds() + //added on 980905 by adb to add sound kill system from original sos digi.c +void reset_sounds_on_channel( int channel ) { int i; - int oldvolume, oldpan; - if (!digi_initialised) return; - - for (i=0; iorient, &Viewer->pos, Viewer->segnum, - &SoundObjects[i].lp_position, SoundObjects[i].lp_segnum, - SoundObjects[i].max_volume, - &SoundObjects[i].volume, &SoundObjects[i].pan, SoundObjects[i].max_distance ); - - } else if ( SoundObjects[i].flags & SOF_LINK_TO_OBJ ) { - object * objp; - - objp = &Objects[SoundObjects[i].lo_objnum]; - - if ((objp->type==OBJ_NONE) || (objp->signature!=SoundObjects[i].lo_objsignature)) { - // The object that this is linked to is dead, so just end this sound if it is looping. - if ( (SoundObjects[i].flags & SOF_PLAYING) && (SoundObjects[i].flags & SOF_PLAY_FOREVER)) { - SoundSlots[SoundObjects[i].handle].playing = 0; - } - SoundObjects[i].flags = 0; // Mark as dead, so some other sound can use this sound - continue; // Go on to next sound... - } else { - digi_get_sound_loc( &Viewer->orient, &Viewer->pos, Viewer->segnum, - &objp->pos, objp->segnum, SoundObjects[i].max_volume, - &SoundObjects[i].volume, &SoundObjects[i].pan, SoundObjects[i].max_distance ); - } - } - - if (oldvolume != SoundObjects[i].volume) { - if ( SoundObjects[i].volume < MIN_VOLUME ) { - // Sound is too far away, so stop it from playing. - if ((SoundObjects[i].flags & SOF_PLAYING)&&(SoundObjects[i].flags & SOF_PLAY_FOREVER)) { - SoundSlots[SoundObjects[i].handle].playing = 0; - SoundObjects[i].flags &= ~SOF_PLAYING; // Mark sound as not playing - } - } else { - if (!(SoundObjects[i].flags & SOF_PLAYING)) { - digi_start_sound_object(i); - } else { - SoundSlots[SoundObjects[i].handle].volume = fixmuldiv(SoundObjects[i].volume,digi_volume,F1_0); - } - } - } - - if (oldpan != SoundObjects[i].pan) { - if (SoundObjects[i].flags & SOF_PLAYING) - SoundSlots[SoundObjects[i].handle].pan = SoundObjects[i].pan; - } - } - } + for (i=0; i (MAX_SOUND_SLOTS-MAX_SOUND_OBJECTS) ) - digi_max_channels = (MAX_SOUND_SLOTS-MAX_SOUND_OBJECTS); + if (digi_max_channels > MAX_SOUND_SLOTS) + digi_max_channels = MAX_SOUND_SLOTS; if ( !digi_initialised ) return; @@ -896,12 +395,50 @@ int digi_get_max_channels() { } // end edit by adb +int digi_is_channel_playing(int channel) +{ + if (!digi_initialised) + return 0; + + return SoundSlots[channel].playing; +} + +void digi_set_channel_volume(int channel, int volume) +{ + if (!digi_initialised) + return; + + if (!SoundSlots[channel].playing) + return; + + SoundSlots[channel].volume = fixmuldiv(volume, digi_volume, F1_0); +} + +void digi_set_channel_pan(int channel, int pan) +{ + if (!digi_initialised) + return; + + if (!SoundSlots[channel].playing) + return; + + SoundSlots[channel].pan = pan; +} + void digi_stop_sound(int channel) { - //FIXME: Is this correct? I dunno, it works. SoundSlots[channel].playing=0; } +void digi_end_sound(int channel) +{ + if (!digi_initialised) + return; + + if (!SoundSlots[channel].playing) + return; +} + void digi_reset_digi_sounds() { int i; @@ -928,4 +465,26 @@ void digi_stop_current_song() send_ipc(buf); #endif } +void digi_pause_midi() {} +void digi_resume_midi() {} +#endif + +#ifndef NDEBUG +void digi_debug() +{ + int i; + int n_voices = 0; + + if (!digi_initialised) + return; + + for (i = 0; i < digi_max_channels; i++) + { + if (digi_is_channel_playing(i)) + n_voices++; + } + + mprintf_at((0, 2, 0, "DIGI: Active Sound Channels: %d/%d (HMI says %d/32) ", n_voices, digi_max_channels, -1)); + //mprintf_at((0, 3, 0, "DIGI: Number locked sounds: %d ", digi_total_locks )); +} #endif diff --git a/arch/win32/midi.c b/arch/win32/midi.c index b9b4d7c2..c396fa7f 100644 --- a/arch/win32/midi.c +++ b/arch/win32/midi.c @@ -1,7 +1,7 @@ // MIDI stuff follows. - #include +#include "error.h" #include "hmpfile.h" hmp_file *hmp = NULL; @@ -62,3 +62,36 @@ void digi_play_midi_song(char *filename, char *melodic_bank, char *drum_bank, in else printf("hmp_open failed\n"); } + + +int sound_paused = 0; + +void digi_pause_midi() +{ +#if 0 + if (!digi_initialised) + return; +#endif + + if (sound_paused == 0) + { + // pause here + } + sound_paused++; +} + +void digi_resume_midi() +{ +#if 0 + if (!digi_initialised) + return; +#endif + + Assert(sound_paused > 0); + + if (sound_paused == 1) + { + // resume sound here + } + sound_paused--; +} diff --git a/main/Makefile.am b/main/Makefile.am index 417d2086..594e5e83 100644 --- a/main/Makefile.am +++ b/main/Makefile.am @@ -19,7 +19,7 @@ endif libmain_a_SOURCES = ${EDITOR_SRCS} ${NETWORK_SRCS} \ ai.c ai2.c aipath.c automap.c bm.c \ cmd.c cntrlcen.c collide.c config.c console.c \ -controls.c credits.c crypt.c effects.c endlevel.c \ +controls.c credits.c crypt.c digiobj.c effects.c endlevel.c \ escort.c fireball.c fuelcen.c fvi.c game.c \ gamecntl.c gamefont.c gamemine.c gamepal.c gamerend.c \ gamesave.c gameseg.c gameseq.c gauges.c hostage.c \ diff --git a/main/digi.h b/main/digi.h index c8fd73f7..202784ee 100644 --- a/main/digi.h +++ b/main/digi.h @@ -1,4 +1,4 @@ -/* $Id: digi.h,v 1.4 2004-08-28 23:17:45 schaffner Exp $ */ +/* $Id: digi.h,v 1.5 2004-11-29 05:25:58 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -37,8 +37,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. typedef SAMPLE digi_sound; #else typedef struct digi_sound { - int bits; - int freq; int length; ubyte * data; } digi_sound; @@ -65,7 +63,6 @@ extern int digi_init(); extern void digi_reset(); extern void digi_close(); -int digi_xlat_sound(int sound); // Volume is max at F1_0. extern void digi_play_sample( int sndnum, fix max_volume ); extern void digi_play_sample_once( int sndnum, fix max_volume ); @@ -94,6 +91,8 @@ extern int digi_is_sound_playing(int soundno); extern void digi_pause_all(); extern void digi_resume_all(); +extern void digi_pause_digi_sounds(); +extern void digi_resume_digi_sounds(); extern void digi_stop_all(); extern void digi_set_max_channels(int n); @@ -101,14 +100,33 @@ extern int digi_get_max_channels(); extern int digi_lomem; -extern void digi_pause_digi_sounds(); -extern void digi_resume_digi_sounds(); +extern int digi_xlat_sound(int soundno); + +extern void digi_stop_sound( int channel ); + +// Returns the channel a sound number is playing on, or +// -1 if none. +extern int digi_find_channel(int soundno); + +// Volume 0-F1_0 +extern int digi_start_sound(short soundnum, fix volume, int pan, int looping, int loop_start, int loop_end, int persistent); + +// Stops all sounds that are playing +void digi_stop_all_channels(); + +extern void digi_end_sound( int channel ); +extern void digi_set_channel_pan( int channel, int pan ); +extern void digi_set_channel_volume( int channel, int volume ); +extern int digi_is_channel_playing(int channel); +extern void digi_pause_midi(); +extern void digi_debug(); +extern void digi_stop_current_song(); + +extern void digi_play_sample_looping( int soundno, fix max_volume,int loop_start, int loop_end ); +extern void digi_change_looping_volume( fix volume ); +extern void digi_stop_looping_sound(); -int digi_start_sound(int soundnum, fix volume, fix pan, int unknown1, int unknown2, int unknown3, int unknown4); -void digi_stop_sound(int channel); -void digi_start_sound_queued( short soundnum, fix volume ); -void digi_play_sample_looping( int soundno, fix max_volume,int loop_start, int loop_end ); -void digi_stop_looping_sound(void); -void digi_change_looping_volume(fix volume); +// Plays a queued voice sound. +extern void digi_start_sound_queued( short soundnum, fix volume ); #endif diff --git a/main/old/digiobj.c b/main/digiobj.c similarity index 96% rename from main/old/digiobj.c rename to main/digiobj.c index 9d17b3b3..ea249756 100644 --- a/main/old/digiobj.c +++ b/main/digiobj.c @@ -1,3 +1,4 @@ +/* $Id: digiobj.c,v 1.1 2004-11-29 05:25:58 btb Exp $ */ /* THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO @@ -12,24 +13,27 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. */ -#pragma off (unreferenced) -static char rcsid[] = "$Id: digiobj.c,v 1.1.1.1 2001-01-19 03:30:14 bradleyb Exp $"; -#pragma on (unreferenced) +#ifdef RCS +static char rcsid[] = "$Id: digiobj.c,v 1.1 2004-11-29 05:25:58 btb Exp $"; +#endif + +#ifdef HAVE_CONFIG_H +#include +#endif -#include -#include -#include -#include -#include +#include +#include +#include -#ifndef MACINTOSH - #include +#ifdef __MSDOS__ +# include +# include +# include +# include #endif -#include -#include -#include -#include +#include +#include #include "fix.h" #include "object.h" @@ -42,7 +46,9 @@ static char rcsid[] = "$Id: digiobj.c,v 1.1.1.1 2001-01-19 03:30:14 bradleyb Exp #include "key.h" #include "newdemo.h" #include "game.h" +#ifdef __MSDOS__ #include "dpmi.h" +#endif #include "error.h" #include "wall.h" #include "cfile.h" @@ -55,7 +61,7 @@ static char rcsid[] = "$Id: digiobj.c,v 1.1.1.1 2001-01-19 03:30:14 bradleyb Exp #define SOF_LINK_TO_OBJ 4 // Sound is linked to a moving object. If object dies, then finishes play and quits. #define SOF_LINK_TO_POS 8 // Sound is linked to segment, pos #define SOF_PLAY_FOREVER 16 // Play forever (or until level is stopped), otherwise plays once -#define SOF_PERMANANT 32 // Part of the level, like a waterfall or fan +#define SOF_PERMANENT 32 // Part of the level, like a waterfall or fan typedef struct sound_object { short signature; // A unique signature to this sound @@ -92,13 +98,17 @@ int digi_sounds_initialized=0; int digi_lomem = 0; +/* Find the sound which actually equates to a sound number */ int digi_xlat_sound(int soundno) { - if ( soundno < 0 ) return -1; + if (soundno < 0) + return -1; - if ( digi_lomem ) { + if (digi_lomem) + { soundno = AltSounds[soundno]; - if ( soundno == 255 ) return -1; + if (soundno == 255) + return -1; } Assert(Sounds[soundno] != 255); //if hit this, probably using undefined sound @@ -220,6 +230,10 @@ void digi_play_sample_3d( int soundno, int angle, int volume, int no_dups ) } +void SoundQ_init(); +void SoundQ_process(); +void SoundQ_pause(); + void digi_init_sounds() { int i; @@ -317,8 +331,8 @@ void digi_start_sound_object(int i) // -- MK, 2/22/96 -- if ( Newdemo_state == ND_STATE_RECORDING ) // -- MK, 2/22/96 -- newdemo_record_sound_3d_once( digi_unxlat_sound(SoundObjects[i].soundnum), SoundObjects[i].pan, SoundObjects[i].volume ); - // only use up to half the sound channels for "permanant" sounts - if ((SoundObjects[i].flags & SOF_PERMANANT) && (N_active_sound_objects >= max(1,digi_max_channels/4)) ) + // only use up to half the sound channels for "permanent" sounts + if ((SoundObjects[i].flags & SOF_PERMANENT) && (N_active_sound_objects >= max(1, digi_get_max_channels() / 4))) return; // start the sample playing @@ -395,7 +409,7 @@ int digi_link_sound_to_object3( int org_soundnum, short objnum, int forever, fix if (Dont_start_sound_objects) { //started at level start - SoundObjects[i].flags |= SOF_PERMANANT; + SoundObjects[i].flags |= SOF_PERMANENT; SoundObjects[i].channel = -1; } else { @@ -481,7 +495,7 @@ int digi_link_sound_to_pos2( int org_soundnum, short segnum, short sidenum, vms_ if (Dont_start_sound_objects) { //started at level start - SoundObjects[i].flags |= SOF_PERMANANT; + SoundObjects[i].flags |= SOF_PERMANENT; SoundObjects[i].channel = -1; } diff --git a/main/kludge.c b/main/kludge.c index 02c7855e..56da841c 100644 --- a/main/kludge.c +++ b/main/kludge.c @@ -1,4 +1,4 @@ -/* $Id: kludge.c,v 1.16 2004-11-28 05:16:38 btb Exp $ */ +/* $Id: kludge.c,v 1.17 2004-11-29 05:25:58 btb Exp $ */ /* * @@ -96,38 +96,3 @@ void network_dump_appletalk_player(ubyte node, ushort net, ubyte socket, int why { } - -void digi_stop_digi_sounds(void) -{ - -} - -void digi_pause_digi_sounds() -{ - -} - -void digi_resume_digi_sounds() -{ - -} -void digi_play_sample_looping( int soundno, fix max_volume,int loop_start, int loop_end ) -{ - -} - -void digi_change_looping_volume( fix volume ) -{ - -} - -void digi_stop_looping_sound() -{ - -} - -// Plays a queued voice sound. -void digi_start_sound_queued( short soundnum, fix volume ) -{ - -} -- 2.39.2