EGOS.CPP 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986
  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: /counterstrike/EGOS.CPP 2 3/10/97 3:19p Steve_tall $ */
  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 - Red Alert *
  20. * *
  21. * File Name : EGOS.CPP *
  22. * *
  23. * Programmer : Steve Tall *
  24. * *
  25. * Start Date : September 4th, 1996 *
  26. * *
  27. * Last Update : September 4th, 1996 [ST] *
  28. * *
  29. *-----------------------------------------------------------------------------------*
  30. * Overview: *
  31. * *
  32. * Scrolling movie style credits. *
  33. * *
  34. *-----------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #if(0)
  38. //PG_TO_FIX
  39. #include "function.h"
  40. /*
  41. ** List of Ego Class instances
  42. ** There will be one instance for each line of text.
  43. */
  44. DynamicVectorClass<EgoClass *> EgoList;
  45. /*
  46. ** Number of slideshow pictures
  47. */
  48. #define NUM_SLIDES 17
  49. /*
  50. ** Length of time frame is displayed for
  51. */
  52. #define FRAME_DELAY 150
  53. /*
  54. ** Number of frames that palete fade occurs over
  55. */
  56. #define FADE_DELAY 37
  57. /*
  58. ** Names of slideshow pictures to play behind the text
  59. */
  60. char SlideNames[NUM_SLIDES][13]={
  61. "aftr_hi.pcx",
  62. "aly1.pcx",
  63. "apc_hi.pcx",
  64. "aphi0049.pcx",
  65. "bnhi0020.pcx",
  66. "dchi0040.pcx",
  67. "frhi0166.pcx",
  68. "lab.pcx",
  69. "landsbrg.pcx",
  70. "mahi0107.pcx",
  71. "mig_hi.pcx",
  72. "mtfacthi.pcx",
  73. "needle.pcx",
  74. "sov2.pcx",
  75. "spy.pcx",
  76. "stalin.pcx",
  77. "tent.pcx"
  78. };
  79. /*
  80. ** Names of low res slideshow pictures to play behind the text
  81. */
  82. char LoresSlideNames[NUM_SLIDES][13]={
  83. "malo0107.cps",
  84. "mig_lo.cps",
  85. "mtfactlo.cps",
  86. "needl-lo.cps",
  87. "sov2-lo.cps",
  88. "spy-lo.cps",
  89. "staln-lo.cps",
  90. "tent-lo.cps",
  91. "aftr_lo.cps",
  92. "aly1-lo.cps",
  93. "apc_lo.cps",
  94. "aplo0049.cps",
  95. "bnlo0020.cps",
  96. "dclo0040.cps",
  97. "frlo0166.cps",
  98. "lab-lo.cps",
  99. "lands-lo.cps"
  100. };
  101. /*
  102. ** Array of all the palettes required for the slides
  103. */
  104. char SlidePals[NUM_SLIDES][256*3];
  105. /*
  106. ** Array of graphic buffers containing the slides
  107. */
  108. GraphicBufferClass *SlideBuffers[NUM_SLIDES];
  109. /*
  110. ** Original copy of slide (pref in video mem) that we use to undraw the text
  111. */
  112. GraphicBufferClass *BackgroundPage;
  113. /*
  114. ** This palette contains both the font palette entries and the slide
  115. ** palette.
  116. */
  117. PaletteClass ComboPalette;
  118. /*
  119. ** Ptr to the combo palette.
  120. */
  121. unsigned char *ComboPalPtr;
  122. /*
  123. ** Lookup table. If an entry is non-zero then it should be faded in/out when the slide changes.
  124. */
  125. char PaletteLUT[256];
  126. /*
  127. ** Height of the strips that are blitted from the slides to the backgound and hid pages.
  128. ** We blit in several strips over several frames so as not to impact on the frame rate.
  129. */
  130. #define CHUNK_HEIGHT RESFACTOR * 50
  131. #ifndef WIN32
  132. extern void Vsync(void);
  133. #pragma aux Vsync modify [edx ebx eax] = \
  134. "mov edx,03DAh" \
  135. "mov ebx,[VertBlank]" \
  136. "and bl,001h" \
  137. "shl bl,3" \
  138. "in_vbi:" \
  139. "in al,dx" \
  140. "and al,008h" \
  141. "xor al,bl" \
  142. "je in_vbi" \
  143. "out_vbi:" \
  144. "in al,dx" \
  145. "and al,008h" \
  146. "xor al,bl" \
  147. "jne out_vbi"
  148. #endif //WIN32
  149. /***********************************************************************************************
  150. * EC::EgoClass -- EgoClass constructor *
  151. * *
  152. * *
  153. * *
  154. * INPUT: x position of text *
  155. * y position of text *
  156. * ptr to text string *
  157. * flags to print text with *
  158. * *
  159. * *
  160. * OUTPUT: Nothing *
  161. * *
  162. * WARNINGS: None *
  163. * *
  164. * HISTORY: *
  165. * 9/9/96 11:53PM ST : Created *
  166. *=============================================================================================*/
  167. EgoClass::EgoClass (int x, int y, char *text, TextPrintType flags)
  168. {
  169. XPos = x;
  170. YPos = y;
  171. Flags= flags;
  172. Text = new char [strlen (text)+1];
  173. strcpy (Text, text);
  174. }
  175. /***********************************************************************************************
  176. * EC::~EgoClass -- EgoClass destructor *
  177. * *
  178. * *
  179. * *
  180. * INPUT: Nothing *
  181. * *
  182. * OUTPUT: Nothing *
  183. * *
  184. * WARNINGS: None *
  185. * *
  186. * HISTORY: *
  187. * 9/9/96 11:54PM ST : Created *
  188. *=============================================================================================*/
  189. EgoClass::~EgoClass(void)
  190. {
  191. delete [] Text;
  192. }
  193. /***********************************************************************************************
  194. * EC::Scroll -- Apply the given distance to the y position of the text. *
  195. * A positive distance scrolls up. *
  196. * *
  197. * *
  198. * INPUT: distance in pixels to scroll up *
  199. * *
  200. * OUTPUT: true if text scrolled beyond the top of the screen *
  201. * *
  202. * WARNINGS: None *
  203. * *
  204. * HISTORY: *
  205. * 9/9/96 11:55PM ST : Created *
  206. *=============================================================================================*/
  207. bool EgoClass::Scroll(int distance)
  208. {
  209. YPos -= distance;
  210. if (YPos < -20) {
  211. return (true);
  212. }else{
  213. return (false);
  214. }
  215. }
  216. /***********************************************************************************************
  217. * EC::Render -- Draws the text to the logic page *
  218. * *
  219. * *
  220. * *
  221. * INPUT: Nothing *
  222. * *
  223. * OUTPUT: Nothing *
  224. * *
  225. * WARNINGS: None *
  226. * *
  227. * HISTORY: *
  228. * 9/9/96 11:57PM ST : Created *
  229. *=============================================================================================*/
  230. void EgoClass::Render (void)
  231. {
  232. if (YPos < LogicPage->Get_Height() && YPos > -16) {
  233. Fancy_Text_Print(Text, XPos, YPos, GadgetClass::Get_Color_Scheme(), TBLACK, Flags);
  234. }
  235. }
  236. /***********************************************************************************************
  237. * EC::Wipe -- Wipes the previously rendered text by blitting a rectangle from the given *
  238. * background screen. *
  239. * *
  240. * *
  241. * INPUT: ptr to screen containing original background *
  242. * *
  243. * OUTPUT: Nothing *
  244. * *
  245. * WARNINGS: None *
  246. * *
  247. * HISTORY: *
  248. * 9/9/96 11:58PM ST : Created *
  249. *=============================================================================================*/
  250. void EgoClass::Wipe (GraphicBufferClass *background)
  251. {
  252. int width = String_Pixel_Width (Text);
  253. int x = XPos;
  254. if (Flags & TPF_RIGHT) {
  255. x -= width;
  256. }else{
  257. if (Flags & TPF_CENTER){
  258. x -= width/2;
  259. }
  260. }
  261. background->Blit(*LogicPage, x-1, YPos, x-1, YPos, width+2, 7 * RESFACTOR +1, false);
  262. }
  263. /***********************************************************************************************
  264. * Set_Pal -- Low level palette set *
  265. * *
  266. * *
  267. * *
  268. * INPUT: ptr to palette *
  269. * *
  270. * OUTPUT: Nothing *
  271. * *
  272. * WARNINGS: None *
  273. * *
  274. * HISTORY: *
  275. * 9/9/96 11:59PM ST : Created *
  276. *=============================================================================================*/
  277. void Set_Pal(char *palette)
  278. {
  279. //#ifndef WIN32
  280. //Vsync();
  281. //unsigned char *rgbptr = (unsigned char *) palette;
  282. //outportb(0x03C8, 0); //Start from color 0
  283. //for (int index = 0; index < 256; index++) {
  284. // outrgb(rgbptr[index*3], rgbptr[index*3+1], rgbptr[index*3+2]);
  285. //}
  286. //#else //WIN32
  287. Set_Palette((void*)palette);
  288. //#endif
  289. }
  290. /***********************************************************************************************
  291. * Slide_Show -- Handles the blitting and fading of the background pictures. *
  292. * *
  293. * The picture frame number is used to trigger blitting and fading events *
  294. * *
  295. * *
  296. * INPUT: picture number *
  297. * frame *
  298. * *
  299. * OUTPUT: Nothing *
  300. * *
  301. * WARNINGS: None *
  302. * *
  303. * HISTORY: *
  304. * 9/10/96 0:16AM ST : Created *
  305. *=============================================================================================*/
  306. void Slide_Show (int slide, int frame)
  307. {
  308. /*
  309. ** Temprary storage to save CCPalette to
  310. */
  311. char save_palette[256*3];
  312. if (frame >= 1 && frame <=4){
  313. /*
  314. ** Blit in a quarter of the new frame to the background page.
  315. */
  316. SlideBuffers[slide]->Blit (*BackgroundPage, 0, (frame-1) * CHUNK_HEIGHT,
  317. 0, (frame-1) * CHUNK_HEIGHT,
  318. SeenBuff.Get_Width(), CHUNK_HEIGHT, false);
  319. return;
  320. }
  321. if (frame >= 5 && frame <=8 ){
  322. /*
  323. ** Blit in a quarter of the new frame to the hid page.
  324. */
  325. BackgroundPage->Blit (HidPage, 0, (frame-5) * CHUNK_HEIGHT,
  326. 0, (frame-5) * CHUNK_HEIGHT,
  327. SeenBuff.Get_Width(), CHUNK_HEIGHT, false);
  328. return;
  329. }
  330. if (frame ==9){
  331. /*
  332. ** Create the combo palette from the font entries and the picture entries.
  333. */
  334. for (int index = 0 ; index < 256 ; index++ ){
  335. if (PaletteLUT[index]) {
  336. ComboPalPtr[index*3] = SlidePals[slide][index*3];
  337. ComboPalPtr[index*3+1] = SlidePals[slide][index*3+1];
  338. ComboPalPtr[index*3+2] = SlidePals[slide][index*3+2];
  339. }
  340. }
  341. return;
  342. }
  343. if (frame >10 && frame < FADE_DELAY+10){
  344. /*
  345. ** Fade up the picture in the background. The text colors never fade.
  346. */
  347. memcpy (save_palette, CCPalette, sizeof(save_palette));
  348. //CCPalette.Partial_Adjust (MIN (6*(frame-5), 255), ComboPalette, PaletteLUT);
  349. CCPalette.Partial_Adjust (MIN ((255/FADE_DELAY)*(frame-10), 255), ComboPalette, PaletteLUT);
  350. Set_Pal ( (char *) &CCPalette);
  351. if (frame != 9+FADE_DELAY){
  352. memcpy (CCPalette, save_palette, sizeof(save_palette));
  353. }else{
  354. memcpy (CCPalette, CurrentPalette, sizeof (CCPalette));
  355. }
  356. return;
  357. }
  358. if (frame >FRAME_DELAY && frame < FRAME_DELAY+FADE_DELAY){
  359. /*
  360. ** Fade down the picture in the background. The text colors never fade.
  361. */
  362. memcpy (save_palette, CCPalette, sizeof(save_palette));
  363. CCPalette.Partial_Adjust (MIN ((255/FADE_DELAY)*(frame-FRAME_DELAY), 255), PaletteLUT);
  364. if (frame != FRAME_DELAY+FADE_DELAY-1){
  365. Set_Pal ( (char *) &CCPalette);
  366. memcpy (CCPalette, save_palette, sizeof(save_palette));
  367. }else{
  368. /*
  369. ** If this is the last fade down frame then zero the picture palette entries.
  370. */
  371. unsigned char *ccpalptr = (unsigned char*)CCPalette;
  372. for (int index = 0 ; index < 256 ; index++){
  373. if (PaletteLUT[index]){
  374. ccpalptr[index*3] = 0;
  375. ccpalptr[index*3+1] = 0;
  376. ccpalptr[index*3+2] = 0;
  377. }
  378. }
  379. Set_Pal ( (char *) &CCPalette);
  380. }
  381. }
  382. }
  383. /***********************************************************************************************
  384. * Show_Who_Was_Responsible -- Main function to print the credits. *
  385. * *
  386. * *
  387. * *
  388. * INPUT: Nothing *
  389. * *
  390. * OUTPUT: Nothing *
  391. * *
  392. * WARNINGS: None *
  393. * *
  394. * HISTORY: *
  395. * 9/10/96 0:20AM ST : Created *
  396. *=============================================================================================*/
  397. void Show_Who_Was_Responsible (void)
  398. {
  399. int i;
  400. int key;
  401. /*
  402. ** Deault speed of credits scolling. This is the frame delay between pixel scrolls.
  403. */
  404. static int speed = 3;
  405. /*
  406. ** In DOS we need to scroll slower so we have a bool that lets us do it every other time
  407. */
  408. #ifndef WIN32
  409. bool scroll_now = false;
  410. #endif //WIN32
  411. /*
  412. ** Read in the credits file to be displayed
  413. **
  414. ** Lines of text in CREDITS.TXT are treated as follows....
  415. **
  416. ** If the text starts and ends to the left of column 40 then text will be right justified.
  417. ** If the text starts before column 40 and ends after it then it will be centered.
  418. ** If the text starts after column 40 it will be right justified.
  419. */
  420. CCFileClass creditsfile ("credits.txt");
  421. if ( !creditsfile.Is_Available()) return;
  422. char *credits = new char [creditsfile.Size()+1];
  423. creditsfile.Read (credits, creditsfile.Size());
  424. /*
  425. ** Initialise the text printing system.
  426. */
  427. GadgetClass::Set_Color_Scheme(&ColorRemaps[PCOLOR_GREEN]);
  428. Fancy_Text_Print(TXT_NONE, 0, 0, GadgetClass::Get_Color_Scheme(),
  429. TBLACK, TPF_CENTER|TPF_6PT_GRAD|TPF_USE_GRAD_PAL|TPF_NOSHADOW);
  430. /*
  431. ** Miscellaneous stuff for parsing the credits text file.
  432. */
  433. int length = creditsfile.Size();
  434. int line = 0;
  435. int column = 0;
  436. char *cptr = credits;
  437. char ch, lastchar, oldchar;
  438. char *strstart, *strparse;
  439. bool gotendstr;
  440. int startcolumn, endcolumn, x;
  441. int y=SeenBuff.Get_Height()+2;
  442. EgoClass *ego;
  443. TextPrintType flags;
  444. /*
  445. ** Search through the text file and extract the strings, using each string to create
  446. ** a new EgoClass
  447. */
  448. do {
  449. /*
  450. ** Search for text
  451. */
  452. ch = *cptr++;
  453. length --;
  454. /*
  455. ** Look for a non whitespace character.
  456. */
  457. switch ( ch ){
  458. case 13:
  459. /*
  460. ** Char was carriage return. Go on to the next line starting at column 0.
  461. */
  462. line++;
  463. column = 0;
  464. break;
  465. case 10:
  466. /*
  467. ** Ignore line feed. CR does both.
  468. */
  469. break;
  470. /*
  471. ** Space character. Just advance the cursor and move on.
  472. */
  473. case 32:
  474. column++;
  475. break;
  476. /*
  477. ** Tab char. Advance to the next tab column. Tabs are every 8 columns.
  478. */
  479. case 9:
  480. column += 8;
  481. column &= 0xfffffff8;
  482. break;
  483. default:
  484. /*
  485. ** Found new string. Work out where it ends so we know how to treat it.
  486. */
  487. lastchar = ch;
  488. strstart = cptr-1;
  489. strparse = cptr-1;
  490. endcolumn = startcolumn = column;
  491. gotendstr = false;
  492. do {
  493. ch = *strparse++;
  494. switch ( ch ){
  495. case 9:
  496. case 10:
  497. case 13:
  498. gotendstr = true;
  499. break;
  500. case 32:
  501. if (lastchar == 32) gotendstr = true;
  502. endcolumn++;
  503. break;
  504. default:
  505. endcolumn++;
  506. }
  507. if (strparse >= cptr+length) gotendstr = true;
  508. lastchar = ch;
  509. }while (!gotendstr);
  510. if (strparse >= cptr+length) break;
  511. /*
  512. ** Strip off any trailing space.
  513. */
  514. if (*(strparse-2) == 32){
  515. strparse--;
  516. endcolumn -= 2;
  517. }
  518. /*
  519. ** If string straddles the center column then center it.
  520. **
  521. ** If string is on the left hand side then right justify it.
  522. **
  523. ** If string is on the right hand side then left justify it.
  524. */
  525. flags = TPF_6PT_GRAD | TPF_USE_GRAD_PAL | TPF_DROPSHADOW; //TPF_NOSHADOW;
  526. if (startcolumn <40 && endcolumn >40){
  527. flags = flags | TPF_CENTER;
  528. x = SeenBuff.Get_Width() / 2;
  529. }else{
  530. if (startcolumn <40){
  531. flags = flags | TPF_RIGHT;
  532. x = endcolumn *SeenBuff.Get_Width() /80;
  533. }else{
  534. x = startcolumn * SeenBuff.Get_Width() / 80;
  535. }
  536. }
  537. /*
  538. ** Temporarily terminate the string.
  539. */
  540. oldchar = *(strparse-1);
  541. *(strparse-1) = 0;
  542. /*
  543. ** Create the new class and add it to our list.
  544. */
  545. ego = new EgoClass (x, y+ line *8 *RESFACTOR, strstart, flags);
  546. EgoList.Add (ego);
  547. /*
  548. ** Restore the character that was lost when we added the terminator.
  549. */
  550. *(strparse-1) = oldchar;
  551. /*
  552. ** Fix up our outer loop parsing variables.
  553. */
  554. cptr = strparse;
  555. column += strparse - strstart;
  556. length -= strparse - strstart-1;
  557. if (ch == 13) {
  558. line++;
  559. column = 0;
  560. }else{
  561. if (ch == 9){
  562. column += 7;
  563. column &= 0xfffffff8;
  564. }
  565. }
  566. break;
  567. }
  568. } while ( length>0 );
  569. /*
  570. ** Work out which palette entries the font needs so we dont fade those colors.
  571. */
  572. memset (PaletteLUT, 1, sizeof (PaletteLUT));
  573. int pcolor = PCOLOR_GREEN;
  574. for (int index = 0; index < 6; index++) {
  575. PaletteLUT[ColorRemaps[pcolor].FontRemap[10+index]] =0;
  576. }
  577. //PaletteLUT[ColorRemaps[pcolor].BrightColor] = 0;
  578. PaletteLUT[ColorRemaps[pcolor].Color] = 0;
  579. PaletteLUT[ColorRemaps[pcolor].Shadow] = 0;
  580. PaletteLUT[ColorRemaps[pcolor].Background] = 0;
  581. PaletteLUT[ColorRemaps[pcolor].Corners] = 0;
  582. PaletteLUT[ColorRemaps[pcolor].Highlight] = 0;
  583. PaletteLUT[ColorRemaps[pcolor].Bright] = 0;
  584. PaletteLUT[ColorRemaps[pcolor].Underline] = 0;
  585. PaletteLUT[ColorRemaps[pcolor].Bar] = 0;
  586. PaletteLUT[ColorRemaps[pcolor].Box] = 0;
  587. /*
  588. ** Stop the music.
  589. */
  590. Theme.Stop();
  591. /*
  592. ** Fade to black.
  593. */
  594. BlackPalette.Set(TIMER_SECOND*2, Call_Back);
  595. /*
  596. ** Load the reference palette for the font.
  597. */
  598. //Load_Title_Page(true);
  599. //#ifdef WIN32
  600. // Load_Picture("EGOPAL.CPS", SysMemPage, SysMemPage, CCPalette, BM_DEFAULT);
  601. //#else //WIN32
  602. // Load_Picture("EGOPAL.CPS", HidPage, HidPage, CCPalette, BM_DEFAULT);
  603. //#endif //WIN32
  604. CCFileClass("EGOPAL.PAL").Read(&CCPalette, sizeof(CCPalette));
  605. /*
  606. ** Copy the font palette entries into the combo palette.
  607. */
  608. PaletteClass credit_palette;
  609. ComboPalPtr = (unsigned char *) &ComboPalette;
  610. unsigned char *creditpal_ptr = (unsigned char *) &credit_palette;
  611. memcpy (ComboPalette, CCPalette, sizeof (ComboPalette));
  612. for (index = 0 ; index < 256 ; index++ ){
  613. if (PaletteLUT[index]) {
  614. ComboPalPtr[index*3] = 0;
  615. ComboPalPtr[index*3+1] = 0;
  616. ComboPalPtr[index*3+2] = 0;
  617. }
  618. }
  619. /*
  620. ** Clear the Seen Page since we will not be blitting to all of it.
  621. */
  622. SeenBuff.Clear();
  623. HidPage.Clear();
  624. /*
  625. ** Set the font palette.
  626. */
  627. memcpy ( CCPalette, ComboPalette, sizeof (ComboPalette) );
  628. CCPalette.Set();
  629. /*
  630. ** Loop through and load up all the slideshow pictures
  631. */
  632. for (index = 0 ; index < NUM_SLIDES ; index++){
  633. #ifdef WIN32
  634. SlideBuffers[index] = new GraphicBufferClass;
  635. SlideBuffers[index]->Init (SeenBuff.Get_Width(), SeenBuff.Get_Height(), NULL , 0 , (GBC_Enum)0);
  636. Load_Title_Screen(&SlideNames[index][0], SlideBuffers[index], (unsigned char*) &SlidePals[index][0]);
  637. #else //WIN32
  638. SlideBuffers[index] = new GraphicBufferClass (SeenBuff.Get_Width(), SeenBuff.Get_Height(), (void*)NULL);
  639. Load_Picture(&LoresSlideNames[index][0], *SlideBuffers[index], *SlideBuffers[index], (unsigned char *)&SlidePals[index][0], BM_DEFAULT);
  640. #endif //WIN32
  641. }
  642. /*
  643. ** Create a new graphic buffer to restore the background from. Initialise it to black so
  644. ** we can start scrolling before the first slideshow picture is blitted.
  645. */
  646. #ifdef WIN32
  647. BackgroundPage = new GraphicBufferClass;
  648. BackgroundPage->Init (SeenBuff.Get_Width(), SeenBuff.Get_Height(), NULL , 0 , (GBC_Enum)(GBC_VIDEOMEM));
  649. #else //WIN32
  650. BackgroundPage = new GraphicBufferClass (SeenBuff.Get_Width(), SeenBuff.Get_Height(), (void*)NULL );
  651. #endif //WIN32
  652. SeenBuff.Blit(*BackgroundPage);
  653. /*
  654. ** Go away nasty keyboard.
  655. */
  656. Keyboard->Clear();
  657. Set_Logic_Page(HidPage);
  658. /*
  659. ** Start any old song.
  660. */
  661. fixed oldvolume = Options.ScoreVolume;
  662. if (oldvolume == 0) {
  663. Options.Set_Score_Volume(fixed(4, 10), false);
  664. }
  665. Theme.Queue_Song(THEME_CREDITS);
  666. /*
  667. ** Init misc timing variables.
  668. */
  669. int time = TickCount;
  670. int frame = 0;
  671. int picture_frame = 0;
  672. int slide_number = 0;
  673. Hide_Mouse();
  674. /*
  675. ** Save the priority of this process so we can change it back later
  676. */
  677. //DWORD process_priority = GetPriorityClass(GetCurrentProcess());
  678. /*
  679. ** Main scrolling loop.
  680. ** Keeps going until all the EgoClass objects are deleted or esc is pressed.
  681. */
  682. while ( EgoList.Count() ){
  683. frame++;
  684. /*
  685. ** Once we have been running for a few frames, and Windows has time to do its virtual
  686. ** memory stuff, increase our priority level.
  687. */
  688. //if (frame == 30){
  689. // SetPriorityClass (GetCurrentProcess() , HIGH_PRIORITY_CLASS);
  690. //}
  691. /*
  692. ** Update the slideshow frame and switch to the next picture if its time.
  693. */
  694. picture_frame++;
  695. if (picture_frame > FRAME_DELAY+50){
  696. if (slide_number <NUM_SLIDES-1){
  697. slide_number++;
  698. picture_frame = 0;
  699. }else{
  700. slide_number = 0;
  701. picture_frame = 0;
  702. }
  703. }
  704. /*
  705. ** Do the slideshow background.
  706. */
  707. Slide_Show (slide_number, picture_frame);
  708. /*
  709. ** Scroll the text. If any text goes off the top then delete that object.
  710. */
  711. #ifndef WIN32
  712. scroll_now = !scroll_now;
  713. if (scroll_now){
  714. #endif //WIN32
  715. for (i=EgoList.Count()-1 ; i>=0 ; i--){
  716. EgoList[i]->Wipe(BackgroundPage);
  717. if ( EgoList[i]->Scroll(1) ){
  718. EgoList.Delete(i);
  719. break;
  720. }
  721. }
  722. #ifndef WIN32
  723. }
  724. #endif //WIN32
  725. /*
  726. ** Render all the text strings in their new positions.
  727. */
  728. if (LogicPage->Lock()){
  729. for (i=EgoList.Count()-1 ; i>=0 ; i--){
  730. EgoList[i]->Render();
  731. }
  732. LogicPage->Unlock();
  733. }
  734. if (frame > 1000 && !Theme.Still_Playing()){
  735. Theme.Queue_Song(THEME_CREDITS); //NONE);
  736. }
  737. /*
  738. ** Stop calling Theme.AI after a while so a different song doesnt start playing
  739. */
  740. Call_Back();
  741. // if (frame <1000 ){
  742. // Theme.AI();
  743. // }else{
  744. // Sound_Callback();
  745. // }
  746. /*
  747. ** Kill any spare time before blitting the hid page forward.
  748. */
  749. while (TickCount - time < frame *speed && !Keyboard->Check()) {}
  750. /*
  751. ** Blit all but the top and bottom of the hid page. This is beacuse the text print doesn't
  752. ** clip vertically and looks ugly when it suddenly appears and disappears.
  753. */
  754. #ifndef WIN32
  755. Wait_Vert_Blank(VertBlank);
  756. //Vsync();
  757. #endif //WIN32
  758. HidPage.Blit(SeenBuff, 0, 8*RESFACTOR, 0, 8*RESFACTOR, SeenBuff.Get_Width(), SeenBuff.Get_Height() - 16*RESFACTOR, false);
  759. /*
  760. ** Try and prevent Win95 from swapping out pictures we havnt used yet.
  761. */
  762. #ifdef WIN32
  763. if (frame && 3 == 3){
  764. for (i=slide_number+1 ; i<NUM_SLIDES ; i++){
  765. if ( !SlideBuffers[i]->Get_IsDirectDraw() ){
  766. Force_VM_Page_In ((void*)SlideBuffers[i]->Get_Offset(), SeenBuff.Get_Width() * SeenBuff.Get_Height() );
  767. }
  768. }
  769. }
  770. #endif //WIN32
  771. /*
  772. ** If user hits escape then break.
  773. */
  774. key = KN_NONE;
  775. if (Keyboard->Check()){
  776. key = Keyboard->Get();
  777. if (key == KN_ESC){
  778. break;
  779. }
  780. #if (0)
  781. if (key == KN_Z){
  782. speed--;
  783. if (speed <1 ) speed=1;
  784. time = TickCount;
  785. frame = 0;
  786. }
  787. if (key == KN_X){
  788. speed++;
  789. time = TickCount;
  790. frame = 0;
  791. }
  792. #endif //(0)
  793. }
  794. }
  795. if (key == KN_ESC){
  796. Theme.Fade_Out();
  797. BlackPalette.Set(TIMER_SECOND*2, Call_Back);
  798. }else{
  799. /*
  800. ** Wait for the picture to fade down
  801. */
  802. while (picture_frame <= FADE_DELAY+FRAME_DELAY){
  803. if (picture_frame < FRAME_DELAY && picture_frame > 10+FADE_DELAY){
  804. picture_frame = FRAME_DELAY;
  805. }
  806. frame++;
  807. picture_frame++;
  808. Slide_Show (slide_number, picture_frame);
  809. Call_Back();
  810. // Sound_Callback(); //Theme.AI();
  811. /*
  812. ** Kill any spare time
  813. */
  814. while (TickCount - time < frame *speed && !Keyboard->Check()) {}
  815. }
  816. }
  817. /*
  818. ** Tidy up.
  819. */
  820. //SetPriorityClass (GetCurrentProcess() , process_priority);
  821. SeenBuff.Clear();
  822. Show_Mouse();
  823. GadgetClass::Set_Color_Scheme(&ColorRemaps[PCOLOR_DIALOG_BLUE]);
  824. Theme.Stop();
  825. Options.Set_Score_Volume(oldvolume, false);
  826. for (index = 0 ; index < NUM_SLIDES ; index++){
  827. delete SlideBuffers[index];
  828. }
  829. delete BackgroundPage;
  830. delete [] credits;
  831. EgoList.Clear();
  832. }
  833. #endif