11 static int rows, linecount; /* for paging */
15 static void outro(void)
16 /* wrap up, either normally or due to signal */
18 if (game.options & OPTION_CURSES) {
31 if (!(game.options & OPTION_CURSES)) {
32 rows = atoi(getenv("LINES"));
35 fprintf(stderr,"Unable to register outro(), exiting...\n");
48 init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
49 init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
50 init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
51 init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
52 init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
53 init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
54 init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
55 init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
59 fullscreen_window = stdscr;
60 srscan_window = newwin(12, 25, 0, 0);
61 report_window = newwin(10, 0, 1, 25);
62 lrscan_window = newwin(10, 0, 0, 64);
63 message_window = newwin(0, 0, 12, 0);
64 prompt_window = newwin(1, 0, LINES-2, 0);
65 scrollok(message_window, TRUE);
66 setwnd(fullscreen_window);
73 /* wait for user action -- OK to do nothing if on a TTY */
75 if (game.options & OPTION_CURSES)
79 void pause_game(int i)
84 if (skill > SKILL_FAIR)
85 prompt = "[ANOUNCEMENT ARRIVING...]";
87 prompt = "[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]";
90 if (skill > SKILL_FAIR)
91 prompt = "[CONTINUE?]";
93 prompt = "[PRESS ENTER TO CONTINUE]";
96 if (game.options & OPTION_CURSES) {
98 setwnd(prompt_window);
99 wclear(prompt_window);
100 waddstr(prompt_window, prompt);
101 wgetnstr(prompt_window, buf, sizeof(buf));
102 wclear(prompt_window);
103 wrefresh(prompt_window);
104 setwnd(message_window);
108 fgets(buf, sizeof(buf), stdin);
111 for (j = 0; j < rows; j++)
122 if (game.options & OPTION_CURSES) {
123 if (curwnd == message_window && linecount >= getmaxy(curwnd) - 3) {
128 if (curwnd == message_window)
133 if (linecount >= rows)
141 static void vproutn(char *fmt, va_list ap)
143 if (game.options & OPTION_CURSES) {
144 vwprintw(curwnd, fmt, ap);
151 void proutn(char *fmt, ...)
159 void prout(char *fmt, ...)
168 void prouts(char *fmt, ...)
171 char *s, buf[BUFSIZ];
174 vsprintf(buf, fmt, ap);
176 for (s = buf; *s; s++) {
178 if (game.options & OPTION_CURSES) {
189 void cgetline(char *line, int max)
191 if (game.options & OPTION_CURSES) {
192 wgetnstr(curwnd, line, max);
196 fgets(line, max, stdin);
198 line[strlen(line)-1] = '\0';
201 void setwnd(WINDOW *wnd)
202 /* change windows -- OK for this to be a no-op in tty mode */
204 if (game.options & OPTION_CURSES) {
206 curs_set(wnd == fullscreen_window || wnd == message_window || wnd == prompt_window);
211 /* clear to end of line -- can be a no-op in tty mode */
213 if (game.options & OPTION_CURSES) {
220 /* clear screen -- can be a no-op in tty mode */
222 if (game.options & OPTION_CURSES) {
230 void textcolor (int color)
233 if (game.options & OPTION_CURSES) {
239 wattron(curwnd, COLOR_PAIR(COLOR_BLACK));
242 wattron(curwnd, COLOR_PAIR(COLOR_BLUE));
245 wattron(curwnd, COLOR_PAIR(COLOR_GREEN));
248 wattron(curwnd, COLOR_PAIR(COLOR_CYAN));
251 wattron(curwnd, COLOR_PAIR(COLOR_RED));
254 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA));
257 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW));
260 wattron(curwnd, COLOR_PAIR(COLOR_WHITE));
263 wattron(curwnd, COLOR_PAIR(COLOR_BLACK) | A_BOLD);
266 wattron(curwnd, COLOR_PAIR(COLOR_BLUE) | A_BOLD);
269 wattron(curwnd, COLOR_PAIR(COLOR_GREEN) | A_BOLD);
272 wattron(curwnd, COLOR_PAIR(COLOR_CYAN) | A_BOLD);
275 wattron(curwnd, COLOR_PAIR(COLOR_RED) | A_BOLD);
278 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA) | A_BOLD);
281 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW) | A_BOLD);
284 wattron(curwnd, COLOR_PAIR(COLOR_WHITE) | A_BOLD);
291 void highvideo (void)
293 if (game.options & OPTION_CURSES) {
294 wattron(curwnd, A_REVERSE);
298 void commandhook(char *cmd, int before) {
302 * Things past this point have policy implications.
305 void drawmaps(short l)
306 /* hook to be called after moving to redraw maps */
308 if (game.options & OPTION_CURSES) {
311 setwnd(srscan_window);
316 setwnd(report_window);
317 wclear(report_window);
318 wmove(report_window, 0, 0);
319 srscan(SCAN_NO_LEFTSIDE);
320 setwnd(lrscan_window);
321 wclear(lrscan_window);
322 wmove(lrscan_window, 0, 0);
329 static void put_srscan_sym(int x, int y, char sym)
331 wmove(srscan_window, x+1, y*2+2);
332 waddch(srscan_window, sym);
333 wrefresh(srscan_window);
336 void boom(int ii, int jj)
337 /* enemy fall down, go boom */
339 if (game.options & OPTION_CURSES) {
341 setwnd(srscan_window);
342 wattron(srscan_window, A_REVERSE);
343 put_srscan_sym(ii, jj, game.quad[ii][jj]);
347 wattroff(srscan_window, A_REVERSE);
348 put_srscan_sym(ii, jj, game.quad[ii][jj]);
350 setwnd(message_window);
355 /* sound and visual effects for teleportation */
357 if (game.options & OPTION_CURSES) {
359 setwnd(message_window);
362 prouts(" . . . . . ");
363 if (game.options & OPTION_CURSES) {
369 void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad)
370 /* torpedo-track animation */
372 if (!game.options & OPTION_CURSES) {
376 proutn("Track for torpedo number %d- ", i);
380 proutn("Torpedo track- ");
382 } else if (l==4 || l==9)
384 proutn("%d - %d ", ix, iy);
386 if (game.damage[DSRSENS]==0 || condit==IHDOCKED) {
387 if (i != 1 && l == 1) {
391 if ((iquad==IHDOT)||(iquad==IHBLANK)){
392 put_srscan_sym(ix, iy, '+');
396 put_srscan_sym(ix, iy, iquad);
399 wattron(curwnd, A_REVERSE);
400 put_srscan_sym(ix, iy, iquad);
404 wattroff(curwnd, A_REVERSE);
405 put_srscan_sym(ix, iy, iquad);
408 proutn("%d - %d ", ix, iy);
415 if (game.options & OPTION_CURSES) {
416 setwnd(message_window);
417 wclear(message_window);
422 void setpassword(void)
424 if (!(game.options & OPTION_CURSES)) {
427 strcpy(game.passwd, citem);
429 if (*game.passwd != 0) break;
430 proutn("Please type in a secret password-");
434 for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));