OLD_GEN.CPP 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <conio.h>
  5. #include "euro.equ"
  6. #include "euro_def.h"
  7. #include "euro_var.h"
  8. #include "euro_grf.h"
  9. #include "euro_dsk.h"
  10. #include "euro_fix.h"
  11. #include "euro_sel.h"
  12. #include "euro_inf.h"
  13. #include "euro_cnt.h"
  14. #include "euro_usr.h"
  15. void DisplayPositionLabels();
  16. void DisplaySquad();
  17. void DisplayFormation( char );
  18. void ClearFormationMarkers();
  19. short AddAnimation( int, int, float, float, float, signed char, signed char );
  20. //void DisplayCountrySelectImages();
  21. #include "defines.h"
  22. extern "C" short MouseBUTTONS;
  23. extern int MouseFlags;
  24. extern "C" short PaletteFlag;
  25. extern int new_menu;
  26. extern "C" short MouseDeBOUNCE;
  27. extern "C" short MouseXminimum;
  28. extern "C" short MouseYminimum;
  29. //********************************************************************************************************************************
  30. char *GetTEXT( short StringNumber )
  31. {
  32. return( (char *)Text[ StringNumber ] );
  33. }
  34. //********************************************************************************************************************************
  35. char *GetTEAMname( char team, char maxlen )
  36. {
  37. char *Name = GetTEXT( COUNTRY_NAMES+team );
  38. char Searchlen = strlen(&Name[0]);
  39. char NAMEoffset = 0;
  40. for ( char x=0; x<Searchlen ; x++ )
  41. {NameBuffer[x] = * (Name+x);}
  42. NameBuffer[x] = 0;
  43. if ( maxlen!=0 && Searchlen > maxlen )
  44. {
  45. NameBuffer[maxlen-1] = '.';
  46. NameBuffer[maxlen] = 0;
  47. }
  48. return ( &NameBuffer[0] );
  49. }
  50. //********************************************************************************************************************************
  51. char *GetPLAYERSname( char player, char team, char format )
  52. {
  53. char *Search = GetTEXT( ( PLAYER_NAMES+(team*20 )+player) );
  54. char NAMEoffset = 0;
  55. char Searchlen = strlen(&Search[0]);
  56. if ( format == FULL_NAME )
  57. {
  58. for ( char x=0; x < Searchlen ; x++ )
  59. {NameBuffer[x] = *(Search+x);}
  60. NameBuffer[x] = 0;
  61. }
  62. if ( format == INITIAL_SURNAME )
  63. {
  64. // *** Get players initials ***
  65. for ( char x=0; x < Searchlen ; x++ )
  66. {
  67. // if ( ( *(Search+x) >= 'A' && *(Search+x) <='Z') &&
  68. // ( *(Search+(x+1)) >= 'a' && *(Search+(x+1)) <='z') && NAMEoffset < (NAME_BUFFER_LEN-3) )
  69. if ( IsUpper[ *(Search+x) ] == up &&
  70. IsUpper[ *(Search+(x+1)) ] == lw &&
  71. NAMEoffset < (NAME_BUFFER_LEN-3) )
  72. {
  73. NameBuffer[NAMEoffset] = *(Search+x);
  74. NAMEoffset++;
  75. if ((*(Search+x))=='-')
  76. NameBuffer[NAMEoffset] = '-';
  77. else
  78. NameBuffer[NAMEoffset] = '.';
  79. NameBuffer[NAMEoffset+1] = 32;
  80. NAMEoffset+= 2;
  81. }
  82. if ((*(Search+x))=='-' && NAMEoffset >1 )
  83. {
  84. NameBuffer[NAMEoffset-2] = '-';
  85. NAMEoffset--;
  86. }
  87. }
  88. }
  89. if ( format == INITIAL_SURNAME || format == SURNAME )
  90. {
  91. // *** Get players surname ***
  92. for ( char y=0; y < Searchlen ; y++ )
  93. {
  94. // if ( ( *(Search+y) >= 'A' && *(Search+y) <='Z') &&
  95. // ( *(Search+(y+1)) >= 'A' && *(Search+(y+1)) <='Z') && NAMEoffset < (NAME_BUFFER_LEN-3) )
  96. if ( IsUpper[ *(Search+y) ] == up &&
  97. IsUpper[ *(Search+(y+1)) ] == up &&
  98. NAMEoffset < (NAME_BUFFER_LEN-3) )
  99. {
  100. NameBuffer[NAMEoffset] = *(Search+y);
  101. // if ( (*(Search+(y-1)) >= 'A' && *(Search+(y-1)) <='Z' && y>0) &&
  102. // (NameBuffer[NAMEoffset-1]!='c' || NameBuffer[NAMEoffset-2]!='M' && NAMEoffset>1 )
  103. // )
  104. if ( (IsUpper[ *(Search+(y-1) ) ] == up && y>0) &&
  105. (NameBuffer[NAMEoffset-1]!='c' || NameBuffer[NAMEoffset-2]!='M' && NAMEoffset>1 ) )
  106. NameBuffer[NAMEoffset]+= 32;
  107. NAMEoffset++;
  108. }
  109. else
  110. // if ( ( *(Search+y) >= 'A' && *(Search+y) <='Z') &&
  111. // ( *(Search+(y-1)) >= 'A' && *(Search+(y-1)) <='Z') && NAMEoffset < (NAME_BUFFER_LEN-3) && y>0 )
  112. if ( IsUpper[ *(Search+y) ] == up &&
  113. IsUpper[ *(Search+(y-1)) ] == up &&
  114. NAMEoffset < (NAME_BUFFER_LEN-3) && y>0 )
  115. {
  116. NameBuffer[NAMEoffset] = *(Search+y);
  117. // if ( *(Search+(y-1)) >= 'A' && *(Search+(y-1)) <='Z' && y>0 )
  118. if ( IsUpper[ *(Search+(y-1)) ] == up && y>0 )
  119. NameBuffer[NAMEoffset]+= 32;
  120. NAMEoffset++;
  121. if ( (*(Search+(y+1)))==' ')
  122. {
  123. NameBuffer[NAMEoffset] = 32;
  124. NAMEoffset++;
  125. }
  126. }
  127. }
  128. NameBuffer[NAMEoffset] = 0; // end of line.
  129. }
  130. return ( &NameBuffer[0] );
  131. }
  132. //********************************************************************************************************************************
  133. void DisplayString( int xpos, int ypos, char *string, int font, int colour, signed char box, pseudo_info *pseudo, texture_info *texture )
  134. {
  135. int c;
  136. svalue = colour;
  137. while ( c=*(string++) )
  138. {
  139. if ( c < 127 )
  140. c-= 32;
  141. else
  142. if ( c < 155 )
  143. c-= 33;
  144. else
  145. if ( c < 166 )
  146. c-= 38;
  147. else
  148. if ( c == 225 )
  149. c-= 97;
  150. else
  151. if ( c == 237 )
  152. c-= 108;
  153. c+= font;
  154. DrawIMAGE( pseudo, texture, c, xpos, ypos, box, spriteinccopy );
  155. xpos+= (Image_Widths[c])+1;
  156. }
  157. NextXposn = xpos;
  158. }
  159. //********************************************************************************************************************************
  160. int PixelLengthOfString( char *string, int font )
  161. {
  162. int c;
  163. int len = 0;
  164. while ( c=*(string++) )
  165. {
  166. if ( c < 127 )
  167. c-= 32;
  168. else
  169. if ( c < 155 )
  170. c-= 33;
  171. else
  172. if ( c < 166 )
  173. c-= 38;
  174. else
  175. if ( c == 225 )
  176. c-= 97;
  177. else
  178. if ( c == 237 )
  179. c-= 108;
  180. c+= font;
  181. len+= (Image_Widths[c])+1;
  182. }
  183. return(len);
  184. }
  185. //********************************************************************************************************************************
  186. void InitialiseMenuPage( char MENU )
  187. {
  188. switch ( MENU )
  189. {
  190. case( SQUAD_SELECT ):
  191. LoadTactics( ((int)FormationInfo[Team]), &EuroDATfile[0], &TeamTactics[0][0][0] );
  192. DisplaySquad();
  193. DisplayFormation( NULL );
  194. DisplayPositionLabels();
  195. MarkPlayer = -1;
  196. SquadBuffer1yposn = -1;
  197. QuestionHandle = AddAnimation( 488, 16,
  198. ( (float)QUESTION_MARK ), ( (float)QUESTION_MARK+19.1 ),
  199. 0.40, QUESTION_BOX, CONT_ANIM );
  200. FormationHandle = AddAnimation( NameBarXposn-16, 426,
  201. ( (float)WHT_BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  202. 0.0, FORMATION_BOX, RUN_ONCE );
  203. ReturnSqdHandle = AddAnimation( 308, 426,
  204. ( (float)WHT_BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  205. 0.0, RETURN_SQUAD_BOX, RUN_ONCE );
  206. ViewTeamHandle = AddAnimation( NameBarXposn-16, 106,
  207. ( (float)WHT_BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  208. 0.0, OPPONENT_TEAM_BOX, RUN_ONCE );
  209. break;
  210. case( GROUP_FIXTURES ):
  211. RedrawHandle = AddAnimation( 509, 181,
  212. ( (float)WHT_BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  213. 0.0, REDRAW_BOX, CONT_ANIM );
  214. break;
  215. case( TEAM_SELECT ):
  216. ClickBOX = NO_BOX;
  217. PlayerSetupHandle = AddAnimation( 446, 180,
  218. ( (float)WHT_BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  219. 0.0, PLAYER_SETUP_BOX, CONT_ANIM );
  220. FormationSetupHandle = AddAnimation( 446, 228,
  221. ( (float)WHT_BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  222. 0.0, FORMATION_SETUP_BOX, CONT_ANIM );
  223. SelectionSpeed = 0;
  224. SelectionFlag = -1;
  225. SelectionAim = AimTBL[EUROteamA];
  226. SelectionCounter = ((float)SelectionAim)*4;
  227. DisplayGameType( EUROgameType );
  228. DisplayCountrySelectImages();
  229. DoFriendlyTeamSelection();
  230. break;
  231. case( EURO_REDRAW ):
  232. DisplayGroupHeadings();
  233. EuroDrawHandle = AddAnimation( 179, 234,
  234. ( (float)EURO_DRAW_ANIM ), ( (float)EURO_DRAW_ANIM+55.0 ),
  235. 0.40, QUESTION_BOX, CONT_ANIM );
  236. EuroReDrawCounter = 30.0;
  237. EuroReDrawFlag = -1;
  238. break;
  239. case( PLAYER_STATS ):
  240. DisplaySquad();
  241. DisplayPositionLabels();
  242. QuestionHandle = AddAnimation( 488, 16,
  243. ( (float)QUESTION_MARK ), ( (float)QUESTION_MARK+19.1 ),
  244. 0.40, QUESTION_BOX, CONT_ANIM );
  245. ReturnStatHandle = AddAnimation( 308, 416,
  246. ( (float)WHT_BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  247. 0.0, RETURN_PSTATS_BOX, CONT_ANIM );
  248. DisplayPlayerStats();
  249. break;
  250. case( PLAYER_SETUP ):
  251. TeamSelectHandle = AddAnimation( 516, 434,
  252. ( (float)BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  253. 0.0, TEAM_SELECT_BOX, CONT_ANIM );
  254. DisplayMatchTeam( EUROteamA, 87, 0, 16 );
  255. DisplayMatchTeam( EUROteamB, 352, 12, 32 );
  256. DisplayUserInfo(EUROplyrSetup);
  257. break;
  258. case( TEAM_STATS ):
  259. ReturnTeamHandle = AddAnimation( 512, 426,
  260. ( (float)BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  261. 0.0, RETURN_TSTATS_BOX, CONT_ANIM );
  262. ViewTeamHandle = AddAnimation( NameBarXposn-16, 106,
  263. ( (float)WHT_BLUE_BUTTON ), ( (float)WHT_BLUE_BUTTON+11.9 ),
  264. 0.0, OPPONENT_TEAM_BOX, RUN_ONCE );
  265. break;
  266. }
  267. SetupMouseLimits( 0, 626, 1, 452 );
  268. }
  269. //********************************************************************************************************************************
  270. void OverlayStaticBackgroundImages( char MENU )
  271. {
  272. int width;
  273. switch ( MENU )
  274. {
  275. case( SQUAD_SELECT ):
  276. DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN,
  277. LION_KITS+Team, 550, 2, NO_BOX, spritecopy );
  278. width = PixelLengthOfString( GetTEAMname( Team, 0 ),
  279. LARGE_FONT);
  280. Image_Widths[NAMEBAR_LEFT] = Image_Widths[NAMEBAR_RIGHT]+width;
  281. DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN,
  282. NAMEBAR_LEFT, NameBarXposn,
  283. 106, NO_BOX, spritecopy );
  284. DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN,
  285. NAMEBAR_RIGHT, NameBarXposn+Image_Widths[NAMEBAR_LEFT],
  286. 106, NO_BOX, spritecopy );
  287. Image_Widths[NAMEBAR_LEFT] = FORMATION_BAR_WIDTH;
  288. DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN,
  289. NAMEBAR_LEFT, NameBarXposn,
  290. 426, NO_BOX, spritecopy );
  291. DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN,
  292. NAMEBAR_RIGHT, NameBarXposn+Image_Widths[NAMEBAR_LEFT],
  293. 426, NO_BOX, spritecopy );
  294. DisplayString( NameBarXposn+Image_Widths[NAMEBAR_RIGHT], 110,
  295. GetTEXT(Team+COUNTRY_NAMES),
  296. LARGE_FONT, 24, TEAM_BOX, &FrontendBackgroundDEFN, &FrontendTextureDEFN );
  297. break;
  298. case( GROUP_FIXTURES ):
  299. CalculateLeagueTables();
  300. DisplayLeagueTables();
  301. DisplayLeagueFixtures( MatchNumber );
  302. DisplayVersusList();
  303. break;
  304. case( TEAM_SELECT ):
  305. DisplayLowerSelectionPanel( EUROgameType );
  306. DisplayCountrySelectImages();
  307. ReadData( BIN_DRAWPAL, &EuroDATfile[0], &SparePaletteBuffer[0] );
  308. memcpy( &PaletteBuffer[44*3], &SparePaletteBuffer[ (LeagueColourOffsets[EUROteamA]*3)+3 ], 7*3 );
  309. memcpy( &PaletteBuffer[51*3], &SparePaletteBuffer[ (LeagueColourOffsets[EUROteamB]*3)+3 ], 7*3 );
  310. break;
  311. case( PLAYER_STATS ):
  312. DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN,
  313. LION_KITS+Team, 550, 2, NO_BOX, spritecopy );
  314. break;
  315. case( PLAYER_SETUP ):
  316. EUROnoOfMatchPlyrs = 2;
  317. DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN,
  318. LION_KITS+EUROteamA, 192, 240, NO_BOX, spritecopy );
  319. svalue = 16;
  320. pmin = 16;
  321. pmax = 32;
  322. DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN,
  323. LION_KITS+EUROteamB, 456, 240, NO_BOX, spriteareainccopy );
  324. DisplayUserLabels(EUROplyrSetup);
  325. break;
  326. case( TEAM_STATS ):
  327. width = PixelLengthOfString( GetTEAMname( EUROstatTeam, 0 ),
  328. LARGE_FONT);
  329. Image_Widths[TSTAT_NAMEBAR_LEFT] = Image_Widths[TSTAT_NAMEBAR_RIGHT]+width;
  330. DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN,
  331. TSTAT_NAMEBAR_LEFT, NameBarXposn,
  332. 106, NO_BOX, spritecopy );
  333. DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN,
  334. TSTAT_NAMEBAR_RIGHT, NameBarXposn+Image_Widths[TSTAT_NAMEBAR_LEFT],
  335. 106, NO_BOX, spritecopy );
  336. DisplayString( NameBarXposn+Image_Widths[TSTAT_NAMEBAR_RIGHT], 110,
  337. GetTEXT(EUROstatTeam+COUNTRY_NAMES),
  338. LARGE_FONT, 36, NO_BOX, &FrontendBackgroundDEFN, &FrontendTextureDEFN );
  339. DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN,
  340. BIG_COUNTRY_STAT_IMG+EUROstatTeam,
  341. TSTATCountryPosnDEFN[EUROstatTeam].xposn,
  342. TSTATCountryPosnDEFN[EUROstatTeam].yposn,
  343. NO_BOX, spritecopy );
  344. DisplayTeamStats();
  345. break;
  346. }
  347. }
  348. //********************************************************************************************************************************
  349. void SetupExtraTexturePages( int MENU )
  350. {
  351. switch ( MENU )
  352. {
  353. case( SQUAD_SELECT ):
  354. LoadTexturePage( BIN_PAGE2,
  355. &EuroDATfile[0],
  356. 2, &FrontendTextureDEFN );
  357. LoadTexturePage( BIN_PAGE3,
  358. &EuroDATfile[0],
  359. 3, &FrontendTextureDEFN );
  360. break;
  361. case( TEAM_SELECT ):
  362. LoadTexturePage( BIN_PAGE4,
  363. &EuroDATfile[0],
  364. 2, &FrontendTextureDEFN );
  365. LoadTexturePage( BIN_PAGE5,
  366. &EuroDATfile[0],
  367. 3, &FrontendTextureDEFN );
  368. LoadTexturePage( BIN_PAGE6,
  369. &EuroDATfile[0],
  370. 4, &FrontendTextureDEFN );
  371. LoadTexturePage( BIN_PAGE7,
  372. &EuroDATfile[0],
  373. 5, &FrontendTextureDEFN );
  374. LoadTexturePage( BIN_PAGE8,
  375. &EuroDATfile[0],
  376. 6, &FrontendTextureDEFN );
  377. LoadTexturePage( BIN_PAGE9,
  378. &EuroDATfile[0],
  379. 7, &FrontendTextureDEFN );
  380. break;
  381. case( EURO_REDRAW ):
  382. LoadTexturePage( BIN_PAGE10,
  383. &EuroDATfile[0],
  384. 2, &FrontendTextureDEFN );
  385. LoadTexturePage( BIN_PAGE11,
  386. &EuroDATfile[0],
  387. 3, &FrontendTextureDEFN );
  388. LoadTexturePage( BIN_PAGE12,
  389. &EuroDATfile[0],
  390. 4, &FrontendTextureDEFN );
  391. break;
  392. case( PLAYER_STATS ):
  393. LoadTexturePage( BIN_PAGE2,
  394. &EuroDATfile[0],
  395. 2, &FrontendTextureDEFN );
  396. LoadTexturePage( BIN_PAGE13,
  397. &EuroDATfile[0],
  398. 3, &FrontendTextureDEFN );
  399. break;
  400. case( PLAYER_SETUP ):
  401. LoadTexturePage( BIN_PAGE13,
  402. &EuroDATfile[0],
  403. 3, &FrontendTextureDEFN );
  404. break;
  405. case( TEAM_STATS ):
  406. LoadTexturePage( BIN_PAGE14,
  407. &EuroDATfile[0],
  408. 4, &FrontendTextureDEFN );
  409. LoadTexturePage( BIN_PAGE15,
  410. &EuroDATfile[0],
  411. 5, &FrontendTextureDEFN );
  412. LoadTexturePage( BIN_PAGE16,
  413. &EuroDATfile[0],
  414. 6, &FrontendTextureDEFN );
  415. break;
  416. }
  417. }
  418. //********************************************************************************************************************************
  419. void __far EUROinterupt(void)
  420. {
  421. float red, green, blue;
  422. if ( LogicState == PALETTE_FADEUP )
  423. {
  424. if ( FadeCounter < 1 || FadeCounter > FADE_COUNTER )
  425. {
  426. float *a;
  427. BYTE *Palette;
  428. a = &DivisionTable[0];
  429. Palette = &PaletteBuffer[0];
  430. FadeCounter = FADE_COUNTER;
  431. for ( int c=0; c < 256; c++ )
  432. {
  433. red = (*(Palette++));
  434. green = (*(Palette++));
  435. blue = (*(Palette++));
  436. (*(a++)) = red / FADE_COUNTER;
  437. (*(a++)) = green / FADE_COUNTER;
  438. (*(a++)) = blue / FADE_COUNTER;
  439. }
  440. memset( CurrentPalette, 0, 768 );
  441. }
  442. float *a;
  443. float *b;
  444. BYTE *Palette;
  445. a = &CurrentPalette[0];
  446. b = &DivisionTable[0];
  447. for ( int c=0; c < 256; c++ )
  448. {
  449. red = (float) (*(a)) + (*(b++));
  450. (*(a++)) = red;
  451. green = (float) (*(a)) + (*(b++));
  452. (*(a++)) = green;
  453. blue = (float) (*(a)) + (*(b++));
  454. (*(a++)) = blue;
  455. outp ( 0x3c8, c );
  456. outp ( 0x3c9, (BYTE) red );
  457. outp ( 0x3c9, (BYTE) green );
  458. outp ( 0x3c9, (BYTE) blue );
  459. }
  460. FadeCounter--;
  461. if ( FadeCounter < 1 )
  462. {
  463. Palette = &PaletteBuffer[0];
  464. for ( int c=0; c < 256; c++ )
  465. {
  466. outp ( 0x3c8, c );
  467. outp ( 0x3c9, (*( Palette++ ) ) );
  468. outp ( 0x3c9, (*( Palette++ ) ) );
  469. outp ( 0x3c9, (*( Palette++ ) ) );
  470. }
  471. float *a;
  472. BYTE *Palette;
  473. a = &CurrentPalette[0];
  474. Palette = &PaletteBuffer[0];
  475. for ( int d=0; d < 256; d++ )
  476. {
  477. red = (*(Palette++));
  478. green = (*(Palette++));
  479. blue = (*(Palette++));
  480. (*(a++)) = red;
  481. (*(a++)) = green;
  482. (*(a++)) = blue;
  483. }
  484. LogicState = RUN_FRONTEND;
  485. FadeCounter = 0;
  486. }
  487. }
  488. else
  489. if ( LogicState == PALETTE_FADEDOWN )
  490. {
  491. if ( FadeCounter < 1 || FadeCounter > FADE_COUNTER )
  492. {
  493. float *a;
  494. float *Palette;
  495. a = &DivisionTable[0];
  496. Palette = &CurrentPalette[0];
  497. FadeCounter = FADE_COUNTER;
  498. for ( int c=0; c < 256; c++ )
  499. {
  500. red = (*(Palette++));
  501. green = (*(Palette++));
  502. blue = (*(Palette++));
  503. (*(a++)) = red / FADE_COUNTER;
  504. (*(a++)) = green / FADE_COUNTER;
  505. (*(a++)) = blue / FADE_COUNTER;
  506. }
  507. }
  508. float *a;
  509. float *b;
  510. BYTE *Palette;
  511. a = &CurrentPalette[0];
  512. b = &DivisionTable[0];
  513. for ( int c=0; c < 256; c++ )
  514. {
  515. red = (float) (*(a)) - (*(b++));
  516. (*(a++)) = red;
  517. green = (float) (*(a)) - (*(b++));
  518. (*(a++)) = green;
  519. blue = (float) (*(a)) - (*(b++));
  520. (*(a++)) = blue;
  521. outp ( 0x3c8, c );
  522. outp ( 0x3c9, (BYTE) red );
  523. outp ( 0x3c9, (BYTE) green );
  524. outp ( 0x3c9, (BYTE) blue );
  525. }
  526. FadeCounter--;
  527. if ( FadeCounter < 1 )
  528. {
  529. for ( int c=0; c < 256; c++ )
  530. {
  531. outp ( 0x3c8, c );
  532. outp ( 0x3c9, 0 );
  533. outp ( 0x3c9, 0 );
  534. outp ( 0x3c9, 0 );
  535. }
  536. memset( CurrentPalette, 0, 768 );
  537. FadeCounter = 0;
  538. LogicState = BLANK_SCREEN;
  539. Finish++;
  540. }
  541. }
  542. if ( LogicState == RUN_FRONTEND )
  543. SelectFrame+= .55;
  544. else
  545. SelectFrame = 0;
  546. }
  547. //********************************************************************************************************************************
  548. void ResetAnimations()
  549. {
  550. for ( short a=0; a < MAX_ANIMATIONS; a++ )
  551. {
  552. Animation_table[a].StartFrame = -1;
  553. Animation_table[a].EndFrame = -1;
  554. Animation_table[a].Counter = 0;
  555. Animation_table[a].AnimationSpeed = 0;
  556. Animation_table[a].Bounding_box = 0;
  557. Animation_table[a].Flags = 0;
  558. Animation_table[a].xposn = 0;
  559. Animation_table[a].yposn = 0;
  560. }
  561. }
  562. //********************************************************************************************************************************
  563. short AddAnimation( int xposn, int yposn, float StartFrame, float EndFrame, float Speed, signed char Box, signed char Flags )
  564. {
  565. short handle = 0;
  566. for ( short a=0; a < MAX_ANIMATIONS; a++ )
  567. {
  568. if ( Animation_table[a].StartFrame==-1 )
  569. {
  570. Animation_table[a].StartFrame = StartFrame;
  571. Animation_table[a].EndFrame = EndFrame;
  572. Animation_table[a].AnimationSpeed = Speed;
  573. Animation_table[a].Bounding_box = Box;
  574. Animation_table[a].Flags = Flags;
  575. Animation_table[a].xposn = xposn;
  576. Animation_table[a].yposn = yposn;
  577. handle = a;
  578. break;
  579. }
  580. }
  581. return(handle);
  582. }
  583. //********************************************************************************************************************************
  584. void ResetBoundingBoxes()
  585. {
  586. for ( short b=0; b < MAX_BOUNDING_BOXES; b++ )
  587. {
  588. Bounding_table[b].BoundingBoxLeft = -1;
  589. Bounding_table[b].BoundingBoxRight = -1;
  590. Bounding_table[b].BoundingBoxTop = -1;
  591. Bounding_table[b].BoundingBoxBottom = -1;
  592. }
  593. }
  594. //********************************************************************************************************************************
  595. signed char GetBoundingBox( short xposn, short yposn )
  596. {
  597. signed char box = -1;
  598. for ( int b=0; b < MAX_BOUNDING_BOXES; b++ )
  599. {
  600. if ( xposn > Bounding_table[b].BoundingBoxLeft
  601. && xposn < Bounding_table[b].BoundingBoxRight
  602. && yposn > Bounding_table[b].BoundingBoxTop
  603. && yposn < Bounding_table[b].BoundingBoxBottom)
  604. box = b;
  605. }
  606. return(box);
  607. }
  608. //********************************************************************************************************************************