1 /* File display.c */
2 /***************************************************************************
3 *  Copyright 2003 -   Steven Shipway <steve@cheshire.demon.co.uk>          *
4 *                     Put "nospam" in subject to avoid spam filter         *
5 *                                                                          *
6 *  This program is free software; you can redistribute it and/or modify    *
7 *  it under the terms of the GNU General Public License as published by    *
8 *  the Free Software Foundation; either version 2 of the License, or       *
9 *  (at your option) any later version.                                     *
10 *                                                                          *
11 *  This program is distributed in the hope that it will be useful,         *
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of          *
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
14 *  GNU General Public License for more details.                            *
15 *                                                                          *
16 *  You should have received a copy of the GNU General Public License       *
17 *  along with this program; if not, write to the Free Software             *
18 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA               *
19 *  02111-1307, USA.                                                        *
20 ***************************************************************************/
21 
22 
23 #include "wand_head.h"
24 
25 /***********************************
26 *        extern variables          *
27 ************************************/
28 extern int debug_disp;
29 extern int edit_mode;
30 extern char screen_name[61];
31 extern char *edit_memory, *memory_end;
32 
33 
34 /****************************************
35 *         function declarations         *
36 *****************************************/
37 void map(char (*row_ptr)[ROWLEN+1]);
38 void display(int cx, int cy, char (*row_ptr)[ROWLEN+1], long score);
39 int inform_me(char *s, int qable);
40 
41 
42 /******************************************
43 *                   map                   *
44 *******************************************/
map(char (* row_ptr)[ROWLEN+1])45 void map(char (*row_ptr)[ROWLEN+1])
46 {
47     int  x,y;
48     char ch;
49 
50     move(0,0);
51     addch('+');
52     for(x = 0;x < ROWLEN; x++)
53         addch('-');
54     addch('+');
55     for(y = 0;y < NOOFROWS; y++)
56     {
57         move(y+1,0);
58         addch('|');
59         for(x = 0; x < ROWLEN; x++)
60         {
61             ch = (*row_ptr)[x];
62             if(!debug_disp)
63             {
64                 if((ch == 'M')||(ch == 'S'))
65                     ch = ' ';
66                 addch(ch);
67             }
68             else
69                 if(ch!='\0')
70                     addch(ch);
71                 else
72                     addch('"');
73         }
74         addch('|');
75         row_ptr++;
76     }
77     move(y+1,0);
78     addch('+');
79     for(x = 0;x < ROWLEN; x++)
80         addch('-');
81     addch('+');
82     if(!debug_disp)
83     {
84         move(18,0);
85         addstr("Press any key to return to the game.");
86         refresh();
87         getchar();
88         move(18,0);
89         addstr("                                    ");
90         refresh();
91         for(y=0;y<=(NOOFROWS+1);y++)
92         {
93             move(y,0);
94             for(x=0;x<=(ROWLEN+2);x++)
95                 addch(' ');
96         }
97     }
98     else
99         refresh();
100 }
101 
102 /**/
103 /***********************************************
104 *                   display                    *
105 ************************************************/
display(int cx,int cy,char (* row_ptr)[ROWLEN+1],long score)106 void display(int cx, int cy, char (*row_ptr)[ROWLEN+1], long score)
107 {
108     int  x,y = 0, x_coord,y_coord;
109     char ch;
110     while(y<(cy-3))
111     {
112         y++;
113         row_ptr++;
114     };
115     move(0,0);
116     addstr("+---------------------------------+");
117     move(15,0);
118     addstr("+---------------------------------+");
119     for(y=(cy-3);y<=(cy+3);y++)
120     {
121         y_coord = (y+3-cy)*2;
122         if ((y<0) || (y>=NOOFROWS))
123         {
124             move(y_coord+1,0);
125             addstr("|#################################|");
126             move(y_coord+2,0);
127             addstr("|#################################|");
128         }
129         else
130         {
131             move(y_coord+1,0);
132             addch('|');
133             move(y_coord+1,34);
134             addch('|');
135             move(y_coord+2,0);
136             addch('|');
137             move(y_coord+2,34);
138             addch('|');
139             for(x=(cx-5);x<=(cx+5);x++)
140             {
141                 x_coord = (x+5-cx)*3;
142                 if ((x<0) || (x>ROWLEN-1))
143                     draw_symbol(x_coord,y_coord,'#');
144                 else
145                 {
146                     ch = (*row_ptr)[x];
147                     draw_symbol(x_coord,y_coord,ch);
148                 }
149             };
150             row_ptr++;
151         }                   /*   end if   */
152     }                       /* end y loop */
153     move(16,0);
154     refresh();
155 }
156 
157 /*************************************************************
158 *                         showname                           *
159 **************************************************************/
showname()160 void showname()
161 {
162     move(19,0);
163     if(( screen_name[0] == '#' )||(screen_name[0] == '\0'))
164     {
165         addstr("Unnamed screen.                         ");
166     }
167     else
168         addstr(screen_name);
169     if( edit_memory )
170     {
171         move(7,45);
172         addstr("MEMORY: ( Start, ) End,");
173         move(8,53);
174         addstr("* Play, & Extend.");
175         move(9,53);
176         addstr("- Chkpt, + Cont.");
177         move(10,53);
178         if( memory_end == edit_memory )
179         {
180             addstr("--Empty--");
181         }
182         else
183         {
184             addstr("-Occupied-");
185         }
186     }
187 }
188 
189 /**/
190 /******************************************************************
191 *                           redraw_screen                         *
192 *******************************************************************/
redraw_screen(bell,maxmoves,num,score,nf,diamonds,mx,sx,sy,frow)193 void redraw_screen(bell,maxmoves,num,score,nf,diamonds,mx,sx,sy,frow)
194     int *bell,maxmoves,num,nf,diamonds,mx,sx,sy;
195     long score;
196     char (*frow)[ROWLEN+1];
197 {
198     char buffer[50];
199 
200     clear();
201     move(0,48);
202     (void) addstr("Score\t   Diamonds");
203     move(1,48);
204     (void) addstr("\tFound\tTotal");
205     move(3,48);
206     (void) sprintf(buffer,"%d\t %d\t %d  ",score,nf,diamonds);
207     (void) addstr(buffer);
208     if(! edit_mode) {
209         move(6,48);
210         (void) sprintf(buffer,"Current screen %d",num);
211         (void) addstr(buffer);
212     }
213     if(maxmoves != -1)
214         (void) sprintf(buffer,"Moves remaining = %d   ",maxmoves);
215     else
216         (void) strcpy(buffer,"     Unlimited moves     ");
217     move(15,48);
218     (void) addstr(buffer);
219     move(17,56);
220     if( *bell ) addstr("Bell ON ");
221     else addstr("Bell OFF");
222     if(mx != -1)  {                         /* tell player if monster exists */
223         draw_symbol(50,11,'M');
224         move(12,56); addstr("Monster on the");
225         move(13,56); addstr("loose!        ");
226     } else {
227         draw_symbol(50,11,' ');
228         move(12,56); addstr("              ");
229         move(13,56); addstr("              ");
230     }
231 
232     showname();
233 
234     if(!debug_disp)
235         display(sx,sy,frow,score);
236     else
237         map(frow);
238 }
239 
240 /*************************************************
241 *                   inform_me                    *
242 **************************************************/
inform_me(char * s,int qable)243 int inform_me(char *s, int qable)
244 {
245     int retval = 0;
246     move(20,0);
247 #ifdef TVI
248     addstr(TVI);
249 #endif
250     standout();
251     addstr(s);
252 #ifdef NOTVI
253     addstr(NOTVI);
254 #endif
255     standend();
256     addstr(" <MORE>");
257     if(qable)
258         addstr(" (q stops)");
259     refresh();
260     if( getch() == 'q' )
261         retval = 1;
262     move(20,0); addstr("                                                                             ");
263     refresh();
264     return(retval);
265 }
266