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

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

?? s_sound.c

?? 游戲類程序源代碼---WinDoom 3D源程序.zip
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):
// Emacs style mode select   -*- C++ -*- 
//-----------------------------------------------------------------------------
//
// $Id:$
//
// Copyright (C) 1993-1996 by id Software, Inc.
//
// This source is available for distribution and/or modification
// only under the terms of the DOOM Source Code License as
// published by id Software. All rights reserved.
//
// The source is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
// for more details.
//
// $Log:$
//
// DESCRIPTION:  none
//
//-----------------------------------------------------------------------------


static const char
rcsid[] = "$Id: s_sound.c,v 1.6 1997/02/03 22:45:12 b1 Exp $";



#include <stdio.h>
#include <stdlib.h>

#include "i_system.h"
#include "i_sound.h"
#include "sounds.h"
#include "s_sound.h"

#include "z_zone.h"
#include "m_random.h"
#include "w_wad.h"

#include "doomdef.h"
#include "p_local.h"

#include "doomstat.h"

void WriteDebug(char *);

// Purpose?
const char snd_prefixen[]
= { 'P', 'P', 'A', 'S', 'S', 'S', 'M', 'M', 'M', 'S', 'S', 'S' };

#define S_MAX_VOLUME		127

// when to clip out sounds
// Does not fit the large outdoor areas.
#define S_CLIPPING_DIST		(1200*0x10000)

// Distance tp origin when sounds should be maxed out.
// This should relate to movement clipping resolution
// (see BLOCKMAP handling).
// Originally: (200*0x10000).
#define S_CLOSE_DIST		(160*0x10000)


#define S_ATTENUATOR		((S_CLIPPING_DIST-S_CLOSE_DIST)>>FRACBITS)

// Adjustable by menu.
#define NORM_VOLUME    		snd_MaxVolume

#define NORM_PITCH     		128
#define NORM_PRIORITY		64
#define NORM_SEP		128

#define S_PITCH_PERTURB		1
#define S_STEREO_SWING		(96*0x10000)

// percent attenuation from front to back
#define S_IFRACVOL		30

#define NA			0
#define S_NUMCHANNELS		2

#define NUM_DSBUFFERS      256

// Current music/sfx card - index useless
//  w/o a reference LUT in a sound module.
extern int snd_MusicDevice;
extern int snd_SfxDevice;
// Config file? Same disclaimer as above.
extern int snd_DesiredMusicDevice;
extern int snd_DesiredSfxDevice;



typedef struct
{
    // sound information (if null, channel avail.)
    sfxinfo_t*	sfxinfo;

    // origin of sound
    void*	origin;

    // handle of the sound being played
    int		handle;
    
} channel_t;


// the set of channels available
static channel_t*	channels;

// These are not used, but should be (menu).
// Maximum volume of a sound effect.
// Internal default is max out of 0-15.
int 		snd_SfxVolume = 15;

// Maximum volume of music. Useless so far.
int 		snd_MusicVolume = 15; 



// whether songs are mus_paused
static boolean		mus_paused;	

// music currently being played
static musicinfo_t*	mus_playing=0;

// following is set
//  by the defaults code in M_misc:
// number of channels available
int			numChannels;	

static int		nextcleanup;



//
// Internals.
//
int
S_getChannel
( void*		origin,
  sfxinfo_t*	sfxinfo,
  int       sfxid );


int
S_AdjustSoundParams
( mobj_t*	listener,
  mobj_t*	source,
  int*		vol,
  int*		sep,
  int*		pitch );

void S_StopChannel(int cnum);



//
// Initializes sound stuff, including volume
// Sets channels, SFX and music volume,
//  allocates channel buffer, sets S_sfx lookup.
//
void S_Init
( int		sfxVolume,
  int		musicVolume )
{  
  int		i;

  fprintf( stderr, "S_Init: default sfx volume %d\n", sfxVolume);

  numChannels = NUM_DSBUFFERS;

  // Whatever these did with DMX, these are rather dummies now.
  I_SetChannels();
  
  S_SetSfxVolume(sfxVolume);
  // No music with Linux - another dummy.
  S_SetMusicVolume(musicVolume);

  // Allocating the internal channels for mixing
  // (the maximum numer of sounds rendered
  // simultaneously) within zone memory.
  channels =
    (channel_t *) Z_Malloc(numChannels*sizeof(channel_t), PU_STATIC, 0);
  
  // Free all channels for use
  for (i=0 ; i<numChannels ; i++)
    channels[i].sfxinfo = 0;
  
  // no sounds are playing, and they are not mus_paused
  mus_paused = 0;

  // Note that sounds have not been cached (yet).
  for (i=1 ; i<NUMSFX ; i++)
    S_sfx[i].lumpnum = S_sfx[i].usefulness = -1;
}




//
// Per level startup code.
// Kills playing sounds at start of level,
//  determines music if any, changes music.
//
void S_Start(void)
{
  int cnum;
  int mnum;

  // kill all playing sounds at start of level
  //  (trust me - a good idea)
  for (cnum=0 ; cnum<numChannels ; cnum++)
    if (channels[cnum].sfxinfo)
      S_StopChannel(cnum);
  
  // start new music for the level
  mus_paused = 0;
  
  if (gamemode == commercial)
    mnum = mus_runnin + gamemap - 1;
  else
  {
    int spmus[]=
    {
      // Song - Who? - Where?
      
      mus_e3m4,	// American	e4m1
      mus_e3m2,	// Romero	e4m2
      mus_e3m3,	// Shawn	e4m3
      mus_e1m5,	// American	e4m4
      mus_e2m7,	// Tim 	e4m5
      mus_e2m4,	// Romero	e4m6
      mus_e2m6,	// J.Anderson	e4m7 CHIRON.WAD
      mus_e2m5,	// Shawn	e4m8
      mus_e1m9	// Tim		e4m9
    };
    
    if (gameepisode < 4)
      mnum = mus_e1m1 + (gameepisode-1)*9 + gamemap-1;
    else
      mnum = spmus[gamemap-1];
    }	
  
  // HACK FOR COMMERCIAL
  //  if (commercial && mnum > mus_e3m9)	
  //      mnum -= mus_e3m9;
  
  S_ChangeMusic(mnum, true);
  
  nextcleanup = 15;
}	

void S_StartSoundAtVolume( void *origin_p, int sfx_id, int volume )
   {
    int        rc;
    int        sep;
    int        pitch;
    int        priority;
    sfxinfo_t *sfx;
    int        cnum;
    int        chnum;
  
    mobj_t*	origin = (mobj_t *)origin_p;
  
    //WriteDebug("S_StartSoundAtVolume...\n");
  
    // Debug.
    /*fprintf( stderr,"S_StartSoundAtVolume: playing sound %d (%s)\n",sfx_id, S_sfx[sfx_id].name );*/
  
    // check for bogus sound #
    if (sfx_id < 1 || sfx_id > NUMSFX)
        I_Error("Bad sfx #: %d", sfx_id);
  
    sfx = &S_sfx[sfx_id];
  
    // Initialize sound parameters
    if (sfx->link)
       {
        pitch = sfx->pitch;
        priority = sfx->priority;
        volume += sfx->volume;
    
        if (volume < 1)
           {
            //WriteDebug("Volume off...\n");
            return;
           }
    
        if (volume > snd_SfxVolume)
            volume = snd_SfxVolume;
       }	
    else
       {
        pitch = NORM_PITCH;
        priority = NORM_PRIORITY;
       }


    // Check to see if it is audible,
    //  and if not, modify the params
    if (origin && origin != players[consoleplayer].mo)
       {
        rc = S_AdjustSoundParams(players[consoleplayer].mo, origin, &volume, &sep, &pitch);
        if ( origin->x == players[consoleplayer].mo->x && origin->y == players[consoleplayer].mo->y)
           {	
            sep = NORM_SEP;
           }
        if (!rc)
           {
            //WriteDebug("No rc from S_AdjustSoundParams...\n");
            return;
           }
       }	
    else
       {
        sep = NORM_SEP;
       }
  
    // hacks to vary the sfx pitches
    if (sfx_id >= sfx_sawup && sfx_id <= sfx_sawhit)
       {	
        pitch += 8 - (M_Random()&15);
        if (pitch < 0)
            pitch = 0;
        else
        if (pitch>255)
            pitch = 255;
       }
    else
    if (sfx_id != sfx_itemup && sfx_id != sfx_tink)
       {
        pitch += 16 - (M_Random()&31);
        if (pitch<0)
            pitch = 0;
        else
        if (pitch > 255)
            pitch = 255;
       }

  // kill old sound
  S_StopSound(origin);

/*
  // try to find a channel
  cnum = S_getChannel(origin, sfx, sfx_id);
  
  if (cnum<0)
     {
        //WriteDebug("cnum < 0 -- no channel...\n");
    return;
     }

*/
  //
  // This is supposed to handle the loading/caching.
  // For some odd reason, the caching is done nearly
  //  each time the sound is needed?
  //
  
  // get lumpnum if necessary
  if (sfx->lumpnum < 0)
    sfx->lumpnum = I_GetSfxLumpNum(sfx);

#ifndef SNDSRV
  // cache data if necessary
  if (!sfx->data)
  {
    fprintf( stderr,
	     "S_StartSoundAtVolume: 16bit and not pre-cached - wtf?\n");

    // DOS remains, 8bit handling
    //sfx->data = (void *) W_CacheLumpNum(sfx->lumpnum, PU_MUSIC);
    // fprintf( stderr,
    //	     "S_StartSoundAtVolume: loading %d (lump %d) : 0x%x\n",
    //       sfx_id, sfx->lumpnum, (int)sfx->data );
    
  }
#endif
  
  // increase the usefulness
  if (sfx->usefulness++ < 0)
      sfx->usefulness = 1;
  
  // Assigns the handle to one of the channels in the
  //  mix/output buffer.
  //WriteDebug("I_StartSound...\n");
  //channels[cnum].handle = I_StartSound(sfx_id,/*sfx->data,*/volume,sep,pitch,priority,origin);
  cnum = I_StartSound(sfx_id,/*sfx->data,*/volume,sep,pitch,priority,origin);
  channels[cnum].handle = cnum;
  channels[cnum].sfxinfo = sfx;
  channels[cnum].origin = origin;
}	

void S_StartSound( void *origin, int sfx_id )
   {
#ifdef SAWDEBUG
    // if (sfx_id == sfx_sawful)
    // sfx_id = sfx_itemup;
#endif

    S_StartSoundAtVolume(origin, sfx_id, snd_SfxVolume);


    // UNUSED. We had problems, had we not?
#ifdef SAWDEBUG
{
    int i;
    int n;
	
    static mobj_t*      last_saw_origins[10] = {1,1,1,1,1,1,1,1,1,1};
    static int		first_saw=0;
    static int		next_saw=0;
	
    if (sfx_id == sfx_sawidl
	|| sfx_id == sfx_sawful
	|| sfx_id == sfx_sawhit)
    {
	for (i=first_saw;i!=next_saw;i=(i+1)%10)
	    if (last_saw_origins[i] != origin)
		fprintf(stderr, "old origin 0x%lx != "
			"origin 0x%lx for sfx %d\n",
			last_saw_origins[i],
			origin,
			sfx_id);
	    
	last_saw_origins[next_saw] = origin;
	next_saw = (next_saw + 1) % 10;
	if (next_saw == first_saw)
	    first_saw = (first_saw + 1) % 10;
	    
	for (n=i=0; i<numChannels ; i++)
	{
	    if (channels[i].sfxinfo == &S_sfx[sfx_sawidl]
		|| channels[i].sfxinfo == &S_sfx[sfx_sawful]
		|| channels[i].sfxinfo == &S_sfx[sfx_sawhit]) n++;
	}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人免费视频在线观看| 欧美高清性hdvideosex| 国产亚洲va综合人人澡精品 | av不卡在线观看| 国产精品久久夜| 一本大道久久a久久综合| 亚洲欧美激情插| 91精品麻豆日日躁夜夜躁| 久久 天天综合| 国产精品成人午夜| 欧美日韩精品高清| 日本欧美大码aⅴ在线播放| 2020日本不卡一区二区视频| 粉嫩一区二区三区在线看| 亚洲欧美激情一区二区| 91麻豆精品国产91久久久久久久久 | 91精品国产综合久久久久久久| 婷婷综合五月天| 日韩精品自拍偷拍| 成人精品电影在线观看| 亚洲线精品一区二区三区八戒| 日韩午夜小视频| 成人毛片老司机大片| 亚洲一区二区av电影| 欧美va在线播放| 99久久久久久| 青青草精品视频| 国产精品午夜在线观看| 欧美日本韩国一区二区三区视频| 国内精品在线播放| 亚洲国产色一区| 久久精品日韩一区二区三区| 在线一区二区三区四区五区| 韩国v欧美v日本v亚洲v| 亚洲影视在线播放| 欧美精品一区二| 欧美少妇xxx| 丁香网亚洲国际| 免费美女久久99| 亚洲激情五月婷婷| www欧美成人18+| 欧美肥胖老妇做爰| 91在线视频在线| 国产乱人伦偷精品视频免下载| 亚洲一区成人在线| 中文字幕一区二| 久久综合中文字幕| 欧美一级在线视频| 欧美色电影在线| 97精品久久久久中文字幕| 国产乱国产乱300精品| 日韩av在线发布| 一区二区三区四区激情 | 日韩一级片在线观看| 日本道在线观看一区二区| 成人综合激情网| 国产剧情av麻豆香蕉精品| 欧美在线观看18| 懂色av噜噜一区二区三区av| 久久99热国产| 九九视频精品免费| 免费人成网站在线观看欧美高清| 亚洲国产日韩a在线播放| 亚洲人成7777| 亚洲精品ww久久久久久p站| 国产精品亲子乱子伦xxxx裸| 久久久九九九九| 久久奇米777| 久久众筹精品私拍模特| 久久综合给合久久狠狠狠97色69| 日韩一区二区三区四区五区六区| 欧美老女人在线| 欧美日韩国产影片| 欧美调教femdomvk| 欧美天天综合网| 欧美日韩国产色站一区二区三区| 在线观看91精品国产入口| 欧洲精品一区二区| 欧美日韩国产影片| 日韩免费看的电影| 久久综合九色综合欧美98| 久久久精品日韩欧美| 国产欧美日韩视频一区二区| 久久精品夜色噜噜亚洲a∨| 久久久久9999亚洲精品| 国产精品国产三级国产| 亚洲精品欧美综合四区| 亚洲国产精品久久久久婷婷884| 性做久久久久久免费观看| 琪琪久久久久日韩精品| 国产真实精品久久二三区| 国产91在线观看丝袜| 91小视频在线| 欧美日韩三级一区二区| 日韩一区二区三区视频在线| 26uuu国产在线精品一区二区| 国产亚洲一区二区在线观看| 日韩毛片一二三区| 亚洲成a人v欧美综合天堂 | 国产三级三级三级精品8ⅰ区| 欧美国产日韩精品免费观看| 亚洲精品你懂的| 日韩av中文字幕一区二区三区| 国产一区日韩二区欧美三区| 99久久精品免费看国产| 欧美精品高清视频| 亚洲精品一区二区在线观看| 国产精品久久久久久久久晋中| 亚洲va欧美va国产va天堂影院| 黑人精品欧美一区二区蜜桃| 91免费看`日韩一区二区| 91精品欧美福利在线观看| 久久久精品国产免大香伊| 亚洲裸体xxx| 看电视剧不卡顿的网站| zzijzzij亚洲日本少妇熟睡| 欧美日韩黄色一区二区| 国产女人18毛片水真多成人如厕| 一区二区在线观看不卡| 国产在线不卡视频| 欧美午夜理伦三级在线观看| 久久久综合网站| 天堂一区二区在线| 成人97人人超碰人人99| 欧美一级搡bbbb搡bbbb| 亚洲欧美偷拍另类a∨色屁股| 男女男精品视频| 91美女视频网站| 久久久精品综合| 奇米色一区二区三区四区| 91丨九色porny丨蝌蚪| 久久女同性恋中文字幕| 日韩专区中文字幕一区二区| 99久久婷婷国产综合精品电影 | 国产日韩欧美制服另类| 午夜欧美电影在线观看| 成人毛片在线观看| 精品福利av导航| 日韩国产在线观看| 色视频一区二区| 国产欧美一区二区精品久导航| 免费观看成人av| 欧美日韩一区二区电影| 亚洲丝袜美腿综合| 国产69精品久久777的优势| 欧美mv日韩mv国产网站app| 亚洲一区二区黄色| 色噜噜狠狠色综合中国| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 色综合久久久久久久久久久| 久久精品视频免费| 国内精品久久久久影院薰衣草| 制服丝袜一区二区三区| 91污在线观看| 综合在线观看色| 成人97人人超碰人人99| 国产精品久久久久三级| 国产一区二区三区香蕉| 久久一夜天堂av一区二区三区| 蜜臀精品久久久久久蜜臀| 欧美精品一卡两卡| 日韩国产精品久久| 91精品综合久久久久久| 偷拍日韩校园综合在线| 在线不卡a资源高清| 午夜精品久久一牛影视| 欧美久久婷婷综合色| 午夜精品国产更新| 欧美福利电影网| 另类的小说在线视频另类成人小视频在线 | 一区二区三区av电影| 日本道免费精品一区二区三区| 亚洲精选免费视频| 色老综合老女人久久久| 一区二区三区日韩| 欧美精品久久一区二区三区| 日韩高清中文字幕一区| 日韩一级黄色片| 国产精品18久久久久久vr| 欧美国产97人人爽人人喊| 99久久精品情趣| 亚洲成人自拍网| 日韩精品在线一区| 国产九色sp调教91| 亚洲嫩草精品久久| 91精品国产91久久综合桃花| 久99久精品视频免费观看| 国产欧美一区二区精品久导航| av不卡在线观看| 天天色综合天天| www精品美女久久久tv| 97se亚洲国产综合自在线不卡| 亚洲午夜激情网站| 欧美xxxxx牲另类人与| 成人国产精品免费网站| 香蕉久久夜色精品国产使用方法 | 精品福利二区三区| 99国产精品久久久| 水蜜桃久久夜色精品一区的特点| 欧美精品一区二|