Mercurial > hg > early-roguelike
comparison srogue/io.c @ 217:94a0d9dd5ce1
Super-Rogue: convert to ANSI-style function declarations.
This fixes most of the build warnings.
author | John "Elwin" Edwards |
---|---|
date | Sun, 31 Jan 2016 13:45:07 -0500 |
parents | 458df24e973d |
children | 70aa5808c782 |
comparison
equal
deleted
inserted
replaced
216:b24545357d2e | 217:94a0d9dd5ce1 |
---|---|
18 #include <ctype.h> | 18 #include <ctype.h> |
19 #include <string.h> | 19 #include <string.h> |
20 #include "rogue.h" | 20 #include "rogue.h" |
21 #include "rogue.ext" | 21 #include "rogue.ext" |
22 | 22 |
23 int md_readchar(WINDOW *win); | 23 void doadd(char *fmt, va_list ap); |
24 | 24 |
25 /* | 25 /* |
26 * msg: | 26 * msg: |
27 * Display a message at the top of the screen. | 27 * Display a message at the top of the screen. |
28 */ | 28 */ |
29 static char msgbuf[BUFSIZ]; | 29 static char msgbuf[BUFSIZ]; |
30 static int newpos = 0; | 30 static int newpos = 0; |
31 | 31 |
32 void | |
32 msg(char *fmt, ...) | 33 msg(char *fmt, ...) |
33 { | 34 { |
34 va_list ap; | 35 va_list ap; |
35 /* | 36 /* |
36 * if the string is "", just clear the line | 37 * if the string is "", just clear the line |
52 | 53 |
53 /* | 54 /* |
54 * addmsg: | 55 * addmsg: |
55 * Add things to the current message | 56 * Add things to the current message |
56 */ | 57 */ |
58 void | |
57 addmsg(char *fmt, ...) | 59 addmsg(char *fmt, ...) |
58 { | 60 { |
59 va_list ap; | 61 va_list ap; |
60 | 62 |
61 va_start(ap, fmt); | 63 va_start(ap, fmt); |
66 /* | 68 /* |
67 * endmsg: | 69 * endmsg: |
68 * Display a new msg, giving him a chance to see the | 70 * Display a new msg, giving him a chance to see the |
69 * previous one if it is up there with the --More-- | 71 * previous one if it is up there with the --More-- |
70 */ | 72 */ |
71 endmsg() | 73 void |
74 endmsg(void) | |
72 { | 75 { |
73 strcpy(huh, msgbuf); | 76 strcpy(huh, msgbuf); |
74 if (mpos > 0) { | 77 if (mpos > 0) { |
75 wmove(cw, 0, mpos); | 78 wmove(cw, 0, mpos); |
76 waddstr(cw, morestr); | 79 waddstr(cw, morestr); |
86 | 89 |
87 /* | 90 /* |
88 * doadd: | 91 * doadd: |
89 * Perform a printf into a buffer | 92 * Perform a printf into a buffer |
90 */ | 93 */ |
94 void | |
91 doadd(char *fmt, va_list ap) | 95 doadd(char *fmt, va_list ap) |
92 { | 96 { |
93 vsprintf(&msgbuf[newpos], fmt, ap); | 97 vsprintf(&msgbuf[newpos], fmt, ap); |
94 newpos = strlen(msgbuf); | 98 newpos = strlen(msgbuf); |
95 } | 99 } |
96 | 100 |
97 /* | 101 /* |
98 * step_ok: | 102 * step_ok: |
99 * Returns TRUE if it is ok to step on ch | 103 * Returns TRUE if it is ok to step on ch |
100 */ | 104 */ |
101 step_ok(ch) | 105 bool |
102 unsigned char ch; | 106 step_ok(unsigned char ch) |
103 { | 107 { |
104 if (dead_end(ch)) | 108 if (dead_end(ch)) |
105 return FALSE; | 109 return FALSE; |
106 else if (ch >= 32 && ch <= 127 && !isalpha(ch)) | 110 else if (ch >= 32 && ch <= 127 && !isalpha(ch)) |
107 return TRUE; | 111 return TRUE; |
111 | 115 |
112 /* | 116 /* |
113 * dead_end: | 117 * dead_end: |
114 * Returns TRUE if you cant walk through that character | 118 * Returns TRUE if you cant walk through that character |
115 */ | 119 */ |
116 dead_end(ch) | 120 bool |
117 char ch; | 121 dead_end(char ch) |
118 { | 122 { |
119 if (ch == '-' || ch == '|' || ch == ' ' || ch == SECRETDOOR) | 123 if (ch == '-' || ch == '|' || ch == ' ' || ch == SECRETDOOR) |
120 return TRUE; | 124 return TRUE; |
121 else | 125 else |
122 return FALSE; | 126 return FALSE; |
127 * readchar: | 131 * readchar: |
128 * flushes stdout so that screen is up to date and then returns | 132 * flushes stdout so that screen is up to date and then returns |
129 * getchar. | 133 * getchar. |
130 */ | 134 */ |
131 | 135 |
132 readchar() | 136 int |
137 readchar(void) | |
133 { | 138 { |
134 char c; | 139 char c; |
135 | 140 |
136 fflush(stdout); | 141 fflush(stdout); |
137 return( md_readchar(cw) ); | 142 return( md_readchar(cw) ); |
146 | 151 |
147 /* | 152 /* |
148 * status: | 153 * status: |
149 * Display the important stats line. Keep the cursor where it was. | 154 * Display the important stats line. Keep the cursor where it was. |
150 */ | 155 */ |
151 status(fromfuse) | 156 void |
152 int fromfuse; | 157 status(int fromfuse) |
153 { | 158 { |
154 reg int totwght, carwght; | 159 reg int totwght, carwght; |
155 reg struct real *stef, *stre, *stmx; | 160 reg struct real *stef, *stre, *stmx; |
156 reg char *pb; | 161 reg char *pb; |
157 int oy, ox, ch; | 162 int oy, ox, ch; |
218 | 223 |
219 /* | 224 /* |
220 * dispmax: | 225 * dispmax: |
221 * Display the hero's maximum status | 226 * Display the hero's maximum status |
222 */ | 227 */ |
223 dispmax() | 228 void |
229 dispmax(void) | |
224 { | 230 { |
225 reg struct real *hmax; | 231 reg struct real *hmax; |
226 | 232 |
227 hmax = &max_stats.s_re; | 233 hmax = &max_stats.s_re; |
228 msg("Maximums: Str = %d Dex = %d Wis = %d Con = %d", | 234 msg("Maximums: Str = %d Dex = %d Wis = %d Con = %d", |
231 | 237 |
232 /* | 238 /* |
233 * illeg_ch: | 239 * illeg_ch: |
234 * Returns TRUE if a char shouldn't show on the screen | 240 * Returns TRUE if a char shouldn't show on the screen |
235 */ | 241 */ |
236 illeg_ch(ch) | 242 bool |
237 unsigned char ch; | 243 illeg_ch(unsigned char ch) |
238 { | 244 { |
239 if (ch < 32 || ch > 127) | 245 if (ch < 32 || ch > 127) |
240 return TRUE; | 246 return TRUE; |
241 if (ch >= '0' && ch <= '9') | 247 if (ch >= '0' && ch <= '9') |
242 return TRUE; | 248 return TRUE; |
245 | 251 |
246 /* | 252 /* |
247 * wait_for: | 253 * wait_for: |
248 * Sit around until the guy types the right key | 254 * Sit around until the guy types the right key |
249 */ | 255 */ |
250 wait_for(win,ch) | 256 void |
251 WINDOW *win; | 257 wait_for(WINDOW *win, char ch) |
252 char ch; | |
253 { | 258 { |
254 register char c; | 259 register char c; |
255 | 260 |
256 if (ch == '\n') | 261 if (ch == '\n') |
257 while ((c = wgetch(win)) != '\n' && c != '\r') | 262 while ((c = wgetch(win)) != '\n' && c != '\r') |
291 | 296 |
292 /* | 297 /* |
293 * dbotline: | 298 * dbotline: |
294 * Displays message on bottom line and waits for a space to return | 299 * Displays message on bottom line and waits for a space to return |
295 */ | 300 */ |
296 dbotline(scr,message) | 301 void |
297 WINDOW *scr; | 302 dbotline(WINDOW *scr, char *message) |
298 char *message; | |
299 { | 303 { |
300 mvwaddstr(scr,LINES-1,0,message); | 304 mvwaddstr(scr,LINES-1,0,message); |
301 draw(scr); | 305 draw(scr); |
302 wait_for(scr,' '); | 306 wait_for(scr,' '); |
303 } | 307 } |
305 | 309 |
306 /* | 310 /* |
307 * restscr: | 311 * restscr: |
308 * Restores the screen to the terminal | 312 * Restores the screen to the terminal |
309 */ | 313 */ |
310 restscr(scr) | 314 void |
311 WINDOW *scr; | 315 restscr(WINDOW *scr) |
312 { | 316 { |
313 clearok(scr,TRUE); | 317 clearok(scr,TRUE); |
314 touchwin(scr); | 318 touchwin(scr); |
315 } | 319 } |
316 | 320 |
317 /* | 321 /* |
318 * npch: | 322 * npch: |
319 * Get the next char in line for inventories | 323 * Get the next char in line for inventories |
320 */ | 324 */ |
321 npch(ch) | 325 char |
322 char ch; | 326 npch(char ch) |
323 { | 327 { |
324 reg char nch; | 328 reg char nch; |
325 if (ch >= 'z') | 329 if (ch >= 'z') |
326 nch = 'A'; | 330 nch = 'A'; |
327 else | 331 else |