comparison xrogue/io.c @ 220:f54901b9c39b

XRogue: convert to ANSI-style function declarations.
author John "Elwin" Edwards
date Wed, 02 Mar 2016 21:13:26 -0500
parents ce0cf824c192
children e52a8a7ad4c5
comparison
equal deleted inserted replaced
219:f9ef86cf22b2 220:f54901b9c39b
19 #include <curses.h> 19 #include <curses.h>
20 #include <ctype.h> 20 #include <ctype.h>
21 #include <stdarg.h> 21 #include <stdarg.h>
22 #include <string.h> 22 #include <string.h>
23 #include "rogue.h" 23 #include "rogue.h"
24
25 void doadd(char *fmt, va_list ap);
24 26
25 /* 27 /*
26 * msg: 28 * msg:
27 * Display a message at the top of the screen. 29 * Display a message at the top of the screen.
28 */ 30 */
75 /* 77 /*
76 * If there is no current message, do nothing. Otherwise, prompt the 78 * If there is no current message, do nothing. Otherwise, prompt the
77 * player with the --More-- string. Then erase the message. 79 * player with the --More-- string. Then erase the message.
78 */ 80 */
79 81
80 rmmsg() 82 void
83 rmmsg(void)
81 { 84 {
82 if (mpos) { 85 if (mpos) {
83 wclear(msgw); 86 wclear(msgw);
84 overwrite(cw, msgw); 87 overwrite(cw, msgw);
85 mvwaddstr(msgw, 0, 0, huh); 88 mvwaddstr(msgw, 0, 0, huh);
94 /* 97 /*
95 * Display a new msg (giving him a chance to see the previous one if it 98 * Display a new msg (giving him a chance to see the previous one if it
96 * is up there with the --More--) 99 * is up there with the --More--)
97 */ 100 */
98 101
99 endmsg() 102 void
103 endmsg(void)
100 { 104 {
101 /* Needed to track where we are for 5.0 (PC) curses */ 105 /* Needed to track where we are for 5.0 (PC) curses */
102 register int x, y; 106 register int x, y;
103 107
104 if (mpos) { 108 if (mpos) {
139 wmove(msgw, y, x); 143 wmove(msgw, y, x);
140 clearok(msgw, FALSE); 144 clearok(msgw, FALSE);
141 draw(msgw); 145 draw(msgw);
142 } 146 }
143 147
148 void
144 doadd(char *fmt, va_list ap) 149 doadd(char *fmt, va_list ap)
145 { 150 {
146 vsprintf((char *) &msgbuf[newpos], fmt, ap); 151 vsprintf((char *) &msgbuf[newpos], fmt, ap);
147 newpos = strlen(msgbuf); 152 newpos = strlen(msgbuf);
148 } 153 }
151 * step_ok: 156 * step_ok:
152 * returns true if it is ok for type to step on ch 157 * returns true if it is ok for type to step on ch
153 * flgptr will be NULL if we don't know what the monster is yet! 158 * flgptr will be NULL if we don't know what the monster is yet!
154 */ 159 */
155 160
156 step_ok(y, x, can_on_monst, flgptr) 161 bool
157 register int y, x, can_on_monst; 162 step_ok(int y, int x, int can_on_monst, struct thing *flgptr)
158 register struct thing *flgptr;
159 { 163 {
160 /* can_on_monst = MONSTOK if all we care about are physical obstacles */ 164 /* can_on_monst = MONSTOK if all we care about are physical obstacles */
161 register struct linked_list *item; 165 register struct linked_list *item;
162 register struct thing *tp; 166 register struct thing *tp;
163 unsigned char ch; 167 unsigned char ch;
220 /* 224 /*
221 * shoot_ok: 225 * shoot_ok:
222 * returns true if it is ok for type to shoot over ch 226 * returns true if it is ok for type to shoot over ch
223 */ 227 */
224 228
229 bool
225 shoot_ok(int ch) 230 shoot_ok(int ch)
226 { 231 {
227 switch (ch) 232 switch (ch)
228 { 233 {
229 case ' ': 234 case ' ':
238 } 243 }
239 244
240 /* 245 /*
241 * status: 246 * status:
242 * Display the important stats line. Keep the cursor where it was. 247 * Display the important stats line. Keep the cursor where it was.
243 */ 248 * display: is TRUE, display unconditionally
244 249 */
245 status(display) 250
246 bool display; /* is TRUE, display unconditionally */ 251 void
252 status(bool display)
247 { 253 {
248 register struct stats *stat_ptr, *max_ptr; 254 register struct stats *stat_ptr, *max_ptr;
249 register int oy = 0, ox = 0, temp; 255 register int oy = 0, ox = 0, temp;
250 register char *pb; 256 register char *pb;
251 char buf[LINELEN]; 257 char buf[LINELEN];
375 /* 381 /*
376 * wait_for 382 * wait_for
377 * Sit around until the guy types the right key 383 * Sit around until the guy types the right key
378 */ 384 */
379 385
380 wait_for(ch) 386 void
381 register char ch; 387 wait_for(char ch)
382 { 388 {
383 register char c; 389 register char c;
384 390
385 clearok(msgw, FALSE); 391 clearok(msgw, FALSE);
386 if (ch == '\n') { 392 if (ch == '\n') {
405 * pertain only the the useful information to be displayed. 411 * pertain only the the useful information to be displayed.
406 * If redraw is non-zero, we wait for the character "redraw" to be 412 * If redraw is non-zero, we wait for the character "redraw" to be
407 * typed and then redraw the starting screen. 413 * typed and then redraw the starting screen.
408 */ 414 */
409 415
410 over_win(oldwin, newin, maxy, maxx, cursory, cursorx, redraw) 416 void
411 WINDOW *oldwin, *newin; 417 over_win(WINDOW *oldwin, WINDOW *newin, int maxy, int maxx, int cursory,
412 int maxy, maxx, cursory, cursorx; 418 int cursorx, char redraw)
413 char redraw;
414 { 419 {
415 char blanks[LINELEN+1]; 420 char blanks[LINELEN+1];
416 register int line, i; 421 register int line, i;
417 WINDOW *ow; /* Overlay window */ 422 WINDOW *ow; /* Overlay window */
418 423
458 /* 463 /*
459 * show_win: 464 * show_win:
460 * function used to display a window and wait before returning 465 * function used to display a window and wait before returning
461 */ 466 */
462 467
463 show_win(scr, message) 468 void
464 register WINDOW *scr; 469 show_win(WINDOW *scr, char *message)
465 char *message;
466 { 470 {
467 mvwaddstr(scr, 0, 0, message); 471 mvwaddstr(scr, 0, 0, message);
468 touchwin(scr); 472 touchwin(scr);
469 wmove(scr, hero.y, hero.x); 473 wmove(scr, hero.y, hero.x);
470 draw(scr); 474 draw(scr);
475 /* 479 /*
476 * dbotline: 480 * dbotline:
477 * Displays message on bottom line and waits for a space to return 481 * Displays message on bottom line and waits for a space to return
478 */ 482 */
479 483
480 dbotline(scr,message) 484 void
481 WINDOW *scr; 485 dbotline(WINDOW *scr, char *message)
482 char *message;
483 { 486 {
484 mvwaddstr(scr,lines-1,0,message); 487 mvwaddstr(scr,lines-1,0,message);
485 draw(scr); 488 draw(scr);
486 wait_for(' '); 489 wait_for(' ');
487 } 490 }
489 /* 492 /*
490 * restscr: 493 * restscr:
491 * Restores the screen to the terminal 494 * Restores the screen to the terminal
492 */ 495 */
493 496
494 restscr(scr) 497 void
495 WINDOW *scr; 498 restscr(WINDOW *scr)
496 { 499 {
497 clearok(scr,TRUE); 500 clearok(scr,TRUE);
498 touchwin(scr); 501 touchwin(scr);
499 draw(scr); 502 draw(scr);
500 } 503 }
504 * Read a byte, short, or long machine independently 507 * Read a byte, short, or long machine independently
505 * Always returns the value as an unsigned long. 508 * Always returns the value as an unsigned long.
506 */ 509 */
507 510
508 unsigned long 511 unsigned long
509 netread(error, size, stream) 512 netread(int *error, int size, FILE *stream)
510 int *error;
511 int size;
512 FILE *stream;
513 { 513 {
514 unsigned long result = 0L, /* What we read in */ 514 unsigned long result = 0L, /* What we read in */
515 partial; /* Partial value */ 515 partial; /* Partial value */
516 int nextc, /* The next byte */ 516 int nextc, /* The next byte */
517 i; /* To index through the result a byte at a time */ 517 i; /* To index through the result a byte at a time */
540 } 540 }
541 541
542 /* 542 /*
543 * netwrite: 543 * netwrite:
544 * Write out a byte, short, or long machine independently. 544 * Write out a byte, short, or long machine independently.
545 */ 545 * value: What to write
546 546 * size: How much to write out
547 netwrite(value, size, stream) 547 * stream: Where to write it
548 unsigned long value; /* What to write */ 548 */
549 int size; /* How much to write out */ 549
550 FILE *stream; /* Where to write it */ 550 int
551 netwrite(unsigned long value, int size, FILE *stream)
551 { 552 {
552 int i; /* Goes through value one byte at a time */ 553 int i; /* Goes through value one byte at a time */
553 char outc; /* The next character to be written */ 554 char outc; /* The next character to be written */
554 555
555 /* Be sure we have a right sized chunk */ 556 /* Be sure we have a right sized chunk */