27 static int linecount; /* for paging */
29 static int screenheight = 24, screenwidth = 80;
31 static int curses = FALSE;
33 static int curses = TRUE;
37 wnd wnds[6]={{1,1,80,25}, /* FULLSCREEN_WINDOW */
38 {1,1,25,12}, /* LEFTUPPER_WINDOW */
39 {26,2,80,12}, /* SRSCAN_WINDOW */
40 {65,1,80,10}, /* LRSCAN_WINDOW */
41 {1,13,80,23}, /* LOWER_WINDOW */
42 {1,24,80,25}, /* BOTTOM_WINDOW */
47 static void outro(int sig) {
48 /* wrap up, either normally or due to signal */
58 static void fastexit(int sig) {
64 void iostart(int usecurses) {
65 (void) signal(SIGINT, fastexit);
66 (void) signal(SIGINT, fastexit);
68 (void) signal(SIGIOT,fastexit); /* for assert(3) */
70 if(signal(SIGQUIT,SIG_IGN) != SIG_IGN)
71 (void)signal(SIGQUIT,fastexit);
73 if ((curses = usecurses)) {
82 scrollok(stdscr, TRUE);
83 getmaxyx(stdscr, screenheight, screenwidth);
85 char *LINES = getenv("LINES");
87 screenheight = atoi(LINES);
96 /* wait for user action -- OK to do nothing if on a TTY */
102 void pause_game(int i) {
108 setwnd(BOTTOM_WINDOW);
112 prompt = "[ANOUNCEMENT ARRIVING...]";
114 prompt = "[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]";
118 prompt = "[CONTINUE?]";
120 prompt = "[PRESS ENTER TO CONTINUE]";
125 waddch(stdscr, '\n');
126 waddstr(stdscr, prompt);
127 wgetnstr(stdscr, buf, sizeof(buf));
133 fgets(buf, sizeof(buf), stdin);
135 /* much more in that old-TTY spirit to throw linefeeds */
137 for (j = 0; j < screenheight; j++)
146 setwnd(LOWER_WINDOW);
158 if (y == screenheight-1)
161 waddch(stdscr, '\n');
164 if (linecount >= screenheight)
170 while (i-- > 0) proutn("\n\r");
173 static void vproutn(char *fmt, va_list ap) {
175 vasprintf(&s, fmt, ap);
177 if ((curwnd==LOWER_WINDOW)&&(wherey()==wnds[curwnd].wndbottom-wnds[curwnd].wndtop)){
178 if (strchr(s,'\n')) {
188 if ((curwnd==LOWER_WINDOW)&&(wherey()>wnds[curwnd].wndbottom-wnds[curwnd].wndtop+1))
191 if (strchr(s,'\n') || strchr(s,'\r')) clreol();
197 void proutn(char *fmt, ...) {
202 vw_printw(stdscr, fmt, ap);
212 void prout(char *fmt, ...) {
217 vw_printw(stdscr, fmt, ap);
228 void proutc(char *line) {
229 line[strlen(line)-1] = '\0';
232 waddstr(stdscr, line);
242 static void prchr(char *s){
249 static void vprouts(char *fmt, va_list ap) {
251 vasprintf(&s, fmt, ap);
261 void prouts(char *fmt, ...) {
264 char *s, buf[BUFSIZ];
268 vsprintf(buf, fmt, ap);
271 for (s = buf; *s; s++) {
272 endTime = clock() + CLOCKS_PER_SEC*0.05;
273 while (clock() < endTime) continue;
291 void c_printf (char *format, ... )
293 char buffer[BUFSIZ]; /* Well, BUFSIZ is from ncurses... */
295 va_start(argp,format);
296 vsprintf(buffer,format,argp);
299 waddstr(conio_scr,buffer);
306 /* sound and visual effects for teleportation */
313 setwnd(LOWER_WINDOW);
319 prouts(" . . . . . ");
323 void setpassword(void) {
327 strcpy(game.passwd, citem);
329 if (*game.passwd != 0) break;
330 proutn("Please type in a secret password-");
334 for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));
339 void getline(char *line, int max) {
342 wgetnstr(stdscr, line, max);
347 memmove(line,&line[2],max-3);
350 fgets(line, max, stdin);
351 line[strlen(line)-1] = '\0';
355 void setwnd(short wndnum){
356 /* change windows -- OK for this to be a no-op in tty mode */
359 cury=wherey()+wnds[curwnd].wndtop-wnds[wndnum].wndtop;
360 if ((curwnd==FULLSCREEN_WINDOW)&&(wndnum!=FULLSCREEN_WINDOW)) clrscr();
361 window(wnds[wndnum].wndleft, wnds[wndnum].wndtop, wnds[wndnum].wndright, wnds[wndnum].wndbottom);
362 if ((curwnd==wndnum)&&(cury>wnds[wndnum].wndbottom-wnds[wndnum].wndtop+1)){
363 gotoxy(wnds[wndnum].wndright-wnds[wndnum].wndleft+1,wnds[wndnum].wndbottom-wnds[wndnum].wndtop+1);
371 void commandhook(char *cmd, int before) {