13 static int linecount; /* for paging */
14 static int curses = TRUE;
18 static void outro(void)
19 /* wrap up, either normally or due to signal */
32 void iostart(int usecurses)
34 if ((curses = usecurses)) {
37 fprintf(stderr,"Unable to register outro(), exiting...\n");
49 int background = COLOR_WHITE;
51 init_pair(COLOR_BLACK, COLOR_BLACK, background);
52 init_pair(COLOR_GREEN, COLOR_GREEN, background);
53 init_pair(COLOR_RED, COLOR_RED, background);
54 init_pair(COLOR_CYAN, COLOR_CYAN, background);
55 init_pair(COLOR_WHITE, COLOR_WHITE, background);
56 init_pair(COLOR_MAGENTA, COLOR_MAGENTA, background);
57 init_pair(COLOR_BLUE, COLOR_BLUE, background);
58 init_pair(COLOR_YELLOW, COLOR_YELLOW, background);
62 fullscreen_window = stdscr;
63 srscan_window = newwin(12, 25, 0, 0);
64 REPORT_WINDOW = newwin(10, 0, 1, 25);
65 lrscan_window = newwin(10, 0, 0, 64);
66 message_window = newwin(0, 0, 12, 0);
67 prompt_window = newwin(1, 0, LINES-1, 0);
68 scrollok(message_window, TRUE);
69 setwnd(fullscreen_window);
76 /* wait for user action -- OK to do nothing if on a TTY */
82 void pause_game(int i)
88 prompt = "[ANOUNCEMENT ARRIVING...]";
90 prompt = "[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]";
94 prompt = "[CONTINUE?]";
96 prompt = "[PRESS ENTER TO CONTINUE]";
101 setwnd(prompt_window);
102 wclear(prompt_window);
103 waddstr(prompt_window, prompt);
104 wgetnstr(prompt_window, buf, sizeof(buf));
105 wclear(prompt_window);
106 wrefresh(prompt_window);
107 setwnd(message_window);
111 fgets(buf, sizeof(buf), stdin);
114 for (j = 0; j < 24; j++)
137 static void vproutn(char *fmt, va_list ap)
140 vwprintw(curwnd, fmt, ap);
147 void proutn(char *fmt, ...)
155 void prout(char *fmt, ...)
164 void prouts(char *fmt, ...)
168 char *s, buf[BUFSIZ];
171 vsprintf(buf, fmt, ap);
174 for (s = buf; *s; s++) {
175 endTime = clock() + CLOCKS_PER_SEC*0.05;
176 while (clock() < endTime) continue;
188 void cgetline(char *line, int max)
191 wgetnstr(curwnd, line, max);
195 fgets(line, max, stdin);
197 line[strlen(line)-1] = '\0';
200 void setwnd(WINDOW *wnd)
201 /* change windows -- OK for this to be a no-op in tty mode */
205 curs_set(wnd == fullscreen_window || wnd == message_window || wnd == prompt_window);
210 /* clear to end of line -- can be a no-op in tty mode */
219 /* clear screen -- can be a no-op in tty mode */
228 void textcolor (int color)
231 wattroff(curwnd, A_REVERSE);
238 wattron(curwnd, COLOR_PAIR(BLACK));
241 wattron(curwnd, COLOR_PAIR(BLUE));
244 wattron(curwnd, COLOR_PAIR(GREEN));
247 wattron(curwnd, COLOR_PAIR(CYAN));
250 wattron(curwnd, COLOR_PAIR(RED));
253 wattron(curwnd, COLOR_PAIR(MAGENTA));
256 wattron(curwnd, COLOR_PAIR(YELLOW));
259 wattron(curwnd, COLOR_PAIR(WHITE));
262 wattron(curwnd, COLOR_PAIR(BLACK) | A_BOLD);
265 wattron(curwnd, COLOR_PAIR(BLUE) | A_BOLD);
268 wattron(curwnd, COLOR_PAIR(GREEN) | A_BOLD);
271 wattron(curwnd, COLOR_PAIR(CYAN) | A_BOLD);
274 wattron(curwnd, COLOR_PAIR(RED) | A_BOLD);
277 wattron(curwnd, COLOR_PAIR(MAGENTA) | A_BOLD);
280 wattron(curwnd, COLOR_PAIR(YELLOW) | A_BOLD);
283 wattron(curwnd, COLOR_PAIR(WHITE) | A_BOLD);
290 void highvideo (void)
293 wattron(curwnd, A_REVERSE);
297 void commandhook(char *cmd, int before) {
301 * Things past this point have policy implications.
304 void drawmaps(short l)
305 /* hook to be called after moving to redraw maps */
311 setwnd(srscan_window);
315 setwnd(REPORT_WINDOW);
316 wclear(REPORT_WINDOW);
317 wmove(REPORT_WINDOW, 0, 0);
318 srscan(SCAN_NO_LEFTSIDE);
319 setwnd(lrscan_window);
320 wclear(lrscan_window);
321 wmove(lrscan_window, 0, 0);
328 void boom(int ii, int jj)
329 /* enemy fall down, go boom */
332 setwnd(srscan_window);
334 wmove(srscan_window, ii*2+3, jj+2);
335 wattron(srscan_window, A_REVERSE);
336 waddch(srscan_window, game.quad[ii][jj]);
337 wrefresh(srscan_window);
341 wmove(srscan_window, ii*2+3, jj+2);
342 wattroff(srscan_window, A_REVERSE);
343 waddch(srscan_window, game.quad[ii][jj]);
344 wrefresh(srscan_window);
345 setwnd(message_window);
351 /* sound and visual effects for teleportation */
355 setwnd(message_window);
360 prouts(" . . . . . ");
363 void tracktorpedo(int x, int y, int ix, int iy, int wait, int l, int i, int n, int iquad)
364 /* torpedo-track animation */
370 proutn("Track for torpedo number %d- ", i);
374 proutn("Torpedo track- ");
376 } else if (l==4 || l==9)
378 proutn("%d - %d ", (int)x, (int)y);
380 if (game.damage[DSRSENS]==0 || condit==IHDOCKED) {
382 delay((wait!=1)*400);
383 if ((game.quad[ix][iy]==IHDOT)||(game.quad[ix][iy]==IHBLANK)){
384 game.quad[ix][iy]='+';
386 game.quad[ix][iy]=iquad;
392 game.quad[ix][iy] |= DAMAGED;
394 game.quad[ix][iy]=iquad;
398 wattroff(curwnd, A_REVERSE);
401 proutn("%d - %d ", (int)x, (int)y);
409 setwnd(message_window);
410 wclear(message_window);
415 void setpassword(void)
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));