EURO_GRF.CPP 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <conio.h>
  5. #include <math.h>
  6. #include "eurodefs.h"
  7. #include "euro_fxd.h"
  8. #include "euro.equ"
  9. #include "euro_sym.h"
  10. #include "euro_def.h"
  11. #include "euro_var.h"
  12. #include "euro_gen.h"
  13. #include "euro_dsk.h"
  14. #include "euro_int.h"
  15. #include "3deng.h"
  16. //#include "video.h"
  17. extern int testVESA;
  18. extern int VESAmode(int *);
  19. extern void near svgacpy( char unsigned near *, short, short, short, short, short );
  20. extern short GetSwitch( char *buf );
  21. //********************************************************************************************************************************
  22. void straightcopy(int copyWidth, BYTE *dest, BYTE *srce)
  23. {
  24. int x;
  25. BYTE pixel;
  26. for (x=0; x < copyWidth; x++)
  27. *dest++ = *srce++;
  28. }
  29. void spritecopy(int copyWidth, BYTE *dest, BYTE *srce)
  30. {
  31. int x;
  32. BYTE pixel;
  33. for (x=0; x < copyWidth; x++)
  34. {
  35. pixel = *srce++;
  36. if (pixel)
  37. *dest = pixel;
  38. dest++;
  39. }
  40. }
  41. void flipsprcopy(int copyWidth, BYTE *dest, BYTE *srce)
  42. {
  43. int x;
  44. BYTE pixel;
  45. srce+= (copyWidth-1);
  46. for (x=0; x < copyWidth; x++)
  47. {
  48. pixel = *srce--;
  49. if (pixel)
  50. *dest = pixel;
  51. dest++;
  52. }
  53. }
  54. void spriteinccopy(int copyWidth, BYTE *dest, BYTE *srce)
  55. {
  56. int x;
  57. BYTE pixel;
  58. for (x=0; x < copyWidth; x++)
  59. {
  60. pixel = *srce++;
  61. if (pixel)
  62. *dest = (pixel+svalue);
  63. dest++;
  64. }
  65. }
  66. void spriteareainccopy(int copyWidth, BYTE *dest, BYTE *srce)
  67. { // if a pixel falls within 'pmin' & 'pmax' then
  68. int x; // it is increased by 'svalue'.
  69. BYTE pixel;
  70. for (x=0; x < copyWidth; x++)
  71. {
  72. pixel = *srce++;
  73. if (pixel)
  74. {
  75. if ( pixel >= pmin && pixel < pmax )
  76. *dest = (pixel+svalue);
  77. else
  78. *dest = pixel;
  79. }
  80. dest++;
  81. }
  82. }
  83. void spritefilter(int copyWidth, BYTE *dest, BYTE *srce)
  84. {
  85. int x;
  86. BYTE pixel;
  87. for (x=0; x < copyWidth; x++)
  88. {
  89. pixel = *srce++;
  90. if (pixel)
  91. {
  92. pixel = *dest;
  93. *dest = ftable[pixel];
  94. }
  95. dest++;
  96. }
  97. }
  98. void pseudostore(int copyWidth, BYTE *dest, BYTE *srce)
  99. {
  100. int x;
  101. BYTE pixel;
  102. for (x=0; x < copyWidth; x++)
  103. {
  104. pixel = *dest++;
  105. *srce = pixel;
  106. srce++;
  107. }
  108. }
  109. //********************************************************************************************************************************
  110. void DrawIMAGE( pseudo_info *pseudo, texture_info *texture, int image_no, int xpos, int ypos, signed char box, copyfunctiontype copyfunction )
  111. {
  112. BYTE *dest = pseudo->pseudo_start + (ypos * pseudo->pseudo_width) + xpos;
  113. BYTE *srce = texture->page_start + (texture->page_width*texture->page_height*Image_Pages[image_no] ) +
  114. ( (texture->page_width * Image_Ycoords[image_no] ) + Image_Xcoords[image_no] );
  115. int copyWidth = Min( Image_Widths[image_no], pseudo->window_width-xpos);
  116. int copyHigh = Min( Image_Heights[image_no], pseudo->window_height-ypos);
  117. if ( copyWidth < 0 || copyHigh < 0 ) return;
  118. if ( box>=0 )
  119. {
  120. if ((xpos < Bounding_table[(box)].BoundingBoxLeft) || Bounding_table[(box)].BoundingBoxLeft == -1)
  121. Bounding_table[(box)].BoundingBoxLeft = (short) xpos;
  122. if ((ypos < Bounding_table[(box)].BoundingBoxTop) || Bounding_table[(box)].BoundingBoxTop == -1)
  123. Bounding_table[(box)].BoundingBoxTop = (short) ypos;
  124. }
  125. int destAddn = pseudo->pseudo_width;
  126. int srceAddn = texture->page_width;
  127. int y;
  128. for (y=0; y < copyHigh; y++)
  129. {
  130. copyfunction( copyWidth, dest, srce );
  131. dest+= destAddn;
  132. srce+= srceAddn;
  133. }
  134. if ( box>=0 )
  135. {
  136. if ( ( (xpos+Image_Widths[image_no]) > Bounding_table[(box)].BoundingBoxRight) ||
  137. Bounding_table[(box)].BoundingBoxRight == -1)
  138. Bounding_table[(box)].BoundingBoxRight = ( (short) xpos+Image_Widths[image_no] );
  139. if ( ( (ypos+Image_Heights[image_no]) > Bounding_table[(box)].BoundingBoxBottom) ||
  140. Bounding_table[(box)].BoundingBoxBottom == -1)
  141. Bounding_table[(box)].BoundingBoxBottom = ( (short) ypos+Image_Heights[image_no]);
  142. }
  143. }
  144. //********************************************************************************************************************************
  145. void StorePSEUDObuffer( pseudo_info *pseudo, texture_info *texture, int image_no, int xpos, int ypos )
  146. {
  147. BYTE *srce = pseudo->pseudo_start + (ypos * pseudo->pseudo_width) + xpos;
  148. BYTE *dest = texture->page_start + (texture->page_width*texture->page_height*Image_Pages[image_no] ) +
  149. ( (texture->page_width * Image_Ycoords[image_no] ) + Image_Xcoords[image_no] );
  150. int copyWidth = Image_Widths[image_no];
  151. int copyHigh = Image_Heights[image_no];
  152. if ( copyWidth < 0 || copyHigh < 0 ) return;
  153. int srceAddn = pseudo->pseudo_width-copyWidth;
  154. int destAddn = texture->page_width-copyWidth;
  155. int y;
  156. for (y=0; y < copyHigh; y++)
  157. {
  158. int x;
  159. BYTE pixel;
  160. for (x=0; x < copyWidth; x++)
  161. {
  162. pixel = *srce++;
  163. *dest = pixel;
  164. dest++;
  165. }
  166. srce+= srceAddn;
  167. dest+= destAddn;
  168. }
  169. }
  170. //********************************************************************************************************************************
  171. void CopyFromBACKtoPSEUDObuffer( pseudo_info *pseudo, pseudo_info *background, int xpos, int ypos, short width, short height )
  172. {
  173. BYTE *dest = pseudo->pseudo_start + (ypos * pseudo->pseudo_width) + xpos;
  174. BYTE *srce = background->pseudo_start + (ypos * background->pseudo_width) + xpos;
  175. int srceAddn = background->pseudo_width-width;
  176. int destAddn = pseudo->pseudo_width-width;
  177. int y;
  178. for (y=0; y < height; y++)
  179. {
  180. int x;
  181. BYTE pixel;
  182. for (x=0; x < width; x++)
  183. {
  184. pixel = *srce++;
  185. *dest = pixel;
  186. dest++;
  187. }
  188. srce+= srceAddn;
  189. dest+= destAddn;
  190. }
  191. }
  192. //********************************************************************************************************************************
  193. void CopyDumpListToScreen()
  194. {
  195. for (short d=0; d<MAX_DUMPS; d++)
  196. {
  197. if ( Dump_list[d].DumpFlag!=0 )
  198. {
  199. svgacpy( (unsigned char *) EuroPseudoBuffer+((640*Dump_list[d].DumpYpos)+
  200. Dump_list[d].DumpXpos),
  201. Dump_list[d].DumpXpos , Dump_list[d].DumpYpos,
  202. Dump_list[d].DumpWidth , Dump_list[d].DumpHeight,
  203. 640);
  204. Dump_list[d].DumpFlag = 0;
  205. }
  206. }
  207. }
  208. //********************************************************************************************************************************
  209. void DisplayString( int xpos, int ypos, char *string, int font, int colour, signed char box, pseudo_info *pseudo, texture_info *texture )
  210. {
  211. int c;
  212. svalue = colour;
  213. while ( c=*(string++) )
  214. {
  215. c = ASCtoImageTBL[c];
  216. c+= font;
  217. DrawIMAGE( pseudo, texture, c, xpos, ypos, box, spriteinccopy );
  218. xpos+= (Image_Widths[c])+1;
  219. }
  220. NextXposn = xpos;
  221. }
  222. //********************************************************************************************************************************
  223. int PixelLengthOfString( char *string, int font )
  224. {
  225. int c;
  226. int len = 0;
  227. while ( c=*(string++) )
  228. {
  229. c = ASCtoImageTBL[c];
  230. c+= font;
  231. len+= (Image_Widths[c])+1;
  232. }
  233. return(len);
  234. }
  235. //********************************************************************************************************************************
  236. void AddToDumpList(short X,short Y,short W,short H)
  237. {
  238. for (short a=0; a<MAX_DUMPS; a++)
  239. {
  240. if (Dump_list[a].DumpFlag==0 )
  241. {
  242. Dump_list[a].DumpXpos = X;
  243. Dump_list[a].DumpYpos = Y;
  244. Dump_list[a].DumpWidth = W;
  245. Dump_list[a].DumpHeight = H;
  246. Dump_list[a].DumpFlag = 1;
  247. break;
  248. }
  249. }
  250. }
  251. //********************************************************************************************************************************
  252. void ClearDumpList()
  253. {
  254. for (short c=0; c<MAX_DUMPS; c++)
  255. Dump_list[c].DumpFlag = 0;
  256. }
  257. //********************************************************************************************************************************
  258. void CreateFilter( BYTE *FilterTable, char fr, char fg, char fb, float mr, float mg, float mb )
  259. {
  260. signed short r1,g1,b1,r2,g2,b2;
  261. signed short x,s,c,l1,l2,d1,d2;
  262. if ((l1=sqrt(fr*fr+fg*fg+fb*fb))==0) l1=1;
  263. for (x=0;x<768;x+=3)
  264. {
  265. l2=sqrt(PaletteBuffer[x]*PaletteBuffer[x]+PaletteBuffer[x+1]*
  266. PaletteBuffer[x+1]+PaletteBuffer[x+2]*PaletteBuffer[x+2]);
  267. r1=PaletteBuffer[x]+mr*(fr*l2/l1-PaletteBuffer[x]);
  268. if (r1<0) r1=0;if (r1>255) r1=255;
  269. g1=PaletteBuffer[x+1]+mg*(fg*l2/l1-PaletteBuffer[x+1]);
  270. if (g1<0) g1=0;if (g1>255) g1=255;
  271. b1=PaletteBuffer[x+2]+mb*(fb*l2/l1-PaletteBuffer[x+2]);
  272. if (b1<0) b1=0;if (b1>255) b1=255;
  273. r1=(fr-PaletteBuffer[x])*mr+PaletteBuffer[x];
  274. g1=(fg-PaletteBuffer[x+1])*mg+PaletteBuffer[x+1];
  275. b1=(fb-PaletteBuffer[x+2])*mb+PaletteBuffer[x+2];
  276. d1=128;
  277. for (s=0;s<768-16*3;s+=3)
  278. {
  279. r2=(PaletteBuffer[s]-r1);
  280. g2=(PaletteBuffer[s+1]-g1);
  281. b2=(PaletteBuffer[s+2]-b1);
  282. d2=sqrt(r2*r2+g2*g2+b2*b2);
  283. if (d2<d1) d1=d2,c=s;
  284. }
  285. FilterTable[x/3]=c/3;
  286. }
  287. }
  288. //********************************************************************************************************************************
  289. void ControlAnimations()
  290. {
  291. signed char BOX;
  292. int width, height;
  293. for ( short a=0; a < MAX_ANIMATIONS; a++ )
  294. {
  295. BOX = Animation_table[a].Bounding_box;
  296. if ( Animation_table[a].StartFrame != -1 )
  297. {
  298. if ( Animation_table[a].Flags != 0 && BOX != NO_BOX )
  299. {
  300. width = Bounding_table[BOX].BoundingBoxRight -
  301. Bounding_table[BOX].BoundingBoxLeft;
  302. height = Bounding_table[BOX].BoundingBoxBottom -
  303. Bounding_table[BOX].BoundingBoxTop;
  304. CopyFromBACKtoPSEUDObuffer(
  305. &FrontendPseudoDEFN, &FrontendBackgroundDEFN,
  306. Bounding_table[BOX].BoundingBoxLeft,
  307. Bounding_table[BOX].BoundingBoxTop,
  308. width, height );
  309. AddToDumpList(
  310. (short)Bounding_table[BOX].BoundingBoxLeft,
  311. (short)Bounding_table[BOX].BoundingBoxTop,
  312. (short)width, height );
  313. }
  314. Animation_table[a].Counter+= Animation_table[a].AnimationSpeed;
  315. if ( Animation_table[a].AnimationSpeed > 0 &&
  316. (Animation_table[a].StartFrame + Animation_table[a].Counter) > Animation_table[a].EndFrame )
  317. {
  318. if ( (Animation_table[a].Flags & CONT_ANIM) == CONT_ANIM )
  319. {
  320. Animation_table[a].Counter-= (Animation_table[a].EndFrame-Animation_table[a].StartFrame);
  321. }
  322. else
  323. {
  324. Animation_table[a].Counter = 0;
  325. Animation_table[a].AnimationSpeed = 0;
  326. }
  327. }
  328. if ( Animation_table[a].AnimationSpeed < 0 &&
  329. (Animation_table[a].StartFrame + Animation_table[a].Counter) < Animation_table[a].StartFrame )
  330. {
  331. Animation_table[a].Counter+= Animation_table[a].EndFrame-Animation_table[a].StartFrame;
  332. }
  333. if ( Animation_table[a].AnimationSpeed < 0
  334. && Animation_table[a].Counter > 0
  335. && Animation_table[a].Counter + Animation_table[a].AnimationSpeed < 0
  336. && ( (Animation_table[a].Flags & CONT_ANIM) == RUN_ONCE )
  337. )
  338. {
  339. Animation_table[a].Counter = 0;
  340. Animation_table[a].AnimationSpeed = 0;
  341. }
  342. DrawIMAGE( &FrontendPseudoDEFN, &FrontendTextureDEFN,
  343. ((int)(Animation_table[a].StartFrame+Animation_table[a].Counter)),
  344. Animation_table[a].xposn,
  345. Animation_table[a].yposn,
  346. BOX,
  347. spritecopy );
  348. Animation_table[a].Flags|= 1;
  349. width = Image_Widths[( (int) (Animation_table[a].StartFrame+Animation_table[a].Counter) )];
  350. height = Image_Heights[( (int) (Animation_table[a].StartFrame+Animation_table[a].Counter) )];
  351. AddToDumpList( (short)Animation_table[a].xposn,
  352. (short)Animation_table[a].yposn,
  353. (short)width, (short)height );
  354. }
  355. }
  356. }
  357. //********************************************************************************************************************************
  358. int MenuBitmaps[32]={
  359. {BIN_MAIN}, {BIN_MAIN}, {BIN_TEAMSET}, {BIN_GRP_FIX},
  360. {BIN_TEAMSEL}, {BIN_EURODRAW}, {BIN_PLYRSTAT}, {BIN_PLYRSET},
  361. {BIN_TEAMSTAT}, {BIN_VENUEFLY}, {BIN_MODEMINI}, {BIN_NEXTMTCH},
  362. {BIN_QUALIFY}, {BIN_QUARTFIN}, {BIN_SEMIFINL}, {BIN_FINAL},
  363. {BIN_MAIN}, {BIN_MAIN}, {BIN_MAIN}, {BIN_MAIN},
  364. {BIN_MAIN}, {BIN_MAIN}, {BIN_MAIN}, {BIN_MAIN},
  365. {BIN_MAIN}, {BIN_MAIN}, {BIN_MAIN}, {BIN_MAIN},
  366. {BIN_MAIN}, {BIN_MAIN}, {BIN_MAIN}, {BIN_MAIN},
  367. };
  368. int MenuPalettes[32]={
  369. {BIN_MAINPAL}, {BIN_MAINPAL}, {BIN_TSETPAL}, {BIN_GFIXPAL},
  370. {BIN_TSELPAL}, {BIN_DRAWPAL}, {BIN_PSTATPAL}, {BIN_PSETPAL},
  371. {BIN_TSTATPAL}, {BIN_VNFLYPAL}, {BIN_MDSETPAL}, {BIN_NMTCHPAL},
  372. {BIN_QUALYPAL}, {BIN_QUTFNPAL}, {BIN_SEMFPAL}, {BIN_FINALPAL},
  373. {BIN_MAINPAL}, {BIN_MAINPAL}, {BIN_MAINPAL}, {BIN_MAINPAL},
  374. {BIN_MAINPAL}, {BIN_MAINPAL}, {BIN_MAINPAL}, {BIN_MAINPAL},
  375. {BIN_MAINPAL}, {BIN_MAINPAL}, {BIN_MAINPAL}, {BIN_MAINPAL},
  376. {BIN_MAINPAL}, {BIN_MAINPAL}, {BIN_MAINPAL}, {BIN_MAINPAL},
  377. };
  378. int FormationPalettes[16]={
  379. {BIN_FBGREEN}, {BIN_FDORAN}, {BIN_FRED}, {BIN_FRED},
  380. {BIN_FBBLUE}, {BIN_FLBLUE}, {BIN_FRED}, {BIN_FBORAN},
  381. {BIN_FBBLUE}, {BIN_FRED}, {BIN_FRED}, {BIN_FBBLUE},
  382. {BIN_FBBLUE}, {BIN_FRED}, {BIN_FRED}, {BIN_FRED},
  383. };
  384. char LeagueColourOffsets[16]={
  385. 43, 78, 64, 64, 15, 71, 15, 57, 36, 64, 50, 15, 71, 64, 64, 15,
  386. };
  387. //********************************************************************************************************************************
  388. void DisplayBackground( int MENU )
  389. {
  390. LoadTexturePage( MenuBitmaps[ MENU ],
  391. &EuroDATfile[0],
  392. 1, &FrontendTextureDEFN );
  393. LoadPalette( MenuPalettes[ MENU ],
  394. &EuroDATfile[0], 0 );
  395. LoadPalette( BIN_MOUSEPAL,
  396. &EuroDATfile[0], 0 );
  397. switch ( MENU )
  398. {
  399. case( SQUAD_SELECT ):
  400. LoadPalette( BIN_BUL_PAL+( 8*Team ),
  401. &EuroDATfile[0], 16 );
  402. LoadPalette( FormationPalettes[Team],
  403. &EuroDATfile[0], 32 );
  404. CreateFilter( &FilterBuffer[0], 16, 16, 16, .35, .35, .35 );
  405. ftable = FilterBuffer;
  406. break;
  407. case( PLAYER_STATS ):
  408. LoadPalette( BIN_BUL_PAL+( 8*Team ),
  409. &EuroDATfile[0], 16 );
  410. LoadPalette( FormationPalettes[Team],
  411. &EuroDATfile[0], 32 );
  412. break;
  413. case( TEAM_SELECT ):
  414. CreateFilter( &FilterBuffer[0], 40, 54, 60, .8, .8, .8);
  415. break;
  416. case( PLAYER_SETUP ):
  417. LoadPalette( BIN_BUL_PAL+( 8*EUROteamA ),
  418. &EuroDATfile[0], 16 );
  419. LoadPalette( BIN_BUL_PAL+( 8*EUROteamB ),
  420. &EuroDATfile[0], 32 );
  421. break;
  422. case( TEAM_STATS ):
  423. LoadPalette( BIN_TBUL_PAL+( 8*EUROstatTeam ),
  424. &EuroDATfile[0], 37 );
  425. LoadPalette( BIN_CBUL_PAL+( 8*EUROstatTeam ),
  426. &EuroDATfile[0], 132 );
  427. break;
  428. }
  429. DrawIMAGE( &FrontendBackgroundDEFN, &FrontendTextureDEFN, BACKGROUNDimge, 0, 0, NO_BOX, straightcopy );
  430. }
  431. //********************************************************************************************************************************
  432. void Set_palette_to_black()
  433. {
  434. for (short i=0;i<256;i++)
  435. {
  436. outp (0x3c8,i);
  437. outp (0x3c9,0);
  438. outp (0x3c9,0);
  439. outp (0x3c9,0);
  440. }
  441. memset( CurrentPalette, 0, 768 );
  442. }
  443. //********************************************************************************************************************************
  444. short ControlSlider( slider_info *slider, short xposn, short yposn, short buttons )
  445. {
  446. float offset;
  447. CopyFromBACKtoPSEUDObuffer(
  448. &FrontendPseudoDEFN, &FrontendBackgroundDEFN,
  449. slider->minx-6, slider->miny-9,
  450. Image_Widths[SLDR_CURS], slider->maxy-slider->miny+Image_Heights[SLDR_CURS] );
  451. if ( xposn > (slider->minx-16)
  452. && xposn < (slider->maxx+16)
  453. && yposn > slider->miny-8
  454. && yposn < slider->maxy+8 && buttons != 0 )
  455. {
  456. if ( yposn < slider->maxy )
  457. {
  458. if ( yposn < slider->miny )
  459. slider->windowposn = 0;
  460. else
  461. slider->windowposn = yposn-slider->miny;
  462. }
  463. else
  464. slider->windowposn = slider->maxy-slider->miny;
  465. }
  466. DrawIMAGE( &FrontendPseudoDEFN, &FrontendTextureDEFN, SLDR_CURS,
  467. (slider->minx-6), ( (slider->windowposn+slider->miny)-9),
  468. NO_BOX, spritecopy );
  469. AddToDumpList( (slider->minx-6), (slider->miny-9),
  470. Image_Widths[SLDR_CURS], slider->maxy-slider->miny+Image_Heights[SLDR_CURS] );
  471. offset = (((float)(slider->elements-slider->page_elements))/
  472. ((float)(slider->maxy-slider->miny)))*
  473. ((float)slider->windowposn);
  474. return( (short)offset );
  475. }
  476. //********************************************************************************************************************************
  477. void Set_640x480_VideoMode()
  478. {
  479. // set the video mode to mode 101 (640x480).
  480. testVESA = 0;
  481. EuroVideoStatus = VESAmode( &EUROvideoMode[0] );
  482. }
  483. //********************************************************************************************************************************
  484. void Test_640x480_VideoMode()
  485. {
  486. // tests for video mode 101 (640x480).
  487. testVESA = 1;
  488. EuroVideoStatus = VESAmode( &EUROvideoMode[0] );
  489. if ( EuroVideoStatus == -1 )
  490. printf("þ Video mode unavailable.\n");
  491. else
  492. printf("þ Video mode initialised.\n");
  493. }
  494. //********************************************************************************************************************************
  495. //
  496. // BUTTON HIGHLIGHT CONTROLLER:
  497. //
  498. // Entry: BOX Normal BOX value.
  499. // CHKBOX1 First box to be checked (button box).
  500. // CHKBOX2 Second box to be checked (text display box).
  501. // HIGH Current highlight value ( -1, 15 or 29 ). A change in HIGH value from previous
  502. // HIGH value means string is to be reprinted.
  503. // BUTHANDLE Handle variable used for this selection button.
  504. //
  505. //
  506. //
  507. // Returns: New Highlight value.
  508. //
  509. //
  510. //
  511. //
  512. #define textxoff 52
  513. #define textyoff 8
  514. char ControlOptionHighlight( signed char BOX, signed char CHKBOX1, signed char CHKBOX2,
  515. char HIGH, short BUTHANDLE, short TEXT )
  516. {
  517. char PAL = -1;
  518. if ( BOX == CHKBOX1 || BOX == CHKBOX2 )
  519. PAL = OVERRIDEpal1;
  520. else
  521. PAL = OVERRIDEpal2;
  522. if ( PAL != HIGH )
  523. {
  524. CopyFromBACKtoPSEUDObuffer( &FrontendPseudoDEFN, &FrontendBackgroundDEFN,
  525. Bounding_table[ CHKBOX1 ].BoundingBoxRight,
  526. Animation_table[BUTHANDLE].yposn+textyoff,
  527. 639-Bounding_table[ CHKBOX1 ].BoundingBoxRight, 28 );
  528. DisplayString(
  529. Animation_table[BUTHANDLE].xposn+textxoff,
  530. Animation_table[BUTHANDLE].yposn+textyoff,
  531. GetTEXT ( TEXT ),
  532. MEDIUM_FONT, (int)PAL, CHKBOX2, &FrontendPseudoDEFN, &FrontendTextureDEFN );
  533. AddToDumpList(
  534. Bounding_table[ CHKBOX1 ].BoundingBoxRight,
  535. Animation_table[BUTHANDLE].yposn+textyoff,
  536. 639-Bounding_table[ CHKBOX1 ].BoundingBoxRight, 28 );
  537. }
  538. Bounding_table[ CHKBOX2 ].BoundingBoxLeft =
  539. Bounding_table[ CHKBOX1 ].BoundingBoxRight;
  540. OVERRIDEpal1 = 15;
  541. OVERRIDEpal2 = 29;
  542. HIGH = PAL;
  543. return(HIGH);
  544. }
  545. //********************************************************************************************************************************
  546. char *LowerCaseString( char *string )
  547. {
  548. char Searchlen = strlen(&string[0]);
  549. for ( char x=1; x<Searchlen ; x++ )
  550. {
  551. if ( *(string+(x-1))!=' ' )
  552. *(string+x) = ToLower[*(string+x)];
  553. }
  554. return(string);
  555. }
  556. //********************************************************************************************************************************
  557. char *GetTEAMname( char team, char maxlen )
  558. {
  559. char *Name = GetTEXT( TEAM_NMES+team );
  560. char Searchlen = strlen(&Name[0]);
  561. char NAMEoffset = 0;
  562. for ( char x=0; x<Searchlen ; x++ )
  563. {StringBuffer[x] = * (Name+x);}
  564. StringBuffer[x] = 0;
  565. if ( maxlen!=0 && Searchlen > maxlen )
  566. {
  567. StringBuffer[maxlen-1] = '.';
  568. StringBuffer[maxlen] = 0;
  569. }
  570. return ( &StringBuffer[0] );
  571. }
  572. //********************************************************************************************************************************
  573. short GetTemplete( char *buf, short soff )
  574. {
  575. char Toffset = 0;
  576. if ( buf[soff] == '?' )
  577. {
  578. soff++;
  579. while ( buf[soff]!=' ' )
  580. {
  581. Templete[Toffset] = buf[soff];
  582. if (Toffset<127)
  583. Toffset++;
  584. soff++;
  585. }
  586. Templete[Toffset] = 0;
  587. strupr( Templete );
  588. }
  589. return(soff);
  590. }
  591. //********************************************************************************************************************************
  592. char *StringTemplete( short text, char flagA )
  593. {
  594. short soff = 0; // input string.
  595. char *string = GetTEXT( text );
  596. char Build[128];
  597. BuildBuffer[0] = 0;
  598. while ( string[soff]!=0 )
  599. {
  600. Build[0] = 0;
  601. if ( string[soff] == '?' )
  602. {
  603. soff = GetTemplete( &string[0], soff );
  604. if ( !strcmp( Templete, "WINTEAM") )
  605. strcpy( Build, LowerCaseString(GetTEAMname( Results[flagA].WinningTeam, 11)));
  606. if ( !strcmp( Templete, "WINPENS") )
  607. {
  608. if ( Results[flagA].HomePens > Results[flagA].AwayPens )
  609. itoa( (int)Results[flagA].HomePens, Build, 10);
  610. else
  611. itoa( (int)Results[flagA].AwayPens, Build, 10);
  612. }
  613. if ( !strcmp( Templete, "LOSEPENS") )
  614. {
  615. if ( Results[flagA].HomePens < Results[flagA].AwayPens )
  616. itoa( (int)Results[flagA].HomePens, Build, 10);
  617. else
  618. itoa( (int)Results[flagA].AwayPens, Build, 10);
  619. }
  620. strcat( BuildBuffer, Build);
  621. }
  622. else
  623. {
  624. Build[0] = * (string+soff);
  625. Build[1] = 0;
  626. strcat( BuildBuffer, Build);
  627. soff++;
  628. }
  629. }
  630. return( &BuildBuffer[0] );
  631. }
  632. //********************************************************************************************************************************