12 static int rows, linecount; /* for paging */
16 static void outro(void)
17 /* wrap up, either normally or due to signal */
19 if (game.options & OPTION_CURSES) {
32 if (!(game.options & OPTION_CURSES)) {
33 rows = atoi(getenv("LINES"));
36 fprintf(stderr,"Unable to register outro(), exiting...\n");
49 init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
50 init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
51 init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
52 init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
53 init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
54 init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
55 init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
56 init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
60 fullscreen_window = stdscr;
61 srscan_window = newwin(12, 25, 0, 0);
62 report_window = newwin(10, 0, 1, 25);
63 lrscan_window = newwin(10, 0, 0, 64);
64 message_window = newwin(0, 0, 12, 0);
65 prompt_window = newwin(1, 0, LINES-2, 0);
66 scrollok(message_window, TRUE);
67 setwnd(fullscreen_window);
74 /* wait for user action -- OK to do nothing if on a TTY */
76 if (game.options & OPTION_CURSES)
80 void pause_game(int i)
85 if (skill > SKILL_FAIR)
86 prompt = "[ANOUNCEMENT ARRIVING...]";
88 prompt = "[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]";
91 if (skill > SKILL_FAIR)
92 prompt = "[CONTINUE?]";
94 prompt = "[PRESS ENTER TO CONTINUE]";
97 if (game.options & OPTION_CURSES) {
99 setwnd(prompt_window);
100 wclear(prompt_window);
101 waddstr(prompt_window, prompt);
102 wgetnstr(prompt_window, buf, sizeof(buf));
103 wclear(prompt_window);
104 wrefresh(prompt_window);
105 setwnd(message_window);
109 fgets(buf, sizeof(buf), stdin);
112 for (j = 0; j < rows; j++)
123 if (game.options & OPTION_CURSES) {
124 if (curwnd == message_window && linecount >= getmaxy(curwnd) - 3) {
129 if (curwnd == message_window)
134 if (linecount >= rows)
142 static void vproutn(char *fmt, va_list ap)
144 if (game.options & OPTION_CURSES) {
145 vwprintw(curwnd, fmt, ap);
152 void proutn(char *fmt, ...)
160 void prout(char *fmt, ...)
169 void prouts(char *fmt, ...)
172 char *s, buf[BUFSIZ];
175 vsprintf(buf, fmt, ap);
177 for (s = buf; *s; s++) {
179 if (game.options & OPTION_CURSES) {
190 void cgetline(char *line, int max)
192 if (game.options & OPTION_CURSES) {
193 wgetnstr(curwnd, line, max);
197 fgets(line, max, stdin);
199 line[strlen(line)-1] = '\0';
202 void setwnd(WINDOW *wnd)
203 /* change windows -- OK for this to be a no-op in tty mode */
205 if (game.options & OPTION_CURSES) {
207 curs_set(wnd == fullscreen_window || wnd == message_window || wnd == prompt_window);
212 /* clear to end of line -- can be a no-op in tty mode */
214 if (game.options & OPTION_CURSES) {
221 /* clear screen -- can be a no-op in tty mode */
223 if (game.options & OPTION_CURSES) {
231 void textcolor (int color)
234 if (game.options & OPTION_CURSES) {
240 wattron(curwnd, COLOR_PAIR(COLOR_BLACK));
243 wattron(curwnd, COLOR_PAIR(COLOR_BLUE));
246 wattron(curwnd, COLOR_PAIR(COLOR_GREEN));
249 wattron(curwnd, COLOR_PAIR(COLOR_CYAN));
252 wattron(curwnd, COLOR_PAIR(COLOR_RED));
255 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA));
258 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW));
261 wattron(curwnd, COLOR_PAIR(COLOR_WHITE));
264 wattron(curwnd, COLOR_PAIR(COLOR_BLACK) | A_BOLD);
267 wattron(curwnd, COLOR_PAIR(COLOR_BLUE) | A_BOLD);
270 wattron(curwnd, COLOR_PAIR(COLOR_GREEN) | A_BOLD);
273 wattron(curwnd, COLOR_PAIR(COLOR_CYAN) | A_BOLD);
276 wattron(curwnd, COLOR_PAIR(COLOR_RED) | A_BOLD);
279 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA) | A_BOLD);
282 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW) | A_BOLD);
285 wattron(curwnd, COLOR_PAIR(COLOR_WHITE) | A_BOLD);
292 void highvideo (void)
294 if (game.options & OPTION_CURSES) {
295 wattron(curwnd, A_REVERSE);
299 void commandhook(char *cmd, int before) {
303 * Things past this point have policy implications.
306 void drawmaps(short l)
307 /* hook to be called after moving to redraw maps */
309 if (game.options & OPTION_CURSES) {
312 setwnd(srscan_window);
317 setwnd(report_window);
318 wclear(report_window);
319 wmove(report_window, 0, 0);
320 srscan(SCAN_NO_LEFTSIDE);
321 setwnd(lrscan_window);
322 wclear(lrscan_window);
323 wmove(lrscan_window, 0, 0);
330 static void put_srscan_sym(int x, int y, char sym)
332 wmove(srscan_window, x+1, y*2+2);
333 waddch(srscan_window, sym);
334 wrefresh(srscan_window);
337 void boom(int ii, int jj)
338 /* enemy fall down, go boom */
340 if (game.options & OPTION_CURSES) {
342 setwnd(srscan_window);
343 wattron(srscan_window, A_REVERSE);
344 put_srscan_sym(ii, jj, game.quad[ii][jj]);
348 wattroff(srscan_window, A_REVERSE);
349 put_srscan_sym(ii, jj, game.quad[ii][jj]);
351 setwnd(message_window);
356 /* sound and visual effects for teleportation */
358 if (game.options & OPTION_CURSES) {
360 setwnd(message_window);
363 prouts(" . . . . . ");
364 if (game.options & OPTION_CURSES) {
370 void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad)
371 /* torpedo-track animation */
373 if (!game.options & OPTION_CURSES) {
377 proutn("Track for torpedo number %d- ", i);
381 proutn("Torpedo track- ");
383 } else if (l==4 || l==9)
385 proutn("%d - %d ", ix, iy);
387 if (game.damage[DSRSENS]==0 || condit==IHDOCKED) {
388 if (i != 1 && l == 1) {
392 if ((iquad==IHDOT)||(iquad==IHBLANK)){
393 put_srscan_sym(ix, iy, '+');
397 put_srscan_sym(ix, iy, iquad);
400 wattron(curwnd, A_REVERSE);
401 put_srscan_sym(ix, iy, iquad);
405 wattroff(curwnd, A_REVERSE);
406 put_srscan_sym(ix, iy, iquad);
409 proutn("%d - %d ", ix, iy);
416 if (game.options & OPTION_CURSES) {
417 setwnd(message_window);
418 wclear(message_window);
423 void setpassword(void)
425 if (!(game.options & OPTION_CURSES)) {
428 strcpy(game.passwd, citem);
430 if (*game.passwd != 0) break;
431 proutn("Please type in a secret password-");
435 for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));