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

  1. /*      TIMER.H
  2.  *
  3.  * TempoTimer, 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 __TIMER_H
  16. #define __TIMER_H
  17.  
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21.  
  22.  
  23. /****************************************************************************\
  24. *
  25. * Function:     int tmrGetScrSync(ushort *scrSync);
  26. *
  27. * Description:  Calculates the screen synchronization value for timer
  28. *
  29. * Input:        ushort *scrSync         pointer to screen synchronization
  30. *                                       value
  31. *
  32. * Returns:      MIDAS error code.
  33. *               Screen syncronization value used with tmrSyncScr() is stored
  34. *               in *scrSync.
  35. *
  36. \****************************************************************************/
  37.  
  38. int CALLING tmrGetScrSync(ushort *scrSync);
  39.  
  40.  
  41.  
  42.  
  43. /****************************************************************************\
  44. *
  45. * Function:     int tmrInit(void);
  46. *
  47. * Description:  Initializes TempoTimer.
  48. *
  49. * Returns:      MIDAS error code
  50. *
  51. \****************************************************************************/
  52.  
  53. int CALLING tmrInit(void);
  54.  
  55.  
  56.  
  57.  
  58. /****************************************************************************\
  59. *
  60. * Function:     int tmrClose(void);
  61. *
  62. * Description:  Uninitializes TempoTimer. MUST be called if and ONLY if
  63. *               tmrInit() has been called.
  64. *
  65. * Returns:      MIDAS error code
  66. *
  67. \****************************************************************************/
  68.  
  69. int CALLING tmrClose(void);
  70.  
  71.  
  72.  
  73.  
  74. /****************************************************************************\
  75. *
  76. * Function:     int tmrPlay(void (*play)(), SoundDevice *SD);
  77. *
  78. * Description:  Starts playing music with the timer. Update rate set to 50Hz.
  79. *
  80. * Input:        void (*play)()          Music playing function
  81. *               SoundDevice *SD         Sound Device used for playing
  82. *
  83. * Returns:      MIDAS error code
  84. *
  85. \****************************************************************************/
  86.  
  87. int CALLING tmrPlay(void (*play)(), SoundDevice *SD);
  88.  
  89.  
  90.  
  91.  
  92. /****************************************************************************\
  93. *
  94. * Function:     int tmrStop(void);
  95. *
  96. * Description:  Stops playing music with the timer.
  97. *
  98. * Returns:      MIDAS error code
  99. *
  100. \****************************************************************************/
  101.  
  102. int CALLING tmrStop(void);
  103.  
  104.  
  105.  
  106.  
  107. /****************************************************************************\
  108. *
  109. * Function:     int tmrSyncScr(ushort sync, void (*preVR)(), void (*immVR)(),
  110. *               void (*inVR)());
  111. *
  112. * Description:  Synchronizes the timer to screen refresh.
  113. *
  114. * Input:        ushort sync             Screen synchronization value returned
  115. *                                       by tmrGetScrSync().
  116. *               void (*preVR)()         Pointer to the routine that will be
  117. *                                       called BEFORE Vertical Retrace
  118. *               void (*immVR)()         Pointer to the routine that will be
  119. *                                       called immediately after Vertical
  120. *                                       Retrace starts
  121. *               void (*inVR)()          Pointer to the routine that will be
  122. *                                       called some time during Vertical
  123. *                                       Retrace
  124. *
  125. * Returns:      MIDAS error code
  126. *
  127. * Notes:        preVR() and immVR() functions must be as short as possible
  128. *               and do nothing else than update counters or set some VGA
  129. *               registers to avoid timer synchronization problems. inVR()
  130. *               can take a longer time and can be used for, for example,
  131. *               setting the palette.
  132. *
  133. \****************************************************************************/
  134.  
  135. int CALLING tmrSyncScr(ushort sync, void (*preVR)(), void (*immVR)(),
  136.     void (*inVR)());
  137.  
  138.  
  139.  
  140.  
  141. /****************************************************************************\
  142. *
  143. * Function:     int tmrStopScrSync(void);
  144. *
  145. * Description:  Stops synchronizing the timer to the screen.
  146. *
  147. * Returns:      MIDAS error code
  148. *
  149. \****************************************************************************/
  150.  
  151. int CALLING tmrStopScrSync(void);
  152.  
  153.  
  154.  
  155. /****************************************************************************\
  156. *
  157. * Function:     int tmrSetUpdRate(ushort updRate);
  158. *
  159. * Description:  Sets the timer update rate, ie. the rate at which the music
  160. *               playing routine is called
  161. *
  162. * Input:        ushort updRate          updating rate, in 100*Hz (5000=50Hz)
  163. *
  164. * Returns:      MIDAS error code
  165. *
  166. \****************************************************************************/
  167.  
  168. int CALLING tmrSetUpdRate(ushort updRate);
  169.  
  170.  
  171. #ifdef __cplusplus
  172. }
  173. #endif
  174.  
  175.  
  176. /****************************************************************************\
  177. *       enum tmrFunctIDs
  178. *       ----------------
  179. * Description:  ID numbers for TempoTimer functions
  180. \****************************************************************************/
  181.  
  182. enum tmrFunctIDs
  183. {
  184.     ID_tmrGetScrSync = ID_tmr,
  185.     ID_tmrInit,
  186.     ID_tmrClose,
  187.     ID_tmrPlay,
  188.     ID_tmrStop,
  189.     ID_tmrSyncScr,
  190.     ID_tmrStopScrSync,
  191.     ID_tmrSetUpdRate
  192. };
  193.  
  194.  
  195.  
  196. #endif
  197.