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)) {
36 fprintf(stderr,"Unable to register outro(), exiting...\n");
47 FULLSCREEN_WINDOW = stdscr;
48 SRSCAN_WINDOW = newwin(12, 25, 0, 0);
49 REPORT_WINDOW = newwin(10, 0, 1, 25);
50 LRSCAN_WINDOW = newwin(10, 0, 0, 64);
51 LOWER_WINDOW = newwin(0, 0, 12, 0);
52 BOTTOM_WINDOW = newwin(1, 0, LINES-1, 0);
53 scrollok(LOWER_WINDOW, TRUE);
59 /* wait for user action -- OK to do nothing if on a TTY */
65 void pause_game(int i)
71 prompt = "[ANOUNCEMENT ARRIVING...]";
73 prompt = "[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]";
77 prompt = "[CONTINUE?]";
79 prompt = "[PRESS ENTER TO CONTINUE]";
84 setwnd(BOTTOM_WINDOW);
85 wclear(BOTTOM_WINDOW);
86 waddstr(BOTTOM_WINDOW, prompt);
87 wgetnstr(BOTTOM_WINDOW, buf, sizeof(buf));
88 wclear(BOTTOM_WINDOW);
89 wrefresh(BOTTOM_WINDOW);
94 fgets(buf, sizeof(buf), stdin);
97 for (j = 0; j < 24; j++)
120 static void vproutn(char *fmt, va_list ap)
123 vwprintw(curwnd, fmt, ap);
130 void proutn(char *fmt, ...)
138 void prout(char *fmt, ...)
147 void prouts(char *fmt, ...)
151 char *s, buf[BUFSIZ];
154 vsprintf(buf, fmt, ap);
157 for (s = buf; *s; s++) {
158 endTime = clock() + CLOCKS_PER_SEC*0.05;
159 while (clock() < endTime) continue;
171 void cgetline(char *line, int max)
174 wgetnstr(curwnd, line, max);
178 fgets(line, max, stdin);
180 line[strlen(line)-1] = '\0';
183 void setwnd(WINDOW *wnd)
184 /* change windows -- OK for this to be a no-op in tty mode */
188 curs_set(wnd == FULLSCREEN_WINDOW || wnd == LOWER_WINDOW);
193 /* clear to end of line -- can be a no-op in tty mode */
202 /* clear screen -- can be a no-op in tty mode */
211 void textcolor (int color)
214 wattroff(curwnd, A_REVERSE);
219 void highvideo (void)
226 void commandhook(char *cmd, int before) {
230 * Things past this point have policy implications.
233 void drawmaps(short l)
234 /* hook to be called after moving to redraw maps */
240 setwnd(SRSCAN_WINDOW);
244 setwnd(REPORT_WINDOW);
245 wclear(REPORT_WINDOW);
246 wmove(REPORT_WINDOW, 0, 0);
247 srscan(SCAN_NO_LEFTSIDE);
248 setwnd(LRSCAN_WINDOW);
249 wclear(LRSCAN_WINDOW);
250 wmove(LRSCAN_WINDOW, 0, 0);
257 void boom(int ii, int jj)
258 /* enemy fall down, go boom */
261 setwnd(SRSCAN_WINDOW);
263 wmove(SRSCAN_WINDOW, ii*2+3, jj+2);
264 wattron(SRSCAN_WINDOW, A_REVERSE);
265 waddch(SRSCAN_WINDOW, game.quad[ii][jj]);
266 wrefresh(SRSCAN_WINDOW);
270 wmove(SRSCAN_WINDOW, ii*2+3, jj+2);
271 wattroff(SRSCAN_WINDOW, A_REVERSE);
272 waddch(SRSCAN_WINDOW, game.quad[ii][jj]);
273 wrefresh(SRSCAN_WINDOW);
274 setwnd(LOWER_WINDOW);
280 /* sound and visual effects for teleportation */
284 setwnd(LOWER_WINDOW);
289 prouts(" . . . . . ");
292 void tracktorpedo(int x, int y, int ix, int iy, int wait, int l, int i, int n, int iquad)
293 /* torpedo-track animation */
299 proutn("Track for torpedo number %d- ", i);
303 proutn("Torpedo track- ");
305 } else if (l==4 || l==9)
307 proutn("%d - %d ", (int)x, (int)y);
309 if (game.damage[DSRSENS]==0 || condit==IHDOCKED) {
311 delay((wait!=1)*400);
312 if ((game.quad[ix][iy]==IHDOT)||(game.quad[ix][iy]==IHBLANK)){
313 game.quad[ix][iy]='+';
315 game.quad[ix][iy]=iquad;
321 game.quad[ix][iy] |= DAMAGED;
323 game.quad[ix][iy]=iquad;
327 wattroff(curwnd, A_REVERSE);
330 proutn("%d - %d ", (int)x, (int)y);
338 setwnd(LOWER_WINDOW);
339 wclear(LOWER_WINDOW);
344 void setpassword(void)
349 strcpy(game.passwd, citem);
351 if (*game.passwd != 0) break;
352 proutn("Please type in a secret password-");
356 for(i=0;i<3;i++) game.passwd[i]=(char)(97+(int)(Rand()*25));