home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / dos / prg / cthugha5 / cthu5src / sb.h < prev    next >
C/C++ Source or Header  |  1994-08-19  |  5KB  |  158 lines

  1. //
  2. // Cthugha - Audio Seeded Image Processing
  3. //
  4. // Zaph, Digital Aasvogel Group, Torps Productions 1993-1994
  5. //
  6.  
  7. /* Include file for Soundblaster library */
  8.  
  9. /* Defines for Soundblaster and Soundblaster Pro IO address */
  10. #define LEFT_FM_STATUS      0x00    /* Pro only */
  11. #define LEFT_FM_ADDRESS     0x00    /* Pro only */
  12. #define LEFT_FM_DATA        0x01    /* Pro only */
  13. #define RIGHT_FM_STATUS     0x02    /* Pro only */
  14. #define RIGHT_FM_ADDRESS    0x02    /* Pro only */
  15. #define RIGHT_FM_DATA       0x03    /* Pro only */
  16. #define MIXER_ADDRESS       0x04    /* Pro only */
  17. #define MIXER_DATA          0x05    /* Pro only */
  18. #define DSP_RESET           0x06
  19. #define FM_STATUS           0x08
  20. #define FM_ADDRESS          0x08
  21. #define FM_DATA             0x09
  22. #define DSP_READ_DATA       0x0A
  23. #define DSP_WRITE_DATA      0x0C
  24. #define DSP_WRITE_STATUS    0x0C
  25. #define DSP_DATA_AVAIL      0x0E
  26. #define CD_ROM_DATA         0x10    /* Pro only */
  27. #define CD_ROM_STATUS       0x11    /* Pro only */
  28. #define CD_ROM_RESET        0x12    /* Pro only */
  29. #define CD_ROM_ENABLE       0x13    /* Pro only */
  30.  
  31. #define ADLIB_FM_STATUS     0x388
  32. #define ADLIB_FM_ADDRESS    0x388
  33. #define ADLIB_FM_DATA       0x389
  34.  
  35. /* Defines for 8237 DMA Controller IO addresses */
  36. #define DMA         0x00
  37. #define CH0_BASE    DMA+0
  38. #define CH0_COUNT   DMA+1
  39. #define CH1_BASE    DMA+2
  40. #define CH1_COUNT   DMA+3
  41. #define CH2_BASE    DMA+4
  42. #define CH2_COUNT   DMA+5
  43. #define CH3_BASE    DMA+6
  44. #define CH3_COUNT   DMA+7
  45. #define DMA_STATUS  DMA+8
  46. #define DMA_CMD     DMA+8
  47. #define DMA_REQUEST DMA+9
  48. #define DMA_MASK    DMA+10
  49. #define DMA_MODE    DMA+11
  50. #define DMA_FF      DMA+12
  51. #define DMA_TMP     DMA+13
  52. #define DMA_CLEAR   DMA+13
  53. #define DMA_CLRMSK  DMA+14
  54. #define DMA_WRMSK   DMA+15
  55. #define DMAPAGE     0x80
  56.  
  57. /* Types of Soundblaster Cards */
  58. #define SB15    1
  59. #define SBPro    2
  60. #define SB20    3
  61.  
  62. /* DSP Commands */
  63. #define DIRECT_8_BIT_DAC    0x10
  64. #define DMA_8_BIT_DAC        0x14
  65. #define DMA_2_BIT_DAC        0x16
  66. #define DMA_2_BIT_REF_DAC   0x17
  67. #define DIRECT_ADC        0x20
  68. #define DMA_ADC         0x24
  69. #define MIDI_READ_POLL        0x30
  70. #define MIDI_READ_IRQ        0x31
  71. #define MIDI_WRITE_POLL     0x38
  72. #define TIME_CONSTANT        0x40
  73. #define DMA_4_BIT_DAC        0x74
  74. #define DMA_4_BIT_REF_DAC   0x75
  75. #define DMA_26_BIT_DAC        0x76
  76. #define DMA_26_BIT_REF_DAC  0x77
  77. #define HALT_DMA        0xD0
  78. #define CONTINUE_DMA        0xD4
  79. #define SPEAKER_ON        0xD1
  80. #define SPEAKER_OFF        0xD3
  81. #define DSP_ID            0xE0
  82. #define DSP_VER         0xE1
  83. #define MDAC1            0x61
  84. #define MDAC2            0x62
  85. #define MDAC3            0x63
  86. #define MDAC4            0x64
  87. #define MDAC5            0x65
  88. #define MDAC6            0x66
  89. #define MDAC7            0x67
  90.  
  91. enum { RECORD = 0, PLAY = 1 };       /* For the 'direction' argument */
  92.  
  93. /* High-speed parameters */
  94. #define MAX_LO_REC 12048
  95. #define MAX_LO_PLAY 22222
  96. #define SET_HS_SIZE 0x48
  97. #define HS_DAC 0x91
  98. #define HS_ADC 0x99
  99.  
  100. /* Functions that are in the library */
  101. int Sb_Init(void);
  102. int Sb_Get_Params(void);
  103. unsigned Sb_Sample_Rate(unsigned rate, int direction);
  104. void Sb_Voice(int state);
  105. void Sb_Voice_DMA(char far *data, unsigned dlen, int stereo, int direction);
  106. void Sb_Init_Voice_DMA(void (__interrupt *handler)(void));
  107. void Sb_DeInit_Voice_DMA(void);
  108. int Sb_DMA_Complete(void);
  109. void Sb_Halt_DMA(void);
  110. void Sb_Continue_DMA(void);
  111.  
  112. /* DMA routines */
  113. int dma_setup(int Channel,char far *Buffer,unsigned Length,int Dir);
  114. int prevent_dma(int Channel);
  115. int allow_dma(int Channel);
  116. unsigned dma_count(int Channel);
  117. unsigned dma_addr(int Channel);
  118.  
  119. extern int dma_errno;
  120. extern char far *dma_errlist[];
  121.  
  122. /* Card parameters */
  123. extern unsigned SbIOaddr;
  124. extern unsigned SbIRQ;
  125. extern unsigned SbDMAchan;
  126. extern int    SbType;
  127.  
  128.  
  129. /* Define a useful macro for writing data to the DAC */
  130. #define writedac(x) { while(inp(SbIOaddr+DSP_WRITE_STATUS) & 0x80); \
  131.                       outp(SbIOaddr+DSP_WRITE_DATA,(x)); }
  132.  
  133. /* Write a byte to the SB Pro mixer chip */
  134. #define writemixer(x,y) { outp(SbIOaddr+MIXER_ADDRESS,(x)); \
  135.               outp(SbIOaddr+MIXER_DATA,(y)); }
  136.  
  137. /* FM Instrument definition */
  138. typedef struct {
  139.     unsigned char SoundCharacteristic[2];
  140.     unsigned char Level[2];
  141.     unsigned char AttackDecay[2];
  142.     unsigned char SustainRelease[2];
  143.     unsigned char WaveSelect[2];
  144.     unsigned char Feedback;
  145.     unsigned char filler[5];
  146. } FM_Instrument;
  147.  
  148. /* FM sound routines */
  149. void Sb_FM_Reset(void);
  150. void Sb_FM_Key_Off(int voice);
  151. void Sb_FM_Key_On(int voice, int freq, int octave);
  152. void Sb_FM_Voice_Volume(int voice, int vol);
  153. void Sb_FM_Set_Voice(int voice_num, FM_Instrument *ins);
  154.  
  155. /* MIDI routines */
  156. int Sb_Read_MIDI(void);
  157. void Sb_Write_MIDI(int data);
  158.