1 /* SCCS Id: @(#)mapglyph.c 3.4 2003/01/08 */
2 /* Copyright (c) David Cohrs, 1991 */
3 /* NetHack may be freely redistributed. See license for details. */
6 #if defined(TTY_GRAPHICS)
7 #include "wintty.h" /* for prototype of has_color() only */
10 #define HI_DOMESTIC CLR_WHITE /* monst.c */
14 CLR_GREEN, /* noxious */
15 CLR_BROWN, /* muddy */
17 CLR_MAGENTA, /* magical */
18 CLR_ORANGE, /* fiery */
19 CLR_WHITE, /* frosty */
22 #if !defined(TTY_GRAPHICS)
23 #define has_color(n) TRUE
27 #define zap_color(n) color = iflags.use_color ? zapcolors[n] : NO_COLOR
28 #define cmap_color(n) color = iflags.use_color ? defsyms[n].color : NO_COLOR
29 #define obj_color(n) color = iflags.use_color ? objects[n].oc_color : NO_COLOR
30 #define mon_color(n) color = iflags.use_color ? mons[n].mcolor : NO_COLOR
31 #define invis_color(n) color = NO_COLOR
32 #define pet_color(n) color = iflags.use_color ? mons[n].mcolor : NO_COLOR
33 #define warn_color(n) color = iflags.use_color ? def_warnsyms[n].color : NO_COLOR
34 #define explode_color(n) color = iflags.use_color ? explcolors[n] : NO_COLOR
35 # if defined(REINCARNATION) && defined(ASCIIGRAPH)
39 #else /* no text color */
45 #define invis_color(n)
48 #define explode_color(n)
52 # if defined(USE_TILES) && defined(MSDOS)
53 #define HAS_ROGUE_IBM_GRAPHICS (iflags.IBMgraphics && !iflags.grmode && \
54 Is_rogue_level(&u.uz))
56 #define HAS_ROGUE_IBM_GRAPHICS (iflags.IBMgraphics && Is_rogue_level(&u.uz))
62 mapglyph(glyph, ochar, ocolor, ospecial, x, y)
63 int glyph, *ocolor, x, y;
68 #if defined(TEXTCOLOR) || defined(ROGUE_COLOR)
75 * Map the glyph back to a character and color.
77 * Warning: For speed, this makes an assumption on the order of
78 * offsets. The order is set in display.h.
80 if ((offset = (glyph - GLYPH_WARNING_OFF)) >= 0) { /* a warning flash */
81 ch = warnsyms[offset];
83 if (HAS_ROGUE_IBM_GRAPHICS)
88 } else if ((offset = (glyph - GLYPH_SWALLOW_OFF)) >= 0) { /* swallow */
89 /* see swallow_to_glyph() in display.c */
90 ch = (uchar) showsyms[S_sw_tl + (offset & 0x7)];
92 if (HAS_ROGUE_IBM_GRAPHICS && iflags.use_color)
96 mon_color(offset >> 3);
97 } else if ((offset = (glyph - GLYPH_ZAP_OFF)) >= 0) { /* zap beam */
98 /* see zapdir_to_glyph() in display.c */
99 ch = showsyms[S_vbeam + (offset & 0x3)];
101 if (HAS_ROGUE_IBM_GRAPHICS && iflags.use_color)
105 zap_color((offset >> 2));
106 } else if ((offset = (glyph - GLYPH_EXPLODE_OFF)) >= 0) { /* explosion */
107 ch = showsyms[(offset % MAXEXPCHARS) + S_explode1];
108 explode_color(offset / MAXEXPCHARS);
109 } else if ((offset = (glyph - GLYPH_CMAP_OFF)) >= 0) { /* cmap */
110 ch = showsyms[offset];
112 if (HAS_ROGUE_IBM_GRAPHICS && iflags.use_color) {
113 if (offset >= S_vwall && offset <= S_hcdoor)
115 else if (offset >= S_arrow_trap && offset <= S_polymorph_trap)
117 else if (offset == S_corr || offset == S_litcorr)
119 else if (offset >= S_room && offset <= S_water)
126 /* provide a visible difference if normal and lit corridor
127 * use the same symbol */
128 if (iflags.use_color &&
129 offset == S_litcorr && ch == showsyms[S_corr])
134 } else if ((offset = (glyph - GLYPH_OBJ_OFF)) >= 0) { /* object */
135 if (offset == BOULDER && iflags.bouldersym) ch = iflags.bouldersym;
136 else ch = oc_syms[(int)objects[offset].oc_class];
138 if (HAS_ROGUE_IBM_GRAPHICS && iflags.use_color) {
139 switch(objects[offset].oc_class) {
140 case COIN_CLASS: color = CLR_YELLOW; break;
141 case FOOD_CLASS: color = CLR_RED; break;
142 default: color = CLR_BRIGHT_BLUE; break;
147 } else if ((offset = (glyph - GLYPH_RIDDEN_OFF)) >= 0) { /* mon ridden */
148 ch = monsyms[(int)mons[offset].mlet];
150 if (HAS_ROGUE_IBM_GRAPHICS)
151 /* This currently implies that the hero is here -- monsters */
152 /* don't ride (yet...). Should we set it to yellow like in */
153 /* the monster case below? There is no equivalent in rogue. */
154 color = NO_COLOR; /* no need to check iflags.use_color */
158 special |= MG_RIDDEN;
159 } else if ((offset = (glyph - GLYPH_BODY_OFF)) >= 0) { /* a corpse */
160 ch = oc_syms[(int)objects[CORPSE].oc_class];
162 if (HAS_ROGUE_IBM_GRAPHICS && iflags.use_color)
167 special |= MG_CORPSE;
168 } else if ((offset = (glyph - GLYPH_DETECT_OFF)) >= 0) { /* mon detect */
169 ch = monsyms[(int)mons[offset].mlet];
171 if (HAS_ROGUE_IBM_GRAPHICS)
172 color = NO_COLOR; /* no need to check iflags.use_color */
176 /* Disabled for now; anyone want to get reverse video to work? */
177 /* is_reverse = TRUE; */
178 special |= MG_DETECT;
179 } else if ((offset = (glyph - GLYPH_INVIS_OFF)) >= 0) { /* invisible */
182 if (HAS_ROGUE_IBM_GRAPHICS)
183 color = NO_COLOR; /* no need to check iflags.use_color */
188 } else if ((offset = (glyph - GLYPH_PET_OFF)) >= 0) { /* a pet */
189 ch = monsyms[(int)mons[offset].mlet];
191 if (HAS_ROGUE_IBM_GRAPHICS)
192 color = NO_COLOR; /* no need to check iflags.use_color */
197 } else { /* a monster */
198 ch = monsyms[(int)mons[glyph].mlet];
200 if (HAS_ROGUE_IBM_GRAPHICS && iflags.use_color) {
201 if (x == u.ux && y == u.uy)
202 /* actually player should be yellow-on-gray if in a corridor */
210 /* special case the hero for `showrace' option */
212 if (iflags.use_color && x == u.ux && y == u.uy &&
213 iflags.showrace && !Upolyd)
220 /* Turn off color if no color defined, or rogue level w/o PC graphics. */
221 # ifdef REINCARNATION
223 if (!has_color(color) || (Is_rogue_level(&u.uz) && !HAS_ROGUE_IBM_GRAPHICS))
225 if (!has_color(color) || Is_rogue_level(&u.uz))
228 if (!has_color(color))