15 static int linecount; /* for paging */
17 static int screenheight = 24, screenwidth = 80;
19 static int curses = FALSE;
21 static int curses = TRUE;
25 wnd wnds[6]={{1,1,80,25}, /* FULLSCREEN_WINDOW */
26 {1,1,25,12}, /* LEFTUPPER_WINDOW */
27 {26,2,80,12}, /* SRSCAN_WINDOW */
28 {65,1,80,10}, /* LRSCAN_WINDOW */
29 {1,13,80,23}, /* LOWER_WINDOW */
30 {1,24,80,25}, /* BOTTOM_WINDOW */
35 static void outro(int sig) {
36 /* wrap up, either normally or due to signal */
46 static void fastexit(int sig) {
52 void iostart(int usecurses) {
53 (void) signal(SIGINT, fastexit);
54 (void) signal(SIGINT, fastexit);
56 (void) signal(SIGIOT,fastexit); /* for assert(3) */
58 if(signal(SIGQUIT,SIG_IGN) != SIG_IGN)
59 (void)signal(SIGQUIT,fastexit);
61 if ((curses = usecurses)) {
70 scrollok(stdscr, TRUE);
71 getmaxyx(stdscr, screenheight, screenwidth);
73 char *LINES = getenv("LINES");
75 screenheight = atoi(LINES);
84 /* wait for user action -- OK to do nothing if on a TTY */
90 void pause_game(int i) {
96 setwnd(BOTTOM_WINDOW);
100 prompt = "[ANOUNCEMENT ARRIVING...]";
102 prompt = "[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]";
106 prompt = "[CONTINUE?]";
108 prompt = "[PRESS ENTER TO CONTINUE]";
113 waddch(stdscr, '\n');
114 waddstr(stdscr, prompt);
115 wgetnstr(stdscr, buf, sizeof(buf));
121 fgets(buf, sizeof(buf), stdin);
123 /* much more in that old-TTY spirit to throw linefeeds */
125 for (j = 0; j < screenheight; j++)
134 setwnd(LOWER_WINDOW);
146 if (y == screenheight-1)
149 waddch(stdscr, '\n');
152 if (linecount >= screenheight)
158 while (i-- > 0) proutn("\n\r");
161 static void vproutn(char *fmt, va_list ap) {
163 vasprintf(&s, fmt, ap);
165 if ((curwnd==LOWER_WINDOW)&&(wherey()==wnds[curwnd].wndbottom-wnds[curwnd].wndtop)){
166 if (strchr(s,'\n')) {
176 if ((curwnd==LOWER_WINDOW)&&(wherey()>wnds[curwnd].wndbottom-wnds[curwnd].wndtop+1))
179 if (strchr(s,'\n') || strchr(s,'\r')) clreol();
185 void proutn(char *fmt, ...) {
190 vw_printw(stdscr, fmt, ap);
200 void prout(char *fmt, ...) {
205 vw_printw(stdscr, fmt, ap);
216 void proutc(char *line) {
217 line[strlen(line)-1] = '\0';
220 waddstr(stdscr, line);
230 static void prchr(char *s){
237 static void vprouts(char *fmt, va_list ap) {
239 vasprintf(&s, fmt, ap);
249 void prouts(char *fmt, ...) {
252 char *s, buf[BUFSIZ];
256 vsprintf(buf, fmt, ap);
259 for (s = buf; *s; s++) {
260 endTime = clock() + CLOCKS_PER_SEC*0.05;
261 while (clock() < endTime) continue;
279 void c_printf (char *format, ... )
281 char buffer[BUFSIZ]; /* Well, BUFSIZ is from ncurses... */
283 va_start(argp,format);
284 vsprintf(buffer,format,argp);
287 waddstr(conio_scr,buffer);
294 /* sound and visual effects for teleportation */
301 setwnd(LOWER_WINDOW);
307 prouts(" . . . . . ");
311 void setpassword(void) {
315 strcpy(game.passwd, citem);
317 if (*game.passwd != 0) break;
318 proutn("Please type in a secret password-");
322 for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));
327 void cgetline(char *line, int max) {
330 wgetnstr(stdscr, line, max);
335 memmove(line,&line[2],max-3);
338 fgets(line, max, stdin);
339 line[strlen(line)-1] = '\0';
343 void setwnd(short wndnum){
344 /* change windows -- OK for this to be a no-op in tty mode */
347 cury=wherey()+wnds[curwnd].wndtop-wnds[wndnum].wndtop;
348 if ((curwnd==FULLSCREEN_WINDOW)&&(wndnum!=FULLSCREEN_WINDOW)) clrscr();
349 window(wnds[wndnum].wndleft, wnds[wndnum].wndtop, wnds[wndnum].wndright, wnds[wndnum].wndbottom);
350 if ((curwnd==wndnum)&&(cury>wnds[wndnum].wndbottom-wnds[wndnum].wndtop+1)){
351 gotoxy(wnds[wndnum].wndright-wnds[wndnum].wndleft+1,wnds[wndnum].wndbottom-wnds[wndnum].wndtop+1);
359 void commandhook(char *cmd, int before) {