home *** CD-ROM | disk | FTP | other *** search
- /* disp.c -- Most of the display-oriented functions for Targ-Hurt ESP
- Trainer.
-
- History: 23-mar-87
- */
-
- #include "colors.h"
- #include "mancon.h"
- #include "declares.h"
- #include <stdio.h>
- #define BLINK 16
-
-
- /* Terminal's foreground and background colors. */
- IMPORT gi_fg1, gi_fg2, gi_bg1, gi_bg2;
-
-
- /* disp_top -- Displays box-character drawing at top of screen.
- */
- void disp_top(title)
- char *title;
- { int j;
-
- curlocat(1,31); colrprts(title, gi_fg1, gi_bg1);
- curlocat(2,0); colrprta(218, gi_fg1, gi_bg1);
- for(j=1; j<79; j++) colrprta(196, gi_fg1, gi_bg1);
- colrprtc(191, gi_fg1, gi_bg1);
- curlocat(3,0); colrprtc(179, gi_fg1, gi_bg1);
- curlocat(3,79); colrprtc(179, gi_fg1, gi_bg1);
- curlocat(4,0); colrprta(212, gi_fg1, gi_bg1);
- for(j=1; j<79; j++) colrprta(205, gi_fg1, gi_bg1);
- colrprtc(190, gi_fg1, gi_bg1);
-
- curlocat(3,2); colrprts("Hits:", gi_fg1, gi_bg1);
- curlocat(3,13); colrprts("Tries:", gi_fg1, gi_bg1);
- curlocat(3,26); colrprts("Hit %:", gi_fg1, gi_bg1);
- }
-
-
- /* disp_cbot -- Displays menu for clairvoyance mode at bottom of screen.
- */
- void disp_cbot()
- {
- curlocat(24, 21);
- colrprtf(0, gi_fg1, gi_bg1,
- "Press: %c %c %c %c P)ass, R)eset, Q)uit",
- 24, 25, 27, 26
- ); /* Characters 24-27 are displayed as arrows. */
- }
-
-
- /* disp_pbot -- Displays menu for precognition mode at bottom of screen.
- */
- void disp_pbot()
- {
- curlocat(24, 11);
- colrprtf(0, gi_fg1, gi_bg1,
- "Press: %c %c %c %c P)ass, R)eset, C)hange-time-delay, Q)uit",
- 24, 25, 27, 26
- ); /* Characters 24-27 are displayed as arrows. */
-
- }
-
-
- /* disp_crtmode -- set video mode on color monitors
- */
- void disp_crtmode()
- { IMPORT gi_vidmode;
- int dummy;
-
- getscmod(&gi_vidmode, &dummy, &dummy);
- if(gi_vidmode==7)
- { clrscrn();
- gi_fg1=7;
- gi_fg2=0;
- gi_bg1=0;
- gi_bg2=7;
- }
- else
- { setscmod(3); /* Set video mode to color 80x25 */
- border(BLUE);
- gi_fg1=WHITE;
- gi_fg2=YELLOW;
- gi_bg1=BLUE;
- gi_bg2=RED;
- }
- }
-
-
- /* disp_cls() -- Clear the screen and fill it with color. */
- void disp_cls()
- { IMPORT gi_fg1, gi_bg1;
- clscolor(gi_fg1, gi_bg1);
- }
-
-
- /* disp_cursor -- Turns cursor on or off depending on the value of flag.
- */
- void disp_cursor(flag)
- int flag;
- { IMPORT int gi_vidmode;
- if(flag==ON)
- if(gi_vidmode==7) curtype(0,12,13); /* For monochrome. */
- else curtype(0, 6, 7); /* For color. */
- else
- curtype(1,0,0);
- }
-
-
- static struct blip {
- int row, col;
- char direction[25];
- } blips[4] = { { 7, 27, " NORTH "},
- { 21,27, " SOUTH "},
- { 14,45, " EAST "},
- { 14,10, " WEST "},
- };
-
-
- /* disp_score -- Updates the scores display.
- */
- void disp_score()
- { IMPORT int gi_hits, gi_tries;
-
- curlocat(3, 8); colrprtf(0, gi_fg2, gi_bg2, "%-4d", gi_hits);
- curlocat(3, 20); colrprtf(0, gi_fg1, gi_bg1, "%-5d", gi_tries);
- curlocat(3, 33); colrprtf(0, gi_fg1, gi_bg1, "%-3d", (gi_tries<=0) ? 0 :
- (int)(( (float)gi_hits / (float)gi_tries )*100.0) );
- }
-
-
- /* pf_display -- Displays machine's selection and updates encouragement
- message.
- */
- void pf_display()
- {
- IMPORT int gi_encourage, gi_direction, gi_wasahit;
- IMPORT struct encouragement gsa_enc[];
- static old_encourage=0;
-
- disp_score();
-
- /* Update encouragement message. */
- if(old_encourage!=gi_encourage)
- { old_encourage = gi_encourage;
- curlocat(3, 38);
- colrprtf(0, gi_fg1, gi_bg1, "%30s","");
- curlocat(3, 38);
- colrprtf(0, gi_fg2, gi_bg2, "%s", gsa_enc[gi_encourage].message);
- }
-
- if(gi_direction==RESET) return;
-
- if(kbhit()==0) /* Don't display machine's selection if keypress is
- waiting. */
- { curlocat(blips[gi_direction].row, blips[gi_direction].col);
- colrprtf(0, gi_fg2+((gi_wasahit)? BLINK : 0), gi_bg2, "%s",
- blips[gi_direction].direction);
-
- wait_keytime( gi_wasahit ? 10 : 1 );
-
- curlocat(blips[gi_direction].row, blips[gi_direction].col);
- colrprtf(0, gi_fg1, gi_bg1, "%s", blips[gi_direction].direction);
- }
-
-
- }
-
-
- /* pf_waitmsg -- Displays message acknowlegement message at center of
- screen (for mode_precognition).
- */
- void pf_waitmsg(toggle, string)
- int toggle;
- char *string;
- { int foreg, backg;
-
- curlocat(14, 28);
- if(toggle==ON) { foreg=gi_fg2; backg=gi_bg2; }
- else { foreg=gi_fg1; backg=gi_bg1; }
- colrprtf(0, foreg, backg, "%-20s", string);
- }
-
-
- /* pf_change_delay -- Menu to update the delay between user input and
- machine selection (for mode_precognition).
- */
- void pf_change_delay(pdelay)
- int *pdelay;
- {
- char temp='9';
- char *validvals = {"123"};
-
- curlocat(24, 0);
- coloreol(gi_fg1, gi_bg1);
- curlocat(24, 5);
- colrprts(" How long a delay do you want? 1) second, 2) seconds, 3) seconds ",
- gi_fg1, gi_bg1);
-
- while(strchr(validvals, temp)==NULL)
- { curlocat(24, 77);
- getkey(&temp);
- }
-
- curlocat(24, 0);
- coloreol(gi_fg1, gi_bg1);
- disp_pbot();
-
- switch(temp)
- { case '1' : *pdelay=10; break;
- case '2' : *pdelay=20; break;
- case '3' : *pdelay=30; break;
- }
- }