PLAYCD.H.BAK 8.9 KB

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