GetCD.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. /*
  2. ** Command & Conquer Generals(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 S T U D I O S ****
  20. ************************************************************************************************
  21. * *
  22. * Project Name : Command & Conquer *
  23. * *
  24. * $Archive:: /Renegade Setup/Autorun/GetCD.h $Author:: Denzil_l *
  25. * $Modtime:: 1/08/02 3:38p $Revision:: 20 *
  26. * *
  27. *----------------------------------------------------------------------------------------------*
  28. * Functions: *
  29. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
  30. #pragma once
  31. #ifndef GETCD_H
  32. #define GETCD_H
  33. extern char * _CD_Volume_Label[];
  34. extern int _Num_Volumes;
  35. #ifdef NOT_FOR_WIN95
  36. /* ==================================================================== */
  37. /* Defines */
  38. /* ==================================================================== */
  39. #define CHLEFT 0
  40. #define CHRIGHT 1
  41. #define CHBOTH 2
  42. #define AUDIO_START_MIN 1
  43. #define AUDIO_START_SEC 44
  44. struct SEGSEL {
  45. unsigned short seg ;
  46. unsigned short sel ;
  47. };
  48. extern "C" int DPMI_real_alloc ( UINT , SEGSEL * , USHORT * ) ;
  49. extern "C" int DPMI_real_free ( SEGSEL ) ;
  50. extern "C" void DPMI_real_intr ( int , union REGS * , struct SREGS * );
  51. extern "C" void DPMI_real_call ( void * funct , union REGS * , struct SREGS * );
  52. /* ==================================================================== */
  53. /* Data structures */
  54. /* ==================================================================== */
  55. //-----------------------------------------------------------------------------
  56. // Audio Track Info request block
  57. //-----------------------------------------------------------------------------
  58. #pragma pack(push, 1)
  59. struct TinfoType {
  60. UBYTE Length;
  61. UBYTE SubCd;
  62. UBYTE Command;
  63. UWORD Status;
  64. UBYTE Rsvd[8];
  65. UBYTE MDescr;
  66. UWORD TrnsAdOff;
  67. UWORD TrnsAdSeg;
  68. UWORD CntTrns;
  69. UWORD StSect;
  70. UWORD VolIDOff;
  71. UWORD VolIDSeg;
  72. UBYTE TrInfo;
  73. UBYTE Track;
  74. ULONG Start;
  75. UBYTE TrCtrl;
  76. };
  77. #pragma pack(pop)
  78. //-----------------------------------------------------------------------------
  79. // Audio Track Status Control Block
  80. //-----------------------------------------------------------------------------
  81. #pragma pack(push, 1)
  82. struct StatType {
  83. UBYTE Length;
  84. UBYTE SubCd;
  85. UBYTE Command;
  86. UWORD Status;
  87. UBYTE Rsvd[8];
  88. UBYTE MDescr;
  89. UWORD TrnsAdOff;
  90. UWORD TrnsAdSeg;
  91. UWORD CntTrns;
  92. UWORD StSect;
  93. UWORD VolIDOff;
  94. UWORD VolIDSeg;
  95. UBYTE StatInfo;
  96. UWORD Stat;
  97. ULONG Start;
  98. ULONG End;
  99. };
  100. #pragma pack(pop)
  101. //-----------------------------------------------------------------------------
  102. // Audio Track Volume control block
  103. //-----------------------------------------------------------------------------
  104. #pragma pack(push, 1)
  105. struct VolmType {
  106. UBYTE Length;
  107. UBYTE SubCd;
  108. UBYTE Command;
  109. UWORD Status;
  110. UBYTE Rsvd[8];
  111. UBYTE MDescr;
  112. UWORD TrnsAdOff;
  113. UWORD TrnsAdSeg;
  114. UWORD CntTrns;
  115. UWORD StSect;
  116. UWORD VolIDOff;
  117. UWORD VolIDSeg;
  118. UBYTE TrInfo;
  119. UBYTE In0;
  120. UBYTE Vol0;
  121. UBYTE In1;
  122. UBYTE Vol1;
  123. UBYTE In2;
  124. UBYTE Vol2;
  125. UBYTE In3;
  126. UBYTE Vol3;
  127. };
  128. #pragma pack(pop)
  129. //-----------------------------------------------------------------------------
  130. // Audio Track Play request block
  131. //-----------------------------------------------------------------------------
  132. #pragma pack(push, 1)
  133. struct PlayType {
  134. UBYTE Length;
  135. UBYTE SubCd;
  136. UBYTE Command;
  137. UWORD Status;
  138. UBYTE Rsvd[8];
  139. UBYTE AddrMd;
  140. ULONG Start;
  141. ULONG CntSect;
  142. };
  143. #pragma pack(pop)
  144. //-----------------------------------------------------------------------------
  145. // Audio Track Stop request block
  146. //-----------------------------------------------------------------------------
  147. #pragma pack(push, 1)
  148. struct StopType {
  149. UBYTE Length;
  150. UBYTE SubCd;
  151. UBYTE Command;
  152. UWORD Status;
  153. UBYTE Rsvd[8];
  154. };
  155. #pragma pack(pop)
  156. #endif //NOT_FOR_WIN95
  157. /****************************************************************************
  158. * GetCDClass -- object which will return logical CD drive *
  159. * *
  160. * HISTORY: *
  161. * 06/04/1994 SW : Created. *
  162. *==========================================================================*/
  163. #define MAX_CD_DRIVES 26
  164. #define NO_CD_DRIVE -1
  165. class GetCDClass
  166. {
  167. public:
  168. GetCDClass ( void ); // This is the default constructor
  169. ~GetCDClass ( void ); // This is the destructor
  170. inline int Get_First_CD_Drive ( void );
  171. inline int Get_Next_CD_Drive ( void );
  172. inline int Get_Number_Of_Drives ( void ) { return( CDCount ); };
  173. inline int Get_Index ( void ) { return( CDIndex ); };
  174. inline void Reset_Index ( void ) { CDIndex = 0; };
  175. int Get_CD_Drive_For_This_Volume ( char *volume_name );
  176. char * Get_Volume_For_This_CD_Drive ( char *path, char *volume_name );
  177. char * Get_Volume_Label ( int index );
  178. protected:
  179. int CDDrives[ MAX_CD_DRIVES ]; //Array containing CD drive letters
  180. int CDCount; //Number of available CD drives
  181. int CDIndex; //Index of current location
  182. };
  183. /****************************************************************************
  184. * GCDC::Get_First_CD_Drive -- return the number of the first CD drive *
  185. * *
  186. * INPUT: none *
  187. * *
  188. * OUTPUT: logical drive number *
  189. * *
  190. * WARNINGS: *
  191. * *
  192. * HISTORY: *
  193. * 05/26/1994 SW : Created. *
  194. * 12/4/95 ST : fixed for Win95 *
  195. *==========================================================================*/
  196. inline int GetCDClass::Get_First_CD_Drive(void)
  197. {
  198. CDIndex = 0;
  199. return (Get_Next_CD_Drive());
  200. }
  201. /************************************************************************************
  202. * GCDC::Get_Next_CD_Drive -- return the logical drive number of the next CD drive *
  203. * *
  204. * INPUT: Nothing *
  205. * *
  206. * OUTPUT: Logical drive number of a cd drive or -1 if none *
  207. * *
  208. * WARNINGS: None *
  209. * *
  210. * HISTORY: *
  211. * 5/21/96 3:50PM ST : Created *
  212. *==================================================================================*/
  213. inline int GetCDClass::Get_Next_CD_Drive(void)
  214. {
  215. if (CDCount){
  216. if (CDIndex >= CDCount) {
  217. CDIndex = 0;
  218. }
  219. return (CDDrives[CDIndex++]);
  220. } else {
  221. return (-1);
  222. }
  223. }
  224. /************************************************************************************
  225. * RedBookClass -- adds red book functionality *
  226. * *
  227. * this class inherits from GetCDClass and adds red book play functionality *
  228. * *
  229. * *
  230. * HISTORY: *
  231. * 06/04/1994 SW : Created. *
  232. *==================================================================================*/
  233. #ifdef NOT_FOR_WIN95
  234. class RedBookClass : public GetCDClass
  235. {
  236. public:
  237. RedBookClass(void); // This is the default constructor
  238. ~RedBookClass(void); // This is the destructor
  239. ULONG RedToHS(ULONG i);
  240. ULONG MSFtoRed(UBYTE m, UBYTE s, UBYTE f);
  241. void FullCDVolume(UBYTE chan);
  242. void PlayTrack(UWORD track);
  243. void Play_CD_MSL(UWORD min_sec, UWORD len);
  244. void PlayMSF(UBYTE startM, UBYTE startS, UBYTE startF,
  245. UBYTE endM, UBYTE endS, UBYTE endF, UBYTE chan);
  246. UWORD CheckCDMusic(void);
  247. void StopCDMusic(void);
  248. private:
  249. SEGSEL Tinfo_addrp;
  250. SEGSEL Stat_addrp;
  251. SEGSEL Stop_addrp;
  252. SEGSEL Volm_addrp;
  253. SEGSEL Play_addrp;
  254. StopType Stop;
  255. PlayType Play;
  256. VolmType Volm;
  257. StatType Stat;
  258. TinfoType Tinfo;
  259. };
  260. #endif //NOT_FOR_WIN95
  261. /***************************** End of Playcd.h ****************************/
  262. extern GetCDClass CDList;
  263. //-----------------------------------------------------------------------------
  264. // Functions
  265. //-----------------------------------------------------------------------------
  266. bool CD_Volume_Verification ( int cd_drive, char *volume_label, char *volume_to_find );
  267. #endif // PLAYCD_H