亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? snd_dma.c

?? 著名游戲quake2原代碼最新版本(vc6.0可以編譯的)
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):
				*p = 0;
		}
	}
	// if we can't figure it out, they're male
	if (!model[0])
		strcpy(model, "male");

	// see if we already know of the model specific sound
	Com_sprintf (sexedFilename, sizeof(sexedFilename), "#players/%s/%s", model, base+1);
	sfx = S_FindName (sexedFilename, false);

	if (!sfx)
	{
		// no, so see if it exists
		FS_FOpenFile (&sexedFilename[1], &f);
		if (f)
		{
			// yes, close the file and register it
			FS_FCloseFile (f);
			sfx = S_RegisterSound (sexedFilename);
		}
		else
		{
			// no, revert to the male sound in the pak0.pak
			Com_sprintf (maleFilename, sizeof(maleFilename), "player/%s/%s", "male", base+1);
			sfx = S_AliasName (sexedFilename, maleFilename);
		}
	}

	return sfx;
}


// =======================================================================
// Start a sound effect
// =======================================================================

/*
====================
S_StartSound

Validates the parms and ques the sound up
if pos is NULL, the sound will be dynamically sourced from the entity
Entchannel 0 will never override a playing sound
====================
*/
void S_StartSound(vec3_t origin, int entnum, int entchannel, sfx_t *sfx, float fvol, float attenuation, float timeofs)
{
	sfxcache_t	*sc;
	int			vol;
	playsound_t	*ps, *sort;
	int			start;

	if (!sound_started)
		return;

	if (!sfx)
		return;

	if (sfx->name[0] == '*')
		sfx = S_RegisterSexedSound(&cl_entities[entnum].current, sfx->name);

	// make sure the sound is loaded
	sc = S_LoadSound (sfx);
	if (!sc)
		return;		// couldn't load the sound's data

	vol = fvol*255;

	// make the playsound_t
	ps = S_AllocPlaysound ();
	if (!ps)
		return;

	if (origin)
	{
		VectorCopy (origin, ps->origin);
		ps->fixed_origin = true;
	}
	else
		ps->fixed_origin = false;

	ps->entnum = entnum;
	ps->entchannel = entchannel;
	ps->attenuation = attenuation;
	ps->volume = vol;
	ps->sfx = sfx;

	// drift s_beginofs
	start = cl.frame.servertime * 0.001 * dma.speed + s_beginofs;
	if (start < paintedtime)
	{
		start = paintedtime;
		s_beginofs = start - (cl.frame.servertime * 0.001 * dma.speed);
	}
	else if (start > paintedtime + 0.3 * dma.speed)
	{
		start = paintedtime + 0.1 * dma.speed;
		s_beginofs = start - (cl.frame.servertime * 0.001 * dma.speed);
	}
	else
	{
		s_beginofs-=10;
	}

	if (!timeofs)
		ps->begin = paintedtime;
	else
		ps->begin = start + timeofs * dma.speed;

	// sort into the pending sound list
	for (sort = s_pendingplays.next ; 
		sort != &s_pendingplays && sort->begin < ps->begin ;
		sort = sort->next)
			;

	ps->next = sort;
	ps->prev = sort->prev;

	ps->next->prev = ps;
	ps->prev->next = ps;
}


/*
==================
S_StartLocalSound
==================
*/
void S_StartLocalSound (char *sound)
{
	sfx_t	*sfx;

	if (!sound_started)
		return;
		
	sfx = S_RegisterSound (sound);
	if (!sfx)
	{
		Com_Printf ("S_StartLocalSound: can't cache %s\n", sound);
		return;
	}
	S_StartSound (NULL, cl.playernum+1, 0, sfx, 1, 1, 0);
}


/*
==================
S_ClearBuffer
==================
*/
void S_ClearBuffer (void)
{
	int		clear;
		
	if (!sound_started)
		return;

	s_rawend = 0;

	if (dma.samplebits == 8)
		clear = 0x80;
	else
		clear = 0;

	SNDDMA_BeginPainting ();
	if (dma.buffer)
		memset(dma.buffer, clear, dma.samples * dma.samplebits/8);
	SNDDMA_Submit ();
}

/*
==================
S_StopAllSounds
==================
*/
void S_StopAllSounds(void)
{
	int		i;

	if (!sound_started)
		return;

	// clear all the playsounds
	memset(s_playsounds, 0, sizeof(s_playsounds));
	s_freeplays.next = s_freeplays.prev = &s_freeplays;
	s_pendingplays.next = s_pendingplays.prev = &s_pendingplays;

	for (i=0 ; i<MAX_PLAYSOUNDS ; i++)
	{
		s_playsounds[i].prev = &s_freeplays;
		s_playsounds[i].next = s_freeplays.next;
		s_playsounds[i].prev->next = &s_playsounds[i];
		s_playsounds[i].next->prev = &s_playsounds[i];
	}

	// clear all the channels
	memset(channels, 0, sizeof(channels));

	S_ClearBuffer ();
}

/*
==================
S_AddLoopSounds

Entities with a ->sound field will generated looped sounds
that are automatically started, stopped, and merged together
as the entities are sent to the client
==================
*/
void S_AddLoopSounds (void)
{
	int			i, j;
	int			sounds[MAX_EDICTS];
	int			left, right, left_total, right_total;
	channel_t	*ch;
	sfx_t		*sfx;
	sfxcache_t	*sc;
	int			num;
	entity_state_t	*ent;

	if (cl_paused->value)
		return;

	if (cls.state != ca_active)
		return;

	if (!cl.sound_prepped)
		return;

	for (i=0 ; i<cl.frame.num_entities ; i++)
	{
		num = (cl.frame.parse_entities + i)&(MAX_PARSE_ENTITIES-1);
		ent = &cl_parse_entities[num];
		sounds[i] = ent->sound;
	}

	for (i=0 ; i<cl.frame.num_entities ; i++)
	{
		if (!sounds[i])
			continue;

		sfx = cl.sound_precache[sounds[i]];
		if (!sfx)
			continue;		// bad sound effect
		sc = sfx->cache;
		if (!sc)
			continue;

		num = (cl.frame.parse_entities + i)&(MAX_PARSE_ENTITIES-1);
		ent = &cl_parse_entities[num];

		// find the total contribution of all sounds of this type
		S_SpatializeOrigin (ent->origin, 255.0, SOUND_LOOPATTENUATE,
			&left_total, &right_total);
		for (j=i+1 ; j<cl.frame.num_entities ; j++)
		{
			if (sounds[j] != sounds[i])
				continue;
			sounds[j] = 0;	// don't check this again later

			num = (cl.frame.parse_entities + j)&(MAX_PARSE_ENTITIES-1);
			ent = &cl_parse_entities[num];

			S_SpatializeOrigin (ent->origin, 255.0, SOUND_LOOPATTENUATE, 
				&left, &right);
			left_total += left;
			right_total += right;
		}

		if (left_total == 0 && right_total == 0)
			continue;		// not audible

		// allocate a channel
		ch = S_PickChannel(0, 0);
		if (!ch)
			return;

		if (left_total > 255)
			left_total = 255;
		if (right_total > 255)
			right_total = 255;
		ch->leftvol = left_total;
		ch->rightvol = right_total;
		ch->autosound = true;	// remove next frame
		ch->sfx = sfx;
		ch->pos = paintedtime % sc->length;
		ch->end = paintedtime + sc->length - ch->pos;
	}
}

//=============================================================================

/*
============
S_RawSamples

Cinematic streaming and voice over network
============
*/
void S_RawSamples (int samples, int rate, int width, int channels, byte *data)
{
	int		i;
	int		src, dst;
	float	scale;

	if (!sound_started)
		return;

	if (s_rawend < paintedtime)
		s_rawend = paintedtime;
	scale = (float)rate / dma.speed;

//Com_Printf ("%i < %i < %i\n", soundtime, paintedtime, s_rawend);
	if (channels == 2 && width == 2)
	{
		if (scale == 1.0)
		{	// optimized case
			for (i=0 ; i<samples ; i++)
			{
				dst = s_rawend&(MAX_RAW_SAMPLES-1);
				s_rawend++;
				s_rawsamples[dst].left =
				    LittleShort(((short *)data)[i*2]) << 8;
				s_rawsamples[dst].right =
				    LittleShort(((short *)data)[i*2+1]) << 8;
			}
		}
		else
		{
			for (i=0 ; ; i++)
			{
				src = i*scale;
				if (src >= samples)
					break;
				dst = s_rawend&(MAX_RAW_SAMPLES-1);
				s_rawend++;
				s_rawsamples[dst].left =
				    LittleShort(((short *)data)[src*2]) << 8;
				s_rawsamples[dst].right =
				    LittleShort(((short *)data)[src*2+1]) << 8;
			}
		}
	}
	else if (channels == 1 && width == 2)
	{
		for (i=0 ; ; i++)
		{
			src = i*scale;
			if (src >= samples)
				break;
			dst = s_rawend&(MAX_RAW_SAMPLES-1);
			s_rawend++;
			s_rawsamples[dst].left =
			    LittleShort(((short *)data)[src]) << 8;
			s_rawsamples[dst].right =
			    LittleShort(((short *)data)[src]) << 8;
		}
	}
	else if (channels == 2 && width == 1)
	{
		for (i=0 ; ; i++)
		{
			src = i*scale;
			if (src >= samples)
				break;
			dst = s_rawend&(MAX_RAW_SAMPLES-1);
			s_rawend++;
			s_rawsamples[dst].left =
			    ((char *)data)[src*2] << 16;
			s_rawsamples[dst].right =
			    ((char *)data)[src*2+1] << 16;
		}
	}
	else if (channels == 1 && width == 1)
	{
		for (i=0 ; ; i++)
		{
			src = i*scale;
			if (src >= samples)
				break;
			dst = s_rawend&(MAX_RAW_SAMPLES-1);
			s_rawend++;
			s_rawsamples[dst].left =
			    (((byte *)data)[src]-128) << 16;
			s_rawsamples[dst].right = (((byte *)data)[src]-128) << 16;
		}
	}
}

//=============================================================================

/*
============
S_Update

Called once each time through the main loop
============
*/
void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
{
	int			i;
	int			total;
	channel_t	*ch;
	channel_t	*combine;

	if (!sound_started)
		return;

	// if the laoding plaque is up, clear everything
	// out to make sure we aren't looping a dirty
	// dma buffer while loading
	if (cls.disable_screen)
	{
		S_ClearBuffer ();
		return;
	}

	// rebuild scale tables if volume is modified
	if (s_volume->modified)
		S_InitScaletable ();

	VectorCopy(origin, listener_origin);
	VectorCopy(forward, listener_forward);
	VectorCopy(right, listener_right);
	VectorCopy(up, listener_up);

	combine = NULL;

	// update spatialization for dynamic sounds	
	ch = channels;
	for (i=0 ; i<MAX_CHANNELS; i++, ch++)
	{
		if (!ch->sfx)
			continue;
		if (ch->autosound)
		{	// autosounds are regenerated fresh each frame
			memset (ch, 0, sizeof(*ch));
			continue;
		}
		S_Spatialize(ch);         // respatialize channel
		if (!ch->leftvol && !ch->rightvol)
		{
			memset (ch, 0, sizeof(*ch));
			continue;
		}
	}

	// add loopsounds
	S_AddLoopSounds ();

	//
	// debugging output
	//
	if (s_show->value)
	{
		total = 0;
		ch = channels;
		for (i=0 ; i<MAX_CHANNELS; i++, ch++)
			if (ch->sfx && (ch->leftvol || ch->rightvol) )
			{
				Com_Printf ("%3i %3i %s\n", ch->leftvol, ch->rightvol, ch->sfx->name);
				total++;
			}
		
		Com_Printf ("----(%i)---- painted: %i\n", total, paintedtime);
	}

// mix some sound
	S_Update_();
}

void GetSoundtime(void)
{
	int		samplepos;
	static	int		buffers;
	static	int		oldsamplepos;
	int		fullsamples;
	
	fullsamples = dma.samples / dma.channels;

// it is possible to miscount buffers if it has wrapped twice between
// calls to S_Update.  Oh well.
	samplepos = SNDDMA_GetDMAPos();

	if (samplepos < oldsamplepos)
	{
		buffers++;					// buffer wrapped
		
		if (paintedtime > 0x40000000)
		{	// time to chop things off to avoid 32 bit limits
			buffers = 0;
			paintedtime = fullsamples;
			S_StopAllSounds ();
		}
	}
	oldsamplepos = samplepos;

	soundtime = buffers*fullsamples + samplepos/dma.channels;
}


void S_Update_(void)
{
	unsigned        endtime;
	int				samps;

	if (!sound_started)
		return;

	SNDDMA_BeginPainting ();

	if (!dma.buffer)
		return;

// Updates DMA time
	GetSoundtime();

// check to make sure that we haven't overshot
	if (paintedtime < soundtime)
	{
		Com_DPrintf ("S_Update_ : overflow\n");
		paintedtime = soundtime;
	}

// mix ahead of current position
	endtime = soundtime + s_mixahead->value * dma.speed;
//endtime = (soundtime + 4096) & ~4095;

	// mix to an even submission block size
	endtime = (endtime + dma.submission_chunk-1)
		& ~(dma.submission_chunk-1);
	samps = dma.samples >> (dma.channels-1);
	if (endtime - soundtime > samps)
		endtime = soundtime + samps;

	S_PaintChannels (endtime);

	SNDDMA_Submit ();
}

/*
===============================================================================

console functions

===============================================================================
*/

void S_Play(void)
{
	int 	i;
	char name[256];
	sfx_t	*sfx;
	
	i = 1;
	while (i<Cmd_Argc())
	{
		if (!strrchr(Cmd_Argv(i), '.'))
		{
			strcpy(name, Cmd_Argv(i));
			strcat(name, ".wav");
		}
		else
			strcpy(name, Cmd_Argv(i));
		sfx = S_RegisterSound(name);
		S_StartSound(NULL, cl.playernum+1, 0, sfx, 1.0, 1.0, 0);
		i++;
	}
}

void S_SoundList(void)
{
	int		i;
	sfx_t	*sfx;
	sfxcache_t	*sc;
	int		size, total;

	total = 0;
	for (sfx=known_sfx, i=0 ; i<num_sfx ; i++, sfx++)
	{
		if (!sfx->registration_sequence)
			continue;
		sc = sfx->cache;
		if (sc)
		{
			size = sc->length*sc->width*(sc->stereo+1);
			total += size;
			if (sc->loopstart >= 0)
				Com_Printf ("L");
			else
				Com_Printf (" ");
			Com_Printf("(%2db) %6i : %s\n",sc->width*8,  size, sfx->name);
		}
		else
		{
			if (sfx->name[0] == '*')
				Com_Printf("  placeholder : %s\n", sfx->name);
			else
				Com_Printf("  not loaded  : %s\n", sfx->name);
		}
	}
	Com_Printf ("Total resident: %i\n", total);
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
婷婷国产在线综合| 欧美在线观看一区二区| 色欧美片视频在线观看| 欧美精品在线观看播放| 久久久久99精品一区| 亚洲国产一区视频| 国产99久久久国产精品| 91精品综合久久久久久| 亚洲综合久久av| 不卡免费追剧大全电视剧网站| 91精品婷婷国产综合久久| 《视频一区视频二区| 国产原创一区二区| 欧美一区中文字幕| 亚洲成人综合网站| 91国偷自产一区二区三区观看| 国产偷国产偷精品高清尤物| 美女任你摸久久 | 亚洲国产精品久久久男人的天堂 | 亚洲精品欧美激情| 高清久久久久久| 久久亚洲二区三区| 激情综合五月婷婷| 精品久久人人做人人爰| 蜜臀久久99精品久久久画质超高清 | 国产综合久久久久影院| 欧美人体做爰大胆视频| 亚洲综合视频在线观看| 色先锋久久av资源部| 亚洲欧美在线aaa| 99久久er热在这里只有精品66| 国产亚洲欧美激情| 成人午夜伦理影院| 欧美经典一区二区| 国产69精品久久久久777| 久久久亚洲精华液精华液精华液| 精品一区二区三区在线播放| 精品国产乱码久久久久久浪潮| 美女视频第一区二区三区免费观看网站 | 一区二区三区**美女毛片| 色哟哟一区二区在线观看| 亚洲免费观看高清完整版在线观看 | 国产精品三级视频| 大白屁股一区二区视频| 国产欧美日韩精品一区| 成人听书哪个软件好| 亚洲欧洲成人av每日更新| 91免费看视频| 亚洲国产成人av网| 欧美不卡视频一区| 成人国产视频在线观看| 亚洲欧美成aⅴ人在线观看 | 91亚洲国产成人精品一区二三| 自拍偷自拍亚洲精品播放| 91成人国产精品| 日韩电影在线免费观看| 久久人人超碰精品| 日本高清无吗v一区| 天天影视色香欲综合网老头| 欧美成人午夜电影| 99久久婷婷国产综合精品电影| 亚洲青青青在线视频| 欧美一区二区在线观看| 丰满岳乱妇一区二区三区| 亚洲精品国产品国语在线app| 宅男在线国产精品| www.色精品| 丝袜亚洲另类欧美| 国产欧美日韩中文久久| 欧美日韩一区三区| 国产成人日日夜夜| 五月天激情综合| 国产精品色一区二区三区| 欧美日韩一区二区三区四区五区| 国产一区二区导航在线播放| 亚洲欧美日韩一区二区 | 欧美日韩成人高清| 国产成人a级片| 午夜精品在线视频一区| 国产精品萝li| 欧美sm美女调教| 在线观看亚洲成人| 国产**成人网毛片九色| 午夜精品久久久久久久久久久 | 成人一级视频在线观看| 美女被吸乳得到大胸91| 亚洲男人天堂av网| 亚洲国产成人私人影院tom| 欧美一区日韩一区| 色妹子一区二区| 粉嫩一区二区三区在线看| 蜜臀国产一区二区三区在线播放| 亚洲免费在线视频一区 二区| 精品处破学生在线二十三| 欧美性猛交xxxx黑人交 | 国产mv日韩mv欧美| 青青草原综合久久大伊人精品优势| 亚洲人精品一区| 国产精品国产三级国产普通话99| 日韩美女一区二区三区四区| 欧美亚洲高清一区| 色婷婷亚洲精品| 不卡的av电影在线观看| 国产成人av一区二区三区在线 | 成人污污视频在线观看| 国产专区欧美精品| 狠狠色狠狠色合久久伊人| 免费成人av在线播放| 丝袜诱惑制服诱惑色一区在线观看| 亚洲综合在线电影| 一区二区国产盗摄色噜噜| 亚洲欧美日韩国产手机在线 | 精品国产一区二区三区久久久蜜月 | 另类小说综合欧美亚洲| 日韩在线一区二区三区| 亚洲第一成人在线| 亚洲h精品动漫在线观看| 香蕉乱码成人久久天堂爱免费| 亚洲综合在线电影| 亚洲v中文字幕| 丝袜美腿一区二区三区| 日本不卡一二三| 狠狠色狠狠色合久久伊人| 久久爱另类一区二区小说| 国产一区福利在线| 国产一区二区精品在线观看| 国产精品一线二线三线精华| 高清不卡一区二区| 成人午夜碰碰视频| 在线一区二区三区四区五区| 欧美三级乱人伦电影| 91精品久久久久久久99蜜桃| 日韩美女一区二区三区四区| 精品国产乱码久久| 国产精品久久久久久福利一牛影视 | 一本一道久久a久久精品综合蜜臀 一本一道综合狠狠老 | 色婷婷精品久久二区二区蜜臀av| 在线免费观看一区| 欧美一区二区日韩一区二区| 久久综合久色欧美综合狠狠| 国产日韩av一区| 亚洲一区二区欧美激情| 久久精品99国产精品| 粉嫩蜜臀av国产精品网站| 91小视频免费观看| 日韩亚洲欧美中文三级| 国产无遮挡一区二区三区毛片日本| 中文字幕av一区 二区| 亚洲午夜在线观看视频在线| 麻豆国产精品一区二区三区 | 欧美三级日韩三级| 欧美成人精品1314www| 中文字幕亚洲精品在线观看| 视频精品一区二区| 成人亚洲一区二区一| 在线电影国产精品| 国产农村妇女毛片精品久久麻豆 | 中文字幕一区不卡| 秋霞电影网一区二区| 99久久亚洲一区二区三区青草| 在线电影院国产精品| 中文字幕视频一区二区三区久| 青青草精品视频| 91在线视频免费91| 26uuu另类欧美| 亚洲不卡在线观看| 99精品久久只有精品| 精品蜜桃在线看| 亚洲国产日产av| 99久久99久久久精品齐齐| 日韩欧美另类在线| 亚洲精品高清在线观看| 国产成人av一区二区三区在线 | 国产亚洲短视频| 丝袜美腿高跟呻吟高潮一区| av一区二区三区四区| 精品少妇一区二区三区 | 欧美精品久久99久久在免费线| 久久久久久**毛片大全| 亚洲gay无套男同| 色婷婷精品大在线视频| 国产精品色婷婷| 国产乱码精品一品二品| 精品人在线二区三区| 日韩精品免费专区| 欧美日韩成人在线一区| 亚洲理论在线观看| www.99精品| 中文字幕电影一区| 国产成人自拍高清视频在线免费播放 | 国产色产综合产在线视频| 久久电影网站中文字幕| 日韩一区二区三区电影在线观看| 一区二区三区在线影院| 一本大道久久a久久精二百| 亚洲欧洲成人自拍| 一本久久a久久免费精品不卡| ...xxx性欧美| 色妹子一区二区| 伊人婷婷欧美激情|