16 static int linecount; /* for paging */
18 static int screenheight = 24, screenwidth = 80;
20 static int curses = FALSE;
22 static int curses = TRUE;
26 wnd wnds[6]={{1,1,80,25}, /* FULLSCREEN_WINDOW */
27 {1,1,25,12}, /* LEFTUPPER_WINDOW */
28 {26,2,80,12}, /* SRSCAN_WINDOW */
29 {65,1,80,10}, /* LRSCAN_WINDOW */
30 {1,13,80,23}, /* LOWER_WINDOW */
31 {1,24,80,25}, /* BOTTOM_WINDOW */
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) {
97 setwnd(BOTTOM_WINDOW);
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++)
135 setwnd(LOWER_WINDOW);
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==LOWER_WINDOW)&&(wherey()==wnds[curwnd].wndbottom-wnds[curwnd].wndtop)){
167 if (strchr(s,'\n')) {
177 if ((curwnd==LOWER_WINDOW)&&(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 */
302 setwnd(LOWER_WINDOW);
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 cgetline(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 setwnd(short wndnum){
345 /* change windows -- OK for this to be a no-op in tty mode */
348 cury=wherey()+wnds[curwnd].wndtop-wnds[wndnum].wndtop;
349 if ((curwnd==FULLSCREEN_WINDOW)&&(wndnum!=FULLSCREEN_WINDOW)) clrscr();
350 window(wnds[wndnum].wndleft, wnds[wndnum].wndtop, wnds[wndnum].wndright, wnds[wndnum].wndbottom);
351 if ((curwnd==wndnum)&&(cury>wnds[wndnum].wndbottom-wnds[wndnum].wndtop+1)){
352 gotoxy(wnds[wndnum].wndright-wnds[wndnum].wndleft+1,wnds[wndnum].wndbottom-wnds[wndnum].wndtop+1);
360 void commandhook(char *cmd, int before) {