8 static int rows, linecount; /* for paging */
11 WINDOW *fullscreen_window;
12 WINDOW *srscan_window;
13 WINDOW *report_window;
14 WINDOW *lrscan_window;
15 WINDOW *message_window;
16 WINDOW *prompt_window;
18 static void outro(void)
19 /* wrap up, either normally or due to signal */
21 if (game.options & OPTION_CURSES) {
34 setlocale(LC_ALL, "");
35 bindtextdomain(PACKAGE, LOCALEDIR);
39 if (!(game.options & OPTION_CURSES)) {
40 rows = atoi(getenv("LINES"));
43 fprintf(stderr,"Unable to register outro(), exiting...\n");
56 init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
57 init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
58 init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
59 init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
60 init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
61 init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
62 init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
63 init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
67 fullscreen_window = stdscr;
68 srscan_window = newwin(12, 25, 0, 0);
69 report_window = newwin(10, 0, 1, 25);
70 lrscan_window = newwin(10, 0, 0, 64);
71 message_window = newwin(0, 0, 12, 0);
72 prompt_window = newwin(1, 0, LINES-2, 0);
73 scrollok(message_window, TRUE);
74 setwnd(fullscreen_window);
81 /* wait for user action -- OK to do nothing if on a TTY */
83 if (game.options & OPTION_CURSES)
87 void pause_game(int i)
92 if (game.skill > SKILL_FAIR)
93 prompt = "[ANOUNCEMENT ARRIVING...]";
95 prompt = "[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]";
98 if (game.skill > SKILL_FAIR)
99 prompt = "[CONTINUE?]";
101 prompt = "[PRESS ENTER TO CONTINUE]";
104 if (game.options & OPTION_CURSES) {
106 setwnd(prompt_window);
107 wclear(prompt_window);
108 waddstr(prompt_window, prompt);
109 wgetnstr(prompt_window, buf, sizeof(buf));
110 wclear(prompt_window);
111 wrefresh(prompt_window);
112 setwnd(message_window);
116 fgets(buf, sizeof(buf), stdin);
119 for (j = 0; j < rows; j++)
130 if (game.options & OPTION_CURSES) {
131 if (curwnd == message_window && linecount >= getmaxy(curwnd) - 3) {
136 if (curwnd == message_window)
141 if (linecount >= rows)
149 static void vproutn(char *fmt, va_list ap)
151 if (game.options & OPTION_CURSES) {
152 vwprintw(curwnd, fmt, ap);
159 void proutn(char *fmt, ...)
167 void prout(char *fmt, ...)
176 void prouts(char *fmt, ...)
179 char *s, buf[BUFSIZ];
182 vsprintf(buf, fmt, ap);
184 for (s = buf; *s; s++) {
186 if (game.options & OPTION_CURSES) {
197 void cgetline(char *line, int max)
199 if (game.options & OPTION_CURSES) {
200 wgetnstr(curwnd, line, max);
204 fgets(line, max, stdin);
206 line[strlen(line)-1] = '\0';
209 void setwnd(WINDOW *wnd)
210 /* change windows -- OK for this to be a no-op in tty mode */
212 if (game.options & OPTION_CURSES) {
214 curs_set(wnd == fullscreen_window || wnd == message_window || wnd == prompt_window);
219 /* clear to end of line -- can be a no-op in tty mode */
221 if (game.options & OPTION_CURSES) {
228 /* clear screen -- can be a no-op in tty mode */
230 if (game.options & OPTION_CURSES) {
238 void textcolor (int color)
241 if (game.options & OPTION_CURSES) {
247 wattron(curwnd, COLOR_PAIR(COLOR_BLACK));
250 wattron(curwnd, COLOR_PAIR(COLOR_BLUE));
253 wattron(curwnd, COLOR_PAIR(COLOR_GREEN));
256 wattron(curwnd, COLOR_PAIR(COLOR_CYAN));
259 wattron(curwnd, COLOR_PAIR(COLOR_RED));
262 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA));
265 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW));
268 wattron(curwnd, COLOR_PAIR(COLOR_WHITE));
271 wattron(curwnd, COLOR_PAIR(COLOR_BLACK) | A_BOLD);
274 wattron(curwnd, COLOR_PAIR(COLOR_BLUE) | A_BOLD);
277 wattron(curwnd, COLOR_PAIR(COLOR_GREEN) | A_BOLD);
280 wattron(curwnd, COLOR_PAIR(COLOR_CYAN) | A_BOLD);
283 wattron(curwnd, COLOR_PAIR(COLOR_RED) | A_BOLD);
286 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA) | A_BOLD);
289 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW) | A_BOLD);
292 wattron(curwnd, COLOR_PAIR(COLOR_WHITE) | A_BOLD);
299 void highvideo (void)
301 if (game.options & OPTION_CURSES) {
302 wattron(curwnd, A_REVERSE);
306 void commandhook(char *cmd, int before) {
310 * Things past this point have policy implications.
313 void drawmaps(short l)
314 /* hook to be called after moving to redraw maps */
316 if (game.options & OPTION_CURSES) {
319 setwnd(srscan_window);
324 setwnd(report_window);
325 wclear(report_window);
326 wmove(report_window, 0, 0);
327 srscan(SCAN_NO_LEFTSIDE);
328 setwnd(lrscan_window);
329 wclear(lrscan_window);
330 wmove(lrscan_window, 0, 0);
337 static void put_srscan_sym(int x, int y, char sym)
339 wmove(srscan_window, x+1, y*2+2);
340 waddch(srscan_window, sym);
341 wrefresh(srscan_window);
344 void boom(int ii, int jj)
345 /* enemy fall down, go boom */
347 if (game.options & OPTION_CURSES) {
349 setwnd(srscan_window);
350 wattron(srscan_window, A_REVERSE);
351 put_srscan_sym(ii, jj, game.quad[ii][jj]);
355 wattroff(srscan_window, A_REVERSE);
356 put_srscan_sym(ii, jj, game.quad[ii][jj]);
358 setwnd(message_window);
363 /* sound and visual effects for teleportation */
365 if (game.options & OPTION_CURSES) {
367 setwnd(message_window);
370 prouts(" . . . . . ");
371 if (game.options & OPTION_CURSES) {
377 void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad)
378 /* torpedo-track animation */
380 if (!game.options & OPTION_CURSES) {
384 proutn("Track for torpedo number %d- ", i);
388 proutn("Torpedo track- ");
390 } else if (l==4 || l==9)
392 proutn("%d - %d ", ix, iy);
394 if (game.damage[DSRSENS]==0 || game.condit==IHDOCKED) {
395 if (i != 1 && l == 1) {
399 if ((iquad==IHDOT)||(iquad==IHBLANK)){
400 put_srscan_sym(ix, iy, '+');
404 put_srscan_sym(ix, iy, iquad);
407 wattron(curwnd, A_REVERSE);
408 put_srscan_sym(ix, iy, iquad);
412 wattroff(curwnd, A_REVERSE);
413 put_srscan_sym(ix, iy, iquad);
416 proutn("%d - %d ", ix, iy);
423 if (game.options & OPTION_CURSES) {
424 setwnd(message_window);
425 wclear(message_window);
430 void setpassword(void)
432 if (!(game.options & OPTION_CURSES)) {
435 strcpy(game.passwd, citem);
437 if (*game.passwd != 0) break;
438 proutn("Please type in a secret password-");
442 for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));