LCOV - code coverage report
Current view: top level - omega-rpg-0.90-pa9 - scr.c (source / functions) Hit Total Coverage
Test: lcov.info Lines: 739 1256 58.8 %
Date: 2017-09-08 22:00:26 Functions: 73 110 66.4 %
Branches: 346 815 42.5 %

           Branch data     Line data    Source code
       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                 :            : # elif defined(USE_OPCURSES)
      13                 :            : #  include "../opcurses/curses.h"
      14                 :            : # else
      15                 :            : #  include <curses.h>
      16                 :            : # endif
      17                 :            : # include <sys/types.h>
      18                 :            : #endif
      19                 :            : 
      20                 :            : #if defined(MSDOS_SUPPORTED_ANTIQUE) || defined(AMIGA)
      21                 :            : # define CHARATTR(c)    ((c) >> 8)
      22                 :            : #else
      23                 :            : # define CHARATTR(c)    ((c) & ~0xff)
      24                 :            : #endif
      25                 :            : 
      26                 :            : #include "glob.h"
      27                 :            : #include <ctype.h>
      28                 :            : #include <unistd.h>
      29                 :            : 
      30                 :            : #ifdef EXCESSIVE_REDRAW
      31                 :            : #undef wclear
      32                 :            : #define wclear werase
      33                 :            : #endif
      34                 :            : 
      35                 :            : #ifdef NEW_BANK
      36                 :            : WINDOW *Bankw;
      37                 :            : #endif
      38                 :            : 
      39                 :            : /* note these variables are not exported to other files */
      40                 :            : 
      41                 :            : WINDOW *Levelw,*Dataw,*Flagw,*Timew,*Menuw,*Locw,*Morew,*Phasew;
      42                 :            : WINDOW *Comwin,*Msg1w,*Msg2w,*Msg3w,*Msgw;
      43                 :            : 
      44                 :            : WINDOW *Cinema;
      45                 :            : /* WDT: interactions and special effects which currently
      46                 :            :  * go into the message window should instead go here.  This
      47                 :            :  * should simplify history-keeping, since we only need to
      48                 :            :  * record actual messages, not special effects. */
      49                 :            : 
      50                 :            : WINDOW *Showline[MAXITEMS];
      51                 :            : 
      52                 :            : #define SL3_LEN 160
      53                 :            : char screenLine3[SL3_LEN];
      54                 :            : 
      55                 :            : /* static function prototypes */
      56                 :            : 
      57                 :            : static long input_number (WINDOW * w);
      58                 :            : 
      59                 :            : /* function definitions */
      60                 :            : 
      61                 :        105 : void phaseprint(void)
      62                 :            : {
      63                 :        105 :   wclear(Phasew);
      64                 :        105 :   wprintw(Phasew,"Moon's Phase:\n");
      65   [ -  -  -  +  :        105 :   switch(Phase/2) {
             +  -  -  - ]
      66                 :          0 :   case 0: wprintw(Phasew,"NEW"); break;
      67                 :          0 :   case 1: case 11: wprintw(Phasew,"CRESCENT"); break;
      68                 :          0 :   case 2: case 10: wprintw(Phasew,"1/4"); break;
      69                 :         74 :   case 3: case 9: wprintw(Phasew,"HALF"); break;
      70                 :         31 :   case 4: case 8: wprintw(Phasew,"3/4"); break;
      71                 :          0 :   case 5: case 7: wprintw(Phasew,"GIBBOUS"); break;
      72                 :          0 :   case 6: wprintw(Phasew,"FULL"); break;
      73                 :            :   }
      74                 :        105 :   wrefresh(Phasew);
      75                 :        105 : }
      76                 :            : 
      77                 :        268 : static void show_screen_level (int top, int left, int bottom, int right)
      78                 :            : {
      79                 :            :   int j;
      80                 :        268 :   int last_attr = 0;
      81                 :            : 
      82         [ +  + ]:       5324 :   for (j = top; j < bottom; ++j)
      83                 :            :     {
      84                 :            :       int i;
      85                 :            : 
      86                 :       5056 :       wmove(Levelw, screenmody(j), 0);
      87                 :            : 
      88         [ +  + ]:     319520 :       for (i = left; i < right; ++i)
      89                 :            :         {
      90                 :            :           int c;
      91                 :            : 
      92         [ +  + ]:     314464 :           if (loc_statusp(i, j, SEEN))
      93                 :     249464 :             c = getspot(i, j, FALSE);
      94                 :            :           else
      95                 :      65000 :             c = SPACE;
      96                 :            : 
      97 [ +  - ][ +  + ]:     314464 :           if (optionp(SHOW_COLOUR) && CHARATTR(c) != last_attr)
      98                 :            :             {
      99                 :      69174 :               last_attr = CHARATTR(c);
     100         [ +  - ]:      69174 :               wattrset(Levelw, last_attr);
     101                 :            :             }
     102                 :            : 
     103                 :     314464 :           waddch(Levelw, c & 0xff);
     104                 :            :         }
     105                 :            :     }
     106                 :        268 : }
     107                 :            : 
     108                 :          3 : static void show_screen_country (int top, int left, int bottom, int right)
     109                 :            : {
     110                 :            :   int j;
     111                 :          3 :   int last_attr = 0;
     112                 :            : 
     113         [ +  + ]:        189 :   for (j = top; j < bottom; ++j)
     114                 :            :     {
     115                 :            :       int i;
     116                 :            : 
     117                 :        186 :       wmove(Levelw, screenmody(j), 0);
     118                 :            : 
     119         [ +  + ]:      12090 :       for (i = left; i < right; ++i)
     120                 :            :         {
     121                 :            :           int c;
     122                 :            : 
     123         [ +  + ]:      11904 :           if (c_statusp(i, j, SEEN))
     124                 :        906 :             c = Country[i][j].current_terrain_type;
     125                 :            :           else
     126                 :      10998 :             c = SPACE;
     127                 :            : 
     128 [ +  - ][ +  + ]:      11904 :           if (optionp(SHOW_COLOUR) && CHARATTR(c) != last_attr)
     129                 :            :             {
     130                 :        501 :               last_attr = CHARATTR(c);
     131         [ +  - ]:        501 :               wattrset(Levelw, last_attr);
     132                 :            :             }
     133                 :            : 
     134                 :      11904 :           waddch(Levelw, c & 0xff);
     135                 :            :         }
     136                 :            :     }
     137                 :          3 : }
     138                 :            : 
     139                 :        271 : void show_screen(void)
     140                 :            : {
     141                 :            :   int top;
     142                 :            :   int left;
     143                 :            :   int right;
     144                 :            :   int bottom;
     145                 :            : 
     146                 :        271 :   wclear(Levelw);
     147                 :            : 
     148         [ +  + ]:        271 :   if (ScreenOffset < 0) ScreenOffset = 0;
     149         [ -  + ]:        271 :   if (ScreenXOffset < 0) ScreenXOffset = 0;
     150                 :            : 
     151                 :        271 :   top = ScreenOffset;
     152                 :        271 :   left = ScreenXOffset;
     153                 :        271 :   right = ScreenXOffset + ScreenWidth;
     154                 :        271 :   bottom = ScreenOffset + ScreenLength;
     155                 :            : 
     156         [ +  + ]:        271 :   if (Current_Environment != E_COUNTRYSIDE)
     157                 :            :     {
     158         [ +  + ]:        268 :       if (right > Level->level_width) right = Level->level_width;
     159         [ +  - ]:        268 :       if (bottom > Level->level_length) bottom = Level->level_length;
     160                 :            :     }
     161                 :            :   else
     162                 :            :     {
     163         [ -  + ]:          3 :       if (right > COUNTRY_WIDTH) right = COUNTRY_WIDTH;
     164         [ +  - ]:          3 :       if (bottom > COUNTRY_LENGTH) bottom = COUNTRY_LENGTH;
     165                 :            :     }
     166                 :            : 
     167         [ +  + ]:        271 :   if (Current_Environment != E_COUNTRYSIDE)
     168                 :            :     {
     169                 :        268 :       show_screen_level(top, left, bottom, right);
     170                 :            :     }
     171                 :            :   else
     172                 :            :     {
     173                 :          3 :       show_screen_country(top, left, bottom, right);
     174                 :            : #if 0
     175                 :            :       for (j=top;j<bottom;j++)
     176                 :            :         {
     177                 :            :           for (i=left;i<right;i++)
     178                 :            :             {
     179                 :            :               wmove(Levelw,screenmody(j),screenmodx(i));
     180                 :            :               c = ((c_statusp(i,j,SEEN)) ? Country[i][j].current_terrain_type:SPACE);
     181                 :            :               if (optionp(SHOW_COLOUR) && CHARATTR(c) != last_attr)
     182                 :            :                 {
     183                 :            :                   last_attr = CHARATTR(c);
     184                 :            :                   wattrset(Levelw,last_attr);
     185                 :            :                 }
     186                 :            :               waddch(Levelw,c&0xff);
     187                 :            :             }
     188                 :            :           wrefresh(Levelw);
     189                 :            :         }
     190                 :            : #endif
     191                 :            :     }
     192                 :        271 : }
     193                 :            : 
     194                 :            : 
     195                 :            : 
     196                 :        475 : char mgetc(void)
     197                 :            : {
     198                 :        475 :   return(wgetch(Msgw));
     199                 :            : }
     200                 :            : 
     201                 :            : /* case insensitive mgetc -- sends uppercase to lowercase */
     202                 :         33 : int mcigetc(void)
     203                 :            : {
     204                 :            :   int c;
     205                 :            : 
     206                 :            : #ifdef MSDOS_SUPPORTED_ANTIQUE
     207                 :            : #ifndef DJGPP
     208                 :            :   keypad(Msgw,TRUE);
     209                 :            : #endif
     210                 :            : #endif
     211                 :         33 :   c = wgetch(Msgw);
     212 [ +  + ][ +  + ]:         33 :   if ((c>=(int)'A') && (c<=(int)'Z'))
     213                 :          2 :     return(c+(int)('a'-'A'));
     214                 :         31 :   else return(c);
     215                 :            : }
     216                 :            : 
     217                 :          2 : char menugetc(void)
     218                 :            : {
     219                 :          2 :   return(wgetch(Menuw));
     220                 :            : }
     221                 :            : 
     222                 :            : 
     223                 :         96 : char lgetc(void)
     224                 :            : {
     225                 :         96 :   return(wgetch(Levelw));
     226                 :            : }
     227                 :            : 
     228                 :          1 : int ynq(void)
     229                 :            : {
     230                 :          1 :   int p='*'; /* the user's choice; start with something impossible
     231                 :            :               * to prevent a loop. */
     232 [ +  - ][ +  + ]:          2 :   while ((p != 'n') && (p != 'y') && (p != 'q') && (p != ESCAPE) &&
         [ +  - ][ +  - ]
                 [ +  - ]
     233         [ +  - ]:          1 :          (p != EOF) && (p != ' '))
     234                 :          1 :     p = wgetch(Msgw);
     235   [ +  -  -  -  :          1 :   switch (p) {
                   -  - ]
     236                 :          1 :   case 'y': wprintw(Msgw,"yes. "); break;
     237                 :          0 :   case 'n': wprintw(Msgw,"no. "); break;
     238                 :            :     
     239                 :          0 :   case ESCAPE: p = 'q'; /* fall through to 'q' */
     240                 :          0 :   case ' ': p = 'q';    /* fall through to 'q' */
     241                 :          0 :   case 'q': wprintw(Msgw,"quit. "); break;
     242         [ #  # ]:          0 :   default: assert( p == EOF );
     243                 :            :   }
     244                 :          1 :   wrefresh(Msgw);
     245                 :          1 :   return(p);
     246                 :            : }
     247                 :            : 
     248                 :            : 
     249                 :          4 : int ynq1(void)
     250                 :            : {
     251                 :          4 :   int p='*'; /* the user's choice; start with something impossible
     252                 :            :               * to prevent a loop. */
     253 [ +  + ][ +  + ]:          8 :   while ((p != 'n') && (p != 'y') && (p != 'q') && (p != ESCAPE) &&
         [ +  - ][ +  - ]
                 [ +  - ]
     254         [ +  - ]:          4 :          (p != ' ') && (p != EOF))
     255                 :          4 :     p = wgetch(Msg1w);
     256   [ +  +  -  -  :          4 :   switch (p) {
                   -  - ]
     257                 :          3 :   case 'y': wprintw(Msg1w,"yes. "); break;
     258                 :          1 :   case 'n': wprintw(Msg1w,"no. "); break;
     259                 :            :     
     260                 :          0 :   case ESCAPE: p = 'q'; /* fall through to 'q' */
     261                 :          0 :   case ' ': p = 'q';    /* fall through to 'q' */
     262                 :          0 :   case 'q': wprintw(Msg1w,"quit. "); break;
     263         [ #  # ]:          0 :   default: assert( p == EOF );
     264                 :            :   }
     265                 :          4 :   wrefresh(Msg1w);
     266                 :          4 :   return(p);
     267                 :            : }
     268                 :            : 
     269                 :            : 
     270                 :          1 : int ynq2(void)
     271                 :            : {
     272                 :          1 :   int p='*'; /* the user's choice; start with something impossible
     273                 :            :               * to prevent a loop. */
     274 [ +  - ][ +  + ]:          2 :   while ((p != 'n') && (p != 'y') && (p != 'q') && (p != ESCAPE) &&
         [ +  - ][ +  - ]
                 [ +  - ]
     275         [ +  - ]:          1 :          (p != ' ') && (p != EOF))
     276                 :          1 :     p = wgetch(Msg2w);
     277   [ +  -  -  -  :          1 :   switch (p) {
                   -  - ]
     278                 :          1 :   case 'y': wprintw(Msg2w,"yes. "); break;
     279                 :          0 :   case 'n': wprintw(Msg2w,"no. "); break;
     280                 :            :     
     281                 :          0 :   case ESCAPE: p = 'q'; /* fall through to 'q' */
     282                 :          0 :   case ' ': p = 'q';    /* fall through to 'q' */
     283                 :          0 :   case 'q': wprintw(Msg2w,"quit. "); break;
     284         [ #  # ]:          0 :   default: assert( p == EOF );
     285                 :            :   }
     286                 :          1 :   wrefresh(Msg2w);
     287                 :          1 :   return(p);
     288                 :            : }
     289                 :            :     
     290                 :        119 : void erasemsg3 (void)
     291                 :            : {
     292                 :        119 :   werase(Msg3w);
     293                 :        119 :   memset(screenLine3, 0, SL3_LEN);
     294                 :        119 : }
     295                 :            : 
     296                 :            : /* puts up a morewait to allow reading if anything in top two lines */
     297                 :          9 : void checkclear(void)
     298                 :            : {
     299                 :            :   int x1,y,x2;
     300 [ +  - ][ +  - ]:          9 :   getyx(Msg1w,x1,y);
     301 [ +  - ][ +  - ]:          9 :   getyx(Msg2w,x2,y);  
     302 [ +  - ][ -  + ]:          9 :   if ((x1 != 0) || (x2 != 0)) {
     303                 :          0 :     morewait();
     304                 :          0 :     wclear(Msg1w);
     305                 :          0 :     wclear(Msg2w);
     306                 :          0 :     wrefresh(Msg1w);
     307                 :          0 :     wrefresh(Msg2w);
     308                 :            :   }
     309                 :          9 : }
     310                 :            :   
     311                 :            : /* for external call */
     312                 :         67 : void clearmsg(void)
     313                 :            : {
     314                 :         67 :   wclear(Msg1w);
     315                 :         67 :   wclear(Msg2w);
     316                 :         67 :   erasemsg3();
     317                 :         67 :   Msgw = Msg1w;
     318                 :         67 :   wrefresh(Msg1w);
     319                 :         67 :   wrefresh(Msg2w);
     320                 :         67 :   wrefresh(Msg3w);
     321                 :         67 : }
     322                 :            : 
     323                 :          7 : void clearmsg3(void)
     324                 :            : {
     325                 :          7 :   erasemsg3();
     326                 :          7 :   wrefresh(Msg3w);
     327                 :          7 : }
     328                 :            : 
     329                 :          7 : void clearmsg1(void)
     330                 :            : {
     331                 :          7 :   wclear(Msg1w);
     332                 :          7 :   wclear(Msg2w);
     333                 :          7 :   Msgw = Msg1w;
     334                 :          7 :   wrefresh(Msg1w);
     335                 :          7 :   wrefresh(Msg2w);
     336                 :          7 : }
     337                 :            : 
     338                 :            : 
     339                 :          0 : void erase_level(void)
     340                 :            : {
     341                 :          0 :   wclear(Levelw);
     342                 :          0 :   wrefresh(Levelw);
     343                 :          0 : }
     344                 :            : 
     345                 :            : /* direct print to first msg line */
     346                 :         51 : void print1(char *s)
     347                 :            : {
     348         [ +  - ]:         51 :   if (! gamestatusp(SUPPRESS_PRINTING)) {
     349                 :         51 :     buffercycle(s);
     350                 :         51 :     wclear(Msg1w);
     351                 :         51 :     wprintw(Msg1w,s);
     352                 :         51 :     wrefresh(Msg1w);
     353                 :            :   }
     354                 :         51 : }
     355                 :            : 
     356                 :            : /* for run on-messages -- print1 clears first.... */
     357                 :          5 : void nprint1(char *s)
     358                 :            : {
     359         [ +  - ]:          5 :   if (! gamestatusp(SUPPRESS_PRINTING)) {
     360         [ +  - ]:          5 :     if (bufferappend(s)) {
     361                 :          5 :       wprintw(Msg1w,s);
     362                 :          5 :       wrefresh(Msg1w);
     363                 :            :     }
     364                 :            :   }
     365                 :          5 : }
     366                 :            : 
     367                 :            : 
     368                 :            : /* direct print to second msg line */
     369                 :         22 : void print2(char *s)
     370                 :            : {
     371         [ +  - ]:         22 :   if (! gamestatusp(SUPPRESS_PRINTING)) {
     372                 :         22 :     buffercycle(s);
     373                 :         22 :     wclear(Msg2w);
     374                 :         22 :     wprintw(Msg2w,s);
     375                 :         22 :     wrefresh(Msg2w);
     376                 :            :   }
     377                 :         22 : }
     378                 :            : 
     379                 :            : /* for run on-messages -- print2 clears first.... */
     380                 :         11 : void nprint2(char *s)
     381                 :            : {
     382         [ +  - ]:         11 :   if (! gamestatusp(SUPPRESS_PRINTING)) {
     383         [ +  - ]:         11 :     if (bufferappend(s)) {
     384                 :         11 :       wprintw(Msg2w,s);
     385                 :         11 :       wrefresh(Msg2w);
     386                 :            :     }
     387                 :            :   }
     388                 :         11 : }
     389                 :            : 
     390                 :            : 
     391                 :            : /* msg line 3 is not part of the region that mprint or printm can reach */
     392                 :            : /* typical use of print3 is for "you can't do that" type error messages */
     393                 :            : /* WDT: it's also typically used for messages intended to persist a while.
     394                 :            :  * Thus I'm having print3 save its input in a global variable which other
     395                 :            :  * things can use. */
     396                 :         12 : void print3 (char *s)
     397                 :            : {
     398         [ +  - ]:         12 :   if (!gamestatusp(SUPPRESS_PRINTING))
     399                 :            :     {
     400                 :         12 :       buffercycle(s);
     401                 :         12 :       erasemsg3();
     402                 :         12 :       wprintw(Msg3w, s);
     403                 :         12 :       strcpy(screenLine3, s);
     404                 :         12 :       wrefresh(Msg3w);
     405                 :            :     }
     406                 :         12 : }
     407                 :            : 
     408                 :            : /* for run on-messages -- print3 clears first.... */
     409                 :          0 : void nprint3(char *s)
     410                 :            : {
     411         [ #  # ]:          0 :   if (!gamestatusp(SUPPRESS_PRINTING))
     412                 :            :     {
     413         [ #  # ]:          0 :       if (bufferappend(s))
     414                 :            :         {
     415                 :          0 :           strcat(screenLine3, s);
     416                 :          0 :           wprintw(Msg3w,s);
     417                 :          0 :           wrefresh(Msg3w);
     418                 :            :         }
     419                 :            :     }
     420                 :          0 : }
     421                 :            : 
     422                 :            : 
     423                 :            : 
     424                 :            : /* prints wherever cursor is in window, but checks to see if
     425                 :            : it should morewait and clear window */
     426                 :        137 : void mprint(char *s)
     427                 :            : {
     428                 :            :   int x,y;
     429         [ +  - ]:        137 :   if (! gamestatusp(SUPPRESS_PRINTING)) {
     430 [ +  - ][ +  - ]:        137 :     getyx(Msgw,y,x);
     431         [ +  + ]:        137 :     if (x+strlen(s) >= ScreenWidth) {
     432                 :         39 :       buffercycle(s);
     433         [ +  + ]:         39 :       if (Msgw == Msg1w) {
     434                 :         24 :         wclear(Msg2w);
     435                 :         24 :         Msgw = Msg2w;
     436                 :            :       }
     437                 :            :       else {
     438                 :         15 :         morewait();
     439                 :         15 :         wclear(Msg1w);
     440                 :         15 :         wclear(Msg2w);
     441                 :         15 :         wrefresh(Msg2w);
     442                 :         39 :         Msgw = Msg1w;
     443                 :            :       }
     444                 :            :     }
     445         [ +  + ]:         98 :     else if (x > 0)
     446                 :         52 :       bufferappend(s);
     447                 :            :     else
     448                 :         46 :       buffercycle(s);
     449                 :        137 :     wprintw(Msgw,s);
     450                 :        137 :     waddch(Msgw,' '); 
     451                 :        137 :     wrefresh(Msgw);
     452                 :            :   }
     453                 :        137 : }
     454                 :            : 
     455                 :            : 
     456                 :          1 : void omega_title(void)
     457                 :            : {
     458                 :          1 :   showmotd();
     459                 :          1 :   clear();
     460         [ +  - ]:          1 :   touchwin(stdscr);
     461                 :          1 :   refresh();  
     462                 :            :   /*  showscores();*/ /* DG */
     463                 :          1 : }
     464                 :            : 
     465                 :            : 
     466                 :            : 
     467                 :            : /* blanks out ith line of Menuw or Levelw */
     468                 :        293 : void hide_line(int i)
     469                 :            : {
     470                 :        293 :   wclear(Showline[i]);
     471         [ +  - ]:        293 :   touchwin(Showline[i]);
     472                 :        293 :   wrefresh(Showline[i]);
     473                 :        293 : }
     474                 :            : 
     475                 :            : #ifdef USE_OPCURSES
     476                 :            : static void load_tiles (void)
     477                 :            : {
     478                 :            :   char * path;
     479                 :            : 
     480                 :            :   path = malloc(strlen(OMEGALIB) + strlen(TILEFILE) + 1);
     481                 :            :   if (0 == path) return;
     482                 :            : 
     483                 :            :   strcpy(path, OMEGALIB);
     484                 :            :   strcat(path, TILEFILE);
     485                 :            : 
     486                 :            :   set_tiles(path);
     487                 :            : 
     488                 :            :   free(path);
     489                 :            : }
     490                 :            : #endif
     491                 :            : 
     492                 :            : /* initialize, screen, windows */
     493                 :          1 : void initgraf(void)
     494                 :            : {
     495                 :            :   int i;
     496                 :            : 
     497                 :            : #ifdef USE_OPCURSES
     498                 :            :   load_tiles();
     499                 :            : #endif
     500                 :            : 
     501                 :          1 :   initscr();
     502                 :            : #if !defined(MSDOS_SUPPORTED_ANTIQUE)
     503                 :          1 :   start_color();
     504                 :            : # ifndef AMIGA
     505                 :          1 :   clrgen_init();
     506                 :            : # endif
     507                 :            : #endif
     508 [ +  - ][ -  + ]:          1 :   if (LINES < 24 || COLS < 80) {
     509                 :          0 :     printf("Minimum Screen Size: 24 Lines by 80 Columns.");
     510                 :          0 :     exit(0);
     511                 :            :   }
     512                 :            : #ifdef AMIGA
     513                 :            :   init_color(1, 800, 800, 800); /* white */
     514                 :            :   init_color(2, 644, 164, 164); /* brown */
     515                 :            :   init_color(3, 800, 800, 0); /* yellow */
     516                 :            :   init_color(4, 200, 200, 200); /* grey */
     517                 :            :   init_color(5, 0, 1000, 0); /* green */
     518                 :            :   init_color(6, 0, 0, 1000); /* blue */
     519                 :            :   init_color(7, 1000, 0, 0); /* red */
     520                 :            :   LINES -= 2;   /* ugly, but neccessary with this curses package... */
     521                 :            : #endif
     522                 :          1 :   ScreenLength = LINES - 6;
     523                 :          1 :   ScreenWidth = 64; /* PGM */
     524                 :          1 :   Msg1w = newwin(1,80,0,0);
     525                 :          1 :   scrollok(Msg1w, 0);   /* DJGPP curses defaults to scrollable new windows */
     526                 :          1 :   Msg2w = newwin(1,80,1,0);
     527                 :          1 :   scrollok(Msg2w, 0);
     528                 :          1 :   Msg3w = newwin(1,80,2,0);
     529                 :          1 :   scrollok(Msg3w, 0);
     530                 :          1 :   Msgw = Msg1w;
     531                 :          1 :   Morew = newwin(1,15,3,65);  
     532                 :          1 :   scrollok(Morew, 0);
     533                 :            : #ifdef NEW_BANK
     534                 :          1 :   Bankw = newwin( 20, 50, ( ScreenLength - 20 ) / 2 + 3, 7 );
     535                 :          1 :   scrollok( Bankw, 0 );
     536                 :            : #endif
     537                 :          1 :   Locw = newwin(1,80,ScreenLength+3,0);
     538                 :          1 :   scrollok(Locw, 0);
     539                 :          1 :   Levelw = newwin(ScreenLength,ScreenWidth,3,0);
     540                 :          1 :   scrollok(Levelw, 0);
     541         [ +  + ]:         17 :   for(i=0;i<MAXITEMS;i++) {
     542                 :         16 :     Showline[i] = newwin(1,ScreenWidth,i+3,0);
     543                 :         16 :     scrollok(Showline[i], 0);
     544                 :         16 :     wclear(Showline[i]);
     545                 :            :   }
     546                 :          1 :   Menuw = newwin(ScreenLength,ScreenWidth,3,0);
     547                 :          1 :   scrollok(Menuw, 0);
     548                 :          1 :   Dataw = newwin(2,80,ScreenLength+4,0);
     549                 :          1 :   scrollok(Dataw, 0);
     550                 :          1 :   Timew = newwin(2,15,4,65);
     551                 :          1 :   scrollok(Timew, 0);
     552                 :          1 :   Phasew = newwin(2,15,6,65);
     553                 :          1 :   scrollok(Phasew, 0);
     554                 :          1 :   Flagw = newwin(4,15,9,65);
     555                 :          1 :   scrollok(Flagw, 0);
     556                 :          1 :   Comwin = newwin(8,15,14,65);
     557                 :          1 :   scrollok(Comwin, 0);
     558                 :          1 :   Cinema = newwin(3,80,0,0); /* the same position and size as the three 
     559                 :            :                               * message windows. */
     560                 :          1 :   scrollok(Cinema,0);
     561                 :            : 
     562                 :          1 :   noecho();
     563                 :          1 :   crmode();
     564                 :            : 
     565                 :          1 :   clear();
     566         [ +  - ]:          1 :   touchwin(stdscr);
     567                 :            :   /*  omega_title();*/
     568                 :            :   /*  clear();*/
     569                 :            :   /*  touchwin(stdscr);*/
     570                 :            :   /*  refresh();*/          /* DG */
     571                 :          1 : }
     572                 :            : 
     573                 :            : /* cinema_display: pop up a window out of the way of the screen and fill it
     574                 :            :  * with 3 lines of text.  The lines may be NULL pointers. */
     575                 :         49 : void cinema_display (char *line1, char *line2, char *line3)
     576                 :            : {
     577                 :         49 :   werase(Cinema);
     578                 :            : 
     579         [ +  - ]:         49 :   if (line1)
     580                 :            :     {
     581         [ +  + ]:         49 :       if (line2)
     582                 :            :         {
     583         [ +  + ]:         42 :           if (line3)
     584                 :            :             {
     585                 :          3 :               mvwprintw(Cinema, 0, 0, line1);
     586                 :          3 :               mvwprintw(Cinema, 1, 0, line2);
     587                 :          3 :               mvwprintw(Cinema, 2, 0, line3);
     588                 :            :             }
     589                 :            :           else
     590                 :            :             {
     591                 :         39 :               mvwprintw(Cinema, 2, 0, screenLine3);
     592                 :         39 :               mvwprintw(Cinema, 0, 0, line1);
     593                 :         42 :               mvwprintw(Cinema, 1, 0, line2);
     594                 :            :             }
     595                 :            :         }
     596                 :            :       else
     597                 :            :         {
     598         [ -  + ]:          7 :           if (line3)
     599                 :            :             {
     600                 :          0 :               mvwprintw(Cinema, 0, 0, line1);
     601                 :          0 :               mvwprintw(Cinema, 2, 0, line3);
     602                 :            :             }
     603                 :            :           else
     604                 :            :             {
     605                 :          7 :               mvwprintw(Cinema, 2, 0, screenLine3);
     606                 :         49 :               mvwprintw(Cinema, 0, 0, line1);
     607                 :            :             }
     608                 :            :         }
     609                 :            :     }
     610                 :            :   else
     611                 :            :     {
     612         [ #  # ]:          0 :       if (line2)
     613                 :            :         {
     614         [ #  # ]:          0 :           if (line3)
     615                 :            :             {
     616                 :          0 :               mvwprintw(Cinema, 1, 0, line2);
     617                 :          0 :               mvwprintw(Cinema, 2, 0, line3);
     618                 :            :             }
     619                 :            :           else
     620                 :            :             {
     621                 :          0 :               mvwprintw(Cinema, 2, 0, screenLine3);
     622                 :          0 :               mvwprintw(Cinema, 1, 0, line2);
     623                 :            :             }
     624                 :            :         }
     625                 :            :       else
     626                 :            :         {
     627         [ #  # ]:          0 :           if (line3)
     628                 :            :             {
     629                 :          0 :               mvwprintw(Cinema, 2, 0, line3);
     630                 :            :             }
     631                 :            :           else
     632                 :            :             {
     633                 :          0 :               mvwprintw(Cinema, 2, 0, screenLine3);
     634                 :            :             }
     635                 :            :         }
     636                 :            :     }
     637                 :            : 
     638                 :         49 :   wrefresh(Cinema);
     639                 :         49 : }
     640                 :            : 
     641                 :          1 : void cinema_blank (void)
     642                 :            : {
     643                 :          1 :   werase(Cinema);
     644                 :          1 : }
     645                 :            : 
     646                 :          0 : static void cinema_blank_line (int line)
     647                 :            : {
     648                 :            :   int x;
     649                 :            :   int maxy, maxx;
     650                 :            : 
     651 [ #  # ][ #  # ]:          0 :   getmaxyx(Cinema, maxy, maxx);
     652                 :          0 :   wmove(Cinema, line, 0);
     653                 :            : 
     654         [ #  # ]:          0 :   for (x = 0; x < maxx; ++x)
     655                 :          0 :     waddch(Cinema, ' ');
     656                 :            : 
     657                 :          0 :   wrefresh(Cinema);
     658                 :          0 : }
     659                 :            : 
     660                 :          1 : void cinema_print_line (int line, char * text)
     661                 :            : {
     662                 :          1 :   mvwprintw(Cinema, line, 0, text);
     663                 :          1 :   wrefresh(Cinema);
     664                 :          1 : }
     665                 :            : 
     666                 :            : /* Doggone it, there ought to be a way to simply hide a window, thereby
     667                 :            :  * redrawing anything which happened to be under it. */
     668                 :         46 : void cinema_hide (void)
     669                 :            : {
     670         [ +  - ]:         46 :   touchwin(Msg1w);
     671                 :         46 :   wrefresh(Msg1w);
     672         [ +  - ]:         46 :   touchwin(Msg2w);
     673                 :         46 :   wrefresh(Msg2w);
     674         [ +  - ]:         46 :   touchwin(Msg3w);
     675                 :         46 :   wrefresh(Msg3w);
     676                 :         46 : }
     677                 :            : 
     678                 :         46 : int cinema_getch (void)
     679                 :            : {
     680                 :            :   int response;
     681                 :         46 :   response = wgetch(Cinema);
     682 [ +  - ][ -  + ]:         46 :   if (EOF == response || ESCAPE == response) response = -1;
     683                 :         46 :   return response;
     684                 :            : }
     685                 :            : 
     686                 :            : /* cinema_interact: pop up a window out of the way of the screen, fill
     687                 :            :  * it with up to three lines of text, wait for user input, close the
     688                 :            :  * window, and return the user's input.
     689                 :            :  * 
     690                 :            :  * Params:
     691                 :            :  * 
     692                 :            :  *   choices: a \0-terminated array containing the characters which are
     693                 :            :  *         acceptable responses to this interaction.  ESC is always
     694                 :            :  *         acceptable, regardless of choices.  \0 is never acceptable
     695                 :            :  *         and may not be embedded in the string.
     696                 :            :  * 
     697                 :            :  *   line1-3: The 3 lines of text, each at most 80 chars long.  Any may
     698                 :            :  *         be NULL, and none may contain CRs or escape sequences.
     699                 :            :  * 
     700                 :            :  * Return Value:
     701                 :            :  *   -1 if ESC was pressed; otherwise the character chosen.
     702                 :            :  */
     703                 :         43 : int cinema_interact (char *choices, char *line1, char *line2, char *line3)
     704                 :            : {
     705                 :            :   int response;
     706                 :            : 
     707 [ +  - ][ -  + ]:         43 :   assert(choices && strlen(choices) > 0);
     708                 :            : 
     709                 :            :   while (1)
     710                 :            :     {
     711                 :         46 :       cinema_display(line1, line2, line3);
     712                 :         46 :       response = cinema_getch();
     713         [ -  + ]:         46 :       if (-1 == response) break;
     714         [ +  + ]:         46 :       if (strchr(choices, response)) break;
     715         [ +  - ]:          3 :       if (!line3) line3 = "What? Try again!";
     716                 :          3 :     }
     717                 :            :   
     718                 :         43 :   cinema_hide();
     719                 :         43 :   return response;
     720                 :            : }
     721                 :            : 
     722                 :          0 : int cinema_interact_line (int line, char * choices, char * text)
     723                 :            : {
     724                 :            :   int response;
     725                 :            : 
     726 [ #  # ][ #  # ]:          0 :   assert(0 == line || 1 == line);
     727 [ #  # ][ #  # ]:          0 :   assert(choices && strlen(choices) > 0);
     728                 :            : 
     729                 :            :   while (1)
     730                 :            :     {
     731                 :          0 :       cinema_print_line(line, text);
     732                 :          0 :       response = cinema_getch();
     733         [ #  # ]:          0 :       if (ABORT == response) break;
     734         [ #  # ]:          0 :       if (strchr(choices, response)) break;
     735                 :          0 :       cinema_print_line(2, "What? Try again!");
     736                 :          0 :     }
     737                 :            : 
     738                 :          0 :   return response;
     739                 :            : }
     740                 :            : 
     741                 :          0 : int cinema_ynq_line (int line, char * prompt)
     742                 :            : {
     743                 :          0 :   return cinema_interact_line(line, "ynqYNQ", prompt);
     744                 :            : }
     745                 :            : 
     746                 :          0 : int cinema_getnum_line (int line, char * prompt)
     747                 :            : {
     748                 :            :   int num;
     749                 :            : 
     750 [ #  # ][ #  # ]:          0 :   assert(0 == line || 1 == line);
     751                 :            : 
     752                 :          0 :   cinema_blank_line(line);
     753                 :          0 :   cinema_print_line(line, prompt);
     754                 :          0 :   num = (int)input_number(Cinema);
     755                 :            : 
     756                 :          0 :   return num;
     757                 :            : }
     758                 :            : 
     759                 :         23 : int cinema_confirm (char * action_description)
     760                 :            : {
     761                 :            :   char *msg;
     762                 :            : 
     763   [ +  +  +  + ]:         23 :   switch (random_range(4))
     764                 :            :     {
     765                 :          7 :     case 0: msg = "Are you sure? [yn] "; break;
     766                 :         11 :     case 1: msg = "Certain about that? [yn] "; break;
     767                 :          4 :     case 2: msg = "Do you really mean it? [yn] "; break;
     768                 :          1 :     default: msg = "Confirm that, would you? [yn] "; break;
     769                 :            :     }
     770                 :            : 
     771                 :         23 :   return cinema_interact("ynqYNQ", action_description, msg, NULL);
     772                 :            : }
     773                 :            : 
     774                 :          7 : int cinema_ynq (char *action_description)
     775                 :            : {
     776                 :          7 :   return cinema_interact("ynqYNQ", action_description, NULL, NULL);
     777                 :            : }
     778                 :            : 
     779                 :          0 : void cinema_scene (char *line1, char *line2, char *line3)
     780                 :            : {
     781                 :          0 :   cinema_display(line1, line2, line3);
     782                 :          0 :   morewait();
     783                 :          0 :   cinema_hide();
     784                 :          0 : }
     785                 :            : 
     786                 :            : int lastx= -1,lasty= -1;
     787                 :            : 
     788                 :       1043 : void drawplayer(void)
     789                 :            : {
     790                 :            :   int c;
     791                 :            : 
     792         [ +  + ]:       1043 :   if (E_COUNTRYSIDE == Current_Environment)
     793                 :            :     {
     794 [ +  - ][ +  - ]:         33 :       if (inbounds(lastx, lasty) && !offscreen(lastx, lasty))
     795                 :            :         {
     796                 :         33 :           wmove(Levelw, screenmody(lasty), screenmodx(lastx));
     797                 :         33 :           c = Country[lastx][lasty].current_terrain_type;
     798                 :            : 
     799 [ +  - ][ +  - ]:         33 :           if (optionp(SHOW_COLOUR)) wattrset(Levelw, CHARATTR(c));
     800                 :            : 
     801                 :         33 :           waddch(Levelw, c & 0xff);
     802                 :            :         }
     803                 :            : 
     804                 :         33 :       wmove(Levelw, screenmody(Player.y), screenmodx(Player.x));
     805                 :            : 
     806 [ +  - ][ +  - ]:         33 :       if (optionp(SHOW_COLOUR)) wattrset(Levelw, CHARATTR(PLAYER));
     807                 :            : 
     808                 :         33 :       waddch(Levelw, PLAYER & 0xff);
     809                 :            :     }
     810                 :            :   else
     811                 :            :     {
     812 [ +  + ][ +  - ]:       1010 :       if (inbounds(lastx, lasty) && !offscreen(lastx, lasty))
     813                 :       1009 :         plotspot(lastx, lasty, (Player.status[BLINDED] > 0 ? FALSE : TRUE));
     814                 :            : 
     815                 :       1010 :       wmove(Levelw, screenmody(Player.y), screenmodx(Player.x));
     816                 :            : 
     817 [ -  + ][ #  # ]:       1010 :       if ((!Player.status[INVISIBLE]) || Player.status[TRUESIGHT])
     818                 :            :         {
     819 [ +  - ][ +  - ]:       1010 :           if (optionp(SHOW_COLOUR)) wattrset(Levelw, CHARATTR(PLAYER));
     820                 :       1010 :           waddch(Levelw, PLAYER & 0xff);
     821                 :            :         }
     822                 :            :     }
     823                 :            : 
     824                 :       1043 :   lastx = Player.x;
     825                 :       1043 :   lasty = Player.y;
     826                 :       1043 : }
     827                 :            : 
     828                 :          6 : void setlastxy(int new_x, int new_y) /* used when changing environments */
     829                 :            : {
     830                 :          6 :   lastx = new_x;
     831                 :          6 :   lasty = new_y;
     832                 :          6 : }
     833                 :            : 
     834                 :          0 : int litroom(int x, int y)
     835                 :            : {
     836         [ #  # ]:          0 :   if (Level->site[x][y].roomnumber < ROOMBASE) return(FALSE);
     837 [ #  # ][ #  # ]:          0 :   else return(loc_statusp(x,y,LIT) ||
     838                 :          0 :               Player.status[ILLUMINATION]);
     839                 :            : }
     840                 :            : 
     841                 :        784 : void drawvision(int x, int y)
     842                 :            : {
     843                 :            :   static int oldx = -1,oldy = -1;
     844                 :            :   int i,j,c;
     845                 :            : 
     846         [ +  + ]:        784 :   if (Current_Environment != E_COUNTRYSIDE) {
     847         [ -  + ]:        751 :     if (Player.status[BLINDED]) {
     848                 :          0 :       drawspot(oldx,oldy);
     849                 :          0 :       drawspot(x,y);
     850                 :          0 :       drawplayer();
     851                 :            :     }
     852                 :            :     else {
     853         [ -  + ]:        751 :       if (Player.status[ILLUMINATION] > 0) {
     854         [ #  # ]:          0 :         for (i= -2;i<3;i++)
     855         [ #  # ]:          0 :           for (j= -2;j<3;j++)
     856         [ #  # ]:          0 :             if (inbounds(x+i,y+j))
     857         [ #  # ]:          0 :               if (view_los_p(x+i,y+j,Player.x,Player.y))
     858                 :          0 :                 dodrawspot(x+i,y+j);
     859                 :            :       }
     860                 :            :       else {
     861         [ +  + ]:       3004 :         for (i= -1;i<2;i++)
     862         [ +  + ]:       9012 :           for (j= -1;j<2;j++)
     863         [ +  + ]:       6759 :             if (inbounds(x+i,y+j))
     864                 :       6645 :               dodrawspot(x+i,y+j);
     865                 :            :       }
     866                 :        751 :       drawplayer();
     867                 :        751 :       drawmonsters(FALSE); /* erase all monsters */
     868                 :        751 :       drawmonsters(TRUE);  /* draw those now visible */
     869                 :            :     }
     870 [ -  + ][ #  # ]:        751 :     if ((! gamestatusp(FAST_MOVE)) || (! optionp(JUMPMOVE)))
     871                 :        751 :       omshowcursor(Player.x,Player.y);
     872                 :        751 :     oldx = x;
     873                 :        751 :     oldy = y;
     874                 :            :   }
     875                 :            :   else {
     876         [ +  + ]:        132 :     for (i= -1;i<2;i++)
     877         [ +  + ]:        396 :       for (j= -1;j<2;j++)
     878         [ +  - ]:        297 :         if (inbounds(x+i,y+j)) {
     879                 :        297 :           c_set(x+i, y+j, SEEN);
     880         [ +  - ]:        297 :           if (!offscreen(x+i,y+j)) {
     881                 :        297 :             wmove(Levelw,screenmody(y+j),screenmodx(x+i));
     882                 :        297 :             c = Country[x+i][y+j].current_terrain_type;
     883         [ +  - ]:        297 :             if (optionp(SHOW_COLOUR))
     884         [ +  - ]:        297 :               wattrset(Levelw, CHARATTR(c));
     885                 :        297 :             waddch(Levelw,(c&0xff));
     886                 :            :           }
     887                 :            :         }
     888                 :         33 :     drawplayer();
     889                 :         33 :     omshowcursor(Player.x,Player.y);
     890                 :            :   }
     891                 :        784 : }
     892                 :            : 
     893                 :            : 
     894                 :        955 : void omshowcursor(int x, int y)
     895                 :            : {
     896         [ +  - ]:        955 :   if (! offscreen(x,y)) {
     897                 :        955 :     wmove(Levelw,screenmody(y),screenmodx(x));
     898                 :        955 :     wrefresh(Levelw);
     899                 :            :   }
     900                 :        955 : }
     901                 :            : 
     902                 :          0 : void levelrefresh(void)
     903                 :            : {
     904                 :          0 :   wrefresh(Levelw);
     905                 :          0 : }
     906                 :            : 
     907                 :            : 
     908                 :            : /* draws a particular spot under if in line-of-sight */
     909                 :          0 : void drawspot(int x, int y)
     910                 :            : {
     911                 :            :   Symbol c;
     912         [ #  # ]:          0 :   if (inbounds(x,y)) {
     913                 :          0 :     c = getspot(x,y,FALSE);
     914         [ #  # ]:          0 :     if (c != Level->site[x][y].showchar)
     915         [ #  # ]:          0 :       if (view_los_p(Player.x,Player.y,x,y)) {
     916                 :          0 :         lset(x,y,SEEN);
     917                 :          0 :         Level->site[x][y].showchar = c;
     918                 :          0 :         putspot(x,y,c);
     919                 :            :       }
     920                 :            :   }
     921                 :          0 : }
     922                 :            : 
     923                 :            : 
     924                 :            : 
     925                 :            : /* draws a particular spot regardless of line-of-sight */
     926                 :       6645 : void dodrawspot(int x, int y)
     927                 :            : {
     928                 :            :   Symbol c;
     929         [ +  - ]:       6645 :   if (inbounds(x,y)) {
     930                 :       6645 :     c = getspot(x,y,FALSE);
     931         [ +  + ]:       6645 :     if (c != Level->site[x][y].showchar) {
     932                 :         57 :       lset(x,y,SEEN);
     933                 :         57 :       Level->site[x][y].showchar = c;
     934                 :         57 :       putspot(x,y,c);
     935                 :            :     }
     936                 :            :   }
     937                 :       6645 : }
     938                 :            : 
     939                 :            : /* write a blank to a spot if it is floor */
     940                 :          0 : void blankoutspot(int i, int j)
     941                 :            : {
     942         [ #  # ]:          0 :   if (inbounds(i,j)) {
     943                 :          0 :     lreset(i,j,LIT);
     944                 :          0 :     lset(i, j, CHANGED);
     945         [ #  # ]:          0 :     if (Level->site[i][j].locchar == FLOOR)  {
     946                 :          0 :       Level->site[i][j].showchar = SPACE;
     947                 :          0 :       putspot(i,j,SPACE);
     948                 :            :     }
     949                 :            :   }
     950                 :          0 : }
     951                 :            : 
     952                 :            : /* blank out a spot regardless */
     953                 :       1766 : void blotspot(int i, int j)
     954                 :            : {
     955         [ +  - ]:       1766 :   if (inbounds(i,j)) {
     956                 :       1766 :     lreset(i,j,SEEN);
     957                 :       1766 :     Level->site[i][j].showchar = SPACE;
     958         [ +  - ]:       1766 :     if (! offscreen(i,j)) {
     959                 :       1766 :       wmove(Levelw,screenmody(j),screenmodx(i));
     960         [ +  - ]:       1766 :       wattrset(Levelw, CHARATTR(SPACE));
     961                 :       1766 :       waddch(Levelw, SPACE&0xff);
     962                 :            :     }
     963                 :            :   }
     964                 :       1766 : }
     965                 :            : 
     966                 :            : 
     967                 :            : /* for displaying activity specifically at some point */
     968                 :       1011 : void plotspot(int x, int y, int showmonster)
     969                 :            : {
     970         [ +  + ]:       1011 :   if (loc_statusp(x,y,SEEN))
     971                 :       1010 :     putspot(x,y,getspot(x,y,showmonster));
     972                 :            :   else 
     973                 :          1 :     putspot(x,y,SPACE);
     974                 :       1011 : }
     975                 :            : 
     976                 :            : 
     977                 :            : /* Puts c at x,y on screen. No fuss, no bother. */
     978                 :      10469 : void putspot(int x, int y, Symbol c)
     979                 :            : {
     980         [ +  + ]:      10469 :   if (! offscreen(x,y)) {
     981                 :       8996 :     wmove(Levelw,screenmody(y),screenmodx(x));
     982         [ +  - ]:       8996 :     if (optionp(SHOW_COLOUR))
     983         [ +  - ]:       8996 :       wattrset(Levelw, CHARATTR(c));
     984                 :       8996 :     waddch(Levelw,(0xff&c));
     985                 :            :   }
     986                 :      10469 : }
     987                 :            : 
     988                 :            : 
     989                 :            : /* regardless of line of sight, etc, draw a monster */
     990                 :          0 : void plotmon(pmt m)
     991                 :            : {
     992         [ #  # ]:          0 :   if (! offscreen(m->x,m->y)) {
     993                 :          0 :     wmove(Levelw,screenmody(m->y),screenmodx(m->x));
     994         [ #  # ]:          0 :     if (optionp(SHOW_COLOUR))
     995         [ #  # ]:          0 :       wattrset(Levelw, CHARATTR(m->monchar));
     996                 :          0 :     waddch(Levelw,(m->monchar&0xff));
     997                 :            :   }
     998                 :          0 : }
     999                 :            :   
    1000                 :            : /* if display, displays monsters, otherwise erases them */
    1001                 :       1767 : void drawmonsters(int display)
    1002                 :            : {
    1003                 :            :   pml ml;
    1004         [ +  + ]:      23135 :   for (ml=Level->mlist;ml!=NULL;ml=ml->next) {
    1005         [ +  + ]:      21368 :     if (ml->m->hp > 0) {
    1006         [ +  + ]:      21365 :       if (display) {
    1007         [ +  + ]:      11585 :         if (view_los_p(Player.x,Player.y,ml->m->x,ml->m->y)) {
    1008 [ +  - ][ +  + ]:       1072 :           if (Player.status[TRUESIGHT] || (! m_statusp(ml->m,M_INVISIBLE))) {
    1009 [ -  + ][ #  # ]:       1051 :             if (!optionp(SHOW_COLOUR) &&
    1010         [ #  # ]:          0 :                 (ml->m->level > 5) &&
    1011         [ #  # ]:          0 :                 ((ml->m->monchar&0xff) != '@') &&
    1012         [ #  # ]:          0 :                 ((ml->m->monchar&0xff) != '|')) wstandout(Levelw);
    1013                 :       1051 :             putspot(ml->m->x,ml->m->y,ml->m->monchar);
    1014         [ -  + ]:       1051 :             if (!optionp(SHOW_COLOUR))
    1015         [ #  # ]:      11585 :               wstandend(Levelw);
    1016                 :            :           }
    1017                 :            :         }
    1018                 :            :       }
    1019                 :       9780 :       else erase_monster(ml->m);
    1020                 :            :     }
    1021                 :            :   }
    1022                 :       1767 : }
    1023                 :            : 
    1024                 :            : /* replace monster with what would be displayed if monster weren't there */
    1025                 :      10115 : void erase_monster(pmt m)
    1026                 :            : {
    1027         [ +  + ]:      10115 :   if (loc_statusp(m->x,m->y,SEEN))
    1028                 :       8349 :     putspot(m->x,m->y,getspot(m->x,m->y,FALSE));
    1029                 :       1766 :   else blotspot(m->x,m->y);
    1030                 :      10115 : }
    1031                 :            : 
    1032                 :            : /* find apt char to display at some location */
    1033                 :     265469 : Symbol getspot(int x, int y, int showmonster)
    1034                 :            : {
    1035                 :            : #ifdef CENTER_ON_PLAYER
    1036                 :            :   /* funny scrolling may cause this. PGM */
    1037                 :            :   if (!inbounds(x,y ) )
    1038                 :            :     {
    1039                 :            :       return SPACE;
    1040                 :            :     }
    1041                 :            : #endif
    1042                 :            : 
    1043         [ +  + ]:     265469 :   if (loc_statusp(x,y,SECRET))
    1044                 :            :     {
    1045         [ -  + ]:        586 :       if ( Level->site[x][y].roomnumber == RS_DRUID )
    1046                 :          0 :         return(HEDGE);  /* secret doors in druid temple are brambles -DAG */
    1047                 :            :       else
    1048                 :        586 :         return(WALL);
    1049                 :            :     }
    1050   [ +  +  +  + ]:     264883 :   else switch (Level->site[x][y].locchar) {
    1051                 :            :   case WATER:
    1052         [ +  - ]:      24203 :     if (Level->site[x][y].creature == NULL) 
    1053                 :      24203 :       return(WATER);
    1054         [ #  # ]:          0 :     else if (m_statusp(Level->site[x][y].creature,SWIMMING))
    1055                 :          0 :       return(WATER);
    1056         [ #  # ]:          0 :     else if (showmonster)
    1057                 :          0 :       return(Level->site[x][y].creature->monchar);
    1058                 :          0 :     else return(WATER);
    1059                 :            :     /* these sites never show anything but their location char's */
    1060                 :            :   case CLOSED_DOOR:
    1061                 :            :   case LAVA:
    1062                 :            :   case FIRE:
    1063                 :            :   case ABYSS:
    1064                 :        907 :     return(Level->site[x][y].locchar);
    1065                 :            :     /* rubble and hedge don't show items on their location */
    1066                 :            :   case RUBBLE:
    1067                 :            :   case HEDGE:
    1068 [ -  + ][ #  # ]:      77527 :     if (showmonster && (Level->site[x][y].creature != NULL)) {
    1069 [ #  # ][ #  # ]:          0 :       if ((m_statusp(Level->site[x][y].creature,M_INVISIBLE)) &&
    1070                 :          0 :           (! Player.status[TRUESIGHT]))
    1071                 :          0 :         return(getspot(x,y,FALSE));
    1072                 :          0 :       else return (Level->site[x][y].creature->monchar);
    1073                 :            :     }
    1074                 :      77527 :     else return(Level->site[x][y].locchar);
    1075                 :            :     /* everywhere else, first try to show monster, next show items, next show
    1076                 :            :        location char */
    1077                 :            :   default:
    1078 [ +  + ][ +  + ]:     162246 :     if (showmonster && (Level->site[x][y].creature != NULL)) {
    1079 [ -  + ][ #  # ]:          3 :       if ((m_statusp(Level->site[x][y].creature,M_INVISIBLE)) &&
    1080                 :          0 :           (! Player.status[TRUESIGHT]))
    1081                 :          0 :         return(getspot(x,y,FALSE));
    1082                 :          3 :       else return (Level->site[x][y].creature->monchar);
    1083                 :            :     }
    1084         [ +  + ]:     162243 :     else if (Level->site[x][y].things != NULL) {
    1085         [ +  + ]:        198 :       if (Level->site[x][y].things->next != NULL)
    1086                 :         92 :         return(PILE);
    1087                 :        106 :       else return(Level->site[x][y].things->thing->objchar);
    1088                 :            :     }
    1089                 :     162045 :     else return(Level->site[x][y].locchar);
    1090                 :            :   }
    1091                 :            : }
    1092                 :            : 
    1093                 :         12 : void commanderror(void)
    1094                 :            : {
    1095                 :         12 :   erasemsg3();
    1096                 :         12 :   wprintw(Msg3w, "%c : unknown command", Cmd);
    1097                 :         12 :   wrefresh(Msg3w);
    1098                 :         12 : }
    1099                 :            : 
    1100                 :         44 : void timeprint(void)
    1101                 :            : {
    1102                 :            :   static char * old_month = 0;
    1103                 :            : 
    1104                 :            :   /* WSS * HACK * This shouldn't be here at all but time is so screwed up */
    1105                 :            :   /* WSS * HACK * I don't know where else I can check for a new month reliably */
    1106         [ +  + ]:         44 :   if (!old_month)
    1107                 :          1 :     old_month = month();
    1108                 :            :   else
    1109                 :            :     {
    1110                 :            :       /* WSS * HACK * ptr comparision... works cause they're static */
    1111 [ -  + ][ #  # ]:         43 :       if (old_month != month() && Player.rank[LEGION] > 0)
    1112                 :            :         {
    1113                 :            :           bank_account * account;
    1114                 :          0 :           account = bank_index_number(SalaryAccount);
    1115         [ #  # ]:          0 :           if (account) account->balance += SalaryAmount;
    1116                 :          0 :           old_month = month();
    1117                 :            :         }
    1118                 :            :     }
    1119                 :            : 
    1120                 :         44 :   wclear(Timew);
    1121                 :         44 :   wprintw(Timew,"%d:%d",showhour(),showminute());
    1122         [ +  + ]:         44 :   if (showminute()==0) waddch(Timew,'0');
    1123         [ +  + ]:         44 :   wprintw(Timew,hour()>11 ? " PM \n" : " AM \n");
    1124                 :         44 :   wprintw(Timew,month());
    1125                 :         44 :   wprintw(Timew," the %d",day());
    1126                 :         44 :   wprintw(Timew,ordinal(day()));
    1127                 :         44 :   wrefresh(Timew);
    1128                 :         44 : }
    1129                 :            : 
    1130                 :            : 
    1131                 :         22 : void comwinprint(void)
    1132                 :            : {
    1133                 :         22 :   wclear(Comwin);
    1134                 :         22 :   wprintw(Comwin,"Hit: %d  \n",Player.hit);
    1135                 :         22 :   wprintw(Comwin,"Dmg: %d  \n",Player.dmg);
    1136                 :         22 :   wprintw(Comwin,"Def: %d  \n",Player.defense);
    1137                 :         22 :   wprintw(Comwin,"Arm: %d  \n",Player.absorption);
    1138                 :         22 :   wprintw(Comwin,"Spd: %d.%d  \n", 5/Player.speed, 500/Player.speed%100);
    1139                 :         22 :   wrefresh(Comwin);
    1140                 :         22 : }
    1141                 :            : 
    1142                 :        168 : void dataprint(void)
    1143                 :            : {
    1144                 :        168 :   wclear(Dataw);
    1145                 :            :   /* WDT HACK: I should make these fields spaced and appropriately justified.
    1146                 :            :    * Maybe I don't feel like it right now. */
    1147                 :        168 :   wprintw(Dataw,"Hp:%d/%d Mana:%ld/%ld Au:%ld Level:%d/%ld Carry:%d/%d \n",
    1148                 :            :           Player.hp,Player.maxhp,Player.mana,Player.maxmana,Player.cash,
    1149                 :            :           Player.level,Player.xp,Player.itemweight,Player.maxweight);
    1150                 :        168 :   wprintw(Dataw,"Str:%d/%d Con:%d/%d Dex:%d/%d Agi:%d/%d Int:%d/%d Pow:%d/%d   ",
    1151                 :            :           Player.str,Player.maxstr,Player.con,Player.maxcon,
    1152                 :            :           Player.dex,Player.maxdex,Player.agi,Player.maxagi,
    1153                 :            :           Player.iq,Player.maxiq,Player.pow,Player.maxpow);
    1154                 :        168 :   wrefresh(Dataw);
    1155                 :        168 : }
    1156                 :            : 
    1157                 :            : 
    1158                 :            : /* redraw everything currently displayed */
    1159                 :          0 : void redraw(void)
    1160                 :            : {
    1161         [ #  # ]:          0 :   touchwin(curscr);
    1162                 :          0 :   wrefresh(curscr);
    1163                 :          0 : }  
    1164                 :            : 
    1165                 :            : /* redraw each permanent window */
    1166                 :         29 : void xredraw(void)
    1167                 :            : {
    1168         [ +  - ]:         29 :   touchwin(Msgw);
    1169         [ +  - ]:         29 :   touchwin(Msg3w);
    1170         [ +  - ]:         29 :   touchwin(Levelw);
    1171         [ +  - ]:         29 :   touchwin(Timew);
    1172         [ +  - ]:         29 :   touchwin(Flagw);
    1173         [ +  - ]:         29 :   touchwin(Dataw);
    1174         [ +  - ]:         29 :   touchwin(Locw);
    1175         [ +  - ]:         29 :   touchwin(Morew);
    1176         [ +  - ]:         29 :   touchwin(Phasew);
    1177         [ +  - ]:         29 :   touchwin(Comwin); 
    1178                 :         29 :   wrefresh(Msgw);
    1179                 :         29 :   wrefresh(Msg3w);
    1180                 :         29 :   wrefresh(Levelw);
    1181                 :         29 :   wrefresh(Timew);
    1182                 :         29 :   wrefresh(Flagw);
    1183                 :         29 :   wrefresh(Dataw);
    1184                 :         29 :   wrefresh(Locw);
    1185                 :         29 :   wrefresh(Morew);
    1186                 :         29 :   wrefresh(Phasew);
    1187                 :         29 :   wrefresh(Comwin);
    1188                 :         29 : }
    1189                 :            : 
    1190                 :            : 
    1191                 :            : 
    1192                 :          0 : void menuaddch(char c)
    1193                 :            : {
    1194                 :          0 :   waddch(Menuw,c);
    1195                 :          0 :   wrefresh(Menuw);
    1196                 :          0 : }
    1197                 :            : 
    1198                 :            : 
    1199                 :            : 
    1200                 :         33 : void morewait(void)
    1201                 :            : {
    1202                 :         33 :   int display=TRUE;
    1203                 :            :   int c;
    1204         [ -  + ]:         33 :   if (gamestatusp(SUPPRESS_PRINTING))
    1205                 :          0 :     return;
    1206                 :            :   do {
    1207                 :         34 :     wclear(Morew);
    1208         [ +  + ]:         34 :     if (display) wprintw(Morew,"***  MORE  ***");
    1209                 :          1 :     else wprintw(Morew,"+++  MORE  +++");
    1210                 :         34 :     display = ! display;
    1211                 :         34 :     wrefresh(Morew);
    1212                 :            :     /* c = wgetch(Msgw); */
    1213                 :         34 :     c = wgetch(Morew);
    1214 [ +  + ][ +  + ]:         34 :   } while ((c != ' ') && (c != RETURN) && (c != EOF));
                 [ +  - ]
    1215                 :         33 :   wclear(Morew);
    1216                 :         33 :   wrefresh(Morew);
    1217                 :            : }
    1218                 :            : 
    1219                 :          0 : int stillonblock(void)
    1220                 :            : {
    1221                 :          0 :   int display=TRUE;
    1222                 :            :   int c;
    1223                 :            :   do {
    1224                 :          0 :     wclear(Morew);
    1225         [ #  # ]:          0 :     if (display) wprintw(Morew,"<<<STAY?>>>");
    1226                 :          0 :     else wprintw(Morew,">>>STAY?<<<");
    1227                 :          0 :     display = ! display;
    1228                 :          0 :     wrefresh(Morew);
    1229                 :          0 :     c = wgetch(Msgw);
    1230 [ #  # ][ #  # ]:          0 :   } while ((c != ' ') && (c != ESCAPE) && (c != EOF));
                 [ #  # ]
    1231                 :          0 :   wclear(Morew);
    1232                 :          0 :   wrefresh(Morew);
    1233                 :          0 :   return (c == ' ');
    1234                 :            : }
    1235                 :            : 
    1236                 :         31 : void menuclear(void)
    1237                 :            : {
    1238                 :         31 :   wclear(Menuw);
    1239         [ +  - ]:         31 :   touchwin(Menuw);
    1240                 :         31 :   wrefresh(Menuw);
    1241                 :         31 : }
    1242                 :            : 
    1243                 :          0 : void menuspellprint(int i)
    1244                 :            : {
    1245                 :            :   int x,y;
    1246 [ #  # ][ #  # ]:          0 :   getyx(Menuw,y,x);
    1247         [ #  # ]:          0 :   if (y >= ScreenLength - 2) {
    1248                 :          0 :     wrefresh(Menuw);
    1249                 :          0 :     morewait();
    1250                 :          0 :     wclear(Menuw);
    1251         [ #  # ]:          0 :     touchwin(Menuw);
    1252                 :            :   }
    1253                 :          0 :   wprintw(Menuw,spellid(i));
    1254                 :          0 :   wprintw(Menuw,"(%d)\n",Spells[i].powerdrain);
    1255                 :          0 : }  
    1256                 :            : 
    1257                 :        444 : void menuprint(char *s)
    1258                 :            : {
    1259                 :            :   int x,y;
    1260 [ +  - ][ +  - ]:        444 :   getyx(Menuw,y,x);
    1261         [ -  + ]:        444 :   if (y >= ScreenLength - 2) {
    1262                 :          0 :     wrefresh(Menuw);
    1263                 :          0 :     morewait();
    1264                 :          0 :     wclear(Menuw);
    1265         [ #  # ]:          0 :     touchwin(Menuw);
    1266                 :            :   }
    1267                 :        444 :   wprintw(Menuw,s);
    1268                 :        444 : }
    1269                 :            : 
    1270                 :         30 : void showmenu(void)
    1271                 :            : {
    1272                 :         30 :   wrefresh(Menuw);
    1273                 :         30 : }
    1274                 :            : 
    1275                 :            : 
    1276                 :          1 : void endgraf(void)
    1277                 :            : {
    1278                 :          1 :   clear();
    1279         [ +  - ]:          1 :   touchwin(stdscr);
    1280                 :          1 :   refresh();
    1281                 :          1 :   endwin();
    1282                 :          1 : }
    1283                 :            : 
    1284                 :            : 
    1285                 :          0 : void plotchar(Symbol pyx, int x, int y)
    1286                 :            : {
    1287         [ #  # ]:          0 :   if (! offscreen(x,y)) {
    1288                 :          0 :     wmove(Levelw,screenmody(y),screenmodx(x));
    1289         [ #  # ]:          0 :     if (optionp(SHOW_COLOUR))
    1290         [ #  # ]:          0 :       wattrset(Levelw, CHARATTR(pyx));
    1291                 :          0 :     waddch(Levelw,(pyx&0xff));
    1292                 :          0 :     wrefresh(Levelw);
    1293                 :            :   }
    1294                 :          0 : }
    1295                 :            : 
    1296                 :            : 
    1297                 :            : 
    1298                 :          0 : void draw_explosion(Symbol pyx, int x, int y)
    1299                 :            : {
    1300                 :            :   int i,j;
    1301                 :            :   
    1302         [ #  # ]:          0 :   for(j=0;j<3;j++) {
    1303         [ #  # ]:          0 :     for(i=0;i<9;i++) 
    1304                 :          0 :       plotchar(pyx,x+Dirs[0][i],y+Dirs[1][i]);
    1305                 :          0 :     usleep(150000);
    1306         [ #  # ]:          0 :     for(i=0;i<9;i++)
    1307                 :          0 :       plotchar(SPACE,x+Dirs[0][i],y+Dirs[1][i]);
    1308                 :          0 :     usleep(150000);
    1309                 :            :   }
    1310         [ #  # ]:          0 :   for(i=0;i<9;i++) 
    1311                 :          0 :     plotspot(x+Dirs[0][i],y+Dirs[1][i],TRUE);
    1312                 :          0 :   wrefresh(Levelw);
    1313                 :          0 : }
    1314                 :            : 
    1315                 :          1 : char *msgscanstring(void)
    1316                 :            : {
    1317                 :            :   static char instring[80],byte='x';
    1318                 :          1 :   int i=0;
    1319                 :            : 
    1320                 :          1 :   instring[0]=0;
    1321                 :          1 :   byte = mgetc();
    1322         [ +  + ]:          9 :   while (byte != '\n') {
    1323 [ +  - ][ +  + ]:          8 :     if ((byte == 8) || (byte == 127)) { /* ^h or delete */
    1324         [ +  - ]:          1 :       if (i>0){ 
    1325                 :          1 :         i--;
    1326                 :          1 :         dobackspace();
    1327                 :            :       }
    1328                 :          1 :       instring[i] = 0;
    1329                 :            :     }
    1330                 :            :     else {
    1331                 :          7 :       instring[i] = byte;
    1332                 :          7 :       waddch(Msgw,byte);
    1333                 :          7 :       wrefresh(Msgw);
    1334                 :          7 :       i++;
    1335                 :          7 :       instring[i] = 0;
    1336                 :            :     }
    1337                 :          8 :     byte = mgetc();
    1338                 :            :   } 
    1339                 :          1 :   return(instring);
    1340                 :            : }
    1341                 :            : 
    1342                 :            : 
    1343                 :         42 : void locprint(char *s)
    1344                 :            : {
    1345                 :         42 :   wclear(Locw);
    1346                 :         42 :   wprintw(Locw,s);
    1347                 :         42 :   wrefresh(Locw);
    1348                 :         42 : }
    1349                 :            : 
    1350                 :            : /* draw everything whether visible or not */
    1351                 :          0 : void drawscreen(void)
    1352                 :            : {
    1353                 :            :   int i,j;
    1354         [ #  # ]:          0 :   if (Current_Environment == E_COUNTRYSIDE)
    1355         [ #  # ]:          0 :     for (i=0;i<COUNTRY_WIDTH;i++)
    1356         [ #  # ]:          0 :       for(j=0;j<COUNTRY_LENGTH;j++)
    1357                 :          0 :         c_set(i, j, SEEN);
    1358         [ #  # ]:          0 :   else for (i=0;i<Level->level_width;i++)
    1359         [ #  # ]:          0 :     for(j=0;j<Level->level_length;j++)
    1360                 :          0 :       lset(i,j,SEEN);
    1361         [ #  # ]:          0 :   if (Current_Environment == E_CITY)
    1362         [ #  # ]:          0 :     for (i = 0; i < NUMCITYSITES; i++)
    1363                 :          0 :       CitySiteList[i][0] = 1;
    1364                 :          0 :   show_screen();
    1365                 :          0 : }
    1366                 :            : 
    1367                 :            : /*selects a number up to range */
    1368                 :            : /* WDT HACK!  This should use the interaction code, and should allow
    1369                 :            :  * direct input. */
    1370                 :          3 : int getnumber(int range)
    1371                 :            : {
    1372                 :          3 :   int done=FALSE,value=1;
    1373                 :            :   int atom;
    1374                 :            : 
    1375         [ +  - ]:          3 :   if (range==1) return(1);
    1376         [ #  # ]:          0 :   else while (! done) {
    1377                 :          0 :     clearmsg();
    1378                 :          0 :     wprintw(Msg1w,"How many? Change with < or >, ESCAPE to select:");
    1379                 :          0 :     mnumprint(value);
    1380                 :            : #ifndef MSDOS
    1381                 :          0 :     do atom=mcigetc();
    1382 [ #  # ][ #  # ]:          0 :     while ((atom != '<')&&(atom != '>')&&(atom!=ESCAPE));
                 [ #  # ]
    1383 [ #  # ][ #  # ]:          0 :     if ((atom=='>') && (value < range)) value++;
    1384 [ #  # ][ #  # ]:          0 :     else if ((atom=='<') && (value > 1)) value--;
    1385         [ #  # ]:          0 :     else if (atom==ESCAPE) done = TRUE;
    1386                 :            : #else
    1387                 :            :     atom=mcigetc();
    1388                 :            :     switch (atom)
    1389                 :            :       {
    1390                 :            :       case '>':
    1391                 :            :       case 'k':
    1392                 :            : #ifdef KEY_UP
    1393                 :            :       case KEY_UP:
    1394                 :            : #endif
    1395                 :            :         if (value < range)
    1396                 :            :           value++;
    1397                 :            :         break;
    1398                 :            :       case '<':
    1399                 :            :       case 'j':
    1400                 :            : #ifdef KEY_DOWN
    1401                 :            :       case KEY_DOWN:
    1402                 :            : #endif
    1403                 :            :         if (value > 1)
    1404                 :            :           value--;
    1405                 :            :         break;
    1406                 :            : #ifdef KEY_HOME
    1407                 :            :       case KEY_HOME:
    1408                 :            : #endif
    1409                 :            :         value = 1;
    1410                 :            :         break;
    1411                 :            : #ifdef KEY_LL
    1412                 :            :       case KEY_LL:
    1413                 :            : #endif
    1414                 :            :         value = range;
    1415                 :            :         break;
    1416                 :            :       case ESCAPE:
    1417                 :            :         done = TRUE;
    1418                 :            :         break;
    1419                 :            :       }
    1420                 :            : #endif
    1421                 :            :   }
    1422                 :          0 :   return(value);
    1423                 :            : }
    1424                 :            : 
    1425                 :          0 : static long input_number (WINDOW * w)
    1426                 :            : {
    1427                 :            :   int ch;
    1428                 :            :   int ypos, xpos;
    1429                 :          0 :   int numlen = 0;
    1430                 :          0 :   int amount = 0;
    1431                 :            : 
    1432 [ #  # ][ #  # ]:          0 :   getyx(w, ypos, xpos);
    1433                 :            : 
    1434                 :            :   while (1)
    1435                 :            :     {
    1436         [ #  # ]:          0 :       ch = mvwgetch(w, ypos, xpos);
    1437                 :            : 
    1438 [ #  # ][ #  # ]:          0 :       if ('\n' == ch || '\r' == ch)
    1439                 :            :         {
    1440                 :          0 :           return amount;
    1441                 :            :         }
    1442 [ #  # ][ #  # ]:          0 :       else if (EOF == ch || ESCAPE == ch)
    1443                 :            :         {
    1444                 :          0 :           return ABORT;
    1445                 :            :         }
    1446 [ #  # ][ #  # ]:          0 :       else if (BACKSPACE == ch || DELETE == ch)
    1447                 :            :         {
    1448         [ #  # ]:          0 :           if (numlen > 0)
    1449                 :            :             {
    1450                 :          0 :               --numlen;
    1451                 :          0 :               amount /= 10;
    1452         [ #  # ]:          0 :               mvwaddch(w, ypos, --xpos, ' ');
    1453                 :            :             }
    1454                 :            :         }
    1455 [ #  # ][ #  # ]:          0 :       else if (isdigit(ch) && (numlen < 9))
    1456                 :            :         {
    1457                 :          0 :           ++xpos;
    1458                 :          0 :           ++numlen;
    1459                 :          0 :           waddch(w, ch);
    1460                 :          0 :           amount = 10 * amount + (ch - '0');
    1461                 :            :         }
    1462                 :            :       else
    1463                 :            :         {
    1464                 :          0 :           beep();
    1465                 :            :         }
    1466                 :          0 :     }
    1467                 :            : }
    1468                 :            : 
    1469                 :            : /* reads a positive number up to 999999 */
    1470                 :            : /* WDT: now asks for the number, and receives it through the cinema
    1471                 :            :  * interface.  Returns ABORT (-1) if aborted. */
    1472                 :          3 : long parsenum (char *message)
    1473                 :            : {
    1474                 :            :   int number[8];
    1475                 :          3 :   int place = -1;
    1476                 :          3 :   int i,x,y,mult=1;
    1477                 :          3 :   long num=0;
    1478                 :          3 :   char byte=' ';
    1479                 :          3 :   int entering_digits = TRUE;
    1480                 :            : 
    1481                 :          3 :   cinema_display(message, "enter a number or ESC: ", NULL);
    1482         [ +  + ]:          7 :   while (entering_digits) {
    1483                 :          4 :     byte = wgetch(Cinema);
    1484 [ +  - ][ -  + ]:          4 :     if ((byte == BACKSPACE) || (byte == DELETE)) {
    1485         [ #  # ]:          0 :       if (place > -1) {
    1486                 :          0 :         number[place] = 0;
    1487                 :          0 :         place--;
    1488 [ #  # ][ #  # ]:          0 :         getyx(Cinema,y,x);
    1489                 :          0 :         wmove(Cinema,y,x-1);
    1490                 :          0 :         waddch(Cinema,' ');
    1491                 :          0 :         wmove(Cinema,y,x-1);
    1492                 :          0 :         wrefresh(Cinema);
    1493                 :            :       }
    1494                 :            :     }
    1495 [ +  - ][ +  + ]:          4 :     else if ((byte <= '9') && (byte >= '0') && (place < 7)) {
                 [ +  - ]
    1496                 :          1 :       place++;
    1497                 :          1 :       number[place]=byte;
    1498                 :          1 :       waddch(Cinema,byte);
    1499                 :          1 :       wrefresh(Cinema);
    1500                 :            :     }
    1501         [ +  - ]:          3 :     else if (isprint(byte)) {
    1502                 :            :       /* I suppose I should beep here, to indicate that only digits belong.
    1503                 :            :        * Right now I'm just ignoring them.
    1504                 :            :        */
    1505                 :            :     }
    1506                 :          3 :     else entering_digits = 0;
    1507                 :            :   }
    1508         [ +  + ]:          3 :   if (byte != '\n') num = ABORT;
    1509                 :            :   else {
    1510         [ +  + ]:          2 :     for (i=place;i>=0;i--) {
    1511                 :          1 :       num += mult*(number[i]-'0');
    1512                 :          1 :       mult*=10;
    1513                 :            :     }
    1514                 :            :   }
    1515                 :          3 :   cinema_hide();
    1516                 :          3 :   return num;
    1517                 :            : }
    1518                 :            : 
    1519                 :            : 
    1520                 :            :     
    1521                 :          0 : void maddch(char c)
    1522                 :            : {
    1523                 :          0 :   waddch(Msgw,c);
    1524                 :          0 :   wrefresh(Msgw);
    1525                 :          0 : }
    1526                 :            : 
    1527                 :            : 
    1528                 :          0 : void display_death(char *source)
    1529                 :            : {
    1530                 :          0 :   clear();
    1531         [ #  # ]:          0 :   touchwin(stdscr);
    1532                 :          0 :   printw("\n\n\n\n");
    1533                 :          0 :   printw("Requiescat In Pace, ");
    1534                 :          0 :   printw(Player.name);
    1535                 :          0 :   printw(" (%ld points)",calc_points());
    1536                 :          0 :   strcpy(Str4,"Killed by ");
    1537                 :          0 :   strcat(Str4,source);
    1538                 :          0 :   printw("\n");
    1539                 :          0 :   printw(Str4);
    1540                 :          0 :   printw(".");
    1541                 :          0 :   printw("\n\n\n\n\nHit 'c' to continue.");
    1542                 :          0 :   refresh();
    1543         [ #  # ]:          0 :   while (wgetch(stdscr) != 'c')
    1544                 :            :         ;
    1545                 :          0 :   clear();
    1546         [ #  # ]:          0 :   touchwin(stdscr);
    1547                 :          0 :   refresh();
    1548                 :          0 :   extendlog(Str4,DEAD);
    1549                 :          0 : }
    1550                 :            : 
    1551                 :            : 
    1552                 :          0 : void display_win(void)
    1553                 :            : {
    1554                 :          0 :   clear();
    1555         [ #  # ]:          0 :   touchwin(stdscr);
    1556                 :          0 :   printw("\n\n\n\n");
    1557                 :          0 :   printw(Player.name);
    1558         [ #  # ]:          0 :   if (Player.rank[ADEPT]) {
    1559                 :          0 :     printw(" is a total master of omega with %ld points!",FixedPoints);
    1560                 :          0 :     strcpy(Str4,"A total master of omega");
    1561                 :            :   }
    1562                 :            :   else {
    1563                 :          0 :     strcpy(Str4,"retired a winner");
    1564                 :          0 :     printw(" triumphed in omega with %ld points!",calc_points());
    1565                 :            :   }
    1566                 :          0 :   printw("\n\n\n\n\nHit 'c' to continue.");
    1567                 :          0 :   refresh();
    1568         [ #  # ]:          0 :   while (wgetch(stdscr) != 'c')
    1569                 :            :         ;
    1570                 :          0 :   clear();
    1571         [ #  # ]:          0 :   touchwin(stdscr);
    1572                 :          0 :   refresh();
    1573         [ #  # ]:          0 :   if (Player.rank[ADEPT])
    1574                 :          0 :     extendlog(Str4,BIGWIN);
    1575                 :          0 :   else extendlog(Str4,WIN);
    1576                 :          0 : }
    1577                 :            : 
    1578                 :          0 : void display_quit(void)
    1579                 :            : {
    1580                 :          0 :   clear();
    1581         [ #  # ]:          0 :   touchwin(stdscr);
    1582                 :          0 :   printw("\n\n\n\n");
    1583                 :          0 :   printw(Player.name);
    1584                 :          0 :   strcpy(Str4,"A quitter.");
    1585                 :          0 :   printw(" wimped out with %ld points!",calc_points());
    1586                 :          0 :   printw("\n\n\n\n\nHit 'c' to continue.");
    1587                 :          0 :   refresh();
    1588         [ #  # ]:          0 :   while (wgetch(stdscr) != 'c')
    1589                 :            :         ;
    1590                 :          0 :   clear();
    1591         [ #  # ]:          0 :   touchwin(stdscr);
    1592                 :          0 :   refresh();
    1593                 :          0 :   extendlog(Str4,QUIT);
    1594                 :          0 : }
    1595                 :            : 
    1596                 :            : 
    1597                 :          0 : void display_bigwin(void)
    1598                 :            : {
    1599                 :          0 :   clear();
    1600         [ #  # ]:          0 :   touchwin(stdscr);
    1601                 :          0 :   printw("\n\n\n\n");
    1602                 :          0 :   printw(Player.name);
    1603                 :          0 :   strcpy(Str4,"retired, an Adept of Omega.");
    1604                 :          0 :   printw(" retired, an Adept of Omega with %ld points!",FixedPoints);
    1605                 :          0 :   printw("\n\n\n\n\nHit 'c' to continue.");
    1606                 :          0 :   refresh();
    1607         [ #  # ]:          0 :   while (wgetch(stdscr) != 'c')
    1608                 :            :         ;
    1609                 :          0 :   clear();
    1610         [ #  # ]:          0 :   touchwin(stdscr);
    1611                 :          0 :   refresh();
    1612                 :          0 :   extendlog(Str4,BIGWIN);
    1613                 :          0 : }
    1614                 :            : 
    1615                 :            : 
    1616                 :         11 : void mnumprint(int n)
    1617                 :            : {
    1618                 :            :   char numstr[20];
    1619                 :         11 :   sprintf(numstr,"%d",n);
    1620                 :         11 :   bufferappend(numstr);
    1621                 :         11 :   wprintw(Msgw,"%d",n);
    1622                 :         11 :   wrefresh(Msgw);
    1623                 :         11 : }
    1624                 :            : 
    1625                 :          4 : void mlongprint(long n)
    1626                 :            : {
    1627                 :            :   char numstr[20];
    1628                 :          4 :   sprintf(numstr,"%ld",n);
    1629                 :          4 :   bufferappend(numstr);
    1630                 :          4 :   wprintw(Msgw,"%ld",n);
    1631                 :          4 :   wrefresh(Msgw);
    1632                 :          4 : }
    1633                 :            : 
    1634                 :            : 
    1635                 :          0 : void menunumprint(int n)
    1636                 :            : {
    1637                 :            :   int x,y;
    1638 [ #  # ][ #  # ]:          0 :   getyx(Menuw,y,x);
    1639         [ #  # ]:          0 :   if (y >= ScreenLength - 2) {
    1640                 :          0 :     wrefresh(Menuw);
    1641                 :          0 :     morewait();
    1642                 :          0 :     wclear(Menuw);
    1643         [ #  # ]:          0 :     touchwin(Menuw);
    1644                 :            :   }
    1645                 :          0 :   wprintw(Menuw,"%d",n);
    1646                 :          0 : }
    1647                 :            : 
    1648                 :          0 : void menulongprint(long n)
    1649                 :            : {
    1650                 :            :   int x,y;
    1651 [ #  # ][ #  # ]:          0 :   getyx(Menuw,y,x);
    1652         [ #  # ]:          0 :   if (y >= ScreenLength - 2) {
    1653                 :          0 :     wrefresh(Menuw);
    1654                 :          0 :     morewait();
    1655                 :          0 :     wclear(Menuw);
    1656         [ #  # ]:          0 :     touchwin(Menuw);
    1657                 :            :   }
    1658                 :          0 :   wprintw(Menuw,"%ld",n);
    1659                 :          0 : }
    1660                 :            : 
    1661                 :            : 
    1662                 :          1 : void dobackspace(void)
    1663                 :            : {
    1664                 :            :   int x,y;
    1665                 :            : 
    1666 [ +  - ][ +  - ]:          1 :   getyx(Msgw,y,x);
    1667         [ +  - ]:          1 :   if (x > 0) {
    1668                 :          1 :     waddch(Msgw,' ');
    1669                 :          1 :     wmove(Msgw,y,x-1);
    1670                 :          1 :     waddch(Msgw,' ');
    1671                 :          1 :     wmove(Msgw,y,x-1);
    1672                 :            :   }
    1673                 :          1 :   wrefresh(Msgw);
    1674                 :          1 : }
    1675                 :            : 
    1676                 :            : 
    1677                 :        104 : void showflags(void)
    1678                 :            : {
    1679                 :            : 
    1680                 :        104 :   phaseprint();
    1681                 :        104 :   wclear(Flagw);
    1682         [ -  + ]:        104 :   if (Player.food < 0)
    1683                 :          0 :     wprintw(Flagw,"Starving\n");
    1684         [ -  + ]:        104 :   else if (Player.food <= 3)
    1685                 :          0 :     wprintw(Flagw,"Weak\n");
    1686         [ -  + ]:        104 :   else if (Player.food <= 10)
    1687                 :          0 :     wprintw(Flagw,"Ravenous\n");
    1688         [ +  + ]:        104 :   else if (Player.food <= 20)
    1689                 :         24 :     wprintw(Flagw,"Hungry\n");
    1690         [ +  + ]:         80 :   else if (Player.food <= 30)
    1691                 :         45 :     wprintw(Flagw,"A mite peckish\n");
    1692         [ +  + ]:         35 :   else if (Player.food <= 36)
    1693                 :         22 :     wprintw(Flagw,"Content\n");
    1694         [ +  - ]:         13 :   else if (Player.food <= 44)
    1695                 :         13 :     wprintw(Flagw,"Satiated\n");
    1696                 :          0 :   else wprintw(Flagw,"Bloated\n");
    1697                 :            : 
    1698                 :            : 
    1699         [ -  + ]:        104 :   if (Player.status[POISONED]>0)
    1700                 :          0 :     wprintw(Flagw,"Poisoned\n");
    1701                 :        104 :   else wprintw(Flagw,"Vigorous\n");
    1702                 :            : 
    1703         [ -  + ]:        104 :   if (Player.status[DISEASED]>0)
    1704                 :          0 :     wprintw(Flagw,"Diseased\n");
    1705                 :        104 :   else wprintw(Flagw,"Healthy\n");
    1706                 :            : 
    1707         [ +  + ]:        104 :   if (gamestatusp(MOUNTED)) wprintw(Flagw,"Mounted\n");
    1708         [ -  + ]:          1 :   else if (Player.status[LEVITATING]) wprintw(Flagw,"Levitating\n");
    1709                 :          1 :   else wprintw(Flagw,"Afoot\n");
    1710                 :            : 
    1711                 :        104 :   wrefresh(Flagw);
    1712                 :        104 : }
    1713                 :            : 
    1714                 :          0 : void drawomega(void)
    1715                 :            : {
    1716                 :            :   int i;
    1717                 :          0 :   clear();
    1718         [ #  # ]:          0 :   touchwin(stdscr);
    1719         [ #  # ]:          0 :   for(i=0;i<7;i++) {
    1720                 :          0 :     move(1, 1);
    1721         [ #  # ]:          0 :     if (optionp(SHOW_COLOUR))
    1722         [ #  # ]:          0 :       wattrset(stdscr, CHARATTR(CLR(LIGHT_BLUE)));
    1723                 :          0 :     printw("\n\n\n");
    1724                 :          0 :     printw("\n                                    *****");
    1725                 :          0 :     printw("\n                               ******   ******");
    1726                 :          0 :     printw("\n                             ***             ***");
    1727                 :          0 :     printw("\n                           ***                 ***");
    1728                 :          0 :     printw("\n                          **                     **");
    1729                 :          0 :     printw("\n                         ***                     ***");
    1730                 :          0 :     printw("\n                         **                       **");
    1731                 :          0 :     printw("\n                         **                       **");
    1732                 :          0 :     printw("\n                         ***                     ***");
    1733                 :          0 :     printw("\n                          ***                   ***");
    1734                 :          0 :     printw("\n                            **                 **");
    1735                 :          0 :     printw("\n                       *   ***                ***   *");
    1736                 :          0 :     printw("\n                        ****                    ****");
    1737                 :          0 :     refresh();
    1738                 :          0 :     usleep(200000);
    1739                 :          0 :     move(1, 1);
    1740         [ #  # ]:          0 :     if (optionp(SHOW_COLOUR))
    1741         [ #  # ]:          0 :       wattrset(stdscr, CHARATTR(CLR(CYAN)));
    1742                 :          0 :     printw("\n\n\n");
    1743                 :          0 :     printw("\n                                    +++++");
    1744                 :          0 :     printw("\n                               ++++++   ++++++");
    1745                 :          0 :     printw("\n                             +++             +++");
    1746                 :          0 :     printw("\n                           +++                 +++");
    1747                 :          0 :     printw("\n                          ++                     ++");
    1748                 :          0 :     printw("\n                         +++                     +++");
    1749                 :          0 :     printw("\n                         ++                       ++");
    1750                 :          0 :     printw("\n                         ++                       ++");
    1751                 :          0 :     printw("\n                         +++                     +++");
    1752                 :          0 :     printw("\n                          +++                   +++");
    1753                 :          0 :     printw("\n                            ++                 ++");
    1754                 :          0 :     printw("\n                       +   +++                +++   +");
    1755                 :          0 :     printw("\n                        ++++                    ++++");
    1756                 :          0 :     refresh();
    1757                 :          0 :     usleep(200000);
    1758                 :          0 :     move(1, 1);
    1759         [ #  # ]:          0 :     if (optionp(SHOW_COLOUR))
    1760         [ #  # ]:          0 :       wattrset(stdscr, CHARATTR(CLR(BLUE)));
    1761                 :          0 :     printw("\n\n\n");
    1762                 :          0 :     printw("\n                                    .....");
    1763                 :          0 :     printw("\n                               ......   ......");
    1764                 :          0 :     printw("\n                             ...             ...");
    1765                 :          0 :     printw("\n                           ...                 ...");
    1766                 :          0 :     printw("\n                          ..                     ..");
    1767                 :          0 :     printw("\n                         ...                     ...");
    1768                 :          0 :     printw("\n                         ..                       ..");
    1769                 :          0 :     printw("\n                         ..                       ..");
    1770                 :          0 :     printw("\n                         ...                     ...");
    1771                 :          0 :     printw("\n                          ...                   ...");
    1772                 :          0 :     printw("\n                            ..                 ..");
    1773                 :          0 :     printw("\n                       .   ...                ...   .");
    1774                 :          0 :     printw("\n                        ....                    ....");
    1775                 :          0 :     refresh();
    1776                 :          0 :     usleep(200000);
    1777                 :            :   }
    1778         [ #  # ]:          0 :   wattrset(stdscr, CHARATTR(CLR(WHITE)));
    1779                 :          0 : }
    1780                 :            : 
    1781                 :            : /* y is an absolute coordinate */
    1782                 :            : /* ScreenOffset is the upper left hand corner of the current screen
    1783                 :            :    in absolute coordinates */
    1784                 :            : #if 0
    1785                 :            : void screencheck(int y)
    1786                 :            : {
    1787                 :            :   if (((y-ScreenOffset) < (ScreenLength/8)) ||
    1788                 :            :       ((y-ScreenOffset) > (7*ScreenLength/8))) {
    1789                 :            :     ScreenOffset = y - (ScreenLength/2);
    1790                 :            :     show_screen();
    1791                 :            :     if (Current_Environment != E_COUNTRYSIDE) 
    1792                 :            :       drawmonsters(TRUE);
    1793                 :            :     if (!offscreen(Player.x,Player.y))
    1794                 :            :       drawplayer();
    1795                 :            :   }
    1796                 :            : }
    1797                 :            : #else
    1798                 :        605 : void screencheck(int x, int y)
    1799                 :            : {
    1800                 :        605 :   int change = 0;
    1801                 :            : #ifdef CENTER_ON_PLAYER
    1802                 :            : 
    1803                 :            :   change = 1;
    1804                 :            :   ScreenOffset = y - (ScreenLength/2);
    1805                 :            :   ScreenXOffset = x - (ScreenWidth/2);
    1806                 :            : 
    1807                 :            : 
    1808                 :            : #else
    1809                 :            : #if 0
    1810                 :            :   int width = 0;
    1811                 :            : #endif
    1812                 :            : 
    1813 [ +  + ][ +  + ]:        605 :   if (((y-ScreenOffset) < (ScreenLength/8)) ||
    1814                 :        345 :       ((y-ScreenOffset) > (7*ScreenLength/8))) {
    1815                 :        261 :     change = 1;
    1816                 :        261 :     ScreenOffset = y - (ScreenLength/2);
    1817                 :            :   }
    1818                 :            : 
    1819 [ +  + ][ +  + ]:        605 :   if (((x-ScreenXOffset) < (ScreenWidth/8)) ||
    1820                 :        592 :       ((x-ScreenXOffset) > (7*ScreenWidth/8))) {
    1821                 :            : 
    1822                 :            : #if 0
    1823                 :            :     if ( Current_Environment == E_COUNTRYSIDE )
    1824                 :            :       width = COUNTRY_WIDTH;
    1825                 :            :     else
    1826                 :            :       width = Level->level_width;
    1827                 :            : 
    1828                 :            :     /*
    1829                 :            :       PGM: this code prevents scrolling when near the right edge of the level,
    1830                 :            :       but this unfortunately results in a badly placed view when, for examples,
    1831                 :            :       restoring a save near the edge of a level. Ideas on fixing this, or moving
    1832                 :            :       it, appreciated.  PGM July 1999.
    1833                 :            :     */
    1834                 :            :     if ( ( (x-ScreenXOffset) + (7*ScreenWidth/8) ) < width +( ScreenWidth/8 ) )
    1835                 :            : #endif
    1836                 :            :       {
    1837                 :         14 :         change = 1;
    1838                 :         14 :         ScreenXOffset = x - (ScreenWidth/2);
    1839         [ +  + ]:         14 :         if (ScreenXOffset < 0)
    1840                 :         12 :           ScreenXOffset = 0;
    1841                 :            :       }
    1842                 :            :   }
    1843                 :            : 
    1844                 :            : #endif
    1845         [ +  + ]:        605 :   if ( change == 1 ) {
    1846                 :        265 :     show_screen();
    1847         [ +  - ]:        265 :     if (Current_Environment != E_COUNTRYSIDE) 
    1848                 :        265 :       drawmonsters(TRUE);
    1849         [ +  + ]:        265 :     if (!offscreen(Player.x,Player.y))
    1850                 :        259 :       drawplayer();
    1851                 :            :   }
    1852                 :        605 : }
    1853                 :            : #endif
    1854                 :            : 
    1855                 :          0 : void spreadroomlight(int x, int y, int roomno)
    1856                 :            : {
    1857 [ #  # ][ #  # ]:          0 :   if (inbounds(x,y) && !loc_statusp(x,y,LIT) &&
                 [ #  # ]
    1858                 :          0 :       Level->site[x][y].roomnumber == roomno) {
    1859                 :          0 :     lightspot(x,y);
    1860                 :          0 :     spreadroomlight(x+1,y,roomno);
    1861                 :          0 :     spreadroomlight(x,y+1,roomno);
    1862                 :          0 :     spreadroomlight(x-1,y,roomno);
    1863                 :          0 :     spreadroomlight(x,y-1,roomno);
    1864                 :            :   }
    1865                 :          0 : }
    1866                 :            : 
    1867                 :            : /* illuminate one spot at x y */
    1868                 :          0 : void lightspot(int x, int y)
    1869                 :            : { 
    1870                 :            :   Symbol c;
    1871                 :          0 :   lset(x,y,LIT);
    1872                 :          0 :   lset(x,y,SEEN);
    1873                 :          0 :   lset(x, y, CHANGED);
    1874                 :          0 :   c = getspot(x,y,FALSE);
    1875                 :          0 :   Level->site[x][y].showchar = c;
    1876                 :          0 :   putspot(x,y,c);
    1877                 :          0 : }
    1878                 :            : 
    1879                 :            : 
    1880                 :          0 : void spreadroomdark(int x, int y, int roomno)
    1881                 :            : {
    1882         [ #  # ]:          0 :   if (inbounds(x,y))
    1883 [ #  # ][ #  # ]:          0 :     if (loc_statusp(x,y,LIT) && (Level->site[x][y].roomnumber == roomno)) {
    1884                 :          0 :       blankoutspot(x,y);
    1885                 :          0 :       spreadroomdark(x+1,y,roomno);
    1886                 :          0 :       spreadroomdark(x,y+1,roomno);
    1887                 :          0 :       spreadroomdark(x-1,y,roomno);
    1888                 :          0 :       spreadroomdark(x,y-1,roomno);
    1889                 :            :     }
    1890                 :          0 : }
    1891                 :            : 
    1892                 :            : 
    1893                 :          0 : void display_pack(void)
    1894                 :            : {
    1895                 :            :   int i;
    1896         [ #  # ]:          0 :   if (Player.packptr < 1) print3("Pack is empty.");
    1897                 :            :   else {
    1898                 :          0 :     menuclear();
    1899                 :          0 :     menuprint("Items in Pack:\n");
    1900         [ #  # ]:          0 :     for(i=0;i<Player.packptr;i++) {
    1901                 :          0 :       sprintf(Str1, "  %c: %s\n", i + 'A', itemid(Player.pack[i]));
    1902                 :          0 :       menuprint(Str1);
    1903                 :            :     }
    1904                 :          0 :     showmenu();
    1905                 :            :   }
    1906                 :          0 : }
    1907                 :            : 
    1908                 :            : 
    1909                 :         14 : void display_possessions(void)
    1910                 :            : {
    1911                 :            :   int i;
    1912         [ +  + ]:        238 :   for(i=0;i<MAXITEMS;i++) 
    1913                 :        224 :     display_inventory_slot(i,FALSE);
    1914                 :         14 : }
    1915                 :            : 
    1916                 :            : 
    1917                 :        279 : void display_inventory_slot(int slotnum, int topline)
    1918                 :            : {
    1919                 :            :   WINDOW *W;
    1920                 :        279 :   char usechar = ')', idchar = '-';
    1921         [ +  + ]:        279 :   if (Player.possessions[slotnum] != NULL)
    1922         [ +  + ]:        147 :     if (Player.possessions[slotnum]->used)
    1923                 :         36 :       usechar = '>';
    1924         [ -  + ]:        279 :   if (topline) W = Msg3w;
    1925                 :            :   else {
    1926                 :        279 :     W = Showline[slotnum];
    1927                 :        279 :     hide_line(slotnum);
    1928                 :            :   }
    1929                 :        279 :   idchar = index_to_key(slotnum);
    1930         [ +  - ]:        279 :   touchwin(W);
    1931                 :        279 :   wclear(W);
    1932   [ +  +  +  +  :        279 :   switch(slotnum) {
          +  +  +  +  +  
          +  +  +  +  +  
                +  +  - ]
    1933                 :            :   case O_UP_IN_AIR:
    1934                 :         36 :     wprintw(W,"-- Object 'up in air':",usechar);
    1935                 :         36 :     break;
    1936                 :            :   case O_READY_HAND:
    1937                 :         18 :     wprintw(W,"-- %c%c ready hand: ",idchar,usechar);
    1938                 :         18 :     break;
    1939                 :            :   case O_WEAPON_HAND:
    1940                 :         18 :     wprintw(W,"-- %c%c weapon hand: ",idchar,usechar);
    1941                 :         18 :     break;
    1942                 :            :   case O_LEFT_SHOULDER:
    1943                 :         18 :     wprintw(W,"-- %c%c left shoulder: ",idchar,usechar);
    1944                 :         18 :     break;
    1945                 :            :   case O_RIGHT_SHOULDER:
    1946                 :         17 :     wprintw(W,"-- %c%c right shoulder: ",idchar,usechar);
    1947                 :         17 :     break;
    1948                 :            :   case O_BELT1:
    1949                 :         18 :     wprintw(W,"-- %c%c belt: ",idchar,usechar);
    1950                 :         18 :     break;
    1951                 :            :   case O_BELT2:
    1952                 :         19 :     wprintw(W,"-- %c%c belt: ",idchar,usechar);
    1953                 :         19 :     break;
    1954                 :            :   case O_BELT3:
    1955                 :         19 :     wprintw(W,"-- %c%c belt: ",idchar,usechar);
    1956                 :         19 :     break;
    1957                 :            :   case O_SHIELD:
    1958                 :         14 :     wprintw(W,"-- %c%c shield: ",idchar,usechar);
    1959                 :         14 :     break;
    1960                 :            :   case O_ARMOR:
    1961                 :         18 :     wprintw(W,"-- %c%c armor: ",idchar,usechar);
    1962                 :         18 :     break;
    1963                 :            :   case O_BOOTS:
    1964                 :         14 :     wprintw(W,"-- %c%c boots: ",idchar,usechar);
    1965                 :         14 :     break;
    1966                 :            :   case O_CLOAK:
    1967                 :         14 :     wprintw(W,"-- %c%c cloak: ",idchar,usechar);
    1968                 :         14 :     break;
    1969                 :            :   case O_RING1:
    1970                 :         14 :     wprintw(W,"-- %c%c finger: ",idchar,usechar);
    1971                 :         14 :     break;
    1972                 :            :   case O_RING2:
    1973                 :         14 :     wprintw(W,"-- %c%c finger: ",idchar,usechar);
    1974                 :         14 :     break;
    1975                 :            :   case O_RING3:
    1976                 :         14 :     wprintw(W,"-- %c%c finger: ",idchar,usechar);
    1977                 :         14 :     break;
    1978                 :            :   case O_RING4:
    1979                 :         14 :     wprintw(W,"-- %c%c finger: ",idchar,usechar);
    1980                 :         14 :     break;
    1981                 :            :   }
    1982         [ +  + ]:        279 :   if (Player.possessions[slotnum]== NULL)
    1983                 :        132 :     wprintw(W,"(slot vacant)");
    1984                 :        147 :   else wprintw(W,itemid(Player.possessions[slotnum]));
    1985                 :        279 :   wrefresh(W);
    1986                 :        279 : }
    1987                 :            : 
    1988                 :         14 : int move_slot(int oldslot, int newslot, int maxslot)
    1989                 :            : {
    1990 [ +  - ][ +  - ]:         14 :   if ((newslot >= 0) && (newslot < maxslot)){
    1991                 :         14 :     wmove(Showline[oldslot],0,0);
    1992                 :         14 :     waddstr(Showline[oldslot],"--");
    1993                 :         14 :     wrefresh(Showline[oldslot]);
    1994                 :         14 :     wmove(Showline[newslot],0,0);
    1995         [ +  - ]:         14 :     wstandout(Showline[newslot]);
    1996                 :         14 :     waddstr(Showline[newslot],">>");
    1997         [ +  - ]:         14 :     wstandend(Showline[newslot]);
    1998                 :         14 :     wrefresh(Showline[newslot]);
    1999                 :         14 :     return(newslot);
    2000                 :            :   }
    2001                 :          0 :   else return(oldslot);
    2002                 :            : }
    2003                 :            : 
    2004                 :          2 : void colour_on(void)
    2005                 :            : {
    2006                 :          2 : }
    2007                 :            : 
    2008                 :          0 : void colour_off(void)
    2009                 :            : {
    2010         [ #  # ]:          0 :   wattrset(Levelw, CHARATTR(CLR(WHITE)));
    2011                 :          0 : }
    2012                 :            : 
    2013                 :         13 : void display_option_slot(int slot)
    2014                 :            : {
    2015                 :         13 :   hide_line(slot);
    2016                 :         13 :   wclear(Showline[slot]);
    2017   [ +  +  +  +  :         13 :   switch(slot) {
          +  +  +  +  +  
                +  +  - ]
    2018                 :            :   case 1:
    2019                 :          3 :     wprintw(Showline[slot],"-- Option BELLICOSE [TF]: ");
    2020         [ -  + ]:          3 :     wprintw(Showline[slot], optionp(BELLICOSE) ? "(now T) " : "(now F) ");
    2021                 :          3 :     break;
    2022                 :            :   case 2:
    2023                 :          1 :     wprintw(Showline[slot],"-- Option JUMPMOVE [TF]: ");
    2024         [ -  + ]:          1 :     wprintw(Showline[slot], optionp(JUMPMOVE) ? "(now T) " : "(now F) ");
    2025                 :          1 :     break;
    2026                 :            :   case 3:
    2027                 :          1 :     wprintw(Showline[slot],"-- Option RUNSTOP [TF]: ");
    2028         [ +  - ]:          1 :     wprintw(Showline[slot], optionp(RUNSTOP) ? "(now T) " : "(now F) ");
    2029                 :          1 :     break;
    2030                 :            :   case 4:
    2031                 :          1 :     wprintw(Showline[slot],"-- Option PICKUP [TF]: ");
    2032         [ -  + ]:          1 :     wprintw(Showline[slot], optionp(PICKUP) ? "(now T) " : "(now F) ");
    2033                 :          1 :     break;
    2034                 :            :   case 5:
    2035                 :          1 :     wprintw(Showline[slot],"-- Option CONFIRM [TF]: ");
    2036         [ +  - ]:          1 :     wprintw(Showline[slot], optionp(CONFIRM) ? "(now T) " : "(now F) ");
    2037                 :          1 :     break;
    2038                 :            :   case 6:
    2039                 :          1 :     wprintw(Showline[slot],"-- Option TOPINV [TF]: ");
    2040         [ -  + ]:          1 :     wprintw(Showline[slot], optionp(TOPINV) ? "(now T) " : "(now F) ");
    2041                 :          1 :     break;
    2042                 :            :   case 7:
    2043                 :          1 :     wprintw(Showline[slot],"-- Option PACKADD [TF]: ");
    2044         [ -  + ]:          1 :     wprintw(Showline[slot], optionp(PACKADD) ? "(now T) " : "(now F) ");
    2045                 :          1 :     break;
    2046                 :            :   case 8:
    2047                 :            : #ifdef COMPRESS_SAVE_FILES
    2048                 :            :     wprintw(Showline[slot],"-- Option COMPRESS [TF]: ");
    2049                 :            :     wprintw(Showline[slot], optionp(COMPRESS_OPTION) ? "(now T) " : "(now F) ");
    2050                 :            : #endif
    2051                 :          1 :     break;
    2052                 :            :   case 9:
    2053                 :          1 :     wprintw(Showline[slot],"-- Option COLOUR [TF]: ");
    2054         [ +  - ]:          1 :     wprintw(Showline[slot], optionp(SHOW_COLOUR) ? "(now T) " : "(now F) ");
    2055                 :          1 :     break;
    2056                 :            :   case VERBOSITY_LEVEL:
    2057                 :          1 :     wprintw(Showline[slot],
    2058                 :            :             "-- Option VERBOSITY [(T)erse,(M)edium,(V)erbose]: (now ");
    2059         [ +  - ]:          1 :     if (Verbosity == VERBOSE) wprintw(Showline[slot],"Verbose)");
    2060         [ #  # ]:          0 :     else if (Verbosity == MEDIUM) wprintw(Showline[slot],"Medium)");
    2061                 :          0 :     else wprintw(Showline[slot],"Terse)");
    2062                 :          1 :     break;
    2063                 :            :   case SEARCH_DURATION:
    2064                 :          1 :     wprintw(Showline[slot],"-- Option SEARCHNUM [0>x>10]: (now %d)",Searchnum);
    2065                 :          1 :     break;
    2066                 :            :   }
    2067                 :         13 :   wrefresh(Showline[slot]);
    2068                 :         13 : }
    2069                 :            : 
    2070                 :          0 : void display_stat_slot(int slot)
    2071                 :            : {
    2072                 :          0 :   hide_line(slot);
    2073                 :          0 :   wclear(Showline[slot]);
    2074   [ #  #  #  #  :          0 :   switch(slot) {
          #  #  #  #  #  
                #  #  # ]
    2075                 :            :   case 1:
    2076                 :          0 :     wprintw(Showline[slot],"-- Strength ... [%d]: ", Player.str);
    2077                 :          0 :     break;
    2078                 :            :   case 2:
    2079                 :          0 :     wprintw(Showline[slot],"-- Constitution [%d]: ", Player.con);
    2080                 :          0 :     break;
    2081                 :            :   case 3:
    2082                 :          0 :     wprintw(Showline[slot],"-- Dexterity .. [%d]: ", Player.dex);
    2083                 :          0 :     break;
    2084                 :            :   case 4:
    2085                 :          0 :     wprintw(Showline[slot],"-- Agility .... [%d]: ", Player.agi);
    2086                 :          0 :     break;
    2087                 :            :   case 5:
    2088                 :          0 :     wprintw(Showline[slot],"-- Intelligence [%d]: ", Player.iq);
    2089                 :          0 :     break;
    2090                 :            :   case 6:
    2091                 :          0 :     wprintw(Showline[slot],"-- Power ...... [%d]: ", Player.pow);
    2092                 :          0 :     break;
    2093                 :            :   case 7:
    2094                 :          0 :     wprintw(Showline[slot],"-- HP ......... [%d]: ", Player.hp);
    2095                 :          0 :     break;
    2096                 :            :   case 8:
    2097                 :          0 :     wprintw(Showline[slot],"-- Max HP ..... [%d]: ", Player.maxhp);
    2098                 :          0 :     break;
    2099                 :            :   case 9:
    2100                 :          0 :     wprintw(Showline[slot],"-- Mana ....... [%d]: ", Player.mana);
    2101                 :          0 :     break;
    2102                 :            :   case 10:
    2103                 :          0 :     wprintw(Showline[slot],"-- Max Mana ... [%d]: ", Player.maxmana);
    2104                 :          0 :     break;
    2105                 :            :   case 11:
    2106                 :          0 :     wprintw(Showline[slot],"-- Cash ....... [%d]: ", Player.cash);
    2107                 :          0 :     break;
    2108                 :            :   }
    2109                 :          0 :   wrefresh(Showline[slot]);
    2110                 :          0 : }
    2111                 :            : 
    2112                 :          1 : void display_options(void)
    2113                 :            : {
    2114                 :            :   int i;
    2115                 :          1 :   menuclear();
    2116                 :          1 :   hide_line(0);
    2117         [ +  + ]:         12 :   for(i=1;i<=NUMOPTIONS;i++)
    2118                 :         11 :     display_option_slot(i);
    2119                 :          1 : }
    2120                 :            : 
    2121                 :          0 : void display_stats(void)
    2122                 :            : {
    2123                 :            :   int i;
    2124                 :          0 :   menuclear();
    2125                 :          0 :   hide_line(0);
    2126         [ #  # ]:          0 :   for(i=1;i<=NUMSTATS;i++)
    2127                 :          0 :     display_stat_slot(i);
    2128                 :          0 : }
    2129                 :            : 
    2130                 :            : /* nya ha ha ha ha haaaa.... */
    2131                 :          0 : void deathprint(void)
    2132                 :            : {
    2133                 :          0 :   mgetc();
    2134                 :          0 :   waddch(Msgw,'D');
    2135                 :          0 :   wrefresh(Msgw);
    2136                 :          0 :   mgetc();
    2137                 :          0 :   waddch(Msgw,'e');
    2138                 :          0 :   wrefresh(Msgw);
    2139                 :          0 :   mgetc();
    2140                 :          0 :   waddch(Msgw,'a');
    2141                 :          0 :   wrefresh(Msgw);
    2142                 :          0 :   mgetc();
    2143                 :          0 :   waddch(Msgw,'t');
    2144                 :          0 :   wrefresh(Msgw);
    2145                 :          0 :   mgetc();
    2146                 :          0 :   waddch(Msgw,'h');
    2147                 :          0 :   wrefresh(Msgw);
    2148                 :          0 :   mgetc();
    2149                 :          0 : }
    2150                 :            :   
    2151                 :        436 : void clear_if_necessary(void)
    2152                 :            : {
    2153                 :            :   int x,y;
    2154 [ +  - ][ +  - ]:        436 :   getyx(Msg1w,y,x);
    2155                 :            : 
    2156         [ +  + ]:        436 :   if (x != 0) {
    2157                 :         53 :     wclear(Msg1w);
    2158                 :         53 :     wrefresh(Msg1w);
    2159                 :            :   }  
    2160                 :            : 
    2161 [ +  - ][ +  - ]:        436 :   getyx(Msg2w,y,x);
    2162                 :            : 
    2163         [ +  + ]:        436 :   if (x != 0) {
    2164                 :         23 :     wclear(Msg2w);
    2165                 :         23 :     wrefresh(Msg2w);
    2166                 :            :   }  
    2167                 :            : 
    2168 [ +  - ][ +  - ]:        436 :   getyx(Msg3w,y,x);
    2169                 :            : 
    2170         [ +  + ]:        436 :   if (x != 0) {
    2171                 :         21 :     erasemsg3();
    2172                 :         21 :     wrefresh(Msg3w);
    2173                 :            :   }
    2174                 :            : 
    2175                 :        436 : }
    2176                 :            : 
    2177                 :            : int bufferpos = 0;
    2178                 :            : 
    2179                 :        170 : void buffercycle(char *s)
    2180                 :            : {
    2181                 :        170 :   strcpy(Stringbuffer[bufferpos++],s);
    2182         [ +  + ]:        170 :   if (bufferpos >= STRING_BUFFER_SIZE)
    2183                 :          6 :     bufferpos = 0;
    2184                 :        170 : }
    2185                 :            : 
    2186                 :         83 : int bufferappend(char *s)
    2187                 :            : {
    2188                 :         83 :   int pos = bufferpos - 1;
    2189                 :            : 
    2190         [ +  + ]:         83 :   if (pos < 0)
    2191                 :          1 :     pos = STRING_BUFFER_SIZE - 1;
    2192         [ +  - ]:         83 :   if (strlen(Stringbuffer[pos]) + strlen(s) < 80 - 1) {
    2193                 :         83 :     strcat(Stringbuffer[pos],s);
    2194                 :         83 :     return 1;
    2195                 :            :   }
    2196                 :            :   else
    2197                 :          0 :     return 0;
    2198                 :            : }
    2199                 :            : 
    2200                 :            : 
    2201                 :          0 : void bufferprint(void)
    2202                 :            : {
    2203                 :          0 :   int i = bufferpos - 1, c, finished = 0;
    2204                 :          0 :   clearmsg();
    2205                 :            : #ifndef MSDOS_SUPPORTED_ANTIQUE
    2206                 :          0 :   wprintw(Msg1w,"^p for previous message, ^n for next, anything else to quit.");
    2207                 :            : #else
    2208                 :            :   wprintw(Msg1w,"^o for last message, ^n for next, anything else to quit.");
    2209                 :            : #endif
    2210                 :          0 :   wrefresh(Msg1w);
    2211                 :            :   do {
    2212         [ #  # ]:          0 :     if (i >= STRING_BUFFER_SIZE) i = 0;
    2213         [ #  # ]:          0 :     if (i < 0) i = STRING_BUFFER_SIZE - 1;
    2214                 :          0 :     wclear(Msg2w);
    2215                 :          0 :     wprintw(Msg2w,Stringbuffer[i]);
    2216                 :          0 :     wrefresh(Msg2w);
    2217                 :          0 :     c = mgetc();
    2218                 :            : #ifndef MSDOS_SUPPORTED_ANTIQUE
    2219         [ #  # ]:          0 :     if (c == 16)        /* ^p */
    2220                 :            : #else
    2221                 :            :     if (c == 15)        /* ^o */
    2222                 :            : #endif
    2223                 :          0 :       i--;
    2224         [ #  # ]:          0 :     else if (c == 14)   /* ^n */
    2225                 :          0 :       i++;
    2226                 :            :     else
    2227                 :          0 :       finished = 1;
    2228         [ #  # ]:          0 :   } while (!finished);
    2229                 :          0 :   clearmsg();
    2230                 :          0 :   omshowcursor(Player.x,Player.y);
    2231                 :          0 : }
    2232                 :            : 
    2233                 :          1 : void clear_screen(void)
    2234                 :            : {
    2235                 :          1 :   clear();
    2236         [ +  - ]:          1 :   touchwin(stdscr);
    2237                 :          1 :   refresh();
    2238                 :          1 : }

Generated by: LCOV version 1.11