Source:NetHack 3.6.1/src/drawing.c

From NetHackWiki
(Redirected from Drawing.c)
Jump to: navigation, search

Below is the full text to drawing.c from the source code of NetHack 3.6.1. To link to a particular line, write [[Source:NetHack 3.6.1/src/drawing.c#line123]], for example.

Top of file

  1.  /* NetHack 3.6	drawing.c	$NHDT-Date: 1463706747 2016/05/20 01:12:27 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.51 $ */
  2.  /* Copyright (c) NetHack Development Team 1992.                   */
  3.  /* NetHack may be freely redistributed.  See license for details. */

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

  1.  
  2.  #include "hack.h"
  3.  #include "tcap.h"
  4.  
  5.  /* Relevant header information in rm.h, objclass.h, and monsym.h. */
  6.  
  7.  #ifdef C
  8.  #undef C
  9.  #endif
  10.  
  11.  #ifdef TEXTCOLOR
  12.  #define C(n) n
  13.  #else
  14.  #define C(n)
  15.  #endif
  16.  
  17.  struct symsetentry symset[NUM_GRAPHICS];
  18.  
  19.  int currentgraphics = 0;
  20.  
  21.  nhsym showsyms[SYM_MAX] = DUMMY; /* symbols to be displayed */
  22.  nhsym l_syms[SYM_MAX] = DUMMY;   /* loaded symbols          */
  23.  nhsym r_syms[SYM_MAX] = DUMMY;   /* rogue symbols           */
  24.  
  25.  nhsym warnsyms[WARNCOUNT] = DUMMY; /* the current warning display symbols */
  26.  const char invisexplain[] = "remembered, unseen, creature";
  27.  
  28.  /* Default object class symbols.  See objclass.h.
  29.   * {symbol, name, explain}
  30.   *     name:    used in object_detect().
  31.   *     explain: used in do_look().
  32.   */
  33.  const struct class_sym def_oc_syms[MAXOCLASSES] = {
  34.      { '\0', "", "" }, /* placeholder for the "random class" */
  35.      { ILLOBJ_SYM, "illegal objects", "strange object" },
  36.      { WEAPON_SYM, "weapons", "weapon" },
  37.      { ARMOR_SYM, "armor", "suit or piece of armor" },
  38.      { RING_SYM, "rings", "ring" },
  39.      { AMULET_SYM, "amulets", "amulet" },
  40.      { TOOL_SYM, "tools", "useful item (pick-axe, key, lamp...)" },
  41.      { FOOD_SYM, "food", "piece of food" },
  42.      { POTION_SYM, "potions", "potion" },
  43.      { SCROLL_SYM, "scrolls", "scroll" },
  44.      { SPBOOK_SYM, "spellbooks", "spellbook" },
  45.      { WAND_SYM, "wands", "wand" },
  46.      { GOLD_SYM, "coins", "pile of coins" },
  47.      { GEM_SYM, "rocks", "gem or rock" },
  48.      { ROCK_SYM, "large stones", "boulder or statue" },
  49.      { BALL_SYM, "iron balls", "iron ball" },
  50.      { CHAIN_SYM, "chains", "iron chain" },
  51.      { VENOM_SYM, "venoms", "splash of venom" }
  52.  };
  53.  
  54.  /* Default monster class symbols.  See monsym.h. */
  55.  const struct class_sym def_monsyms[MAXMCLASSES] = {
  56.      { '\0', "", "" },
  57.      { DEF_ANT, "", "ant or other insect" },
  58.      { DEF_BLOB, "", "blob" },
  59.      { DEF_COCKATRICE, "", "cockatrice" },
  60.      { DEF_DOG, "", "dog or other canine" },
  61.      { DEF_EYE, "", "eye or sphere" },
  62.      { DEF_FELINE, "", "cat or other feline" },
  63.      { DEF_GREMLIN, "", "gremlin" },
  64.      { DEF_HUMANOID, "", "humanoid" },
  65.      { DEF_IMP, "", "imp or minor demon" },
  66.      { DEF_JELLY, "", "jelly" },
  67.      { DEF_KOBOLD, "", "kobold" },
  68.      { DEF_LEPRECHAUN, "", "leprechaun" },
  69.      { DEF_MIMIC, "", "mimic" },
  70.      { DEF_NYMPH, "", "nymph" },
  71.      { DEF_ORC, "", "orc" },
  72.      { DEF_PIERCER, "", "piercer" },
  73.      { DEF_QUADRUPED, "", "quadruped" },
  74.      { DEF_RODENT, "", "rodent" },
  75.      { DEF_SPIDER, "", "arachnid or centipede" },
  76.      { DEF_TRAPPER, "", "trapper or lurker above" },
  77.      { DEF_UNICORN, "", "unicorn or horse" },
  78.      { DEF_VORTEX, "", "vortex" },
  79.      { DEF_WORM, "", "worm" },
  80.      { DEF_XAN, "", "xan or other mythical/fantastic insect" },
  81.      { DEF_LIGHT, "", "light" },
  82.      { DEF_ZRUTY, "", "zruty" },
  83.      { DEF_ANGEL, "", "angelic being" },
  84.      { DEF_BAT, "", "bat or bird" },
  85.      { DEF_CENTAUR, "", "centaur" },
  86.      { DEF_DRAGON, "", "dragon" },
  87.      { DEF_ELEMENTAL, "", "elemental" },
  88.      { DEF_FUNGUS, "", "fungus or mold" },
  89.      { DEF_GNOME, "", "gnome" },
  90.      { DEF_GIANT, "", "giant humanoid" },
  91.      { '\0', "", "invisible monster" },
  92.      { DEF_JABBERWOCK, "", "jabberwock" },
  93.      { DEF_KOP, "", "Keystone Kop" },
  94.      { DEF_LICH, "", "lich" },
  95.      { DEF_MUMMY, "", "mummy" },
  96.      { DEF_NAGA, "", "naga" },
  97.      { DEF_OGRE, "", "ogre" },
  98.      { DEF_PUDDING, "", "pudding or ooze" },
  99.      { DEF_QUANTMECH, "", "quantum mechanic" },
  100.      { DEF_RUSTMONST, "", "rust monster or disenchanter" },
  101.      { DEF_SNAKE, "", "snake" },
  102.      { DEF_TROLL, "", "troll" },
  103.      { DEF_UMBER, "", "umber hulk" },
  104.      { DEF_VAMPIRE, "", "vampire" },
  105.      { DEF_WRAITH, "", "wraith" },
  106.      { DEF_XORN, "", "xorn" },
  107.      { DEF_YETI, "", "apelike creature" },
  108.      { DEF_ZOMBIE, "", "zombie" },
  109.      { DEF_HUMAN, "", "human or elf" },
  110.      { DEF_GHOST, "", "ghost" },
  111.      { DEF_GOLEM, "", "golem" },
  112.      { DEF_DEMON, "", "major demon" },
  113.      { DEF_EEL, "", "sea monster" },
  114.      { DEF_LIZARD, "", "lizard" },
  115.      { DEF_WORM_TAIL, "", "long worm tail" },
  116.      { DEF_MIMIC_DEF, "", "mimic" },
  117.  };
  118.  
  119.  const struct symdef def_warnsyms[WARNCOUNT] = {
  120.      /* white warning  */
  121.      { '0', "unknown creature causing you worry",    C(CLR_WHITE) },
  122.      /* pink warning   */
  123.      { '1', "unknown creature causing you concern",  C(CLR_RED) },
  124.      /* red warning    */
  125.      { '2', "unknown creature causing you anxiety",  C(CLR_RED) },
  126.      /* ruby warning   */
  127.      { '3', "unknown creature causing you disquiet", C(CLR_RED) },
  128.      /* purple warning */
  129.      { '4', "unknown creature causing you alarm",    C(CLR_MAGENTA) },
  130.      /* black warning  */
  131.      { '5', "unknown creature causing you dread",    C(CLR_BRIGHT_MAGENTA) },
  132.  };
  133.  
  134.  /*
  135.   *  Default screen symbols with explanations and colors.
  136.   */
  137.  const struct symdef defsyms[MAXPCHARS] = {
  138.  /* 0*/ { ' ', "dark part of a room", C(NO_COLOR) },  /* stone */
  139.         { '|', "wall", C(CLR_GRAY) },                 /* vwall */
  140.         { '-', "wall", C(CLR_GRAY) },                 /* hwall */
  141.         { '-', "wall", C(CLR_GRAY) },                 /* tlcorn */
  142.         { '-', "wall", C(CLR_GRAY) },                 /* trcorn */
  143.         { '-', "wall", C(CLR_GRAY) },                 /* blcorn */
  144.         { '-', "wall", C(CLR_GRAY) },                 /* brcorn */
  145.         { '-', "wall", C(CLR_GRAY) },                 /* crwall */
  146.         { '-', "wall", C(CLR_GRAY) },                 /* tuwall */
  147.         { '-', "wall", C(CLR_GRAY) },                 /* tdwall */
  148.  /*10*/ { '|', "wall", C(CLR_GRAY) },                 /* tlwall */
  149.         { '|', "wall", C(CLR_GRAY) },                 /* trwall */
  150.         { '.', "doorway", C(CLR_GRAY) },              /* ndoor */
  151.         { '-', "open door", C(CLR_BROWN) },           /* vodoor */
  152.         { '|', "open door", C(CLR_BROWN) },           /* hodoor */
  153.         { '+', "closed door", C(CLR_BROWN) },         /* vcdoor */
  154.         { '+', "closed door", C(CLR_BROWN) },         /* hcdoor */
  155.         { '#', "iron bars", C(HI_METAL) },            /* bars */
  156.         { '#', "tree", C(CLR_GREEN) },                /* tree */
  157.         { '.', "floor of a room", C(CLR_GRAY) },      /* room */
  158.  /*20*/ { '.', "dark part of a room", C(CLR_BLACK) }, /* dark room */
  159.         { '#', "corridor", C(CLR_GRAY) },             /* dark corr */
  160.         { '#', "lit corridor", C(CLR_GRAY) },   /* lit corr (see mapglyph.c) */
  161.         { '<', "staircase up", C(CLR_GRAY) },         /* upstair */
  162.         { '>', "staircase down", C(CLR_GRAY) },       /* dnstair */
  163.         { '<', "ladder up", C(CLR_BROWN) },           /* upladder */
  164.         { '>', "ladder down", C(CLR_BROWN) },         /* dnladder */
  165.         { '_', "altar", C(CLR_GRAY) },                /* altar */
  166.         { '|', "grave", C(CLR_WHITE) },               /* grave */
  167.         { '\\', "opulent throne", C(HI_GOLD) },       /* throne */
  168.  /*30*/ { '#', "sink", C(CLR_GRAY) },                 /* sink */
  169.         { '{', "fountain", C(CLR_BRIGHT_BLUE) },      /* fountain */
  170.         { '}', "water", C(CLR_BLUE) },                /* pool */
  171.         { '.', "ice", C(CLR_CYAN) },                  /* ice */
  172.         { '}', "molten lava", C(CLR_RED) },           /* lava */
  173.         { '.', "lowered drawbridge", C(CLR_BROWN) },  /* vodbridge */
  174.         { '.', "lowered drawbridge", C(CLR_BROWN) },  /* hodbridge */
  175.         { '#', "raised drawbridge", C(CLR_BROWN) },   /* vcdbridge */
  176.         { '#', "raised drawbridge", C(CLR_BROWN) },   /* hcdbridge */
  177.         { ' ', "air", C(CLR_CYAN) },                  /* open air */
  178.  /*40*/ { '#', "cloud", C(CLR_GRAY) },                /* [part of] a cloud */
  179.         { '}', "water", C(CLR_BLUE) },                /* under water */
  180.         { '^', "arrow trap", C(HI_METAL) },           /* trap */
  181.         { '^', "dart trap", C(HI_METAL) },            /* trap */
  182.         { '^', "falling rock trap", C(CLR_GRAY) },    /* trap */
  183.         { '^', "squeaky board", C(CLR_BROWN) },       /* trap */
  184.         { '^', "bear trap", C(HI_METAL) },            /* trap */
  185.         { '^', "land mine", C(CLR_RED) },             /* trap */
  186.         { '^', "rolling boulder trap", C(CLR_GRAY) }, /* trap */
  187.         { '^', "sleeping gas trap", C(HI_ZAP) },      /* trap */
  188.  /*50*/ { '^', "rust trap", C(CLR_BLUE) },            /* trap */
  189.         { '^', "fire trap", C(CLR_ORANGE) },          /* trap */
  190.         { '^', "pit", C(CLR_BLACK) },                 /* trap */
  191.         { '^', "spiked pit", C(CLR_BLACK) },          /* trap */
  192.         { '^', "hole", C(CLR_BROWN) },                /* trap */
  193.         { '^', "trap door", C(CLR_BROWN) },           /* trap */
  194.         { '^', "teleportation trap", C(CLR_MAGENTA) },  /* trap */
  195.         { '^', "level teleporter", C(CLR_MAGENTA) },    /* trap */
  196.         { '^', "magic portal", C(CLR_BRIGHT_MAGENTA) }, /* trap */
  197.         { '"', "web", C(CLR_GRAY) },                    /* web */
  198.  /*60*/ { '^', "statue trap", C(CLR_GRAY) },            /* trap */
  199.         { '^', "magic trap", C(HI_ZAP) },               /* trap */
  200.         { '^', "anti-magic field", C(HI_ZAP) },         /* trap */
  201.         { '^', "polymorph trap", C(CLR_BRIGHT_GREEN) }, /* trap */
  202.         { '~', "vibrating square", C(CLR_MAGENTA) },    /* "trap" */
  203.         /* zap colors are changed by mapglyph() to match type of beam */
  204.         { '|', "", C(CLR_GRAY) },                /* vbeam */
  205.         { '-', "", C(CLR_GRAY) },                /* hbeam */
  206.         { '\\', "", C(CLR_GRAY) },               /* lslant */
  207.         { '/', "", C(CLR_GRAY) },                /* rslant */
  208.         { '*', "", C(CLR_WHITE) },               /* dig beam */
  209.         { '!', "", C(CLR_WHITE) },               /* camera flash beam */
  210.         { ')', "", C(HI_WOOD) },                 /* boomerang open left */
  211.  /*70*/ { '(', "", C(HI_WOOD) },                 /* boomerang open right */
  212.         { '0', "", C(HI_ZAP) },                  /* 4 magic shield symbols */
  213.         { '#', "", C(HI_ZAP) },
  214.         { '@', "", C(HI_ZAP) },
  215.         { '*', "", C(HI_ZAP) },
  216.         { '#', "poison cloud", C(CLR_BRIGHT_GREEN) },   /* part of a cloud */
  217.         { '?', "valid position", C(CLR_BRIGHT_GREEN) }, /*  target position */
  218.         /* swallow colors are changed by mapglyph() to match engulfing monst */
  219.         { '/', "", C(CLR_GREEN) },         /* swallow top left      */
  220.         { '-', "", C(CLR_GREEN) },         /* swallow top center    */
  221.         { '\\', "", C(CLR_GREEN) },        /* swallow top right     */
  222.  /*80*/ { '|', "", C(CLR_GREEN) },         /* swallow middle left   */
  223.         { '|', "", C(CLR_GREEN) },         /* swallow middle right  */
  224.         { '\\', "", C(CLR_GREEN) },        /* swallow bottom left   */
  225.         { '-', "", C(CLR_GREEN) },         /* swallow bottom center */
  226.         { '/', "", C(CLR_GREEN) },         /* swallow bottom right  */
  227.         /* explosion colors are changed by mapglyph() to match type of expl. */
  228.         { '/', "", C(CLR_ORANGE) },        /* explosion top left     */
  229.         { '-', "", C(CLR_ORANGE) },        /* explosion top center   */
  230.         { '\\', "", C(CLR_ORANGE) },       /* explosion top right    */
  231.         { '|', "", C(CLR_ORANGE) },        /* explosion middle left  */
  232.         { ' ', "", C(CLR_ORANGE) },        /* explosion middle center*/
  233.  /*90*/ { '|', "", C(CLR_ORANGE) },        /* explosion middle right */
  234.         { '\\', "", C(CLR_ORANGE) },       /* explosion bottom left  */
  235.         { '-', "", C(CLR_ORANGE) },        /* explosion bottom center*/
  236.         { '/', "", C(CLR_ORANGE) },        /* explosion bottom right */
  237.  };
  238.  
  239.  /* default rogue level symbols */
  240.  static const uchar def_r_oc_syms[MAXOCLASSES] = {
  241.  /* 0*/ '\0', ILLOBJ_SYM, WEAPON_SYM, ']', /* armor */
  242.         RING_SYM,
  243.  /* 5*/ ',',                     /* amulet */
  244.         TOOL_SYM, ':',           /* food */
  245.         POTION_SYM, SCROLL_SYM,
  246.  /*10*/ SPBOOK_SYM, WAND_SYM,
  247.         GEM_SYM,                /* gold -- yes it's the same as gems */
  248.         GEM_SYM, ROCK_SYM,
  249.  /*15*/ BALL_SYM, CHAIN_SYM, VENOM_SYM
  250.  };
  251.  
  252.  #undef C
  253.  
  254.  #ifdef TERMLIB
  255.  void NDECL((*decgraphics_mode_callback)) = 0; /* set in tty_start_screen() */
  256.  #endif /* TERMLIB */
  257.  
  258.  #ifdef PC9800
  259.  void NDECL((*ibmgraphics_mode_callback)) = 0; /* set in tty_start_screen() */
  260.  void NDECL((*ascgraphics_mode_callback)) = 0; /* set in tty_start_screen() */
  261.  #endif
  262.  

def_char_to_objclass

  1.  /*
  2.   * Convert the given character to an object class.  If the character is not
  3.   * recognized, then MAXOCLASSES is returned.  Used in detect.c, invent.c,
  4.   * objnam.c, options.c, pickup.c, sp_lev.c, lev_main.c, and tilemap.c.
  5.   */
  6.  int
  7.  def_char_to_objclass(ch)
  8.  char ch;
  9.  {
  10.      int i;
  11.      for (i = 1; i < MAXOCLASSES; i++)
  12.          if (ch == def_oc_syms[i].sym)
  13.              break;
  14.      return i;
  15.  }
  16.  

def_char_to_monclass

  1.  /*
  2.   * Convert a character into a monster class.  This returns the _first_
  3.   * match made.  If there are are no matches, return MAXMCLASSES.
  4.   * Used in detect.c, options.c, read.c, sp_lev.c, and lev_main.c
  5.   */
  6.  int
  7.  def_char_to_monclass(ch)
  8.  char ch;
  9.  {
  10.      int i;
  11.      for (i = 1; i < MAXMCLASSES; i++)
  12.          if (ch == def_monsyms[i].sym)
  13.              break;
  14.      return i;
  15.  }
  16.  
  17.  /*
  18.   * Explanations of the functions found below:
  19.   *
  20.   * init_symbols()
  21.   *                     Sets the current display symbols, the
  22.   *                     loadable symbols to the default NetHack
  23.   *                     symbols, including the r_syms rogue level
  24.   *                     symbols. This would typically be done
  25.   *                     immediately after execution begins. Any
  26.   *                     previously loaded external symbol sets are
  27.   *                     discarded.
  28.   *
  29.   * switch_symbols(arg)
  30.   *                     Called to swap in new current display symbols
  31.   *                     (showsyms) from either the default symbols,
  32.   *                     or from the loaded symbols.
  33.   *
  34.   *                     If (arg == 0) then showsyms are taken from
  35.   *                     defsyms, def_oc_syms, and def_monsyms.
  36.   *
  37.   *                     If (arg != 0), which is the normal expected
  38.   *                     usage, then showsyms are taken from the
  39.   *                     adjustable display symbols found in l_syms.
  40.   *                     l_syms may have been loaded from an external
  41.   *                     symbol file by config file options or interactively
  42.   *                     in the Options menu.
  43.   *
  44.   * assign_graphics(arg)
  45.   *
  46.   *                     This is used in the game core to toggle in and
  47.   *                     out of other {rogue} level display modes.
  48.   *
  49.   *                     If arg is ROGUESET, this places the rogue level
  50.   *                     symbols from r_syms into showsyms.
  51.   *
  52.   *                     If arg is PRIMARY, this places the symbols
  53.   *                     from l_monsyms into showsyms.
  54.   *
  55.   * update_l_symset()
  56.   *                     Update a member of the loadable (l_*) symbol set.
  57.   *
  58.   * update_r_symset()
  59.   *                     Update a member of the rogue (r_*) symbol set.
  60.   *
  61.   */
  62.  

init_symbols

  1.  void
  2.  init_symbols()
  3.  {
  4.      init_l_symbols();
  5.      init_showsyms();
  6.      init_r_symbols();
  7.  }
  8.  

update_bouldersym

  1.  void
  2.  update_bouldersym()
  3.  {
  4.      showsyms[SYM_BOULDER + SYM_OFF_X] = iflags.bouldersym;
  5.      l_syms[SYM_BOULDER + SYM_OFF_X] = iflags.bouldersym;
  6.      r_syms[SYM_BOULDER + SYM_OFF_X] = iflags.bouldersym;
  7.  }
  8.  

init_showsyms

  1.  void
  2.  init_showsyms()
  3.  {
  4.      register int i;
  5.  
  6.      for (i = 0; i < MAXPCHARS; i++)
  7.          showsyms[i + SYM_OFF_P] = defsyms[i].sym;
  8.      for (i = 0; i < MAXOCLASSES; i++)
  9.          showsyms[i + SYM_OFF_O] = def_oc_syms[i].sym;
  10.      for (i = 0; i < MAXMCLASSES; i++)
  11.          showsyms[i + SYM_OFF_M] = def_monsyms[i].sym;
  12.      for (i = 0; i < WARNCOUNT; i++)
  13.          showsyms[i + SYM_OFF_W] = def_warnsyms[i].sym;
  14.      for (i = 0; i < MAXOTHER; i++) {
  15.          if (i == SYM_BOULDER)
  16.              showsyms[i + SYM_OFF_X] = iflags.bouldersym
  17.                                          ? iflags.bouldersym
  18.                                          : def_oc_syms[ROCK_CLASS].sym;
  19.          else if (i == SYM_INVISIBLE)
  20.              showsyms[i + SYM_OFF_X] = DEF_INVISIBLE;
  21.      }
  22.  }
  23.  

init_l_symbols

  1.  /* initialize defaults for the loadable symset */
  2.  void
  3.  init_l_symbols()
  4.  {
  5.      register int i;
  6.  
  7.      for (i = 0; i < MAXPCHARS; i++)
  8.          l_syms[i + SYM_OFF_P] = defsyms[i].sym;
  9.      for (i = 0; i < MAXOCLASSES; i++)
  10.          l_syms[i + SYM_OFF_O] = def_oc_syms[i].sym;
  11.      for (i = 0; i < MAXMCLASSES; i++)
  12.          l_syms[i + SYM_OFF_M] = def_monsyms[i].sym;
  13.      for (i = 0; i < WARNCOUNT; i++)
  14.          l_syms[i + SYM_OFF_W] = def_warnsyms[i].sym;
  15.      for (i = 0; i < MAXOTHER; i++) {
  16.          if (i == SYM_BOULDER)
  17.              l_syms[i + SYM_OFF_X] = iflags.bouldersym
  18.                                        ? iflags.bouldersym
  19.                                        : def_oc_syms[ROCK_CLASS].sym;
  20.          else if (i == SYM_INVISIBLE)
  21.              l_syms[i + SYM_OFF_X] = DEF_INVISIBLE;
  22.      }
  23.  
  24.      clear_symsetentry(PRIMARY, FALSE);
  25.  }
  26.  

init_r_symbols

  1.  void
  2.  init_r_symbols()
  3.  {
  4.      register int i;
  5.  
  6.      /* These are defaults that can get overwritten
  7.         later by the roguesymbols option */
  8.  
  9.      for (i = 0; i < MAXPCHARS; i++)
  10.          r_syms[i + SYM_OFF_P] = defsyms[i].sym;
  11.      r_syms[S_vodoor] = r_syms[S_hodoor] = r_syms[S_ndoor] = '+';
  12.      r_syms[S_upstair] = r_syms[S_dnstair] = '%';
  13.  
  14.      for (i = 0; i < MAXOCLASSES; i++)
  15.          r_syms[i + SYM_OFF_O] = def_r_oc_syms[i];
  16.      for (i = 0; i < MAXMCLASSES; i++)
  17.          r_syms[i + SYM_OFF_M] = def_monsyms[i].sym;
  18.      for (i = 0; i < WARNCOUNT; i++)
  19.          r_syms[i + SYM_OFF_W] = def_warnsyms[i].sym;
  20.      for (i = 0; i < MAXOTHER; i++) {
  21.          if (i == SYM_BOULDER)
  22.              r_syms[i + SYM_OFF_X] = iflags.bouldersym
  23.                                        ? iflags.bouldersym
  24.                                        : def_oc_syms[ROCK_CLASS].sym;
  25.          else if (i == SYM_INVISIBLE)
  26.              r_syms[i + SYM_OFF_X] = DEF_INVISIBLE;
  27.      }
  28.  
  29.      clear_symsetentry(ROGUESET, FALSE);
  30.      /* default on Rogue level is no color
  31.       * but some symbol sets can override that
  32.       */
  33.      symset[ROGUESET].nocolor = 1;
  34.  }
  35.  

assign_graphics

  1.  void
  2.  assign_graphics(whichset)
  3.  int whichset;
  4.  {
  5.      register int i;
  6.  
  7.      switch (whichset) {
  8.      case ROGUESET:
  9.          /* Adjust graphics display characters on Rogue levels */
  10.  
  11.          for (i = 0; i < SYM_MAX; i++)
  12.              showsyms[i] = r_syms[i];
  13.  
  14.  #if defined(MSDOS) && defined(USE_TILES)
  15.          if (iflags.grmode)
  16.              tileview(FALSE);
  17.  #endif
  18.          currentgraphics = ROGUESET;
  19.          break;
  20.  
  21.      case PRIMARY:
  22.      default:
  23.          for (i = 0; i < SYM_MAX; i++)
  24.              showsyms[i] = l_syms[i];
  25.  
  26.  #if defined(MSDOS) && defined(USE_TILES)
  27.          if (iflags.grmode)
  28.              tileview(TRUE);
  29.  #endif
  30.          currentgraphics = PRIMARY;
  31.          break;
  32.      }
  33.  }
  34.  

switch_symbols

  1.  void
  2.  switch_symbols(nondefault)
  3.  int nondefault;
  4.  {
  5.      register int i;
  6.  
  7.      if (nondefault) {
  8.          for (i = 0; i < SYM_MAX; i++)
  9.              showsyms[i] = l_syms[i];
  10.  #ifdef PC9800
  11.          if (SYMHANDLING(H_IBM) && ibmgraphics_mode_callback)
  12.              (*ibmgraphics_mode_callback)();
  13.          else if (!symset[currentgraphics].name && ascgraphics_mode_callback)
  14.              (*ascgraphics_mode_callback)();
  15.  #endif
  16.  #ifdef TERMLIB
  17.          if (SYMHANDLING(H_DEC) && decgraphics_mode_callback)
  18.              (*decgraphics_mode_callback)();
  19.  #endif
  20.      } else
  21.          init_symbols();
  22.  }
  23.  

update_l_symset

  1.  void
  2.  update_l_symset(symp, val)
  3.  struct symparse *symp;
  4.  int val;
  5.  {
  6.      l_syms[symp->idx] = val;
  7.  }
  8.  

update_r_symset

  1.  void
  2.  update_r_symset(symp, val)
  3.  struct symparse *symp;
  4.  int val;
  5.  {
  6.      r_syms[symp->idx] = val;
  7.  }
  8.  

clear_symsetentry

  1.  void
  2.  clear_symsetentry(which_set, name_too)
  3.  int which_set;
  4.  boolean name_too;
  5.  {
  6.      if (symset[which_set].desc)
  7.          free((genericptr_t) symset[which_set].desc);
  8.      symset[which_set].desc = (char *) 0;
  9.  
  10.      symset[which_set].handling = H_UNK;
  11.      symset[which_set].nocolor = 0;
  12.      /* initialize restriction bits */
  13.      symset[which_set].primary = 0;
  14.      symset[which_set].rogue = 0;
  15.  
  16.      if (name_too) {
  17.          if (symset[which_set].name)
  18.              free((genericptr_t) symset[which_set].name);
  19.          symset[which_set].name = (char *) 0;
  20.      }
  21.  }
  22.  
  23.  /*
  24.   * If you are adding code somewhere to be able to recognize
  25.   * particular types of symset "handling", define a
  26.   * H_XXX macro in include/rm.h and add the name
  27.   * to this array at the matching offset.
  28.   */
  29.  const char *known_handling[] = {
  30.      "UNKNOWN", /* H_UNK */
  31.      "IBM",     /* H_IBM */
  32.      "DEC",     /* H_DEC */
  33.      (const char *) 0,
  34.  };
  35.  
  36.  /*
  37.   * Accepted keywords for symset restrictions.
  38.   * These can be virtually anything that you want to
  39.   * be able to test in the code someplace.
  40.   * Be sure to:
  41.   *    - add a corresponding Bitfield to the symsetentry struct in rm.h
  42.   *    - initialize the field to zero in parse_sym_line in the SYM_CONTROL
  43.   *      case 0 section of the idx switch. The location is prefaced with
  44.   *      with a comment stating "initialize restriction bits".
  45.   *    - set the value appropriately based on the index of your keyword
  46.   *      under the case 5 sections of the same SYM_CONTROL idx switches.
  47.   *    - add the field to clear_symsetentry()
  48.   */
  49.  const char *known_restrictions[] = {
  50.      "primary", "rogue", (const char *) 0,
  51.  };
  52.  
  53.  struct symparse loadsyms[] = {
  54.      { SYM_CONTROL, 0, "start" },
  55.      { SYM_CONTROL, 0, "begin" },
  56.      { SYM_CONTROL, 1, "finish" },
  57.      { SYM_CONTROL, 2, "handling" },
  58.      { SYM_CONTROL, 3, "description" },
  59.      { SYM_CONTROL, 4, "color" },
  60.      { SYM_CONTROL, 4, "colour" },
  61.      { SYM_CONTROL, 5, "restrictions" },
  62.      { SYM_PCHAR, S_stone, "S_stone" },
  63.      { SYM_PCHAR, S_vwall, "S_vwall" },
  64.      { SYM_PCHAR, S_hwall, "S_hwall" },
  65.      { SYM_PCHAR, S_tlcorn, "S_tlcorn" },
  66.      { SYM_PCHAR, S_trcorn, "S_trcorn" },
  67.      { SYM_PCHAR, S_blcorn, "S_blcorn" },
  68.      { SYM_PCHAR, S_brcorn, "S_brcorn" },
  69.      { SYM_PCHAR, S_crwall, "S_crwall" },
  70.      { SYM_PCHAR, S_tuwall, "S_tuwall" },
  71.      { SYM_PCHAR, S_tdwall, "S_tdwall" },
  72.      { SYM_PCHAR, S_tlwall, "S_tlwall" },
  73.      { SYM_PCHAR, S_trwall, "S_trwall" },
  74.      { SYM_PCHAR, S_ndoor, "S_ndoor" },
  75.      { SYM_PCHAR, S_vodoor, "S_vodoor" },
  76.      { SYM_PCHAR, S_hodoor, "S_hodoor" },
  77.      { SYM_PCHAR, S_vcdoor, "S_vcdoor" },
  78.      { SYM_PCHAR, S_hcdoor, "S_hcdoor" },
  79.      { SYM_PCHAR, S_bars, "S_bars" },
  80.      { SYM_PCHAR, S_tree, "S_tree" },
  81.      { SYM_PCHAR, S_room, "S_room" },
  82.      { SYM_PCHAR, S_darkroom, "S_darkroom" },
  83.      { SYM_PCHAR, S_corr, "S_corr" },
  84.      { SYM_PCHAR, S_litcorr, "S_litcorr" },
  85.      { SYM_PCHAR, S_upstair, "S_upstair" },
  86.      { SYM_PCHAR, S_dnstair, "S_dnstair" },
  87.      { SYM_PCHAR, S_upladder, "S_upladder" },
  88.      { SYM_PCHAR, S_dnladder, "S_dnladder" },
  89.      { SYM_PCHAR, S_altar, "S_altar" },
  90.      { SYM_PCHAR, S_grave, "S_grave" },
  91.      { SYM_PCHAR, S_throne, "S_throne" },
  92.      { SYM_PCHAR, S_sink, "S_sink" },
  93.      { SYM_PCHAR, S_fountain, "S_fountain" },
  94.      { SYM_PCHAR, S_pool, "S_pool" },
  95.      { SYM_PCHAR, S_ice, "S_ice" },
  96.      { SYM_PCHAR, S_lava, "S_lava" },
  97.      { SYM_PCHAR, S_vodbridge, "S_vodbridge" },
  98.      { SYM_PCHAR, S_hodbridge, "S_hodbridge" },
  99.      { SYM_PCHAR, S_vcdbridge, "S_vcdbridge" },
  100.      { SYM_PCHAR, S_hcdbridge, "S_hcdbridge" },
  101.      { SYM_PCHAR, S_air, "S_air" },
  102.      { SYM_PCHAR, S_cloud, "S_cloud" },
  103.      { SYM_PCHAR, S_poisoncloud, "S_poisoncloud" },
  104.      { SYM_PCHAR, S_water, "S_water" },
  105.      { SYM_PCHAR, S_arrow_trap, "S_arrow_trap" },
  106.      { SYM_PCHAR, S_dart_trap, "S_dart_trap" },
  107.      { SYM_PCHAR, S_falling_rock_trap, "S_falling_rock_trap" },
  108.      { SYM_PCHAR, S_squeaky_board, "S_squeaky_board" },
  109.      { SYM_PCHAR, S_bear_trap, "S_bear_trap" },
  110.      { SYM_PCHAR, S_land_mine, "S_land_mine" },
  111.      { SYM_PCHAR, S_rolling_boulder_trap, "S_rolling_boulder_trap" },
  112.      { SYM_PCHAR, S_sleeping_gas_trap, "S_sleeping_gas_trap" },
  113.      { SYM_PCHAR, S_rust_trap, "S_rust_trap" },
  114.      { SYM_PCHAR, S_fire_trap, "S_fire_trap" },
  115.      { SYM_PCHAR, S_pit, "S_pit" },
  116.      { SYM_PCHAR, S_spiked_pit, "S_spiked_pit" },
  117.      { SYM_PCHAR, S_hole, "S_hole" },
  118.      { SYM_PCHAR, S_trap_door, "S_trap_door" },
  119.      { SYM_PCHAR, S_teleportation_trap, "S_teleportation_trap" },
  120.      { SYM_PCHAR, S_level_teleporter, "S_level_teleporter" },
  121.      { SYM_PCHAR, S_magic_portal, "S_magic_portal" },
  122.      { SYM_PCHAR, S_web, "S_web" },
  123.      { SYM_PCHAR, S_statue_trap, "S_statue_trap" },
  124.      { SYM_PCHAR, S_magic_trap, "S_magic_trap" },
  125.      { SYM_PCHAR, S_anti_magic_trap, "S_anti_magic_trap" },
  126.      { SYM_PCHAR, S_polymorph_trap, "S_polymorph_trap" },
  127.      { SYM_PCHAR, S_vibrating_square, "S_vibrating_square" },
  128.      { SYM_PCHAR, S_vbeam, "S_vbeam" },
  129.      { SYM_PCHAR, S_hbeam, "S_hbeam" },
  130.      { SYM_PCHAR, S_lslant, "S_lslant" },
  131.      { SYM_PCHAR, S_rslant, "S_rslant" },
  132.      { SYM_PCHAR, S_digbeam, "S_digbeam" },
  133.      { SYM_PCHAR, S_flashbeam, "S_flashbeam" },
  134.      { SYM_PCHAR, S_boomleft, "S_boomleft" },
  135.      { SYM_PCHAR, S_boomright, "S_boomright" },
  136.      { SYM_PCHAR, S_goodpos, "S_goodpos" },
  137.      { SYM_PCHAR, S_ss1, "S_ss1" },
  138.      { SYM_PCHAR, S_ss2, "S_ss2" },
  139.      { SYM_PCHAR, S_ss3, "S_ss3" },
  140.      { SYM_PCHAR, S_ss4, "S_ss4" },
  141.      { SYM_PCHAR, S_sw_tl, "S_sw_tl" },
  142.      { SYM_PCHAR, S_sw_tc, "S_sw_tc" },
  143.      { SYM_PCHAR, S_sw_tr, "S_sw_tr" },
  144.      { SYM_PCHAR, S_sw_ml, "S_sw_ml" },
  145.      { SYM_PCHAR, S_sw_mr, "S_sw_mr" },
  146.      { SYM_PCHAR, S_sw_bl, "S_sw_bl" },
  147.      { SYM_PCHAR, S_sw_bc, "S_sw_bc" },
  148.      { SYM_PCHAR, S_sw_br, "S_sw_br" },
  149.      { SYM_PCHAR, S_explode1, "S_explode1" },
  150.      { SYM_PCHAR, S_explode2, "S_explode2" },
  151.      { SYM_PCHAR, S_explode3, "S_explode3" },
  152.      { SYM_PCHAR, S_explode4, "S_explode4" },
  153.      { SYM_PCHAR, S_explode5, "S_explode5" },
  154.      { SYM_PCHAR, S_explode6, "S_explode6" },
  155.      { SYM_PCHAR, S_explode7, "S_explode7" },
  156.      { SYM_PCHAR, S_explode8, "S_explode8" },
  157.      { SYM_PCHAR, S_explode9, "S_explode9" },
  158.      { SYM_OC, ILLOBJ_CLASS + SYM_OFF_O, "S_strange_obj" },
  159.      { SYM_OC, WEAPON_CLASS + SYM_OFF_O, "S_weapon" },
  160.      { SYM_OC, ARMOR_CLASS + SYM_OFF_O, "S_armor" },
  161.      { SYM_OC, ARMOR_CLASS + SYM_OFF_O, "S_armour" },
  162.      { SYM_OC, RING_CLASS + SYM_OFF_O, "S_ring" },
  163.      { SYM_OC, AMULET_CLASS + SYM_OFF_O, "S_amulet" },
  164.      { SYM_OC, TOOL_CLASS + SYM_OFF_O, "S_tool" },
  165.      { SYM_OC, FOOD_CLASS + SYM_OFF_O, "S_food" },
  166.      { SYM_OC, POTION_CLASS + SYM_OFF_O, "S_potion" },
  167.      { SYM_OC, SCROLL_CLASS + SYM_OFF_O, "S_scroll" },
  168.      { SYM_OC, SPBOOK_CLASS + SYM_OFF_O, "S_book" },
  169.      { SYM_OC, WAND_CLASS + SYM_OFF_O, "S_wand" },
  170.      { SYM_OC, COIN_CLASS + SYM_OFF_O, "S_coin" },
  171.      { SYM_OC, GEM_CLASS + SYM_OFF_O, "S_gem" },
  172.      { SYM_OC, ROCK_CLASS + SYM_OFF_O, "S_rock" },
  173.      { SYM_OC, BALL_CLASS + SYM_OFF_O, "S_ball" },
  174.      { SYM_OC, CHAIN_CLASS + SYM_OFF_O, "S_chain" },
  175.      { SYM_OC, VENOM_CLASS + SYM_OFF_O, "S_venom" },
  176.      { SYM_MON, S_ANT + SYM_OFF_M, "S_ant" },
  177.      { SYM_MON, S_BLOB + SYM_OFF_M, "S_blob" },
  178.      { SYM_MON, S_COCKATRICE + SYM_OFF_M, "S_cockatrice" },
  179.      { SYM_MON, S_DOG + SYM_OFF_M, "S_dog" },
  180.      { SYM_MON, S_EYE + SYM_OFF_M, "S_eye" },
  181.      { SYM_MON, S_FELINE + SYM_OFF_M, "S_feline" },
  182.      { SYM_MON, S_GREMLIN + SYM_OFF_M, "S_gremlin" },
  183.      { SYM_MON, S_HUMANOID + SYM_OFF_M, "S_humanoid" },
  184.      { SYM_MON, S_IMP + SYM_OFF_M, "S_imp" },
  185.      { SYM_MON, S_JELLY + SYM_OFF_M, "S_jelly" },
  186.      { SYM_MON, S_KOBOLD + SYM_OFF_M, "S_kobold" },
  187.      { SYM_MON, S_LEPRECHAUN + SYM_OFF_M, "S_leprechaun" },
  188.      { SYM_MON, S_MIMIC + SYM_OFF_M, "S_mimic" },
  189.      { SYM_MON, S_NYMPH + SYM_OFF_M, "S_nymph" },
  190.      { SYM_MON, S_ORC + SYM_OFF_M, "S_orc" },
  191.      { SYM_MON, S_PIERCER + SYM_OFF_M, "S_piercer" },
  192.      { SYM_MON, S_QUADRUPED + SYM_OFF_M, "S_quadruped" },
  193.      { SYM_MON, S_RODENT + SYM_OFF_M, "S_rodent" },
  194.      { SYM_MON, S_SPIDER + SYM_OFF_M, "S_spider" },
  195.      { SYM_MON, S_TRAPPER + SYM_OFF_M, "S_trapper" },
  196.      { SYM_MON, S_UNICORN + SYM_OFF_M, "S_unicorn" },
  197.      { SYM_MON, S_VORTEX + SYM_OFF_M, "S_vortex" },
  198.      { SYM_MON, S_WORM + SYM_OFF_M, "S_worm" },
  199.      { SYM_MON, S_XAN + SYM_OFF_M, "S_xan" },
  200.      { SYM_MON, S_LIGHT + SYM_OFF_M, "S_light" },
  201.      { SYM_MON, S_ZRUTY + SYM_OFF_M, "S_zruty" },
  202.      { SYM_MON, S_ANGEL + SYM_OFF_M, "S_angel" },
  203.      { SYM_MON, S_BAT + SYM_OFF_M, "S_bat" },
  204.      { SYM_MON, S_CENTAUR + SYM_OFF_M, "S_centaur" },
  205.      { SYM_MON, S_DRAGON + SYM_OFF_M, "S_dragon" },
  206.      { SYM_MON, S_ELEMENTAL + SYM_OFF_M, "S_elemental" },
  207.      { SYM_MON, S_FUNGUS + SYM_OFF_M, "S_fungus" },
  208.      { SYM_MON, S_GNOME + SYM_OFF_M, "S_gnome" },
  209.      { SYM_MON, S_GIANT + SYM_OFF_M, "S_giant" },
  210.      { SYM_MON, S_JABBERWOCK + SYM_OFF_M, "S_jabberwock" },
  211.      { SYM_MON, S_KOP + SYM_OFF_M, "S_kop" },
  212.      { SYM_MON, S_LICH + SYM_OFF_M, "S_lich" },
  213.      { SYM_MON, S_MUMMY + SYM_OFF_M, "S_mummy" },
  214.      { SYM_MON, S_NAGA + SYM_OFF_M, "S_naga" },
  215.      { SYM_MON, S_OGRE + SYM_OFF_M, "S_ogre" },
  216.      { SYM_MON, S_PUDDING + SYM_OFF_M, "S_pudding" },
  217.      { SYM_MON, S_QUANTMECH + SYM_OFF_M, "S_quantmech" },
  218.      { SYM_MON, S_RUSTMONST + SYM_OFF_M, "S_rustmonst" },
  219.      { SYM_MON, S_SNAKE + SYM_OFF_M, "S_snake" },
  220.      { SYM_MON, S_TROLL + SYM_OFF_M, "S_troll" },
  221.      { SYM_MON, S_UMBER + SYM_OFF_M, "S_umber" },
  222.      { SYM_MON, S_VAMPIRE + SYM_OFF_M, "S_vampire" },
  223.      { SYM_MON, S_WRAITH + SYM_OFF_M, "S_wraith" },
  224.      { SYM_MON, S_XORN + SYM_OFF_M, "S_xorn" },
  225.      { SYM_MON, S_YETI + SYM_OFF_M, "S_yeti" },
  226.      { SYM_MON, S_ZOMBIE + SYM_OFF_M, "S_zombie" },
  227.      { SYM_MON, S_HUMAN + SYM_OFF_M, "S_human" },
  228.      { SYM_MON, S_GHOST + SYM_OFF_M, "S_ghost" },
  229.      { SYM_MON, S_GOLEM + SYM_OFF_M, "S_golem" },
  230.      { SYM_MON, S_DEMON + SYM_OFF_M, "S_demon" },
  231.      { SYM_MON, S_EEL + SYM_OFF_M, "S_eel" },
  232.      { SYM_MON, S_LIZARD + SYM_OFF_M, "S_lizard" },
  233.      { SYM_MON, S_WORM_TAIL + SYM_OFF_M, "S_worm_tail" },
  234.      { SYM_MON, S_MIMIC_DEF + SYM_OFF_M, "S_mimic_def" },
  235.      { SYM_OTH, SYM_BOULDER + SYM_OFF_X, "S_boulder" },
  236.      { SYM_OTH, SYM_INVISIBLE + SYM_OFF_X, "S_invisible" },
  237.      { 0, 0, (const char *) 0 } /* fence post */
  238.  };
  239.  
  240.  /*drawing.c*/