home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser-CD 2000 January / LCD_01_2000.iso / games / doom / pmdoom / src / sound / ataridma.c next >
C/C++ Source or Header  |  1999-12-17  |  4KB  |  152 lines

  1. /*  Emacs style mode select   -*- C++ -*-  */
  2. /* ----------------------------------------------------------------------------- */
  3. /*  */
  4. /*  $Id:$ */
  5. /*  */
  6. /*  Copyright (C) 1993-1996 by id Software, Inc. */
  7. /*  */
  8. /*  This source is available for distribution and/or modification */
  9. /*  only under the terms of the DOOM Source Code License as */
  10. /*  published by id Software. All rights reserved. */
  11. /*  */
  12. /*  The source is distributed in the hope that it will be useful, */
  13. /*  but WITHOUT ANY WARRANTY; without even the implied warranty of */
  14. /*  FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License */
  15. /*  for more details. */
  16. /*  */
  17. /*  $Log:$ */
  18. /*  */
  19. /*  DESCRIPTION: */
  20. /*     System interface for sound. */
  21. /*  */
  22. /* ----------------------------------------------------------------------------- */
  23.  
  24. #include <osbind.h>
  25. #include <falcon.h>
  26.  
  27. #include "z_zone.h"
  28. #include "i_system.h"
  29. #include "i_sound.h"
  30. #include "i_cookies.h"
  31. #include "sound/ataridma.h"
  32.  
  33. char *atari_dmabuffer;
  34. int atari_sndcoef;
  35. int atari_sndlength;
  36.  
  37. int DmaSoundInited=0;
  38.  
  39. /*  */
  40. /*  Starting a sound means adding it */
  41. /*   to the current list of active sounds */
  42. /*   in the internal channels. */
  43. /*  As the SFX info struct contains */
  44. /*   e.g. a pointer to the raw data, */
  45. /*   it is ignored. */
  46. /*  As our sound handling does not handle */
  47. /*   priority, it is ignored. */
  48. /*  Pitching (that is, increased speed of playback) */
  49. /*   is set, but currently not used by mixing. */
  50. /*  */
  51. int
  52. I_StartSound_atari
  53. ( int        id,
  54.   int        vol,
  55.   int        sep,
  56.   int        pitch,
  57.   int        priority )
  58. {
  59.     /*  Debug. */
  60.     /* fprintf( stderr, "starting sound %d", id ); */
  61.     
  62.     /*  Returns a handle (not used). */
  63.     id = addsfx( id, vol, 0 /* steptable[pitch]*/ , sep );
  64.  
  65.     /*  fprintf( stderr, "/handle is %d\n", id ); */
  66.     
  67.     return id;
  68. }
  69.  
  70.  
  71. void I_ShutdownSound_atari(void)
  72. {    
  73.     if (!DmaSoundInited)
  74.         return;
  75.  
  76.     /* Stop Timer A */
  77.     Supexec(I_Atari_StopDmaSound);
  78.  
  79.     Mfree(atari_dmabuffer);
  80. }
  81.  
  82. void
  83. I_InitSound_atari()
  84.     int i;
  85.   
  86.     /* Configure sound matrix */
  87.  
  88.     if (cookie_snd & (1<<SND_DMAREC))
  89.     {
  90.         Devconnect(DMAPLAY,DAC+DMAREC,CLK25M,CLKOLD,1);
  91.         Setinterrupt(SI_NONE,SI_PLAY);
  92.         Settracks(0,0);
  93.         Setmontracks(0);
  94.         Setmode(STEREO8);
  95.         Soundcmd(SETPRESCALE,PRE640);
  96.     }
  97.  
  98.     switch(cookie_mch)
  99.     {
  100.         case MCH_TT:
  101.             atari_sndcoef=(11025<<16)/DMAFREQ_TT;
  102.             atari_sndlength=(DMAFREQ_TT/TIMERA_FREQ);
  103.             break;
  104.         case MCH_F30:
  105.             atari_sndcoef=(11025<<16)/DMAFREQ_F30;
  106.             atari_sndlength=(DMAFREQ_F30/TIMERA_FREQ);
  107.             break;
  108.     }
  109.  
  110.     /*  Initialize external data (all sounds) at start, keep static. */
  111.     fprintf( stderr, "I_InitSound: ");
  112.   
  113.     for (i=1 ; i<NUMSFX ; i++)
  114.     { 
  115.         sfxinfo_t *sfx=&S_sfx[i];
  116.     
  117.         sfx->nbusing=0;
  118.  
  119.         /*  Alias? Example is the chaingun sound linked to pistol. */
  120.         if (!sfx->link)
  121.         {
  122.             /*  Load data from WAD file. */
  123.             sfx->data = getsfx( sfx->name, &lengths[i] );
  124.             Z_ChangeTag ( (sfx->data)-8, PU_CACHE);
  125.         }    
  126.     }
  127.  
  128.     fprintf( stderr, " pre-cached all sound data\n");
  129.   
  130.     /*  Now initialize mixbuffer with zero. */
  131. /*
  132.     for ( i = 0; i< MIXBUFFERSIZE; i++ )
  133.         mixbuffer[i] = 0;
  134.   */
  135.     /*  Finished initialization. */
  136.     fprintf(stderr, "I_InitSound: sound module ready\n");
  137.  
  138.     /* Run Timer A interrupt */
  139.     Supexec(I_Atari_InitDmaSound);
  140.  
  141.     DmaSoundInited=1;
  142. }
  143.  
  144. void I_SndInit_atari(void)
  145. {
  146.     /* Allocate DMA sound buffer */
  147.  
  148.     atari_dmabuffer=Mxalloc(512*4*2,0);
  149.     memset(atari_dmabuffer,0,512*4*2);
  150. }
  151.