home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Exec 1 / CD_Magazyn_EXEC_nr_1.iso / Gry / battalion.lha / Battalion / source / audio.c < prev    next >
C/C++ Source or Header  |  1999-12-23  |  40KB  |  1,301 lines

  1. /****************************************************************/
  2. /* code copyright 1995-1996 Andrew Johnson - ALL RIGHTS RESERVED*/
  3. /*                          ajohnson@eecs.uic.edu               */
  4. /*                                                              */
  5. /*                      Electronic Visualization Lab (M/C 154)  */
  6. /*                      University of Illinois at Chicago       */
  7. /*                      851 South Morgan St. Room 1120 SEO      */
  8. /*                      Chicago, IL 60607-7053                  */
  9. /*                                                              */
  10. /*                      (312) 996-3002     (312) 413-7585 FAX   */
  11. /***********************************************************************/
  12. /* audio.c  v 1.4                                                      */
  13. /* audio routines for battalion                                        */
  14. /* since audio is so machine dependant there is separate code for the  */
  15. /*    various implementations ...                                      */
  16. /***********************************************************************/
  17.  
  18. #include "battalion.h"
  19. #ifdef AMIGAAUDIO
  20. #include "amigasnd.h"
  21. #endif
  22.  
  23. extern int noSound;
  24. int soundOn;
  25. int musicOn;
  26. extern int showframes;
  27. extern struct monsterInfo Googelon;
  28.  
  29. /***************/
  30. /* music stuff */
  31. /***************/
  32.  
  33. int playingTankFire, playingHeloRocket, playingTankMaser;
  34. int playingExplosion, playingSlag, playingTech;
  35.  
  36. int musicCount, deadCount;
  37.  
  38. #ifdef SGIAUDIO
  39.  
  40.     struct sound * allSounds;
  41.     struct aSound oneSound[MAXSOUNDS];
  42.  
  43. #endif
  44. #ifdef SUNAUDIO
  45.  
  46.     char        *audio_buffer[MAXSOUNDS];
  47.     int         buffer_counter[MAXSOUNDS];
  48.     char        *audio_dev = "/dev/audio";
  49.     int         audiofd;
  50.     Audio_hdr   file_hdr;
  51.     
  52.     int playingBeam, playingMusic;
  53.  
  54. #endif
  55. #ifdef AMIGAAUDIO
  56. static struct SoundInfo oneSound[MAXSOUNDS];
  57. int playingBeam, playingMusic;
  58. #endif
  59.  
  60. #ifdef MACVERSION
  61.  
  62.     int playingBeam, playingCrash, playingMusic, maserOn;
  63.  
  64. Boolean idleFlag;
  65.  
  66.                 Handle  beamSound, boomSound, crashSound, monsterbeamSound,
  67.                                 rocketSound, slagSound, tankSound, techSound, musicSound;
  68.                                 
  69. long musicRefNum, monsterbeamRefNum, maserbeamRefNum;
  70. SndChannelPtr musicChan, monsterbeamChan, maserbeamChan;
  71.  
  72. #endif
  73.  
  74. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  75. /* small sound routines to avoid having to use external variables*/
  76.  
  77. #ifdef MACVERSION
  78. void setSoundVolume(long vol)
  79.         {
  80.         SetDefaultOutputVolume(vol);
  81.         }
  82. #endif
  83.  
  84. void turnSoundOff()
  85.     {
  86.     soundOn = 0;
  87.     }
  88.     
  89. void turnSoundOn()
  90.     {
  91.     soundOn = 1;
  92.     }
  93.     
  94. void toggleSound()
  95.     {
  96.     soundOn = !soundOn;
  97.     }
  98.     
  99. int getSoundOn()
  100.     {
  101.     return(soundOn);
  102.     }
  103.     
  104. void turnMusicOff()
  105.     {
  106.     musicOn = 0;
  107.     }
  108.     
  109. void turnMusicOn()
  110.     {
  111.     musicOn = 1;
  112.     }
  113.     
  114. void toggleMusic()
  115.     {
  116.     musicOn = !musicOn;
  117.     }
  118.     
  119. int getMusicOn()
  120.     {
  121.     return(musicOn);
  122.     }
  123.     
  124.  
  125. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  126.  
  127. void ExitAudio(void)
  128. {
  129. #ifdef AMIGAAUDIO
  130.     int i;
  131.  
  132.     for (i=0; i<MAXSOUNDS; i++) {
  133.         if (oneSound[i].loaded)
  134.             amigasnd_free(&oneSound[i]);
  135.     }
  136.     amigasnd_exit();
  137. #endif
  138. }
  139.  
  140. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  141.  
  142. void checkSound(char * dataPath)
  143.     {
  144.     char * garbage;
  145.  
  146. #ifdef SGIAUDIO
  147.     long pvbuf[4];
  148.  
  149.     ALseterrorhandler(0);
  150.  
  151.     pvbuf[0] = AL_OUTPUT_COUNT;
  152.     pvbuf[2] = AL_MONITOR_CTL;
  153.     
  154.     if (ALgetparams(AL_DEFAULT_DEVICE, pvbuf, 4) < 0)
  155.         {
  156.         noSound = 1;
  157.         soundOn = 0;
  158.         musicOn = 0;
  159.         }
  160.         
  161.     if (!noSound)
  162.         {  
  163.         /******************************************/
  164.         /* load all the sound effects into memory */
  165.         /******************************************/
  166.  
  167.         InitAudio("SOUNDS/beam.aiff",        dataPath,  0);
  168.         InitAudio("SOUNDS/boom.aiff",        dataPath,  1);
  169.         InitAudio("SOUNDS/crash.aiff",       dataPath,  2);
  170.         InitAudio("SOUNDS/monsterbeam.aiff", dataPath,  3);
  171.         InitAudio("SOUNDS/rocket.aiff",      dataPath,  4);
  172.         InitAudio("SOUNDS/slag.aiff",        dataPath,  5);
  173.         InitAudio("SOUNDS/tank.aiff",        dataPath,  6);
  174.         InitAudio("SOUNDS/tech.aiff",        dataPath,  7);
  175.  
  176.         /*********************************************/
  177.         /* load all the background music into memory */
  178.         /*********************************************/
  179.  
  180.         InitAudio("MUSIC/1.aiff",        dataPath,  10);
  181.         InitAudio("MUSIC/2.aiff",        dataPath,  11);
  182.         InitAudio("MUSIC/3.aiff",        dataPath,  12);
  183.         InitAudio("MUSIC/4.aiff",        dataPath,  13);
  184.         InitAudio("MUSIC/5.aiff",        dataPath,  14);
  185.  
  186.         InitAudio("MUSIC/d1.aiff",       dataPath,  15);
  187.         InitAudio("MUSIC/d2.aiff",       dataPath,  16);
  188.         InitAudio("MUSIC/d3.aiff",       dataPath,  17);
  189.         InitAudio("MUSIC/d4.aiff",       dataPath,  18);
  190.         InitAudio("MUSIC/d5.aiff",       dataPath,  19);
  191.  
  192.         }
  193. #else
  194. # ifdef SUNAUDIO
  195.     /* Solaris audio support */
  196.  
  197.     noSound = 1;
  198.     soundOn = 0;
  199.     musicOn = 0;
  200.     {
  201.         /* Check if audio device is available and writable */
  202.         struct stat st;
  203.         
  204.         if (stat(audio_dev, &st) >= 0) {
  205.             audiofd = open(audio_dev, O_WRONLY);
  206.             if (audiofd >= 0) {
  207.                 noSound = 0;
  208.                 close(audiofd);
  209.             }
  210.         }
  211.     }
  212.  
  213.     if (!noSound) {  
  214.         /* Load all sound effects into memory */
  215.         InitAudio("SOUNDS/beam.au",         dataPath,  0);
  216.         InitAudio("SOUNDS/boom.au",         dataPath,  1);
  217.         InitAudio("SOUNDS/crash.au",        dataPath,  2);
  218.         InitAudio("SOUNDS/monsterbeam.au",  dataPath,  3);
  219.         InitAudio("SOUNDS/rocket.au",       dataPath,  4);
  220.         InitAudio("SOUNDS/slag.au",         dataPath,  5);
  221.         InitAudio("SOUNDS/tank.au",         dataPath,  6);
  222.         InitAudio("SOUNDS/tech.au",         dataPath,  7);
  223.  
  224.         /* Load all background music into memory */
  225.         InitAudio("MUSIC/1.au",             dataPath,  10);
  226.         InitAudio("MUSIC/2.au",             dataPath,  11);
  227.         InitAudio("MUSIC/3.au",             dataPath,  12);
  228.         InitAudio("MUSIC/4.au",             dataPath,  13);
  229.         InitAudio("MUSIC/5.au",             dataPath,  14);
  230.  
  231.         InitAudio("MUSIC/d1.au",            dataPath,  15);
  232.         InitAudio("MUSIC/d2.au",            dataPath,  16);
  233.         InitAudio("MUSIC/d3.au",            dataPath,  17);
  234.         InitAudio("MUSIC/d4.au",            dataPath,  18);
  235.         InitAudio("MUSIC/d5.au",            dataPath,  19);
  236.     }
  237. #else
  238. #ifdef AMIGAAUDIO
  239.     /* Amiga audio support */
  240.  
  241.     if (amigasnd_init()) {
  242.         /* Load all sound effects into memory */
  243.         InitAudio("SOUNDS/beam.au",         dataPath,  0);
  244.         InitAudio("SOUNDS/boom.au",         dataPath,  1);
  245.         InitAudio("SOUNDS/crash.au",        dataPath,  2);
  246.         InitAudio("SOUNDS/monsterbeam.au",  dataPath,  3);
  247.         InitAudio("SOUNDS/rocket.au",       dataPath,  4);
  248.         InitAudio("SOUNDS/slag.au",         dataPath,  5);
  249.         InitAudio("SOUNDS/tank.au",         dataPath,  6);
  250.         InitAudio("SOUNDS/tech.au",         dataPath,  7);
  251.  
  252.         /* Load all background music into memory */
  253.         InitAudio("MUSIC/1.au",             dataPath,  10);
  254.         InitAudio("MUSIC/2.au",             dataPath,  11);
  255.         InitAudio("MUSIC/3.au",             dataPath,  12);
  256.         InitAudio("MUSIC/4.au",             dataPath,  13);
  257.         InitAudio("MUSIC/5.au",             dataPath,  14);
  258.  
  259.         InitAudio("MUSIC/d1.au",            dataPath,  15);
  260.         InitAudio("MUSIC/d2.au",            dataPath,  16);
  261.         InitAudio("MUSIC/d3.au",            dataPath,  17);
  262.         InitAudio("MUSIC/d4.au",            dataPath,  18);
  263.         InitAudio("MUSIC/d5.au",            dataPath,  19);
  264.         atexit(ExitAudio);
  265.     }
  266.     else {
  267.         noSound = 1;
  268.         soundOn = 0;
  269.         musicOn = 0;
  270.     }
  271.  
  272. #else
  273. #ifdef MACVERSION
  274.  
  275. SndCommand testCommand;
  276.  
  277.         beamSound       = GetResource( 'snd ', 1000 );
  278.         boomSound       = GetResource( 'snd ', 1001 );
  279.         crashSound      = GetResource( 'snd ', 1002 );
  280.         monsterbeamSound = GetResource( 'snd ', 1003 );
  281.         rocketSound     = GetResource( 'snd ', 1004 );
  282.         slagSound       = GetResource( 'snd ', 1005 );
  283.         tankSound       = GetResource( 'snd ', 1006 );
  284.         techSound       = GetResource( 'snd ', 1007 );
  285.         musicSound      = GetResource( 'snd ', 1010 );
  286.         
  287.     noSound = 0;
  288.     soundOn = 0;
  289.     musicOn = 0;
  290.     
  291.     /* using the SoundHelper code to do asynch audio */
  292.     
  293.     SHInitSoundHelper(&idleFlag, 8);
  294.  
  295. SHPlayByHandle(musicSound, -1, &musicRefNum);
  296. SHPlayPause(musicRefNum);
  297. SHPlayByHandle(beamSound, -1, &maserbeamRefNum);
  298. SHPlayPause(maserbeamRefNum);
  299. SHPlayByHandle(monsterbeamSound, -1, &monsterbeamRefNum);
  300. SHPlayPause(monsterbeamRefNum);
  301.  
  302.  
  303. # else
  304.  
  305.     /*  Other than SGI or Solaris or Macintosh*/
  306.     noSound = 1;
  307.     soundOn = 0;
  308.     musicOn = 0;
  309.  
  310. #endif
  311. #endif
  312. #endif
  313. #endif
  314.  
  315.         garbage = dataPath; /* to avoid compiler warning */
  316.     }
  317.  
  318. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  319.  
  320. #ifdef MACVERSION
  321.  
  322. void processIdleAppSounds(void)
  323. {
  324.         if (idleFlag)
  325.         {
  326.         SHIdle();
  327.         }
  328. }
  329. #endif
  330.  
  331. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  332. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  333. /* initialize sound list to empty                                */
  334. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  335.  
  336. void initSounds()
  337.     {
  338. #ifdef SGIAUDIO
  339.  
  340.     register int i;
  341.     
  342.     allSounds = NULL;
  343.     allSounds = (struct sound *) calloc(1, sizeof(struct sound));
  344.     allSounds->next = NULL;
  345.  
  346.     musicCount          = 0;
  347.     deadCount           = 0;
  348.  
  349.     playingTankFire = playingHeloRocket = playingTankMaser = 0;
  350.     playingExplosion = playingSlag = playingTech = 0;
  351.  
  352.     for (i=0; i<MAXSOUNDS; i++)
  353.         {
  354.         oneSound[i].samplesPerFrame     = 0;
  355.         oneSound[i].numberSamples       = 0;
  356.         oneSound[i].samplesPerBuffer    = 0;
  357.         oneSound[i].audioRate           = 0;
  358.         oneSound[i].sampleBuffer        = NULL;
  359.         }
  360.  
  361. #endif
  362. # ifdef SUNAUDIO
  363.  
  364.     int n;
  365.     
  366.     musicCount          = 0;
  367.     deadCount           = 0;
  368.  
  369.     playingTankFire = playingHeloRocket = playingTankMaser = 0;
  370.     playingExplosion = playingSlag = playingTech = 0;
  371.     playingBeam = playingMusic = 0;
  372.  
  373.     /* Mark audio buffers as empty */
  374.     
  375.     for (n = 0; n < MAXSOUNDS; n++)
  376.         audio_buffer[n] = NULL;
  377.  
  378. # endif
  379.  
  380. #ifdef AMIGAAUDIO
  381.     musicCount          = 0;
  382.     deadCount           = 0;
  383.     playingTankFire = playingHeloRocket = playingTankMaser = 0;
  384.     playingExplosion = playingSlag = playingTech = 0;
  385.     playingBeam = playingMusic = 0;
  386.  
  387.     memset(oneSound,0,sizeof(struct SoundInfo)*MAXSOUNDS);
  388. #endif
  389.  
  390. #ifdef MACVERSION
  391.  
  392.     musicCount          = 0;
  393.     deadCount           = 0;
  394.  
  395.     playingTankFire = playingHeloRocket = playingTankMaser = 0;
  396.     playingExplosion = playingSlag = playingTech = 0;
  397.     playingBeam = playingMusic = maserOn = 0;
  398.         playingCrash = 0;
  399.  
  400.  
  401. #endif
  402.  
  403.     }
  404.  
  405. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  406. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  407. /* clear all completed sounds from the sound list                */
  408. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  409.  
  410. void flushSounds()
  411.     {
  412. #ifdef SGIAUDIO
  413.  
  414.     struct sound *s, *t;
  415.  
  416.     playingHeloRocket = playingTech = playingTankMaser = playingSlag = 0;
  417.  
  418.     playingExplosion--;
  419.     if (playingExplosion < 0)
  420.         playingExplosion = 0;
  421.  
  422.     playingTankFire--;
  423.     if (playingTankFire < 0)
  424.         playingTankFire =  0;
  425.  
  426.     s = allSounds;
  427.     while(s->next != NULL)
  428.         {
  429.         if(ALgetfilled(s->next->audio_port) <= 0)
  430.             {
  431.             ALcloseport(s->next->audio_port);
  432.             t = s->next;
  433.             s->next = s->next->next;
  434.             free(t);
  435.             }
  436.         else
  437.             s = s->next;
  438.         }
  439. #endif
  440. # ifdef SUNAUDIO
  441.  
  442.     playingHeloRocket = playingTech = playingTankMaser = playingSlag = 0;
  443.  
  444.     playingExplosion--;
  445.     if (playingExplosion < 0)
  446.         playingExplosion = 0;
  447.  
  448.     playingTankFire--;
  449.     if (playingTankFire < 0)
  450.         playingTankFire = 0;
  451.  
  452.     playingBeam--;
  453.     if (playingBeam < 0)
  454.         playingBeam = 0;
  455.  
  456.     playingMusic--;
  457.     if (playingMusic < 0)
  458.         playingMusic = 0;
  459.  
  460. # endif
  461.  
  462. # ifdef AMIGAAUDIO
  463.  
  464.     playingHeloRocket = playingTech = playingTankMaser = playingSlag = 0;
  465.  
  466.     playingExplosion--;
  467.     if (playingExplosion < 0)
  468.         playingExplosion = 0;
  469.  
  470.     playingTankFire--;
  471.     if (playingTankFire < 0)
  472.         playingTankFire = 0;
  473.  
  474.     playingBeam--;
  475.     if (playingBeam < 0)
  476.         playingBeam = 0;
  477.  
  478.     playingMusic--;
  479.     if (playingMusic < 0)
  480.         playingMusic = 0;
  481.  
  482. # endif
  483.  
  484. #ifdef MACVERSION
  485.  
  486.         processIdleAppSounds();
  487.  
  488.     playingTankMaser = playingSlag = 0;
  489.  
  490.     playingHeloRocket--;
  491.     if (playingHeloRocket < 0)
  492.         playingHeloRocket = 0;
  493.  
  494.     playingCrash--;
  495.     if (playingCrash < 0)
  496.         playingCrash = 0;
  497.  
  498.     playingExplosion--;
  499.     if (playingExplosion < 0)
  500.         playingExplosion = 0;
  501.  
  502.     playingTech--;
  503.     if (playingTech < 0)
  504.         playingTech = 0;
  505.  
  506.     playingTankFire--;
  507.     if (playingTankFire < 0)
  508.         playingTankFire =  0;
  509. #endif
  510.  
  511.     }
  512.  
  513.  
  514.  
  515. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  516. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  517. /* clear all sounds of a given type from the sound list          */
  518. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  519.  
  520. void soundKiller(int soundType)
  521.     {
  522.     int garbage;
  523.     
  524. #ifdef SGIAUDIO
  525.  
  526.     struct sound * s, *t;
  527.  
  528.     s = allSounds;
  529.     
  530.     while(s->next != NULL)
  531.         {
  532.         if (s->next->type == soundType)
  533.             {
  534.             ALcloseport(s->next->audio_port);
  535.             t = s->next;
  536.             s->next = s->next->next;
  537.             free(t);
  538.             }
  539.         else
  540.             s = s->next;
  541.         }
  542. #endif
  543.  
  544. #ifdef MACVERSION
  545.  
  546.         /* stop the sound */
  547.  
  548.         switch (soundType) {
  549.                 case MUSIC: 
  550.                         /*if (playingMusic)*/
  551.                                 {
  552.                                 /* SHPlayStop(musicRefNum);*/
  553.                                 SHPlayPause(musicRefNum);
  554.                                 playingMusic = 0;
  555.                                 }
  556.                         break;
  557.                 case MONSTERBEAM:
  558.                         /*if (playingBeam)*/
  559.                                 {
  560.                                 /*SHPlayStop(monsterbeamRefNum);*/
  561.                                 SHPlayPause(monsterbeamRefNum);
  562.                                 playingBeam = 0;
  563.                                 }
  564.                         break;
  565.         
  566.                 case TANKMASER:
  567.                 /*      if (maserOn)*/
  568.                                 {
  569.                                 /*SHPlayStop(maserbeamRefNum);*/
  570.                                 SHPlayPause(maserbeamRefNum);
  571.                                 maserOn = 0;
  572.                                 }
  573.                         break;
  574.                                 
  575. }
  576. #endif
  577.  
  578.  
  579.     garbage = soundType; /* to avoid compiler warning */
  580.     }
  581.  
  582. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  583. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  584. /* process a request for a specific sound                        */
  585. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  586.  
  587. void doSound(int theSound)
  588.     {
  589.     int garbage;
  590.  
  591. #ifdef SGIAUDIO
  592.  
  593. static int deadMusic[MAXDEADMUSIC] = {15, 16, 17, 18, 19};
  594.  
  595. static int theMusic[MAXMUSIC] = {10, 11, 12, 13, 14};
  596.  
  597.  
  598.     struct sound * s, *t;
  599.     int soundDelay;
  600.  
  601.     if (!noSound)
  602.         {
  603.         soundDelay = showframes;
  604.  
  605.         if (soundDelay <= 1)
  606.             soundDelay = 1;
  607.  
  608.         if (soundDelay > 30)
  609.             soundDelay = 30;
  610.   
  611.         if (((theSound == MUSIC) && musicOn) || ((theSound != MUSIC) && soundOn))
  612.             {
  613.             t = NULL;
  614.  
  615.             switch (theSound){
  616.             case MUSIC:         s = allSounds->next;
  617.                                 while ((s != NULL) && (t == NULL))
  618.                                     if (s->type == MUSIC)
  619.                                         t = s;
  620.                                     else
  621.                                         s = s->next;
  622.                                         
  623.                                 if (Googelon.monsterIsDead)
  624.                                     {
  625.                                     musicCount = 0;
  626.                                     if ((t != NULL) && (deadCount < MAXDEADMUSIC))
  627.                                         {
  628.                                         if ((ALgetfilled(t->audio_port)+oneSound[deadMusic[deadCount]].numberSamples < 2*oneSound[10].samplesPerBuffer) && (deadCount < 3))
  629.                                             {
  630.                                             ALwritesamps(t->audio_port,
  631.                                                         oneSound[deadMusic[deadCount]].sampleBuffer,
  632.                                                         oneSound[deadMusic[deadCount]].numberSamples);
  633.                                             deadCount = deadCount+1;
  634.                                             }
  635.                                         }
  636.                                     else if (deadCount < MAXDEADMUSIC)
  637.                                         {
  638.                                         OutAudio(deadMusic[deadCount]);
  639.                                         deadCount = deadCount+1;
  640.                                         }
  641.                                     }
  642.                                 else
  643.                                     {
  644.                                     deadCount = 0;
  645.                                     if (t != NULL)
  646.                                         {
  647.                                         if(ALgetfilled(t->audio_port)+oneSound[theMusic[musicCount]].numberSamples < 2*oneSound[10].samplesPerBuffer)
  648.                                             {
  649.                                             ALwritesamps(t->audio_port,
  650.                                                         oneSound[theMusic[musicCount]].sampleBuffer,
  651.                                                         oneSound[theMusic[musicCount]].numberSamples);
  652.                                             musicCount = (musicCount+1) % MAXMUSIC;
  653.                                             }
  654.                                         }
  655.                                     else
  656.                                         {
  657.                                         OutAudio(theMusic[musicCount]);
  658.                                         musicCount = (musicCount+1) % MAXMUSIC;
  659.                                         }
  660.                                         
  661.                                     }
  662.                                 break;
  663.                                 
  664.             case TANKFIRE:      if (!playingTankFire)
  665.                                     {
  666.                                     OutAudio(6);
  667.                                     playingTankFire = soundDelay / 5;
  668.                                     if (playingTankFire < 2)
  669.                                         playingTankFire = 2;
  670.                                     }
  671.                                 break;
  672.                                 
  673.             case HELOROCKET:    if (!playingHeloRocket)
  674.                                     {
  675.                                     OutAudio(4);
  676.                                     playingHeloRocket = 1;
  677.                                     }
  678.                                 break;
  679.                                 
  680.             case TANKMASER:     s = allSounds->next;
  681.                                 while ((s != NULL) && (t == NULL))
  682.                                     if (s->type == TANKMASER)
  683.                                         t = s;
  684.                                     else
  685.                                         s = s->next;
  686.                                 if (t != NULL)
  687.                                     {
  688.                                     if(ALgetfilled(t->audio_port) <= oneSound[0].samplesPerBuffer)
  689.                                         ALwritesamps(t->audio_port,
  690.                                                     oneSound[0].sampleBuffer,
  691.                                                     oneSound[0].numberSamples);
  692.                                     }
  693.                                 else
  694.                                     OutAudio(0);
  695.                                 break;
  696.                                 
  697.             case EXPLOSION:     if (!playingExplosion)
  698.                                     {
  699.                                     OutAudio(1);
  700.                                     playingExplosion = soundDelay / 5; 
  701.                                     if (playingExplosion < 2)
  702.                                         playingExplosion = 2;
  703.                                     }
  704.                                 break;
  705.                                 
  706.             case MONSTERBEAM:   s = allSounds->next;
  707.                                 while ((s != NULL) && (t == NULL))
  708.                                     if (s->type == MONSTERBEAM)
  709.                                         t = s;
  710.                                     else
  711.                                         s = s->next;
  712.                                 if (t != NULL)
  713.                                     {
  714.                                     if(ALgetfilled(t->audio_port) <= oneSound[3].samplesPerBuffer)
  715.                                         ALwritesamps(t->audio_port,
  716.                                                     oneSound[3].sampleBuffer,
  717.                                                     oneSound[3].numberSamples);
  718.                                     }
  719.                                 else
  720.                                     OutAudio(3);
  721.                                 break;
  722.                                 
  723.             case SLAG:          if (!playingSlag)
  724.                                     {
  725.                                     OutAudio(5);
  726.                                     playingSlag = 1;
  727.                                     }
  728.                                 break;
  729.                                 
  730.             case CRASH:         OutAudio(2);
  731.                                 break;
  732.                                 
  733.             case TECHSHOOT:    if (!playingTech)
  734.                                     {
  735.                                     OutAudio(7);
  736.                                     playingTech = 1;
  737.                                     }
  738.                                 break;
  739.             }
  740.         }
  741.     }
  742.  
  743. #endif
  744. # ifdef SUNAUDIO
  745.  
  746. static int deadMusic[MAXDEADMUSIC] = {15, 16, 17, 18, 19};
  747.  
  748. static int theMusic[MAXMUSIC] = {10, 11, 12, 13, 14};
  749.  
  750.     int soundDelay;
  751.  
  752.     if (!noSound) {
  753.         soundDelay = showframes;
  754.  
  755.         if (soundDelay <= 1)
  756.             soundDelay = 1;
  757.  
  758.         if (soundDelay > 30)
  759.             soundDelay = 30;
  760.   
  761.         if (((theSound == MUSIC) && musicOn) ||
  762.             ((theSound != MUSIC) && soundOn)) {
  763.  
  764.             switch (theSound) {
  765.             case MUSIC:
  766.                 if (!playingMusic) {
  767.                     if (Googelon.monsterIsDead) {
  768.                         musicCount = 0;
  769.                         OutAudio(deadMusic[deadCount]);
  770.                         deadCount = (deadCount+1) % MAXDEADMUSIC;
  771.                     }
  772.                     else {
  773.                         deadCount = 0;
  774.                         OutAudio(theMusic[musicCount]);
  775.                         musicCount = (musicCount+1) % MAXMUSIC;
  776.                     }
  777.                     /* each music sample is 5 secs long */
  778.                     playingMusic =  soundDelay * 5; ;
  779.                 }
  780.                 break;
  781.  
  782.             case TANKFIRE:
  783.                 if (!playingTankFire) {
  784.                     OutAudio(6);
  785.                     playingTankFire = soundDelay / 5;
  786.                     if (playingTankFire < 2)
  787.                         playingTankFire = 2;
  788.                 }
  789.                 break;
  790.                                 
  791.             case HELOROCKET:
  792.                 if (!playingHeloRocket) {
  793.                     OutAudio(4);
  794.                     playingHeloRocket = 1;
  795.                 }
  796.                 break;
  797.                                 
  798.             case TANKMASER:
  799.                     OutAudio(0);
  800.                 break;
  801.                                 
  802.             case EXPLOSION:
  803.                 if (!playingExplosion) {
  804.                     OutAudio(1);
  805.                     playingExplosion = soundDelay / 5; 
  806.                     if (playingExplosion < 2)
  807.                         playingExplosion = 2;
  808.                 }
  809.                 break;
  810.                                 
  811.             case MONSTERBEAM:
  812.                 if (!playingBeam) {
  813.                     OutAudio(3);
  814.                     playingBeam = 5 /*soundDelay / 5*/;
  815.                 }
  816.                 break;
  817.                                 
  818.             case SLAG:
  819.                 if (!playingSlag) {
  820.                     OutAudio(5);
  821.                     playingSlag = 1;
  822.                 }
  823.                 break;
  824.                                 
  825.             case CRASH:
  826.                 OutAudio(2);
  827.                 break;
  828.                                 
  829.             case TECHSHOOT:
  830.                 if (!playingTech) {
  831.                     OutAudio(7);
  832.                     playingTech = 1;
  833.                 }
  834.                 break;
  835.             }
  836.         }
  837.     }
  838.  
  839. #endif
  840.  
  841. #ifdef AMIGAAUDIO
  842.     static int deadMusic[MAXDEADMUSIC] = {15, 16, 17, 18, 19};
  843.     static int theMusic[MAXMUSIC] = {10, 11, 12, 13, 14};
  844.     int soundDelay;
  845.  
  846.     if (!noSound) {
  847.         soundDelay = showframes;
  848.  
  849.         if (soundDelay <= 1)
  850.             soundDelay = 1;
  851.  
  852.         if (soundDelay > 30)
  853.             soundDelay = 30;
  854.   
  855.         if (((theSound == MUSIC) && musicOn) ||
  856.             ((theSound != MUSIC) && soundOn)) {
  857.  
  858.             switch (theSound) {
  859.             case MUSIC:
  860.                 if (!playingMusic) {
  861.                     if (Googelon.monsterIsDead) {
  862.                         musicCount = 0;
  863.                         OutAudio(deadMusic[deadCount]);
  864.                         deadCount = (deadCount+1) % MAXDEADMUSIC;
  865.                     }
  866.                     else {
  867.                         deadCount = 0;
  868.                         OutAudio(theMusic[musicCount]);
  869.                         musicCount = (musicCount+1) % MAXMUSIC;
  870.                     }
  871.                     /* each music sample is 5 secs long */
  872.                     playingMusic =  soundDelay * 5; ;
  873.                 }
  874.                 break;
  875.  
  876.             case TANKFIRE:
  877.                 if (!playingTankFire) {
  878.                     OutAudio(6);
  879.                     playingTankFire = soundDelay / 5;
  880.                     if (playingTankFire < 2)
  881.                         playingTankFire = 2;
  882.                 }
  883.                 break;
  884.                                 
  885.             case HELOROCKET:
  886.                 if (!playingHeloRocket) {
  887.                     OutAudio(4);
  888.                     playingHeloRocket = 1;
  889.                 }
  890.                 break;
  891.                                 
  892.             case TANKMASER:
  893.                     OutAudio(0);
  894.                 break;
  895.                                 
  896.             case EXPLOSION:
  897.                 if (!playingExplosion) {
  898.                     OutAudio(1);
  899.                     playingExplosion = soundDelay / 5; 
  900.                     if (playingExplosion < 2)
  901.                         playingExplosion = 2;
  902.                 }
  903.                 break;
  904.                                 
  905.             case MONSTERBEAM:
  906.                 if (!playingBeam) {
  907.                     OutAudio(3);
  908.                     playingBeam = 5 /*soundDelay / 5*/;
  909.                 }
  910.                 break;
  911.                                 
  912.             case SLAG:
  913.                 if (!playingSlag) {
  914.                     OutAudio(5);
  915.                     playingSlag = 1;
  916.                 }
  917.                 break;
  918.                                 
  919.             case CRASH:
  920.                 OutAudio(2);
  921.                 break;
  922.                                 
  923.             case TECHSHOOT:
  924.                 if (!playingTech) {
  925.                     OutAudio(7);
  926.                     playingTech = 1;
  927.                 }
  928.                 break;
  929.             }
  930.         }
  931.     }
  932. #endif
  933.  
  934. /*------------------------ Mac Specific code --------------------*/
  935.  
  936. #ifdef MACVERSION
  937.     int soundDelay;
  938.  
  939.     if (!noSound)
  940.         {
  941.         soundDelay = showframes;
  942.  
  943.         if (soundDelay <= 1)
  944.             soundDelay = 1;
  945.  
  946.         if (soundDelay > 30)
  947.             soundDelay = 30;
  948.   
  949.         if (((theSound == MUSIC) && musicOn) || ((theSound != MUSIC) && soundOn))
  950.             {    
  951.             switch (theSound){
  952.             case MUSIC: if (!playingMusic)
  953.                                         {
  954.                                         /*SHPlayByHandle(musicSound, &musicRefNum);*/
  955.                                         SHPlayContinue(musicRefNum);
  956.                                         playingMusic = 1;
  957.                                         }
  958.                                 break;
  959.                                 
  960.             case TANKFIRE:if (!playingTankFire)
  961.                                             { /* different from sun version */
  962.                                             SHPlayByHandle(tankSound, 1, nil);
  963.  
  964.                                             playingTankFire = soundDelay / 5;
  965.                                             if (playingTankFire < 3)
  966.                                                 playingTankFire = 3;
  967.                                             }
  968.                                 break;
  969.                                 
  970.             case HELOROCKET:
  971.                         if (!playingHeloRocket)
  972.                                 { /* different from sun version */
  973.                             SHPlayByHandle(rocketSound, 1, nil);
  974.                             
  975.                             playingHeloRocket = soundDelay / 5;
  976.                             if (playingHeloRocket < 3)
  977.                                         playingHeloRocket = 3;
  978.                             
  979.                                 }
  980.                         break;
  981.                                 
  982.  
  983.             case TANKMASER:
  984.                                 if (!maserOn)
  985.                                         {
  986.                                         /*SHPlayByHandle(beamSound, &maserbeamRefNum);*/
  987.                                         SHPlayContinue(maserbeamRefNum);
  988.  
  989.                                         maserOn = 1;
  990.                                         }
  991.                                 break;
  992.                                 
  993.             case EXPLOSION:
  994.                                 if (!playingExplosion)
  995.                                         { /* different from sun version */
  996.                                      SHPlayByHandle(boomSound, 1, nil);
  997.                                      
  998.                                     playingExplosion = soundDelay / 5; 
  999.                                     if (playingExplosion < 3)
  1000.                                         playingExplosion = 3;
  1001.                                         }   
  1002.                                 break;
  1003.                                 
  1004.             case MONSTERBEAM:
  1005.                         if (!playingBeam)
  1006.                                 {
  1007.                                 /*SHPlayByHandle(monsterbeamSound, &monsterbeamRefNum);*/
  1008.                                 SHPlayContinue(monsterbeamRefNum);
  1009.                                 
  1010.                                 playingBeam = 1;
  1011.                                 }
  1012.                                 break;
  1013.                                 
  1014.             case SLAG:
  1015.                                 if (!playingSlag) {
  1016.                                     SHPlayByHandle(slagSound, 1, nil);
  1017.                                     
  1018.                                     playingSlag = 1;
  1019.                                 }                   
  1020.                                 break;
  1021.                                 
  1022.             case CRASH: 
  1023.                         if (!playingCrash)
  1024.                                 {
  1025.                                 SHPlayByHandle(crashSound, 1, nil);
  1026.  
  1027.                                     playingCrash = 2;
  1028.                                     }
  1029.                                 break;
  1030.                                 
  1031.             case TECHSHOOT:
  1032.                                 if (!playingTech)
  1033.                                         { /* different from sun version */
  1034.                                     SHPlayByHandle(techSound, 1, nil);
  1035.                                     
  1036.                                     playingTech = 2;
  1037.                                         }                   
  1038.                                 break;
  1039.             }
  1040.         }
  1041.     }
  1042. #endif
  1043.     garbage = theSound;
  1044. }
  1045.  
  1046.  
  1047.  
  1048. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  1049. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  1050. /* output a particular sound                                     */
  1051. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  1052.  
  1053.  
  1054. void OutAudio(int sCounter)
  1055.     {
  1056.     int garbage;
  1057.     
  1058. #ifdef SGIAUDIO
  1059.  
  1060.     ALconfig audioPortConfig;
  1061.     long pvbuf[4];
  1062.     long outputRate;
  1063.     struct sound * s;
  1064.         
  1065.     pvbuf[0] = AL_OUTPUT_RATE;
  1066.     ALgetparams(AL_DEFAULT_DEVICE, pvbuf, 2);
  1067.  
  1068.     if (pvbuf[1] > 0) 
  1069.         outputRate = pvbuf[1];
  1070.     else 
  1071.         outputRate = AL_RATE_UNDEFINED;
  1072.     
  1073.     pvbuf[0] = AL_OUTPUT_COUNT;
  1074.     pvbuf[2] = AL_MONITOR_CTL;
  1075.     ALgetparams(AL_DEFAULT_DEVICE, pvbuf, 4);
  1076.     
  1077.     if ((outputRate != oneSound[sCounter].audioRate) || ((pvbuf[1] == 0) && (pvbuf[3] == AL_MONITOR_OFF)))
  1078.         {
  1079.         outputRate = oneSound[sCounter].audioRate;
  1080.         pvbuf[0] = AL_OUTPUT_RATE;
  1081.         pvbuf[1] = outputRate;
  1082.         ALsetparams(AL_DEFAULT_DEVICE, pvbuf, 2);
  1083.         }
  1084.   
  1085.     audioPortConfig = ALnewconfig();
  1086.     ALsetwidth(audioPortConfig, AL_SAMPLE_16);
  1087.     ALsetchannels(audioPortConfig, oneSound[sCounter].samplesPerFrame);
  1088.     
  1089.      switch(sCounter){
  1090.         case 1:
  1091.         case 2:
  1092.         case 4:
  1093.         case 5:
  1094.         case 6:
  1095.         case 7:     ALsetqueuesize(audioPortConfig, oneSound[sCounter].samplesPerBuffer);
  1096.                     break;
  1097.         case 0:
  1098.         case 3:     ALsetqueuesize(audioPortConfig, 2*oneSound[sCounter].samplesPerBuffer);
  1099.                     break;
  1100.         default:    ALsetqueuesize(audioPortConfig, 3*oneSound[sCounter].samplesPerBuffer);
  1101.                     break;
  1102.     }
  1103.     
  1104.     s = (struct sound *) calloc(1, sizeof(struct sound));
  1105.         
  1106.     if (s != NULL)
  1107.         {
  1108.         if (sCounter == 3)
  1109.             s->type = MONSTERBEAM;
  1110.         else if (sCounter == 0)
  1111.             s->type = TANKMASER;
  1112.         else if (sCounter >= 10)
  1113.             s->type = MUSIC;
  1114.         else
  1115.             s->type = -1;
  1116.  
  1117.         s->next = allSounds->next;
  1118.         allSounds->next = s;
  1119.  
  1120.         s->audio_port = ALopenport("battalion", "w", audioPortConfig);
  1121.         if (s->audio_port == 0)
  1122.             {
  1123.             showError("too many simultaneous sounds");
  1124.             allSounds->next = s->next;
  1125.             free(s);
  1126.             }
  1127.         else
  1128.             ALwritesamps(s->audio_port, oneSound[sCounter].sampleBuffer, oneSound[sCounter].numberSamples);
  1129.         }
  1130.  
  1131. #endif
  1132. # ifdef SUNAUDIO
  1133.  
  1134.     static int first = 1;
  1135.  
  1136.     /* Check if a valid buffer and buffer contains a sample */
  1137.     
  1138.     if (sCounter < 0 || sCounter >= MAXSOUNDS ||
  1139.                 audio_buffer[sCounter] == NULL)
  1140.         return;
  1141.  
  1142.     if (first) {
  1143.         first = 0;
  1144.  
  1145.         /* Open audio device */
  1146.         
  1147.         audiofd = open(audio_dev, O_WRONLY /*| O_NDELAY | O_NONBLOCK*/);
  1148.         if (audiofd < 0)
  1149.             return;
  1150.     }
  1151.         
  1152.     audio_flush_play(audiofd);
  1153.  
  1154.     if (write(audiofd, audio_buffer[sCounter], buffer_counter[sCounter]) < 0)
  1155.         fprintf(stderr, "audio_play: buffer %d failed\n", sCounter);
  1156.  
  1157. # endif
  1158.  
  1159. #ifdef AMIGAAUDIO
  1160.     static int chidx = 1;   /* channel 0 is reserved for music */
  1161.  
  1162.     if (sCounter>=0 && sCounter<=MAXSOUNDS) {
  1163.         /* play sample at next free channel */
  1164.         amigasnd_play(&oneSound[sCounter],sCounter>=10?0:chidx++);
  1165.         if (chidx > amigasnd_getchannels())
  1166.            chidx = 1;
  1167.     }
  1168. #endif
  1169.  
  1170.     garbage = sCounter; /* to avoid compiler warning */
  1171.     }
  1172.  
  1173. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  1174. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  1175. /* load a particular sound into memory                           */
  1176. /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
  1177.  
  1178.  
  1179. void InitAudio(char * fileName,  char * dataPath, int sCounter)
  1180.     {
  1181.     char * garbName,  * garbPath;
  1182.     int garbCount;
  1183.     
  1184. #ifdef SGIAUDIO
  1185.  
  1186.     /* IRIX 6 compilers want these next two to be integers 
  1187.      * while IRIS 5 compilers want them to be long ... sheesh */
  1188.  
  1189.     int bitsPerSample;
  1190.     int garbage;
  1191.  
  1192.     long framesPerBuffer;
  1193.     long framesRead;
  1194.     FILE * sndtest;
  1195.     AFfilehandle audioFile;
  1196.     char textBuffer[80];
  1197.     char fullPath[MAXPATH];
  1198.     
  1199.     
  1200.     bitsPerSample   = 0;
  1201.     framesPerBuffer = 0;
  1202.     garbage         = 0;
  1203.     framesRead      = 0;
  1204.     
  1205.     strcpy(fullPath, dataPath);
  1206.     strcat(fullPath, fileName);
  1207.     
  1208.     sndtest = fopen(fullPath, "rb");
  1209.     if (sndtest == NULL)
  1210.         {
  1211.         sprintf(textBuffer, "Could not load %s", fullPath);
  1212.         showError(textBuffer);
  1213.         }
  1214.     else
  1215.         {       
  1216.         fclose(sndtest);
  1217.         
  1218.         audioFile = AFopenfile(fullPath, "r", AF_NULL_FILESETUP);
  1219.     
  1220.         oneSound[sCounter].samplesPerFrame = AFgetchannels(audioFile, AF_DEFAULT_TRACK);
  1221.     
  1222.         AFgetsampfmt(audioFile, AF_DEFAULT_TRACK, &garbage, &bitsPerSample);
  1223.     
  1224.         oneSound[sCounter].audioRate  = (long) (AFgetrate(audioFile, AF_DEFAULT_TRACK));
  1225.        
  1226.         if (bitsPerSample != 16)
  1227.             {
  1228.             sprintf(textBuffer, "incorrect sound format for %s - should be 16-bits", fileName);
  1229.             showError(textBuffer);
  1230.             }
  1231.         
  1232.         framesPerBuffer = AFgetframecnt(audioFile, AF_DEFAULT_TRACK);
  1233.     
  1234.         oneSound[sCounter].samplesPerBuffer = framesPerBuffer * oneSound[sCounter].samplesPerFrame;
  1235.     
  1236.         oneSound[sCounter].sampleBuffer = (short *) calloc((unsigned) oneSound[sCounter].samplesPerBuffer, sizeof(short));
  1237.     
  1238.         AFseekframe(audioFile, AF_DEFAULT_TRACK, 0);
  1239.     
  1240.         framesRead = AFreadframes(audioFile, AF_DEFAULT_TRACK, oneSound[sCounter].sampleBuffer, framesPerBuffer);
  1241.  
  1242.         AFclosefile(audioFile);
  1243.  
  1244.         oneSound[sCounter].numberSamples = framesRead * oneSound[sCounter].samplesPerFrame;
  1245.         }
  1246.  
  1247. #endif
  1248. # ifdef SUNAUDIO
  1249.            
  1250.     int     error;
  1251.     int     count;
  1252.     char    audioFile[MAXPATH];
  1253.  
  1254.     strcpy(audioFile, dataPath);
  1255.     strcat(audioFile, fileName);
  1256.  
  1257.     if ((audiofd = open(audioFile, O_RDONLY, 0)) < 0) {
  1258.         fprintf(stderr, "audio_load: cannot open %s\n", audioFile);
  1259.         exit(1);
  1260.     }
  1261.  
  1262.     error = audio_read_filehdr(audiofd, &file_hdr, (char *)NULL, 0);
  1263.  
  1264.     if (error != AUDIO_SUCCESS) {
  1265.         fprintf(stderr, "audio_load: %s is not a valid audio file\n",
  1266.                 audioFile);
  1267.         exit(-1);
  1268.     }
  1269.  
  1270.     if (audio_buffer[sCounter]) {
  1271.         free(audio_buffer[sCounter]);
  1272.         audio_buffer[sCounter] = NULL;
  1273.     }
  1274.  
  1275.     audio_buffer[sCounter] = (char *)malloc(file_hdr.data_size);
  1276.  
  1277.     if ((count = read(audiofd, audio_buffer[sCounter],
  1278.                           file_hdr.data_size)) < 0) {
  1279.         fprintf(stderr, "audio_load: error reading\n");
  1280.         close(audiofd);
  1281.     }
  1282.  
  1283.     buffer_counter[sCounter] = count;
  1284.     close(audiofd);
  1285.  
  1286. # endif
  1287.  
  1288. # ifdef AMIGAAUDIO           
  1289.     char audioFile[MAXPATH];
  1290.  
  1291.     strcpy(audioFile, dataPath);
  1292.     strcat(audioFile, fileName);
  1293.     amigasnd_loadau(&oneSound[sCounter],audioFile);
  1294. # endif
  1295.  
  1296.     garbName  = fileName;
  1297.     garbPath  = dataPath;
  1298.     garbCount = sCounter;
  1299.  
  1300.     }
  1301.