xref: /csrg-svn/games/larn/help.c (revision 36985)
1*36985Sbostic /*	help.c		Larn is copyrighted 1986 by Noah Morgan. */
2*36985Sbostic #include "header.h"
3*36985Sbostic /*
4*36985Sbostic  *	help function to display the help info
5*36985Sbostic  *
6*36985Sbostic  *	format of the .larn.help file
7*36985Sbostic  *
8*36985Sbostic  *	1st character of file:	# of pages of help available (ascii digit)
9*36985Sbostic  *	page (23 lines) for the introductory message (not counted in above)
10*36985Sbostic  *	pages of help text (23 lines per page)
11*36985Sbostic  */
12*36985Sbostic extern char helpfile[];
help()13*36985Sbostic help()
14*36985Sbostic 	{
15*36985Sbostic 	register int i,j;
16*36985Sbostic #ifndef VT100
17*36985Sbostic 	char tmbuf[128];	/* intermediate translation buffer when not a VT100 */
18*36985Sbostic #endif VT100
19*36985Sbostic 	if ((j=openhelp()) < 0)  return;	/* open the help file and get # pages */
20*36985Sbostic 	for (i=0; i<23; i++) lgetl();	/* skip over intro message */
21*36985Sbostic 	for (;  j>0; j--)
22*36985Sbostic 		{
23*36985Sbostic 		clear();
24*36985Sbostic 		for (i=0; i<23; i++)
25*36985Sbostic #ifdef VT100
26*36985Sbostic 			lprcat(lgetl());	/* print out each line that we read in */
27*36985Sbostic #else VT100
28*36985Sbostic 			{ tmcapcnv(tmbuf,lgetl());  lprcat(tmbuf); } /* intercept \33's */
29*36985Sbostic #endif VT100
30*36985Sbostic 		if (j>1)
31*36985Sbostic 			{
32*36985Sbostic 			lprcat("    ---- Press ");  standout("return");
33*36985Sbostic 			lprcat(" to exit, ");  standout("space");
34*36985Sbostic 			lprcat(" for more help ---- ");
35*36985Sbostic 			i=0; while ((i!=' ') && (i!='\n') && (i!='\33')) i=getchar();
36*36985Sbostic 			if ((i=='\n') || (i=='\33'))
37*36985Sbostic 				{
38*36985Sbostic 				lrclose();  setscroll();  drawscreen();  return;
39*36985Sbostic 				}
40*36985Sbostic 			}
41*36985Sbostic 		}
42*36985Sbostic 	lrclose();  retcont();  drawscreen();
43*36985Sbostic 	}
44*36985Sbostic 
45*36985Sbostic /*
46*36985Sbostic  *	function to display the welcome message and background
47*36985Sbostic  */
welcome()48*36985Sbostic welcome()
49*36985Sbostic 	{
50*36985Sbostic 	register int i;
51*36985Sbostic #ifndef VT100
52*36985Sbostic 	char tmbuf[128];	/* intermediate translation buffer when not a VT100 */
53*36985Sbostic #endif VT100
54*36985Sbostic 	if (openhelp() < 0)  return;   	/* open the help file */
55*36985Sbostic 	clear();
56*36985Sbostic 	for(i=0; i<23; i++)
57*36985Sbostic #ifdef VT100
58*36985Sbostic 			lprcat(lgetl());	/* print out each line that we read in */
59*36985Sbostic #else VT100
60*36985Sbostic 			{ tmcapcnv(tmbuf,lgetl());  lprcat(tmbuf); } /* intercept \33's */
61*36985Sbostic #endif VT100
62*36985Sbostic 	lrclose();  retcont();	/* press return to continue */
63*36985Sbostic 	}
64*36985Sbostic 
65*36985Sbostic /*
66*36985Sbostic  *	function to say press return to continue and reset scroll when done
67*36985Sbostic  */
retcont()68*36985Sbostic retcont()
69*36985Sbostic 	{
70*36985Sbostic 	cursor(1,24); lprcat("Press "); standout("return");
71*36985Sbostic 	lprcat(" to continue: ");   while (getchar() != '\n');
72*36985Sbostic 	setscroll();
73*36985Sbostic 	}
74*36985Sbostic 
75*36985Sbostic /*
76*36985Sbostic  *	routine to open the help file and return the first character - '0'
77*36985Sbostic  */
openhelp()78*36985Sbostic openhelp()
79*36985Sbostic 	{
80*36985Sbostic 	if (lopen(helpfile)<0)
81*36985Sbostic 		{
82*36985Sbostic 		lprintf("Can't open help file \"%s\" ",helpfile);
83*36985Sbostic 		lflush(); sleep(4);	drawscreen();	setscroll(); return(-1);
84*36985Sbostic 		}
85*36985Sbostic 	resetscroll();  return(lgetc() - '0');
86*36985Sbostic 	}
87*36985Sbostic 
88