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) {
127 if (linecount >= rows)
135 static void vproutn(char *fmt, va_list ap)
137 if (game.options & OPTION_CURSES) {
138 vwprintw(curwnd, fmt, ap);
145 void proutn(char *fmt, ...)
153 void prout(char *fmt, ...)
162 void prouts(char *fmt, ...)
165 char *s, buf[BUFSIZ];
168 vsprintf(buf, fmt, ap);
171 for (s = buf; *s; s++) {
173 if (game.options & OPTION_CURSES) {
184 void cgetline(char *line, int max)
186 if (game.options & OPTION_CURSES) {
187 wgetnstr(curwnd, line, max);
191 fgets(line, max, stdin);
193 line[strlen(line)-1] = '\0';
196 void setwnd(WINDOW *wnd)
197 /* change windows -- OK for this to be a no-op in tty mode */
199 if (game.options & OPTION_CURSES) {
201 curs_set(wnd == fullscreen_window || wnd == message_window || wnd == prompt_window);
206 /* clear to end of line -- can be a no-op in tty mode */
208 if (game.options & OPTION_CURSES) {
215 /* clear screen -- can be a no-op in tty mode */
217 if (game.options & OPTION_CURSES) {
224 void textcolor (int color)
227 if (game.options & OPTION_CURSES) {
233 wattron(curwnd, COLOR_PAIR(COLOR_BLACK));
236 wattron(curwnd, COLOR_PAIR(COLOR_BLUE));
239 wattron(curwnd, COLOR_PAIR(COLOR_GREEN));
242 wattron(curwnd, COLOR_PAIR(COLOR_CYAN));
245 wattron(curwnd, COLOR_PAIR(COLOR_RED));
248 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA));
251 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW));
254 wattron(curwnd, COLOR_PAIR(COLOR_WHITE));
257 wattron(curwnd, COLOR_PAIR(COLOR_BLACK) | A_BOLD);
260 wattron(curwnd, COLOR_PAIR(COLOR_BLUE) | A_BOLD);
263 wattron(curwnd, COLOR_PAIR(COLOR_GREEN) | A_BOLD);
266 wattron(curwnd, COLOR_PAIR(COLOR_CYAN) | A_BOLD);
269 wattron(curwnd, COLOR_PAIR(COLOR_RED) | A_BOLD);
272 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA) | A_BOLD);
275 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW) | A_BOLD);
278 wattron(curwnd, COLOR_PAIR(COLOR_WHITE) | A_BOLD);
285 void highvideo (void)
287 if (game.options & OPTION_CURSES) {
288 wattron(curwnd, A_REVERSE);
292 void commandhook(char *cmd, int before) {
296 * Things past this point have policy implications.
299 void drawmaps(short l)
300 /* hook to be called after moving to redraw maps */
302 if (game.options & OPTION_CURSES) {
305 setwnd(srscan_window);
310 setwnd(report_window);
311 wclear(report_window);
312 wmove(report_window, 0, 0);
313 srscan(SCAN_NO_LEFTSIDE);
314 setwnd(lrscan_window);
315 wclear(lrscan_window);
316 wmove(lrscan_window, 0, 0);
323 static void put_srscan_sym(int x, int y, char sym)
325 wmove(srscan_window, x+1, y*2+2);
326 waddch(srscan_window, sym);
327 wrefresh(srscan_window);
330 void boom(int ii, int jj)
331 /* enemy fall down, go boom */
333 if (game.options & OPTION_CURSES) {
335 setwnd(srscan_window);
336 wattron(srscan_window, A_REVERSE);
337 put_srscan_sym(ii, jj, game.quad[ii][jj]);
341 wattroff(srscan_window, A_REVERSE);
342 put_srscan_sym(ii, jj, game.quad[ii][jj]);
344 setwnd(message_window);
349 /* sound and visual effects for teleportation */
351 if (game.options & OPTION_CURSES) {
353 setwnd(message_window);
358 prouts(" . . . . . ");
361 void tracktorpedo(int ix, int iy, int l, int i, int n)
362 /* torpedo-track animation */
364 if (!game.options & OPTION_CURSES) {
368 proutn("Track for torpedo number %d- ", i);
372 proutn("Torpedo track- ");
374 } else if (l==4 || l==9)
376 proutn("%d - %d ", ix, iy);
378 if (game.damage[DSRSENS]==0 || condit==IHDOCKED) {
379 if (i != 1 && l == 1) {
383 if ((game.quad[ix][iy]==IHDOT)||(game.quad[ix][iy]==IHBLANK)){
384 put_srscan_sym(ix, iy, '+');
388 put_srscan_sym(ix, iy, game.quad[ix][iy]);
391 wattron(curwnd, A_REVERSE);
392 put_srscan_sym(ix, iy, game.quad[ix][iy]);
396 wattroff(curwnd, A_REVERSE);
397 put_srscan_sym(ix, iy, game.quad[ix][iy]);
400 proutn("%d - %d ", ix, iy);
407 if (game.options & OPTION_CURSES) {
408 setwnd(message_window);
409 wclear(message_window);
414 void setpassword(void)
416 if (!(game.options & OPTION_CURSES)) {
419 strcpy(game.passwd, citem);
421 if (*game.passwd != 0) break;
422 proutn("Please type in a secret password-");
426 for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));