CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

EGOS.CPP (31980B)


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