Annotation of early-roguelike/srogue/disply.c, Revision 1.1
1.1 ! rubenllo 1: /*
! 2: * various display routines and flag checking functions
! 3: *
! 4: * @(#)disply.c 9.0 (rdk) 7/17/84
! 5: *
! 6: * Super-Rogue
! 7: * Copyright (C) 1984 Robert D. Kindelberger
! 8: * All rights reserved.
! 9: *
! 10: * See the file LICENSE.TXT for full copyright and licensing information.
! 11: */
! 12:
! 13: #include "rogue.h"
! 14: #include <ctype.h>
! 15: #include "rogue.ext"
! 16:
! 17: /*
! 18: * displevl:
! 19: * Display detailed level for wizard and scroll
! 20: */
! 21: void
! 22: displevl(void)
! 23: {
! 24: reg char ch, mch;
! 25: reg int i,j;
! 26: reg struct room *rp;
! 27:
! 28: for (rp = rooms; rp < &rooms[MAXROOMS]; rp++)
! 29: rp->r_flags &= ~ISDARK;
! 30:
! 31: for (i = 0; i < LINES - 2; i++) {
! 32: for (j = 0; j < COLS - 1; j++) {
! 33: ch = mvinch(i,j);
! 34: if (isatrap(ch)) {
! 35: struct trap *what;
! 36:
! 37: what = trap_at(i, j);
! 38: if (what != NULL)
! 39: what->tr_flags |= ISFOUND;
! 40: }
! 41: else if (ch == SECRETDOOR) {
! 42: ch = DOOR;
! 43: mvaddch(i, j, ch);
! 44: }
! 45: else if (illeg_ch(ch)) {
! 46: ch = FLOOR;
! 47: mvaddch(i, j, ch);
! 48: }
! 49: if (mvwinch(mw, i, j) != ' ') {
! 50: struct linked_list *what;
! 51: struct thing *it;
! 52:
! 53: what = find_mons(i, j);
! 54: if (what == NULL) {
! 55: ch = FLOOR;
! 56: mvaddch(i, j, ch);
! 57: }
! 58: else {
! 59: it = THINGPTR(what);
! 60: it->t_oldch = ch;
! 61: }
! 62: }
! 63: mch = mvwinch(cw, i, j);
! 64: if (isalpha(mch))
! 65: ch = mch;
! 66: mvwaddch(cw, i, j, ch);
! 67: }
! 68: }
! 69: nochange = FALSE; /* display status again */
! 70: draw(cw);
! 71: }
! 72:
! 73: /*
! 74: * dispmons:
! 75: * Show monsters for wizard and potion
! 76: */
! 77: void
! 78: dispmons(void)
! 79: {
! 80: reg int ch, y, x;
! 81: reg struct thing *it;
! 82: reg struct linked_list *item;
! 83:
! 84: for (item = mlist; item != NULL; item = next(item)) {
! 85: it = THINGPTR(item);
! 86: y = it->t_pos.y;
! 87: x = it->t_pos.x;
! 88: mvwaddch(cw, y, x, it->t_type);
! 89: it->t_flags |= ISFOUND;
! 90: if (it->t_type == 'M') /* if a mimic */
! 91: it->t_disguise = 'M'; /* give it away */
! 92: }
! 93: draw(cw);
! 94: }
! 95:
! 96: /*
! 97: * winat:
! 98: * Get whatever character is at a location on the screen
! 99: */
! 100: char
! 101: winat(int y, int x)
! 102: {
! 103: reg char ch;
! 104:
! 105: if (mvwinch(mw,y,x) == ' ')
! 106: ch = mvinch(y, x); /* non-monsters */
! 107: else
! 108: ch = winch(mw); /* monsters */
! 109: return ch;
! 110: }
! 111:
! 112: /*
! 113: * cordok:
! 114: * Returns TRUE if coordinate is on usable screen
! 115: */
! 116: bool
! 117: cordok(int y, int x)
! 118: {
! 119: if (x < 0 || y < 0 || x >= COLS || y >= LINES - 1)
! 120: return FALSE;
! 121: return TRUE;
! 122: }
! 123:
! 124: /*
! 125: * pl_on:
! 126: * Returns TRUE if the player's flag is set
! 127: */
! 128: bool
! 129: pl_on(long what)
! 130: {
! 131: return (player.t_flags & what);
! 132: }
! 133:
! 134:
! 135: /*
! 136: * pl_off:
! 137: * Returns TRUE when player's flag is reset
! 138: */
! 139: bool
! 140: pl_off(long what)
! 141: {
! 142: return (!(player.t_flags & what));
! 143: }
! 144:
! 145:
! 146: /*
! 147: * o_on:
! 148: * Returns TRUE in the objects flag is set
! 149: */
! 150: bool
! 151: o_on(struct object *what, long bit)
! 152: {
! 153: reg int flag;
! 154:
! 155: flag = FALSE;
! 156: if (what != NULL)
! 157: flag = (what->o_flags & bit);
! 158: return flag;
! 159: }
! 160:
! 161:
! 162: /*
! 163: * o_off:
! 164: * Returns TRUE is the objects flag is reset
! 165: */
! 166: bool
! 167: o_off(struct object *what, long bit)
! 168: {
! 169: reg int flag;
! 170:
! 171: flag = FALSE;
! 172: if (what != NULL)
! 173: flag = !(what->o_flags & bit);
! 174: return flag;
! 175: }
! 176:
! 177:
! 178: /*
! 179: * setoflg:
! 180: * Set the specified flag for the object
! 181: */
! 182: void
! 183: setoflg(struct object *what, long bit)
! 184: {
! 185: what->o_flags |= bit;
! 186: }
! 187:
! 188:
! 189: /*
! 190: * resoflg:
! 191: * Reset the specified flag for the object
! 192: */
! 193: void
! 194: resoflg(struct object *what, long bit)
! 195: {
! 196: what->o_flags &= ~bit;
! 197: }
CVSweb