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);
170 for (s = buf; *s; s++) {
172 if (game.options & OPTION_CURSES) {
183 void cgetline(char *line, int max)
185 if (game.options & OPTION_CURSES) {
186 wgetnstr(curwnd, line, max);
190 fgets(line, max, stdin);
192 line[strlen(line)-1] = '\0';
195 void setwnd(WINDOW *wnd)
196 /* change windows -- OK for this to be a no-op in tty mode */
198 if (game.options & OPTION_CURSES) {
200 curs_set(wnd == fullscreen_window || wnd == message_window || wnd == prompt_window);
205 /* clear to end of line -- can be a no-op in tty mode */
207 if (game.options & OPTION_CURSES) {
214 /* clear screen -- can be a no-op in tty mode */
216 if (game.options & OPTION_CURSES) {
223 void textcolor (int color)
226 if (game.options & OPTION_CURSES) {
232 wattron(curwnd, COLOR_PAIR(COLOR_BLACK));
235 wattron(curwnd, COLOR_PAIR(COLOR_BLUE));
238 wattron(curwnd, COLOR_PAIR(COLOR_GREEN));
241 wattron(curwnd, COLOR_PAIR(COLOR_CYAN));
244 wattron(curwnd, COLOR_PAIR(COLOR_RED));
247 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA));
250 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW));
253 wattron(curwnd, COLOR_PAIR(COLOR_WHITE));
256 wattron(curwnd, COLOR_PAIR(COLOR_BLACK) | A_BOLD);
259 wattron(curwnd, COLOR_PAIR(COLOR_BLUE) | A_BOLD);
262 wattron(curwnd, COLOR_PAIR(COLOR_GREEN) | A_BOLD);
265 wattron(curwnd, COLOR_PAIR(COLOR_CYAN) | A_BOLD);
268 wattron(curwnd, COLOR_PAIR(COLOR_RED) | A_BOLD);
271 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA) | A_BOLD);
274 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW) | A_BOLD);
277 wattron(curwnd, COLOR_PAIR(COLOR_WHITE) | A_BOLD);
284 void highvideo (void)
286 if (game.options & OPTION_CURSES) {
287 wattron(curwnd, A_REVERSE);
291 void commandhook(char *cmd, int before) {
295 * Things past this point have policy implications.
298 void drawmaps(short l)
299 /* hook to be called after moving to redraw maps */
301 if (game.options & OPTION_CURSES) {
304 setwnd(srscan_window);
309 setwnd(report_window);
310 wclear(report_window);
311 wmove(report_window, 0, 0);
312 srscan(SCAN_NO_LEFTSIDE);
313 setwnd(lrscan_window);
314 wclear(lrscan_window);
315 wmove(lrscan_window, 0, 0);
322 static void put_srscan_sym(int x, int y, char sym)
324 wmove(srscan_window, x+1, y*2+2);
325 waddch(srscan_window, sym);
326 wrefresh(srscan_window);
329 void boom(int ii, int jj)
330 /* enemy fall down, go boom */
332 if (game.options & OPTION_CURSES) {
334 setwnd(srscan_window);
335 wattron(srscan_window, A_REVERSE);
336 put_srscan_sym(ii, jj, game.quad[ii][jj]);
340 wattroff(srscan_window, A_REVERSE);
341 put_srscan_sym(ii, jj, game.quad[ii][jj]);
343 setwnd(message_window);
348 /* sound and visual effects for teleportation */
350 if (game.options & OPTION_CURSES) {
352 setwnd(message_window);
355 prouts(" . . . . . ");
356 if (game.options & OPTION_CURSES) {
362 void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad)
363 /* torpedo-track animation */
365 if (!game.options & OPTION_CURSES) {
369 proutn("Track for torpedo number %d- ", i);
373 proutn("Torpedo track- ");
375 } else if (l==4 || l==9)
377 proutn("%d - %d ", ix, iy);
379 if (game.damage[DSRSENS]==0 || condit==IHDOCKED) {
380 if (i != 1 && l == 1) {
384 if ((iquad==IHDOT)||(iquad==IHBLANK)){
385 put_srscan_sym(ix, iy, '+');
389 put_srscan_sym(ix, iy, iquad);
392 wattron(curwnd, A_REVERSE);
393 put_srscan_sym(ix, iy, iquad);
397 wattroff(curwnd, A_REVERSE);
398 put_srscan_sym(ix, iy, iquad);
401 proutn("%d - %d ", ix, iy);
408 if (game.options & OPTION_CURSES) {
409 setwnd(message_window);
410 wclear(message_window);
415 void setpassword(void)
417 if (!(game.options & OPTION_CURSES)) {
420 strcpy(game.passwd, citem);
422 if (*game.passwd != 0) break;
423 proutn("Please type in a secret password-");
427 for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));