home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / midas / dma.h < prev    next >
C/C++ Source or Header  |  1994-08-06  |  4KB  |  146 lines

  1. /*      DMA.H
  2.  *
  3.  * DMA handling routines, v1.10
  4.  *
  5.  * Copyright 1994 Petteri Kangaslampi and Jarno Paananen
  6.  *
  7.  * This file is part of the MIDAS Sound System, and may only be
  8.  * used, modified and distributed under the terms of the MIDAS
  9.  * Sound System license, LICENSE.TXT. By continuing to use,
  10.  * modify or distribute this file you indicate that you have
  11.  * read the license and understand and accept it fully.
  12. */
  13.  
  14.  
  15. #ifndef __DMA_H
  16. #define __DMA_H
  17.  
  18.  
  19.  
  20. /****************************************************************************\
  21. *       struct dmaBuffer
  22. *       ----------------
  23. * Description:  DMA playing buffer
  24. \****************************************************************************/
  25.  
  26. typedef struct
  27. {
  28.     ushort      segment;                /* segment of the buffer (offset */
  29.                                         /* must be zero) */
  30.     ulong       address;                /* buffer physical start address */
  31.     ushort      length;                 /* length of buffer, MULTIPLE OF 16 */
  32.     void        *memBlk;                /* internal, used for unallocating */
  33.     short       channel;                /* channel on which the buffer is
  34.                                            being played or -1 */
  35. } dmaBuffer;
  36.  
  37.  
  38.  
  39. /****************************************************************************\
  40. *
  41. * Function:     int dmaAllocBuffer(ushort size, dmaBuffer *buf);
  42. *
  43. * Description:  Allocates a DMA buffer (totally inside a 64K physical page)
  44. *
  45. * Input:        ushort size             size of buffer in bytes
  46. *               dmaBuffer *buf          ptr to buffer structure to be filled
  47. *
  48. * Returns:      MIDAS error code.
  49. *               DMA buffer data is strored in *buf.
  50. *
  51. \****************************************************************************/
  52.  
  53. int CALLING dmaAllocBuffer(ushort size, dmaBuffer *buf);
  54.  
  55.  
  56.  
  57. /****************************************************************************\
  58. *
  59. * Function:     int dmaFreeBuffer(dmaBuffer *buf);
  60. *
  61. * Description:  Deallocates an allocated DMA buffer
  62. *
  63. * Input:        dmaBuffer *buf          ptr to buffer to be deallocated
  64. *
  65. * Returns:      MIDAS error code
  66. *
  67. \****************************************************************************/
  68.  
  69. int CALLING dmaFreeBuffer(dmaBuffer *buf);
  70.  
  71.  
  72.  
  73. /****************************************************************************\
  74. *
  75. * Function:     int dmaPlayBuffer(dmaBuffer *buf, ushort channel,
  76. *                                 ushort autoInit);
  77. *
  78. * Description:  Plays a DMA buffer
  79. *
  80. * Input:        dmaBuffer *buf          buffer to be player
  81. *               ushort channel          DMA channel number
  82. *               ushort autoInit         use autoinitialization?
  83. *
  84. * Returns:      MIDAS error code
  85. *
  86. \****************************************************************************/
  87.  
  88. int CALLING dmaPlayBuffer(dmaBuffer *buf, ushort channel, ushort autoInit);
  89.  
  90.  
  91.  
  92.  
  93. /****************************************************************************\
  94. *
  95. * Function:     int dmaStop(ushort channel);
  96. *
  97. * Description:  Stops DMA playing
  98. *
  99. * Input:        ushort channel          DMA channel number
  100. *
  101. * Returns:      MIDAS error code
  102. *
  103. \****************************************************************************/
  104.  
  105. int CALLING dmaStop(ushort channel);
  106.  
  107.  
  108.  
  109. /****************************************************************************\
  110. *
  111. * Function:     int dmaGetPos(dmaBuffer *buf, ushort *pos);
  112. *
  113. * Description:  Gets the DMA playing position
  114. *
  115. * Input:        dmaBuffer *buf          buffer that is being played
  116. *               ushort *pos             pointer to return value
  117. *
  118. * Returns:      MIDAS error code.
  119. *               DMA playing position from the beginning of the buffer,
  120. *               in bytes, is stored in *pos.
  121. *
  122. \****************************************************************************/
  123.  
  124. int CALLING dmaGetPos(dmaBuffer *buf, ushort *pos);
  125.  
  126.  
  127.  
  128.  
  129. /****************************************************************************\
  130. *       enum dmaFunctIDs
  131. *       ----------------
  132. * Description:  ID numbers for DMA handling functions
  133. \****************************************************************************/
  134.  
  135. enum dmaFunctIDs
  136. {
  137.     ID_dmaAllocBuffer = ID_dma,
  138.     ID_dmaFreeBuffer,
  139.     ID_dmaPlayBuffer,
  140.     ID_dmaStop,
  141.     ID_dmaGetPos
  142. };
  143.  
  144.  
  145. #endif
  146.