CnC_Remastered_Collection

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

MAPSEL.CPP (53178B)


      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:   F:\projects\c&c\vcs\code\mapsel.cpv   1.8   16 Oct 1995 16:49:48   JOE_BOSTIC  $ */
     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                                            *
     22  *                                                                                             *
     23  *                    File Name : MAPSEL.CPP                                                   *
     24  *                                                                                             *
     25  *                   Programmer : Barry W. Green                                               *
     26  *                                                                                             *
     27  *                   Start Date : April 17, 1995                                               *
     28  *                                                                                             *
     29  *                  Last Update : April 27, 1995   [BWG]                                       *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  *   Bit_It_In -- Pixel fade graphic copy.                                                     *
     34  *   Map_Selection -- Starts the whole process of selecting next map to go to                  *
     35  *   Print_Statistics -- Prints statistics on country selected                                 *
     36  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     37 
     38 #include	"function.h"
     39 #include	"textblit.h"
     40 
     41 #ifndef DEMO
     42 
     43 void Map_Selection(void);
     44 void Fading_Byte_Blit(int srcx, int srcy, int destx, int desty, int w, int h, GraphicBufferClass *src, GraphicBufferClass *dest);
     45 void Print_Statistics(int country, int xpos, int ypos);
     46 void Cycle_Call_Back_Delay(int time, unsigned char *pal);
     47 int LowMedHiStr(int percentage);
     48 extern int ControlQ;
     49 
     50 unsigned char CountryRemap[256];
     51 #ifdef OBSOLETE
     52 unsigned char const High16Remap[256]={
     53  0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
     54  0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
     55  0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
     56  0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
     57  0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
     58  0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
     59  0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
     60  0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
     61  0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
     62  0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
     63  0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
     64  0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
     65  0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
     66  0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
     67  0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
     68  0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF
     69 };
     70 #endif
     71 
     72 #define SDE	SCEN_DIR_EAST
     73 #define SDW	SCEN_DIR_WEST
     74 #define SDN SCEN_DIR_NONE
     75 #define SVA SCEN_VAR_A
     76 #define SVB SCEN_VAR_B
     77 #define SVC SCEN_VAR_C
     78 #define SVN SCEN_VAR_NONE
     79 struct countrylist {
     80 	int Choices[2];	// # of map choices this time - 0 = no map selection screen
     81 	int Start[2];
     82 	int ContAnim[2];
     83 	int CountryColor[2][3];
     84 	int CountryShape[2][3];	// shape in COUNTRYE.SHP
     85 	ScenarioDirType CountryDir[2][3];
     86 	ScenarioVarType CountryVariant[2][3];
     87 } const CountryArray[27] = {
     88 // GDI SCENARIO CHOICES
     89 /*  0 */	{0},	  /*E  W*/ /* cont */	/* East colors */ /* West color*/	/* E frame   W frame */
     90 /*  1 */	{{1,1}, { 0, 0}, {  3,  3},{{0x95,   0,   0},{0x95,   0,   0}}, {{17, 0, 0},{17, 0, 0}}, {{SDE,SDN,SDN},{SDN,SDN,SDN}},{{SVA,SVN,SVN},{SVN,SVN,SVN}}},
     91 /*  2 */	{{1,1}, {16,16}, { 19, 19},{{0x80,   0,   0},{0x80,   0,   0}}, {{ 0, 0, 0},{ 0, 0, 0}}, {{SDE,SDN,SDN},{SDN,SDN,SDN}},{{SVA,SVN,SVN},{SVN,SVN,SVN}}},
     92 /*  3 */	{{3,3}, {32,32}, { 35, 35},{{0x81,0x82,0x83},{0x81,0x82,0x83}}, {{ 3, 3, 1},{ 3, 3, 1}}, {{SDW,SDW,SDE},{SDN,SDN,SDN}},{{SVA,SVB,SVA},{SVN,SVN,SVN}}},
     93 /*  4 */	{{2,2}, {48,64}, { 51, 67},{{0x84,0x85,   0},{0x86,0x87,   0}}, {{ 4, 4, 0},{ 2, 2, 0}}, {{SDE,SDE,SDN},{SDW,SDW,SDN}},{{SVA,SVA,SVN},{SVA,SVB,SVN}}},
     94 /*  5 */	{{2,2}, {99,99}, {102,102},{{0x88,0x89,   0},{0x88,0x89,   0}}, {{ 7, 7, 0},{ 7, 7, 0}}, {{SDE,SDE,SDN},{SDE,SDE,SDN}},{{SVA,SVA,SVN},{SVA,SVA,SVN}}},
     95 /*  6 */	{{2,2}, {80,83}, { 86, 86},{{0x88,0x89,   0},{0x88,0x89,   0}}, {{ 7, 7, 0},{ 7, 7, 0}}, {{SDE,SDE,SDN},{SDE,SDE,SDN}},{{SVA,SVA,SVN},{SVA,SVA,SVN}}},
     96 /*  7 */	{{2,2}, {115,0}, {118,  0},{{0x8B,0x8A,   0},{0x8B,0x8A,   0}}, {{ 6, 8, 0},{ 6, 8, 0}}, {{SDE,SDE,SDN},{SDN,SDN,SDN}},{{SVA,SVB,SVN},{SVN,SVN,SVN}}},
     97 /*  8 */	{{1,1}, {131,0}, {134,  0},{{0x8C,   0,   0},{0x8C,   0,   0}}, {{ 9, 0, 0},{ 9, 0, 0}}, {{SDE,SDN,SDN},{SDN,SDN,SDN}},{{SVA,SVN,SVN},{SVN,SVN,SVN}}},
     98 /*  9 */	{{2,1}, {147,0}, {150,  0},{{0x8D,0x8E,   0},{   0,   0,   0}}, {{10,13, 0},{ 0, 0, 0}}, {{SDE,SDE,SDN},{SDN,SDN,SDN}},{{SVA,SVB,SVN},{SVN,SVN,SVN}}},
     99 /* 10 */	{{1,1}, {163,0}, {166,  0},{{0x8F,   0,   0},{   0,   0,   0}}, {{16, 0, 0},{ 0, 0, 0}}, {{SDE,SDN,SDN},{SDN,SDN,SDN}},{{SVA,SVN,SVN},{SVN,SVN,SVN}}},
    100 /* 11 */	{{2,1}, {179,0}, {182,  0},{{0x90,0x91,   0},{   0,   0,   0}}, {{14,15, 0},{ 0, 0, 0}}, {{SDE,SDE,SDN},{SDN,SDN,SDN}},{{SVA,SVB,SVN},{SVN,SVN,SVN}}},
    101 /* 12 */	{{2,1}, {195,0}, {198,  0},{{0x92,0x93,   0},{   0,   0,   0}}, {{12,12, 0},{ 0, 0, 0}}, {{SDE,SDE,SDN},{SDN,SDN,SDN}},{{SVA,SVB,SVN},{SVN,SVN,SVN}}},
    102 /* 13 */	{{1,1}, {211,0}, {214,  0},{{0x93,   0,   0},{   0,   0,   0}}, {{12, 0, 0},{ 0, 0, 0}}, {{SDE,SDN,SDN},{SDN,SDN,SDN}},{{SVA,SVN,SVN},{SVN,SVN,SVN}}},
    103 /* 14 */	{{3,1}, {  0,0}, {  3,  0},{{0x81,0x82,0x83},{   0,   0,   0}}, {{ 0, 0, 0},{ 0, 0, 0}}, {{SDE,SDE,SDE},{SDN,SDN,SDN}},{{SVA,SVB,SVC},{SVN,SVN,SVN}}},
    104 
    105 // NOD SCENARIO CHOICES
    106 //	  		choices   E/W start continue   East colors    West colors  E shape    W shape	  direction								variant
    107 /*  1 */	{ {2,1}, {  0,0},   {  3,  0},{{0x80,0x81,0x00},{0,0,0}}, {{ 4, 4, 0},{0,0,0}}, {{SDE,SDE,SDN},{SDN,SDN,SDN}},{{SVA,SVB,SVN},{SVN,SVN,SVN}} },
    108 /*  2 */	{ {2,1}, { 16,0},   { 19,  0},{{0x82,0x83,0x00},{0,0,0}}, {{ 6, 6, 0},{0,0,0}}, {{SDE,SDE,SDN},{SDN,SDN,SDN}},{{SVA,SVB,SVN},{SVN,SVN,SVN}} },
    109 /*  3 */	{ {2,1}, { 32,0},   { 35,  0},{{0x84,0x85,0x00},{0,0,0}}, {{ 5, 5, 0},{0,0,0}}, {{SDE,SDE,SDN},{SDN,SDN,SDN}},{{SVA,SVB,SVN},{SVN,SVN,SVN}} },
    110 /*  4 */	{ {1,1}, { 48,0},   { 51,  0},{{0x86,0x00,0x00},{0,0,0}}, {{ 0, 0, 0},{0,0,0}}, {{SDE,SDN,SDN},{SDN,SDN,SDN}},{{SVA,SVN,SVN},{SVN,SVN,SVN}} },
    111 /*  5 */	{ {3,1}, { 64,0},   { 67,  0},{{0x87,0x88,0x89},{0,0,0}}, {{ 1, 2, 3},{0,0,0}}, {{SDE,SDE,SDE},{SDN,SDN,SDN}},{{SVA,SVB,SVC},{SVN,SVN,SVN}} },
    112 /*  6 */	{ {3,1}, { 80,0},   { 83,  0},{{0x8A,0x8B,0x8C},{0,0,0}}, {{ 9, 7, 8},{0,0,0}}, {{SDE,SDE,SDE},{SDN,SDN,SDN}},{{SVA,SVB,SVC},{SVN,SVN,SVN}} },
    113 /*  7 */	{ {2,1}, { 96,0},   { 99,  0},{{0x8D,0x8E,0x00},{0,0,0}}, {{10,10, 0},{0,0,0}}, {{SDE,SDE,SDN},{SDN,SDN,SDN}},{{SVA,SVB,SVN},{SVN,SVN,SVN}} },
    114 /*  8 */	{ {1,1}, {112,0},   {115,  0},{{0xA0,0x00,0x00},{0,0,0}}, {{ 4, 4, 0},{0,0,0}}, {{SDE,SDN,SDN},{SDN,SDN,SDN}},{{SVA,SVN,SVN},{SVN,SVN,SVN}} },
    115 /*  9 */	{ {2,1}, {128,0},   {131,  0},{{0x8F,0x90,0x00},{0,0,0}}, {{11,15, 0},{0,0,0}}, {{SDE,SDE,SDN},{SDN,SDN,SDN}},{{SVA,SVB,SVN},{SVN,SVN,SVN}} },
    116 /* 10 */	{ {2,1}, {144,0},   {147,  0},{{0x91,0x92,0x00},{0,0,0}}, {{12,16, 0},{0,0,0}}, {{SDE,SDE,SDN},{SDN,SDN,SDN}},{{SVA,SVB,SVN},{SVN,SVN,SVN}} },
    117 /* 11 */	{ {1,1}, {160,0},   {163,  0},{{0x93,0x00,0x00},{0,0,0}}, {{13, 0, 0},{0,0,0}}, {{SDE,SDN,SDN},{SDN,SDN,SDN}},{{SVA,SVN,SVN},{SVN,SVN,SVN}} },
    118 /* 12 */	{ {3,1}, {  0,0},   {  3,  0},{{0x81,0x82,0x83},{0,0,0}}, {{14, 0, 0},{0,0,0}}, {{SDE,SDE,SDE},{SDN,SDN,SDN}},{{SVA,SVB,SVC},{SVN,SVN,SVN}} }
    119 };
    120 
    121 struct gdistats {
    122 	int nameindex;
    123 	int pop;
    124 	int area;
    125 	int capital;
    126 	int govt;
    127 	int gdp;
    128 	int conflict;
    129 	int  military;
    130 } const GDIStats[]={
    131 // Name   Pop        Area  	  Capital	Government     GDP	    Conflict   Military
    132 	{ 0,TXT_MAP_P01, TXT_MAP_A00,TXT_MAP_C00, 0,       TXT_MAP_GDP00, TXT_MAP_PC00,	0},
    133 	{ 1,TXT_MAP_P02, TXT_MAP_A01,TXT_MAP_C01, 1,			TXT_MAP_GDP01, TXT_MAP_PC01,	3},
    134 	{ 1,TXT_MAP_P02, TXT_MAP_A01,TXT_MAP_C01, 1,			TXT_MAP_GDP01, TXT_MAP_PC02,	3},
    135 	{ 2,TXT_MAP_P03, TXT_MAP_A02,TXT_MAP_C02, 0,       TXT_MAP_GDP00, TXT_MAP_PC03,	1},
    136 	{ 3,TXT_MAP_P04, TXT_MAP_A03,TXT_MAP_C03, 3,			TXT_MAP_GDP02, TXT_MAP_PC04,	1},
    137 	{ 3,TXT_MAP_P04, TXT_MAP_A03,TXT_MAP_C03, 3,			TXT_MAP_GDP02, TXT_MAP_PC04,	1},
    138 	{ 4,TXT_MAP_P05, TXT_MAP_A04,TXT_MAP_C04, 2,			TXT_MAP_GDP03, TXT_MAP_PC05,	5},
    139 	{ 4,TXT_MAP_P05, TXT_MAP_A04,TXT_MAP_C04, 2,			TXT_MAP_GDP03, TXT_MAP_PC06,	5},
    140 	{ 5,TXT_MAP_P06, TXT_MAP_A05,TXT_MAP_C05, 0,			TXT_MAP_GDP04, TXT_MAP_PC07,	2},
    141 	{ 5,TXT_MAP_P06, TXT_MAP_A05,TXT_MAP_C05, 0,			TXT_MAP_GDP04, TXT_MAP_PC07,	2},
    142 	{ 6,TXT_MAP_P07, TXT_MAP_A06,TXT_MAP_C06, 0,			TXT_MAP_GDP00, TXT_MAP_PC08,	0},
    143 	{ 7,TXT_MAP_P08, TXT_MAP_A07,TXT_MAP_C07, 4,			TXT_MAP_GDP05, TXT_MAP_PC00,	2},
    144 	{ 8,TXT_MAP_P09, TXT_MAP_A08,TXT_MAP_C08, 4,			TXT_MAP_GDP06, TXT_MAP_PC10,	2},
    145 	{ 9,TXT_MAP_P10, TXT_MAP_A09,TXT_MAP_C09, 0,			TXT_MAP_GDP07, TXT_MAP_PC11,	1},
    146 	{10,TXT_MAP_P11, TXT_MAP_A10,TXT_MAP_C10, 0,			TXT_MAP_GDP08, TXT_MAP_PC12,	2},
    147 	{11,TXT_MAP_P12, TXT_MAP_A11,TXT_MAP_C11, 5,			TXT_MAP_GDP09, TXT_MAP_PC13,	3},
    148 	{12,TXT_MAP_P13, TXT_MAP_A12,TXT_MAP_C12, 6,			TXT_MAP_GDP10, TXT_MAP_PC14,	2},
    149 	{13,TXT_MAP_P14, TXT_MAP_A13,TXT_MAP_C13, 0,			TXT_MAP_GDP11, TXT_MAP_PC15,	2},
    150 	{14,TXT_MAP_P15, TXT_MAP_A14,TXT_MAP_C14, 0,			TXT_MAP_GDP12, TXT_MAP_PC16,	3},
    151 	{14,TXT_MAP_P15, TXT_MAP_A14,TXT_MAP_C14, 0,			TXT_MAP_GDP12, TXT_MAP_PC17,	3},
    152 	{15,TXT_MAP_P16, TXT_MAP_A15,TXT_MAP_C15, 7,			TXT_MAP_GDP13, TXT_MAP_PC18,	4},
    153 // Hack in a slot for Estonia
    154 	{34,TXT_MAP_P17, TXT_MAP_A16,TXT_MAP_C16, 0,			TXT_MAP_GDP00, TXT_MAP_PC19,	0}
    155 };
    156 
    157 struct nodstats {
    158 	int nameindex;
    159 	int pop;
    160 	int expendable;
    161 	int capital;
    162 	int govt;
    163 	int corruptible;
    164 	int worth;
    165 	int conflict;
    166 	int military;
    167 	int probability;
    168 } const NodStats[]={
    169 // Name   Pop     Expendable   Capital	Government Corruptible   Worth	    Conflict   Military  Probability
    170 	{16, TXT_MAP_P18,  38,     TXT_MAP_C17,   8,     86,        TXT_MAP_GDP14, TXT_MAP_PC20, 0,       23},
    171 	{17, TXT_MAP_P19,	 75,		TXT_MAP_C18,   0,		 18,			TXT_MAP_GDP15, TXT_MAP_PC21, 1,			82},
    172 	{17, TXT_MAP_P19,	 75,		TXT_MAP_C18,   0,		 18,			TXT_MAP_GDP15, TXT_MAP_PC22, 1,			82},
    173 	{18, TXT_MAP_P20,	 50,		TXT_MAP_C19,   9,		 52,			TXT_MAP_GDP16, TXT_MAP_PC23, 0,			72},
    174 	{18, TXT_MAP_P20,	 50,		TXT_MAP_C19,   9,		 52,			TXT_MAP_GDP16, TXT_MAP_PC24, 0,			72},
    175 	{19, TXT_MAP_P21,	 80,		TXT_MAP_C20,   0,		 85,			TXT_MAP_GDP17, TXT_MAP_PC25, 2,			35},
    176 	{19, TXT_MAP_P21,	 80,		TXT_MAP_C20,   0,		 85,			TXT_MAP_GDP17, TXT_MAP_PC26, 2,			35},
    177 	{20, TXT_MAP_P22,	 50,		TXT_MAP_C21,  10,		 48,			TXT_MAP_GDP17, TXT_MAP_PC27, 2,			24},
    178 	{21, TXT_MAP_P23,	 33,		TXT_MAP_C22,   0,		 28,			TXT_MAP_GDP18, TXT_MAP_PC28, 3,			67},
    179 	{22, TXT_MAP_P24,	 75,		TXT_MAP_C23,   6,		 17,			TXT_MAP_GDP19, TXT_MAP_PC29, 2,			80},
    180 	{23, TXT_MAP_P25,	 60,		TXT_MAP_C24,   7,		 93,			TXT_MAP_GDP20, TXT_MAP_PC30, 3,			50},
    181 	{24, TXT_MAP_P26,	  5,		TXT_MAP_C25,   0,		 84,			TXT_MAP_GDP21, TXT_MAP_PC31, 2,			22},
    182 	{25, TXT_MAP_P27,	 55,		TXT_MAP_C26,   0,		 48,			TXT_MAP_GDP22, TXT_MAP_PC32, 3,			62},
    183 	{26, TXT_MAP_P28,	 65,		TXT_MAP_C27,   0,		 41,			TXT_MAP_GDP23, TXT_MAP_PC33, 2,			49},
    184 	{27, TXT_MAP_P29,	 72,		TXT_MAP_C28,   0,		 74,			TXT_MAP_GDP24, TXT_MAP_PC34, 3,			54},
    185 	{27, TXT_MAP_P29,	 72,		TXT_MAP_C28,   0,		 74,			TXT_MAP_GDP24, TXT_MAP_PC35, 3,			54},
    186 	{17, TXT_MAP_P30,	 45,		TXT_MAP_C29,   6,		  3,			TXT_MAP_GDP15, TXT_MAP_PC36, 3,		  100},
    187 	{28, TXT_MAP_P31,	 45,		TXT_MAP_C30,   0,		 63,			TXT_MAP_GDP25, TXT_MAP_PC37, 2,			66},
    188 	{29, TXT_MAP_P32,	 55,		TXT_MAP_C31,   0,		 27,			TXT_MAP_GDP26, TXT_MAP_PC38, 2,			68},
    189 	{30, TXT_MAP_P33,	  5,		TXT_MAP_C32,   0,		 65,			TXT_MAP_GDP27, TXT_MAP_PC39, 4,			74},
    190 	{31, TXT_MAP_P34,	 65,		TXT_MAP_C33,   0,		 52,			TXT_MAP_GDP19, TXT_MAP_PC40, 2,			84},
    191 	{32, TXT_MAP_P35,	  2,		TXT_MAP_C34,  11,		 12,			TXT_MAP_GDP28, TXT_MAP_PC41, 2,			92},
    192 	{33, TXT_MAP_P36,	 10,		TXT_MAP_C35,   0,		  8,			TXT_MAP_GDP29, TXT_MAP_PC42, 1,		  100}
    193 };
    194 
    195 
    196 
    197 /***********************************************************************************************
    198  * Map_Selection -- Starts the whole process of selecting next map to go to                    *
    199  *                                                                                             *
    200  *                                                                                             *
    201  * INPUT:                                                                                      *
    202  *                                                                                             *
    203  * OUTPUT:  none                                                                               *
    204  *                                                                                             *
    205  * WARNINGS:   none                                                                            *
    206  *                                                                                             *
    207  * HISTORY:                                                                                    *
    208  *   04/17/1995 BWG : Created.                                                                 *
    209  *=============================================================================================*/
    210 void Map_Selection(void)
    211 {
    212 	void *anim, *progress, *oldfont, *greyearth, *greyearth2;
    213 	unsigned char localpalette[768];
    214 	int scenario, lastscenario;
    215 	int house = PlayerPtr->Class->House;
    216 	int attackxcoord = 0;
    217 
    218 	static int const _countryx[]={195,217,115,167,
    219 											244, 97,130,142,
    220 											171,170,139,158,
    221 											180,207,177,213,
    222 											201,198,
    223 											/* Nod countries */
    224 											 69, 82,105,119,
    225 											184,149,187,130,
    226 											153,124,162,144,
    227 											145,164,166,200,
    228 											201};
    229 	static int const _countryy[]={ 35, 57, 82, 75,
    230 											 93,111,108, 91,
    231 											100,111,120,136,
    232 											136,117,158,143,
    233 											167,21,
    234 											/* Nod countries */
    235 											 45, 80, 75, 76,
    236 											 31, 64, 69, 89,
    237 											 88,106,115,139,
    238 											168,164,183,123,
    239 											154};
    240 	//static char const _greenpal[]={0,1,0x42,3,0x43,5,0x44,7,0x44,9,10,1,12,13,0x41,15};
    241 	static char const _greenpal[]={0,0x41,0x42,0x43,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44};
    242 	static char const _othergreenpal[]={0,0x21,0x22,0x23,0x24,0x25,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26};
    243 	static char const _regpal[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
    244 	GraphicBufferClass backpage(20*6,8);
    245 
    246 	unsigned char *grey2palette    = new unsigned char[768];
    247 	unsigned char *progresspalette = new unsigned char[768];
    248 
    249 
    250 	Keyboard::Clear();
    251 	oldfont = Set_Font(ScoreFontPtr);
    252 	Set_Font_Palette(_regpal);
    253 	Set_Palette(BlackPalette);
    254 
    255 	scenario = Scenario + ((house == HOUSE_GOOD) ? 0 : 14);
    256 	if (house == HOUSE_GOOD) {
    257 		lastscenario = (Scenario == 14);
    258 		if (Scenario == 15) return;
    259 	} else {
    260 		lastscenario = (Scenario == 12);
    261 		if (Scenario == 13) return;
    262 	}
    263 
    264 	// Check if they're even entitled to map selection this time
    265 	if (CountryArray[scenario].Choices[ScenDir]==0) return;
    266 
    267 	Theme.Queue_Song(THEME_MAP1);
    268 	PseudoSeenBuff = new GraphicBufferClass(320,200,(void*)NULL);
    269 
    270 	/*
    271 	** Extra graphic buffer to draw text into
    272 	*/
    273 	TextPrintBuffer = new GraphicBufferClass(SeenBuff.Get_Width(), SeenBuff.Get_Height(), (void*)NULL);
    274 	TextPrintBuffer->Clear();
    275 	BlitList.Clear();
    276 
    277 	/*
    278 	** Now start the process where we fade the gray earth in.
    279 	*/
    280 	greyearth  = Open_Animation("GREYERTH.WSA", NULL, 0, (WSAOpenType)(WSA_OPEN_FROM_MEM | WSA_OPEN_TO_PAGE), localpalette);
    281 	greyearth2 = Open_Animation("E-BWTOCL.WSA", NULL, 0, (WSAOpenType)(WSA_OPEN_FROM_MEM | WSA_OPEN_TO_PAGE), grey2palette);
    282 
    283 	/*
    284 	** Load the spinning-globe anim
    285 	*/
    286 	if (house == HOUSE_GOOD) {
    287 		//anim     = Open_Animation("EARTH_E.WSA", NULL,0,(WSAOpenType)(WSA_OPEN_FROM_MEM | WSA_OPEN_TO_PAGE),Palette);
    288 		anim     = Open_Animation("HEARTH_E.WSA", NULL,0,(WSAOpenType)(WSA_OPEN_FROM_MEM | WSA_OPEN_TO_PAGE),Palette);
    289 		//progress = Open_Animation(lastscenario ? "BOSNIA.WSA" : "EUROPE.WSA",NULL,0,(WSAOpenType)(WSA_OPEN_FROM_MEM | WSA_OPEN_TO_PAGE),progresspalette);
    290 		progress = Open_Animation(lastscenario ? "HBOSNIA.WSA" : "EUROPE.WSA",NULL,0,(WSAOpenType)(WSA_OPEN_FROM_MEM | WSA_OPEN_TO_PAGE),progresspalette);
    291 	} else {
    292 		//anim     = Open_Animation("EARTH_A.WSA", NULL,0,(WSAOpenType)(WSA_OPEN_FROM_MEM | WSA_OPEN_TO_PAGE),Palette);
    293 		anim     = Open_Animation("HEARTH_A.WSA", NULL,0,(WSAOpenType)(WSA_OPEN_FROM_MEM | WSA_OPEN_TO_PAGE),Palette);
    294 		//progress = Open_Animation(lastscenario ? "S_AFRICA.WSA" : "AFRICA.WSA",NULL,0,(WSAOpenType)(WSA_OPEN_FROM_MEM | WSA_OPEN_TO_PAGE),progresspalette);
    295 		progress = Open_Animation(lastscenario ? "HSAFRICA.WSA" : "AFRICA.WSA",NULL,0,(WSAOpenType)(WSA_OPEN_FROM_MEM | WSA_OPEN_TO_PAGE),progresspalette);
    296 	}
    297 
    298 	void const * appear1 = MixFileClass::Retrieve("APPEAR1.AUD");
    299 	void const * sfx4 = MixFileClass::Retrieve("SFX4.AUD");
    300 	void const * text2 = MixFileClass::Retrieve("TEXT2.AUD");
    301 	void const * target1 = MixFileClass::Retrieve("TARGET1.AUD");
    302 	void const * target2 = MixFileClass::Retrieve("TARGET2.AUD");
    303 //	void const * target3 = MixFileClass::Retrieve("TARGET3.AUD");
    304 	void const * newtarg1  = MixFileClass::Retrieve("NEWTARG1.AUD");
    305 	void const * beepy2  = MixFileClass::Retrieve("BEEPY2.AUD");
    306 	void const * beepy3  = MixFileClass::Retrieve("BEEPY3.AUD");
    307 	void const * beepy6  = MixFileClass::Retrieve("BEEPY6.AUD");
    308 	void const * world2  = MixFileClass::Retrieve("WORLD2.AUD");
    309 	void const * country1 = MixFileClass::Retrieve("COUNTRY1.AUD");
    310 	void const * scold1 = MixFileClass::Retrieve("SCOLD1.AUD");
    311 
    312 	SysMemPage.Clear();
    313 	PseudoSeenBuff->Clear();
    314 	WWMouse->Erase_Mouse(&HidPage, TRUE);
    315 	HiddenPage.Clear();
    316 	InterpolationPaletteChanged = TRUE;
    317 	InterpolationPalette = Palette;
    318 	Increase_Palette_Luminance(InterpolationPalette , 30,30,30,63);
    319 	Read_Interpolation_Palette("MAP1.PAL");
    320 //	SeenBuff.Blit(HidPage);
    321 	Animate_Frame(greyearth, SysMemPage, 0);
    322 
    323 	Bit_It_In_Scale(0, 0, 320, 200, &SysMemPage, PseudoSeenBuff , &SeenBuff);
    324 	PseudoSeenBuff->Put_Pixel(237,92,TBLACK);
    325 	PseudoSeenBuff->Put_Pixel(237,93,TBLACK);
    326 	Interpolate_2X_Scale(PseudoSeenBuff, &SeenBuff,"MAP1.PAL");
    327 
    328 	InterpolationPaletteChanged = TRUE;
    329 	InterpolationPalette = localpalette;
    330 	Increase_Palette_Luminance(InterpolationPalette , 30,30,30,63);
    331 	Read_Interpolation_Palette("MAP_LOCL.PAL");
    332 	Play_Sample(appear1, 255, Options.Normalize_Sound(110));
    333 	Fade_Palette_To(localpalette, FADE_PALETTE_MEDIUM, Call_Back);
    334 	int i;
    335 	for (i = 1; i < Get_Animation_Frame_Count(greyearth); i++) {
    336 		Call_Back_Delay(4);
    337 		Animate_Frame(greyearth, *PseudoSeenBuff, i);
    338 	}
    339 	Close_Animation(greyearth);
    340 	Write_Interpolation_Palette("MAP_LOCL.PAL");
    341 
    342 	Call_Back_Delay(4);
    343 	SysMemPage.Clear();
    344 	Animate_Frame(greyearth2, SysMemPage, 0);
    345 	InterpolationPaletteChanged = TRUE;
    346 	InterpolationPalette = grey2palette;
    347 	Increase_Palette_Luminance(InterpolationPalette , 30,30,30,63);
    348 	Read_Interpolation_Palette("MAP_GRY2.PAL");
    349 	Wait_Vert_Blank();
    350 	Set_Palette(grey2palette);
    351 	SysMemPage.Blit(*PseudoSeenBuff);
    352 	Call_Back_Delay(4);
    353 	for (i = 1; i < Get_Animation_Frame_Count(greyearth2); i++) {
    354 		Animate_Frame(greyearth2,*PseudoSeenBuff,i);
    355 		Call_Back_Delay(4);
    356 	}
    357 	Close_Animation(greyearth2);
    358 	Write_Interpolation_Palette("MAP_GRY2.PAL");
    359 
    360 	/*
    361 	** Copy the first frame up to the seenpage (while screen is black)
    362 	*/
    363 	SysMemPage.Clear();
    364 	Animate_Frame(anim, SysMemPage, 1);//, 0,0, (WSAType)0,0,0);
    365 	SysMemPage.Blit(*PseudoSeenBuff);
    366 	Interpolate_2X_Scale(PseudoSeenBuff, &SeenBuff ,NULL);
    367 
    368 	Stop_Speaking();
    369 
    370 	while (CountDownTimer.Time() || Is_Speaking()) {
    371 		Call_Back();
    372 //		if (Keyboard::Check()) CountDownTimer.Set(0);
    373 	}
    374 
    375 //	Keyboard::Clear();
    376 
    377 	/*
    378 	** now make the grid appear
    379 	*/
    380 	SysMemPage.Blit(*PseudoSeenBuff);
    381 	Interpolate_2X_Scale(PseudoSeenBuff, &SeenBuff, NULL);
    382 	Play_Sample(sfx4, 255, Options.Normalize_Sound(130));
    383 	Play_Sample(text2, 255, Options.Normalize_Sound(90));
    384 
    385 
    386 	int frame = 1;
    387 
    388 	while (frame < Get_Animation_Frame_Count(anim)) {
    389 		if (frame == 16 || frame == 33 || frame == 44 || frame == 70 || frame == 73) Play_Sample(text2, 255, Options.Normalize_Sound(90));
    390 		if (frame == 21 || frame == 27) Play_Sample(target1, 255, Options.Normalize_Sound(90));
    391 		if (frame == 45 || frame == 47 || frame == 49) Play_Sample(beepy6, 255, Options.Normalize_Sound(90));
    392 		if (frame == 51) Play_Sample(world2, 255, Options.Normalize_Sound(90));
    393 		if (frame == 70 || frame == 72) Play_Sample(beepy2, 255, Options.Normalize_Sound(90));
    394 		if (frame == 74) Play_Sample(target2, 255, Options.Normalize_Sound(110));
    395 
    396 		switch (frame){
    397 			case 1:
    398 				Alloc_Object(new MultiStagePrintClass(Text_String (TXT_READING_IMAGE_DATA), 0,10,_othergreenpal));
    399 				break;
    400 
    401 			case 16:
    402 				TextPrintBuffer->Fill_Rect (0, 2*10, 2*String_Pixel_Width (Text_String (TXT_READING_IMAGE_DATA)), 2*(10 + 12), BLACK);
    403 				break;
    404 
    405 			case 17:
    406 				TextPrintBuffer->Fill_Rect (0, 2*10, 2*String_Pixel_Width (Text_String (TXT_READING_IMAGE_DATA)), 2*(10 + 12), TBLACK);
    407 				Alloc_Object(new MultiStagePrintClass("ANALYZING", 0,10,_othergreenpal));
    408 				break;
    409 
    410 			case 33:
    411 				TextPrintBuffer->Fill_Rect (0, 2*10, 2*String_Pixel_Width (Text_String (TXT_ANALYZING)), 2*(10 + 12), BLACK);
    412 				break;
    413 
    414 			case 34:
    415 				TextPrintBuffer->Fill_Rect (0, 2*10, 2*String_Pixel_Width (Text_String (TXT_ANALYZING)), 2*(10 + 12), TBLACK);
    416 				Alloc_Object(new MultiStagePrintClass(Text_String (TXT_ENHANCING_IMAGE_DATA), 0,10,_othergreenpal));
    417 				break;
    418 
    419 			case 44:
    420 				TextPrintBuffer->Fill_Rect (0, 2*10, 2*String_Pixel_Width (Text_String (TXT_ENHANCING_IMAGE_DATA)), 2*(10 + 12), BLACK);
    421 				break;
    422 
    423 			case 45:
    424 				TextPrintBuffer->Fill_Rect (0, 2*10, 2*String_Pixel_Width (Text_String (TXT_ENHANCING_IMAGE_DATA)), 2*(10 + 12), TBLACK);
    425 				Alloc_Object(new MultiStagePrintClass(Text_String(TXT_ISOLATING_OPERATIONAL_THEATER), 0,10,_othergreenpal));
    426 				break;
    427 
    428 			case 70:
    429 				TextPrintBuffer->Fill_Rect (0, 2*10, 2*String_Pixel_Width (Text_String(TXT_ISOLATING_OPERATIONAL_THEATER)), 2*(10 + 12), BLACK);
    430 				break;
    431 
    432 			case 71:
    433 				TextPrintBuffer->Fill_Rect (0, 2*10, 2*String_Pixel_Width (Text_String(TXT_ISOLATING_OPERATIONAL_THEATER)), 2*(10 + 12), TBLACK);
    434 				Alloc_Object(new MultiStagePrintClass(Text_String (TXT_ESTABLISHING_TRADITIONAL_BOUNDARIES), 0,10,_othergreenpal));
    435 				break;
    436 
    437 			case 74:
    438 				Alloc_Object(new MultiStagePrintClass(Text_String (TXT_FOR_VISUAL_REFERENCE), 0,22,_othergreenpal));
    439 				break;
    440 		}
    441 
    442 
    443 		Animate_Frame(anim, *PseudoSeenBuff, frame++);
    444 		Call_Back_Delay(/*Keyboard::Check() ? 0 :*/ 3);
    445 	}
    446 
    447 	TextPrintBuffer->Fill_Rect (0, 2*10, 2*String_Pixel_Width (Text_String (TXT_ESTABLISHING_TRADITIONAL_BOUNDARIES)), 2*(10 + 24), BLACK);
    448 	Call_Back_Delay (1);
    449 	TextPrintBuffer->Fill_Rect (0, 2*10, 2*String_Pixel_Width (Text_String (TXT_ESTABLISHING_TRADITIONAL_BOUNDARIES)), 2*(10 + 24), TBLACK);
    450 	Call_Back_Delay (1);
    451 
    452 	Close_Animation(anim);
    453 
    454 	Keyboard::Clear();
    455 	BlitList.Clear();
    456 
    457 	/*
    458 	** Freeze on the map of Europe or Africa
    459 	*/
    460 
    461 	SysMemPage.Clear();
    462 	Animate_Frame(progress,SysMemPage,0);
    463 	SysMemPage.Blit(*PseudoSeenBuff);
    464 	InterpolationPaletteChanged = TRUE;
    465 	InterpolationPalette = progresspalette;
    466 	Increase_Palette_Luminance(InterpolationPalette , 30,30,30,63);
    467 	Read_Interpolation_Palette("MAP_PROG.PAL");
    468 
    469 	GraphicBufferClass *europe = new GraphicBufferClass(SysMemPage.Get_Width(),SysMemPage.Get_Height(),(GBC_Enum)0);
    470 	SysMemPage.Blit(*europe);
    471 
    472 	/*
    473 	** Now show territories as they existed last scenario
    474 	*/
    475 	int startframe = CountryArray[scenario].Start[ScenDir];
    476 	if (startframe) {
    477 		Animate_Frame(progress,SysMemPage,startframe);
    478 		SysMemPage.Blit(*PseudoSeenBuff);
    479 	}
    480 	Set_Palette(progresspalette);
    481 	Call_Back_Delay(45);
    482 	//Write_Interpolation_Palette("MAP_PROG.PAL");
    483 
    484 	/*
    485 	** Now dissolve in first advance of territories
    486 	*/
    487 	int xcoord = (house == HOUSE_GOOD ? 0 : 204);
    488 	SysMemPage.Blit(backpage, xcoord,1, 0,0, 20*6,8);
    489 	Play_Sample(text2, 255, Options.Normalize_Sound(90));
    490 	if (house == HOUSE_GOOD) {
    491 		Alloc_Object(new ScorePrintClass(TXT_MAP_GDI,0,2,_greenpal));
    492 	} else {
    493 		Alloc_Object(new ScorePrintClass(TXT_MAP_NOD,xcoord,2,_greenpal));
    494 	}
    495 	Call_Back_Delay(60);
    496 
    497 	Play_Sample(country1, 255, Options.Normalize_Sound(90));
    498 	Animate_Frame(progress,SysMemPage,startframe+1);
    499 	Bit_It_In_Scale(0, 0, 320, 200, &SysMemPage, PseudoSeenBuff,&SeenBuff,1,1);
    500 	backpage.Blit(SysMemPage, 0,0, xcoord,1, 20*6,8);
    501 	Call_Back_Delay(85);
    502 
    503 	/*
    504 	** Now dissolve in second advance of territories
    505 	*/
    506 #ifdef FRENCH
    507 	PseudoSeenBuff->Fill_Rect(xcoord,0,xcoord + 6*16 + 10,8,BLACK);
    508 	TextPrintBuffer->Fill_Rect(xcoord*2,0,2*(xcoord + 6*16 + 10),2*8,BLACK);
    509 #else
    510 	PseudoSeenBuff->Fill_Rect(xcoord,0,xcoord + 6*16,8,BLACK);
    511 	TextPrintBuffer->Fill_Rect(2*xcoord,0,2*(xcoord + 6*16),2*8,BLACK);
    512 #endif
    513 	Interpolate_2X_Scale(PseudoSeenBuff, &SeenBuff,NULL);
    514 	SysMemPage.Blit(backpage, xcoord,1, 0,0, 20*6,8);
    515 	if (!lastscenario) {
    516 		Play_Sample(text2, 255, Options.Normalize_Sound(90));
    517 		if (house == HOUSE_GOOD) {
    518 			Alloc_Object(new ScorePrintClass(TXT_MAP_NOD,0,12,_greenpal));
    519 		} else {
    520 			Alloc_Object(new ScorePrintClass(TXT_MAP_GDI,xcoord,12,_greenpal));
    521 		}
    522 		Call_Back_Delay(65);
    523 	}
    524 
    525 	Play_Sample(country1, 255, Options.Normalize_Sound(90));
    526 	Animate_Frame(progress,SysMemPage,startframe+2);
    527 	Bit_It_In_Scale(0, 0, 320, 200, &SysMemPage, PseudoSeenBuff , &SeenBuff,1,1);
    528 	backpage.Blit(SysMemPage, 0,0, xcoord,11, 20*6,8);
    529 	if (!lastscenario) Call_Back_Delay(85);
    530 //	Set_Font(oldfont);
    531 #ifdef FRENCH
    532 	PseudoSeenBuff->Fill_Rect(xcoord,12,xcoord+6*16+10,20,BLACK);
    533 	TextPrintBuffer->Fill_Rect(2*xcoord,2*12,2*(xcoord+6*16+10),2*20,BLACK);
    534 #else
    535 	PseudoSeenBuff->Fill_Rect(xcoord,12,xcoord+6*16,20,BLACK);
    536 	TextPrintBuffer->Fill_Rect(2*xcoord,2*12,2*(xcoord+6*16),2*20,BLACK);
    537 #endif
    538 	Interpolate_2X_Scale(PseudoSeenBuff, &SeenBuff,NULL);
    539 
    540 	startframe = CountryArray[scenario].ContAnim[ScenDir];
    541 
    542 	/*
    543 	** Now print the text over the page
    544 	*/
    545 	Play_Sample(text2, 255, Options.Normalize_Sound(90));
    546 	Alloc_Object(new ScorePrintClass(TXT_MAP_LOCATE,0,160,_greenpal));
    547 	Call_Back_Delay(20);
    548 	Alloc_Object(new ScorePrintClass(TXT_MAP_NEXT_MISSION,     0,170,_greenpal));
    549 #if (GERMAN | FRENCH)
    550 	Call_Back_Delay(20);
    551 	Alloc_Object(new ScorePrintClass(TXT_MAP_NEXT_MISS2,       0,180,_greenpal));
    552 #endif
    553 	Call_Back_Delay(50);
    554 
    555 	/*
    556 	** If we're on the last scenario, erase that text before doing the crosshairs
    557 	*/
    558 	if (lastscenario) {
    559 #if (GERMAN | FRENCH)
    560 		SysMemPage.Fill_Rect(0,160, 20*6,186, TBLACK);
    561 		PseudoSeenBuff->Fill_Rect(0,160, 20*6,186, TBLACK);
    562 		TextPrintBuffer->Fill_Rect(0,2*160, 2*20*6,2*186, BLACK);
    563 		SeenBuff.Fill_Rect(0,2*160, 2*20*6,2*186, TBLACK);
    564 		HidPage.Fill_Rect(0,2*160, 2*20*6,2*186, TBLACK);
    565 #else
    566 		SysMemPage.Fill_Rect(0,160, 20*6,176, TBLACK);
    567 		PseudoSeenBuff->Fill_Rect(0,160, 20*6,176, TBLACK);
    568 		TextPrintBuffer->Fill_Rect(0,2*160, 2*20*6,2*176, BLACK);
    569 		SeenBuff.Fill_Rect(0,2*160, 2*20*6,2*176, TBLACK);
    570 		HidPage.Fill_Rect(0,2*160, 2*20*6,2*176, TBLACK);
    571 #endif
    572 		BlitList.Clear();
    573 		Bit_It_In_Scale(0, 0, 320, 200, &SysMemPage, PseudoSeenBuff , &SeenBuff);
    574 	}
    575 
    576 	/*
    577 	** Fix up the palette that seems different for the last scenario
    578 	*/
    579 	if (lastscenario){
    580 		InterpolationPaletteChanged = TRUE;
    581 		InterpolationPalette = CurrentPalette;
    582 		if (house == HOUSE_GOOD){
    583 			Read_Interpolation_Palette("LASTSCNG.PAL");
    584 			Interpolate_2X_Scale(PseudoSeenBuff, &SeenBuff, "LASTSCNG.PAL");
    585 		}else{
    586 			Read_Interpolation_Palette("LASTSCNB.PAL");
    587 			Interpolate_2X_Scale(PseudoSeenBuff, &SeenBuff, "LASTSCNB.PAL");
    588 		}
    589 	}
    590 
    591 
    592 	int q = 0;
    593 	for (frame = 0; frame < ((lastscenario) ? Get_Animation_Frame_Count(progress)-4 : 13); frame++) {
    594 		if (!frame) Play_Sample(beepy3, 255, Options.Normalize_Sound(90));
    595 		if (frame == 2) Play_Sample(beepy3, 255, Options.Normalize_Sound(90));
    596 		if (frame == 6) Play_Sample(newtarg1, 255, Options.Normalize_Sound(90));
    597 
    598 
    599 		if (lastscenario){
    600 			switch ( frame ){
    601 
    602 				case 23:
    603 					if (house == HOUSE_GOOD){
    604 						Alloc_Object(new MultiStagePrintClass (Text_String (TXT_ENHANCING_IMAGE), 0, 10, _othergreenpal));
    605 					}else{
    606 #if (FRENCH)
    607 						Alloc_Object(new MultiStagePrintClass (Text_String (TXT_ENHANCING_IMAGE), 180, 10, _othergreenpal));
    608 #else
    609 						Alloc_Object(new MultiStagePrintClass (Text_String (TXT_ENHANCING_IMAGE), 210, 10, _othergreenpal));
    610 #endif	//(FRENCH)
    611 					}
    612 
    613 
    614 				case 35:
    615 					if (house == HOUSE_GOOD){
    616 						TextPrintBuffer->Fill_Rect (0, 2*10, 2*String_Pixel_Width (Text_String (TXT_ENHANCING_IMAGE)), 2*(10 + 12), BLACK);
    617 					}else{
    618 #if (FRENCH)
    619 						TextPrintBuffer->Fill_Rect (2*180, 2*10, 2*(180+String_Pixel_Width (Text_String (TXT_ENHANCING_IMAGE))), 2*(10 + 12), BLACK);
    620 #else
    621 						TextPrintBuffer->Fill_Rect (2*210, 2*10, 2*(210+String_Pixel_Width (Text_String (TXT_ENHANCING_IMAGE))), 2*(10 + 12), BLACK);
    622 #endif	//(FRENCH)
    623 					}
    624 					break;
    625 
    626 				case 36:
    627 					if (house == HOUSE_GOOD){
    628 						TextPrintBuffer->Fill_Rect (0, 2*10, 2*String_Pixel_Width (Text_String (TXT_ENHANCING_IMAGE)), 2*(10 + 12), TBLACK);
    629 					}else{
    630 #if (FRENCH)
    631 						TextPrintBuffer->Fill_Rect (2*180, 2*10, 2*(180+String_Pixel_Width (Text_String (TXT_ENHANCING_IMAGE))), 2*(10 + 12), TBLACK);
    632 #else
    633 						TextPrintBuffer->Fill_Rect (2*210, 2*10, 2*(210+String_Pixel_Width (Text_String (TXT_ENHANCING_IMAGE))), 2*(10 + 12), TBLACK);
    634 #endif	//(FRENCH)
    635 					}
    636 					break;
    637 			}
    638 		}
    639 
    640 		Animate_Frame(progress,*PseudoSeenBuff,startframe + frame);
    641 		Call_Back_Delay(6);
    642 		/* Cause it to cycle on the flashing on the country for a little while */
    643 		if (!lastscenario && frame == 4 && q < 4) {
    644 			frame = 2;
    645 			q++;
    646 		}
    647 	}
    648 
    649 	int selection = 0, color = 0;
    650 	// erase the "Locating Coordinates" message...
    651 	Play_Sample(beepy6, 255, Options.Normalize_Sound(90));
    652 	if (!lastscenario) {
    653 #if (GERMAN | FRENCH)
    654 		SysMemPage.Fill_Rect( 0,160, 20*6,186, TBLACK);
    655 		PseudoSeenBuff->Fill_Rect(0,160, 20*6,186, TBLACK);
    656 		TextPrintBuffer->Fill_Rect(0,2*160, 2*20*6,2*186, BLACK);
    657 #else
    658 		SysMemPage.Fill_Rect( 0,160, 20*6,176, TBLACK);
    659 		PseudoSeenBuff->Fill_Rect(0,160, 20*6,176, TBLACK);
    660 		TextPrintBuffer->Fill_Rect(0,2*160, 2*20*6,2*176, BLACK);
    661 #endif
    662 	}
    663 	Interpolate_2X_Scale(PseudoSeenBuff, &SeenBuff, NULL);
    664 
    665 	/*
    666 	** Now the crosshairs are over the target countries - loop until a
    667 	** selection is made?
    668 	*/
    669 	int done = 0;
    670 	int framecounter = 0;
    671 
    672 	if (house == HOUSE_GOOD) {
    673 		Load_Uncompress(CCFileClass(lastscenario ? "CLICK_EB.CPS" : "CLICK_E.CPS"), SysMemPage, SysMemPage);
    674 	} else {
    675 		Load_Uncompress(CCFileClass(lastscenario ? "CLICK_SA.CPS" : "CLICK_A.CPS"), SysMemPage, SysMemPage);
    676 		if (lastscenario) attackxcoord = 200;
    677 	}
    678 
    679 //	Set_Font(ScoreFontPtr);
    680 	Play_Sample(text2, 255, Options.Normalize_Sound(90));
    681 	Alloc_Object(new ScorePrintClass(TXT_MAP_SELECT,attackxcoord,160,_greenpal));
    682 	Cycle_Call_Back_Delay(16,progresspalette);
    683 	Alloc_Object(new ScorePrintClass(TXT_MAP_TO_ATTACK,attackxcoord,170,_greenpal));
    684 	Cycle_Call_Back_Delay(24,progresspalette);
    685 	while (Get_Mouse_State() > 0) Show_Mouse();
    686 
    687 	Keyboard::Clear();
    688 	while (!done) {
    689 		Cycle_Call_Back_Delay(1,progresspalette);
    690 
    691 		// Check for the mouse button
    692 		if (Keyboard::Check()) {
    693 			if ((Keyboard::Get() & 0x10FF) == KN_LMOUSE) {
    694 				for (selection = 0; selection < CountryArray[scenario].Choices[ScenDir]; selection++) {
    695 					color = SysMemPage.Get_Pixel(Get_Mouse_X()/2,Get_Mouse_Y()/2);
    696 
    697 					/*
    698 					** Special hack for Egypt the second time through
    699 					*/
    700 					if (CountryArray[scenario].CountryColor[ScenDir][selection] == 0xA0) {
    701 						if ((color == 0x80) || (color == 0x81)) color = 0xA0;
    702 					}
    703 
    704 					if (CountryArray[scenario].CountryColor[ScenDir][selection] == color) {
    705 						Play_Sample(world2, 255, Options.Normalize_Sound(90));
    706 						done = 1;
    707 						break;
    708 					} else {
    709 						Play_Sample(scold1, 255, Options.Normalize_Sound(90));
    710 					}
    711 				}
    712 			}
    713 		}
    714 	}
    715 	ScenVar = CountryArray[scenario].CountryVariant[ScenDir][selection];
    716 	ScenDir = CountryArray[scenario].CountryDir[ScenDir][selection];
    717 
    718 	if (!lastscenario) {
    719 		Close_Animation(progress);
    720 
    721 		/*
    722 		** Now it's time to highlight the country we're going to.
    723 		*/
    724 		void const * countryshape = MixFileClass::Retrieve(house == HOUSE_GOOD ? "COUNTRYE.SHP" : "COUNTRYA.SHP");
    725 
    726 		Hide_Mouse();
    727 		// erase "Select country to attack"
    728 		PseudoSeenBuff->Fill_Rect(attackxcoord,160, attackxcoord+(17*6),178,BLACK);
    729 		TextPrintBuffer->Fill_Rect(2*attackxcoord,2*160, 2*(attackxcoord+(17*6)),2*178,BLACK);
    730 #if (GERMAN | FRENCH)
    731 		PseudoSeenBuff->Fill_Rect(attackxcoord+(17*6),160, attackxcoord+(21*6),178,BLACK);
    732 		TextPrintBuffer->Fill_Rect(2*attackxcoord+(17*6*2),2*160, 2*(attackxcoord+(21*6)),2*178,BLACK);
    733 #endif	//GERMAN
    734 		Interpolate_2X_Scale(PseudoSeenBuff, &SeenBuff ,NULL);
    735 
    736 		/*
    737 		** Draw the country's shape in non-fading colors
    738 		*/
    739 		Set_Logic_Page(SysMemPage);
    740 		europe->Blit(SysMemPage);
    741 
    742 		int shape = CountryArray[scenario].CountryShape[ScenDir][selection];
    743 		int xyindex = shape + (house == HOUSE_GOOD ? 0 : 18);
    744 		CC_Draw_Shape(countryshape, shape,
    745 					 _countryx[xyindex],_countryy[xyindex],
    746 					 WINDOW_MAIN, SHAPE_WIN_REL | SHAPE_CENTER, 0,0);
    747 		SysMemPage.Blit(*PseudoSeenBuff);
    748 		Interpolate_2X_Scale(PseudoSeenBuff, &SeenBuff ,NULL);
    749 
    750 		/*
    751 		** Now clear the palette of all but the country's colors, and fade
    752 		** the palette down
    753 		*/
    754 		CCFileClass("DARK_E.PAL").Read(localpalette, 768);
    755 //		Load_Data("DARK_E.PAL", localpalette, 768);
    756 		InterpolationPaletteChanged = TRUE;
    757 		InterpolationPalette = localpalette;
    758 		Increase_Palette_Luminance(localpalette , 30,30,30,63);
    759 		Read_Interpolation_Palette("MAP_LOC2.PAL");
    760 		Interpolate_2X_Scale(PseudoSeenBuff , &SeenBuff , "MAP_LOC2.PAL");
    761 		Fade_Palette_To(localpalette, FADE_PALETTE_MEDIUM, Call_Back);
    762 
    763 		countryshape = 0;
    764 
    765 		Print_Statistics(color & 0x7F, _countryx[xyindex], _countryy[xyindex]);
    766 	} else {
    767 		CCFileClass(house == HOUSE_GOOD ? "DARK_B.PAL" : "DARK_SA.PAL").Read(localpalette, 768);
    768 		InterpolationPaletteChanged = TRUE;
    769 		InterpolationPalette = localpalette;
    770 		Increase_Palette_Luminance(localpalette , 30,30,30,63);
    771 		Read_Interpolation_Palette("MAP_LOC3.PAL");
    772 		Interpolate_2X_Scale(PseudoSeenBuff , &SeenBuff , "MAP_LOC3.PAL");
    773 		Set_Palette(localpalette);
    774 //		Load_Data(house == HOUSE_GOOD ? "DARK_B.PAL" : "DARK_SA.PAL", localpalette, 768);
    775 
    776 		Hide_Mouse();
    777 #if (GERMAN | FRENCH)
    778 		PseudoSeenBuff->Fill_Rect(attackxcoord, 160, 319, 178, BLACK);	// erase "Select country to attack"
    779 		TextPrintBuffer->Fill_Rect(2*attackxcoord, 2*160, 639, 2*178, BLACK);	// erase "Select country to attack"
    780 #else
    781 		PseudoSeenBuff->Fill_Rect(attackxcoord, 160, attackxcoord + (17*6), 199, BLACK);	// erase "Select country to attack"
    782 		TextPrintBuffer->Fill_Rect(2*attackxcoord, 2*160, 2*(attackxcoord + (17*6)), 2*199, BLACK);	// erase "Select country to attack"
    783 #endif
    784 		Interpolate_2X_Scale(PseudoSeenBuff, &SeenBuff, NULL);
    785 		Animate_Frame(progress, *PseudoSeenBuff, Get_Animation_Frame_Count(progress)-1);
    786 		Set_Palette(localpalette);
    787 		Close_Animation(progress);
    788 		PseudoSeenBuff->Blit(SysMemPage);
    789 		Print_Statistics(20, 160, house == HOUSE_GOOD ? 0 : 160);
    790 	}
    791 
    792 	Theme.Queue_Song(THEME_NONE);
    793 	Fade_Palette_To(BlackPalette, FADE_PALETTE_MEDIUM, NULL);
    794 	delete europe;
    795 	delete progresspalette;
    796 	delete grey2palette;
    797 	delete TextPrintBuffer;
    798 	TextPrintBuffer = NULL;
    799 	BlitList.Clear();
    800 }
    801 
    802 
    803 /***************************************************************************
    804  * Print_Statistics -- Prints statistics on country selected               *
    805  *                                                                         *
    806  *                                                                         *
    807  *                                                                         *
    808  * INPUT:   shape = country #, x & y = country's on-screen coords          *
    809  *                                                                         *
    810  * OUTPUT:                                                                 *
    811  *                                                                         *
    812  * WARNINGS:                                                               *
    813  *                                                                         *
    814  * HISTORY:                                                                *
    815  *   04/27/1995 BWG : Created.                                             *
    816  *=========================================================================*/
    817 void Print_Statistics(int country, int xpos, int ypos)
    818 {
    819 	int index,newx;
    820 	void *oldfont;
    821 	static int const _gdistatnames[]={
    822 		TXT_MAP_GDISTAT0,
    823 		TXT_MAP_GDISTAT1,
    824 		TXT_MAP_GDISTAT2,
    825 		TXT_MAP_GDISTAT3,
    826 		TXT_MAP_GDISTAT4,
    827 		TXT_MAP_GDISTAT5,
    828 		TXT_MAP_GDISTAT6
    829 		};
    830 	static int const _nodstatnames[]={
    831 		TXT_MAP_GDISTAT0,
    832 		TXT_MAP_NODSTAT0,
    833 		TXT_MAP_GDISTAT2,
    834 		TXT_MAP_GDISTAT3,
    835 		TXT_MAP_NODSTAT1,
    836 		TXT_MAP_NODSTAT2,
    837 		TXT_MAP_GDISTAT5,
    838 		TXT_MAP_NODSTAT3,
    839 		TXT_MAP_NODSTAT4
    840 	};
    841 	static int const _countryname[]={
    842 		TXT_MAP_COUNTRYNAME0,
    843 		TXT_MAP_COUNTRYNAME1,
    844 		TXT_MAP_COUNTRYNAME2,
    845 		TXT_MAP_COUNTRYNAME3,
    846 		TXT_MAP_COUNTRYNAME4,
    847 		TXT_MAP_COUNTRYNAME5,
    848 		TXT_MAP_COUNTRYNAME6,
    849 		TXT_MAP_COUNTRYNAME7,
    850 		TXT_MAP_COUNTRYNAME8,
    851 		TXT_MAP_COUNTRYNAME9,
    852 		TXT_MAP_COUNTRYNAME10,
    853 		TXT_MAP_COUNTRYNAME11,
    854 		TXT_MAP_COUNTRYNAME12,
    855 		TXT_MAP_COUNTRYNAME13,
    856 		TXT_MAP_COUNTRYNAME14,
    857 		TXT_MAP_COUNTRYNAME15,
    858 		TXT_MAP_COUNTRYNAME16,
    859 		TXT_MAP_COUNTRYNAME17,
    860 		TXT_MAP_COUNTRYNAME18,
    861 		TXT_MAP_COUNTRYNAME19,
    862 		TXT_MAP_COUNTRYNAME20,
    863 		TXT_MAP_COUNTRYNAME21,
    864 		TXT_MAP_COUNTRYNAME22,
    865 		TXT_MAP_COUNTRYNAME23,
    866 		TXT_MAP_COUNTRYNAME24,
    867 		TXT_MAP_COUNTRYNAME25,
    868 		TXT_MAP_COUNTRYNAME26,
    869 		TXT_MAP_COUNTRYNAME27,
    870 		TXT_MAP_COUNTRYNAME28,
    871 		TXT_MAP_COUNTRYNAME29,
    872 		TXT_MAP_COUNTRYNAME30,
    873 		TXT_MAP_COUNTRYNAME31,
    874 		TXT_MAP_COUNTRYNAME32,
    875 		TXT_MAP_COUNTRYNAME33,
    876 		TXT_MAP_COUNTRYNAME34
    877 	};
    878 
    879 	static int const _govtnames[]={
    880 		TXT_MAP_GOVT0,
    881 		TXT_MAP_GOVT1,
    882 		TXT_MAP_GOVT2,
    883 		TXT_MAP_GOVT3,
    884 		TXT_MAP_GOVT4,
    885 		TXT_MAP_GOVT5,
    886 		TXT_MAP_GOVT6,
    887 		TXT_MAP_GOVT7,
    888 		TXT_MAP_GOVT8,
    889 		TXT_MAP_GOVT9,
    890 		TXT_MAP_GOVT10,
    891 		TXT_MAP_GOVT11
    892 	};
    893 	static int const _armynames[]={
    894 		TXT_MAP_ARMY0,
    895 		TXT_MAP_ARMY1,
    896 		TXT_MAP_ARMY2,
    897 		TXT_MAP_ARMY3,
    898 		TXT_MAP_ARMY4,
    899 		TXT_MAP_ARMY5
    900 	};
    901 	static int const _military[]={
    902 		TXT_MAP_MILITARY0,
    903 		TXT_MAP_MILITARY1,
    904 		TXT_MAP_MILITARY2,
    905 		TXT_MAP_MILITARY3,
    906 		TXT_MAP_MILITARY4
    907 	};
    908 
    909 	static char const _greenpal[]={0,0x41,0x42,0x43,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44};
    910 	//static char const _greenpal[]={0,1,0x42,3,0x43,5,0x44,7,0x44,9,10,1,12,13,0x41,15};
    911 	static char _deststr[16];
    912 
    913 /* Change to the six-point font for Text_Print */
    914 	oldfont = Set_Font(ScoreFontPtr);
    915 
    916 #ifdef GERMAN
    917 	xpos = 8;
    918 #else
    919 	xpos = (xpos > 128) ? 8 : 136;
    920 #endif
    921 	ypos = (ypos > 100) ? 8 : 104-6;
    922 	if (PlayerPtr->Class->House == HOUSE_GOOD) {
    923 		Alloc_Object(new ScorePrintClass(_countryname[GDIStats[country].nameindex],xpos,ypos,_greenpal));
    924 		Call_Back_Delay(strlen(Text_String(_countryname[GDIStats[country].nameindex]))*3);
    925 		ypos += 16;
    926 		for (index = 0; index < 7; index ++) {
    927 			Alloc_Object(new ScorePrintClass(_gdistatnames[index],xpos,ypos,_greenpal));
    928 			Call_Back_Delay(strlen(Text_String(_gdistatnames[index]+3)));
    929 			newx = xpos + 6*strlen(Text_String(_gdistatnames[index]));
    930 			switch (index) {
    931 				case 0:
    932 					Alloc_Object(new ScorePrintClass(GDIStats[country].pop,newx,ypos,_greenpal));
    933 					break;
    934 				case 1:
    935 					Alloc_Object(new ScorePrintClass(GDIStats[country].area,newx,ypos,_greenpal));
    936 					break;
    937 				case 2:
    938 					Alloc_Object(new ScorePrintClass(GDIStats[country].capital,newx,ypos,_greenpal));
    939 					break;
    940 				case 3:
    941 					Alloc_Object(new ScorePrintClass(_govtnames[GDIStats[country].govt],newx,ypos,_greenpal));
    942 					break;
    943 				case 4:
    944 					Alloc_Object(new ScorePrintClass(GDIStats[country].gdp,newx,ypos,_greenpal));
    945 					break;
    946 				case 5:
    947 					Alloc_Object(new ScorePrintClass(GDIStats[country].conflict,newx,ypos,_greenpal));
    948 					break;
    949 				case 6:
    950 					Alloc_Object(new ScorePrintClass(_armynames[GDIStats[country].military],newx,ypos,_greenpal));
    951 					break;
    952 			}
    953 			ypos += 8;
    954 		}
    955 	} else {	// Nod statistics
    956 		if (country > 30) {
    957 			country = 15;	// hack for 2nd time in Egypt
    958 		} else {
    959 			if (country >=15) country++;	// hack to account for Egypt
    960 		}
    961 		country++;
    962 
    963 		Alloc_Object(new ScorePrintClass(_countryname[NodStats[country].nameindex],xpos,ypos,_greenpal));
    964 		Call_Back_Delay(strlen(Text_String(_countryname[NodStats[country].nameindex]))*3);
    965 		ypos += 16;
    966 		for (index = 0; index < 9; index ++) {
    967 			Alloc_Object(new ScorePrintClass(_nodstatnames[index],xpos,ypos,_greenpal));
    968 			Call_Back_Delay(strlen(Text_String(_nodstatnames[index]+3)));
    969 			newx = xpos + 6*strlen(Text_String(_nodstatnames[index]));
    970 			switch (index) {
    971 				case 0:
    972 					Alloc_Object(new ScorePrintClass(NodStats[country].pop,newx,ypos,_greenpal));
    973 					break;
    974 				case 1:
    975 					sprintf(_deststr,"%d%%",NodStats[country].expendable);
    976 					Alloc_Object(new ScorePrintClass(_deststr,newx,ypos,_greenpal));
    977 					break;
    978 				case 2:
    979 					Alloc_Object(new ScorePrintClass(NodStats[country].capital,newx,ypos,_greenpal));
    980 					break;
    981 				case 3:
    982 					Alloc_Object(new ScorePrintClass(_govtnames[NodStats[country].govt],newx,ypos,_greenpal));
    983 					break;
    984 				case 4:
    985 #ifdef FIX_ME_LATER
    986 					sprintf(_deststr,"%s %d%%",LowMedHiStr(NodStats[country].corruptible),NodStats[country].corruptible);
    987 #endif	//FIX_ME_LATER
    988 					sprintf(_deststr,"%d%%",NodStats[country].corruptible);
    989 					Alloc_Object(new ScorePrintClass(_deststr,newx,ypos,_greenpal));
    990 					break;
    991 				case 5:
    992 					Alloc_Object(new ScorePrintClass(NodStats[country].worth,newx,ypos,_greenpal));
    993 					break;
    994 				case 6:
    995 					Alloc_Object(new ScorePrintClass(NodStats[country].conflict,newx,ypos,_greenpal));
    996 					break;
    997 				case 7:
    998 					Alloc_Object(new ScorePrintClass(_military[NodStats[country].military],newx,ypos,_greenpal));
    999 					break;
   1000 				case 8:
   1001 					sprintf(_deststr,"%d%%",NodStats[country].probability);
   1002 					Alloc_Object(new ScorePrintClass(_deststr,newx,ypos,_greenpal));
   1003 					break;
   1004 			}
   1005 			ypos += 8;
   1006 		}
   1007 	}
   1008 
   1009 #ifdef FRENCH
   1010 	Alloc_Object(new ScorePrintClass(TXT_MAP_CLICK2,94,193-6,_greenpal));
   1011 #else
   1012 	Alloc_Object(new ScorePrintClass(TXT_MAP_CLICK2,160-(17*3),193-6,_greenpal));
   1013 #endif
   1014 
   1015 	int done = 0;
   1016 	while (!done) {
   1017 		done = 1;
   1018 		for (int x = 0; x < MAXSCOREOBJS; x++) if (ScoreObjs[x]) {
   1019 			done = 0;
   1020 			Call_Back_Delay(1);
   1021 		}
   1022 	}
   1023 	Keyboard::Clear();
   1024 	while (Keyboard::Check()){
   1025 		Keyboard::Clear();
   1026 	}
   1027 	while (!Keyboard::Check() && !ControlQ) {
   1028 		Call_Back_Delay(1);
   1029 	}
   1030 	Keyboard::Clear();
   1031 	Set_Font(oldfont);
   1032 }
   1033 
   1034 #ifdef NEVER
   1035 /***************************************************************************
   1036  * FADING_BYTE_BLIT -- 'Pixelized' incremental byte blit.                  *
   1037  *                                                                         *
   1038  *    This routine will perform the same function as Byte_Blit, but will   *
   1039  *    do so in an incremental (one piece at a time) method.  This is       *
   1040  *    usefull for graphic 'fades' from one display to another.             *
   1041  *                                                                         *
   1042  * INPUT:   srcx  - Source page X byte position of upper left corner.      *
   1043  *                                                                         *
   1044  *          srcy  - Source page Y pixel position of upper left corner.     *
   1045  *                                                                         *
   1046  *          destx - Dest page X byte position of upper left corner.        *
   1047  *                                                                         *
   1048  *          desty - Dest page Y pixel position of upper left corner.       *
   1049  *                                                                         *
   1050  *          w     - Width of the blit in bytes.                            *
   1051  *                                                                         *
   1052  *          h     - Height of the blit in pixels.                          *
   1053  *                                                                         *
   1054  *          src   - PageType of the source page.                           *
   1055  *                                                                         *
   1056  *          dest  - Page type of the destination.                          *
   1057  *                                                                         *
   1058  * OUTPUT:  none                                                           *
   1059  *                                                                         *
   1060  * WARNINGS:   This routine, although functionally equivalent to the       *
   1061  *             normal Byte_Blit, is very slow.  Only use this when         *
   1062  *             the 'fading' graphic effect is desired.  This means the     *
   1063  *             destination page should probably be the SEENPAGE.           *
   1064  *                                                                         *
   1065  * HISTORY:                                                                *
   1066  *   07/17/1991 JLB : Created from Bit_It_In() (LJC code).                 *
   1067  *   04/17/1995 BWG : Adapted to the C++ system.									*
   1068  *=========================================================================*/
   1069 void Fading_Byte_Blit(int srcx, int srcy, int destx, int desty, int w, int h, GraphicBufferClass *src, GraphicBufferClass *dest)
   1070 {
   1071 	unsigned int	xindex,			// Working array index var.
   1072 						yindex;			// Working y index var.
   1073 	unsigned int	x,y;				// Extraction position indexes.
   1074 	unsigned int	tempy;			// Temporary working Y index var.
   1075 	int	_xindex[40];	// X position array.
   1076 	int	_yindex[200];	// Y position array.
   1077 
   1078 	// Anticipate two pixel rows per blit.
   1079 	h >>= 1;
   1080 
   1081 	// This routine is byte-aligned
   1082 	srcx  >>=3;
   1083 	destx >>=3;
   1084 	w		>>=3;
   1085 
   1086 	for (xindex = 0; xindex < w; xindex++) _xindex[xindex] = xindex;		/* init the index array */
   1087 	for (yindex = 0; yindex < h; yindex++) _yindex[yindex] = yindex;		/* init the index array */
   1088 
   1089 	/*
   1090 	**	Shuffle the X indexes around a bit.  This gives it
   1091 	**	that 'random' feel while remaining precise.
   1092 	*/
   1093 	for (xindex = 0; xindex < w; xindex++) {
   1094 		int	temp;
   1095 
   1096 	 	x = IRandom(0,w-1);
   1097 		temp = _xindex[x];
   1098 		_xindex[x] = _xindex[xindex];
   1099 		_xindex[xindex] = temp;
   1100 	}
   1101 
   1102 	/*
   1103 	**	Shuffle the Y indexes around a bit for the same reason that
   1104 	**	the x indexes were shuffled.
   1105 	*/
   1106 	for (yindex = 0; yindex < h; yindex++) {
   1107 		int	temp;
   1108 
   1109 	 	y = IRandom(0,h-1);
   1110 		temp = _yindex[y];
   1111 		_yindex[y] = _yindex[yindex];
   1112 		_yindex[yindex] = temp;
   1113 	}
   1114 
   1115 	/*
   1116 	**	Sweep through the indexes and 'construct' the destination display
   1117 	**	from a series of miniature Byte_Blits.
   1118 	*/
   1119 	for (yindex = 0; yindex < h; yindex++) {
   1120 		tempy = yindex;
   1121 		Call_Back();
   1122 		for (xindex = 0; xindex < w; xindex++) {
   1123 			x = _xindex[xindex];
   1124 			y = _yindex[tempy];
   1125 			tempy++;
   1126 			if (tempy >= h) tempy = 0;
   1127 			src->Blit(*dest, (srcx+x)<<3, srcy+(y<<1), (destx+x)<<3, desty+(y<<1), 1<<3, 2);
   1128 		}
   1129 	}
   1130 }
   1131 #endif
   1132 
   1133 
   1134 
   1135 
   1136 
   1137 void Cycle_Call_Back_Delay(int time, unsigned char *pal)
   1138 {
   1139 	static int _counter;
   1140 	unsigned char r,g,b;
   1141 	int i;
   1142 
   1143 	while (time--) {
   1144 		_counter = (++_counter & 3);
   1145 
   1146 		if (!(_counter & 3) ) {
   1147 			r = pal[249*3+0];
   1148 			g = pal[249*3+1];
   1149 			b = pal[249*3+2];
   1150 
   1151 			for (i = 249; i < 254; i++) {
   1152 				pal[i*3+0] = pal[(i+1)*3+0];
   1153 				pal[i*3+1] = pal[(i+1)*3+1];
   1154 				pal[i*3+2] = pal[(i+1)*3+2];
   1155 			}
   1156 			pal[254*3+0] = r;
   1157 			pal[254*3+1] = g;
   1158 			pal[254*3+2] = b;
   1159 
   1160 			Set_Palette(pal);
   1161 		}
   1162 		Call_Back_Delay(1);
   1163 	}
   1164 }
   1165 
   1166 int LowMedHiStr(int percentage)
   1167 {
   1168 	if (percentage < 30) return(TXT_MAP_LMH0);
   1169 	if (percentage < 70) return(TXT_MAP_LMH1);
   1170 	return(TXT_MAP_LMH2);
   1171 }
   1172 
   1173 
   1174 
   1175 #endif		//DEMO
   1176 
   1177 
   1178 /***************************************************************************
   1179  * Bit_It_In -- Pixel fade graphic copy.                                   *
   1180  *                                                                         *
   1181  *    Copies a block of graphic memory using a 'random' pixel algorithm.   *
   1182  *    Typcial use would be to 'fade' some graphic display into another.    *
   1183  *                                                                         *
   1184  * INPUT:   x,y   - Pixel position of upper left corner of block.          *
   1185  *                                                                         *
   1186  *          w,y   - Pixel width and height of block to pixel blit.         *
   1187  *                                                                         *
   1188  *          src   - Page number of the source page.                        *
   1189  *                                                                         *
   1190  *          dest  - Page number of the destination page.                   *
   1191  *                                                                         *
   1192  *    		delay - # of frames to wait after each line fades in           *
   1193  *                                                                         *
   1194  * OUTPUT:     none                                                        *
   1195  *                                                                         *
   1196  * WARNINGS:   This function uses PIXEL coordinates for the X and width    *
   1197  *             parameters.  This is unlike the Byte_Blit() routine that    *
   1198  *             it most closely resembles.                                  *
   1199  *                                                                         *
   1200  * HISTORY:                                                                *
   1201  *   04/16/1991 JLB : Created.                                             *
   1202  *   04/17/1995 BWG : Adapted to C++ library.                              *
   1203  *=========================================================================*/
   1204 
   1205 void Bit_It_In_Scale(int x, int y, int w, int h, GraphicBufferClass *src, GraphicBufferClass *dest, GraphicViewPortClass * /*seen*/ , int delay, int dagger)
   1206 {
   1207 	short int	 *xindex,*yindex;
   1208 	int			 n;
   1209 	int i,j,k,m,j1;
   1210 	short			 ScaleBuffer[320+200];
   1211 
   1212 	xindex = (short int *) ScaleBuffer;
   1213 	yindex = xindex + 320;
   1214 
   1215 	for (i=0; i<w; i++) xindex[i]=i;		/* init the index array */
   1216 	for (i=0; i<h; i++) yindex[i]=i;		/* init the index array */
   1217 	for (i=0; i<w; i++) {						/* shuffle the indexes */
   1218 	 	k=IRandom(0,w-1);
   1219 		m=i;
   1220 		n=xindex[k];
   1221 		xindex[k]=xindex[m];
   1222 		xindex[m]=n;
   1223 	}
   1224 	for (i=0; i<h; i++) {						/* shuffle the indexes */
   1225 	 	k=IRandom(0,h-1);
   1226 		m=i;
   1227 		n=yindex[k];
   1228 		yindex[k]=yindex[m];
   1229 		yindex[m]=n;
   1230 	}
   1231 
   1232 	for (j=0; j<h; j++) {
   1233 		j1=j;
   1234 // execute delay every other line
   1235 		if (j & 1) {
   1236 			i = delay;
   1237 			do {
   1238 				Call_Back_Delay(i ? 1 : 0);
   1239 			} while(i--);
   1240 		} else {
   1241 			Call_Back();
   1242 		}
   1243 
   1244 		if (src->Lock() && dest->Lock()){
   1245 			for (i=0; i<w; i++) {
   1246 				k=x+xindex[i];
   1247 				m=y+yindex[j1];
   1248 				j1++;
   1249 				if (j1>=h) j1=0;
   1250 
   1251 				Buffer_Put_Pixel (dest,k,m,Buffer_Get_Pixel(src,k,m));
   1252 				//n=src->Get_Pixel(k,m);
   1253 				//dest->Put_Pixel(k,m,n);
   1254 			}
   1255 			if (dagger) for (int q=j; q>=0; q--) {
   1256 				Buffer_Put_Pixel(dest,160-(j-q),q,Buffer_Get_Pixel(src,160-(j-q),q));
   1257 				Buffer_Put_Pixel(dest,160+(j-q),q,Buffer_Get_Pixel(src,160+(j-q),q));
   1258 				//dest->Put_Pixel(160-(j-q),q,src->Get_Pixel(160-(j-q),q));
   1259 				//dest->Put_Pixel(160+(j-q),q,src->Get_Pixel(160+(j-q),q));
   1260 			}
   1261 		}
   1262 		src->Unlock();
   1263 		dest->Unlock();
   1264 		//if (seen){
   1265 			//Interpolate_2X_Scale(dest , seen ,NULL);
   1266 		//}
   1267 	}
   1268 }
   1269 
   1270 void Bit_It_In(int x, int y, int w, int h, GraphicBufferClass *src, GraphicBufferClass *dest, int delay, int dagger)
   1271 {
   1272 	Bit_It_In_Scale (x, y, w, h,  src, dest, NULL , delay,  dagger);
   1273 }
   1274