]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_dma.c
added back support for textures smaller than 4 pixels wide (Nehahra uses one)
[xonotic/darkplaces.git] / snd_dma.c
index 7c28e3a1cf5a4791044cd8f2f20a589bd0f7ef81..4f760acc917c4083434abc34b49b37f96e1155e8 100644 (file)
--- a/snd_dma.c
+++ b/snd_dma.c
@@ -64,9 +64,6 @@ int                   num_sfx;
 
 sfx_t          *ambient_sfx[NUM_AMBIENTS];
 
-int            desired_speed = 11025;
-int            desired_bits = 16;
-
 int sound_started=0;
 
 cvar_t bgmvolume = {"bgmvolume", "1", true};
@@ -74,7 +71,7 @@ cvar_t volume = {"volume", "0.7", true};
 
 cvar_t nosound = {"nosound", "0"};
 cvar_t precache = {"precache", "1"};
-cvar_t loadas8bit = {"loadas8bit", "0"};
+//cvar_t loadas8bit = {"loadas8bit", "0"};
 cvar_t bgmbuffer = {"bgmbuffer", "4096"};
 cvar_t ambient_level = {"ambient_level", "0.3"};
 cvar_t ambient_fade = {"ambient_fade", "100"};
@@ -189,7 +186,7 @@ void S_Init (void)
        Cvar_RegisterVariable(&nosound);
        Cvar_RegisterVariable(&volume);
        Cvar_RegisterVariable(&precache);
-       Cvar_RegisterVariable(&loadas8bit);
+//     Cvar_RegisterVariable(&loadas8bit);
        Cvar_RegisterVariable(&bgmvolume);
        Cvar_RegisterVariable(&bgmbuffer);
        Cvar_RegisterVariable(&ambient_level);
@@ -199,11 +196,13 @@ void S_Init (void)
        Cvar_RegisterVariable(&_snd_mixahead);
        Cvar_RegisterVariable(&snd_swapstereo); // LordHavoc: for people with backwards sound wiring
 
+       /*
        if (host_parms.memsize < 0x800000)
        {
                Cvar_Set ("loadas8bit", "1");
                Con_Printf ("loading all sounds as 8bit\n");
        }
+       */
 
 
 
@@ -374,7 +373,7 @@ channel_t *SND_PickChannel(int entnum, int entchannel)
                if (entchannel != 0             // channel 0 never overrides
                && channels[ch_idx].entnum == entnum
                && (channels[ch_idx].entchannel == entchannel || entchannel == -1) )
-               {       // allways override sound from same entity
+               {       // always override sound from same entity
                        first_to_die = ch_idx;
                        break;
                }
@@ -412,7 +411,7 @@ void SND_Spatialize(channel_t *ch)
     vec3_t source_vec;
        sfx_t *snd;
 
-// anything coming from the view entity will allways be full volume
+// anything coming from the view entity will always be full volume
 // LordHavoc: make sounds with ATTN_NONE have no spatialization
        if (ch->entnum == cl.viewentity || ch->dist_mult == 0)
        {
@@ -515,9 +514,12 @@ void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float f
                        continue;
                if (check->sfx == sfx && !check->pos)
                {
-                       skip = rand () % (int)(0.1*shm->speed);
-                       if (skip >= target_chan->end)
-                               skip = target_chan->end - 1;
+                       // LordHavoc: fixed skip calculations
+                       skip = 0.1 * shm->speed;
+                       if (skip > sc->length)
+                               skip = sc->length;
+                       if (skip > 0)
+                               skip = rand() % skip;
                        target_chan->pos += skip;
                        target_chan->end -= skip;
                        break;
@@ -705,13 +707,13 @@ void S_UpdateAmbientSounds (void)
        // don't adjust volume too fast
                if (chan->master_vol < vol)
                {
-                       chan->master_vol += host_frametime * ambient_fade.value;
+                       chan->master_vol += host_realframetime * ambient_fade.value;
                        if (chan->master_vol > vol)
                                chan->master_vol = vol;
                }
                else if (chan->master_vol > vol)
                {
-                       chan->master_vol -= host_frametime * ambient_fade.value;
+                       chan->master_vol -= host_realframetime * ambient_fade.value;
                        if (chan->master_vol < vol)
                                chan->master_vol = vol;
                }
@@ -761,7 +763,7 @@ void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
        // try to combine static sounds with a previous channel of the same
        // sound effect so we don't mix five torches every frame
        
-               if (i >= MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS)
+               if (i > MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS)
                {
                // see if it can just use the last one
                        if (combine && combine->sfx == ch->sfx)