EGOS.CPP 31 KB

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