2 * Various input/output functions
4 * @(#)io.c 3.10 (Berkeley) 6/15/81
6 * Rogue: Exploring the Cavern of Cuties
7 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
10 * See the file LICENSE.TXT for full copyright and licensing information.
21 * Display a message at the top of the screen.
24 static char msgbuf
[BUFSIZ
];
25 static int newpos
= 0;
32 * if the string is "", just clear the line
42 * otherwise add to the message and flush it out
51 * add things to the current message
53 addmsg(char *fmt
, ...)
63 * Display a new msg (giving him a chance to see the previous one if it
64 * is up there with the --More--)
68 strncpy(huh
, msgbuf
, 80);
74 waddstr(cw
, "--More--");
78 mvwaddstr(cw
, 0, 0, msgbuf
);
85 doadd(char *fmt
, va_list ap
)
87 vsprintf(&msgbuf
[newpos
], fmt
, ap
);
88 newpos
= (int) strlen(msgbuf
);
93 * returns true if it is ok to step on ch
106 return (!isalpha(ch
));
112 * flushes stdout so that screen is up to date and then returns
121 ch
= md_readchar(win
);
123 if ((ch
== 3) || (ch
== 0))
134 * Display the important stats line. Keep the cursor where it was.
139 register int oy
, ox
, temp
;
142 static int hpwidth
= 0, s_hungry
= -1;
143 static int s_lvl
= -1, s_pur
, s_hp
= -1, s_str
, s_add
, s_ac
= 0;
144 static long s_exp
= 0;
147 * If nothing has changed since the last status, don't
150 if (s_hp
== pstats
.s_hpt
&& s_exp
== pstats
.s_exp
&& s_pur
== purse
151 && s_ac
== (cur_armor
!= NULL
? cur_armor
->o_ac
: pstats
.s_arm
)
152 && s_str
== pstats
.s_str
.st_str
&& s_add
== pstats
.s_str
.st_add
153 && s_lvl
== level
&& s_hungry
== hungry_state
)
159 temp
= s_hp
= max_hp
;
160 for (hpwidth
= 0; temp
; hpwidth
++)
163 sprintf(buf
, "Level: %d Gold: %-5d Hp: %*d(%*d) Str: %-2d",
164 level
, purse
, hpwidth
, pstats
.s_hpt
, hpwidth
, max_hp
,
165 pstats
.s_str
.st_str
);
166 if (pstats
.s_str
.st_add
!= 0)
168 pb
= &buf
[strlen(buf
)];
169 sprintf(pb
, "/%d", pstats
.s_str
.st_add
);
171 pb
= &buf
[strlen(buf
)];
172 sprintf(pb
, " Ac: %-2d Exp: %d/%ld",
173 cur_armor
!= NULL
? cur_armor
->o_ac
: pstats
.s_arm
, pstats
.s_lvl
,
181 s_str
= pstats
.s_str
.st_str
;
182 s_add
= pstats
.s_str
.st_add
;
183 s_exp
= pstats
.s_exp
;
184 s_ac
= (cur_armor
!= NULL
? cur_armor
->o_ac
: pstats
.s_arm
);
185 mvwaddstr(cw
, LINES
- 1, 0, buf
);
186 switch (hungry_state
)
190 waddstr(cw
, " Hungry");
192 waddstr(cw
, " Weak");
194 waddstr(cw
, " Fainting");
197 s_hungry
= hungry_state
;
203 * Sit around until the guy types the right key
213 while ((c
= readchar(win
)) != '\n' && c
!= '\r')
216 while (readchar(win
) != ch
)
222 * function used to display a window and wait before returning
225 show_win(scr
, message
)
226 register WINDOW
*scr
;
229 mvwaddstr(scr
, 0, 0, message
);
231 wmove(scr
, hero
.y
, hero
.x
);