AUDIO.CPP 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  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. /* $Header: F:\projects\c&c\vcs\code\audio.cpv 2.17 16 Oct 1995 16:50:20 JOE_BOSTIC $ */
  15. /***********************************************************************************************
  16. *** 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 ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : AUDIO.CPP *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : September 10, 1993 *
  26. * *
  27. * Last Update : May 4, 1995 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * Is_Speaking -- Checks to see if the eva voice is still playing. *
  32. * Sound_Effect -- General purpose sound player. *
  33. * Sound_Effect -- Plays a sound effect in the tactical map. *
  34. * Speak -- Computer speaks to the player. *
  35. * Speak_AI -- Handles starting the EVA voices. *
  36. * Stop_Speaking -- Forces the EVA voice to stop talking. *
  37. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  38. #include "function.h"
  39. /*
  40. **
  41. **
  42. ** Win32lib stubs
  43. **
  44. **
  45. **
  46. */
  47. SFX_Type SoundType;
  48. Sample_Type SampleType;
  49. int File_Stream_Sample(char const *filename, BOOL real_time_start) {return 1;};
  50. int File_Stream_Sample_Vol(char const *filename, int volume, BOOL real_time_start) {return 1;};
  51. void __cdecl Sound_Callback(void) {};
  52. void __cdecl far maintenance_callback(void) {};
  53. void *Load_Sample(char const *filename) {return NULL;};
  54. long Load_Sample_Into_Buffer(char const *filename, void *buffer, long size) {return 0;}
  55. long Sample_Read(int fh, void *buffer, long size) {return 0;};
  56. void Free_Sample(void const *sample) {};
  57. BOOL Audio_Init( HWND window , int bits_per_sample, BOOL stereo , int rate , int reverse_channels) {return 0;};
  58. void Sound_End(void) {};
  59. void Stop_Sample(int handle) {};
  60. BOOL Sample_Status(int handle) {return 0;};
  61. BOOL Is_Sample_Playing(void const * sample) {return 0;};
  62. void Stop_Sample_Playing(void const * sample) {};
  63. int Play_Sample(void const *sample, int priority, int volume, signed short panloc) {return 1;};
  64. int Play_Sample_Handle(void const *sample, int priority, int volume, signed short panloc, int id) {return 1;};
  65. int Set_Sound_Vol(int volume) {return 0;};
  66. int Set_Score_Vol(int volume) {return 0;};
  67. void Fade_Sample(int handle, int ticks) {};
  68. int Get_Free_Sample_Handle(int priority) {return 1;};
  69. int Get_Digi_Handle(void) {return 1;}
  70. long Sample_Length(void const *sample) {return 0;};
  71. void Restore_Sound_Buffers (void) {};
  72. BOOL Set_Primary_Buffer_Format(void) {return 0;};
  73. BOOL Start_Primary_Sound_Buffer (BOOL forced) {return 0;};
  74. void Stop_Primary_Sound_Buffer (void) {};
  75. /***************************************************************************
  76. ** Controls what special effects may occur on the sound effect.
  77. */
  78. typedef enum {
  79. IN_NOVAR, // No variation or alterations allowed.
  80. IN_JUV, // Juvenile sound effect alternate option.
  81. IN_VAR, // Infantry variance response modification.
  82. } ContextType;
  83. // static struct { // MBL 02.21.2019
  84. // Had to name the struct for VS 2017 distributed build. ST - 4/10/2019 3:59PM
  85. struct SoundEffectNameStruct {
  86. char const *Name; // Digitized voice file name.
  87. int Priority; // Playback priority of this sample.
  88. ContextType Where; // In what game context does this sample exist.
  89. } SoundEffectName[VOC_COUNT] = {
  90. /*
  91. ** Special voices (typically associated with the commando).
  92. */
  93. {"BOMBIT1", 20, IN_NOVAR}, // VOC_RAMBO_PRESENT "I've got a present for ya"
  94. {"CMON1", 20, IN_NOVAR}, // VOC_RAMBO_CMON "c'mon"
  95. {"GOTIT1", 20, IN_NOVAR}, // VOC_RAMBO_UGOTIT "you got it" *
  96. {"KEEPEM1", 20, IN_NOVAR}, // VOC_RAMBO_COMIN "keep 'em commin'"
  97. {"LAUGH1", 20, IN_NOVAR}, // VOC_RAMBO_LAUGH "hahaha"
  98. {"LEFTY1", 20, IN_NOVAR}, // VOC_RAMBO_LEFTY "that was left handed" *
  99. {"NOPRBLM1", 20, IN_NOVAR}, // VOC_RAMBO_NOPROB "no problem"
  100. // {"OHSH1", 20, IN_NOVAR}, // VOC_RAMBO_OHSH "oh shiiiiii...."
  101. {"ONIT1", 20, IN_NOVAR}, // VOC_RAMBO_ONIT "I'm on it"
  102. {"RAMYELL1", 20, IN_NOVAR}, // VOC_RAMBO_YELL "ahhhhhhh"
  103. {"ROKROLL1", 20, IN_NOVAR}, // VOC_RAMBO_ROCK "time to rock and roll"
  104. {"TUFFGUY1", 20, IN_NOVAR}, // VOC_RAMBO_TUFF "real tuff guy" *
  105. {"YEAH1", 20, IN_NOVAR}, // VOC_RAMBO_YEA "yea" *
  106. {"YES1", 20, IN_NOVAR}, // VOC_RAMBO_YES "yes" *
  107. {"YO1", 20, IN_NOVAR}, // VOC_RAMBO_YO "yo"
  108. /*
  109. ** Civilian voices (technicians too).
  110. */
  111. {"GIRLOKAY", 20, IN_NOVAR}, // VOC_GIRL_OKAY
  112. {"GIRLYEAH", 20, IN_NOVAR}, // VOC_GIRL_YEAH
  113. {"GUYOKAY1", 20, IN_NOVAR}, // VOC_GUY_OKAY
  114. {"GUYYEAH1", 20, IN_NOVAR}, // VOC_GUY_YEAH
  115. /*
  116. ** Infantry and vehicle responses.
  117. */
  118. {"2DANGR1", 10, IN_VAR}, // VOC_2DANGER "negative, too dangerous"
  119. {"ACKNO", 10, IN_VAR}, // VOC_ACKNOWL "acknowledged"
  120. {"AFFIRM1", 10, IN_VAR}, // VOC_AFFIRM "affirmative"
  121. {"AWAIT1", 10, IN_VAR}, // VOC_AWAIT1 "awaiting orders"
  122. // {"BACKUP", 10, IN_VAR}, // VOC_BACKUP "send backup"
  123. // {"HELP", 10, IN_VAR}, // VOC_HELP "send help"
  124. {"MOVOUT1", 10, IN_VAR}, // VOC_MOVEOUT "movin' out"
  125. {"NEGATV1", 10, IN_VAR}, // VOC_NEGATIVE "negative"
  126. {"NOPROB", 10, IN_VAR}, // VOC_NO_PROB "not a problem"
  127. {"READY", 10, IN_VAR}, // VOC_READY "ready and waiting"
  128. {"REPORT1", 10, IN_VAR}, // VOC_REPORT "reporting"
  129. {"RITAWAY", 10, IN_VAR}, // VOC_RIGHT_AWAY "right away sir"
  130. {"ROGER", 10, IN_VAR}, // VOC_ROGER "roger"
  131. // {"SIR1", 10, IN_VAR}, // VOC_SIR1 "sir?"
  132. // {"SQUAD1", 10, IN_VAR}, // VOC_SQUAD1 "squad reporting"
  133. // {"TARGET1", 10, IN_VAR}, // VOC_PRACTICE "target practice"
  134. {"UGOTIT", 10, IN_VAR}, // VOC_UGOTIT "you got it"
  135. {"UNIT1", 10, IN_VAR}, // VOC_UNIT1 "unit reporting"
  136. {"VEHIC1", 10, IN_VAR}, // VOC_VEHIC1 "vehicle reporting"
  137. {"YESSIR1", 10, IN_VAR}, // VOC_YESSIR "yes sir"
  138. /*
  139. ** Sound effects that have a juvenile counterpart.
  140. */
  141. {"BAZOOK1", 1, IN_JUV}, // VOC_BAZOOKA Gunfire
  142. {"BLEEP2", 1, IN_JUV}, // VOC_BLEEP Clean metal bing
  143. {"BOMB1", 1, IN_JUV}, // VOC_BOMB1 Crunchy parachute bomb type explosion
  144. {"BUTTON", 1, IN_JUV}, // VOC_BUTTON Dungeon Master button click
  145. {"COMCNTR1", 10, IN_JUV}, // VOC_RADAR_ON Elecronic static with beeps
  146. {"CONSTRU2", 10, IN_JUV}, // VOC_CONSTRUCTION construction sounds
  147. {"CRUMBLE", 1, IN_JUV}, // VOC_CRUMBLE muffled crumble sound
  148. {"FLAMER2", 4, IN_JUV}, // VOC_FLAMER1 flame thrower
  149. {"GUN18", 4, IN_JUV}, // VOC_RIFLE rifle shot
  150. {"GUN19", 4, IN_JUV}, // VOC_M60 machine gun burst -- 6 rounds
  151. {"GUN20", 4, IN_JUV}, // VOC_GUN20 bat hitting heavy metal door
  152. {"GUN5", 4, IN_JUV}, // VOC_M60A medium machine gun burst
  153. {"GUN8", 4, IN_JUV}, // VOC_MINI mini gun burst
  154. {"GUNCLIP1", 1, IN_JUV}, // VOC_RELOAD gun clip reload
  155. {"HVYDOOR1", 5, IN_JUV}, // VOC_SLAM metal plates slamming together
  156. {"HVYGUN10", 1, IN_JUV}, // VOC_HVYGUN10 loud sharp cannon
  157. {"ION1", 1, IN_JUV}, // VOC_ION_CANNON partical beam
  158. {"MGUN11", 1, IN_JUV}, // VOC_MGUN11 alternate tripple burst
  159. {"MGUN2", 1, IN_JUV}, // VOC_MGUN2 M-16 tripple burst
  160. {"NUKEMISL", 1, IN_JUV}, // VOC_NUKE_FIRE long missile sound
  161. {"NUKEXPLO", 1, IN_JUV}, // VOC_NUKE_EXPLODE long but not loud explosion
  162. {"OBELRAY1", 1, IN_JUV}, // VOC_LASER humming laser beam
  163. {"OBELPOWR", 1, IN_JUV}, // VOC_LASER_POWER warming-up sound of laser beam
  164. {"POWRDN1", 1, IN_JUV}, // VOC_RADAR_OFF doom door slide
  165. {"RAMGUN2", 1, IN_JUV}, // VOC_SNIPER silenced rifle fire
  166. {"ROCKET1", 1, IN_JUV}, // VOC_ROCKET1 rocket launch variation #1
  167. {"ROCKET2", 1, IN_JUV}, // VOC_ROCKET2 rocket launch variation #2
  168. {"SAMMOTR2", 1, IN_JUV}, // VOC_MOTOR dentists drill
  169. {"SCOLD2", 1, IN_JUV}, // VOC_SCOLD cannot perform action feedback tone
  170. {"SIDBAR1C", 1, IN_JUV}, // VOC_SIDEBAR_OPEN xylophone clink
  171. {"SIDBAR2C", 1, IN_JUV}, // VOC_SIDEBAR_CLOSE xylophone clink
  172. {"SQUISH2", 1, IN_JUV}, // VOC_SQUISH2 crushing infantry
  173. {"TNKFIRE2", 1, IN_JUV}, // VOC_TANK1 sharp tank fire with recoil
  174. {"TNKFIRE3", 1, IN_JUV}, // VOC_TANK2 sharp tank fire
  175. {"TNKFIRE4", 1, IN_JUV}, // VOC_TANK3 sharp tank fire
  176. {"TNKFIRE6", 1, IN_JUV}, // VOC_TANK4 big gun tank fire
  177. {"TONE15", 0, IN_JUV}, // VOC_UP credits counting up
  178. {"TONE16", 0, IN_JUV}, // VOC_DOWN credits counting down
  179. {"TONE2", 1, IN_JUV}, // VOC_TARGET target sound
  180. {"TONE5", 10, IN_JUV}, // VOC_SONAR sonar echo
  181. {"TOSS", 1, IN_JUV}, // VOC_TOSS air swish
  182. {"TRANS1", 1, IN_JUV}, // VOC_CLOAK stealth tank
  183. {"TREEBRN1", 1, IN_JUV}, // VOC_BURN burning crackle
  184. {"TURRFIR5", 1, IN_JUV}, // VOC_TURRET muffled gunfire
  185. {"XPLOBIG4", 5, IN_JUV}, // VOC_XPLOBIG4 very long muffled explosion
  186. {"XPLOBIG6", 5, IN_JUV}, // VOC_XPLOBIG6 very long muffled explosion
  187. {"XPLOBIG7", 5, IN_JUV}, // VOC_XPLOBIG7 very long muffled explosion
  188. {"XPLODE", 1, IN_JUV}, // VOC_XPLODE long soft muffled explosion
  189. {"XPLOS", 4, IN_JUV}, // VOC_XPLOS short crunchy explosion
  190. {"XPLOSML2", 5, IN_JUV}, // VOC_XPLOSML2 muffled mechanical explosion
  191. /*
  192. ** Generic sound effects (no variations).
  193. */
  194. {"NUYELL1", 10, IN_NOVAR}, // VOC_SCREAM1 short infantry scream
  195. {"NUYELL3", 10, IN_NOVAR}, // VOC_SCREAM3 short infantry scream
  196. {"NUYELL4", 10, IN_NOVAR}, // VOC_SCREAM4 short infantry scream
  197. {"NUYELL5", 10, IN_NOVAR}, // VOC_SCREAM5 short infantry scream
  198. {"NUYELL6", 10, IN_NOVAR}, // VOC_SCREAM6 short infantry scream
  199. {"NUYELL7", 10, IN_NOVAR}, // VOC_SCREAM7 short infantry scream
  200. {"NUYELL10", 10, IN_NOVAR}, // VOC_SCREAM10 short infantry scream
  201. {"NUYELL11", 10, IN_NOVAR}, // VOC_SCREAM11 short infantry scream
  202. {"NUYELL12", 10, IN_NOVAR}, // VOC_SCREAM12 short infantry scream
  203. {"YELL1", 1, IN_NOVAR}, // VOC_YELL1 long infantry scream
  204. {"MYES1", 10, IN_NOVAR}, // VOC_YES "Yes?"
  205. {"MCOMND1", 10, IN_NOVAR}, // VOC_COMMANDER "Commander?"
  206. {"MHELLO1", 10, IN_NOVAR}, // VOC_HELLO "Hello?"
  207. {"MHMMM1", 10, IN_NOVAR}, // VOC_HMMM "Hmmm?"
  208. // {"MHASTE1", 10, IN_NOVAR}, // VOC_PROCEED1 "I will proceed, post haste."
  209. // {"MONCE1", 10, IN_NOVAR}, // VOC_PROCEED2 "I will proceed, at once."
  210. // {"MIMMD1", 10, IN_NOVAR}, // VOC_PROCEED3 "I will proceed, immediately."
  211. // {"MPLAN1", 10, IN_NOVAR}, // VOC_EXCELLENT1 "That is an excellent plan."
  212. // {"MPLAN2", 10, IN_NOVAR}, // VOC_EXCELLENT2 "Yes, that is an excellent plan."
  213. {"MPLAN3", 10, IN_NOVAR}, // VOC_EXCELLENT3 "A wonderful plan."
  214. // {"MACTION1", 10, IN_NOVAR}, // VOC_EXCELLENT4 "Astounding plan of action commander."
  215. // {"MREMARK1", 10, IN_NOVAR}, // VOC_EXCELLENT5 "Remarkable contrivance."
  216. {"MCOURSE1", 10, IN_NOVAR}, // VOC_OF_COURSE "Of course."
  217. {"MYESYES1", 10, IN_NOVAR}, // VOC_YESYES "Yes yes yes."
  218. {"MTIBER1", 10, IN_NOVAR}, // VOC_QUIP1 "Mind the Tiberium."
  219. // {"MMG1", 10, IN_NOVAR}, // VOC_QUIP2 "A most remarkable Metasequoia Glyptostroboides."
  220. {"MTHANKS1", 10, IN_NOVAR}, // VOC_THANKS "Thank you."
  221. {"CASHTURN", 1, IN_NOVAR}, // VOC_CASHTURN Sound of money being piled up.
  222. {"BLEEP2", 10, IN_NOVAR}, // VOC_BLEEPY3 Clean computer bleep sound.
  223. {"DINOMOUT", 10, IN_NOVAR}, // VOC_DINOMOUT Movin' out in dino-speak.
  224. {"DINOYES", 10, IN_NOVAR}, // VOC_DINOYES Yes Sir in dino-speak.
  225. {"DINOATK1", 10, IN_NOVAR}, // VOC_DINOATK1 Dino attack sound.
  226. {"DINODIE1", 10, IN_NOVAR}, // VOC_DINODIE1 Dino die sound.
  227. {"BEACON", 10, IN_NOVAR }, // VOC_BEACON Beacon sound.
  228. #ifdef PETROGLYPH_EXAMPLE_MOD
  229. {"NUKE_LOB", 10, IN_NOVAR} // VOC_NUKE_LOB Mod expansion unit firing sound
  230. #endif //PETROGLYPH_EXAMPLE_MOD
  231. };
  232. //
  233. // External handlers. ST - 2/20/2019 3:41PM
  234. //
  235. extern void On_Sound_Effect(int sound_index, int variation, COORDINATE coord);
  236. // extern void On_Speech(int speech_index); // MBL 02.06.2020
  237. extern void On_Speech(int speech_index, HouseClass *house);
  238. extern void On_Ping(const HouseClass* player_ptr, COORDINATE coord);
  239. /***********************************************************************************************
  240. * Sound_Effect -- Plays a sound effect in the tactical map. *
  241. * *
  242. * This routine is used when a sound effect occurs in the game world. It handles fading *
  243. * the sound according to distance. *
  244. * *
  245. * INPUT: voc -- The sound effect number to play. *
  246. * *
  247. * coord -- The world location that the sound originates from. *
  248. * *
  249. * OUTPUT: none *
  250. * *
  251. * WARNINGS: none *
  252. * *
  253. * HISTORY: *
  254. * 11/12/1994 JLB : Created. *
  255. * 01/05/1995 JLB : Reduces sound more dramatically when off screen. *
  256. *=============================================================================================*/
  257. void Sound_Effect(VocType voc, COORDINATE coord, int variation)
  258. {
  259. //
  260. // Intercept sound effect calls. ST - 2/20/2019 3:37PM
  261. //
  262. On_Sound_Effect((int)voc, variation, coord);
  263. #if (0)
  264. unsigned distance;
  265. CELL cell_pos;
  266. int pan_value;
  267. if (!Options.Volume || voc == VOC_NONE || !SoundOn || SampleType == SAMPLE_NONE) {
  268. return;
  269. }
  270. if (coord) {
  271. cell_pos = Coord_Cell(coord);
  272. }
  273. distance = 0xFF;
  274. pan_value = 0;
  275. if (coord && !Map.In_View(cell_pos)) {
  276. distance = Map.Cell_Distance(cell_pos, Coord_Cell(Map.TacticalCoord));
  277. distance = (unsigned int)MIN((int)distance, (int)MAP_CELL_W);
  278. distance = Cardinal_To_Fixed(MAP_CELL_W, distance);
  279. distance = MIN(distance, 0xFFu);
  280. distance ^= 0xFF;
  281. distance /= 2;
  282. distance = MAX(distance, 25U);
  283. pan_value = Cell_X(cell_pos);
  284. pan_value -= Coord_XCell(Map.TacticalCoord) + (Lepton_To_Cell(Map.TacLeptonWidth) >> 1);
  285. if (ABS(pan_value) > Lepton_To_Cell(Map.TacLeptonWidth >> 1)) {
  286. pan_value *= 0x8000;
  287. pan_value /= (MAP_CELL_W >> 2);
  288. pan_value = Bound(pan_value, -0x7FFF, 0x7FFF);
  289. // pan_value = MAX((int)pan_value, (int)-0x7FFF);
  290. // pan_value = MIN((int)pan_value, 0x7FFF);
  291. } else {
  292. pan_value = 0;
  293. }
  294. }
  295. Sound_Effect(voc, (VolType)Fixed_To_Cardinal(distance, Options.Volume), variation, pan_value);
  296. #endif
  297. }
  298. /***********************************************************************************************
  299. * Sound_Effect -- General purpose sound player. *
  300. * *
  301. * This is used for general purpose sound effects. These are sounds that occur outside *
  302. * of the game world. They do not have a corresponding game world location as their source. *
  303. * *
  304. * INPUT: voc -- The sound effect number to play. *
  305. * *
  306. * volume -- The volume to assign to this sound effect. *
  307. * *
  308. * OUTPUT: Returns with the sound handle (-1 if no sound was played). *
  309. * *
  310. * WARNINGS: none *
  311. * *
  312. * HISTORY: *
  313. * 11/12/1994 JLB : Created. *
  314. * 11/12/1994 JLB : Handles cache logic. *
  315. * 05/04/1995 JLB : Variation adjustments. *
  316. *=============================================================================================*/
  317. int Sound_Effect(VocType voc, VolType volume, int variation, signed short pan_value)
  318. {
  319. char name[_MAX_FNAME+_MAX_EXT]; // Working filename of sound effect.
  320. if (!Options.Volume || voc == VOC_NONE || !SoundOn || SampleType == SAMPLE_NONE) {
  321. return(-1);
  322. }
  323. /*
  324. ** Fetch a pointer to the sound effect data. Modify the sound as appropriate and desired.
  325. */
  326. char const * ext = ".AUD";
  327. if (Special.IsJuvenile && SoundEffectName[voc].Where == IN_JUV) {
  328. ext = ".JUV";
  329. } else {
  330. if (SoundEffectName[voc].Where == IN_VAR) {
  331. /*
  332. ** For infantry, use a variation on the response. For vehicles, always
  333. ** use the vehicle response table.
  334. */
  335. if (variation < 0) {
  336. if (ABS(variation) % 2) {
  337. ext = ".V00";
  338. } else {
  339. ext = ".V02";
  340. }
  341. } else {
  342. if (variation % 2) {
  343. ext = ".V01";
  344. } else {
  345. ext = ".V03";
  346. }
  347. }
  348. }
  349. }
  350. _makepath(name, NULL, NULL, SoundEffectName[voc].Name, ext);
  351. void const * ptr = MixFileClass::Retrieve(name);
  352. /*
  353. ** If the sound data pointer is not null, then presume that it is valid.
  354. */
  355. if (ptr) {
  356. return(Play_Sample(ptr, Fixed_To_Cardinal(SoundEffectName[voc].Priority, (int)volume), (int)volume, pan_value));
  357. }
  358. return(-1);
  359. }
  360. /*
  361. ** This elaborates all the EVA speech voices.
  362. */
  363. char const * Speech[VOX_COUNT] = {
  364. "ACCOM1", // mission accomplished
  365. "FAIL1", // your mission has failed
  366. "BLDG1", // unable to comply, building in progress
  367. "CONSTRU1", // construction complete
  368. "UNITREDY", // unit ready
  369. "NEWOPT1", // new construction options
  370. "DEPLOY1", // cannot deploy here
  371. "GDIDEAD1", // GDI unit destroyed
  372. "NODDEAD1", // Nod unit destroyed
  373. "CIVDEAD1", // civilian killed
  374. // "EVAYES1", // affirmative
  375. // "EVANO1", // negative
  376. // "UPUNIT1", // upgrade complete, new unit available
  377. // "UPSTRUC1", // upgrade complete, new structure available
  378. "NOCASH1", // insufficient funds
  379. "BATLCON1", // battle control terminated
  380. "REINFOR1", // reinforcements have arrived
  381. "CANCEL1", // canceled
  382. "BLDGING1", // building
  383. "LOPOWER1", // low power
  384. "NOPOWER1", // insufficient power
  385. "MOCASH1", // need more funds
  386. "BASEATK1", // our base is under attack
  387. "INCOME1", // incoming missile
  388. "ENEMYA", // enemy planes approaching
  389. "NUKE1", // nuclear warhead approaching - VOX_INCOMING_NUKE
  390. // "RADOK1", // radiation levels are acceptable
  391. // "RADFATL1", // radiation levels are fatal
  392. "NOBUILD1", // unable to build more
  393. "PRIBLDG1", // primary building selected
  394. // "REPDONE1", // repairs completed
  395. "NODCAPT1", // Nod building captured
  396. "GDICAPT1", // GDI building captured
  397. // "SOLD1", // structure sold
  398. "IONCHRG1", // ion cannon charging
  399. "IONREDY1", // ion cannon ready
  400. "NUKAVAIL", // nuclear weapon available
  401. "NUKLNCH1", // nuclear weapon launched - VOX_NUKE_LAUNCHED
  402. "UNITLOST", // unit lost
  403. "STRCLOST", // structure lost
  404. "NEEDHARV", // need harvester
  405. "SELECT1", // select target
  406. "AIRREDY1", // airstrike ready
  407. "NOREDY1", // not ready
  408. "TRANSSEE", // Nod transport sighted
  409. "TRANLOAD", // Nod transport loaded
  410. "ENMYAPP1", // enemy approaching
  411. "SILOS1", // silos needed
  412. "ONHOLD1", // on hold
  413. "REPAIR1", // repairing
  414. "ESTRUCX", // enemy structure destroyed
  415. "GSTRUC1", // GDI structure destroyed
  416. "NSTRUC1", // NOD structure destroyed
  417. "ENMYUNIT", // Enemy unit destroyed
  418. // "GUKILL1", // gold unit destroyed
  419. // "GSTRUD1", // gold structure destroyed
  420. // "GONLINE1", // gold player online
  421. // "GLEFT1", // gold player has departed
  422. // "GOLDKILT", // gold player destroyed
  423. // "GOLDWIN", // gold player is victorious
  424. // "RUKILL1", // red unit destroyed
  425. // "RSTRUD1", // red structure destroyed
  426. // "RONLINE1", // red player online
  427. // "RLEFT1", // red player has departed
  428. // "REDKILT", // red player destroyed
  429. // "REDWIN", // red player is victorious
  430. // "GYUKILL1", // grey unit destroyed
  431. // "GYSTRUD1", // grey structure destroyed
  432. // "GYONLINE", // grey player online
  433. // "GYLEFT1", // grey player has departed
  434. // "GREYKILT", // grey player destroyed
  435. // "GREYWIN", // grey player is victorious
  436. // "OUKILL1", // orange unit destroyed
  437. // "OSTRUD1", // orange structure destroyed
  438. // "OONLINE1", // orange player online
  439. // "OLEFT1", // orange player has departed
  440. // "ORANKILT", // orange player destroyed
  441. // "ORANWIN", // orange player is victorious
  442. // "GNUKILL1", // green unit destroyed
  443. // "GNSTRUD1", // green structure destroyed
  444. // "GNONLINE", // green player online
  445. // "GNLEFT1", // green player has departed
  446. // "GRENKILT", // green player destroyed
  447. // "GRENWIN", // green player is victorious
  448. // "BUKILL1", // blue unit destroyed
  449. // "BSTRUD1", // blue structure destroyed
  450. // "BONLINE1", // blue player online
  451. // "BLEFT1", // blue player has departed
  452. // "BLUEKILT", // blue player destroyed
  453. // "BLUEWIN" // blue player is victorious
  454. };
  455. static VoxType CurrentVoice = VOX_NONE;
  456. /***********************************************************************************************
  457. * Speak -- Computer speaks to the player. *
  458. * *
  459. * This routine is used to have the game computer (EVA) speak to the player. *
  460. * *
  461. * INPUT: voice -- The voice number to speak (see defines.h). *
  462. * *
  463. * OUTPUT: Returns with the handle of the playing speech (-1 if no voice started). *
  464. * *
  465. * WARNINGS: none *
  466. * *
  467. * HISTORY: *
  468. * 11/12/1994 JLB : Created. *
  469. *=============================================================================================*/
  470. void Speak(VoxType voice, HouseClass *house, COORDINATE coord)
  471. {
  472. // MBL 02.22.2019
  473. if (voice == VOX_NONE)
  474. {
  475. return;
  476. }
  477. //
  478. // Intercept speech calls. ST - 2/20/2019 3:37PM
  479. //
  480. // On_Speech((int)voice); // MBL 02.06.2020
  481. On_Speech((int)voice, house);
  482. if (coord) {
  483. On_Ping(house, coord);
  484. }
  485. #if (0)
  486. if (Options.Volume && SampleType != 0 && voice != VOX_NONE && voice != SpeakQueue && voice != CurrentVoice && SpeakQueue == VOX_NONE) {
  487. SpeakQueue = voice;
  488. }
  489. #endif
  490. }
  491. /***********************************************************************************************
  492. * Speak_AI -- Handles starting the EVA voices. *
  493. * *
  494. * This starts the EVA voice talking as well. If there is any speech request in the queue, *
  495. * it will be started when the current voice is finished. Call this routine as often as *
  496. * possible (once per game tick is sufficient). *
  497. * *
  498. * INPUT: none *
  499. * *
  500. * OUTPUT: none *
  501. * *
  502. * WARNINGS: none *
  503. * *
  504. * HISTORY: *
  505. * 12/27/1994 JLB : Created. *
  506. *=============================================================================================*/
  507. void Speak_AI(void)
  508. {
  509. // MBL 06.17.2019 KO
  510. #if 0
  511. static VoxType _last = VOX_NONE;
  512. if (SampleType == 0) return;
  513. if (!Is_Sample_Playing(SpeechBuffer)) {
  514. CurrentVoice = VOX_NONE;
  515. if (SpeakQueue != VOX_NONE) {
  516. if (SpeakQueue != _last) {
  517. char name[_MAX_FNAME+_MAX_EXT];
  518. _makepath(name, NULL, NULL, Speech[SpeakQueue], ".AUD");
  519. if (CCFileClass(name).Read(SpeechBuffer, SPEECH_BUFFER_SIZE)) {
  520. Play_Sample(SpeechBuffer, 254, Options.Volume);
  521. }
  522. _last = SpeakQueue;
  523. } else {
  524. Play_Sample(SpeechBuffer, 254, Options.Volume);
  525. }
  526. SpeakQueue = VOX_NONE;
  527. }
  528. }
  529. #endif
  530. }
  531. /***********************************************************************************************
  532. * Stop_Speaking -- Forces the EVA voice to stop talking. *
  533. * *
  534. * Use this routine to immediately stop the EVA voice from speaking. It also clears out *
  535. * the pending voice queue. *
  536. * *
  537. * INPUT: none *
  538. * *
  539. * OUTPUT: none *
  540. * *
  541. * WARNINGS: none *
  542. * *
  543. * HISTORY: *
  544. * 12/27/1994 JLB : Created. *
  545. *=============================================================================================*/
  546. void Stop_Speaking(void)
  547. {
  548. SpeakQueue = VOX_NONE;
  549. if (SampleType != 0) {
  550. Stop_Sample_Playing(SpeechBuffer);
  551. }
  552. }
  553. /***********************************************************************************************
  554. * Is_Speaking -- Checks to see if the eva voice is still playing. *
  555. * *
  556. * Call this routine when the EVA voice being played needs to be checked. A typical use *
  557. * of this would be when some action needs to be delayed until the voice has finished -- *
  558. * say the end of the game. *
  559. * *
  560. * INPUT: none *
  561. * *
  562. * OUTPUT: bool; Is the EVA voice still playing? *
  563. * *
  564. * WARNINGS: none *
  565. * *
  566. * HISTORY: *
  567. * 03/12/1995 JLB : Created. *
  568. *=============================================================================================*/
  569. bool Is_Speaking(void)
  570. {
  571. Speak_AI();
  572. if (SampleType != 0 && (SpeakQueue != VOX_NONE || Is_Sample_Playing(SpeechBuffer))) {
  573. return(true);
  574. }
  575. return(false);
  576. }