11 static int rows, linecount; /* for paging */
14 WINDOW *fullscreen_window;
15 WINDOW *srscan_window;
16 WINDOW *report_window;
17 WINDOW *lrscan_window;
18 WINDOW *message_window;
19 WINDOW *prompt_window;
21 static void outro(void)
22 /* wrap up, either normally or due to signal */
24 if (game.options & OPTION_CURSES) {
37 if (!(game.options & OPTION_CURSES)) {
38 rows = atoi(getenv("LINES"));
41 fprintf(stderr,"Unable to register outro(), exiting...\n");
54 init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
55 init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
56 init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
57 init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
58 init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
59 init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
60 init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
61 init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
65 fullscreen_window = stdscr;
66 srscan_window = newwin(12, 25, 0, 0);
67 report_window = newwin(10, 0, 1, 25);
68 lrscan_window = newwin(10, 0, 0, 64);
69 message_window = newwin(0, 0, 12, 0);
70 prompt_window = newwin(1, 0, LINES-2, 0);
71 scrollok(message_window, TRUE);
72 setwnd(fullscreen_window);
79 /* wait for user action -- OK to do nothing if on a TTY */
81 if (game.options & OPTION_CURSES)
85 void pause_game(int i)
90 if (game.skill > SKILL_FAIR)
91 prompt = "[ANOUNCEMENT ARRIVING...]";
93 prompt = "[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]";
96 if (game.skill > SKILL_FAIR)
97 prompt = "[CONTINUE?]";
99 prompt = "[PRESS ENTER TO CONTINUE]";
102 if (game.options & OPTION_CURSES) {
104 setwnd(prompt_window);
105 wclear(prompt_window);
106 waddstr(prompt_window, prompt);
107 wgetnstr(prompt_window, buf, sizeof(buf));
108 wclear(prompt_window);
109 wrefresh(prompt_window);
110 setwnd(message_window);
114 fgets(buf, sizeof(buf), stdin);
117 for (j = 0; j < rows; j++)
128 if (game.options & OPTION_CURSES) {
129 if (curwnd == message_window && linecount >= getmaxy(curwnd) - 3) {
134 if (curwnd == message_window)
139 if (linecount >= rows)
147 static void vproutn(char *fmt, va_list ap)
149 if (game.options & OPTION_CURSES) {
150 vwprintw(curwnd, fmt, ap);
157 void proutn(char *fmt, ...)
165 void prout(char *fmt, ...)
174 void prouts(char *fmt, ...)
177 char *s, buf[BUFSIZ];
180 vsprintf(buf, fmt, ap);
182 for (s = buf; *s; s++) {
184 if (game.options & OPTION_CURSES) {
195 void cgetline(char *line, int max)
197 if (game.options & OPTION_CURSES) {
198 wgetnstr(curwnd, line, max);
202 fgets(line, max, stdin);
204 line[strlen(line)-1] = '\0';
207 void setwnd(WINDOW *wnd)
208 /* change windows -- OK for this to be a no-op in tty mode */
210 if (game.options & OPTION_CURSES) {
212 curs_set(wnd == fullscreen_window || wnd == message_window || wnd == prompt_window);
217 /* clear to end of line -- can be a no-op in tty mode */
219 if (game.options & OPTION_CURSES) {
226 /* clear screen -- can be a no-op in tty mode */
228 if (game.options & OPTION_CURSES) {
236 void textcolor (int color)
239 if (game.options & OPTION_CURSES) {
245 wattron(curwnd, COLOR_PAIR(COLOR_BLACK));
248 wattron(curwnd, COLOR_PAIR(COLOR_BLUE));
251 wattron(curwnd, COLOR_PAIR(COLOR_GREEN));
254 wattron(curwnd, COLOR_PAIR(COLOR_CYAN));
257 wattron(curwnd, COLOR_PAIR(COLOR_RED));
260 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA));
263 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW));
266 wattron(curwnd, COLOR_PAIR(COLOR_WHITE));
269 wattron(curwnd, COLOR_PAIR(COLOR_BLACK) | A_BOLD);
272 wattron(curwnd, COLOR_PAIR(COLOR_BLUE) | A_BOLD);
275 wattron(curwnd, COLOR_PAIR(COLOR_GREEN) | A_BOLD);
278 wattron(curwnd, COLOR_PAIR(COLOR_CYAN) | A_BOLD);
281 wattron(curwnd, COLOR_PAIR(COLOR_RED) | A_BOLD);
284 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA) | A_BOLD);
287 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW) | A_BOLD);
290 wattron(curwnd, COLOR_PAIR(COLOR_WHITE) | A_BOLD);
297 void highvideo (void)
299 if (game.options & OPTION_CURSES) {
300 wattron(curwnd, A_REVERSE);
304 void commandhook(char *cmd, int before) {
308 * Things past this point have policy implications.
311 void drawmaps(short l)
312 /* hook to be called after moving to redraw maps */
314 if (game.options & OPTION_CURSES) {
317 setwnd(srscan_window);
322 setwnd(report_window);
323 wclear(report_window);
324 wmove(report_window, 0, 0);
325 srscan(SCAN_NO_LEFTSIDE);
326 setwnd(lrscan_window);
327 wclear(lrscan_window);
328 wmove(lrscan_window, 0, 0);
335 static void put_srscan_sym(int x, int y, char sym)
337 wmove(srscan_window, x+1, y*2+2);
338 waddch(srscan_window, sym);
339 wrefresh(srscan_window);
342 void boom(int ii, int jj)
343 /* enemy fall down, go boom */
345 if (game.options & OPTION_CURSES) {
347 setwnd(srscan_window);
348 wattron(srscan_window, A_REVERSE);
349 put_srscan_sym(ii, jj, game.quad[ii][jj]);
353 wattroff(srscan_window, A_REVERSE);
354 put_srscan_sym(ii, jj, game.quad[ii][jj]);
356 setwnd(message_window);
361 /* sound and visual effects for teleportation */
363 if (game.options & OPTION_CURSES) {
365 setwnd(message_window);
368 prouts(" . . . . . ");
369 if (game.options & OPTION_CURSES) {
375 void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad)
376 /* torpedo-track animation */
378 if (!game.options & OPTION_CURSES) {
382 proutn("Track for torpedo number %d- ", i);
386 proutn("Torpedo track- ");
388 } else if (l==4 || l==9)
390 proutn("%d - %d ", ix, iy);
392 if (game.damage[DSRSENS]==0 || game.condit==IHDOCKED) {
393 if (i != 1 && l == 1) {
397 if ((iquad==IHDOT)||(iquad==IHBLANK)){
398 put_srscan_sym(ix, iy, '+');
402 put_srscan_sym(ix, iy, iquad);
405 wattron(curwnd, A_REVERSE);
406 put_srscan_sym(ix, iy, iquad);
410 wattroff(curwnd, A_REVERSE);
411 put_srscan_sym(ix, iy, iquad);
414 proutn("%d - %d ", ix, iy);
421 if (game.options & OPTION_CURSES) {
422 setwnd(message_window);
423 wclear(message_window);
428 void setpassword(void)
430 if (!(game.options & OPTION_CURSES)) {
433 strcpy(game.passwd, citem);
435 if (*game.passwd != 0) break;
436 proutn("Please type in a secret password-");
440 for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));