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) {
306 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 void boom(int ii, int jj)
324 /* enemy fall down, go boom */
326 if (game.options & OPTION_CURSES) {
327 setwnd(srscan_window);
329 wmove(srscan_window, ii*2+3, jj+2);
330 wattron(srscan_window, A_REVERSE);
331 waddch(srscan_window, game.quad[ii][jj]);
332 wrefresh(srscan_window);
336 wmove(srscan_window, ii*2+3, jj+2);
337 wattroff(srscan_window, A_REVERSE);
338 waddch(srscan_window, game.quad[ii][jj]);
339 wrefresh(srscan_window);
340 setwnd(message_window);
346 /* sound and visual effects for teleportation */
348 if (game.options & OPTION_CURSES) {
350 setwnd(message_window);
355 prouts(" . . . . . ");
358 void tracktorpedo(int x, int y, int ix, int iy, int wait, int l, int i, int n, int iquad)
359 /* torpedo-track animation */
361 if (!game.options & OPTION_CURSES) {
365 proutn("Track for torpedo number %d- ", i);
369 proutn("Torpedo track- ");
371 } else if (l==4 || l==9)
373 proutn("%d - %d ", (int)x, (int)y);
375 if (game.damage[DSRSENS]==0 || condit==IHDOCKED) {
377 delay((wait!=1)*400);
378 if ((game.quad[ix][iy]==IHDOT)||(game.quad[ix][iy]==IHBLANK)){
379 game.quad[ix][iy]='+';
381 game.quad[ix][iy]=iquad;
387 game.quad[ix][iy] |= DAMAGED;
389 game.quad[ix][iy]=iquad;
393 wattroff(curwnd, A_REVERSE);
396 proutn("%d - %d ", (int)x, (int)y);
403 if (game.options & OPTION_CURSES) {
404 setwnd(message_window);
405 wclear(message_window);
410 void setpassword(void)
412 if (!(game.options & OPTION_CURSES)) {
415 strcpy(game.passwd, citem);
417 if (*game.passwd != 0) break;
418 proutn("Please type in a secret password-");
422 for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));