27 static int linecount; /* for paging */
29 static int screenheight = 24, screenwidth = 80;
31 static int curses = FALSE;
33 static int curses = TRUE;
36 static void outro(int sig) {
37 /* wrap up, either normally or due to signal */
47 static void fastexit(int sig) {
53 void iostart(int usecurses) {
54 (void) signal(SIGINT, fastexit);
55 (void) signal(SIGINT, fastexit);
57 (void) signal(SIGIOT,fastexit); /* for assert(3) */
59 if(signal(SIGQUIT,SIG_IGN) != SIG_IGN)
60 (void)signal(SIGQUIT,fastexit);
62 if ((curses = usecurses)) {
71 scrollok(stdscr, TRUE);
72 getmaxyx(stdscr, screenheight, screenwidth);
74 char *LINES = getenv("LINES");
76 screenheight = atoi(LINES);
84 void clearscreen(void) {
85 /* Somehow we need to clear the screen */
87 extern void clrscr(void);
94 // proutn("\033[2J"); /* Hope for an ANSI display */
95 /* much more in that old-TTY spirit to just throw linefeeds */
97 for (i = 0; i < screenheight; i++)
104 /* wait for user action -- OK to do nothing if on a TTY */
110 void pause_game(int i) {
120 prompt = "[ANOUNCEMENT ARRIVING...]";
122 prompt = "[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]";
126 prompt = "[CONTINUE?]";
128 prompt = "[PRESS ENTER TO CONTINUE]";
133 waddch(stdscr, '\n');
134 waddstr(stdscr, prompt);
135 wgetnstr(stdscr, buf, sizeof(buf));
141 fgets(buf, sizeof(buf), stdin);
163 if (y == screenheight-1)
166 waddch(stdscr, '\n');
169 if (linecount >= screenheight)
175 while (i-- > 0) proutn("\n\r");
178 static void vproutn(char *fmt, va_list ap) {
180 vasprintf(&s, fmt, ap);
182 if ((curwnd==4)&&(wherey()==wnds[curwnd].wndbottom-wnds[curwnd].wndtop)){
183 if (strchr(s,'\n')) {
193 if ((curwnd==4)&&(wherey()>wnds[curwnd].wndbottom-wnds[curwnd].wndtop+1))
196 if (strchr(s,'\n') || strchr(s,'\r')) clreol();
202 void proutn(char *fmt, ...) {
207 vw_printw(stdscr, fmt, ap);
217 void prout(char *fmt, ...) {
222 vw_printw(stdscr, fmt, ap);
233 void proutc(char *line) {
234 line[strlen(line)-1] = '\0';
237 waddstr(stdscr, line);
247 static void prchr(char *s){
254 static void vprouts(char *fmt, va_list ap) {
256 vasprintf(&s, fmt, ap);
266 void prouts(char *fmt, ...) {
269 char *s, buf[BUFSIZ];
273 vsprintf(buf, fmt, ap);
276 for (s = buf; *s; s++) {
277 endTime = clock() + CLOCKS_PER_SEC*0.05;
278 while (clock() < endTime) continue;
297 /* sound and visual effects for teleportation */
310 prouts(" . . . . . ");
314 void setpassword(void) {
318 strcpy(game.passwd, citem);
320 if (*game.passwd != 0) break;
321 proutn("Please type in a secret password-");
325 for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));
330 void getline(char *line, int max) {
333 wgetnstr(stdscr, line, max);
338 memmove(line,&line[2],max-3);
341 fgets(line, max, stdin);
342 line[strlen(line)-1] = '\0';
346 void commandhook(char *cmd, int before) {