Example #1
0
int xyzsound(short num,short i,long x,long y,long z)
{
    long sndist, cx, cy, cz, j,k;
    short pitche,pitchs,cs;
    int voice, sndang, ca, pitch;

//    if(num != 358) return 0;

    if( num >= NUM_SOUNDS ||
        FXDevice < 0 ||
        ( (soundm[num]&8) && ud.lockout ) ||
        SoundToggle == 0 ||
        Sound[num].num > 3 ||
        FX_VoiceAvailable(soundpr[num]) == 0 ||
        (ps[myconnectindex].timebeforeexit > 0 && ps[myconnectindex].timebeforeexit <= 26*3) ||
        ps[myconnectindex].gm&MODE_MENU) return -1;

    if( soundm[num]&128 )
    {
        sound(num);
        return 0;
    }

    if( soundm[num]&4 )
    {
        if(VoiceToggle==0 || (ud.multimode > 1 && PN == APLAYER && sprite[i].yvel != screenpeek && ud.coop != 1) ) return -1;

        for(j=0;j<NUM_SOUNDS;j++)
          for(k=0;k<Sound[j].num;k++)
            if( (Sound[j].num > 0) && (soundm[j]&4) )
              return -1;
    }

    cx = ps[screenpeek].oposx;
    cy = ps[screenpeek].oposy;
    cz = ps[screenpeek].oposz;
    cs = ps[screenpeek].cursectnum;
    ca = ps[screenpeek].ang+ps[screenpeek].look_ang;

    sndist = FindDistance3D((cx-x),(cy-y),(cz-z)>>4);

    if( i >= 0 && (soundm[num]&16) == 0 && PN == MUSICANDSFX && SLT < 999 && (sector[SECT].lotag&0xff) < 9 )
        sndist = divscale14(sndist,(SHT+1));

    pitchs = soundps[num];
    pitche = soundpe[num];
    j = klabs(pitche-pitchs);

    if(j)
    {
        if( pitchs < pitche )
             pitch = pitchs + ( rand()%j );
        else pitch = pitche + ( rand()%j );
    }
    else pitch = pitchs;

    sndist += soundvo[num];
    if(sndist < 0) sndist = 0;
    if( sndist && PN != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,SX,SY,SZ-(24<<8),SECT) )
        sndist += sndist>>5;

    switch(num)
    {
        case PIPEBOMB_EXPLODE:
        case LASERTRIP_EXPLODE:
        case RPG_EXPLODE:
            if(sndist > (6144) )
                sndist = 6144;
            if(sector[ps[screenpeek].cursectnum].lotag == 2)
                pitch -= 1024;
            break;
        default:
            if(sector[ps[screenpeek].cursectnum].lotag == 2 && (soundm[num]&4) == 0)
                pitch = -768;
            if( sndist > 31444 && PN != MUSICANDSFX)
                return -1;
            break;
    }


    if( Sound[num].num > 0 && PN != MUSICANDSFX )
    {
        if( SoundOwner[num][0].i == i ) stopsound(num);
        else if( Sound[num].num > 1 ) stopsound(num);
        else if( badguy(&sprite[i]) && sprite[i].extra <= 0 ) stopsound(num);
    }

    if( PN == APLAYER && sprite[i].yvel == screenpeek )
    {
        sndang = 0;
        sndist = 0;
    }
    else
    {
        sndang = 2048 + ca - getangle(cx-x,cy-y);
        sndang &= 2047;
    }

    if(Sound[num].ptr == 0) { if( loadsound(num) == 0 ) return 0; }
    else
    {
       if (Sound[num].lock < 200)
          Sound[num].lock = 200;
       else Sound[num].lock++;
    }

    if( soundm[num]&16 ) sndist = 0;

    if(sndist < ((255-LOUDESTVOLUME)<<6) )
        sndist = ((255-LOUDESTVOLUME)<<6);

    if( soundm[num]&1 )
    {
        if(Sound[num].num > 0) return -1;

        voice = FX_PlayLoopedAuto( Sound[num].ptr, soundsiz[num], 0, -1,
                    pitch,sndist>>6,sndist>>6,0,soundpr[num],num);
    }
    else
    {
Example #2
0
OpenAll()
{
  CreateBasicMaze(); /* Default maze for construction set */

  strcpy(sprite_dat,"pw:sprites/sprite.dat");

  if((GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",36))==NULL)
  {
     wb2_0=0;
     if((GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0))==NULL) {
         printf("I can't open my graphics library! Oh, NOOOO!!!");
         FreeMemory(); }
  }
  else wb2_0=1; /* Hey!  We're in workbench 2.0! */

  /* Save the active view for quit time */
  oldview = GfxBase->ActiView;

  if((IntuitionBase=(struct IntuitionBase *)
     OpenLibrary("intuition.library",0))==NULL) {
       printf("Could not open the Intuition Library!");
       FreeMemory(); }

  CloseWorkBench();

  if ((DiskfontBase=(struct Library *)
      OpenLibrary("diskfont.library", 33L))==NULL) {
       printf("Could not open the diskfont library!  DUUUUUUUDE!\n");
       FreeMemory(); }

  /* Get best font available */
  if(( !(defaultFont = LoadThisFont(loresAttr=&pacqAttr))))
  if(( !(defaultFont = LoadThisFont(loresAttr=&cleanAttr))))
  if(( !(defaultFont = LoadThisFont(loresAttr=&topazAttr))))
        { printf("Couldn't open any fonts!  Not even ROM fonts?!?!\n\n");
          FreeMemory(); }

  if((ArpBase = (struct ArpBase *) OpenLibrary("arp.library",0))==NULL) {
       printf("Unable to open the arp.library.\nPlease use the arp.library "
       "V1.3 or higher to run this program.\n");
       FreeMemory(); }

/*  if(JoySetup()) { printf("No Joystick, No program...\n\n");
                   FreeMemory(); } */

    if(ReadSprites()) {
       printf("Error while trying to read sprite file \"%s\"\n\n",sprite_dat);
       printf("Aborting program!\n\n");
       FreeMemory(); }

    if((pacmen=(sprite_type *)AllocMem(sizeof(sprite_type)*12,
                                                       MEMF_CHIP|MEMF_CLEAR))==0)
    {  printf("Error while allocting CHIP RAM.\n");
       FreeMemory(); } /* pacmen[12] */

    if((blank=(sprite_type *)AllocMem(sizeof(sprite_type),
                                               MEMF_CHIP|MEMF_CLEAR))==0)
    {  printf("Error while allocting blank sprite.\n");
       FreeMemory(); } /* pacmen[12] */

    if((ghosts=(sprite_type *)AllocMem(sizeof(sprite_type)*6*MAXGHOSTS
                                                       ,MEMF_CHIP))==0)
    {  printf("Error while allocting CHIP RAM.\n");
       FreeMemory(); } /* ghosts[36] */

    if((eyes=(sprite_type *)AllocMem(sizeof(sprite_type)*6*MAXGHOSTS
                                                       ,MEMF_CHIP))==0)
    {  printf("Error while allocting CHIP RAM.\n");
       FreeMemory(); } /* eyes[24] */

    if((scores=(sprite_type *)AllocMem(sizeof(sprite_type)*NUMSCORES
                                                       ,MEMF_CHIP))==0)
    {  printf("Error while allocting CHIP RAM.\n");
       FreeMemory(); } /* scores[6] */

   if (initsound() || loadsound(defaultpath))
   {
    printf("No sound files will be used.\n");
    nosound = TRUE;
   }

   return 0;
}
Example #3
0
File: 21.c Project: manish05/TCR
void oursoundinit() {
  loadsound("21complete.wav",0);
  loadsound("21die.wav",1);
  loadsound("21freeze.wav",2);  sounds[2].loop=1;
  loadsound("21hourglass.wav",3);
}
Example #4
0
void main(){
 int i;
 int key = 0, flag = 0;
 int sel = 0;
 int reps = 1;
 unsigned freq[32] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0,
		    0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0};
 unsigned t[32] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0,
		 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0};
 textmode(C4350);
 clrscr();
 graphsound(freq, 32);
 gotoxy(1, sel + 18);
 putch(26);
 _setcursortype(_NOCURSOR);
 gotoxy(50, 4);
 cprintf("Frecuencia:  %5u Hz", freq[sel]);
 gotoxy(50, 5);
 cprintf("Tiempo:      %03.3f secs", (float)t[sel] / 1000);
 gotoxy(50, 6);
 cprintf("Repeticiones: %3d ", reps);
 int lastsel = 0;
 gotoxy(2,2);
 cputs("F1         Reset\n\r");
 cputs(" F2         Guardar\n\r");
 cputs(" F3         Cargar\n\r ");
 putch(24);
 putch(25);
 cputs("         Seleccionar\n\r ");
 putch(27);
 putch(26);
 cputs("         Disminuir/Incrementar frecuencia\n\r");
 cputs(" -+         Disminuir/Incrementar tiempo\n\r");
 cputs(" ENTER      Ejecutar sonido\n\r");
 cputs(" Fin/Inicio Disminuir/Incrementar tiempo total\n\r");
 cputs(" F9/F10     Disminuir/Incrementar frecuencia en todos\n\r");
 cputs(" ESPACIO    Ejecutar seleccionado\n\r");
 cputs(" F4         Editar frecuencia\n\r");
 cputs(" F5         Editar tiempo\n\r");
 cputs(" F6         Invertir frecuencia\n\r");
 cputs(" RePag      Incrementa las repeticiones\n\r");
 cputs(" AvPag      Disminuye las repeticiones\n\r");
 cputs(" ESC        Salir");
 do{
  key = 0;
  key = bioskey(0);
  if(key == SC_ARRIBA) sel--;
  if(key == SC_ABAJO) sel++;
  if(key == SC_DER){
   freq[sel]+=4;
   gotoxy(2, sel + 18);
   spectral((int)((float)freq[sel] * 78 / MAX_FREQ));
  }
  if(key == SC_IZQ){
   freq[sel]-=4;
   gotoxy(2, sel + 18);
   spectral((int)((float)freq[sel] * 78 / MAX_FREQ));
  }
  if(sel > 31) sel = 0;
  if(sel < 0) sel = 31;
  if(freq[sel] < 0) freq[sel] = 0;
  if(freq[sel] > MAX_FREQ) freq[sel] = MAX_FREQ;
  gotoxy(1, lastsel + 18);
  putch(32);
  gotoxy(1, sel + 18);
  putch(26);
  if(key == SC_MINUS) t[sel]--;
  if(key == SC_PLUS) t[sel]++;
  if(key == SC_ENTER) play(freq, t, 32, reps);
  if(key == 0x011B) flag = 1;
  if(key == 0x5100) reps--;
  if(key == 0x4900) reps++;
  if(key == 0x3C00) savesound(freq, t, 32);
  if(key == 0x3D00){
   loadsound(freq, t, 32);
   graphsound(freq, 32);
  }
  if(key == 0x3920){
   sound(freq[sel]);
   delay(t[sel]);
   nosound();
  }
  if(key == 0x3B00){
   for(i = 0; i < 32; i++){
    freq[i] = 0;
    t[i] = 0;
   }
   graphsound(freq,32);
  }
  if(key == 0x3E00){
   gotoxy(1,1);
   printf("Frecuencia: ");
   _setcursortype(_NORMALCURSOR);
   scanf("%d", &freq[sel]);
   _setcursortype(_NOCURSOR);
   fflush(stdin);
   gotoxy(1,1);
   printchars(32, 79);
   graphsound(freq, 32);
  }
  if(key == 0x3F00){
   gotoxy(1,1);
   printf("Tiempo (milisegundos): ");
   _setcursortype(_NORMALCURSOR);
   scanf("%d", &t[sel]);
    _setcursortype(_NOCURSOR);
   fflush(stdin);
   gotoxy(1,1);
   printchars(32, 79);
  }
  if(key == 0x4000){
   freq[sel] = MAX_FREQ - freq[sel];
   gotoxy(2, sel + 18);
   spectral((int)((float)freq[sel] * 78 / MAX_FREQ));
  }
  if(key == 0x4700){
   for(i = 0; i < 32; i++){
    if(freq[i] != 0) t[i]++;
   }
  }
  if(key == 0x4F00){
   for(i = 0; i < 32; i++){
    if((freq[i] != 0) && (t[i] != 0)) t[i]--;
   }
  }
  if(key == 0x4300){
   for(i = 0; i < 32; i++){
    if(freq[i] != 0) freq[i]-=4;
    if(kbhit())getch();
   }
   graphsound(freq, 32);
  }
  if(key == 0x4400){
   for(i = 0; i < 32; i++){
    freq[i]+=4;
    if(freq[i] > MAX_FREQ) freq[i] = MAX_FREQ;
    if(kbhit())getch();
   }
   graphsound(freq, 32);
  }
  if(t[sel] > 5000) t[sel] = 5000;
  gotoxy(1, lastsel + 18);
  putch(32);
  gotoxy(1, sel + 18);
  putch(26);
  gotoxy(50, 4);
  cprintf("Frecuencia:  %5u Hz", freq[sel]);
  gotoxy(50, 5);
  cprintf("Tiempo:      %03.3f secs", (float)t[sel] / 1000);
  gotoxy(50, 6);
  cprintf("Repeticiones: %3d ", reps);
  lastsel = sel;
 }while(flag == 0);
 _setcursortype(_NORMALCURSOR);
 clrscr();
}