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);
85 /* wait for user action -- OK to do nothing if on a TTY */
91 void pause_game(int i) {
101 prompt = "[ANOUNCEMENT ARRIVING...]";
103 prompt = "[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]";
107 prompt = "[CONTINUE?]";
109 prompt = "[PRESS ENTER TO CONTINUE]";
114 waddch(stdscr, '\n');
115 waddstr(stdscr, prompt);
116 wgetnstr(stdscr, buf, sizeof(buf));
122 fgets(buf, sizeof(buf), stdin);
124 /* much more in that old-TTY spirit to throw linefeeds */
126 for (j = 0; j < screenheight; j++)
147 if (y == screenheight-1)
150 waddch(stdscr, '\n');
153 if (linecount >= screenheight)
159 while (i-- > 0) proutn("\n\r");
162 static void vproutn(char *fmt, va_list ap) {
164 vasprintf(&s, fmt, ap);
166 if ((curwnd==4)&&(wherey()==wnds[curwnd].wndbottom-wnds[curwnd].wndtop)){
167 if (strchr(s,'\n')) {
177 if ((curwnd==4)&&(wherey()>wnds[curwnd].wndbottom-wnds[curwnd].wndtop+1))
180 if (strchr(s,'\n') || strchr(s,'\r')) clreol();
186 void proutn(char *fmt, ...) {
191 vw_printw(stdscr, fmt, ap);
201 void prout(char *fmt, ...) {
206 vw_printw(stdscr, fmt, ap);
217 void proutc(char *line) {
218 line[strlen(line)-1] = '\0';
221 waddstr(stdscr, line);
231 static void prchr(char *s){
238 static void vprouts(char *fmt, va_list ap) {
240 vasprintf(&s, fmt, ap);
250 void prouts(char *fmt, ...) {
253 char *s, buf[BUFSIZ];
257 vsprintf(buf, fmt, ap);
260 for (s = buf; *s; s++) {
261 endTime = clock() + CLOCKS_PER_SEC*0.05;
262 while (clock() < endTime) continue;
280 void c_printf (char *format, ... )
282 char buffer[BUFSIZ]; /* Well, BUFSIZ is from ncurses... */
284 va_start(argp,format);
285 vsprintf(buffer,format,argp);
288 waddstr(conio_scr,buffer);
295 /* sound and visual effects for teleportation */
308 prouts(" . . . . . ");
312 void setpassword(void) {
316 strcpy(game.passwd, citem);
318 if (*game.passwd != 0) break;
319 proutn("Please type in a secret password-");
323 for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));
328 void getline(char *line, int max) {
331 wgetnstr(stdscr, line, max);
336 memmove(line,&line[2],max-3);
339 fgets(line, max, stdin);
340 line[strlen(line)-1] = '\0';
344 void commandhook(char *cmd, int before) {