12 static int 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) {
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 < 24; j++)
122 if (game.options & OPTION_CURSES) {
134 static void vproutn(char *fmt, va_list ap)
136 if (game.options & OPTION_CURSES) {
137 vwprintw(curwnd, fmt, ap);
144 void proutn(char *fmt, ...)
152 void prout(char *fmt, ...)
161 void prouts(char *fmt, ...)
164 char *s, buf[BUFSIZ];
167 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) {
305 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 void boom(int ii, int jj)
323 /* enemy fall down, go boom */
325 if (game.options & OPTION_CURSES) {
326 setwnd(srscan_window);
328 wmove(srscan_window, ii*2+3, jj+2);
329 wattron(srscan_window, A_REVERSE);
330 waddch(srscan_window, game.quad[ii][jj]);
331 wrefresh(srscan_window);
335 wmove(srscan_window, ii*2+3, jj+2);
336 wattroff(srscan_window, A_REVERSE);
337 waddch(srscan_window, game.quad[ii][jj]);
338 wrefresh(srscan_window);
339 setwnd(message_window);
345 /* sound and visual effects for teleportation */
347 if (game.options & OPTION_CURSES) {
349 setwnd(message_window);
354 prouts(" . . . . . ");
357 void tracktorpedo(int x, int y, int ix, int iy, int wait, int l, int i, int n, int iquad)
358 /* torpedo-track animation */
360 if (!game.options & OPTION_CURSES) {
364 proutn("Track for torpedo number %d- ", i);
368 proutn("Torpedo track- ");
370 } else if (l==4 || l==9)
372 proutn("%d - %d ", (int)x, (int)y);
374 if (game.damage[DSRSENS]==0 || condit==IHDOCKED) {
376 delay((wait!=1)*400);
377 if ((game.quad[ix][iy]==IHDOT)||(game.quad[ix][iy]==IHBLANK)){
378 game.quad[ix][iy]='+';
380 game.quad[ix][iy]=iquad;
386 game.quad[ix][iy] |= DAMAGED;
388 game.quad[ix][iy]=iquad;
392 wattroff(curwnd, A_REVERSE);
395 proutn("%d - %d ", (int)x, (int)y);
402 if (game.options & OPTION_CURSES) {
403 setwnd(message_window);
404 wclear(message_window);
409 void setpassword(void)
411 if (!(game.options & OPTION_CURSES)) {
414 strcpy(game.passwd, citem);
416 if (*game.passwd != 0) break;
417 proutn("Please type in a secret password-");
421 for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));