1 /* omega (c) 1987,1988,1989 by Laurence Raphael Brothers */
2 /* scr.c */
3 /* functions that use curses routines directly */
4 /* plus a few file i/o stuff */
5 /* also some in file.c */
6 
7 #ifdef MSDOS_SUPPORTED_ANTIQUE
8 # include "curses.h"
9 #else
10 # ifdef AMIGA
11 #  include <curses210.h>
12 # else
13 #  ifdef __FreeBSD__
14 #   include <ncurses.h>
15 #  else
16 #   include <curses.h>
17 #  endif
18 # endif
19 # include <sys/types.h>
20 #endif
21 
22 #if defined(MSDOS_SUPPORTED_ANTIQUE) || defined(AMIGA)
23 # define CHARATTR(c)	((c) >> 8)
24 #else
25 # define CHARATTR(c)	((c) & ~0xff)
26 #endif
27 
28 #include "glob.h"
29 
30 #ifdef EXCESSIVE_REDRAW
31 #undef wclear
32 #define wclear werase
33 #endif
34 
35 
36 /* note these variables are not exported to other files */
37 
38 WINDOW *Levelw,*Dataw,*Flagw,*Timew,*Menuw,*Locw,*Morew,*Phasew;
39 WINDOW *Comwin,*Msg1w,*Msg2w,*Msg3w,*Msgw;
40 WINDOW *Showline[MAXITEMS];
41 
phaseprint()42 void phaseprint()
43 {
44   wclear(Phasew);
45   wprintw(Phasew,"Moon's Phase:\n");
46   switch(Phase/2) {
47   case 0: wprintw(Phasew,"NEW"); break;
48   case 1: case 11: wprintw(Phasew,"CRESCENT"); break;
49   case 2: case 10: wprintw(Phasew,"1/4"); break;
50   case 3: case 9: wprintw(Phasew,"HALF"); break;
51   case 4: case 8: wprintw(Phasew,"3/4"); break;
52   case 5: case 7: wprintw(Phasew,"GIBBOUS"); break;
53   case 6: wprintw(Phasew,"FULL"); break;
54   }
55   wrefresh(Phasew);
56 }
57 
show_screen()58 void show_screen()
59 {
60   int i,j,top,bottom;
61   int last_attr = 0, c;
62 
63   wclear(Levelw);
64   top = ScreenOffset;
65   bottom = ScreenOffset + ScreenLength;
66   top = max(0,top);
67   bottom = min(bottom,LENGTH);
68   if (Current_Environment != E_COUNTRYSIDE)
69     for (j=top;j<bottom;j++) {
70       wmove(Levelw,screenmod(j),0);
71       for (i=0;i<WIDTH;i++) {
72 	c = ((loc_statusp(i,j,SEEN)) ? getspot(i,j,FALSE):SPACE);
73         if (optionp(SHOW_COLOUR) && CHARATTR(c) != last_attr) {
74           last_attr = CHARATTR(c);
75           wattrset(Levelw,last_attr);
76         }
77         waddch(Levelw,c&0xff);
78       }
79     }
80   else for (j=top;j<bottom;j++)
81       for (i=0;i<WIDTH;i++) {
82 	wmove(Levelw,screenmod(j),i);
83         c = ((c_statusp(i,j,SEEN)) ? Country[i][j].current_terrain_type:SPACE);
84         if (optionp(SHOW_COLOUR) && CHARATTR(c) != last_attr) {
85           last_attr = CHARATTR(c);
86           wattrset(Levelw,last_attr);
87         }
88         waddch(Levelw,c&0xff);
89       }
90   wrefresh(Levelw);
91 }
92 
93 
94 
mgetc()95 char mgetc()
96 {
97   return(wgetch(Msgw));
98 }
99 
100 /* case insensitive mgetc -- sends uppercase to lowercase */
mcigetc()101 int mcigetc()
102 {
103   int c;
104 
105 #ifdef MSDOS_SUPPORTED_ANTIQUE
106 #ifndef DJGPP
107   keypad(Msgw,TRUE);
108 #endif
109 #endif
110   c = wgetch(Msgw);
111   if ((c>=(int)'A') && (c<=(int)'Z'))
112     return(c+(int)('a'-'A'));
113   else return(c);
114 }
115 
menugetc()116 char menugetc()
117 {
118   return(wgetch(Menuw));
119 }
120 
121 
lgetc()122 char lgetc()
123 {
124   return(wgetch(Levelw));
125 }
126 
127 
ynq()128 int ynq()
129 {
130   char p='*'; /* the user's choice; start with something impossible
131                * to prevent a loop. */
132   while ((p != 'n') && (p != 'y') && (p != 'q') && (p != ESCAPE) &&
133          (p != EOF) && (p != ' '))
134     p = wgetch(Msgw);
135   switch (p) {
136     case 'y': wprintw(Msgw,"yes. "); break;
137     case 'n': wprintw(Msgw,"no. "); break;
138 
139     case ESCAPE: p = 'q'; /* fall through to 'q' */
140     case ' ': p = 'q';    /* fall through to 'q' */
141     case 'q': wprintw(Msgw,"quit. "); break;
142     default: assert( p == EOF );
143     }
144   wrefresh(Msgw);
145   return(p);
146 }
147 
148 
ynq1()149 int ynq1()
150 {
151   char p='*'; /* the user's choice; start with something impossible
152                * to prevent a loop. */
153   while ((p != 'n') && (p != 'y') && (p != 'q') && (p != ESCAPE) &&
154           (p != ' ') && (p != EOF))
155     p = wgetch(Msg1w);
156   switch (p) {
157     case 'y': wprintw(Msg1w,"yes. "); break;
158     case 'n': wprintw(Msg1w,"no. "); break;
159 
160     case ESCAPE: p = 'q'; /* fall through to 'q' */
161     case ' ': p = 'q';    /* fall through to 'q' */
162     case 'q': wprintw(Msg1w,"quit. "); break;
163     default: assert( p == EOF );
164     }
165   wrefresh(Msg1w);
166   return(p);
167 }
168 
169 
ynq2()170 int ynq2()
171 {
172   char p='*'; /* the user's choice; start with something impossible
173                * to prevent a loop. */
174   while ((p != 'n') && (p != 'y') && (p != 'q') && (p != ESCAPE) &&
175           (p != ' ') && (p != EOF))
176     p = wgetch(Msg2w);
177   switch (p) {
178     case 'y': wprintw(Msg2w,"yes. "); break;
179     case 'n': wprintw(Msg2w,"no. "); break;
180 
181     case ESCAPE: p = 'q'; /* fall through to 'q' */
182     case ' ': p = 'q';    /* fall through to 'q' */
183     case 'q': wprintw(Msg2w,"quit. "); break;
184     default: assert( p == EOF );
185     }
186   wrefresh(Msg2w);
187   return(p);
188 }
189 
190 /* puts up a morewait to allow reading if anything in top two lines */
checkclear()191 void checkclear()
192 {
193   int x1,y,x2;
194   getyx(Msg1w,x1,y);
195   getyx(Msg2w,x2,y);
196   if ((x1 != 0) || (x2 != 0)) {
197     morewait();
198     wclear(Msg1w);
199     wclear(Msg2w);
200     wrefresh(Msg1w);
201     wrefresh(Msg2w);
202   }
203 }
204 
205 /* for external call */
clearmsg()206 void clearmsg()
207 {
208   wclear(Msg1w);
209   wclear(Msg2w);
210   wclear(Msg3w);
211   Msgw = Msg1w;
212   wrefresh(Msg1w);
213   wrefresh(Msg2w);
214   wrefresh(Msg3w);
215 }
216 
clearmsg3()217 void clearmsg3()
218 {
219   wclear(Msg3w);
220   wrefresh(Msg3w);
221 }
222 
clearmsg1()223 void clearmsg1()
224 {
225   wclear(Msg1w);
226   wclear(Msg2w);
227   Msgw = Msg1w;
228   wrefresh(Msg1w);
229   wrefresh(Msg2w);
230 }
231 
232 
erase_level()233 void erase_level()
234 {
235   wclear(Levelw);
236   wrefresh(Levelw);
237 }
238 
239 /* direct print to first msg line */
print1(s)240 void print1(s)
241 char *s;
242 {
243   if (! gamestatusp(SUPPRESS_PRINTING)) {
244     buffercycle(s);
245     wclear(Msg1w);
246     wprintw(Msg1w,s);
247     wrefresh(Msg1w);
248   }
249 }
250 
251 /* for run on-messages -- print1 clears first.... */
nprint1(s)252 void nprint1(s)
253 char *s;
254 {
255   if (! gamestatusp(SUPPRESS_PRINTING)) {
256     if (bufferappend(s)) {
257       wprintw(Msg1w,s);
258       wrefresh(Msg1w);
259     }
260   }
261 }
262 
263 
264 
265 
266 /* direct print to second msg line */
print2(s)267 void print2(s)
268 char *s;
269 {
270   if (! gamestatusp(SUPPRESS_PRINTING)) {
271     buffercycle(s);
272     wclear(Msg2w);
273     wprintw(Msg2w,s);
274     wrefresh(Msg2w);
275   }
276 }
277 
278 /* for run on-messages -- print2 clears first.... */
nprint2(s)279 void nprint2(s)
280 char *s;
281 {
282   if (! gamestatusp(SUPPRESS_PRINTING)) {
283     if (bufferappend(s)) {
284       wprintw(Msg2w,s);
285       wrefresh(Msg2w);
286     }
287   }
288 }
289 
290 
291 
292 
293 /* msg line 3 is not part of the region that mprint or printm can reach */
294 /* typical use of print3 is for "you can't do that" type error messages */
print3(s)295 void print3(s)
296 char *s;
297 {
298   if (! gamestatusp(SUPPRESS_PRINTING)) {
299     buffercycle(s);
300     wclear(Msg3w);
301     wprintw(Msg3w,s);
302     wrefresh(Msg3w);
303   }
304 }
305 
306 /* for run on-messages -- print3 clears first.... */
nprint3(s)307 void nprint3(s)
308 char *s;
309 {
310   if (! gamestatusp(SUPPRESS_PRINTING)) {
311     if (bufferappend(s)) {
312       wprintw(Msg3w,s);
313       wrefresh(Msg3w);
314     }
315   }
316 }
317 
318 
319 
320 /* prints wherever cursor is in window, but checks to see if
321 it should morewait and clear window */
mprint(s)322 void mprint(s)
323 char *s;
324 {
325   int x,y;
326   if (! gamestatusp(SUPPRESS_PRINTING)) {
327     getyx(Msgw,y,x);
328     if (x+strlen(s) >= WIDTH) {
329       buffercycle(s);
330       if (Msgw == Msg1w) {
331 	wclear(Msg2w);
332 	Msgw = Msg2w;
333       }
334       else {
335 	morewait();
336 	wclear(Msg1w);
337 	wclear(Msg2w);
338 	wrefresh(Msg2w);
339 	Msgw = Msg1w;
340       }
341     }
342     else if (x > 0)
343       bufferappend(s);
344     else
345       buffercycle(s);
346     wprintw(Msgw,s);
347     waddch(Msgw,' ');
348     wrefresh(Msgw);
349   }
350 }
351 
352 
353 
354 
omega_title()355 void omega_title()
356 {
357   showmotd();
358   clear();
359   touchwin(stdscr);
360   refresh();
361 /*  showscores();*/ /* DG */
362 }
363 
364 
365 
366 
367 
368 /* blanks out ith line of Menuw or Levelw */
hide_line(i)369 void hide_line(i)
370 int i;
371 {
372   wclear(Showline[i]);
373   touchwin(Showline[i]);
374   wrefresh(Showline[i]);
375 }
376 
377 
378 
379 /* initialize, screen, windows */
initgraf()380 void initgraf()
381 {
382   int i;
383   initscr();
384 #ifndef MSDOS_SUPPORTED_ANTIQUE
385   start_color();
386 # ifndef AMIGA
387   clrgen_init();
388 # endif
389 #endif
390   if (LINES < 24 || COLS < 80) {
391     printf("Minimum Screen Size: 24 Lines by 80 Columns.");
392     exit(0);
393   }
394 #ifdef AMIGA
395   init_color(1, 800, 800, 800); /* white */
396   init_color(2, 644, 164, 164); /* brown */
397   init_color(3, 800, 800, 0); /* yellow */
398   init_color(4, 200, 200, 200); /* grey */
399   init_color(5, 0, 1000, 0); /* green */
400   init_color(6, 0, 0, 1000); /* blue */
401   init_color(7, 1000, 0, 0); /* red */
402   LINES -= 2;	/* ugly, but neccessary with this curses package... */
403 #endif
404   ScreenLength = LINES - 6;
405   Msg1w = newwin(1,80,0,0);
406   scrollok(Msg1w, 0);	/* DJGPP curses defaults to scrollable new windows */
407   Msg2w = newwin(1,80,1,0);
408   scrollok(Msg2w, 0);
409   Msg3w = newwin(1,80,2,0);
410   scrollok(Msg3w, 0);
411   Msgw = Msg1w;
412   Morew = newwin(1,15,3,65);
413   scrollok(Morew, 0);
414   Locw = newwin(1,80,ScreenLength+3,0);
415   scrollok(Locw, 0);
416   Levelw = newwin(ScreenLength,64,3,0);
417   scrollok(Levelw, 0);
418   for(i=0;i<MAXITEMS;i++) {
419     Showline[i] = newwin(1,64,i+3,0);
420     scrollok(Showline[i], 0);
421     wclear(Showline[i]);
422   }
423   Menuw = newwin(ScreenLength,64,3,0);
424   scrollok(Menuw, 0);
425   Dataw = newwin(2,80,ScreenLength+4,0);
426   scrollok(Dataw, 0);
427   Timew = newwin(2,15,4,65);
428   scrollok(Timew, 0);
429   Phasew = newwin(2,15,6,65);
430   scrollok(Phasew, 0);
431   Flagw = newwin(4,15,9,65);
432   scrollok(Flagw, 0);
433   Comwin = newwin(8,15,14,65);
434   scrollok(Comwin, 0);
435 
436   noecho();
437   crmode();
438 
439   clear();
440   touchwin(stdscr);
441 /*  omega_title();*/
442 /*  clear();*/
443 /*  touchwin(stdscr);*/
444 /*  refresh();*/          /* DG */
445 }
446 
447 
448 
449 
450 
451 int lastx= -1,lasty= -1;
452 
drawplayer()453 void drawplayer()
454 {
455   int c;
456 
457   if (Current_Environment == E_COUNTRYSIDE) {
458     if (inbounds(lastx,lasty) && !offscreen(lasty)) {
459 	wmove(Levelw,screenmod(lasty),lastx);
460         c = Country[lastx][lasty].current_terrain_type;
461         if (optionp(SHOW_COLOUR))
462           wattrset(Levelw, CHARATTR(c));
463         waddch(Levelw,(c&0xff));
464     }
465     wmove(Levelw,screenmod(Player.y),Player.x);
466     if (optionp(SHOW_COLOUR))
467       wattrset(Levelw, CHARATTR(PLAYER));
468     waddch(Levelw,(PLAYER&0xff));
469   }
470   else {
471     if (inbounds(lastx,lasty) && !offscreen(lasty))
472       plotspot(lastx,lasty,(Player.status[BLINDED]>0 ? FALSE : TRUE));
473     wmove(Levelw,screenmod(Player.y),Player.x);
474     if ((! Player.status[INVISIBLE]) || Player.status[TRUESIGHT]) {
475       if (optionp(SHOW_COLOUR))
476         wattrset(Levelw, CHARATTR(PLAYER));
477       waddch(Levelw,(PLAYER&0xff));
478     }
479   }
480   lastx = Player.x;
481   lasty = Player.y;
482 }
483 
setlastxy(new_x,new_y)484 void setlastxy(new_x, new_y) /* used when changing environments */
485 int new_x, new_y;
486 {
487     lastx = new_x;
488     lasty = new_y;
489 }
490 
litroom(x,y)491 int litroom(x,y)
492 int x,y;
493 {
494   if (Level->site[x][y].roomnumber < ROOMBASE) return(FALSE);
495   else return(loc_statusp(x,y,LIT) ||
496 	      Player.status[ILLUMINATION]);
497 }
498 
drawvision(x,y)499 void drawvision(x,y)
500 int x,y;
501 {
502   static int oldx = -1,oldy = -1;
503   int i,j,c;
504 
505   if (Current_Environment != E_COUNTRYSIDE) {
506     if (Player.status[BLINDED]) {
507       drawspot(oldx,oldy);
508       drawspot(x,y);
509       drawplayer();
510     }
511     else {
512       if (Player.status[ILLUMINATION] > 0) {
513 	for (i= -2;i<3;i++)
514 	  for (j= -2;j<3;j++)
515 	    if (inbounds(x+i,y+j))
516 	      if (view_los_p(x+i,y+j,Player.x,Player.y))
517 		dodrawspot(x+i,y+j);
518       }
519       else {
520 	for (i= -1;i<2;i++)
521 	  for (j= -1;j<2;j++)
522 	    if (inbounds(x+i,y+j))
523 	      dodrawspot(x+i,y+j);
524       }
525       drawplayer();
526       drawmonsters(FALSE); /* erase all monsters */
527       drawmonsters(TRUE);  /* draw those now visible */
528     }
529     if ((! gamestatusp(FAST_MOVE)) || (! optionp(JUMPMOVE)))
530       omshowcursor(Player.x,Player.y);
531     oldx = x;
532     oldy = y;
533   }
534   else {
535     for (i= -1;i<2;i++)
536       for (j= -1;j<2;j++)
537 	if (inbounds(x+i,y+j)) {
538 	  c_set(x+i, y+j, SEEN);
539 	  if (!offscreen(y+j)) {
540 	    wmove(Levelw,screenmod(y+j),x+i);
541             c = Country[x+i][y+j].current_terrain_type;
542             if (optionp(SHOW_COLOUR))
543               wattrset(Levelw, CHARATTR(c));
544             waddch(Levelw,(c&0xff));
545 	  }
546 	}
547     drawplayer();
548     omshowcursor(Player.x,Player.y);
549   }
550 }
551 
552 
omshowcursor(x,y)553 void omshowcursor(x,y)
554 int x,y;
555 {
556   if (! offscreen(y)) {
557     wmove(Levelw,screenmod(y),x);
558     wrefresh(Levelw);
559   }
560 }
561 
levelrefresh()562 void levelrefresh()
563 {
564   wrefresh(Levelw);
565 }
566 
567 
568 /* draws a particular spot under if in line-of-sight */
drawspot(x,y)569 void drawspot(x,y)
570 int x,y;
571 {
572   Symbol c;
573   if (inbounds(x,y)) {
574     c = getspot(x,y,FALSE);
575     if (c != Level->site[x][y].showchar)
576       if (view_los_p(Player.x,Player.y,x,y)) {
577 	lset(x,y,SEEN);
578 	Level->site[x][y].showchar = c;
579 	putspot(x,y,c);
580       }
581   }
582 }
583 
584 
585 
586 /* draws a particular spot regardless of line-of-sight */
dodrawspot(x,y)587 void dodrawspot(x,y)
588 int x,y;
589 {
590   Symbol c;
591   if (inbounds(x,y)) {
592     c = getspot(x,y,FALSE);
593     if (c != Level->site[x][y].showchar) {
594       lset(x,y,SEEN);
595       Level->site[x][y].showchar = c;
596       putspot(x,y,c);
597     }
598   }
599 }
600 
601 /* write a blank to a spot if it is floor */
blankoutspot(i,j)602 void blankoutspot(i,j)
603 int i,j;
604 {
605   if (inbounds(i,j)) {
606     lreset(i,j,LIT);
607     lset(i, j, CHANGED);
608     if (Level->site[i][j].locchar == FLOOR)  {
609       Level->site[i][j].showchar = SPACE;
610       putspot(i,j,SPACE);
611     }
612   }
613 }
614 
615 /* blank out a spot regardless */
blotspot(i,j)616 void blotspot(i,j)
617 int i,j;
618 {
619   if (inbounds(i,j)) {
620     lreset(i,j,SEEN);
621     Level->site[i][j].showchar = SPACE;
622     if (! offscreen(j)) {
623       wmove(Levelw,screenmod(j),i);
624       wattrset(Levelw, CHARATTR(SPACE));
625       waddch(Levelw, SPACE&0xff);
626     }
627   }
628 }
629 
630 
631 /* for displaying activity specifically at some point */
plotspot(x,y,showmonster)632 void plotspot(x,y,showmonster)
633 int x,y,showmonster;
634 {
635   if (loc_statusp(x,y,SEEN))
636     putspot(x,y,getspot(x,y,showmonster));
637   else
638     putspot(x,y,SPACE);
639 }
640 
641 
642 /* Puts c at x,y on screen. No fuss, no bother. */
putspot(x,y,c)643 void putspot(x,y,c)
644 int x,y;
645 Symbol c;
646 {
647   if (! offscreen(y)) {
648     wmove(Levelw,screenmod(y),x);
649     if (optionp(SHOW_COLOUR))
650       wattrset(Levelw, CHARATTR(c));
651     waddch(Levelw,(0xff&c));
652   }
653 }
654 
655 
656 /* regardless of line of sight, etc, draw a monster */
plotmon(m)657 void plotmon(m)
658 struct monster *m;
659 {
660   if (! offscreen(m->y)) {
661     wmove(Levelw,screenmod(m->y),m->x);
662     if (optionp(SHOW_COLOUR))
663       wattrset(Levelw, CHARATTR(m->monchar));
664     waddch(Levelw,(m->monchar&0xff));
665   }
666 }
667 
668 /* if display, displays monsters, otherwise erases them */
drawmonsters(display)669 void drawmonsters(display)
670 int display;
671 {
672   pml ml;
673   for (ml=Level->mlist;ml!=NULL;ml=ml->next) {
674     if (ml->m->hp > 0) {
675       if (display) {
676 	if (view_los_p(Player.x,Player.y,ml->m->x,ml->m->y)) {
677 	  if (Player.status[TRUESIGHT] || (! m_statusp(ml->m,M_INVISIBLE))) {
678 	    if (!optionp(SHOW_COLOUR) &&
679 	        (ml->m->level > 5) &&
680 		((ml->m->monchar&0xff) != '@') &&
681 		((ml->m->monchar&0xff) != '|')) wstandout(Levelw);
682 	    putspot(ml->m->x,ml->m->y,ml->m->monchar);
683 	    if (!optionp(SHOW_COLOUR))
684 	      wstandend(Levelw);
685 	  }
686 	}
687       }
688       else erase_monster(ml->m);
689     }
690   }
691 }
692 
693 /* replace monster with what would be displayed if monster weren't there */
erase_monster(m)694 void erase_monster(m)
695 struct monster *m;
696 {
697   if (loc_statusp(m->x,m->y,SEEN))
698     putspot(m->x,m->y,getspot(m->x,m->y,FALSE));
699   else blotspot(m->x,m->y);
700 }
701 
702 /* find apt char to display at some location */
getspot(x,y,showmonster)703 Symbol getspot(x,y,showmonster)
704 int x,y,showmonster;
705 {
706   if (loc_statusp(x,y,SECRET)) return(WALL);
707   else switch (Level->site[x][y].locchar) {
708   case WATER:
709     if (Level->site[x][y].creature == NULL)
710       return(WATER);
711     else if (m_statusp(Level->site[x][y].creature,SWIMMING))
712       return(WATER);
713     else if (showmonster)
714       return(Level->site[x][y].creature->monchar);
715     else return(WATER);
716   /* these sites never show anything but their location char's */
717   case CLOSED_DOOR:
718   case LAVA:
719   case FIRE:
720   case ABYSS:
721     return(Level->site[x][y].locchar);
722   /* rubble and hedge don't show items on their location */
723   case RUBBLE:
724   case HEDGE:
725     if (showmonster && (Level->site[x][y].creature != NULL)) {
726       if ((m_statusp(Level->site[x][y].creature,M_INVISIBLE)) &&
727 	  (! Player.status[TRUESIGHT]))
728 	return(getspot(x,y,FALSE));
729       else return (Level->site[x][y].creature->monchar);
730     }
731     else return(Level->site[x][y].locchar);
732   /* everywhere else, first try to show monster, next show items, next show
733      location char */
734   default:
735     if (showmonster && (Level->site[x][y].creature != NULL)) {
736       if ((m_statusp(Level->site[x][y].creature,M_INVISIBLE)) &&
737 	  (! Player.status[TRUESIGHT]))
738 	return(getspot(x,y,FALSE));
739       else return (Level->site[x][y].creature->monchar);
740     }
741     else if (Level->site[x][y].things != NULL) {
742       if (Level->site[x][y].things->next != NULL)
743 	return(PILE);
744       else return(Level->site[x][y].things->thing->objchar);
745     }
746     else return(Level->site[x][y].locchar);
747   }
748 }
749 
commanderror()750 void commanderror()
751 {
752   wclear(Msg3w);
753   wprintw(Msg3w,"%c : unknown command",Cmd);
754   wrefresh(Msg3w);
755 }
756 
timeprint()757 void timeprint()
758 {
759   wclear(Timew);
760   wprintw(Timew,"%d:%d",showhour(),showminute());
761   if (showminute()==0) waddch(Timew,'0');
762   wprintw(Timew,hour()>11 ? " PM \n" : " AM \n");
763   wprintw(Timew,month());
764   wprintw(Timew," the %d",day());
765   wprintw(Timew,ordinal(day()));
766   wrefresh(Timew);
767 }
768 
769 
comwinprint()770 void comwinprint()
771 {
772   wclear(Comwin);
773   wprintw(Comwin,"Hit: %d  \n",Player.hit);
774   wprintw(Comwin,"Dmg: %d  \n",Player.dmg);
775   wprintw(Comwin,"Def: %d  \n",Player.defense);
776   wprintw(Comwin,"Arm: %d  \n",Player.absorption);
777   wprintw(Comwin,"Spd: %d.%d  \n", 5/Player.speed, 500/Player.speed%100);
778   wrefresh(Comwin);
779 }
780 
dataprint()781 void dataprint()
782 {
783   wclear(Dataw);
784   /* WDT HACK: I should make these fields spaced and appropriately justified.
785    * Maybe I don't feel like it right now. */
786   wprintw(Dataw,"Hp:%d/%d Mana:%ld/%ld Au:%ld Level:%d/%ld Carry:%d/%d \n",
787 	  Player.hp,Player.maxhp,Player.mana,Player.maxmana,Player.cash,
788 	  Player.level,Player.xp,Player.itemweight,Player.maxweight);
789   wprintw(Dataw,"Str:%d/%d Con:%d/%d Dex:%d/%d Agi:%d/%d Int:%d/%d Pow:%d/%d   ",
790 	  Player.str,Player.maxstr,Player.con,Player.maxcon,
791 	  Player.dex,Player.maxdex,Player.agi,Player.maxagi,
792 	  Player.iq,Player.maxiq,Player.pow,Player.maxpow);
793   wrefresh(Dataw);
794 }
795 
796 
797 /* redraw everything currently displayed */
redraw()798 void redraw()
799 {
800   touchwin(curscr);
801   wrefresh(curscr);
802 }
803 
804 /* redraw each permanent window */
xredraw()805 void xredraw()
806 {
807   touchwin(Msgw);
808   touchwin(Msg3w);
809   touchwin(Levelw);
810   touchwin(Timew);
811   touchwin(Flagw);
812   touchwin(Dataw);
813   touchwin(Locw);
814   touchwin(Morew);
815   touchwin(Phasew);
816   touchwin(Comwin);
817   wrefresh(Msgw);
818   wrefresh(Msg3w);
819   wrefresh(Levelw);
820   wrefresh(Timew);
821   wrefresh(Flagw);
822   wrefresh(Dataw);
823   wrefresh(Locw);
824   wrefresh(Morew);
825   wrefresh(Phasew);
826   wrefresh(Comwin);
827 }
828 
829 
830 
menuaddch(c)831 void menuaddch(c)
832 char c;
833 {
834   waddch(Menuw,c);
835   wrefresh(Menuw);
836 }
837 
838 
839 
morewait()840 void morewait()
841 {
842   int display=TRUE;
843   int c;
844   if (gamestatusp(SUPPRESS_PRINTING))
845     return;
846   do {
847     wclear(Morew);
848     if (display) wprintw(Morew,"***  MORE  ***");
849     else wprintw(Morew,"+++  MORE  +++");
850     display = ! display;
851     wrefresh(Morew);
852     c = wgetch(Msgw);
853   } while ((c != ' ') && (c != RETURN) && (c != EOF));
854   wclear(Morew);
855   wrefresh(Morew);
856 }
857 
stillonblock()858 int stillonblock()
859 {
860   int display=TRUE;
861   int c;
862   do {
863     wclear(Morew);
864     if (display) wprintw(Morew,"<<<STAY?>>>");
865     else wprintw(Morew,">>>STAY?<<<");
866     display = ! display;
867     wrefresh(Morew);
868     c = wgetch(Msgw);
869   } while ((c != ' ') && (c != ESCAPE) && (c != EOF));
870   wclear(Morew);
871   wrefresh(Morew);
872   return (c == ' ');
873 }
874 
menuclear()875 void menuclear()
876 {
877   wclear(Menuw);
878   touchwin(Menuw);
879   wrefresh(Menuw);
880 }
881 
menuspellprint(i)882 void menuspellprint(i)
883 int i;
884 {
885   int x,y;
886   getyx(Menuw,y,x);
887   if (y >= ScreenLength - 2) {
888     wrefresh(Menuw);
889     morewait();
890     wclear(Menuw);
891     touchwin(Menuw);
892   }
893   wprintw(Menuw,spellid(i));
894   wprintw(Menuw,"(%d)\n",Spells[i].powerdrain);
895 }
896 
menuprint(s)897 void menuprint(s)
898 char *s;
899 {
900   int x,y;
901   getyx(Menuw,y,x);
902   if (y >= ScreenLength - 2) {
903     wrefresh(Menuw);
904     morewait();
905     wclear(Menuw);
906     touchwin(Menuw);
907   }
908   wprintw(Menuw,s);
909 }
910 
showmenu()911 void showmenu()
912 {
913   wrefresh(Menuw);
914 }
915 
916 
endgraf()917 void endgraf()
918 {
919   clear();
920   touchwin(stdscr);
921   refresh();
922   endwin();
923 }
924 
925 
plotchar(pyx,x,y)926 void plotchar(pyx,x,y)
927 Symbol pyx;
928 int x,y;
929 {
930   if (! offscreen(y)) {
931     wmove(Levelw,screenmod(y),x);
932     if (optionp(SHOW_COLOUR))
933       wattrset(Levelw, CHARATTR(pyx));
934     waddch(Levelw,(pyx&0xff));
935     wrefresh(Levelw);
936   }
937 }
938 
939 
940 
draw_explosion(pyx,x,y)941 void draw_explosion(pyx,x,y)
942 Symbol pyx;
943 int x,y;
944 {
945   int i,j;
946 
947   for(j=0;j<3;j++) {
948     for(i=0;i<9;i++)
949       plotchar(pyx,x+Dirs[0][i],y+Dirs[1][i]);
950     usleep(150000);
951     for(i=0;i<9;i++)
952       plotchar(SPACE,x+Dirs[0][i],y+Dirs[1][i]);
953     usleep(150000);
954   }
955   for(i=0;i<9;i++)
956     plotspot(x+Dirs[0][i],y+Dirs[1][i],TRUE);
957   wrefresh(Levelw);
958 }
959 
msgscanstring()960 char *msgscanstring()
961 {
962   static char instring[80],byte='x';
963   int i=0;
964 
965   instring[0]=0;
966   byte = mgetc();
967   while (byte != '\n') {
968     if ((byte == 8) || (byte == 127)) { /* ^h or delete */
969       if (i>0){
970 	i--;
971 	dobackspace();
972       }
973       instring[i] = 0;
974     }
975     else {
976       instring[i] = byte;
977       waddch(Msgw,byte);
978       wrefresh(Msgw);
979       i++;
980       instring[i] = 0;
981     }
982     byte = mgetc();
983   }
984   return(instring);
985 }
986 
987 
locprint(s)988 void locprint(s)
989 char *s;
990 {
991   wclear(Locw);
992   wprintw(Locw,s);
993   wrefresh(Locw);
994 }
995 
996 /* draw everything whether visible or not */
drawscreen()997 void drawscreen()
998 {
999   int i,j;
1000   if (Current_Environment == E_COUNTRYSIDE)
1001     for (i=0;i<WIDTH;i++)
1002       for(j=0;j<LENGTH;j++)
1003 	c_set(i, j, SEEN);
1004   else for (i=0;i<WIDTH;i++)
1005     for(j=0;j<LENGTH;j++)
1006       lset(i,j,SEEN);
1007   if (Current_Environment == E_CITY)
1008     for (i = 0; i < NUMCITYSITES; i++)
1009       CitySiteList[i][0] = 1;
1010   show_screen();
1011 }
1012 
1013 /*selects a number up to range */
1014 
getnumber(range)1015 int getnumber(range)
1016 int range;
1017 {
1018   int done=FALSE,value=1;
1019   int atom;
1020 
1021   if (range==1) return(1);
1022   else while (! done) {
1023     clearmsg();
1024     wprintw(Msg1w,"How many? Change with < or >, ESCAPE to select:");
1025     mnumprint(value);
1026 #ifndef MSDOS
1027     do atom=mcigetc();
1028     while ((atom != '<')&&(atom != '>')&&(atom!=ESCAPE));
1029     if ((atom=='>') && (value < range)) value++;
1030     else if ((atom=='<') && (value > 1)) value--;
1031     else if (atom==ESCAPE) done = TRUE;
1032 #else
1033     atom=mcigetc();
1034     switch (atom)
1035     {
1036       case '>':
1037       case 'k':
1038 #ifdef KEY_UP
1039       case KEY_UP:
1040 #endif
1041         if (value < range)
1042 	  value++;
1043 	break;
1044       case '<':
1045       case 'j':
1046 #ifdef KEY_DOWN
1047       case KEY_DOWN:
1048 #endif
1049         if (value > 1)
1050 	  value--;
1051 	break;
1052 #ifdef KEY_HOME
1053       case KEY_HOME:
1054 #endif
1055         value = 1;
1056         break;
1057 #ifdef KEY_LL
1058       case KEY_LL:
1059 #endif
1060         value = range;
1061         break;
1062       case ESCAPE:
1063       	done = TRUE;
1064 	break;
1065     }
1066 #endif
1067   }
1068   return(value);
1069 }
1070 
1071 /* reads a positive number up to 999999 */
parsenum()1072 long parsenum()
1073 {
1074   int number[8];
1075   int place = -1;
1076   int i,x,y,mult=1;
1077   long num=0;
1078   char byte=' ';
1079 
1080   while ((byte != ESCAPE) && (byte != '\n')) {
1081     byte = mgetc();
1082     if ((byte == BACKSPACE) || (byte == DELETE)) {
1083       if (place > -1) {
1084 	number[place] = 0;
1085 	place--;
1086 	getyx(Msgw,y,x);
1087 	wmove(Msgw,y,x-1);
1088 	waddch(Msgw,' ');
1089 	wmove(Msgw,y,x-1);
1090 	wrefresh(Msgw);
1091       }
1092     }
1093     else if ((byte <= '9') && (byte >= '0') && (place < 7)) {
1094       place++;
1095       number[place]=byte;
1096       waddch(Msgw,byte);
1097       wrefresh(Msgw);
1098     }
1099   }
1100   waddch(Msgw,' ');
1101   if (byte == ESCAPE) return(ABORT);
1102   else {
1103     for (i=place;i>=0;i--) {
1104       num += mult*(number[i]-'0');
1105       mult*=10;
1106     }
1107     return(num);
1108   }
1109 }
1110 
1111 
1112 
maddch(c)1113 void maddch(c)
1114 char c;
1115 {
1116   waddch(Msgw,c);
1117   wrefresh(Msgw);
1118 }
1119 
1120 
display_death(source)1121 void display_death(source)
1122 char *source;
1123 {
1124   clear();
1125   touchwin(stdscr);
1126   printw("\n\n\n\n");
1127   printw("Requiescat In Pace, ");
1128   printw(Player.name);
1129   printw(" (%ld points)",calc_points());
1130   strcpy(Str4,"Killed by ");
1131   strcat(Str4,source);
1132   printw("\n");
1133   printw(Str4);
1134   printw(".");
1135   printw("\n\n\n\n\nHit 'c' to continue.");
1136   refresh();
1137   while (wgetch(stdscr) != 'c')
1138 	;
1139   clear();
1140   touchwin(stdscr);
1141   refresh();
1142   extendlog(Str4,DEAD);
1143 }
1144 
1145 
display_win()1146 void display_win()
1147 {
1148   clear();
1149   touchwin(stdscr);
1150   printw("\n\n\n\n");
1151   printw(Player.name);
1152   if (Player.rank[ADEPT]) {
1153     printw(" is a total master of omega with %ld points!",FixedPoints);
1154     strcpy(Str4,"A total master of omega");
1155   }
1156   else {
1157     strcpy(Str4,"retired a winner");
1158     printw(" triumphed in omega with %ld points!",calc_points());
1159   }
1160   printw("\n\n\n\n\nHit 'c' to continue.");
1161   refresh();
1162   while (wgetch(stdscr) != 'c')
1163 	;
1164   clear();
1165   touchwin(stdscr);
1166   refresh();
1167   if (Player.rank[ADEPT])
1168     extendlog(Str4,BIGWIN);
1169   else extendlog(Str4,WIN);
1170 }
1171 
display_quit()1172 void display_quit()
1173 {
1174   clear();
1175   touchwin(stdscr);
1176   printw("\n\n\n\n");
1177   printw(Player.name);
1178   strcpy(Str4,"A quitter.");
1179   printw(" wimped out with %ld points!",calc_points());
1180   printw("\n\n\n\n\nHit 'c' to continue.");
1181   refresh();
1182   while (wgetch(stdscr) != 'c')
1183 	;
1184   clear();
1185   touchwin(stdscr);
1186   refresh();
1187   extendlog(Str4,QUIT);
1188 }
1189 
1190 
display_bigwin()1191 void display_bigwin()
1192 {
1193   clear();
1194   touchwin(stdscr);
1195   printw("\n\n\n\n");
1196   printw(Player.name);
1197   strcpy(Str4,"retired, an Adept of Omega.");
1198   printw(" retired, an Adept of Omega with %ld points!",FixedPoints);
1199   printw("\n\n\n\n\nHit 'c' to continue.");
1200   refresh();
1201   while (wgetch(stdscr) != 'c')
1202 	;
1203   clear();
1204   touchwin(stdscr);
1205   refresh();
1206   extendlog(Str4,BIGWIN);
1207 }
1208 
1209 
mnumprint(n)1210 void mnumprint(n)
1211 int n;
1212 {
1213   char numstr[20];
1214   sprintf(numstr,"%d",n);
1215   bufferappend(numstr);
1216   wprintw(Msgw,"%d",n);
1217   wrefresh(Msgw);
1218 }
1219 
mlongprint(n)1220 void mlongprint(n)
1221 long n;
1222 {
1223   char numstr[20];
1224   sprintf(numstr,"%ld",n);
1225   bufferappend(numstr);
1226   wprintw(Msgw,"%ld",n);
1227   wrefresh(Msgw);
1228 }
1229 
1230 
menunumprint(n)1231 void menunumprint(n)
1232 int n;
1233 {
1234   int x,y;
1235   getyx(Menuw,y,x);
1236   if (y >= ScreenLength - 2) {
1237     wrefresh(Menuw);
1238     morewait();
1239     wclear(Menuw);
1240     touchwin(Menuw);
1241   }
1242   wprintw(Menuw,"%d",n);
1243 }
1244 
menulongprint(n)1245 void menulongprint(n)
1246 long n;
1247 {
1248   int x,y;
1249   getyx(Menuw,y,x);
1250   if (y >= ScreenLength - 2) {
1251     wrefresh(Menuw);
1252     morewait();
1253     wclear(Menuw);
1254     touchwin(Menuw);
1255   }
1256   wprintw(Menuw,"%ld",n);
1257 }
1258 
1259 
dobackspace()1260 void dobackspace()
1261 {
1262   int x,y;
1263 
1264   getyx(Msgw,y,x);
1265   if (x > 0) {
1266     waddch(Msgw,' ');
1267     wmove(Msgw,y,x-1);
1268     waddch(Msgw,' ');
1269     wmove(Msgw,y,x-1);
1270   }
1271   wrefresh(Msgw);
1272 }
1273 
1274 
showflags()1275 void showflags()
1276 {
1277 
1278   phaseprint();
1279   wclear(Flagw);
1280   if (Player.food < 0)
1281     wprintw(Flagw,"Starving\n");
1282   else if (Player.food <= 3)
1283     wprintw(Flagw,"Weak\n");
1284   else if (Player.food <= 10)
1285     wprintw(Flagw,"Ravenous\n");
1286   else if (Player.food <= 20)
1287     wprintw(Flagw,"Hungry\n");
1288   else if (Player.food <= 30)
1289     wprintw(Flagw,"A mite peckish\n");
1290   else if (Player.food <= 36)
1291     wprintw(Flagw,"Content\n");
1292   else if (Player.food <= 44)
1293     wprintw(Flagw,"Satiated\n");
1294   else wprintw(Flagw,"Bloated\n");
1295 
1296 
1297   if (Player.status[POISONED]>0)
1298     wprintw(Flagw,"Poisoned\n");
1299   else wprintw(Flagw,"Vigorous\n");
1300 
1301   if (Player.status[DISEASED]>0)
1302     wprintw(Flagw,"Diseased\n");
1303   else wprintw(Flagw,"Healthy\n");
1304 
1305   if (gamestatusp(MOUNTED)) wprintw(Flagw,"Mounted\n");
1306   else if (Player.status[LEVITATING]) wprintw(Flagw,"Levitating\n");
1307   else wprintw(Flagw,"Afoot\n");
1308 
1309   wrefresh(Flagw);
1310 }
1311 
drawomega()1312 void drawomega()
1313 {
1314   int i;
1315   clear();
1316   touchwin(stdscr);
1317   for(i=0;i<7;i++) {
1318       move(1, 1);
1319       if (optionp(SHOW_COLOUR))
1320         wattrset(stdscr, CHARATTR(CLR(LIGHT_BLUE)));
1321       printw("\n\n\n");
1322       printw("\n                                    *****");
1323       printw("\n                               ******   ******");
1324       printw("\n                             ***             ***");
1325       printw("\n                           ***                 ***");
1326       printw("\n                          **                     **");
1327       printw("\n                         ***                     ***");
1328       printw("\n                         **                       **");
1329       printw("\n                         **                       **");
1330       printw("\n                         ***                     ***");
1331       printw("\n                          ***                   ***");
1332       printw("\n                            **                 **");
1333       printw("\n                       *   ***                ***   *");
1334       printw("\n                        ****                    ****");
1335       refresh();
1336       usleep(200000);
1337       move(1, 1);
1338       if (optionp(SHOW_COLOUR))
1339         wattrset(stdscr, CHARATTR(CLR(CYAN)));
1340       printw("\n\n\n");
1341       printw("\n                                    +++++");
1342       printw("\n                               ++++++   ++++++");
1343       printw("\n                             +++             +++");
1344       printw("\n                           +++                 +++");
1345       printw("\n                          ++                     ++");
1346       printw("\n                         +++                     +++");
1347       printw("\n                         ++                       ++");
1348       printw("\n                         ++                       ++");
1349       printw("\n                         +++                     +++");
1350       printw("\n                          +++                   +++");
1351       printw("\n                            ++                 ++");
1352       printw("\n                       +   +++                +++   +");
1353       printw("\n                        ++++                    ++++");
1354       refresh();
1355       usleep(200000);
1356       move(1, 1);
1357       if (optionp(SHOW_COLOUR))
1358         wattrset(stdscr, CHARATTR(CLR(BLUE)));
1359       printw("\n\n\n");
1360       printw("\n                                    .....");
1361       printw("\n                               ......   ......");
1362       printw("\n                             ...             ...");
1363       printw("\n                           ...                 ...");
1364       printw("\n                          ..                     ..");
1365       printw("\n                         ...                     ...");
1366       printw("\n                         ..                       ..");
1367       printw("\n                         ..                       ..");
1368       printw("\n                         ...                     ...");
1369       printw("\n                          ...                   ...");
1370       printw("\n                            ..                 ..");
1371       printw("\n                       .   ...                ...   .");
1372       printw("\n                        ....                    ....");
1373       refresh();
1374       usleep(200000);
1375   }
1376   wattrset(stdscr, CHARATTR(CLR(WHITE)));
1377 }
1378 
1379 /* y is an absolute coordinate */
1380 /* ScreenOffset is the upper left hand corner of the current screen
1381    in absolute coordinates */
1382 
screencheck(y)1383 void screencheck(y)
1384 int y;
1385 {
1386   if (((y-ScreenOffset) < (ScreenLength/8)) ||
1387       ((y-ScreenOffset) > (7*ScreenLength/8))) {
1388     ScreenOffset = y - (ScreenLength/2);
1389     show_screen();
1390     if (Current_Environment != E_COUNTRYSIDE)
1391       drawmonsters(TRUE);
1392     if (!offscreen(Player.y))
1393       drawplayer();
1394   }
1395 }
1396 
1397 
1398 
1399 
spreadroomlight(x,y,roomno)1400 void spreadroomlight(x,y,roomno)
1401 int x,y,roomno;
1402 {
1403   if (inbounds(x,y) && !loc_statusp(x,y,LIT) &&
1404       Level->site[x][y].roomnumber == roomno) {
1405     lightspot(x,y);
1406     spreadroomlight(x+1,y,roomno);
1407     spreadroomlight(x,y+1,roomno);
1408     spreadroomlight(x-1,y,roomno);
1409     spreadroomlight(x,y-1,roomno);
1410   }
1411 }
1412 
1413 /* illuminate one spot at x y */
lightspot(x,y)1414 void lightspot(x,y)
1415 int x,y;
1416 {
1417   Symbol c;
1418   lset(x,y,LIT);
1419   lset(x,y,SEEN);
1420   lset(x, y, CHANGED);
1421   c = getspot(x,y,FALSE);
1422   Level->site[x][y].showchar = c;
1423   putspot(x,y,c);
1424 }
1425 
1426 
1427 
spreadroomdark(x,y,roomno)1428 void spreadroomdark(x,y,roomno)
1429 int x,y,roomno;
1430 {
1431   if (inbounds(x,y))
1432     if (loc_statusp(x,y,LIT) && (Level->site[x][y].roomnumber == roomno)) {
1433       blankoutspot(x,y);
1434       spreadroomdark(x+1,y,roomno);
1435       spreadroomdark(x,y+1,roomno);
1436       spreadroomdark(x-1,y,roomno);
1437       spreadroomdark(x,y-1,roomno);
1438     }
1439 }
1440 
1441 
1442 
1443 
display_pack()1444 void display_pack()
1445 {
1446   int i;
1447   if (Player.packptr < 1) print3("Pack is empty.");
1448   else {
1449     menuclear();
1450     menuprint("Items in Pack:\n");
1451     for(i=0;i<Player.packptr;i++) {
1452       sprintf(Str1, "  %c: %s\n", i + 'A', itemid(Player.pack[i]));
1453       menuprint(Str1);
1454     }
1455     showmenu();
1456   }
1457 }
1458 
1459 
display_possessions()1460 void display_possessions()
1461 {
1462   int i;
1463   for(i=0;i<MAXITEMS;i++)
1464     display_inventory_slot(i,FALSE);
1465 }
1466 
1467 
display_inventory_slot(slotnum,topline)1468 void display_inventory_slot(slotnum,topline)
1469 int slotnum;
1470 int topline;
1471 {
1472   WINDOW *W;
1473   char usechar = ')', idchar = '-';
1474   if (Player.possessions[slotnum] != NULL)
1475     if (Player.possessions[slotnum]->used)
1476       usechar = '>';
1477   if (topline) W = Msg3w;
1478   else {
1479     W = Showline[slotnum];
1480     hide_line(slotnum);
1481   }
1482   idchar = index_to_key(slotnum);
1483   touchwin(W);
1484   wclear(W);
1485   switch(slotnum) {
1486   case O_UP_IN_AIR:
1487     wprintw(W,"-- Object 'up in air':",usechar);
1488     break;
1489   case O_READY_HAND:
1490     wprintw(W,"-- %c%c ready hand: ",idchar,usechar);
1491     break;
1492   case O_WEAPON_HAND:
1493     wprintw(W,"-- %c%c weapon hand: ",idchar,usechar);
1494     break;
1495   case O_LEFT_SHOULDER:
1496     wprintw(W,"-- %c%c left shoulder: ",idchar,usechar);
1497     break;
1498   case O_RIGHT_SHOULDER:
1499     wprintw(W,"-- %c%c right shoulder: ",idchar,usechar);
1500     break;
1501   case O_BELT1:
1502     wprintw(W,"-- %c%c belt: ",idchar,usechar);
1503     break;
1504   case O_BELT2:
1505     wprintw(W,"-- %c%c belt: ",idchar,usechar);
1506     break;
1507   case O_BELT3:
1508     wprintw(W,"-- %c%c belt: ",idchar,usechar);
1509     break;
1510   case O_SHIELD:
1511     wprintw(W,"-- %c%c shield: ",idchar,usechar);
1512     break;
1513   case O_ARMOR:
1514     wprintw(W,"-- %c%c armor: ",idchar,usechar);
1515     break;
1516   case O_BOOTS:
1517     wprintw(W,"-- %c%c boots: ",idchar,usechar);
1518     break;
1519   case O_CLOAK:
1520     wprintw(W,"-- %c%c cloak: ",idchar,usechar);
1521     break;
1522   case O_RING1:
1523     wprintw(W,"-- %c%c finger: ",idchar,usechar);
1524     break;
1525   case O_RING2:
1526     wprintw(W,"-- %c%c finger: ",idchar,usechar);
1527     break;
1528   case O_RING3:
1529     wprintw(W,"-- %c%c finger: ",idchar,usechar);
1530     break;
1531   case O_RING4:
1532     wprintw(W,"-- %c%c finger: ",idchar,usechar);
1533     break;
1534   }
1535   if (Player.possessions[slotnum]== NULL)
1536     wprintw(W,"(slot vacant)");
1537   else wprintw(W,itemid(Player.possessions[slotnum]));
1538   wrefresh(W);
1539 }
1540 
move_slot(oldslot,newslot,maxslot)1541 int move_slot(oldslot,newslot,maxslot)
1542 int oldslot,newslot,maxslot;
1543 {
1544   if ((newslot >= 0) && (newslot < maxslot)){
1545     wmove(Showline[oldslot],0,0);
1546     waddstr(Showline[oldslot],"--");
1547     wrefresh(Showline[oldslot]);
1548     wmove(Showline[newslot],0,0);
1549     wstandout(Showline[newslot]);
1550     waddstr(Showline[newslot],">>");
1551     wstandend(Showline[newslot]);
1552     wrefresh(Showline[newslot]);
1553     return(newslot);
1554   }
1555   else return(oldslot);
1556 }
1557 
colour_on()1558 void colour_on()
1559 {
1560 }
1561 
colour_off()1562 void colour_off()
1563 {
1564   wattrset(Levelw, CHARATTR(CLR(WHITE)));
1565 }
1566 
display_option_slot(slot)1567 void display_option_slot(slot)
1568 int slot;
1569 {
1570   hide_line(slot);
1571   wclear(Showline[slot]);
1572   switch(slot) {
1573   case 1:
1574     wprintw(Showline[slot],"-- Option BELLICOSE [TF]: ");
1575     wprintw(Showline[slot], optionp(BELLICOSE) ? "(now T) " : "(now F) ");
1576     break;
1577   case 2:
1578     wprintw(Showline[slot],"-- Option JUMPMOVE [TF]: ");
1579     wprintw(Showline[slot], optionp(JUMPMOVE) ? "(now T) " : "(now F) ");
1580     break;
1581   case 3:
1582     wprintw(Showline[slot],"-- Option RUNSTOP [TF]: ");
1583     wprintw(Showline[slot], optionp(RUNSTOP) ? "(now T) " : "(now F) ");
1584     break;
1585   case 4:
1586     wprintw(Showline[slot],"-- Option PICKUP [TF]: ");
1587     wprintw(Showline[slot], optionp(PICKUP) ? "(now T) " : "(now F) ");
1588     break;
1589   case 5:
1590     wprintw(Showline[slot],"-- Option CONFIRM [TF]: ");
1591     wprintw(Showline[slot], optionp(CONFIRM) ? "(now T) " : "(now F) ");
1592     break;
1593   case 6:
1594     wprintw(Showline[slot],"-- Option TOPINV [TF]: ");
1595     wprintw(Showline[slot], optionp(TOPINV) ? "(now T) " : "(now F) ");
1596     break;
1597   case 7:
1598     wprintw(Showline[slot],"-- Option PACKADD [TF]: ");
1599     wprintw(Showline[slot], optionp(PACKADD) ? "(now T) " : "(now F) ");
1600     break;
1601   case 8:
1602 #ifdef COMPRESS_SAVE_FILES
1603     wprintw(Showline[slot],"-- Option COMPRESS [TF]: ");
1604     wprintw(Showline[slot], optionp(COMPRESS_OPTION) ? "(now T) " : "(now F) ");
1605 #endif
1606     break;
1607   case 9:
1608     wprintw(Showline[slot],"-- Option COLOUR [TF]: ");
1609     wprintw(Showline[slot], optionp(SHOW_COLOUR) ? "(now T) " : "(now F) ");
1610     break;
1611   case VERBOSITY_LEVEL:
1612     wprintw(Showline[slot],
1613 	    "-- Option VERBOSITY [(T)erse,(M)edium,(V)erbose]: (now ");
1614     if (Verbosity == VERBOSE) wprintw(Showline[slot],"Verbose)");
1615     else if (Verbosity == MEDIUM) wprintw(Showline[slot],"Medium)");
1616     else wprintw(Showline[slot],"Terse)");
1617     break;
1618   case SEARCH_DURATION:
1619     wprintw(Showline[slot],"-- Option SEARCHNUM [0>x>10]: (now %d)",Searchnum);
1620     break;
1621   }
1622   wrefresh(Showline[slot]);
1623 }
1624 
1625 
display_options()1626 void display_options()
1627 {
1628   int i;
1629   menuclear();
1630   hide_line(0);
1631   for(i=1;i<=NUMOPTIONS;i++)
1632     display_option_slot(i);
1633 }
1634 
1635 
1636 /* nya ha ha ha ha haaaa.... */
deathprint()1637 void deathprint()
1638 {
1639   mgetc();
1640   waddch(Msgw,'D');
1641   wrefresh(Msgw);
1642   mgetc();
1643   waddch(Msgw,'e');
1644   wrefresh(Msgw);
1645   mgetc();
1646   waddch(Msgw,'a');
1647   wrefresh(Msgw);
1648   mgetc();
1649   waddch(Msgw,'t');
1650   wrefresh(Msgw);
1651   mgetc();
1652   waddch(Msgw,'h');
1653   wrefresh(Msgw);
1654   mgetc();
1655 }
1656 
clear_if_necessary()1657 void clear_if_necessary()
1658 {
1659   int x,y;
1660   getyx(Msg1w,y,x);
1661 
1662   if (x != 0) {
1663     wclear(Msg1w);
1664     wrefresh(Msg1w);
1665   }
1666 
1667   getyx(Msg2w,y,x);
1668 
1669   if (x != 0) {
1670     wclear(Msg2w);
1671     wrefresh(Msg2w);
1672   }
1673 
1674   getyx(Msg3w,y,x);
1675 
1676   if (x != 0) {
1677     wclear(Msg3w);
1678     wrefresh(Msg3w);
1679   }
1680 
1681 }
1682 
1683 int bufferpos = 0;
1684 
buffercycle(s)1685 void buffercycle(s)
1686 char *s;
1687 {
1688   strcpy(Stringbuffer[bufferpos++],s);
1689   if (bufferpos >= STRING_BUFFER_SIZE)
1690     bufferpos = 0;
1691 }
1692 
bufferappend(s)1693 int bufferappend(s)
1694 char *s;
1695 {
1696   int pos = bufferpos - 1;
1697 
1698   if (pos < 0)
1699     pos = STRING_BUFFER_SIZE - 1;
1700   if (strlen(Stringbuffer[pos]) + strlen(s) < 80 - 1) {
1701     strcat(Stringbuffer[pos],s);
1702     return 1;
1703   }
1704   else
1705     return 0;
1706 }
1707 
1708 
bufferprint()1709 void bufferprint()
1710 {
1711   int i = bufferpos - 1, c, finished = 0;
1712   clearmsg();
1713 #ifndef MSDOS_SUPPORTED_ANTIQUE
1714   wprintw(Msg1w,"^p for previous message, ^n for next, anything else to quit.");
1715 #else
1716   wprintw(Msg1w,"^o for last message, ^n for next, anything else to quit.");
1717 #endif
1718   wrefresh(Msg1w);
1719   do {
1720     if (i >= STRING_BUFFER_SIZE) i = 0;
1721     if (i < 0) i = STRING_BUFFER_SIZE - 1;
1722     wclear(Msg2w);
1723     wprintw(Msg2w,Stringbuffer[i]);
1724     wrefresh(Msg2w);
1725     c = mgetc();
1726 #ifndef MSDOS_SUPPORTED_ANTIQUE
1727     if (c == 16)	/* ^p */
1728 #else
1729     if (c == 15)	/* ^o */
1730 #endif
1731       i--;
1732     else if (c == 14)	/* ^n */
1733       i++;
1734     else
1735       finished = 1;
1736   } while (!finished);
1737   clearmsg();
1738   omshowcursor(Player.x,Player.y);
1739 }
1740 
clear_screen()1741 void clear_screen()
1742 {
1743   clear();
1744   touchwin(stdscr);
1745   refresh();
1746 }
1747