home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Game Programming Gurus / Tricks_of_the_Game_Programming_Gurus_SAMS_Publishing_1994.iso / digipak / theaudio / flat / midpak.h < prev    next >
C/C++ Source or Header  |  1993-12-31  |  8KB  |  142 lines

  1. /*****************************************************************************/
  2. /* MIDPAK.H     C prototype header for flat-model MIDPAK interface layer             */
  3. /*                        MIDPAK.ASM.  Because MIDPAK is a real-mode program all                 */
  4. /*                        addresses passed must be in the first 1mb of address space.      */
  5. /*                        This is an absolute requirement because MIDPAK drivers                 */
  6. /*                        are still all real-mode code!  Include the header file to          */
  7. /*                        DOSCALLS.H and link to DOSCALLS.OBJ.    This gives you basic         */
  8. /*                        memory management (low dos memory allocation) and pointer type */
  9. /*                        conversion resources without being dependent on any particular */
  10. /*                        compiler vendor's C link libraries.                            */
  11. /*                                                                                                                                                     */
  12. /*                        See MIDPKAPI.DOC for complete MIDPAK documentation.                      */
  13. /*                                                                                                                                                     */
  14. /*                        MIDPAK.ASM is the flat-model link layer to MIDPAK functions.     */
  15. /*                        written using Borland Assembler in IDEAL mode.    Assumes              */
  16. /*                        a DPMI with a flat model address space where selectors                 */
  17. /*                        DS and ES always point to flat address 0000000000000h!                 */
  18. /*                        Written and tested with DOS4GW and Watcom C.    Uses                         */
  19. /*                        standard C calling convention.    Getting this to work                     */
  20. /*                        under any other DPMI is an excercise left for ths student.         */
  21. /*                                                                                                                                                     */
  22. /*            Warning!! The Watcom compiler passes 4 bytes on the stack      */
  23. /*                        to a cdecl external routine, even if the parameter is only         */
  24. /*                        a char.  All of these assembly routines have been defined          */
  25. /*                        this way.  If you are using a compiler that passes different     */
  26. /*                        size arguments to cdecl routines, you may want to double             */
  27. /*                        check for compatibilities sake.                                                              */
  28. /*                                                                                                                                                     */
  29. /*                        The protected mode MIDPAK interface did not require a rev to     */
  30. /*                        the MIDPAK drivers.  However in porting the code I did discover*/
  31. /*                        several instances where MIDPAK was not preserving the ES             */
  32. /*                        register.  This is why the MIDPAK.ASM link layer always pushs  */
  33. /*                        and pops the es register at each call to MIDPAK, just to be      */
  34. /*                        safe in that regard.                                                                                     */
  35. /*                                                                                                                                                     */
  36. /*        Written by John W. Ratcliff (c) 1994                                                                     */
  37. /*             Compuserve: 70253,3237                                                                                          */
  38. /*             Genie: J.RATCLIFF3                                                                                                  */
  39. /*             BBS: 1-314-939-0200                                                                                                 */
  40. /*             Addresss:                                                                                                                     */
  41. /*                     747 Napa Lane                                                                                                     */
  42. /*                     St. Charles, MO 63304                                                                                     */
  43. /*                                                                                                                                                     */
  44. /*        A $500 per product license fee applies to all commercial software          */
  45. /*        products distributed with ANY MIDPAK drivers.                                                  */
  46. /*                                                                                                                                                     */
  47. /*        To pay a license, simply write a check for $500 payable to                         */
  48. /*                The Audio Solution, 747 Napa Lane, St. Charles, MO 63304                     */
  49. /*                with a copy of your commerical product.  You will receive a signed */
  50. /*                license agreement from The Audio Solution shortly thereafter.          */
  51. /*                This license fee applies specifically to the inclusion with your     */
  52. /*                distribution disk any of the MIDPAK drivers from The Audio Solution*/
  53. /*                These drivers are copyrighted works, created by me, to enhance the */
  54. /*                use of sound and music in DOS based commercial software.    The          */
  55. /*                license fees collected are used to maintain the drivers and keep     */
  56. /*                the BBS running.    There is a seperate license fee for the use          */
  57. /*                and distribution of DIGPAK drivers.                                                              */
  58. /*                                                                                                                                                     */
  59. /*                See accompaning documentation regarding license fees for DIGPAK      */
  60. /*                distribution.  You would be ill-advised to distribute a commercial */
  61. /*                product containing either DIGPAK and/or MIDPAK drivers without         */
  62. /*                having paid the distribution license fee.  Since your product would*/
  63. /*                contain unlicensed copyrighted software from The Audio Solution,     */
  64. /*                your product could be required to be immediately removed from retail*/
  65. /*                distribution.  I doubt this is going to be a problem.  Clearly if  */
  66. /*                your product is enhanced by the use of these drivers, your company */
  67. /*                can easily afford a nominal license fee of $500 in exchange for      */
  68. /*                getting the use of several man-years of software engineering             */
  69. /*                resources.                                                                                                                 */
  70. /*****************************************************************************/
  71. extern short    cdecl CheckMidiIn(void); // Returns 1 if MIDPAK is installed, 0 if not.
  72. extern short    cdecl DigPakAvailable(void);    // Returns 1 if DIGPAK is installed, 0 if not.
  73.  
  74. /****************************************************************************/
  75. /* These flags are returned by the XMIDI registration call.             */
  76. /****************************************************************************/
  77. #define FAILURE_TO_REGISTER 0     // Xmidi file registration failed.
  78. #define REGISTERED_RESIDENT 1   // Resident driver holds midi file now.
  79.                 // The application can throw away the memory
  80.                 // if it wants to.
  81. #define REGISTERED_APPLICATION 2  // Driver didn't have a big enough buffer
  82.                   // area reserved to hold the audio data
  83.                   // so the application is responsible for
  84.                   // keeping the memory for this sequence
  85.                   // while it is registered.
  86.  
  87. extern short    cdecl PlaySequence(short seqnum); // Play a particular sequence number from
  88.                   // the currently registered xmidi file.
  89.  
  90. #define NEXT_CALLBACK -1    // Activation on next callback.
  91.  
  92. extern short    cdecl SegueSequence(short seqnum,short activate);
  93.                 // Switch sequence to this sequence when next
  94.                 // callback trigger event is hit with the
  95.                 // event number equal to activate.    If activate
  96.                 // is set to -1 then the next event causes the
  97.                 // segue to occur.
  98.  
  99. extern short    cdecl RegisterXmidi(char    *xmidi,long int size);
  100.                 // Registers an extended midi file for playback.
  101.                 // This call will register all sequences.
  102.  
  103. extern short    cdecl MidiStop(void);     // Stop playing current sequence.
  104.  
  105. extern long int  cdecl ReportCallbackTrigger(void); // Low word is trigger count.
  106.                       // High word is last event ID.
  107.  
  108. extern void  cdecl ResetCallbackCounter(void);    // Reset callback counter to zero.
  109.  
  110. extern void  cdecl ResumePlaying(void);     // Resume playing last sequence.
  111.  
  112. #define SEQ_STOPPED 0         // equates for SequenceStatus()
  113. #define SEQ_PLAYING 1
  114. #define SEQ_DONE 2
  115. extern short     cdecl SequenceStatus(void);    // Report current sequence play status.
  116.  
  117. extern short     cdecl RelativeVolume(short vol); // Report current volume.
  118.  
  119. extern void  cdecl SetRelativeVolume(short vol,short time); // Set volume, over time period.
  120.  
  121. #define NOBUFFER 1        // No resident buffer available.
  122. #define FILENOTFOUND 2        // The file was not found.
  123. #define FILETOBIG 3         // The file exceeds the reserved buffer size.
  124. #define REGISTRATIONERROR 4     // Error registering the XMI file.
  125.  
  126. extern short     cdecl RegisterXmidiFile(char *fname); // Register by filename.
  127.  
  128. extern void  cdecl PollMidPak(void); // Poll MidPak for music processing.
  129.  
  130. extern long int  cdecl MidPakClock(void); // Return MIDPAK heartbeat count (120hz)
  131.  
  132. extern long int  * cdecl MidPakClockAddress(void); // Return address of midpak clock.
  133.  
  134. extern short    *  cdecl TriggerCountAddress(void); // Report address of trigger count.
  135.  
  136. extern short    *  cdecl EventIDAddress(void); // Report address of event id.
  137.  
  138. extern short    cdecl ReportSequenceNumber(void);
  139.  
  140. extern short    cdecl InitMP(char *midpak,char *adv,char    *ad); // Init MIDI driver.
  141. extern void cdecl DeInitMP(char *midpak); // Unload a previously loaded sound driver.
  142.