예제 #1
0
파일: i_sound.c 프로젝트: Krazygamr/D-Touch
void I_sndArbitrateCards(void)
{
    char tmp[160];
    boolean gus, adlib, pc, sb, midi;
    int i, rc, mputype, p, opltype, wait, dmxlump;

//  snd_MaxVolume = 127;
    //Damn you, Dave Taylor!

    snd_MusicDevice = snd_DesiredMusicDevice;
    snd_SfxDevice = snd_DesiredSfxDevice;

    // check command-line parameters- overrides config file
    //
    if (M_CheckParm("-nosound"))
        snd_MusicDevice = snd_SfxDevice = snd_none;
    if (M_CheckParm("-nosfx"))
        snd_SfxDevice = snd_none;
    if (M_CheckParm("-nomusic"))
        snd_MusicDevice = snd_none;

    if (snd_MusicDevice > snd_MPU && snd_MusicDevice <= snd_MPU3)
        snd_MusicDevice = snd_MPU;
    if (snd_MusicDevice == snd_SB)
        snd_MusicDevice = snd_Adlib;
    if (snd_MusicDevice == snd_PAS)
        snd_MusicDevice = snd_Adlib;

    // figure out what i've got to initialize
    //
    gus = snd_MusicDevice == snd_GUS || snd_SfxDevice == snd_GUS;
    sb = snd_SfxDevice == snd_SB || snd_MusicDevice == snd_SB;
    adlib = snd_MusicDevice == snd_Adlib;
    pc = snd_SfxDevice == snd_PC;
    midi = snd_MusicDevice == snd_MPU;

    // initialize whatever i've got
    //
    if (gus)
    {
        if (GF1_Detect())
            tprintf("Dude.  The GUS ain't responding.\n", 1);
        else
        {
            dmxlump = W_GetNumForName("dmxgus");
            GF1_SetMap(W_CacheLumpNum(dmxlump, PU_CACHE),
                       lumpinfo[dmxlump].size);
        }

    }
    if (sb)
    {
        if (debugmode)
        {
            sprintf(tmp, "cfg p=0x%x, i=%d, d=%d\n",
                    snd_SBport, snd_SBirq, snd_SBdma);
            tprintf(tmp, 0);
        }
        if (SB_Detect(&snd_SBport, &snd_SBirq, &snd_SBdma, 0))
        {
            sprintf(tmp, "SB isn't responding at p=0x%x, i=%d, d=%d\n",
                    snd_SBport, snd_SBirq, snd_SBdma);
            tprintf(tmp, 0);
        }
        else
            SB_SetCard(snd_SBport, snd_SBirq, snd_SBdma);

        if (debugmode)
        {
            sprintf(tmp, "SB_Detect returned p=0x%x,i=%d,d=%d\n",
                    snd_SBport, snd_SBirq, snd_SBdma);
            tprintf(tmp, 0);
        }
    }

    if (adlib)
    {
        if (AL_Detect(&wait, 0))
            tprintf("Dude.  The Adlib isn't responding.\n", 1);
        else
            AL_SetCard(wait, W_CacheLumpName("genmidi", PU_STATIC));
    }

    if (midi)
    {
        if (debugmode)
        {
            sprintf(tmp, "cfg p=0x%x\n", snd_Mport);
            tprintf(tmp, 0);
        }

        if (MPU_Detect(&snd_Mport, &i))
        {
            sprintf(tmp, "The MPU-401 isn't reponding @ p=0x%x.\n",
                    snd_Mport);
            tprintf(tmp, 0);
        }
        else
            MPU_SetCard(snd_Mport);
    }

}
예제 #2
0
파일: sound2.c 프로젝트: spippolatore/abuse
int sound_init(int argc, char **argv)
{
  int i,return_code,
      sr=SAMPLE_RATE,nc=NUMBER_CHANNELS;
  unsigned short ver;
  
  for (i=1;i<argc;i++)
  {    
    if (!strcmp(argv[i],"-samplerate"))
    {
      i++;
      if (atoi(argv[i])<5000 || atoi(argv[i])>50000)
        printf("Bad sample rate : valid range is 5000..50000, default is %d",SAMPLE_RATE);
      else 
      {
	printf("Sample rate set to %d\n",sr);
        sr=SAMPLE_RATE;
      }           
    } else if (!strcmp(argv[i],"-channels"))
    {      
      i++;
      if (atoi(argv[i])<1 || atoi(argv[i])>4)
        printf("Bad # of channels : valid range is 1..4, default is %d",NUMBER_CHANNELS);
      else 
      {
	printf("# of channels set to %d\n",nc);
        nc=NUMBER_CHANNELS;
      }           
    } else if (!strcmp(argv[i],"-sblaster"))
    { card=AHW_SOUND_BLASTER; 
      if (music_card==NO_CARD)
        music_card=AHW_ADLIB;
    }
    else if (!strcmp(argv[i],"-proaudio"))
    {
      card=AHW_MEDIA_VISION;
      if (music_card==NO_CARD)
        music_card=AHW_ADLIB;
    }
    else if (!strcmp(argv[i],"-gravis") || !strcmp(argv[i],"-gus"))    
      music_card=card=AHW_ULTRA_SOUND;         
    else if (!strcmp(argv[i],"-speaker"))
      music_card=AHW_PC_SPEAKER;
    else if (!strcmp(argv[i],"-adlib"))
      music_card=AHW_ADLIB;
    else if (!strcmp(argv[i],"mpu401"))
      music_card=AHW_MPU_401;
    else if (!strcmp(argv[i],"-detect"))
      music_card=card=AHW_ANY;    
    else if (!strcmp(argv[i],"-irq"))
    { i++;
      irq=atoi(argv[i]);
    } else if (!strcmp(argv[i],"-dma"))
    { i++;
      dma=atoi(argv[i]);
    }  else if (!strcmp(argv[i],"-addr"))
    { i++;
      addr=atoi(argv[i]);
    }              
  }

  if (card==NO_CARD && music_card==NO_CARD)
     return 0;  

  TSM_Install(140);
  atexit(TSM_Remove);  

  if (card==AHW_ANY || card==AHW_MEDIA_VISION)
  {    
    if ( MV_Detect() == 0 )
    {      
      printf( "Detected MEDIA VISION card.  (Pro Audio)\n" );      
      card=AHW_MEDIA_VISION;
      music_card=AHW_ADLIB;      
    }    
    else if (card==AHW_MEDIA_VISION)
    {	
      printf("Warning : Detect failed for MEDIA VISION (Pro Audio) card.\n");
      card=NO_CARD;      
    }
  } 
  
  if (card==AHW_ANY || card==AHW_ULTRA_SOUND)
  {      
    if ( GF1_Detect() == 0 )
    {      
      printf( "Detected GRAVIS Ultrasound card.\n" );
      music_card=card=AHW_ULTRA_SOUND;
    }    
    else if (card==AHW_ULTRA_SOUND)
    {	
      printf("Warning : Detect failed for GRAVIS Ultrasound card.\n");
      card=NO_CARD;     
    }      
  }    
    
  if (card==AHW_ANY)
  {    
    if (!addr || !dma || !irq)
    {      
      addr = dma = -1; irq = 0;
      return_code=SB_Detect( &addr, &irq, &dma, &ver);  
      if (!return_code)      
        printf( "SBlaster defaults are Port:%xh Irq:%d  DMA:%d\n", addr, irq, dma );
	
      printf( "Looking for a SOUND BLASTER card...\n" );
      addr = irq = dma = -1;
      return_code = SB_Detect( &addr, &irq, &dma, &ver );      
      if (!return_code)
      {             
	printf( "Found SoundBlaster card\n" );
	printf( "ADDR:%03xh IRQ:%d DMA:%d  Ver:%2x.%02x\n",addr, irq, dma, ver>>8,ver&0xff);
	SB_SetCard( addr, irq, dma );
      } 
    } else SB_SetCard( addr, irq, dma );