cd_dev[sizeof(cd_dev) - 1] = 0;
}
- if ((cdfile = open(cd_dev, O_RDONLY)) == -1) {
- Con_DPrintf("CDAudio_Init: open of \"%s\" failed (%i)\n", cd_dev, errno);
- cdfile = -1;
- return -1;
- }
+ Cmd_AddCommand("cd", CD_f);
for (i = 0; i < 100; i++)
remap[i] = i;
cdaudioinitialized = true;
- initialized = true;
enabled = true;
+ return 0;
+}
+
+int CDAudio_Startup(void)
+{
+ if ((cdfile = open(cd_dev, O_RDONLY)) == -1) {
+ Con_DPrintf("CDAudio_Init: open of \"%s\" failed (%i)\n", cd_dev, errno);
+ cdfile = -1;
+ return -1;
+ }
+
if (CDAudio_GetAudioDiskInfo())
{
Con_DPrintf("CDAudio_Init: No CD in player.\n");
cdValid = false;
}
- Cmd_AddCommand ("cd", CD_f);
+ initialized = true;
- Con_DPrintf("CD Audio Initialized\n");
+ Con_DPrintf("CD Audio Started\n");
return 0;
}
-
void CDAudio_Shutdown(void)
{
if (!initialized)
CDAudio_Stop();
close(cdfile);
cdfile = -1;
+ initialized = false;
}
-void CDAudio_Open(void)
-{
-}
-
-void CDAudio_Close(void)
-{
-}
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
return 0;
}
+int CDAudio_Startup(void)
+{
+ return 0;
+}
void CDAudio_Shutdown(void)
{
int CDAudio_Init(void)
{
- DWORD dwReturn;
- MCI_OPEN_PARMS mciOpenParms;
- MCI_SET_PARMS mciSetParms;
- int n;
-
if (cls.state == ca_dedicated)
return -1;
if (COM_CheckParm("-nocdaudio") || COM_CheckParm("-safe"))
return -1;
+ for (n = 0; n < 100; n++)
+ remap[n] = n;
+ cdaudioinitialized = true;
+ enabled = true;
+
+ Cmd_AddCommand("cd", CD_f);
+
+ return 0;
+}
+
+int CDAudio_Startup(void)
+{
+ DWORD dwReturn;
+ MCI_OPEN_PARMS mciOpenParms;
+ MCI_SET_PARMS mciSetParms;
+ int n;
+
mciOpenParms.lpstrDeviceType = "cdaudio";
if ((dwReturn = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_SHAREABLE, (DWORD) (LPVOID) &mciOpenParms)))
{
return -1;
}
- for (n = 0; n < 100; n++)
- remap[n] = n;
- cdaudioinitialized = true;
- initialized = true;
- enabled = true;
-
if (CDAudio_GetAudioDiskInfo())
{
Con_DPrintf("CDAudio_Init: No CD in player.\n");
cdValid = false;
}
- Cmd_AddCommand ("cd", CD_f);
+ initialized = true;
Con_DPrintf("CD Audio Initialized\n");
CDAudio_Stop();
if (mciSendCommand(wDeviceID, MCI_CLOSE, MCI_WAIT, (DWORD)NULL))
Con_DPrintf("CDAudio_Shutdown: MCI_CLOSE failed\n");
+ initialized = false;
}
-
-void CDAudio_Open(void)
-{
-}
-
-void CDAudio_Close(void)
-{
-}
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
void CDAudio_Stop(void);
void CDAudio_Pause(void);
void CDAudio_Resume(void);
+int CDAudio_Startup(void);
void CDAudio_Shutdown(void);
void CDAudio_Update(void);
cullradius = RadiusFromBoundsAndOrigin(clipmins, clipmaxs, rd->origin);
VectorScale(rd->light, (1.0f / 4096.0f), lightcolor);
- if (gl_stencil || visiblevolumes)
+ if (r_shadow_shadows.integer && (gl_stencil || visiblevolumes))
{
if (!visiblevolumes)
R_Shadow_Stage_ShadowVolumes();
if (!visiblevolumes)
{
- if (gl_stencil)
+ if (r_shadow_shadows.integer && gl_stencil)
R_Shadow_Stage_LightWithShadows();
else
R_Shadow_Stage_LightWithoutShadows();
{
if (!gl_stencil)
{
- Con_Printf("Stencil not enabled, turning off r_shadow_realtime_world, please type vid_stencil 1;vid_bitsperpixel 32;vid_restart and try again\n");
+ Con_Printf("Realtime world lighting requires 32bit color turning off r_shadow_realtime_world, please type vid_bitsperpixel 32;vid_restart and try again\n");
Cvar_SetValueQuick(&r_shadow_realtime_world, 0);
}
}
R_TimeReport("markentity");
GL_SetupView_ViewPort(r_refdef.x, r_refdef.y, r_refdef.width, r_refdef.height);
- if (r_shadow_realtime_world.integer || gl_stencil)
+ if ((r_shadow_realtime_world.integer || r_shadow_shadows.integer) && gl_stencil)
GL_SetupView_Mode_PerspectiveInfiniteFarClip(r_refdef.fov_x, r_refdef.fov_y, 1.0f);
else
GL_SetupView_Mode_Perspective(r_refdef.fov_x, r_refdef.fov_y, 1.0f, r_farclip);
CDAudio_Shutdown ();
NetConn_Shutdown ();
- S_Shutdown();
if (cls.state != ca_dedicated)
{
//=============================================================================
/* VIDEO MENU */
-#define VIDEO_ITEMS 5
+#define VIDEO_ITEMS 4
int video_cursor = 0;
-int video_cursor_table[] = {56, 68, 80, 92, 116};
+int video_cursor_table[] = {56, 68, 80, 100};
// note: if modes are added to the beginning of this list, update the
// video_resolution = x; in M_Menu_Video_f below
unsigned short video_resolutions[][2] = {{320,240}, {400,300}, {512,384}, {640,480}, {800,600}, {1024,768}, {1152,864}, {1280,960}, {1280,1024}, {1600,1200}, {1792,1344}, {1920,1440}, {2048,1536}};
extern int current_vid_width;
extern int current_vid_height;
extern int current_vid_bitsperpixel;
-extern int current_vid_stencil;
void M_Menu_Video_f (void)
M_Print(16, video_cursor_table[2], " Fullscreen");
M_DrawCheckbox(220, video_cursor_table[2], vid_fullscreen.integer);
- // Stencil
- M_Print(16, video_cursor_table[3], " Stencil");
- M_DrawCheckbox(220, video_cursor_table[3], vid_stencil.integer);
-
// "Apply" button
- M_Print(220, video_cursor_table[4], "Apply");
+ M_Print(220, video_cursor_table[3], "Apply");
// Cursor
M_DrawCharacter(200, video_cursor_table[video_cursor], 12+((int)(realtime*4)&1));
case 2:
Cvar_SetValueQuick (&vid_fullscreen, !vid_fullscreen.integer);
break;
- case 3:
- Cvar_SetValueQuick (&vid_stencil, !vid_stencil.integer);
- break;
}
}
Cvar_SetValueQuick(&vid_width, current_vid_width);
Cvar_SetValueQuick(&vid_height, current_vid_height);
Cvar_SetValueQuick(&vid_bitsperpixel, current_vid_bitsperpixel);
- Cvar_SetValueQuick(&vid_stencil, current_vid_stencil);
S_LocalSound ("misc/menu1.wav");
M_Menu_Options_f ();
cvar_t r_shadow_projectdistance = {0, "r_shadow_projectdistance", "10000"};
cvar_t r_shadow_texture3d = {0, "r_shadow_texture3d", "1"};
cvar_t r_shadow_singlepassvolumegeneration = {0, "r_shadow_singlepassvolumegeneration", "1"};
+cvar_t r_shadow_shadows = {CVAR_SAVE, "r_shadow_shadows", "1"};
int c_rt_lights, c_rt_clears, c_rt_scissored;
int c_rt_shadowmeshes, c_rt_shadowtris, c_rt_lightmeshes, c_rt_lighttris;
Cvar_RegisterVariable(&r_shadow_projectdistance);
Cvar_RegisterVariable(&r_shadow_texture3d);
Cvar_RegisterVariable(&r_shadow_singlepassvolumegeneration);
+ Cvar_RegisterVariable(&r_shadow_shadows);
R_Shadow_EditLights_Init();
R_RegisterModule("R_Shadow", r_shadow_start, r_shadow_shutdown, r_shadow_newmap);
}
extern cvar_t r_shadow_debuglight;
extern cvar_t r_shadow_bumpscale_bumpmap;
extern cvar_t r_shadow_bumpscale_basetexture;
+extern cvar_t r_shadow_shadows;
void R_Shadow_Init(void);
void R_Shadow_Volume(int numverts, int numtris, const float *invertex3f, int *elements, int *neighbors, vec3_t relativelightorigin, float lightradius, float projectdistance);
if ((rc=snd_pcm_channel_setup(pcm_handle, &setup))<0)
goto error;
- shm=&sn;
memset((dma_t*)shm,0,sizeof(*shm));
- shm->splitbuffer = 0;
shm->channels=setup.format.voices;
- shm->submission_chunk=128; // don't mix less than this #
shm->samplepos=0; // in mono samples
shm->samplebits=setup.format.format==SND_PCM_SFMT_S16_LE?16:8;
shm->samples=setup.buf.block.frags*setup.buf.block.frag_size/(shm->samplebits/8); // mono samples in buffer
Con_Printf("%5d samples\n", shm->samples);
Con_Printf("%5d samplepos\n", shm->samplepos);
Con_Printf("%5d samplebits\n", shm->samplebits);
- Con_Printf("%5d submission_chunk\n", shm->submission_chunk);
Con_Printf("%5d speed\n", shm->speed);
Con_Printf("0x%x dma buffer\n", (int)shm->buffer);
Con_Printf("%5d total_channels\n", total_channels);
{
}
-void S_Open(void)
-{
-}
-
-void S_Close(void)
-{
-}
break;
case 8:
case 16:
- if (snd_pcm_hw_params_set_format(pcm, hw,
+ if (snd_pcm_hw_params_set_format(pcm, hw,
bps == 8 ? SND_PCM_FORMAT_U8 :
SND_PCM_FORMAT_S16) >= 0) {
break;
goto error;
}
- if (snd_pcm_hw_params_set_access(pcm, hw,
+ if (snd_pcm_hw_params_set_access(pcm, hw,
SND_PCM_ACCESS_MMAP_INTERLEAVED) < 0) {
Con_Printf("ALSA: interleaved is not supported\n");
goto error;
}
snd_pcm_hw_params_set_period_size_near(pcm, hw, frag_size, 0);
-
+
err = snd_pcm_hw_params(pcm, hw);
if (err < 0) {
Con_Printf("ALSA: unable to install hw params\n");
mmap_areas = snd_pcm_mmap_running_areas(pcm);
- shm=&sn;
memset((dma_t*)shm,0,sizeof(*shm));
- shm->splitbuffer = 0;
shm->channels=stereo+1;
- shm->submission_chunk=snd_pcm_hw_params_get_period_size(hw, 0); // don't mix less than this #
shm->samplepos=0; // in mono samples
shm->samplebits=bps;
- buffer_size = snd_pcm_hw_params_get_buffer_size(hw);
+ buffer_size = snd_pcm_hw_params_get_buffer_size(hw);
shm->samples=buffer_size*shm->channels; // mono samples in buffer
shm->speed=rate;
shm->buffer=(unsigned char*)mmap_areas->addr;
Con_Printf("%5d samples\n", shm->samples);
Con_Printf("%5d samplepos\n", shm->samplepos);
Con_Printf("%5d samplebits\n", shm->samplebits);
- Con_Printf("%5d submission_chunk\n", shm->submission_chunk);
Con_Printf("%5d speed\n", shm->speed);
Con_Printf("0x%x dma buffer\n", (int)shm->buffer);
Con_Printf("%5d total_channels\n", total_channels);
{
}
-
-void S_Open(void)
-{
-}
-
-void S_Close(void)
-{
-}
Con_Printf("%5d samples\n", shm->samples);
Con_Printf("%5d samplepos\n", shm->samplepos);
Con_Printf("%5d samplebits\n", shm->samplebits);
- Con_Printf("%5d submission_chunk\n", shm->submission_chunk);
Con_Printf("%5d speed\n", shm->speed);
Con_Printf("0x%x dma buffer\n", shm->buffer);
Con_Printf("%5d total_channels\n", total_channels);
}
+void S_UnloadSounds(void)
+{
+ int i;
+ for (i = 0;i < num_sfx;i++)
+ S_UnloadSound(known_sfx + i);
+}
-/*
-================
-S_Startup
-================
-*/
-void S_Startup (void)
+void S_LoadSounds(void)
{
- int rc;
+ int i;
+ for (i = 0;i < num_sfx;i++)
+ S_LoadSound(known_sfx + i, false);
+}
+void S_Startup(void)
+{
if (!snd_initialized)
return;
- if (!fakedma)
- {
- rc = SNDDMA_Init();
+ shm = &sn;
+ memset((void *)shm, 0, sizeof(*shm));
+
+// create a piece of DMA memory
- if (!rc)
+ if (fakedma)
+ {
+ shm->samplebits = 16;
+ shm->speed = 22050;
+ shm->channels = 2;
+ shm->samples = 32768;
+ shm->samplepos = 0;
+ shm->buffer = Mem_Alloc(snd_mempool, shm->channels * shm->samples * (shm->samplebits / 8));
+ }
+ else
+ {
+ if (!SNDDMA_Init())
{
Con_Printf("S_Startup: SNDDMA_Init failed.\n");
sound_started = 0;
+ shm = NULL;
return;
}
}
sound_started = 1;
+
+ Con_DPrintf("Sound sampling rate: %i\n", shm->speed);
+
+ //S_LoadSounds();
+
+ S_StopAllSounds(true);
+}
+
+void S_Shutdown(void)
+{
+ if (!sound_started)
+ return;
+
+ //S_UnloadSounds();
+
+ if (fakedma)
+ Mem_Free(shm->buffer);
+ else
+ SNDDMA_Shutdown();
+
+ shm = NULL;
+ sound_started = 0;
+}
+
+void S_Restart_f(void)
+{
+ S_Shutdown();
+ S_Startup();
}
/*
S_Init
================
*/
-void S_Init (void)
+void S_Init(void)
{
Con_DPrintf("\nSound Initialization\n");
Cmd_AddCommand("stopsound", S_StopAllSoundsC);
Cmd_AddCommand("soundlist", S_SoundList);
Cmd_AddCommand("soundinfo", S_SoundInfo_f);
+ Cmd_AddCommand("snd_restart", S_Restart_f);
Cvar_RegisterVariable(&nosound);
Cvar_RegisterVariable(&snd_precache);
known_sfx = Mem_Alloc(snd_mempool, MAX_SFX*sizeof(sfx_t));
num_sfx = 0;
- S_Startup ();
-
SND_InitScaletable ();
-// create a piece of DMA memory
-
- if (fakedma)
- {
- shm = (void *) Mem_Alloc(snd_mempool, sizeof(*shm));
- shm->splitbuffer = 0;
- shm->samplebits = 16;
- shm->speed = 22050;
- shm->channels = 2;
- shm->samples = 32768;
- shm->samplepos = 0;
- shm->soundalive = true;
- shm->gamealive = true;
- shm->submission_chunk = 1;
- shm->buffer = Mem_Alloc(snd_mempool, shm->channels * shm->samples * (shm->samplebits / 8));
- }
-
- if (!sound_started)
- return;
-
- Con_DPrintf ("Sound sampling rate: %i\n", shm->speed);
-
- // provides a tick sound until washed clean
-
ambient_sfx[AMBIENT_WATER] = S_PrecacheSound ("ambience/water1.wav", false);
ambient_sfx[AMBIENT_SKY] = S_PrecacheSound ("ambience/wind2.wav", false);
- S_StopAllSounds (true);
-}
-
-
-// =======================================================================
-// Shutdown sound engine
-// =======================================================================
-
-void S_Shutdown(void)
-{
- if (!sound_started)
- return;
-
- if (shm)
- shm->gamealive = 0;
-
- shm = 0;
- sound_started = 0;
-
- if (!fakedma)
- SNDDMA_Shutdown();
+ total_channels = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; // no statics
+ memset(channels, 0, MAX_CHANNELS * sizeof(channel_t));
}
sfx_t *sfx;
if (!name)
- Host_Error ("S_FindName: NULL\n");
+ Host_Error("S_FindName: NULL\n");
if (strlen(name) >= MAX_QPATH)
- Host_Error ("Sound name too long: %s", name);
+ Host_Error("Sound name too long: %s", name);
// see if already loaded
for (i = 0;i < num_sfx;i++)
return &known_sfx[i];
if (num_sfx == MAX_SFX)
- Sys_Error ("S_FindName: out of sfx_t");
+ Sys_Error("S_FindName: out of sfx_t");
- sfx = &known_sfx[i];
+ sfx = &known_sfx[num_sfx++];
memset(sfx, 0, sizeof(*sfx));
- strcpy (sfx->name, name);
-
- num_sfx++;
-
+ snprintf(sfx->name, sizeof(sfx->name), "%s", name);
return sfx;
}
*/
void S_TouchSound (char *name)
{
- sfx_t *sfx;
-
- if (!sound_started)
- return;
-
- sfx = S_FindName (name);
+ S_FindName(name);
}
/*
{
sfx_t *sfx;
- if (!sound_started || nosound.integer)
- return NULL;
-
- sfx = S_FindName (name);
+ sfx = S_FindName(name);
-// cache it in
- if (snd_precache.integer)
- S_LoadSound (sfx, complain);
+ if (snd_initialized && !nosound.integer && snd_precache.integer)
+ S_LoadSound(sfx, complain);
return sfx;
}
*/
void SND_Spatialize(channel_t *ch, int isstatic)
{
- vec_t dot;
- vec_t dist;
- vec_t lscale, rscale, scale;
+ vec_t dist, scale, pan;
vec3_t source_vec;
- sfx_t *snd;
// anything coming from the view entity will always be full volume
// LordHavoc: make sounds with ATTN_NONE have no spatialization
}
// calculate stereo seperation and distance attenuation
- snd = ch->sfx;
VectorSubtract(ch->origin, listener_origin, source_vec);
-
- dist = VectorNormalizeLength(source_vec) * ch->dist_mult;
-
- dot = DotProduct(listener_right, source_vec);
-
- if (shm->channels == 1)
- {
- rscale = 1.0;
- lscale = 1.0;
- }
- else
- {
- rscale = 1.0 + dot;
- lscale = 1.0 - dot;
- }
-
- // add in distance effect
- scale = (1.0 - dist) * rscale;
- ch->rightvol = (int) (ch->master_vol * scale);
- if (ch->rightvol < 0)
- ch->rightvol = 0;
-
- scale = (1.0 - dist) * lscale;
- ch->leftvol = (int) (ch->master_vol * scale);
- if (ch->leftvol < 0)
- ch->leftvol = 0;
+ dist = VectorNormalizeLength(source_vec);
+ // distance
+ scale = ch->master_vol * (1.0 - (dist * ch->dist_mult));
+ // panning
+ pan = scale * DotProduct(listener_right, source_vec);
+ // calculate the volumes
+ ch->leftvol = (int) (scale - pan);
+ ch->rightvol = (int) (scale + pan);
}
// LordHavoc: allow adjusting volume of static sounds
ch->leftvol *= snd_staticvolume.value;
ch->rightvol *= snd_staticvolume.value;
}
+
+ // clamp volumes
+ ch->leftvol = bound(0, ch->leftvol, 255);
+ ch->rightvol = bound(0, ch->rightvol, 255);
}
int ch_idx;
int skip;
- if (!sound_started)
- return;
-
- if (!sfx)
- return;
-
- if (nosound.integer)
+ if (!sound_started || !sfx || nosound.integer)
return;
vol = fvol*255;
// spatialize
memset (target_chan, 0, sizeof(*target_chan));
- /*
- if (cls.state == ca_connected && entnum > 0 && cl_entities[entnum].state_current.active)
- {
- target_chan.follow = true;
- VectorSubtract(origin, cl_entities[entnum].state_current.origin, target_chan.followoriginoffset);
- }
- */
VectorCopy(origin, target_chan->origin);
target_chan->dist_mult = attenuation / sound_nominal_clip_dist;
target_chan->master_vol = vol;
if (check->sfx == sfx && !check->pos)
{
// LordHavoc: fixed skip calculations
- skip = 0.1 * shm->speed;
+ skip = 0.1 * sc->speed;
if (skip > sc->length)
skip = sc->length;
if (skip > 0)
target_chan->end -= skip;
break;
}
-
}
}
void S_StopAllSounds(qboolean clear)
{
- if (!sound_started)
- return;
-
total_channels = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; // no statics
memset(channels, 0, MAX_CHANNELS * sizeof(channel_t));
if (clear)
- S_ClearBuffer ();
+ S_ClearBuffer();
}
-void S_StopAllSoundsC (void)
+void S_StopAllSoundsC(void)
{
- S_StopAllSounds (true);
+ S_StopAllSounds(true);
}
-void S_ClearBuffer (void)
+void S_ClearBuffer(void)
{
int clear;
-#ifdef _WIN32
- if (!sound_started || !shm || (!shm->buffer && !pDSBuf))
-#else
- if (!sound_started || !shm || !shm->buffer)
-#endif
+ if (!sound_started || !shm)
return;
if (shm->samplebits == 8)
}
else
#endif
+ if (shm->buffer)
{
int setsize = shm->samples * shm->samplebits / 8;
char *buf = shm->buffer;
while (setsize--)
- *buf++ = 0;
+ *buf++ = clear;
// on i586/i686 optimized versions of glibc, glibc *wrongly* IMO,
// reads the memory area before writing to it causing a seg fault
channel_t *ch;
channel_t *combine;
- if (!sound_started || (snd_blocked > 0))
+ if (!snd_initialized || (snd_blocked > 0))
return;
VectorCopy(origin, listener_origin);
for (sfx=known_sfx, i=0 ; i<num_sfx ; i++, sfx++)
{
sc = sfx->sfxcache;
- if (!sc)
- continue;
- size = sc->length*sc->width*(sc->stereo+1);
- total += size;
- if (sc->loopstart >= 0)
- Con_Printf ("L");
- else
- Con_Printf (" ");
- Con_Printf("(%2db) %6i : %s\n",sc->width*8, size, sfx->name);
+ if (sc)
+ {
+ size = sc->length*sc->width*(sc->stereo+1);
+ total += size;
+ Con_Printf("%c(%2db) %6i : %s\n", sc->loopstart >= 0 ? 'L' : ' ',sc->width*8, size, sfx->name);
+ }
}
- Con_Printf ("Total resident: %i\n", total);
+ Con_Printf("Total resident: %i\n", total);
}
{
sfx_t *sfx;
- if (nosound.integer)
- return;
- if (!sound_started)
+ if (!snd_initialized || nosound.integer)
return;
sfx = S_PrecacheSound (sound, true);
int S_RawSamples_QueueWantsMore(void)
{
- if (s_rawsamplesbuffer_count < min(shm->speed >> 1, RAWSAMPLESBUFFER >> 1))
+ if (shm != NULL && s_rawsamplesbuffer_count < min(shm->speed >> 1, RAWSAMPLESBUFFER >> 1))
return RAWSAMPLESBUFFER - s_rawsamplesbuffer_count;
else
return 0;
{
return shm != NULL ? shm->speed : 0;
}
+
sfxcache_t *sc;
// see if still in memory
- if (s->sfxcache)
+ if (!shm || !shm->speed)
+ return NULL;
+ if (s->sfxcache && s->sfxcache->speed == shm->speed)
return s->sfxcache;
// load it in
- strcpy(namebuffer, "sound/");
- strcat(namebuffer, s->name);
+ snprintf(namebuffer, sizeof(namebuffer), "sound/%s", s->name);
data = FS_LoadFile(namebuffer, false);
return sc;
}
+void S_UnloadSound(sfx_t *s)
+{
+ if (s->sfxcache)
+ {
+ s->sfxcache = NULL;
+ Mem_FreePool(&s->mempool);
+ }
+}
/*
{
}
+void S_Startup (void)
+{
+}
+
void S_Shutdown (void)
{
}
return 0;
}
-
-void S_Open(void)
-{
-}
-
-void S_Close(void)
-{
-}
char *s;
struct audio_buf_info info;
int caps;
+ int format16bit;
+ // LordHavoc: a quick patch to support big endian cpu, I hope
+ union
+ {
+ unsigned char c[2];
+ unsigned short s;
+ }
+ endiantest;
+ endiantest.s = 1;
+ if (endiantest.c[1])
+ format16bit = AFMT_S16_BE;
+ else
+ format16bit = AFMT_S16_LE;
snd_inited = 0;
return 0;
}
- rc = ioctl(audio_fd, SNDCTL_DSP_RESET, 0);
- if (rc < 0)
+ if (ioctl(audio_fd, SNDCTL_DSP_RESET, 0) < 0)
{
perror("/dev/dsp");
Con_Printf("Could not reset /dev/dsp\n");
return 0;
}
- shm = &sn;
- shm->splitbuffer = 0;
-
// set sample bits & speed
s = getenv("QUAKE_SOUND_SAMPLEBITS");
if (s)
if (shm->samplebits != 16 && shm->samplebits != 8)
{
ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &fmt);
- if (fmt & AFMT_S16_LE)
+ if (fmt & format16bit)
shm->samplebits = 16;
else if (fmt & AFMT_U8)
shm->samplebits = 8;
shm->channels = 2;
shm->samples = info.fragstotal * info.fragsize / (shm->samplebits/8);
- shm->submission_chunk = 1;
// memory map the dma buffer
- shm->buffer = (unsigned char *) mmap(NULL, info.fragstotal
- * info.fragsize, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, audio_fd, 0);
+ shm->bufferlength = info.fragstotal * info.fragsize;
+ shm->buffer = (unsigned char *) mmap(NULL, shm->bufferlength, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, audio_fd, 0);
if (!shm->buffer || shm->buffer == (unsigned char *)-1)
{
perror("/dev/dsp");
if (shm->samplebits == 16)
{
- rc = AFMT_S16_LE;
+ rc = format16bit;
rc = ioctl(audio_fd, SNDCTL_DSP_SETFMT, &rc);
if (rc < 0)
{
void SNDDMA_Shutdown(void)
{
+ int tmp;
if (snd_inited)
{
+ // unmap the memory
+ munmap(shm->buffer, shm->bufferlength);
+ // stop the sound
+ tmp = 0;
+ ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &tmp);
+ ioctl(audio_fd, SNDCTL_DSP_RESET, 0);
+ // close the device
close(audio_fd);
+ audio_fd = -1;
snd_inited = 0;
}
}
{
}
-
-void S_Open(void)
-{
-}
-
-void S_Close(void)
-{
-}
int reps;
int i;
- memset ((void *)&sn, 0, sizeof (sn));
-
- shm = &sn;
-
+ memset(shm, 0, sizeof(*shm));
shm->channels = 2;
shm->samplebits = 16;
i = COM_CheckParm ("-sndspeed"); // LordHavoc: -sndspeed option
pDSBuf->lpVtbl->GetCurrentPosition(pDSBuf, &mmstarttime.u.sample, &dwWrite);
pDSBuf->lpVtbl->Play(pDSBuf, 0, 0, DSBPLAY_LOOPING);
- shm->soundalive = true;
- shm->splitbuffer = false;
shm->samples = gSndBufSize/(shm->samplebits/8);
shm->samplepos = 0;
- shm->submission_chunk = 1;
shm->buffer = (unsigned char *) lpData;
sample16 = (shm->samplebits/8) - 1;
snd_sent = 0;
snd_completed = 0;
- shm = &sn;
-
+ memset(shm, 0, sizeof(*shm));
shm->channels = 2;
shm->samplebits = 16;
i = COM_CheckParm ("-sndspeed"); // LordHavoc: -sndspeed option
}
}
- shm->soundalive = true;
- shm->splitbuffer = false;
shm->samples = gSndBufSize/(shm->samplebits/8);
shm->samplepos = 0;
- shm->submission_chunk = 1;
shm->buffer = (unsigned char *) lpData;
sample16 = (shm->samplebits/8) - 1;
{
#ifndef AKVERSION
Con_DPrintf ("Sound overrun\n");
-#endif
+#endif
break;
}
pDSBuf->lpVtbl->Unlock(pDSBuf, dsound_pbuf, dsound_dwSize, dsound_pbuf2, dsound_dwSize2);
}
-void S_Open(void)
-{
-}
-
-void S_Close(void)
-{
-}
typedef struct
{
- qboolean gamealive;
- qboolean soundalive;
- qboolean splitbuffer;
int channels;
int samples; // mono samples in buffer
- int submission_chunk; // don't mix less than this #
int samplepos; // in mono samples
int samplebits;
int speed;
unsigned char *buffer;
+ int bufferlength; // used only by certain drivers
} dma_t;
typedef struct
void S_Init (void);
void S_Startup (void);
void S_Shutdown (void);
-void S_Open (void);
-void S_Close (void);
void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation);
void S_StopSound (int entnum, int entchannel);
void S_LocalSound (char *s);
sfxcache_t *S_LoadSound (sfx_t *s, int complain);
+void S_UnloadSound(sfx_t *s);
wavinfo_t GetWavinfo (char *name, qbyte *wav, int wavlength);
extern cvar_t vid_height;
extern cvar_t vid_bitsperpixel;
extern cvar_t vid_mouse;
-extern cvar_t vid_stencil;
extern cvar_t v_gamma;
extern cvar_t v_contrast;
InitSig(); // trap evil signals
}
-int VID_InitMode(int fullscreen, int width, int height, int bpp, int stencil)
+int VID_InitMode(int fullscreen, int width, int height, int bpp)
{
return false;
}
cvar_t vid_fullscreen = {CVAR_SAVE, "vid_fullscreen", "1"};
cvar_t vid_width = {CVAR_SAVE, "vid_width", "640"};
cvar_t vid_height = {CVAR_SAVE, "vid_height", "480"};
-cvar_t vid_bitsperpixel = {CVAR_SAVE, "vid_bitsperpixel", "16"};
-cvar_t vid_stencil = {CVAR_SAVE, "vid_stencil", "0"};
+cvar_t vid_bitsperpixel = {CVAR_SAVE, "vid_bitsperpixel", "32"};
cvar_t vid_mouse = {CVAR_SAVE, "vid_mouse", "1"};
cvar_t gl_combine = {CVAR_SAVE, "gl_combine", "1"};
void VID_CheckExtensions(void)
{
- gl_stencil = vid_stencil.integer;
+ gl_stencil = vid_bitsperpixel.integer == 32;
gl_combine_extension = false;
gl_dot3arb = false;
gl_supportslockarrays = false;
Cvar_RegisterVariable(&vid_width);
Cvar_RegisterVariable(&vid_height);
Cvar_RegisterVariable(&vid_bitsperpixel);
- Cvar_RegisterVariable(&vid_stencil);
Cvar_RegisterVariable(&vid_mouse);
Cvar_RegisterVariable(&gl_combine);
Cvar_RegisterVariable(&in_pitch_min);
int current_vid_width;
int current_vid_height;
int current_vid_bitsperpixel;
-int current_vid_stencil;
-extern int VID_InitMode (int fullscreen, int width, int height, int bpp, int stencil);
-int VID_Mode(int fullscreen, int width, int height, int bpp, int stencil)
+extern int VID_InitMode (int fullscreen, int width, int height, int bpp);
+int VID_Mode(int fullscreen, int width, int height, int bpp)
{
- Con_Printf("Video: %s %dx%dx%d %s\n", fullscreen ? "fullscreen" : "window", width, height, bpp, stencil ? "with stencil" : "without stencil");
- if (VID_InitMode(fullscreen, width, height, bpp, stencil))
+ Con_Printf("Video: %s %dx%dx%d\n", fullscreen ? "fullscreen" : "window", width, height, bpp);
+ if (VID_InitMode(fullscreen, width, height, bpp))
{
current_vid_fullscreen = fullscreen;
current_vid_width = width;
current_vid_height = height;
current_vid_bitsperpixel = bpp;
- current_vid_stencil = stencil;
Cvar_SetValueQuick(&vid_fullscreen, fullscreen);
Cvar_SetValueQuick(&vid_width, width);
Cvar_SetValueQuick(&vid_height, height);
Cvar_SetValueQuick(&vid_bitsperpixel, bpp);
- Cvar_SetValueQuick(&vid_stencil, stencil);
return true;
}
else
static void VID_OpenSystems(void)
{
R_Modules_Start();
- S_Open();
- CDAudio_Open();
+ S_Startup();
+ CDAudio_Startup();
}
static void VID_CloseSystems(void)
{
- CDAudio_Close();
- S_Close();
+ CDAudio_Shutdown();
+ S_Shutdown();
R_Modules_Shutdown();
}
void VID_Restart_f(void)
{
- Con_Printf("VID_Restart: changing from %s %dx%dx%dbpp %s, to %s %dx%dx%dbpp %s.\n",
- current_vid_fullscreen ? "fullscreen" : "window", current_vid_width, current_vid_height, current_vid_bitsperpixel, current_vid_stencil ? "with stencil" : "without stencil",
- vid_fullscreen.integer ? "fullscreen" : "window", vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_stencil.integer ? "with stencil" : "without stencil");
+ Con_Printf("VID_Restart: changing from %s %dx%dx%dbpp, to %s %dx%dx%dbpp.\n",
+ current_vid_fullscreen ? "fullscreen" : "window", current_vid_width, current_vid_height, current_vid_bitsperpixel,
+ vid_fullscreen.integer ? "fullscreen" : "window", vid_width.integer, vid_height.integer, vid_bitsperpixel.integer);
VID_Close();
- if (!VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_stencil.integer))
+ if (!VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer))
{
Con_Printf("Video mode change failed\n");
- if (!VID_Mode(current_vid_fullscreen, current_vid_width, current_vid_height, current_vid_bitsperpixel, current_vid_stencil))
+ if (!VID_Mode(current_vid_fullscreen, current_vid_width, current_vid_height, current_vid_bitsperpixel))
Sys_Error("Unable to restore to last working video mode\n");
}
VID_OpenSystems();
Cvar_SetValueQuick(&vid_height, height);
if ((i = COM_CheckParm("-bpp")) != 0)
Cvar_SetQuick(&vid_bitsperpixel, com_argv[i+1]);
- if ((i = COM_CheckParm("-nostencil")) != 0)
- Cvar_SetValueQuick(&vid_stencil, 0);
- if ((i = COM_CheckParm("-stencil")) != 0)
- Cvar_SetValueQuick(&vid_stencil, 1);
- }
-
- if (vid_stencil.integer && vid_bitsperpixel.integer != 32)
- {
- Con_Printf("vid_stencil not allowed without vid_bitsperpixel 32, turning off vid_stencil\n");
- Cvar_SetValueQuick(&vid_stencil, 0);
}
Con_DPrintf("Starting video system\n");
- if (!VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_stencil.integer))
+ if (!VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer))
{
Con_Printf("Desired video mode fail, trying fallbacks...\n");
- if (!vid_stencil.integer || !VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, false))
+ if (vid_fullscreen.integer)
{
- if (vid_fullscreen.integer)
- {
- if (!VID_Mode(true, 640, 480, 16, false))
- if (!VID_Mode(false, 640, 480, 16, false))
- Sys_Error("Video modes failed\n");
- }
- else
- Sys_Error("Windowed video failed\n");
+ if (!VID_Mode(true, 640, 480, 16))
+ if (!VID_Mode(false, 640, 480, 16))
+ Sys_Error("Video modes failed\n");
}
+ else
+ Sys_Error("Windowed video failed\n");
}
VID_OpenSystems();
}
IN_Init();
}
-int VID_InitMode (int fullscreen, int width, int height, int bpp, int stencil)
+int VID_InitMode (int fullscreen, int width, int height, int bpp)
{
int i;
HDC hdc;
Sys_Error("VID_InitMode called when video is already initialised\n");
// if stencil is enabled, ask for alpha too
- if (stencil)
+ if (bpp >= 32)
{
pfd.cStencilBits = 8;
pfd.cAlphaBits = 8;