Source:NetHack 3.4.3/src/drawing.c

From NetHackWiki
(Redirected from Source:Ref/assign graphics)
Jump to: navigation, search

Below is the full text to src/drawing.c from NetHack 3.4.3. To link to a particular line, write [[drawing.c#line123]], for example. This file defines several graphics sets; a basic one that Nethack calls ASCII; IBM, DEC, MAC, and two special sets for the rogue level, one if you are using the IBM set and one if you aren't. It also defines functions for swapping these graphics sets in.

Top of file

  1. /*	SCCS Id: @(#)drawing.c	3.4	1999/12/02	*/
  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. #include "hack.h"
  2. #include "tcap.h"
  3.  
  4. /* Relevent header information in rm.h and objclass.h. */

Note that {1, 2, 3,} is syntactically valid, so if this macro leaves a trailing comma at the end of an array it's no big deal.

  1. #ifdef C
  2. #undef C
  3. #endif
  4.  
  5. #ifdef TEXTCOLOR
  6. #define C(n) n
  7. #else
  8. #define C(n)
  9. #endif

0 means use the default symbol. The 0 will actually be replaced by the default symbol in drawing.c#assign_graphics

  1. #define g_FILLER(symbol) 0

DUMMY is defined as "{ 0 }" in hack.h, so these arrays are zerod.

  1. uchar oc_syms[MAXOCLASSES] = DUMMY; /* the current object  display symbols */
  2. uchar showsyms[MAXPCHARS]  = DUMMY; /* the current feature display symbols */
  3. uchar monsyms[MAXMCLASSES] = DUMMY; /* the current monster display symbols */
  4. uchar warnsyms[WARNCOUNT]  = DUMMY;  /* the current warning display symbols */

The symbols for monsters and items are defined via macros in objclass.h and monsym.h but placed into arrays in this file.

  1. /* Default object class symbols.  See objclass.h. */
  2. const char def_oc_syms[MAXOCLASSES] = {
  3. /* 0*/	'\0',		/* placeholder for the "random class" */
  4. 	ILLOBJ_SYM,
  5. 	WEAPON_SYM,
  6. 	ARMOR_SYM,
  7. 	RING_SYM,
  8. /* 5*/	AMULET_SYM,
  9. 	TOOL_SYM,
  10. 	FOOD_SYM,
  11. 	POTION_SYM,
  12. 	SCROLL_SYM,
  13. /*10*/	SPBOOK_SYM,
  14. 	WAND_SYM,
  15. 	GOLD_SYM,
  16. 	GEM_SYM,
  17. 	ROCK_SYM,
  18. /*15*/	BALL_SYM,
  19. 	CHAIN_SYM,
  20. 	VENOM_SYM
  21. };

This next part is for farlooking.

  1. const char invisexplain[] = "remembered, unseen, creature";
  2.  
  3. /* Object descriptions.  Used in do_look(). */
  4. const char * const objexplain[] = {	/* these match def_oc_syms, above */
  5. /* 0*/	0,
  6. 	"strange object",
  7. 	"weapon",
  8. 	"suit or piece of armor",
  9. 	"ring",
  10. /* 5*/	"amulet",
  11. 	"useful item (pick-axe, key, lamp...)",
  12. 	"piece of food",
  13. 	"potion",
  14. 	"scroll",
  15. /*10*/	"spellbook",
  16. 	"wand",
  17. 	"pile of coins",
  18. 	"gem or rock",
  19. 	"boulder or statue",
  20. /*15*/	"iron ball",
  21. 	"iron chain",
  22. 	"splash of venom"
  23. };
  24.  
  25. /* Object class names.  Used in object_detect(). */
  26. const char * const oclass_names[] = {
  27. /* 0*/	0,
  28. 	"illegal objects",
  29. 	"weapons",
  30. 	"armor",
  31. 	"rings",
  32. /* 5*/	"amulets",
  33. 	"tools",
  34. 	"food",
  35. 	"potions",
  36. 	"scrolls",
  37. /*10*/	"spellbooks",
  38. 	"wands",
  39. 	"coins",
  40. 	"rocks",
  41. 	"large stones",
  42. /*15*/	"iron balls",
  43. 	"chains",
  44. 	"venoms"
  45. };

Back to filling in arrays. The null in the middle of this array between DEF_GIANT "H" and DEF_JABBERWOCK "J" is the letter "I", which corresponds to the gap between S_GIANT 34 and S_JABBERWOCK 36. This is an artifact of the fact that stalkers used to be represented by "I" until they were moved under "E".

  1. /* Default monster class symbols.  See monsym.h. */
  2. const char def_monsyms[MAXMCLASSES] = {
  3. 	'\0',		/* holder */
  4. 	DEF_ANT,
  5. 	DEF_BLOB,
  6. 	DEF_COCKATRICE,
  7. 	DEF_DOG,
  8. 	DEF_EYE,
  9. 	DEF_FELINE,
  10. 	DEF_GREMLIN,
  11. 	DEF_HUMANOID,
  12. 	DEF_IMP,
  13. 	DEF_JELLY,		/* 10 */
  14. 	DEF_KOBOLD,
  15. 	DEF_LEPRECHAUN,
  16. 	DEF_MIMIC,
  17. 	DEF_NYMPH,
  18. 	DEF_ORC,
  19. 	DEF_PIERCER,
  20. 	DEF_QUADRUPED,
  21. 	DEF_RODENT,
  22. 	DEF_SPIDER,
  23. 	DEF_TRAPPER,		/* 20 */
  24. 	DEF_UNICORN,
  25. 	DEF_VORTEX,
  26. 	DEF_WORM,
  27. 	DEF_XAN,
  28. 	DEF_LIGHT,
  29. 	DEF_ZRUTY,
  30. 	DEF_ANGEL,
  31. 	DEF_BAT,
  32. 	DEF_CENTAUR,
  33. 	DEF_DRAGON,		/* 30 */
  34. 	DEF_ELEMENTAL,
  35. 	DEF_FUNGUS,
  36. 	DEF_GNOME,
  37. 	DEF_GIANT,
  38. 	'\0',
  39. 	DEF_JABBERWOCK,
  40. 	DEF_KOP,
  41. 	DEF_LICH,
  42. 	DEF_MUMMY,
  43. 	DEF_NAGA,		/* 40 */
  44. 	DEF_OGRE,
  45. 	DEF_PUDDING,
  46. 	DEF_QUANTMECH,
  47. 	DEF_RUSTMONST,
  48. 	DEF_SNAKE,
  49. 	DEF_TROLL,
  50. 	DEF_UMBER,
  51. 	DEF_VAMPIRE,
  52. 	DEF_WRAITH,
  53. 	DEF_XORN,		/* 50 */
  54. 	DEF_YETI,
  55. 	DEF_ZOMBIE,
  56. 	DEF_HUMAN,
  57. 	DEF_GHOST,
  58. 	DEF_GOLEM,
  59. 	DEF_DEMON,
  60. 	DEF_EEL,
  61. 	DEF_LIZARD,
  62. 	DEF_WORM_TAIL,
  63. 	DEF_MIMIC_DEF,		/* 60 */
  64. };

Back to farlooking.

  1. /* The explanations below are also used when the user gives a string
  2. * for blessed genocide, so no text should wholly contain any later
  3. * text.  They should also always contain obvious names (eg. cat/feline).
  4. */
  5. const char * const monexplain[MAXMCLASSES] = {
  6. 0,
  7. "ant or other insect",	"blob",			"cockatrice",
  8. "dog or other canine",	"eye or sphere",	"cat or other feline",
  9. "gremlin",			"humanoid",		"imp or minor demon",
  10. "jelly",			"kobold",		"leprechaun",
  11. "mimic",			"nymph",		"orc",
  12. "piercer",			"quadruped",		"rodent",
  13. "arachnid or centipede",	"trapper or lurker above", "unicorn or horse",
  14. "vortex",		"worm", "xan or other mythical/fantastic insect",
  15. "light",			"zruty",
  16.  
  17. "angelic being",		"bat or bird",		"centaur",
  18. "dragon",			"elemental",		"fungus or mold",
  19. "gnome",			"giant humanoid",	0,
  20. "jabberwock",		"Keystone Kop",		"lich",
  21. "mummy",			"naga",			"ogre",
  22. "pudding or ooze",		"quantum mechanic",	"rust monster or disenchanter",
  23. "snake",			"troll",		"umber hulk",
  24. "vampire",			"wraith",		"xorn",
  25. "apelike creature",		"zombie",
  26.  
  27. "human or elf",		"ghost",		"golem",
  28. "major demon",		"sea monster",		"lizard",
  29. "long worm tail",		"mimic"
  30. };
  31.  
  32. const struct symdef def_warnsyms[WARNCOUNT] = {
  33. 	{'0', "unknown creature causing you worry", C(CLR_WHITE)},  	/* white warning  */
  34. 	{'1', "unknown creature causing you concern", C(CLR_RED)},	/* pink warning   */
  35. 	{'2', "unknown creature causing you anxiety", C(CLR_RED)},	/* red warning    */
  36. 	{'3', "unknown creature causing you disquiet", C(CLR_RED)},	/* ruby warning   */
  37. 	{'4', "unknown creature causing you alarm",
  38. 						C(CLR_MAGENTA)},        /* purple warning */
  39. 	{'5', "unknown creature causing you dread",
  40. 						C(CLR_BRIGHT_MAGENTA)}	/* black warning  */
  41. };

Default graphics style

  1. /*
  2. *  Default screen symbols with explanations and colors.
  3. *  Note:  {ibm|dec|mac}_graphics[] arrays also depend on this symbol order.
  4. */
  5. const struct symdef defsyms[MAXPCHARS] = {
  6. /* 0*/	{' ', "dark part of a room",C(NO_COLOR)},	/* stone */
  7. 	{'|', "wall",		C(CLR_GRAY)},	/* vwall */
  8. 	{'-', "wall",		C(CLR_GRAY)},	/* hwall */
  9. 	{'-', "wall",		C(CLR_GRAY)},	/* tlcorn */
  10. 	{'-', "wall",		C(CLR_GRAY)},	/* trcorn */
  11. 	{'-', "wall",		C(CLR_GRAY)},	/* blcorn */
  12. 	{'-', "wall",		C(CLR_GRAY)},	/* brcorn */
  13. 	{'-', "wall",		C(CLR_GRAY)},	/* crwall */
  14. 	{'-', "wall",		C(CLR_GRAY)},	/* tuwall */
  15. 	{'-', "wall",		C(CLR_GRAY)},	/* tdwall */
  16. /*10*/	{'|', "wall",		C(CLR_GRAY)},	/* tlwall */
  17. 	{'|', "wall",		C(CLR_GRAY)},	/* trwall */
  18. 	{'.', "doorway",	C(CLR_GRAY)},	/* ndoor */
  19. 	{'-', "open door",	C(CLR_BROWN)},	/* vodoor */
  20. 	{'|', "open door",	C(CLR_BROWN)},	/* hodoor */
  21. 	{'+', "closed door",	C(CLR_BROWN)},	/* vcdoor */
  22. 	{'+', "closed door",	C(CLR_BROWN)},	/* hcdoor */
  23. 	{'#', "iron bars",	C(HI_METAL)},	/* bars */
  24. 	{'#', "tree",		C(CLR_GREEN)},	/* tree */
  25. 	{'.', "floor of a room",C(CLR_GRAY)},	/* room */
  26. /*20*/	{'#', "corridor",	C(CLR_GRAY)},	/* dark corr */
  27. 	{'#', "lit corridor",	C(CLR_GRAY)},	/* lit corr (see mapglyph.c) */
  28. 	{'<', "staircase up",	C(CLR_GRAY)},	/* upstair */
  29. 	{'>', "staircase down",	C(CLR_GRAY)},	/* dnstair */
  30. 	{'<', "ladder up",	C(CLR_BROWN)},	/* upladder */
  31. 	{'>', "ladder down",	C(CLR_BROWN)},	/* dnladder */
  32. 	{'_', "altar",		C(CLR_GRAY)},	/* altar */
  33. 	{'|', "grave",      C(CLR_GRAY)},   /* grave */
  34. 	{'\\', "opulent throne",C(HI_GOLD)},	/* throne */
  35. #ifdef SINKS
  36. 	{'#', "sink",		C(CLR_GRAY)},	/* sink */
  37. #else
  38. 	{'#', "",		C(CLR_GRAY)},	/* sink */
  39. #endif
  40. /*30*/	{'{', "fountain",	C(CLR_BLUE)},	/* fountain */
  41. 	{'}', "water",		C(CLR_BLUE)},	/* pool */
  42. 	{'.', "ice",		C(CLR_CYAN)},	/* ice */
  43. 	{'}', "molten lava",	C(CLR_RED)},	/* lava */
  44. 	{'.', "lowered drawbridge",C(CLR_BROWN)},	/* vodbridge */
  45. 	{'.', "lowered drawbridge",C(CLR_BROWN)},	/* hodbridge */
  46. 	{'#', "raised drawbridge",C(CLR_BROWN)},/* vcdbridge */
  47. 	{'#', "raised drawbridge",C(CLR_BROWN)},/* hcdbridge */
  48. 	{' ', "air",		C(CLR_CYAN)},	/* open air */
  49. 	{'#', "cloud",		C(CLR_GRAY)},	/* [part of] a cloud */
  50. /*40*/	{'}', "water",		C(CLR_BLUE)},	/* under water */
  51. 	{'^', "arrow trap",	C(HI_METAL)},	/* trap */
  52. 	{'^', "dart trap",	C(HI_METAL)},	/* trap */
  53. 	{'^', "falling rock trap",C(CLR_GRAY)},	/* trap */
  54. 	{'^', "squeaky board",	C(CLR_BROWN)},	/* trap */
  55. 	{'^', "bear trap",	C(HI_METAL)},	/* trap */
  56. 	{'^', "land mine",	C(CLR_RED)},	/* trap */
  57. 	{'^', "rolling boulder trap",	C(CLR_GRAY)},	/* trap */
  58. 	{'^', "sleeping gas trap",C(HI_ZAP)},	/* trap */
  59. 	{'^', "rust trap",	C(CLR_BLUE)},	/* trap */
  60. /*50*/	{'^', "fire trap",	C(CLR_ORANGE)},	/* trap */
  61. 	{'^', "pit",		C(CLR_BLACK)},	/* trap */
  62. 	{'^', "spiked pit",	C(CLR_BLACK)},	/* trap */
  63. 	{'^', "hole",	C(CLR_BROWN)},	/* trap */
  64. 	{'^', "trap door",	C(CLR_BROWN)},	/* trap */
  65. 	{'^', "teleportation trap", C(CLR_MAGENTA)},	/* trap */
  66. 	{'^', "level teleporter", C(CLR_MAGENTA)},	/* trap */
  67. 	{'^', "magic portal",	C(CLR_BRIGHT_MAGENTA)},	/* trap */
  68. 	{'"', "web",		C(CLR_GRAY)},	/* web */
  69. 	{'^', "statue trap",	C(CLR_GRAY)},	/* trap */
  70. /*60*/	{'^', "magic trap",	C(HI_ZAP)},	/* trap */
  71. 	{'^', "anti-magic field", C(HI_ZAP)},	/* trap */
  72. 	{'^', "polymorph trap",	C(CLR_BRIGHT_GREEN)},	/* trap */
  73. 	{'|', "wall",		C(CLR_GRAY)},	/* vbeam */
  74. 	{'-', "wall",		C(CLR_GRAY)},	/* hbeam */
  75. 	{'\\',"wall",		C(CLR_GRAY)},	/* lslant */
  76. 	{'/', "wall",		C(CLR_GRAY)},	/* rslant */
  77. 	{'*', "",		C(CLR_WHITE)},	/* dig beam */
  78. 	{'!', "",		C(CLR_WHITE)},	/* camera flash beam */
  79. 	{')', "",		C(HI_WOOD)},	/* boomerang open left */
  80. /*70*/	{'(', "",		C(HI_WOOD)},	/* boomerang open right */
  81. 	{'0', "",		C(HI_ZAP)},	/* 4 magic shield symbols */
  82. 	{'#', "",		C(HI_ZAP)},
  83. 	{'@', "",		C(HI_ZAP)},
  84. 	{'*', "",		C(HI_ZAP)},
  85. 	{'/', "",		C(CLR_GREEN)},	/* swallow top left	*/
  86. 	{'-', "",		C(CLR_GREEN)},	/* swallow top center	*/
  87. 	{'\\', "",		C(CLR_GREEN)},	/* swallow top right	*/
  88. 	{'|', "",		C(CLR_GREEN)},	/* swallow middle left	*/
  89. 	{'|', "",		C(CLR_GREEN)},	/* swallow middle right	*/
  90. /*80*/	{'\\', "",		C(CLR_GREEN)},	/* swallow bottom left	*/
  91. 	{'-', "",		C(CLR_GREEN)},	/* swallow bottom center*/
  92. 	{'/', "",		C(CLR_GREEN)},	/* swallow bottom right	*/
  93. 	{'/', "",		C(CLR_ORANGE)},	/* explosion top left     */
  94. 	{'-', "",		C(CLR_ORANGE)},	/* explosion top center   */
  95. 	{'\\', "",		C(CLR_ORANGE)},	/* explosion top right    */
  96. 	{'|', "",		C(CLR_ORANGE)},	/* explosion middle left  */
  97. 	{' ', "",		C(CLR_ORANGE)},	/* explosion middle center*/
  98. 	{'|', "",		C(CLR_ORANGE)},	/* explosion middle right */
  99. 	{'\\', "",		C(CLR_ORANGE)},	/* explosion bottom left  */
  100. /*90*/	{'-', "",		C(CLR_ORANGE)},	/* explosion bottom center*/
  101. 	{'/', "",		C(CLR_ORANGE)},	/* explosion bottom right */
  102. /*
  103. *  Note: Additions to this array should be reflected in the
  104. *	  {ibm,dec,mac}_graphics[] arrays below.
  105. */
  106. };
  107.  
  108. #undef C
  109.  
  110. #ifdef ASCIIGRAPH
  111.  
  112. #ifdef PC9800
  113. void NDECL((*ibmgraphics_mode_callback)) = 0;	/* set in tty_start_screen() */
  114. #endif /* PC9800 */

IBMgraphics

  1. static uchar ibm_graphics[MAXPCHARS] = {
  2. /* 0*/	g_FILLER(S_stone),
  3. 	0xb3,	/* S_vwall:	meta-3, vertical rule */
  4. 	0xc4,	/* S_hwall:	meta-D, horizontal rule */
  5. 	0xda,	/* S_tlcorn:	meta-Z, top left corner */
  6. 	0xbf,	/* S_trcorn:	meta-?, top right corner */
  7. 	0xc0,	/* S_blcorn:	meta-@, bottom left */
  8. 	0xd9,	/* S_brcorn:	meta-Y, bottom right */
  9. 	0xc5,	/* S_crwall:	meta-E, cross */
  10. 	0xc1,	/* S_tuwall:	meta-A, T up */
  11. 	0xc2,	/* S_tdwall:	meta-B, T down */
  12. /*10*/	0xb4,	/* S_tlwall:	meta-4, T left */
  13. 	0xc3,	/* S_trwall:	meta-C, T right */
  14. 	0xfa,	/* S_ndoor:	meta-z, centered dot */
  15. 	0xfe,	/* S_vodoor:	meta-~, small centered square */
  16. 	0xfe,	/* S_hodoor:	meta-~, small centered square */
  17. 	g_FILLER(S_vcdoor),
  18. 	g_FILLER(S_hcdoor),
  19. 	240,	/* S_bars:	equivalence symbol */
  20. 	241,	/* S_tree:	plus or minus symbol */
  21. 	0xfa,	/* S_room:	meta-z, centered dot */
  22. /*20*/	0xb0,	/* S_corr:	meta-0, light shading */
  23. 	0xb1,	/* S_litcorr:	meta-1, medium shading */
  24. 	g_FILLER(S_upstair),
  25. 	g_FILLER(S_dnstair),
  26. 	g_FILLER(S_upladder),
  27. 	g_FILLER(S_dnladder),
  28. 	g_FILLER(S_altar),
  29. 	g_FILLER(S_grave),
  30. 	g_FILLER(S_throne),
  31. 	g_FILLER(S_sink),
  32. /*30*/	0xf4,	/* S_fountain:	meta-t, integral top half */
  33. 	0xf7,	/* S_pool:	meta-w, approx. equals */
  34. 	0xfa,	/* S_ice:	meta-z, centered dot */
  35. 	0xf7,	/* S_lava:	meta-w, approx. equals */
  36. 	0xfa,	/* S_vodbridge:	meta-z, centered dot */
  37. 	0xfa,	/* S_hodbridge:	meta-z, centered dot */
  38. 	g_FILLER(S_vcdbridge),
  39. 	g_FILLER(S_hcdbridge),
  40. 	g_FILLER(S_air),
  41. 	g_FILLER(S_cloud),
  42. /*40*/	0xf7,	/* S_water:	meta-w, approx. equals */
  43. 	g_FILLER(S_arrow_trap),
  44. 	g_FILLER(S_dart_trap),
  45. 	g_FILLER(S_falling_rock_trap),
  46. 	g_FILLER(S_squeaky_board),
  47. 	g_FILLER(S_bear_trap),
  48. 	g_FILLER(S_land_mine),
  49. 	g_FILLER(S_rolling_boulder_trap),
  50. 	g_FILLER(S_sleeping_gas_trap),
  51. 	g_FILLER(S_rust_trap),
  52. /*50*/	g_FILLER(S_fire_trap),
  53. 	g_FILLER(S_pit),
  54. 	g_FILLER(S_spiked_pit),
  55. 	g_FILLER(S_hole),
  56. 	g_FILLER(S_trap_door),
  57. 	g_FILLER(S_teleportation_trap),
  58. 	g_FILLER(S_level_teleporter),
  59. 	g_FILLER(S_magic_portal),
  60. 	g_FILLER(S_web),
  61. 	g_FILLER(S_statue_trap),
  62. /*60*/	g_FILLER(S_magic_trap),
  63. 	g_FILLER(S_anti_magic_trap),
  64. 	g_FILLER(S_polymorph_trap),
  65. 	0xb3,	/* S_vbeam:	meta-3, vertical rule */
  66. 	0xc4,	/* S_hbeam:	meta-D, horizontal rule */
  67. 	g_FILLER(S_lslant),
  68. 	g_FILLER(S_rslant),
  69. 	g_FILLER(S_digbeam),
  70. 	g_FILLER(S_flashbeam),
  71. 	g_FILLER(S_boomleft),
  72. /*70*/	g_FILLER(S_boomright),
  73. 	g_FILLER(S_ss1),
  74. 	g_FILLER(S_ss2),
  75. 	g_FILLER(S_ss3),
  76. 	g_FILLER(S_ss4),
  77. 	g_FILLER(S_sw_tl),
  78. 	g_FILLER(S_sw_tc),
  79. 	g_FILLER(S_sw_tr),
  80. 	0xb3,	/* S_sw_ml:	meta-3, vertical rule */
  81. 	0xb3,	/* S_sw_mr:	meta-3, vertical rule */
  82. /*80*/	g_FILLER(S_sw_bl),
  83. 	g_FILLER(S_sw_bc),
  84. 	g_FILLER(S_sw_br),
  85. 	g_FILLER(S_explode1),
  86. 	g_FILLER(S_explode2),
  87. 	g_FILLER(S_explode3),
  88. 	0xb3,	/* S_explode4:	meta-3, vertical rule */
  89. 	g_FILLER(S_explode5),
  90. 	0xb3,	/* S_explode6:	meta-3, vertical rule */
  91. 	g_FILLER(S_explode7),
  92. /*90*/	g_FILLER(S_explode8),
  93. 	g_FILLER(S_explode9)
  94. };
  95. #endif  /* ASCIIGRAPH */
  96.  
  97. #ifdef TERMLIB
  98. void NDECL((*decgraphics_mode_callback)) = 0;  /* set in tty_start_screen() */

DECgraphics

  1. static uchar dec_graphics[MAXPCHARS] = {
  2. /* 0*/	g_FILLER(S_stone),
  3. 	0xf8,	/* S_vwall:	meta-x, vertical rule */
  4. 	0xf1,	/* S_hwall:	meta-q, horizontal rule */
  5. 	0xec,	/* S_tlcorn:	meta-l, top left corner */
  6. 	0xeb,	/* S_trcorn:	meta-k, top right corner */
  7. 	0xed,	/* S_blcorn:	meta-m, bottom left */
  8. 	0xea,	/* S_brcorn:	meta-j, bottom right */
  9. 	0xee,	/* S_crwall:	meta-n, cross */
  10. 	0xf6,	/* S_tuwall:	meta-v, T up */
  11. 	0xf7,	/* S_tdwall:	meta-w, T down */
  12. /*10*/	0xf5,	/* S_tlwall:	meta-u, T left */
  13. 	0xf4,	/* S_trwall:	meta-t, T right */
  14. 	0xfe,	/* S_ndoor:	meta-~, centered dot */
  15. 	0xe1,	/* S_vodoor:	meta-a, solid block */
  16. 	0xe1,	/* S_hodoor:	meta-a, solid block */
  17. 	g_FILLER(S_vcdoor),
  18. 	g_FILLER(S_hcdoor),
  19. 	0xfb,	/* S_bars:	meta-{, small pi */
  20. 	0xe7,	/* S_tree:	meta-g, plus-or-minus */
  21. 	0xfe,	/* S_room:	meta-~, centered dot */
  22. /*20*/	g_FILLER(S_corr),
  23. 	g_FILLER(S_litcorr),
  24. 	g_FILLER(S_upstair),
  25. 	g_FILLER(S_dnstair),
  26. 	0xf9,	/* S_upladder:	meta-y, greater-than-or-equals */
  27. 	0xfa,	/* S_dnladder:	meta-z, less-than-or-equals */
  28. 	g_FILLER(S_altar),	/* 0xc3, \E)3: meta-C, dagger */
  29. 	g_FILLER(S_grave),
  30. 	g_FILLER(S_throne),
  31. 	g_FILLER(S_sink),
  32. /*30*/	g_FILLER(S_fountain),	/* 0xdb, \E)3: meta-[, integral top half */
  33. 	0xe0,	/* S_pool:	meta-\, diamond */
  34. 	0xfe,	/* S_ice:	meta-~, centered dot */
  35. 	0xe0,	/* S_lava:	meta-\, diamond */
  36. 	0xfe,	/* S_vodbridge:	meta-~, centered dot */
  37. 	0xfe,	/* S_hodbridge:	meta-~, centered dot */
  38. 	g_FILLER(S_vcdbridge),
  39. 	g_FILLER(S_hcdbridge),
  40. 	g_FILLER(S_air),
  41. 	g_FILLER(S_cloud),
  42. /*40*/	0xe0,	/* S_water:	meta-\, diamond */
  43. 	g_FILLER(S_arrow_trap),
  44. 	g_FILLER(S_dart_trap),
  45. 	g_FILLER(S_falling_rock_trap),
  46. 	g_FILLER(S_squeaky_board),
  47. 	g_FILLER(S_bear_trap),
  48. 	g_FILLER(S_land_mine),
  49. 	g_FILLER(S_rolling_boulder_trap),
  50. 	g_FILLER(S_sleeping_gas_trap),
  51. 	g_FILLER(S_rust_trap),
  52. /*50*/	g_FILLER(S_fire_trap),
  53. 	g_FILLER(S_pit),
  54. 	g_FILLER(S_spiked_pit),
  55. 	g_FILLER(S_hole),
  56. 	g_FILLER(S_trap_door),
  57. 	g_FILLER(S_teleportation_trap),
  58. 	g_FILLER(S_level_teleporter),
  59. 	g_FILLER(S_magic_portal),
  60. 	g_FILLER(S_web),	/* 0xbd, \E)3: meta-=, int'l currency */
  61. 	g_FILLER(S_statue_trap),
  62. /*60*/	g_FILLER(S_magic_trap),
  63. 	g_FILLER(S_anti_magic_trap),
  64. 	g_FILLER(S_polymorph_trap),
  65. 	0xf8,	/* S_vbeam:	meta-x, vertical rule */
  66. 	0xf1,	/* S_hbeam:	meta-q, horizontal rule */
  67. 	g_FILLER(S_lslant),
  68. 	g_FILLER(S_rslant),
  69. 	g_FILLER(S_digbeam),
  70. 	g_FILLER(S_flashbeam),
  71. 	g_FILLER(S_boomleft),
  72. /*70*/	g_FILLER(S_boomright),
  73. 	g_FILLER(S_ss1),
  74. 	g_FILLER(S_ss2),
  75. 	g_FILLER(S_ss3),
  76. 	g_FILLER(S_ss4),
  77. 	g_FILLER(S_sw_tl),
  78. 	0xef,	/* S_sw_tc:	meta-o, high horizontal line */
  79. 	g_FILLER(S_sw_tr),
  80. 	0xf8,	/* S_sw_ml:	meta-x, vertical rule */
  81. 	0xf8,	/* S_sw_mr:	meta-x, vertical rule */
  82. /*80*/	g_FILLER(S_sw_bl),
  83. 	0xf3,	/* S_sw_bc:	meta-s, low horizontal line */
  84. 	g_FILLER(S_sw_br),
  85. 	g_FILLER(S_explode1),
  86. 	0xef,	/* S_explode2:	meta-o, high horizontal line */
  87. 	g_FILLER(S_explode3),
  88. 	0xf8,	/* S_explode4:	meta-x, vertical rule */
  89. 	g_FILLER(S_explode5),
  90. 	0xf8,	/* S_explode6:	meta-x, vertical rule */
  91. 	g_FILLER(S_explode7),
  92. /*90*/	0xf3,	/* S_explode8:	meta-s, low horizontal line */
  93. 	g_FILLER(S_explode9)
  94. };
  95. #endif  /* TERMLIB */

MACgraphics

  1. #ifdef MAC_GRAPHICS_ENV
  2. static uchar mac_graphics[MAXPCHARS] = {
  3. /* 0*/	g_FILLER(S_stone),
  4. 	0xba,	/* S_vwall */
  5. 	0xcd,	/* S_hwall */
  6. 	0xc9,	/* S_tlcorn */
  7. 	0xbb,	/* S_trcorn */
  8. 	0xc8,	/* S_blcorn */
  9. 	0xbc,	/* S_brcorn */
  10. 	0xce,	/* S_crwall */
  11. 	0xca,	/* S_tuwall */
  12. 	0xcb,	/* S_tdwall */
  13. /*10*/	0xb9,	/* S_tlwall */
  14. 	0xcc,	/* S_trwall */
  15. 	0xb0,	/* S_ndoor */
  16. 	0xee,	/* S_vodoor */
  17. 	0xee,	/* S_hodoor */
  18. 	0xef,	/* S_vcdoor */
  19. 	0xef,	/* S_hcdoor */
  20. 	0xf0,	/* S_bars:	equivalency symbol */
  21. 	0xf1,	/* S_tree:	plus-or-minus */
  22. 	g_FILLER(S_Room),
  23. /*20*/	0xB0,	/* S_corr */
  24. 	g_FILLER(S_litcorr),
  25. 	g_FILLER(S_upstair),
  26. 	g_FILLER(S_dnstair),
  27. 	g_FILLER(S_upladder),
  28. 	g_FILLER(S_dnladder),
  29. 	g_FILLER(S_altar),
  30. 	0xef,	/* S_grave:	same as open door */
  31. 	g_FILLER(S_throne),
  32. 	g_FILLER(S_sink),
  33. /*30*/	g_FILLER(S_fountain),
  34. 	0xe0,	/* S_pool */
  35. 	g_FILLER(S_ice),
  36. 	g_FILLER(S_lava),
  37. 	g_FILLER(S_vodbridge),
  38. 	g_FILLER(S_hodbridge),
  39. 	g_FILLER(S_vcdbridge),
  40. 	g_FILLER(S_hcdbridge),
  41. 	g_FILLER(S_air),
  42. 	g_FILLER(S_cloud),
  43. /*40*/	g_FILLER(S_water),
  44. 	g_FILLER(S_arrow_trap),
  45. 	g_FILLER(S_dart_trap),
  46. 	g_FILLER(S_falling_rock_trap),
  47. 	g_FILLER(S_squeaky_board),
  48. 	g_FILLER(S_bear_trap),
  49. 	g_FILLER(S_land_mine),
  50. 	g_FILLER(S_rolling_boulder_trap),
  51. 	g_FILLER(S_sleeping_gas_trap),
  52. 	g_FILLER(S_rust_trap),
  53. /*50*/	g_FILLER(S_fire_trap),
  54. 	g_FILLER(S_pit),
  55. 	g_FILLER(S_spiked_pit),
  56. 	g_FILLER(S_hole),
  57. 	g_FILLER(S_trap_door),
  58. 	g_FILLER(S_teleportation_trap),
  59. 	g_FILLER(S_level_teleporter),
  60. 	g_FILLER(S_magic_portal),
  61. 	g_FILLER(S_web),
  62. 	g_FILLER(S_statue_trap),
  63. /*60*/	g_FILLER(S_magic_trap),
  64. 	g_FILLER(S_anti_magic_trap),
  65. 	g_FILLER(S_polymorph_trap),
  66. 	g_FILLER(S_vbeam),
  67. 	g_FILLER(S_hbeam),
  68. 	g_FILLER(S_lslant),
  69. 	g_FILLER(S_rslant),
  70. 	g_FILLER(S_digbeam),
  71. 	g_FILLER(S_flashbeam),
  72. 	g_FILLER(S_boomleft),
  73. /*70*/	g_FILLER(S_boomright),
  74. 	g_FILLER(S_ss1),
  75. 	g_FILLER(S_ss2),
  76. 	g_FILLER(S_ss3),
  77. 	g_FILLER(S_ss4),
  78. 	g_FILLER(S_sw_tl),
  79. 	g_FILLER(S_sw_tc),
  80. 	g_FILLER(S_sw_tr),
  81. 	g_FILLER(S_sw_ml),
  82. 	g_FILLER(S_sw_mr),
  83. /*80*/	g_FILLER(S_sw_bl),
  84. 	g_FILLER(S_sw_bc),
  85. 	g_FILLER(S_sw_br),
  86. 	g_FILLER(S_explode1),
  87. 	g_FILLER(S_explode2),
  88. 	g_FILLER(S_explode3),
  89. 	g_FILLER(S_explode4),
  90. 	g_FILLER(S_explode5),
  91. 	g_FILLER(S_explode6),
  92. 	g_FILLER(S_explode7),
  93. /*90*/	g_FILLER(S_explode8),
  94. 	g_FILLER(S_explode9)
  95. };
  96. #endif	/* MAC_GRAPHICS_ENV */
  97.  
  98. #ifdef PC9800
  99. void NDECL((*ascgraphics_mode_callback)) = 0;	/* set in tty_start_screen() */
  100. #endif

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. * options.c, pickup.c, sp_lev.c, and lev_main.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]) break;
  13. return i;
  14. }

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. */
  5. int
  6. def_char_to_monclass(ch)
  7. char ch;
  8. {
  9. int i;
  10. for (i = 1; i < MAXMCLASSES; i++)
  11. 	if (def_monsyms[i] == ch) break;
  12. return i;
  13. }

assign_graphics

This function modifies the showsyms array. graph_chars is a pointer to an array of symbols that are meant to replace symbols in showsyms. This function is used by switch_graphics to swap in the DEC, IBM, MAC, and ASCII graphic sets defined above. For any entry in graph_chars which is 0, use the default symbol.

  1. void
  2. assign_graphics(graph_chars, glth, maxlen, offset)
  3. register uchar *graph_chars;
  4. int glth, maxlen, offset;
  5. {
  6. register int i;
  7.  
  8. for (i = 0; i < maxlen; i++)
  9. 	showsyms[i+offset] = (((i < glth) && graph_chars[i]) ?
  10. 		       graph_chars[i] : defsyms[i+offset].sym);
  11. }

switch_graphics

Swap in one of the predefined graphic sets ASCII, IBM, DEC, or MAC. Note that this function, unlike assign_rogue_graphics below does NOT record the current graphics set. So if you are using a custom graphics set defined by GRAPHICS in the options then this function will overwrite it (this function is called if you toggle the DECgraphics or IBMgraphics options in game).

  1. void
  2. switch_graphics(gr_set_flag)
  3. int gr_set_flag;
  4. {
  5. switch (gr_set_flag) {
  6. 	default:
  7. 	case ASCII_GRAPHICS:
  8. 	    assign_graphics((uchar *)0, 0, MAXPCHARS, 0);
  9. #ifdef PC9800
  10. 	    if (ascgraphics_mode_callback) (*ascgraphics_mode_callback)();
  11. #endif
  12. 	    break;
  13. #ifdef ASCIIGRAPH
  14. 	case IBM_GRAPHICS:
  15. /*
  16. * Use the nice IBM Extended ASCII line-drawing characters (codepage 437).
  17. *
  18. * OS/2 defaults to a multilingual character set (codepage 850, corresponding
  19. * to the ISO 8859 character set.  We should probably do a VioSetCp() call to
  20. * set the codepage to 437.
  21. */
  22. 	    iflags.IBMgraphics = TRUE;
  23. 	    iflags.DECgraphics = FALSE;
  24. 	    assign_graphics(ibm_graphics, SIZE(ibm_graphics), MAXPCHARS, 0);
  25. #ifdef PC9800
  26. 	    if (ibmgraphics_mode_callback) (*ibmgraphics_mode_callback)();
  27. #endif
  28. 	    break;
  29. #endif /* ASCIIGRAPH */
  30. #ifdef TERMLIB
  31. 	case DEC_GRAPHICS:
  32. /*
  33. * Use the VT100 line drawing character set.
  34. */
  35. 	    iflags.DECgraphics = TRUE;
  36. 	    iflags.IBMgraphics = FALSE;
  37. 	    assign_graphics(dec_graphics, SIZE(dec_graphics), MAXPCHARS, 0);
  38. 	    if (decgraphics_mode_callback) (*decgraphics_mode_callback)();
  39. 	    break;
  40. #endif /* TERMLIB */
  41. #ifdef MAC_GRAPHICS_ENV
  42. 	case MAC_GRAPHICS:
  43. 	    assign_graphics(mac_graphics, SIZE(mac_graphics), MAXPCHARS, 0);
  44. 	    break;
  45. #endif
  46. 	}
  47. return;
  48. }

Rogue-level graphics

The devteam didn't bother making extensive arrays for all the dungeon features like they did for the other graphics sets. There is only this array for items. Rogue graphics are different if you visit with IBM graphics chosen. See function below this section.

  1. #ifdef REINCARNATION
  2.  
  3. /*
  4. * saved display symbols for objects & features.
  5. */
  6. static uchar save_oc_syms[MAXOCLASSES] = DUMMY;
  7. static uchar save_showsyms[MAXPCHARS]  = DUMMY;
  8. static uchar save_monsyms[MAXPCHARS]   = DUMMY;
  9.  
  10. static const uchar r_oc_syms[MAXOCLASSES] = {
  11. /* 0*/	'\0',
  12. 	ILLOBJ_SYM,
  13. 	WEAPON_SYM,
  14. 	']',			/* armor */
  15. 	RING_SYM,
  16. /* 5*/	',',			/* amulet */
  17. 	TOOL_SYM,
  18. 	':',			/* food */
  19. 	POTION_SYM,
  20. 	SCROLL_SYM,
  21. /*10*/	SPBOOK_SYM,
  22. 	WAND_SYM,
  23. 	GEM_SYM,		/* gold -- yes it's the same as gems */
  24. 	GEM_SYM,
  25. 	ROCK_SYM,
  26. /*15*/	BALL_SYM,
  27. 	CHAIN_SYM,
  28. 	VENOM_SYM
  29. };
  30.  
  31. # ifdef ASCIIGRAPH
  32. /* Rogue level graphics.  Under IBM graphics mode, use the symbols that were
  33. * used for Rogue on the IBM PC.  Unfortunately, this can't be completely
  34. * done because some of these are control characters--armor and rings under
  35. * DOS, and a whole bunch of them under Linux.  Use the TTY Rogue characters
  36. * for those cases.
  37. */
  38. static const uchar IBM_r_oc_syms[MAXOCLASSES] = {	/* a la EPYX Rogue */
  39. /* 0*/	'\0',
  40. 	ILLOBJ_SYM,
  41. #  if defined(MSDOS) || defined(OS2) || ( defined(WIN32) && !defined(MSWIN_GRAPHICS) )
  42. 	0x18,			/* weapon: up arrow */
  43. /*	0x0a, */ ARMOR_SYM,	/* armor:  Vert rect with o */
  44. /*	0x09, */ RING_SYM,	/* ring:   circle with arrow */
  45. /* 5*/	0x0c,			/* amulet: "female" symbol */
  46. 	TOOL_SYM,
  47. 	0x05,			/* food:   club (as in cards) */
  48. 	0xad,			/* potion: upside down '!' */
  49. 	0x0e,			/* scroll: musical note */
  50. /*10*/	SPBOOK_SYM,
  51. 	0xe7,			/* wand:   greek tau */
  52. 	0x0f,			/* gold:   yes it's the same as gems */
  53. 	0x0f,			/* gems:   fancy '*' */
  54. #  else
  55. 	')',			/* weapon  */
  56. 	ARMOR_SYM,		/* armor */
  57. 	RING_SYM,		/* ring */
  58. /* 5*/	',',			/* amulet  */
  59. 	TOOL_SYM,
  60. 	':',			/* food    */
  61. 	0xad,			/* potion: upside down '!' */
  62. 	SCROLL_SYM,		/* scroll  */
  63. /*10*/	SPBOOK_SYM,
  64. 	0xe7,			/* wand:   greek tau */
  65. 	GEM_SYM,		/* gold:   yes it's the same as gems */
  66. 	GEM_SYM,		/* gems    */
  67. #  endif
  68. 	ROCK_SYM,
  69. /*15*/	BALL_SYM,
  70. 	CHAIN_SYM,
  71. 	VENOM_SYM
  72. };
  73. # endif /* ASCIIGRAPH */

assign_rogue_graphics

Either swap in rogue graphics, taking care to save the current graphic set, or swap the saved set back in, depending on Boolean is_rlevel (is rogue level).

  1. void
  2. assign_rogue_graphics(is_rlevel)
  3. boolean is_rlevel;
  4. {
  5. /* Adjust graphics display characters on Rogue levels */
  6.  
  7. if (is_rlevel) {
  8. 	register int i;
  9.  
  10. 	(void) memcpy((genericptr_t)save_showsyms,
  11. 		      (genericptr_t)showsyms, sizeof showsyms);
  12. 	(void) memcpy((genericptr_t)save_oc_syms,
  13. 		      (genericptr_t)oc_syms, sizeof oc_syms);
  14. 	(void) memcpy((genericptr_t)save_monsyms,
  15. 		      (genericptr_t)monsyms, sizeof monsyms);
  16.  
  17. 	/* Use a loop: char != uchar on some machines. */
  18. 	for (i = 0; i < MAXMCLASSES; i++)
  19. 	    monsyms[i] = def_monsyms[i];
  20. # if defined(ASCIIGRAPH) && !defined(MSWIN_GRAPHICS)
  21. 	if (iflags.IBMgraphics
  22. #  if defined(USE_TILES) && defined(MSDOS)
  23. 		&& !iflags.grmode
  24. #  endif
  25. 		)
  26. 	    monsyms[S_HUMAN] = 0x01; /* smiley face */
  27. # endif
  28. 	for (i = 0; i < MAXPCHARS; i++)
  29. 	    showsyms[i] = defsyms[i].sym;
  30.  
  31. /*
  32. * Some day if these rogue showsyms get much more extensive than this,
  33. * we may want to create r_showsyms, and IBM_r_showsyms arrays to hold
  34. * all of this info and to simply initialize it via a for() loop like r_oc_syms.
  35. */
  36.  
  37. # ifdef ASCIIGRAPH
  38. 	if (!iflags.IBMgraphics
  39. #  if defined(USE_TILES) && defined(MSDOS)
  40. 		|| iflags.grmode
  41. #  endif
  42. 				) {
  43. # endif
  44. 	    showsyms[S_vodoor]  = showsyms[S_hodoor]  = showsyms[S_ndoor] = '+';
  45. 	    showsyms[S_upstair] = showsyms[S_dnstair] = '%';
  46. # ifdef ASCIIGRAPH
  47. 	} else {
  48. 	    /* a la EPYX Rogue */
  49. 	    showsyms[S_vwall]   = 0xba; /* all walls now use	*/
  50. 	    showsyms[S_hwall]   = 0xcd; /* double line graphics	*/
  51. 	    showsyms[S_tlcorn]  = 0xc9;
  52. 	    showsyms[S_trcorn]  = 0xbb;
  53. 	    showsyms[S_blcorn]  = 0xc8;
  54. 	    showsyms[S_brcorn]  = 0xbc;
  55. 	    showsyms[S_crwall]  = 0xce;
  56. 	    showsyms[S_tuwall]  = 0xca;
  57. 	    showsyms[S_tdwall]  = 0xcb;
  58. 	    showsyms[S_tlwall]  = 0xb9;
  59. 	    showsyms[S_trwall]  = 0xcc;
  60. 	    showsyms[S_ndoor]   = 0xce;
  61. 	    showsyms[S_vodoor]  = 0xce;
  62. 	    showsyms[S_hodoor]  = 0xce;
  63. 	    showsyms[S_room]    = 0xfa; /* centered dot */
  64. 	    showsyms[S_corr]    = 0xb1;
  65. 	    showsyms[S_litcorr] = 0xb2;
  66. 	    showsyms[S_upstair] = 0xf0; /* Greek Xi */
  67. 	    showsyms[S_dnstair] = 0xf0;
  68. #ifndef MSWIN_GRAPHICS
  69. 	    showsyms[S_arrow_trap] = 0x04; /* diamond (cards) */
  70. 	    showsyms[S_dart_trap] = 0x04;
  71. 	    showsyms[S_falling_rock_trap] = 0x04;
  72. 	    showsyms[S_squeaky_board] = 0x04;
  73. 	    showsyms[S_bear_trap] = 0x04;
  74. 	    showsyms[S_land_mine] = 0x04;
  75. 	    showsyms[S_rolling_boulder_trap] = 0x04;
  76. 	    showsyms[S_sleeping_gas_trap] = 0x04;
  77. 	    showsyms[S_rust_trap] = 0x04;
  78. 	    showsyms[S_fire_trap] = 0x04;
  79. 	    showsyms[S_pit] = 0x04;
  80. 	    showsyms[S_spiked_pit] = 0x04;
  81. 	    showsyms[S_hole] = 0x04;
  82. 	    showsyms[S_trap_door] = 0x04;
  83. 	    showsyms[S_teleportation_trap] = 0x04;
  84. 	    showsyms[S_level_teleporter] = 0x04;
  85. 	    showsyms[S_magic_portal] = 0x04;
  86. 	    showsyms[S_web] = 0x04;
  87. 	    showsyms[S_statue_trap] = 0x04;
  88. 	    showsyms[S_magic_trap] = 0x04;
  89. 	    showsyms[S_anti_magic_trap] = 0x04;
  90. 	    showsyms[S_polymorph_trap] = 0x04;
  91. #endif
  92. 	}
  93. #endif /* ASCIIGRAPH */
  94.  
  95. 	for (i = 0; i < MAXOCLASSES; i++) {
  96. #ifdef ASCIIGRAPH
  97. 	    if (iflags.IBMgraphics
  98. # if defined(USE_TILES) && defined(MSDOS)
  99. 		&& !iflags.grmode
  100. # endif
  101. 		)
  102. 		oc_syms[i] = IBM_r_oc_syms[i];
  103. 	    else
  104. #endif /* ASCIIGRAPH */
  105. 		oc_syms[i] = r_oc_syms[i];
  106. 	}
  107. #if defined(MSDOS) && defined(USE_TILES)
  108. 	if (iflags.grmode) tileview(FALSE);
  109. #endif
  110. } else {
  111. 	(void) memcpy((genericptr_t)showsyms,
  112. 		      (genericptr_t)save_showsyms, sizeof showsyms);
  113. 	(void) memcpy((genericptr_t)oc_syms,
  114. 		      (genericptr_t)save_oc_syms, sizeof oc_syms);
  115. 	(void) memcpy((genericptr_t)monsyms,
  116. 		      (genericptr_t)save_monsyms, sizeof monsyms);
  117. #if defined(MSDOS) && defined(USE_TILES)
  118. 	if (iflags.grmode) tileview(TRUE);
  119. #endif
  120. }
  121. }
  122. #endif /* REINCARNATION */
  123.  
  124. /*drawing.c*/