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");
50 init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
51 init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
52 init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
53 init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
54 init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
55 init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
56 init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
57 init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
61 fullscreen_window = stdscr;
62 srscan_window = newwin(12, 25, 0, 0);
63 report_window = newwin(10, 0, 1, 25);
64 lrscan_window = newwin(10, 0, 0, 64);
65 message_window = newwin(0, 0, 12, 0);
66 prompt_window = newwin(1, 0, LINES-1, 0);
67 scrollok(message_window, TRUE);
68 setwnd(fullscreen_window);
75 /* wait for user action -- OK to do nothing if on a TTY */
81 void pause_game(int i)
87 prompt = "[ANOUNCEMENT ARRIVING...]";
89 prompt = "[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]";
93 prompt = "[CONTINUE?]";
95 prompt = "[PRESS ENTER TO CONTINUE]";
100 setwnd(prompt_window);
101 wclear(prompt_window);
102 waddstr(prompt_window, prompt);
103 wgetnstr(prompt_window, buf, sizeof(buf));
104 wclear(prompt_window);
105 wrefresh(prompt_window);
106 setwnd(message_window);
110 fgets(buf, sizeof(buf), stdin);
113 for (j = 0; j < 24; j++)
136 static void vproutn(char *fmt, va_list ap)
139 vwprintw(curwnd, fmt, ap);
146 void proutn(char *fmt, ...)
154 void prout(char *fmt, ...)
163 void prouts(char *fmt, ...)
167 char *s, buf[BUFSIZ];
170 vsprintf(buf, fmt, ap);
173 for (s = buf; *s; s++) {
174 endTime = clock() + CLOCKS_PER_SEC*0.05;
175 while (clock() < endTime) continue;
187 void cgetline(char *line, int max)
190 wgetnstr(curwnd, line, max);
194 fgets(line, max, stdin);
196 line[strlen(line)-1] = '\0';
199 void setwnd(WINDOW *wnd)
200 /* change windows -- OK for this to be a no-op in tty mode */
204 curs_set(wnd == fullscreen_window || wnd == message_window || wnd == prompt_window);
209 /* clear to end of line -- can be a no-op in tty mode */
218 /* clear screen -- can be a no-op in tty mode */
227 void textcolor (int color)
236 wattron(curwnd, COLOR_PAIR(COLOR_BLACK));
239 wattron(curwnd, COLOR_PAIR(COLOR_BLUE));
242 wattron(curwnd, COLOR_PAIR(COLOR_GREEN));
245 wattron(curwnd, COLOR_PAIR(COLOR_CYAN));
248 wattron(curwnd, COLOR_PAIR(COLOR_RED));
251 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA));
254 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW));
257 wattron(curwnd, COLOR_PAIR(COLOR_WHITE));
260 wattron(curwnd, COLOR_PAIR(COLOR_BLACK) | A_BOLD);
263 wattron(curwnd, COLOR_PAIR(COLOR_BLUE) | A_BOLD);
266 wattron(curwnd, COLOR_PAIR(COLOR_GREEN) | A_BOLD);
269 wattron(curwnd, COLOR_PAIR(COLOR_CYAN) | A_BOLD);
272 wattron(curwnd, COLOR_PAIR(COLOR_RED) | A_BOLD);
275 wattron(curwnd, COLOR_PAIR(COLOR_MAGENTA) | A_BOLD);
278 wattron(curwnd, COLOR_PAIR(COLOR_YELLOW) | A_BOLD);
281 wattron(curwnd, COLOR_PAIR(COLOR_WHITE) | A_BOLD);
288 void highvideo (void)
291 wattron(curwnd, A_REVERSE);
295 void commandhook(char *cmd, int before) {
299 * Things past this point have policy implications.
302 void drawmaps(short l)
303 /* hook to be called after moving to redraw maps */
309 setwnd(srscan_window);
313 setwnd(report_window);
314 wclear(report_window);
315 wmove(report_window, 0, 0);
316 srscan(SCAN_NO_LEFTSIDE);
317 setwnd(lrscan_window);
318 wclear(lrscan_window);
319 wmove(lrscan_window, 0, 0);
326 void boom(int ii, int jj)
327 /* enemy fall down, go boom */
330 setwnd(srscan_window);
332 wmove(srscan_window, ii*2+3, jj+2);
333 wattron(srscan_window, A_REVERSE);
334 waddch(srscan_window, game.quad[ii][jj]);
335 wrefresh(srscan_window);
339 wmove(srscan_window, ii*2+3, jj+2);
340 wattroff(srscan_window, A_REVERSE);
341 waddch(srscan_window, game.quad[ii][jj]);
342 wrefresh(srscan_window);
343 setwnd(message_window);
349 /* sound and visual effects for teleportation */
353 setwnd(message_window);
358 prouts(" . . . . . ");
361 void tracktorpedo(int x, int y, int ix, int iy, int wait, int l, int i, int n, int iquad)
362 /* torpedo-track animation */
368 proutn("Track for torpedo number %d- ", i);
372 proutn("Torpedo track- ");
374 } else if (l==4 || l==9)
376 proutn("%d - %d ", (int)x, (int)y);
378 if (game.damage[DSRSENS]==0 || condit==IHDOCKED) {
380 delay((wait!=1)*400);
381 if ((game.quad[ix][iy]==IHDOT)||(game.quad[ix][iy]==IHBLANK)){
382 game.quad[ix][iy]='+';
384 game.quad[ix][iy]=iquad;
390 game.quad[ix][iy] |= DAMAGED;
392 game.quad[ix][iy]=iquad;
396 wattroff(curwnd, A_REVERSE);
399 proutn("%d - %d ", (int)x, (int)y);
407 setwnd(message_window);
408 wclear(message_window);
413 void setpassword(void)
418 strcpy(game.passwd, citem);
420 if (*game.passwd != 0) break;
421 proutn("Please type in a secret password-");
425 for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));