1 /*--------------------------------------------------------------------------
2
3 REVERSEM :
4
5 UNIT : GRAPHICS CONTROL
6
7 Most of the methods used here are not very 'C++' like. They were used in
8 development of the game Anarchy (ok, continuing development, it will be
9 released in Jan 95). Hey. It's an AI class; so, a bit of code reuse
10 did me well.
11
12 COPYRIGHT (C) 1994 Erich P. Gatejen ALL RIGHTS RESERVED
13 This is Freeware. You may distribute it as you wish. However, you may not
14 distribute a modified version without my consent.
15
16 Feel free to cut and paste any algorthm.
17
18 NOTE: XTILE is (C) 1992, 1994 by myself. It is NOT freeware. You may use
19 it for personal projects, but otherwise, it is not to be distributed
20 outside this REVERSEM package. (Contact me if you wish to do
21 otherwise)
22
23 ---------------------------------------------------------------------------*/
24
25 // ------------------------------------------------------------------------
26 // --- INCLUDES
27 // ------------------------------------------------------------------------
28 #include<stdlib.h>
29 #include<stdio.h>
30 extern "C" {
31 #include "xtile21!.h"
32 };
33 #include<alloc.h>
34 #include<string.h>
35 #include"reversem.hpp"
36 #include"spots.hpp"
37 #include"board.hpp"
38 #include"eval.hpp"
39 #include"graphics.hpp"
40
41 #include"conio.h"
42
43 // ------------------------------------------------------------------------
44 // --- GRAPHICS DEFINEs
45 // ------------------------------------------------------------------------
46 #define MAIN_PAGE PAGE1
47
48 #define MOUSE_EVENTS (XLEFT_BUTTON | XRIGHT_BUTTON)
49
50 #define FONT_4_SIZE 192
51
52 #define BRAIN_BUTTONSX 4
53 #define BRAIN_BUTTONSY 177
54 #define BRAIN_BUTTONXSIZE 52
55 #define BRAIN_BUTTONYSIZE 20
56 #define BRAIN_BUTTONXSEP 50
57
58 #define MAIN_BUTTONSX 152
59 #define MAIN_BUTTONSY 0
60 #define MAIN_BUTTONSXSIZE 56
61 #define MAIN_BUTTONSYSIZE 20
62
63 #define POPUP_XSIZE 104
64 #define POPUP_YSIZE 32
65
66 #define BOARDX 116
67 #define BOARDY 32
68
69 #define SPOT_XYSIZE 24
70 #define SPOT_TRIMXSIZE 20
71 #define SPOT_TRIMYSIZE 17
72 #define SPOT_TRIMX 4
73 #define SPOT_TRIMY 5
74
75 #define SCORE_X 112
76 #define SCORE_Y 13
77 #define SCORE_XSIZE 32
78 #define SCORE_YSIZE 5
79 #define SCORE_COLOR 15
80
81
82 // ------------------------------------------------------------------------
83 // --- TGA offsets ( a hold over from Anarchy method )
84 // ------------------------------------------------------------------------
85
86 // -- TGA set for main load ----
87 #define PREP_MOUSE_DATA_SIZE 256
88 #define PREP_MOUSE_DATA_SITE 0
89
90 #define PREP_MOUSE_MASK_SIZE 64
91 #define PREP_MOUSE_MASK_SITE (PREP_MOUSE_DATA_SITE + PREP_MOUSE_DATA_SIZE)
92
93 #define WAIT_MOUSE_DATA_SIZE 256
94 #define WAIT_MOUSE_DATA_SITE (PREP_MOUSE_MASK_SITE + PREP_MOUSE_MASK_SIZE)
95
96 #define WAIT_MOUSE_MASK_SIZE 64
97 #define WAIT_MOUSE_MASK_SITE (WAIT_MOUSE_DATA_SITE + WAIT_MOUSE_DATA_SIZE)
98
99 #define MAIN_PAL_SIZE 768
100 #define MAIN_PAL_SITE (WAIT_MOUSE_MASK_SITE + WAIT_MOUSE_MASK_SIZE)
101
102 #define SPOT_SIZE 576
103 #define SPOT_SITE (MAIN_PAL_SITE + MAIN_PAL_SIZE)
104
105 #define HERE_SIZE 576
106 #define HERE_SITE (SPOT_SITE + SPOT_SIZE)
107
108 #define OK_SIZE 576
109 #define OK_SITE (HERE_SITE + HERE_SIZE)
110
111 #define BLACK_SPOTS_EACH 340
112 #define BLACK_SPOTS_SIZE (BLACK_SPOTS_EACH * 6)
113 #define BLACK_SPOTS_SITE (OK_SITE + OK_SIZE)
114
115 #define WHITE_SPOTS_EACH 340
116 #define WHITE_SPOTS_SIZE (WHITE_SPOTS_EACH * 6)
117 #define WHITE_SPOTS_SITE (BLACK_SPOTS_SITE + BLACK_SPOTS_SIZE)
118
119 #define MUST_PASS_SIZE 3328
120 #define MUST_PASS_SITE (WHITE_SPOTS_SITE + WHITE_SPOTS_SIZE)
121
122 #define WHO_1ST_SIZE 3328
123 #define WHO_1ST_SITE (MUST_PASS_SITE + MUST_PASS_SIZE)
124
125 #define YOU_SURE_SIZE 3328
126 #define YOU_SURE_SITE (WHO_1ST_SITE + WHO_1ST_SIZE)
127
128 #define BRAIN_BUTTON_EACH 1040
129 #define BRAIN_BUTTON_SIZE (BRAIN_BUTTON_EACH * 6)
130 #define BRAIN_BUTTON_SITE (YOU_SURE_SITE + YOU_SURE_SIZE)
131
132 #define BRAIN_BPUSHED_SITE (BRAIN_BUTTON_SITE + BRAIN_BUTTON_SIZE)
133
134 #define MAIN_BUTTON_EACH 1120
135 #define MAIN_BUTTON_SIZE (MAIN_BUTTON_EACH * 3)
136 #define MAIN_BUTTON_SITE (BRAIN_BPUSHED_SITE + BRAIN_BUTTON_SIZE)
137
138 #define MAIN_BPUSHED_SITE (MAIN_BUTTON_SITE + MAIN_BUTTON_SIZE)
139
140 #define LOAD1_SIZE (MAIN_BPUSHED_SITE + MAIN_BUTTON_SIZE)
141
142 #define POPUP_RELOAD_SITE LOAD1_SIZE
143
144 #define SCORE_RELOAD_SITE (POPUP_RELOAD_SITE + WHO_1ST_SIZE)
145
146
147 #define MAIN_SCREEN_FILE_SITE 36400
148
149
150
151 // ------------------------------------------------------------------------
152 // --- DATA
153 // ------------------------------------------------------------------------
154
155 // --- The TGA
156 char *TGA;
157
158 // --- TGA Hooks
159 char *White_Spots;
160 char *Black_Spots;
161
162 // --- The Main Graphics File
163 FILE *MainGFile;
164
165 // --- Mouse data
166 unsigned int Mouse_Data_Ready;
167 unsigned int MouseX;
168 unsigned int MouseY;
169 unsigned int Mouse_Flags;
170
171
172 // --- Data for the 4-pix font
173 char Font4[FONT_4_SIZE];
174
175
176
177 // ------------------------------------------------------------------------
178 // --- SPECIAL MOUSE HANDLER FUNCTIONS AND MEMBERS
179 // ------------------------------------------------------------------------
180
181 // The declaration of this function MUST NOT be changed for it to work
182 // with XTile.
183 void GMouse_Handler( unsigned int X,
184 unsigned int Y,
185 unsigned int Event_Mask ) {
186
187 Mouse_Data_Ready = TRUE;
188 MouseX = X;
189 MouseY = Y;
190 Mouse_Flags = Event_Mask;
191
192 };
193
194 int GraphicsControl::MouseView ( void ) {
195 /* View a fleet screen and wait an event */
196
197 unsigned int X, Y, Temp; /* Last known mouse locations */
198
199 Mouse_Data_Ready = FALSE;
200 XWhere_Mouse( &X, &Y );
201 XMouse_Active( MOUSE_EVENTS, X, Y, NORMALPAGE );
202
203
204 /* Wait until the mouse button is pressed or a key */
205 while ((Mouse_Data_Ready == FALSE)&&( kbhit() == 0)) {
206
207 }
208
209 /* Turn mouse off */
210 XMouse_InActive();
211
212 if ( kbhit() ) {
213 Temp = getch();
214 if (Temp == NULL) Temp = getch(); // Take care of function keys
215 return Temp;
216 } else
217 return 0;
218
219 }
220
221
222 USER_ACTION GraphicsControl::ParseMouseCkick( Go& AGo ) {
223
224 unsigned int Temp;
225
226 // This will be some pretty cryptic code.
227
228 // Check top button region
229 if ( (MouseX >= MAIN_BUTTONSX)&&(MouseY < MAIN_BUTTONSYSIZE) ) {
230
231 // return the specific button
232 Temp = MouseX - MAIN_BUTTONSX;
233 Temp = Temp / MAIN_BUTTONSXSIZE;
234 return( (USER_ACTION) (((unsigned int)CLICK_HELP) + Temp) );
235
236 } else
237
238 // Check if in brain button area
239 if ( ( MouseX >= BRAIN_BUTTONSX )&&
240 ( MouseX <= (BRAIN_BUTTONSX+(2*BRAIN_BUTTONXSEP)) )&&
241 ( MouseY >= BRAIN_BUTTONSY )&&
242 ( MouseY <= (BRAIN_BUTTONSY+(3*BRAIN_BUTTONYSIZE)) ) ) {
243
244 // return the specific button
245 if ( MouseX < (BRAIN_BUTTONSX + BRAIN_BUTTONXSEP) ) {
246
247 // left half
248 if ( MouseY < (BRAIN_BUTTONSY + BRAIN_BUTTONYSIZE) )
249 return CLICK_BRAIN1;
250 if ( MouseY < (BRAIN_BUTTONSY + (2 * BRAIN_BUTTONYSIZE)) )
251 return CLICK_BRAIN3;
252 return CLICK_BRAIN5;
253
254 } else {
255
256 // right half
257 if ( MouseY < (BRAIN_BUTTONSY + BRAIN_BUTTONYSIZE) )
258 return CLICK_BRAIN2;
259 if ( MouseY < (BRAIN_BUTTONSY + (2 * BRAIN_BUTTONYSIZE)) )
260 return CLICK_BRAIN4;
261 return CLICK_BRAIN6;
262
263 }
264
265 } else
266
267 // Is it in the board
268 if ((MouseX >= BOARDX)&&(MouseX < (BOARDX + (BOARDXSIZE * SPOT_XYSIZE) ))&&
269 (MouseY >= BOARDY)&&(MouseY < (BOARDY + (BOARDYSIZE * SPOT_XYSIZE) )) ) {
270
271 Temp = MouseX - BOARDX;
272 Temp = Temp / SPOT_XYSIZE;
273 AGo.XIs( Temp );
274
275 Temp = MouseY - BOARDY;
276 Temp = Temp / SPOT_XYSIZE;
277 AGo.YIs( Temp );
278
279 return CLICK_BOARD;
280
281 }
282
283 return NO_ACTION;
284
285
286 };
287
288
289
290 // ------------------------------------------------------------------------
291 // --- PRIVATE MEMBERS
292 // ------------------------------------------------------------------------
293
294 // -- Member : Initialize the TGA hooks -----------------------------------
295 void GraphicsControl::InitTGAHooks( void ) {
296
297 // Set the TGA hooks
298 White_Spots = TGA + WHITE_SPOTS_SITE;
299 Black_Spots = TGA + BLACK_SPOTS_SITE;
300
301 };
302
303 // ------------------------------------------------------------------------
304 // --- CONSTRUCTOR/DESTRUCTOR
305 // ------------------------------------------------------------------------
306 GraphicsControl::GraphicsControl( void ) {
307
308 FILE *FontFile;
309
310 // Allocate TGA and generate the hooks. Any error is fatal.
311 TGA = (char *) farmalloc( 65530 ); // I know, malloc. It's safer here though
312 if ( TGA == NULL ) {
313 puts( ".. FATAL ERROR .. Could not allocate memory for graphics!\n\r\n\r");
314 exit( 1 );
315 }
316 InitTGAHooks();
317
318 // Open the main graphics file. It will be closed by the destructor
319 MainGFile = fopen( "reversem.cmb", "rb");
320 if ( MainGFile == NULL ) {
321 puts( ".. FATAL ERROR .. Could not open the 'reversem.cmb' graphics file.\n\r\n\r");
322 exit(2);
323 }
324
325 // Load the TGA
326 fread( TGA, LOAD1_SIZE, 1, MainGFile );
327
328 // Init various items
329 BrainButtonState = SIMPLETON; // This is the default!
330
331 // Load the font and register it
332 FontFile = fopen("font4x6.msf","rb");
333 if ( MainGFile == NULL ) {
334 puts( ".. FATAL ERROR .. Could not open the 'font4x6.msf' font file.\n\r\n\r");
335 exit(2);
336 }
337 fread(Font4, FONT_4_SIZE, 1, FontFile);
338 fclose(FontFile);
339 XRegister_Font4( 0, 65, ' ', DONTUPLOADFONT, Font4 ); /* Font4 is dummy */
340 Register_Font_Masks4( Font4 );
341
342 };
343
344 GraphicsControl::~GraphicsControl() {
345
346 fclose(MainGFile);
347 farfree(TGA);
348
349 // Put it back to text screen
350 textmode ( LASTMODE );
351
352 }
353
354
355 // ------------------------------------------------------------------------
356 // --- PUBLIC MEMBERS
357 // ------------------------------------------------------------------------
358
359 // -- Member : Initialize the main screen --------------------------------
360 void GraphicsControl::InitMainScreen( void ) {
361
362 char* TMA;
363
364 // We will temporarily need 64000 bytes
365 TMA = (char *) farmalloc( 64000 );
366 if ( TMA == NULL ) {
367 puts( ".. FATAL ERROR .. Could not allocate memory for graphics screen load!\n\r\n\r");
368 exit( 1 );
369 }
370
371 // Clear video memory and set the mode
372 XWait_Retrace();
373 XInit_Mode( 0 );
374 XClear( 0 );
375 XInit_Mode( 0 );
376
377 // Load and put the main screen (in the main page)
378 XSet_Write_Page( MAIN_PAGE, 320 );
379 fseek( MainGFile, MAIN_SCREEN_FILE_SITE, SEEK_SET );
380 fread( TMA, 1, (320*200), MainGFile);
381 XPut_Tile( 0, 0, 320, 200, TMA );
382 fread( TMA, 1, (320*40), MainGFile );
383 XPut_Tile( 0, 200, 320, 40, TMA );
384
385
386 // NOTE: The default brain button is IDIOT (SIMPLETON);
387 // the loaded screen has that button pushed
388
389 // ALSO: The screen will show a completely blank board
390
391 // Do any reloads
392 XDownload_TileP ( SCORE_X, SCORE_Y, SCORE_XSIZE, SCORE_YSIZE,
393 TGA + SCORE_RELOAD_SITE );
394
395
396 // Register mouse. (default mouse is prep mouse)
397 XRegister_Mouse( (TGA + PREP_MOUSE_DATA_SITE),
398 (TGA + PREP_MOUSE_MASK_SITE),
399 GMouse_Handler );
400
401 // Show the welcome picture
402 Me.ShowPicture( PIC_NOEXP );
403 Me.SayText( "HI. I AM ERICH.", "HIT 'NEW' IF YOU", "WANT TO PLAY" );
404
405 // Show the screen. Page flip to main page.
406 XSet_Display_PageP( MAIN_PAGE, 320, 240, 0, 0, 0, 255,
407 TGA + MAIN_PAL_SITE );
408
409 // Don't need the TMA anymore
410 farfree( TMA );
411
412 };
413
414
415 // -- Member : Show a board. No finesse, just blast it out --------------
416 void GraphicsControl::ShowBoard( Board TheBoard ) {
417
418 unsigned int X, Y, XLoc, YLoc;
419
420 // Lets try to avoid some flicker
421 XWait_Retrace();
422
423 // Put the tiles
424 XLoc = BOARDX;
425 for ( X = 0; X < BOARDXSIZE; X++ ) {
426 YLoc = BOARDY;
427 for ( Y = 0; Y < BOARDYSIZE; Y++ ) {
428
429 XPut_Tile( XLoc, YLoc, SPOT_XYSIZE, SPOT_XYSIZE, TGA + SPOT_SITE );
430 if ( TheBoard.Spots[X][Y].IsSpotBlack() )
431 XPut_Tile( XLoc + SPOT_TRIMX, YLoc + SPOT_TRIMY,
432 SPOT_TRIMXSIZE, SPOT_TRIMYSIZE,
433 TGA + BLACK_SPOTS_SITE );
434 if ( TheBoard.Spots[X][Y].IsSpotWhite() )
435 XPut_Tile( XLoc + SPOT_TRIMX, YLoc + SPOT_TRIMY,
436 SPOT_TRIMXSIZE, SPOT_TRIMYSIZE,
437 TGA + WHITE_SPOTS_SITE );
438
439 YLoc = YLoc + SPOT_XYSIZE;
440 }
441 XLoc = XLoc + SPOT_XYSIZE;
442 }
443
444 };
445
446
447 // -- Member : Show valid moves for the player (WHITE) ----------------
448 void GraphicsControl::ShowValidMoves( Board TheBoard ) {
449
450 register unsigned int X, Y;
451 unsigned int XLoc, YLoc;
452 Go AGo;
453
454 // Lets try to avoid some flicker
455 XWait_Retrace();
456
457 // Put the tiles
458 XLoc = BOARDX;
459 for ( X = 0; X < BOARDXSIZE; X++ ) {
460 YLoc = BOARDY;
461 for ( Y = 0; Y < BOARDYSIZE; Y++ ) {
462
463 AGo.XIs( X );
464 AGo.YIs( Y );
465 if ( TheBoard.ValidGo( AGo, SPOT_WHITE ) )
466 XPut_Tile( XLoc, YLoc, SPOT_XYSIZE, SPOT_XYSIZE,
467 TGA + OK_SITE );
468
469 YLoc = YLoc + SPOT_XYSIZE;
470 }
471 XLoc = XLoc + SPOT_XYSIZE;
472 }
473
474 };
475
476
477
478 // -- Member : Wait for a user event -------------------------------------
479 USER_ACTION GraphicsControl::WaitUser( Go& AGo ) {
480
481 int ViewReturn;
482 USER_ACTION ParseReturn = NO_ACTION;
483
484 while ( ParseReturn == NO_ACTION ) {
485
486 ViewReturn = MouseView();
487 if ( ViewReturn == 0 )
488 ParseReturn = ParseMouseCkick( AGo );
489
490 }
491
492 return( ParseReturn );
493 };
494
495
496 // -- Member : Set the appropriate button for the brain setting ----------
497 void GraphicsControl::BrainSetting( BRAIN Setting ) {
498
499 if ( Setting == BrainButtonState ) return;
500
501 // Undo old button
502 XWait_Retrace();
503 switch( BrainButtonState ) {
504
505 case SIMPLETON:
506 XPut_TileA_M( BRAIN_BUTTONSX, BRAIN_BUTTONSY, BRAIN_BUTTONXSIZE,
507 BRAIN_BUTTONYSIZE,
508 TGA + BRAIN_BUTTON_SITE );
509 break;
510
511 case DULLARD:
512 XPut_TileA_M( BRAIN_BUTTONSX + BRAIN_BUTTONXSEP,
513 BRAIN_BUTTONSY, BRAIN_BUTTONXSIZE,
514 BRAIN_BUTTONYSIZE,
515 TGA + (BRAIN_BUTTON_SITE + BRAIN_BUTTON_EACH ) );
516 break;
517
518 case AVERAGE:
519 XPut_TileA_M( BRAIN_BUTTONSX,
520 BRAIN_BUTTONSY + BRAIN_BUTTONYSIZE,
521 BRAIN_BUTTONXSIZE, BRAIN_BUTTONYSIZE,
522 TGA + (BRAIN_BUTTON_SITE + (2*BRAIN_BUTTON_EACH) ) );
523 break;
524
525 case SWIFT:
526 XPut_TileA_M( BRAIN_BUTTONSX + BRAIN_BUTTONXSEP,
527 BRAIN_BUTTONSY + BRAIN_BUTTONYSIZE,
528 BRAIN_BUTTONXSIZE, BRAIN_BUTTONYSIZE,
529 TGA + (BRAIN_BUTTON_SITE + (3*BRAIN_BUTTON_EACH) ) );
530 break;
531
532 case GENIUS:
533 XPut_TileA_M( BRAIN_BUTTONSX,
534 BRAIN_BUTTONSY + (2*BRAIN_BUTTONYSIZE),
535 BRAIN_BUTTONXSIZE, BRAIN_BUTTONYSIZE,
536 TGA + (BRAIN_BUTTON_SITE + (4*BRAIN_BUTTON_EACH) ) );
537 break;
538
539 case EXPERIMENTAL:
540 XPut_TileA_M( BRAIN_BUTTONSX + BRAIN_BUTTONXSEP,
541 BRAIN_BUTTONSY + (2*BRAIN_BUTTONYSIZE),
542 BRAIN_BUTTONXSIZE, BRAIN_BUTTONYSIZE,
543 TGA + (BRAIN_BUTTON_SITE + (5*BRAIN_BUTTON_EACH) ) );
544 break;
545 }
546
547 // Put the new button
548 BrainButtonState = Setting;
549 switch( BrainButtonState ) {
550
551 case SIMPLETON:
552 XPut_TileA_M( BRAIN_BUTTONSX, BRAIN_BUTTONSY, BRAIN_BUTTONXSIZE,
553 BRAIN_BUTTONYSIZE,
554 TGA + BRAIN_BPUSHED_SITE );
555 break;
556
557 case DULLARD:
558 XPut_TileA_M( BRAIN_BUTTONSX + BRAIN_BUTTONXSEP,
559 BRAIN_BUTTONSY, BRAIN_BUTTONXSIZE,
560 BRAIN_BUTTONYSIZE,
561 TGA + (BRAIN_BPUSHED_SITE + BRAIN_BUTTON_EACH ) );
562 break;
563
564 case AVERAGE:
565 XPut_TileA_M( BRAIN_BUTTONSX,
566 BRAIN_BUTTONSY + BRAIN_BUTTONYSIZE,
567 BRAIN_BUTTONXSIZE, BRAIN_BUTTONYSIZE,
568 TGA + (BRAIN_BPUSHED_SITE + (2*BRAIN_BUTTON_EACH) ) );
569 break;
570
571 case SWIFT:
572 XPut_TileA_M( BRAIN_BUTTONSX + BRAIN_BUTTONXSEP,
573 BRAIN_BUTTONSY + BRAIN_BUTTONYSIZE,
574 BRAIN_BUTTONXSIZE, BRAIN_BUTTONYSIZE,
575 TGA + (BRAIN_BPUSHED_SITE + (3*BRAIN_BUTTON_EACH) ) );
576 break;
577
578 case GENIUS:
579 XPut_TileA_M( BRAIN_BUTTONSX,
580 BRAIN_BUTTONSY + (2*BRAIN_BUTTONYSIZE),
581 BRAIN_BUTTONXSIZE, BRAIN_BUTTONYSIZE,
582 TGA + (BRAIN_BPUSHED_SITE + (4*BRAIN_BUTTON_EACH) ) );
583 break;
584
585 case EXPERIMENTAL:
586 XPut_TileA_M( BRAIN_BUTTONSX + BRAIN_BUTTONXSEP,
587 BRAIN_BUTTONSY + (2*BRAIN_BUTTONYSIZE),
588 BRAIN_BUTTONXSIZE, BRAIN_BUTTONYSIZE,
589 TGA + (BRAIN_BPUSHED_SITE + (5*BRAIN_BUTTON_EACH) ) );
590 break;
591 }
592
593 };
594
595
596 // -- Member : Push the button specified -----------------------------
597 void GraphicsControl::PushMainButton( MAIN_BUTTONS TheButton ) {
598
599 XPut_Tile( MAIN_BUTTONSX + (TheButton * MAIN_BUTTONSXSIZE),
600 MAIN_BUTTONSY, MAIN_BUTTONSXSIZE, MAIN_BUTTONSYSIZE,
601 TGA + (MAIN_BPUSHED_SITE + (TheButton * MAIN_BUTTON_EACH)) );
602
603 };
604
605
606 // -- Member : Pop the button specified -----------------------------
607 void GraphicsControl::PopMainButton( MAIN_BUTTONS TheButton ) {
608
609 XPut_Tile( MAIN_BUTTONSX + (TheButton * MAIN_BUTTONSXSIZE),
610 MAIN_BUTTONSY, MAIN_BUTTONSXSIZE, MAIN_BUTTONSYSIZE,
611 TGA + (MAIN_BUTTON_SITE + (TheButton * MAIN_BUTTON_EACH)) );
612
613 };
614
615
616 // -- Member : Who is first -----------------------------------------
617 BOOLEAN GraphicsControl::WhoFirst( void ) {
618
619 BOOLEAN ReturnValue;
620
621 // Definitions unique to this popup
622 #define WHO_FIRSTX 160
623 #define WHO_FIRSTY 87
624 #define WHO_FIRST_YOUX (WHO_FIRSTX + 12)
625 #define WHO_FIRST_YOUY (WHO_FIRSTY + 16)
626 #define WHO_FIRST_MEX (WHO_FIRSTX + 62)
627 #define WHO_FIRST_YMSIZEX 30
628 #define WHO_FIRST_YMSIZEY 11
629
630
631 // Return TRUE if it is the player (YOU), FALSE is (ME).
632
633 // Put the popup on the screen
634 XDownload_TileP ( WHO_FIRSTX, WHO_FIRSTY, POPUP_XSIZE, POPUP_YSIZE,
635 TGA + POPUP_RELOAD_SITE );
636 XPut_Tile ( WHO_FIRSTX, WHO_FIRSTY, POPUP_XSIZE, POPUP_YSIZE,
637 TGA + WHO_1ST_SITE );
638
639 // Loop until valid
640 for(;;) {
641
642 // Wait for a mouse event
643 MouseView();
644
645 // See if valid
646 if ( (MouseY >= WHO_FIRST_YOUY)&&
647 (MouseY < (WHO_FIRST_YOUY + WHO_FIRST_YMSIZEY)) ) {
648
649 if ( (MouseX >= WHO_FIRST_YOUX) &&
650 (MouseX < (WHO_FIRST_YOUX + WHO_FIRST_YMSIZEX)) ) {
651 ReturnValue = TRUE;
652 break;
653 }
654 if ( (MouseX >= WHO_FIRST_MEX) &&
655 (MouseX < (WHO_FIRST_MEX + WHO_FIRST_YMSIZEX)) ) {
656 ReturnValue = FALSE;
657 break;
658 }
659
660 }
661
662 }
663
664 // Restore screen
665 XPut_Tile ( WHO_FIRSTX, WHO_FIRSTY, POPUP_XSIZE, POPUP_YSIZE,
666 TGA + POPUP_RELOAD_SITE );
667
668 return ReturnValue;
669
670 };
671
672 // -- Member : You sure? -----------------------------------------
673 BOOLEAN GraphicsControl::YouSure( void ) {
674
675 // return true if sure
676
677 BOOLEAN ReturnValue;
678
679 // Definitions
680 #define YOU_SUREX 160
681 #define YOU_SUREY 87
682 #define YOU_SURE_YOUX (YOU_SUREX + 12)
683 #define YOU_SURE_YOUY (YOU_SUREY + 16)
684 #define YOU_SURE_MEX (YOU_SUREX + 62)
685 #define YOU_SURE_YMSIZEX 30
686 #define YOU_SURE_YMSIZEY 11
687
688
689 // Return TRUE if it is the player (YOU), FALSE is (ME).
690
691 // Put the popup on the screen
692 XDownload_TileP ( YOU_SUREX, YOU_SUREY, POPUP_XSIZE, POPUP_YSIZE,
693 TGA + POPUP_RELOAD_SITE );
694 XPut_Tile ( YOU_SUREX, YOU_SUREY, POPUP_XSIZE, POPUP_YSIZE,
695 TGA + YOU_SURE_SITE );
696
697 // Loop until valid
698 for(;;) {
699
700 // Wait for a mouse event
701 MouseView();
702
703 // See if valid
704 if ( (MouseY >= YOU_SURE_YOUY)&&
705 (MouseY < (YOU_SURE_YOUY + YOU_SURE_YMSIZEY)) ) {
706
707 if ( (MouseX >= YOU_SURE_YOUX) &&
708 (MouseX < (YOU_SURE_YOUX + YOU_SURE_YMSIZEX)) ) {
709 ReturnValue = TRUE;
710 break;
711 }
712 if ( (MouseX >= YOU_SURE_MEX) &&
713 (MouseX < (YOU_SURE_MEX + YOU_SURE_YMSIZEX)) ) {
714 ReturnValue = FALSE;
715 break;
716 }
717
718 }
719
720 }
721
722 // Restore screen
723 XPut_Tile ( YOU_SUREX, YOU_SUREY, POPUP_XSIZE, POPUP_YSIZE,
724 TGA + POPUP_RELOAD_SITE );
725
726 return ReturnValue;
727
728 };
729
730 // -- Member : The You Must Pass popup ---------------------------------
731 void GraphicsControl::YouMustPass( void ) {
732
733 // Definitions unique to this popup
734 #define MUST_PASSX 160
735 #define MUST_PASSY 87
736
737
738 // Put the popup on the screen
739 XDownload_TileP ( MUST_PASSX, MUST_PASSY, POPUP_XSIZE, POPUP_YSIZE,
740 TGA + POPUP_RELOAD_SITE );
741 XPut_Tile ( MUST_PASSX, MUST_PASSY, POPUP_XSIZE, POPUP_YSIZE,
742 TGA + MUST_PASS_SITE );
743
744 // Wait for a mouse event
745 MouseView();
746
747 // Restore screen
748 XPut_Tile ( MUST_PASSX, MUST_PASSY, POPUP_XSIZE, POPUP_YSIZE,
749 TGA + POPUP_RELOAD_SITE );
750
751 };
752
753
754 // -- Member : Show the HERE tile --------------------------------------
755 void GraphicsControl::Here( Go TheGo ) {
756
757 XWait_Retrace();
758
759 XPut_Tile( BOARDX + (SPOT_XYSIZE * TheGo.XIs()),
760 BOARDY + (SPOT_XYSIZE * TheGo.YIs()),
761 SPOT_XYSIZE, SPOT_XYSIZE,
762 TGA + HERE_SITE );
763
764
765 };
766
767
768 // -- Member : Show the HERE tile --------------------------------------
769 void GraphicsControl::Score( int TheScore ) {
770
771 char Buffer[10];
772
773 XWait_Retrace();
774
775 XPut_Tile( SCORE_X, SCORE_Y, SCORE_XSIZE, SCORE_YSIZE,
776 TGA + SCORE_RELOAD_SITE );
777
778 itoa( TheScore, Buffer, 10 );
779 XString4_C( SCORE_X, SCORE_Y, SCORE_COLOR, Buffer );
780
781 };
|