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