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