xref: /csrg-svn/contrib/dungeon/cio.c (revision 35973)
1*35973Sbostic /* these are c routines to handle the pdp dungeon i/o */
2*35973Sbostic #include <stdio.h>
3*35973Sbostic 
4*35973Sbostic /*	send arguments to message printing process */
rspsb3_(arg1,arg2,arg3)5*35973Sbostic rspsb3_(arg1,arg2,arg3)
6*35973Sbostic 
7*35973Sbostic int *arg1,*arg2,*arg3;
8*35973Sbostic {
9*35973Sbostic 	printf("n%d %d %d\n",*arg1,*arg2,*arg3);
10*35973Sbostic 	fflush(stdout);
11*35973Sbostic 	return;
12*35973Sbostic }
13*35973Sbostic 
14*35973Sbostic /* print for puzzle room */
puzout_(p)15*35973Sbostic puzout_(p)
16*35973Sbostic 
17*35973Sbostic char *p;
18*35973Sbostic {
19*35973Sbostic 
20*35973Sbostic printf("       |%c%c %c%c %c%c|\n",p[0],p[0],p[1],p[1],p[2],p[2]);
21*35973Sbostic printf("  WEST |%c%c .. %c%c| EAST\n",p[3],p[3],p[4],p[4]);
22*35973Sbostic printf("       |%c%c %c%c %c%c|\n",p[5],p[5],p[6],p[6],p[7],p[7]);
23*35973Sbostic fflush(stdout);
24*35973Sbostic return;
25*35973Sbostic }
26*35973Sbostic 
27*35973Sbostic /* output general string (echo room) */
outstr_(ptr,len)28*35973Sbostic outstr_(ptr,len)
29*35973Sbostic 
30*35973Sbostic int  *len;
31*35973Sbostic char *ptr[];
32*35973Sbostic {
33*35973Sbostic 	printf("%.*s\n",*len,ptr);
34*35973Sbostic 	fflush(stdout);
35*35973Sbostic 	return;
36*35973Sbostic }
37*35973Sbostic 
38*35973Sbostic 
39*35973Sbostic /* print a prompt */
prompt_()40*35973Sbostic prompt_()
41*35973Sbostic {
42*35973Sbostic 	printf(" > ~");
43*35973Sbostic 	fflush(stdout);
44*35973Sbostic 	return;
45*35973Sbostic }
46*35973Sbostic 
47*35973Sbostic /* terminate the game */
exit_()48*35973Sbostic exit_()
49*35973Sbostic {
50*35973Sbostic 	fprintf(stderr,"The game is over\n");
51*35973Sbostic 	exit(0);
52*35973Sbostic }
53*35973Sbostic 
54*35973Sbostic /*	read a character */
rdchr_(cptr)55*35973Sbostic rdchr_(cptr)
56*35973Sbostic 
57*35973Sbostic char *cptr;
58*35973Sbostic {
59*35973Sbostic static int ch;
60*35973Sbostic 
61*35973Sbostic 	if((ch = getchar()) == EOF){
62*35973Sbostic 		fprintf(stderr,"EOF on input\n");
63*35973Sbostic 		exit_();
64*35973Sbostic 	}
65*35973Sbostic 	else 	*cptr = ch;
66*35973Sbostic 	return;
67*35973Sbostic }
68*35973Sbostic 
69*35973Sbostic /* read a line from std input */
rdlin_(sptr,cntptr)70*35973Sbostic rdlin_(sptr,cntptr)
71*35973Sbostic 
72*35973Sbostic int *cntptr;
73*35973Sbostic char *sptr;
74*35973Sbostic {
75*35973Sbostic static int chr;
76*35973Sbostic 	*cntptr = 0;
77*35973Sbostic 	while ((chr = getchar()) != EOF){
78*35973Sbostic 		if((chr >= 97) && (chr <= 122))	/* convert to uc */
79*35973Sbostic 			chr -= 32;
80*35973Sbostic 		if (chr == 10 ){ 		/* quit if newline */
81*35973Sbostic 			*sptr++ = '\0';
82*35973Sbostic 			return;
83*35973Sbostic 		}
84*35973Sbostic 		if ((chr == 32) && (*cntptr == 0))  /* rm lead blank */
85*35973Sbostic 			continue;
86*35973Sbostic 		if (*cntptr >= 78)
87*35973Sbostic 			continue;
88*35973Sbostic 		*sptr++ = chr;
89*35973Sbostic 		(*cntptr)++;
90*35973Sbostic 	}
91*35973Sbostic 	fprintf(stderr,"EOF on input\n");
92*35973Sbostic 	exit_();
93*35973Sbostic }
94*35973Sbostic 
95*35973Sbostic /*	print cure time */
cured_(time)96*35973Sbostic cured_(time)
97*35973Sbostic 
98*35973Sbostic int *time;
99*35973Sbostic {
100*35973Sbostic 	printf(" You will be cured in %d moves\n",*time);
101*35973Sbostic 	fflush(stdout);
102*35973Sbostic 	return;
103*35973Sbostic }
104*35973Sbostic 
105*35973Sbostic /* print the score */
pscore_(score,max,moves)106*35973Sbostic pscore_(score,max,moves)
107*35973Sbostic 
108*35973Sbostic int *score, *max, *moves;
109*35973Sbostic {
110*35973Sbostic printf(" Your current score is %d out of %d points in %d moves.\n",*score, *max, *moves);
111*35973Sbostic 	fflush(stdout);
112*35973Sbostic 	return;
113*35973Sbostic }
114*35973Sbostic 
115*35973Sbostic /* BUG-- REPORT FATAL SYSTEM ERROR
116*35973Sbostic C
117*35973Sbostic C CALLED BY--
118*35973Sbostic C
119*35973Sbostic C	CALL BUG(NO,PAR)
120*35973Sbostic C
121*35973Sbostic C      note: return if DBGFLG set is not implemented
122*35973Sbostic C*/
bug_(a,b)123*35973Sbostic bug_(a,b)
124*35973Sbostic 
125*35973Sbostic int *a,*b;
126*35973Sbostic {
127*35973Sbostic 	fprintf(stderr,"Program error %d ; Parameter %d\n",*a,*b);
128*35973Sbostic 	exit(0);
129*35973Sbostic }
130*35973Sbostic 
131*35973Sbostic 
132*35973Sbostic /* send restore message  */
restor_()133*35973Sbostic restor_()
134*35973Sbostic {
135*35973Sbostic 	printf(" Restore by starting with 'dungeon r'\n");
136*35973Sbostic 	return;
137*35973Sbostic }
138*35973Sbostic 
139*35973Sbostic /* password output */
voice_(sp1,sp2)140*35973Sbostic voice_(sp1, sp2)
141*35973Sbostic 
142*35973Sbostic char *sp1, *sp2;
143*35973Sbostic {
144*35973Sbostic 	printf(" A Hollow voice replies: %6.6s %6.6s\n", sp1, sp2);
145*35973Sbostic 	return;
146*35973Sbostic }
147*35973Sbostic 
148*35973Sbostic /* print version */
prvers_(v1,v2,v3)149*35973Sbostic prvers_(v1, v2, v3)
150*35973Sbostic 
151*35973Sbostic int *v1, *v2;
152*35973Sbostic char *v3;
153*35973Sbostic {
154*35973Sbostic 	printf(" V%1d.%2d%c\n", *v1, *v2, *v3);
155*35973Sbostic 	return;
156*35973Sbostic }
157*35973Sbostic 
158*35973Sbostic /* dummy stub for game debugger */
nogdt_()159*35973Sbostic nogdt_()
160*35973Sbostic {
161*35973Sbostic 	/* debugger deleted to save room */
162*35973Sbostic 	printf(" Sorry, no debugger available in this version.\n");
163*35973Sbostic 	return;
164*35973Sbostic }
165