]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - snd_mix.c
renamed r_shadow_shadows to r_shadow_dlightshadows and added r_shadow_worldshadows...
[xonotic/darkplaces.git] / snd_mix.c
index d4dadbae3f84b654bfa1a2e59a6f14c4a9a3bcc3..3f9f01b60b4fd2ae0d3bb1e918ff9552224c2633 100644 (file)
--- a/snd_mix.c
+++ b/snd_mix.c
@@ -21,14 +21,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "quakedef.h"
 
-#ifdef _WIN32
-#include "winquake.h"
-#endif
-
 // LordHavoc: was 512, expanded to 2048
-#define        PAINTBUFFER_SIZE        2048
+#define        PAINTBUFFER_SIZE 2048
 portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE];
-int            snd_scaletable[32][256];
+int snd_scaletable[32][256];
 
 /*
 // LordHavoc: disabled this because it desyncs with the video too easily
@@ -44,8 +40,7 @@ void S_CaptureAVISound(portable_samplepair_t *buf, int length)
        {
                if (cl_avidemo_soundfile == NULL)
                {
-                       sprintf (filename, "%s/dpavi.wav", com_gamedir);
-                       cl_avidemo_soundfile = fopen(filename, "wb");
+                       cl_avidemo_soundfile = FS_Open ("dpavi.wav", "wb", false);
                        memset(out, 0, 44);
                        fwrite(out, 1, 44, cl_avidemo_soundfile);
                        // header will be filled out when file is closed
@@ -267,11 +262,11 @@ void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime);
 
 void S_PaintChannels(int endtime)
 {
-       int     i;
-       int     end;
+       int i;
+       int end;
        channel_t *ch;
-       sfxcache_t      *sc;
-       int             ltime, count;
+       sfxcache_t *sc;
+       int ltime, count;
 
        while (paintedtime < endtime)
        {
@@ -280,8 +275,8 @@ void S_PaintChannels(int endtime)
                if (endtime - paintedtime > PAINTBUFFER_SIZE)
                        end = paintedtime + PAINTBUFFER_SIZE;
 
-               // clear the paint buffer
-               memset(paintbuffer, 0, (end - paintedtime) * sizeof(portable_samplepair_t));
+               // clear the paint buffer, filling it with data from rawsamples (music/video/whatever)
+               S_RawSamples_Dequeue(&paintbuffer->left, end - paintedtime);
 
                // paint in the channels.
                ch = channels;
@@ -318,9 +313,9 @@ void S_PaintChannels(int endtime)
                                // if at end of loop, restart
                                if (ltime >= ch->end)
                                {
-                                       if (sc->loopstart >= 0)
+                                       if (sc->loopstart >= 0 || ch->forceloop)
                                        {
-                                               ch->pos = sc->loopstart;
+                                               ch->pos = bound(0, sc->loopstart, sc->length - 1);
                                                ch->end = ltime + sc->length - ch->pos;
                                        }
                                        else
@@ -331,7 +326,6 @@ void S_PaintChannels(int endtime)
                                        }
                                }
                        }
-
                }
 
                // transfer out according to DMA format
@@ -343,19 +337,19 @@ void S_PaintChannels(int endtime)
 
 void SND_InitScaletable (void)
 {
-       int             i, j;
+       int i, j;
 
-       for (i=0 ; i<32 ; i++)
-               for (j=0 ; j<256 ; j++)
+       for (i = 0;i < 32;i++)
+               for (j = 0;j < 256;j++)
                        snd_scaletable[i][j] = ((signed char)j) * i * 8;
 }
 
 
 void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count)
 {
-       int             *lscale, *rscale;
+       int *lscale, *rscale;
        unsigned char *sfx;
-       int             i;
+       int i, n;
 
        if (ch->leftvol > 255)
                ch->leftvol = 255;
@@ -368,22 +362,20 @@ void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count)
        {
                // LordHavoc: stereo sound support, and optimizations
                sfx = (unsigned char *)sc->data + ch->pos * 2;
-
-               for (i=0 ; i<count ; i++)
+               for (i = 0;i < count;i++)
                {
                        paintbuffer[i].left += lscale[*sfx++];
                        paintbuffer[i].right += rscale[*sfx++];
                }
-               
        }
        else
        {
                sfx = (unsigned char *)sc->data + ch->pos;
-
-               for (i=0 ; i<count ; i++)
+               for (i = 0;i < count;i++)
                {
-                       paintbuffer[i].left += lscale[*sfx];
-                       paintbuffer[i].right += rscale[*sfx++];
+                       n = *sfx++;
+                       paintbuffer[i].left += lscale[n];
+                       paintbuffer[i].right += rscale[n];
                }
 
        }
@@ -394,7 +386,7 @@ void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count)
 {
        int leftvol, rightvol;
        signed short *sfx;
-       int     i;
+       int i;
 
        leftvol = ch->leftvol;
        rightvol = ch->rightvol;