PLAYCD.H 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /***************************************************************************
  15. ** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
  16. ***************************************************************************
  17. * *
  18. * Project Name : WWLIB *
  19. * *
  20. * File Name : PLAYCD.H *
  21. * *
  22. * Programmer : STEVE WETHERILL *
  23. * *
  24. * Start Date : 5/13/94 *
  25. * *
  26. * Last Update : June 4, 1994 [SW] *
  27. * *
  28. *-------------------------------------------------------------------------*/
  29. #ifndef PLAYCD_H
  30. #define PLAYCD_H
  31. #ifdef NOT_FOR_WIN95
  32. /* ==================================================================== */
  33. /* Defines */
  34. /* ==================================================================== */
  35. #define CHLEFT 0
  36. #define CHRIGHT 1
  37. #define CHBOTH 2
  38. #define AUDIO_START_MIN 1
  39. #define AUDIO_START_SEC 44
  40. typedef struct {
  41. unsigned short seg ;
  42. unsigned short sel ;
  43. } SEGSEL ;
  44. extern "C" int DPMI_real_alloc ( UINT , SEGSEL * , USHORT * ) ;
  45. extern "C" int DPMI_real_free ( SEGSEL ) ;
  46. extern "C" void DPMI_real_intr ( int , union REGS * , struct SREGS * );
  47. extern "C" void DPMI_real_call ( void * funct , union REGS * , struct SREGS * );
  48. /* ==================================================================== */
  49. /* Data structures */
  50. /* ==================================================================== */
  51. // Audio Track Info request block
  52. struct TinfoType {
  53. UBYTE Length;
  54. UBYTE SubCd;
  55. UBYTE Command;
  56. UWORD Status;
  57. UBYTE Rsvd[8];
  58. UBYTE MDescr;
  59. UWORD TrnsAdOff;
  60. UWORD TrnsAdSeg;
  61. UWORD CntTrns;
  62. UWORD StSect;
  63. UWORD VolIDOff;
  64. UWORD VolIDSeg;
  65. UBYTE TrInfo;
  66. UBYTE Track;
  67. ULONG Start;
  68. UBYTE TrCtrl;
  69. };
  70. // Audio Track Status Control Block
  71. struct StatType {
  72. UBYTE Length;
  73. UBYTE SubCd;
  74. UBYTE Command;
  75. UWORD Status;
  76. UBYTE Rsvd[8];
  77. UBYTE MDescr;
  78. UWORD TrnsAdOff;
  79. UWORD TrnsAdSeg;
  80. UWORD CntTrns;
  81. UWORD StSect;
  82. UWORD VolIDOff;
  83. UWORD VolIDSeg;
  84. UBYTE StatInfo;
  85. UWORD Stat;
  86. ULONG Start;
  87. ULONG End;
  88. };
  89. // Audio Track Volume control block
  90. struct VolmType {
  91. UBYTE Length;
  92. UBYTE SubCd;
  93. UBYTE Command;
  94. UWORD Status;
  95. UBYTE Rsvd[8];
  96. UBYTE MDescr;
  97. UWORD TrnsAdOff;
  98. UWORD TrnsAdSeg;
  99. UWORD CntTrns;
  100. UWORD StSect;
  101. UWORD VolIDOff;
  102. UWORD VolIDSeg;
  103. UBYTE TrInfo;
  104. UBYTE In0;
  105. UBYTE Vol0;
  106. UBYTE In1;
  107. UBYTE Vol1;
  108. UBYTE In2;
  109. UBYTE Vol2;
  110. UBYTE In3;
  111. UBYTE Vol3;
  112. };
  113. // Audio Track Play request block
  114. struct PlayType {
  115. UBYTE Length;
  116. UBYTE SubCd;
  117. UBYTE Command;
  118. UWORD Status;
  119. UBYTE Rsvd[8];
  120. UBYTE AddrMd;
  121. ULONG Start;
  122. ULONG CntSect;
  123. };
  124. // Audio Track Stop request block
  125. struct StopType {
  126. UBYTE Length;
  127. UBYTE SubCd;
  128. UBYTE Command;
  129. UWORD Status;
  130. UBYTE Rsvd[8];
  131. };
  132. #endif //NOT_FOR_WIN95
  133. /***************************************************************************
  134. * GetCDClass -- object which will return logical CD drive *
  135. * *
  136. * HISTORY: *
  137. * 06/04/1994 SW : Created. *
  138. *=========================================================================*/
  139. #define MAX_CD_DRIVES 26
  140. #define NO_CD_DRIVE -1
  141. class GetCDClass {
  142. protected:
  143. int CDDrives[MAX_CD_DRIVES]; //Array containing CD drive letters
  144. int CDCount; //Number of available CD drives
  145. int CDIndex;
  146. public:
  147. GetCDClass(VOID); // This is the default constructor
  148. ~GetCDClass(VOID); // This is the destructor
  149. inline int Get_First_CD_Drive(void);
  150. inline int Get_Next_CD_Drive(void);
  151. inline int Get_Number_Of_Drives(void) {return (CDCount);};
  152. };
  153. /***********************************************************************************************
  154. * GCDC::Get_Next_CD_Drive -- return the logical drive number of the next CD drive *
  155. * *
  156. * *
  157. * *
  158. * INPUT: Nothing *
  159. * *
  160. * OUTPUT: Logical drive number of a cd drive or -1 if none *
  161. * *
  162. * WARNINGS: None *
  163. * *
  164. * HISTORY: *
  165. * 5/21/96 3:50PM ST : Created *
  166. *=============================================================================================*/
  167. inline int GetCDClass::Get_Next_CD_Drive(void)
  168. {
  169. if (CDCount){
  170. if (CDIndex == CDCount) CDIndex = 0;
  171. return (CDDrives[CDIndex++]);
  172. }else{
  173. return (-1);
  174. }
  175. }
  176. /***************************************************************************
  177. * GCDC::Get_First_CD_Drive -- return the number of the first CD drive *
  178. * *
  179. * *
  180. * *
  181. * INPUT: *
  182. * none *
  183. * OUTPUT: *
  184. * logical drive number *
  185. * WARNINGS: *
  186. * *
  187. * HISTORY: *
  188. * 05/26/1994 SW : Created. *
  189. * 12/4/95 ST : fixed for Win95 *
  190. *=========================================================================*/
  191. inline int GetCDClass::Get_First_CD_Drive(void)
  192. {
  193. CDIndex = 0;
  194. return (Get_Next_CD_Drive());
  195. }
  196. /***************************************************************************
  197. * RedBookClass -- adds red book functionality *
  198. * *
  199. * this class inherits from GetCDClass and adds red book play functionality*
  200. * *
  201. * *
  202. * HISTORY: *
  203. * 06/04/1994 SW : Created. *
  204. *=========================================================================*/
  205. #ifdef NOT_FOR_WIN95
  206. class RedBookClass : public GetCDClass {
  207. private:
  208. SEGSEL Tinfo_addrp;
  209. SEGSEL Stat_addrp;
  210. SEGSEL Stop_addrp;
  211. SEGSEL Volm_addrp;
  212. SEGSEL Play_addrp;
  213. StopType Stop;
  214. PlayType Play;
  215. VolmType Volm;
  216. StatType Stat;
  217. TinfoType Tinfo;
  218. public:
  219. RedBookClass(VOID); // This is the default constructor
  220. ~RedBookClass(VOID); // This is the destructor
  221. ULONG RedToHS(ULONG i);
  222. ULONG MSFtoRed(UBYTE m, UBYTE s, UBYTE f);
  223. VOID FullCDVolume(UBYTE chan);
  224. VOID PlayTrack(UWORD track);
  225. VOID Play_CD_MSL(UWORD min_sec, UWORD len);
  226. VOID PlayMSF(UBYTE startM, UBYTE startS, UBYTE startF,
  227. UBYTE endM, UBYTE endS, UBYTE endF, UBYTE chan);
  228. UWORD CheckCDMusic(VOID);
  229. VOID StopCDMusic(VOID);
  230. };
  231. #endif //NOT_FOR_WIN95
  232. /***************************** End of Playcd.h ****************************/
  233. #endif // PLAYCD_H
  234.