home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / midas / dma.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-06  |  5KB  |  156 lines

  1. {*      DMA.PAS
  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. unit DMA;
  16.  
  17.  
  18. interface
  19.  
  20.  
  21.  
  22.  
  23. {****************************************************************************\
  24. *       struct dmaBuffer
  25. *       ----------------
  26. * Description:  DMA playing buffer
  27. \****************************************************************************}
  28.  
  29. type
  30.     dmaBuffer = record
  31.         segment : word;                 { segment of the buffer (offset
  32.                                           must be zero) }
  33.         address : longint;              { buffer physical start address }
  34.         length : word;                  { length of buffer, MULTIPLE OF 16 }
  35.         memBlk : pointer;               { internal, used for unallocating }
  36.         channel : integer;              { channel on which the buffer is
  37.                                           being played or -1 }
  38.     end;
  39.  
  40.     PdmaBuffer = ^dmaBuffer;
  41.  
  42.     Pword = ^word;
  43.  
  44.  
  45.  
  46.  
  47. {****************************************************************************\
  48. *
  49. * Function:     dmaAllocBuffer(size : word; buf : PdmaBuffer) : integer
  50. *
  51. * Description:  Allocates a DMA buffer (totally inside a 64K physical page)
  52. *
  53. * Input:        size : word             size of buffer in bytes
  54. *               buf : PdmaBuffer        ptr to buffer strucure to be filled
  55. *
  56. * Returns:      MIDAS error code.
  57. *               DMA buffer data is strored in buf^.
  58. *
  59. \****************************************************************************}
  60.  
  61. function dmaAllocBuffer(size : word; buf : PdmaBuffer) : integer;
  62.  
  63.  
  64.  
  65. {****************************************************************************\
  66. *
  67. * Function:     dmaFreeBuffer(buf : PdmaBuffer) : integer;
  68. *
  69. * Description:  Deallocates an allocated DMA buffer
  70. *
  71. * Input:        buf : PdmaBuffer        pointer to buffer to be deallocated
  72. *
  73. * Returns:      MIDAS error code
  74. *
  75. \****************************************************************************}
  76.  
  77. function dmaFreeBuffer(buf : PdmaBuffer) : integer;
  78.  
  79.  
  80.  
  81. {****************************************************************************\
  82. *
  83. * Function:     dmaPlayBuffer(buf : PdmaBuffer; channel, autoInit : word) :
  84. *                   integer;
  85. *
  86. * Description:  Plays a DMA buffer
  87. *
  88. * Input:        buf : PdmaBuffer        pointer to buffer to be player
  89. *               channel : word          DMA channel number
  90. *               autoInit : word         use autoinitialization?
  91. *
  92. * Returns:      MIDAS error code
  93. *
  94. \****************************************************************************}
  95.  
  96. function dmaPlayBuffer(buf : PdmaBuffer; channel, autoInit : word) : integer;
  97.  
  98.  
  99.  
  100.  
  101. {****************************************************************************\
  102. *
  103. * Function:     dmaStop(channel : word) : integer;
  104. *
  105. * Description:  Stops DMA playing
  106. *
  107. * Input:        channel : word          DMA channel number
  108. *
  109. * Returns:      MIDAS error code
  110. *
  111. \****************************************************************************}
  112.  
  113. function dmaStop(channel : word) : integer;
  114.  
  115.  
  116.  
  117.  
  118. {****************************************************************************\
  119. *
  120. * Function:     dmaGetPos(buf : PdmaBuffer; pos : Pword) : integer;
  121. *
  122. * Description:  Gets the DMA playing position
  123. *
  124. * Input:        buf : PdmaBuffer        buffer that is being played
  125. *               pos : Pword             pointer to return value
  126. *
  127. * Returns:      MIDAS error code.
  128. *               DMA playing position from the beginning of the buffer,
  129. *               in bytes, is stored in pos^.
  130. *
  131. \****************************************************************************}
  132.  
  133. function dmaGetPos(buf : PdmaBuffer; pos : Pword) : integer;
  134.  
  135.  
  136.  
  137.  
  138. implementation
  139.  
  140.  
  141. uses mMem, Errors;
  142.  
  143.  
  144.  
  145. function dmaAllocBuffer(size : word; buf : PdmaBuffer) : integer; external;
  146. function dmaFreeBuffer(buf : PdmaBuffer) : integer; external;
  147. function dmaPlayBuffer(buf : PdmaBuffer; channel, autoInit : word) : integer;
  148.     external;
  149. function dmaStop(channel : word) : integer; external;
  150. function dmaGetPos(buf : PdmaBuffer; pos : Pword) : integer; external;
  151. {$L DMA.OBJ}
  152.  
  153.  
  154.  
  155. END.
  156.