home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / games / volume16 / nethack31 / part90 < prev    next >
Internet Message Format  |  1993-02-06  |  60KB

  1. Path: uunet!news.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v16i098:  nethack31 - display oriented dungeons & dragons (Ver. 3.1), Part90/108
  5. Message-ID: <4463@master.CNA.TEK.COM>
  6. Date: 5 Feb 93 22:02:33 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1958
  9. Approved: billr@saab.CNA.TEK.COM
  10. Xref: uunet comp.sources.games:1649
  11.  
  12. Submitted-by: izchak@linc.cis.upenn.edu (Izchak Miller)
  13. Posting-number: Volume 16, Issue 98
  14. Archive-name: nethack31/Part90
  15. Supersedes: nethack3p9: Volume 10, Issue 46-102
  16. Environment: Amiga, Atari, Mac, MS-DOS, OS2, Unix, VMS, X11
  17.  
  18.  
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then unpack
  22. # it by saving it into a file and typing "sh file".  To overwrite existing
  23. # files, type "sh file -c".  You can also feed this as standard input via
  24. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  25. # will see the following message at the end:
  26. #        "End of archive 90 (of 108)."
  27. # Contents:  dat/Barb.des include/winX.h src/mondata.c
  28. #   sys/mac/macmain.c sys/share/termcap
  29. # Wrapped by billr@saab on Wed Jan 27 16:09:23 1993
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'dat/Barb.des' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'dat/Barb.des'\"
  33. else
  34. echo shar: Extracting \"'dat/Barb.des'\" \(13280 characters\)
  35. sed "s/^X//" >'dat/Barb.des' <<'END_OF_FILE'
  36. X#    SCCS Id: @(#)Barb.des    3.1    91/12/22
  37. X#    Copyright (c) 1989 by Jean-Christophe Collet
  38. X#    Copyright (c) 1991 by M. Stephenson
  39. X# NetHack may be freely redistributed.  See license for details.
  40. X#
  41. X#    The "start" level for the quest.
  42. X#
  43. X#    Here you meet your (besieged) class leader, Pelias,
  44. X#    and receive your quest assignment.
  45. X#
  46. XMAZE: "B-start",' '
  47. XFLAGS: noteleport,hardfloor
  48. XGEOMETRY:center,center
  49. XMAP
  50. X..................................PP........................................
  51. X...................................PP.......................................
  52. X...................................PP.......................................
  53. X....................................PP......................................
  54. X........--------------......-----....PPP....................................
  55. X........|...S........|......+...|...PPP.....................................
  56. X........|----........|......|...|....PP.....................................
  57. X........|.\..........+......-----...........................................
  58. X........|----........|...............PP.....................................
  59. X........|...S........|...-----.......PPP....................................
  60. X........--------------...+...|......PPPPP...................................
  61. X.........................|...|.......PPP....................................
  62. X...-----......-----......-----........PP....................................
  63. X...|...+......|...+..--+--.............PP...................................
  64. X...|...|......|...|..|...|..............PP..................................
  65. X...-----......-----..|...|.............PPPP.................................
  66. X.....................-----............PP..PP................................
  67. X.....................................PP...PP................................
  68. X....................................PP...PP.................................
  69. X....................................PP....PP................................
  70. XENDMAP
  71. X# Random Monsters
  72. XRANDOM_MONSTERS: 'O', 'T'
  73. X# Dungeon Description
  74. XREGION:(00,00,75,19),lit,"ordinary"
  75. XREGION:(09,05,11,05),unlit,"ordinary"
  76. XREGION:(09,07,11,07),lit,"ordinary"
  77. XREGION:(09,09,11,09),unlit,"ordinary"
  78. XREGION:(13,05,20,09),lit,"ordinary"
  79. XREGION:(29,05,31,06),lit,"ordinary"
  80. XREGION:(26,10,28,11),lit,"ordinary"
  81. XREGION:(04,13,06,14),lit,"ordinary"
  82. XREGION:(15,13,17,14),lit,"ordinary"
  83. XREGION:(22,14,24,15),lit,"ordinary"
  84. X# Stairs
  85. XSTAIR:(09,09),down
  86. X# Portal arrival point
  87. XBRANCH:(62,02,62,02),(0,0,0,0)
  88. X# Doors
  89. XDOOR:locked,(12,05)
  90. XDOOR:locked,(12,09)
  91. XDOOR:closed,(21,07)
  92. XDOOR:open,(07,13)
  93. XDOOR:open,(18,13)
  94. XDOOR:open,(23,13)
  95. XDOOR:open,(25,10)
  96. XDOOR:open,(28,05)
  97. X# Elder
  98. XMONSTER:'@',"Pelias",(10,07)
  99. X# The treasure of Pelias
  100. XOBJECT:'(',"chest",(09,05)
  101. X# chieftain guards for the audience chamber
  102. XMONSTER:'@',"chieftain",(10,05)
  103. XMONSTER:'@',"chieftain",(10,09)
  104. XMONSTER:'@',"chieftain",(11,05)
  105. XMONSTER:'@',"chieftain",(11,09)
  106. XMONSTER:'@',"chieftain",(14,05)
  107. XMONSTER:'@',"chieftain",(14,09)
  108. XMONSTER:'@',"chieftain",(16,05)
  109. XMONSTER:'@',"chieftain",(16,09)
  110. X# Non diggable walls
  111. XNON_DIGGABLE:(00,00,75,19)
  112. X# One trap to keep the ogres at bay.
  113. XTRAP:"spiked pit",(37,07)
  114. X# Eels in the river
  115. XMONSTER:';',"giant eel",(36,01)
  116. XMONSTER:';',"giant eel",(37,09)
  117. XMONSTER:';',"giant eel",(38,15)
  118. X# Monsters on siege duty.
  119. XMONSTER:'O',"ogre",(40,08),hostile
  120. XMONSTER:'O',"ogre",(41,06),hostile
  121. XMONSTER:'O',"ogre",(41,07),hostile
  122. XMONSTER:'O',"ogre",(41,08),hostile
  123. XMONSTER:'O',"ogre",(41,09),hostile
  124. XMONSTER:'O',"ogre",(41,10),hostile
  125. XMONSTER:'O',"ogre",(42,06),hostile
  126. XMONSTER:'O',"ogre",(42,07),hostile
  127. XMONSTER:'O',"ogre",(42,08),hostile
  128. XMONSTER:'O',"ogre",(42,09),hostile
  129. XMONSTER:'O',"ogre",(42,10),hostile
  130. X#
  131. X#    The "locate" level for the quest.
  132. X#
  133. X#    Here you have to infiltrate the Duali Oasis to go
  134. X#    further towards your assigned quest.
  135. X#
  136. X
  137. XMAZE: "B-locate",' '
  138. XFLAGS: hardfloor
  139. XGEOMETRY:center,center
  140. XMAP
  141. X..........PPP.........................................                      
  142. X...........PP..........................................        .......      
  143. X..........PP...........-----..........------------------     ..........     
  144. X...........PP..........+...|..........|....S...........|..  ............    
  145. X..........PPP..........|...|..........|-----...........|...  .............  
  146. X...........PPP.........-----..........+....+...........|...  .............  
  147. X..........PPPPPPPPP...................+....+...........S.................   
  148. X........PPPPPPPPPPPPP.........-----...|-----...........|................    
  149. X......PPPPPPPPPPPPPP..P.......+...|...|....S...........|          ...       
  150. X.....PPPPPPP......P..PPPP.....|...|...------------------..         ...      
  151. X....PPPPPPP.........PPPPPP....-----........................      ........   
  152. X...PPPPPPP..........PPPPPPP..................................   ..........  
  153. X....PPPPPPP........PPPPPPP....................................  ..........  
  154. X.....PPPPP........PPPPPPP.........-----........................   ........  
  155. X......PPP..PPPPPPPPPPPP...........+...|.........................    .....   
  156. X..........PPPPPPPPPPP.............|...|.........................     ....   
  157. X..........PPPPPPPPP...............-----.........................       .    
  158. X..............PPP.................................................          
  159. X...............PP....................................................       
  160. X................PPP...................................................      
  161. XENDMAP
  162. X# Random Monsters
  163. XRANDOM_MONSTERS: 'O', 'T'
  164. X# Dungeon Description
  165. XREGION:(00,00,75,19),lit,"ordinary"
  166. XREGION:(24,03,26,04),unlit,"ordinary"
  167. XREGION:(31,08,33,09),unlit,"ordinary"
  168. XREGION:(35,14,37,15),unlit,"ordinary"
  169. XREGION:(39,03,54,08),lit,"ordinary"
  170. XREGION:(56,00,75,08),unlit,"ordinary"
  171. XREGION:(64,09,75,16),unlit,"ordinary"
  172. X# Doors
  173. XDOOR:open,(23,03)
  174. XDOOR:open,(30,08)
  175. XDOOR:open,(34,14)
  176. XDOOR:locked,(38,05)
  177. XDOOR:locked,(38,06)
  178. XDOOR:closed,(43,03)
  179. XDOOR:closed,(43,05)
  180. XDOOR:closed,(43,06)
  181. XDOOR:closed,(43,08)
  182. XDOOR:locked,(55,06)
  183. X# Stairs
  184. XSTAIR:(05,02),up
  185. XSTAIR:(70,13),down
  186. X# Objects
  187. XOBJECT:random,random,(42,03)
  188. XOBJECT:random,random,(42,03)
  189. XOBJECT:random,random,(42,03)
  190. XOBJECT:random,random,(41,03)
  191. XOBJECT:random,random,(41,03)
  192. XOBJECT:random,random,(41,03)
  193. XOBJECT:random,random,(41,03)
  194. XOBJECT:random,random,(41,08)
  195. XOBJECT:random,random,(41,08)
  196. XOBJECT:random,random,(42,08)
  197. XOBJECT:random,random,(42,08)
  198. XOBJECT:random,random,(42,08)
  199. XOBJECT:random,random,(71,13)
  200. XOBJECT:random,random,(71,13)
  201. XOBJECT:random,random,(71,13)
  202. X# Random traps
  203. XTRAP:"spiked pit",(10,13)
  204. XTRAP:"spiked pit",(21,07)
  205. XTRAP:"spiked pit",(67,08)
  206. XTRAP:"spiked pit",(68,09)
  207. XTRAP:random,random
  208. XTRAP:random,random
  209. XTRAP:random,random
  210. XTRAP:random,random
  211. X# Random monsters.
  212. XMONSTER:'O',"ogre",(12,09),hostile
  213. XMONSTER:'O',"ogre",(18,11),hostile
  214. XMONSTER:'O',"ogre",(45,05),hostile
  215. XMONSTER:'O',"ogre",(45,06),hostile
  216. XMONSTER:'O',"ogre",(47,05),hostile
  217. XMONSTER:'O',"ogre",(46,05),hostile
  218. XMONSTER:'O',"ogre",(56,03),hostile
  219. XMONSTER:'O',"ogre",(56,04),hostile
  220. XMONSTER:'O',"ogre",(56,05),hostile
  221. XMONSTER:'O',"ogre",(56,06),hostile
  222. XMONSTER:'O',"ogre",(57,03),hostile
  223. XMONSTER:'O',"ogre",(57,04),hostile
  224. XMONSTER:'O',"ogre",(57,05),hostile
  225. XMONSTER:'O',"ogre",(57,06),hostile
  226. XMONSTER:'O',"ogre",random,hostile
  227. XMONSTER:'O',"ogre",random,hostile
  228. XMONSTER:'O',"ogre",random,hostile
  229. XMONSTER:'O',random,random,hostile
  230. XMONSTER:'T',random,random,hostile
  231. XMONSTER:'T',"rock troll",(46,06),hostile
  232. XMONSTER:'T',"rock troll",(47,06),hostile
  233. XMONSTER:'T',"rock troll",(56,07),hostile
  234. XMONSTER:'T',"rock troll",(57,07),hostile
  235. XMONSTER:'T',"rock troll",(70,13),hostile
  236. XMONSTER:'T',"rock troll",random,hostile
  237. XMONSTER:'T',"rock troll",random,hostile
  238. XMONSTER:'T',random,random,hostile
  239. X
  240. X#
  241. X#    The "goal" level for the quest.
  242. X#
  243. X#    Here you meet Thoth Amon, your nemesis monster.  You have to
  244. X#    defeat Thoth Amon in combat to gain the artifact you have
  245. X#    been assigned to retrieve.
  246. X#
  247. X
  248. XMAZE: "B-goal", ' '
  249. XGEOMETRY:center,center
  250. XMAP
  251. X                                                                            
  252. X                               .............                                
  253. X                             ..................                             
  254. X        ....              .........................          ....           
  255. X      .......          ..........................           .......         
  256. X      ......             ........................          .......          
  257. X      ..  ......................................             ..             
  258. X       ..                 .....................             ..              
  259. X        ..                 ..................              ..               
  260. X         ..         ..S...S..............   ................                
  261. X          ..                   ........                ...                  
  262. X       .........                                         ..                 
  263. X       ......  ..                                         ...  ....         
  264. X      .. ...    ..                             ......       ........        
  265. X   ....          .. ..................        ........       ......         
  266. X  ......          ......................       ......         ..            
  267. X   ....             ..................              ...........             
  268. X                      ..............                                        
  269. X                        ...........                                         
  270. X                                                                            
  271. XENDMAP
  272. X# Random Monsters
  273. XRANDOM_MONSTERS: 'O', 'T'
  274. X# Dungeon Description
  275. XREGION:(00,00,75,19),unlit,"ordinary"
  276. X# Secret doors
  277. XDOOR:locked,(22,09)
  278. XDOOR:locked,(26,09)
  279. X# Stairs
  280. XSTAIR:(36,05),up
  281. X# The altar.  Unattended.
  282. XALTAR:(63,04),align[2],altar
  283. XNON_DIGGABLE:(00,00,75,19)
  284. X# Objects
  285. XOBJECT:'*',"luckstone",(63,04),blessed,0,"The Heart of Ahriman"
  286. XOBJECT:random,random,random
  287. XOBJECT:random,random,random
  288. XOBJECT:random,random,random
  289. XOBJECT:random,random,random
  290. XOBJECT:random,random,random
  291. XOBJECT:random,random,random
  292. XOBJECT:random,random,random
  293. XOBJECT:random,random,random
  294. XOBJECT:random,random,random
  295. XOBJECT:random,random,random
  296. XOBJECT:random,random,random
  297. XOBJECT:random,random,random
  298. XOBJECT:random,random,random
  299. XOBJECT:random,random,random
  300. X# Random traps
  301. XTRAP:random,random
  302. XTRAP:random,random
  303. XTRAP:random,random
  304. XTRAP:random,random
  305. XTRAP:random,random
  306. XTRAP:random,random
  307. X# Random monsters.
  308. XMONSTER:'@',"Thoth Amon",(63,04),hostile
  309. XMONSTER:'O',"ogre",random,hostile
  310. XMONSTER:'O',"ogre",random,hostile
  311. XMONSTER:'O',"ogre",random,hostile
  312. XMONSTER:'O',"ogre",random,hostile
  313. XMONSTER:'O',"ogre",random,hostile
  314. XMONSTER:'O',"ogre",random,hostile
  315. XMONSTER:'O',"ogre",random,hostile
  316. XMONSTER:'O',"ogre",random,hostile
  317. XMONSTER:'O',"ogre",random,hostile
  318. XMONSTER:'O',"ogre",random,hostile
  319. XMONSTER:'O',"ogre",random,hostile
  320. XMONSTER:'O',"ogre",random,hostile
  321. XMONSTER:'O',"ogre",random,hostile
  322. XMONSTER:'O',"ogre",random,hostile
  323. XMONSTER:'O',"ogre",random,hostile
  324. XMONSTER:'O',"ogre",random,hostile
  325. XMONSTER:'O',random,random,hostile
  326. XMONSTER:'O',random,random,hostile
  327. XMONSTER:'T',"rock troll",random,hostile
  328. XMONSTER:'T',"rock troll",random,hostile
  329. XMONSTER:'T',"rock troll",random,hostile
  330. XMONSTER:'T',"rock troll",random,hostile
  331. XMONSTER:'T',"rock troll",random,hostile
  332. XMONSTER:'T',"rock troll",random,hostile
  333. XMONSTER:'T',"rock troll",random,hostile
  334. XMONSTER:'T',"rock troll",random,hostile
  335. XMONSTER:'T',random,random,hostile
  336. XWALLIFY
  337. X
  338. X#
  339. X#    The "fill" levels for the quest.
  340. X#
  341. X#    These levels are used to fill out any levels not occupied by specific
  342. X#    levels as defined above. "filla" is the upper filler, between the
  343. X#    start and locate levels, and "fillb" the lower between the locate
  344. X#    and goal levels.
  345. X#
  346. X
  347. XMAZE: "B-filla" , ' '
  348. XINIT_MAP: '.' , '.' , true , true , unlit , false
  349. XNOMAP
  350. X# Random Monsters
  351. XRANDOM_MONSTERS: 'O', 'T'
  352. X#
  353. XSTAIR: random, up
  354. XSTAIR: random, down
  355. X#
  356. XOBJECT: random, random, random
  357. XOBJECT: random, random, random
  358. XOBJECT: random, random, random
  359. XOBJECT: random, random, random
  360. XOBJECT: random, random, random
  361. XOBJECT: random, random, random
  362. XOBJECT: random, random, random
  363. XOBJECT: random, random, random
  364. X#
  365. XTRAP: random, random
  366. XTRAP: random, random
  367. XTRAP: random, random
  368. XTRAP: random, random
  369. X#
  370. XMONSTER: 'O', "ogre", random, hostile
  371. XMONSTER: 'O', "ogre", random, hostile
  372. XMONSTER: 'O', random, random, hostile
  373. XMONSTER: 'T', "rock troll", random, hostile
  374. X
  375. XMAZE: "B-fillb" , ' '
  376. XINIT_MAP: '.' , ' ' , true , true , unlit , true
  377. XNOMAP
  378. X# Random Monsters
  379. XRANDOM_MONSTERS: 'O', 'T'
  380. X#
  381. XSTAIR: random, up
  382. XSTAIR: random, down
  383. X#
  384. XOBJECT: random, random, random
  385. XOBJECT: random, random, random
  386. XOBJECT: random, random, random
  387. XOBJECT: random, random, random
  388. XOBJECT: random, random, random
  389. XOBJECT: random, random, random
  390. XOBJECT: random, random, random
  391. XOBJECT: random, random, random
  392. XOBJECT: random, random, random
  393. XOBJECT: random, random, random
  394. XOBJECT: random, random, random
  395. X#
  396. XTRAP: random, random
  397. XTRAP: random, random
  398. XTRAP: random, random
  399. XTRAP: random, random
  400. X#
  401. XMONSTER: 'O', "ogre", random, hostile
  402. XMONSTER: 'O', "ogre", random, hostile
  403. XMONSTER: 'O', "ogre", random, hostile
  404. XMONSTER: 'O', "ogre", random, hostile
  405. XMONSTER: 'O', "ogre", random, hostile
  406. XMONSTER: 'O', "ogre", random, hostile
  407. XMONSTER: 'O', "ogre", random, hostile
  408. XMONSTER: 'O', random , random, hostile
  409. XMONSTER: 'T', "rock troll", random, hostile
  410. XMONSTER: 'T', "rock troll", random, hostile
  411. XMONSTER: 'T', "rock troll", random, hostile
  412. XMONSTER: 'T', random , random, hostile
  413. END_OF_FILE
  414. if test 13280 -ne `wc -c <'dat/Barb.des'`; then
  415.     echo shar: \"'dat/Barb.des'\" unpacked with wrong size!
  416. fi
  417. # end of 'dat/Barb.des'
  418. fi
  419. if test -f 'include/winX.h' -a "${1}" != "-c" ; then 
  420.   echo shar: Will not clobber existing file \"'include/winX.h'\"
  421. else
  422. echo shar: Extracting \"'include/winX.h'\" \(11646 characters\)
  423. sed "s/^X//" >'include/winX.h' <<'END_OF_FILE'
  424. X/*    SCCS Id: @(#)winX.h    3.1    93/01/22          */
  425. X/* Copyright (c) Dean Luick, 1992                  */
  426. X/* NetHack may be freely redistributed.  See license for details. */
  427. X
  428. X/*
  429. X * Definitions for the X11 window-port.  See doc/window.doc for details on
  430. X * the window interface.
  431. X */
  432. X#ifndef WINX_H
  433. X#define WINX_H
  434. X
  435. X#ifndef E
  436. X#define E extern
  437. X#endif
  438. X
  439. X#if defined(BOS) || defined(NHSTDC)
  440. X#define DIMENSION_P int
  441. X#else
  442. X# ifdef WIDENED_PROTOTYPES
  443. X#define DIMENSION_P unsigned int
  444. X# else
  445. X#define DIMENSION_P Dimension
  446. X# endif
  447. X#endif
  448. X
  449. X/*
  450. X * Generic text buffer.
  451. X */
  452. X#define START_SIZE 512    /* starting text buffer size */
  453. Xstruct text_buffer {
  454. X    char *text;
  455. X    int  text_size;
  456. X    int  text_last;
  457. X    int  num_lines;
  458. X};
  459. X
  460. X
  461. X/*
  462. X * Information specific to a map window.
  463. X */
  464. Xstruct map_info_t {
  465. X    unsigned char   text[ROWNO][COLNO],    /* Actual displayed screen. */
  466. X            t_start[ROWNO],    /* Staring column for new info. */
  467. X            t_stop[ROWNO];    /* Ending column for new info. */
  468. X    int            char_width,        /* Saved font information so we can  */
  469. X            char_height,    /*   calculate the correct placement */
  470. X            char_ascent,    /*   of changes.             */
  471. X            char_lbearing;
  472. X    Dimension        viewport_width,    /* Saved viewport size, so we can */
  473. X            viewport_height;    /*   clip to cursor on a resize.  */
  474. X#ifdef TEXTCOLOR
  475. X    unsigned char   colors[ROWNO][COLNO];    /* Color of each character. */
  476. X    GC            color_gcs[MAXCOLORS],    /* GC for each color */
  477. X            inv_color_gcs[MAXCOLORS];    /* GC for each inverse color */
  478. X#define copy_gc     color_gcs[NO_COLOR]
  479. X#define inv_copy_gc inv_color_gcs[NO_COLOR]
  480. X#else
  481. X    GC            copy_gc,            /* Drawing GC */
  482. X            inv_copy_gc;        /* Inverse drawing GC */
  483. X#endif
  484. X};
  485. X
  486. X/*
  487. X * Information specific to a message window.
  488. X */
  489. Xstruct line_element {
  490. X    struct line_element *next;
  491. X    char *line;            /* char buffer */
  492. X    int  buf_length;        /* length of buffer */
  493. X    int  str_length;        /* length of string in buffer */
  494. X};
  495. X
  496. Xstruct mesg_info_t {
  497. X    XFontStruct *fs;        /* Font for the window. */
  498. X    int        num_lines;    /* line count */
  499. X    struct line_element *head;    /* head of circular line queue */
  500. X    struct line_element *last_pause;/* point to the line after the prev */
  501. X                /*    bottom of screen */
  502. X    struct line_element *last_pause_head;/* pointer to head of previous */
  503. X                /* turn                    */
  504. X    GC        gc;        /* GC for text drawing */
  505. X    int         char_width,     /* Saved font information so we can  */
  506. X        char_height,    /*   calculate the correct placement */
  507. X        char_ascent,    /*   of changes.                     */
  508. X        char_lbearing;
  509. X    Dimension    viewport_width,    /* Saved viewport size, so we can adjust */
  510. X        viewport_height;/*   the slider on a resize.         */
  511. X    Boolean    dirty;        /* Lines have been added to the window. */
  512. X};
  513. X
  514. X/*
  515. X * Information specific to a "text" status window.
  516. X */
  517. Xstruct status_info_t {
  518. X    struct text_buffer text;    /* Just a text buffer. */
  519. X};
  520. X
  521. X/*
  522. X * Information specific to a menu window.  First a structure for each
  523. X * menu entry, then the structure for each menu window.
  524. X */
  525. Xstruct menu_item {
  526. X    struct menu_item *next;
  527. X    char selector;        /* Char used to select this entry. */
  528. X    int  attr;            /* Attribute for the line. */
  529. X    char *str;            /* The text of the item. */
  530. X};
  531. X
  532. Xstruct menu_info_t {
  533. X    struct menu_item *base;    /* Starting pointer for item list. */
  534. X    struct menu_item *last;    /* End pointer for item list. */
  535. X    const char    *query;
  536. X    const char    *other_valid;
  537. X    char    other_response;
  538. X    int     count;
  539. X    String  *list_pointer;
  540. X    boolean valid_widgets;
  541. X    boolean is_menu;        /* Has been conformed to being a menu window. */
  542. X};
  543. X
  544. X/*
  545. X * Information specific to a text window.
  546. X */
  547. Xstruct text_info_t {
  548. X    struct text_buffer text;
  549. X    XFontStruct *fs;        /* Font for the text window. */
  550. X    int        max_width;    /* Width of widest line so far. */
  551. X    int        extra_width,    /* Sum of left and right border widths. */
  552. X        extra_height;    /* Sum of top and bottom border widths. */
  553. X    boolean    blocked;    /*  */
  554. X    boolean    destroy_on_ack;    /* Destroy this window when acknowleged. */
  555. X};
  556. X
  557. X
  558. X/*
  559. X * Basic window structure.
  560. X */
  561. Xstruct xwindow {
  562. X    int          type;        /* type of nethack window */
  563. X    Widget    popup;        /* direct parent of widget w or viewport */
  564. X    Widget    w;        /* the widget that does things */
  565. X    Dimension pixel_width;    /* window size, in pixels */
  566. X    Dimension pixel_height;
  567. X    int          prevx, cursx;    /* Cursor position, only used by    */
  568. X    int       prevy, cursy;    /*   map and "plain" status windows.*/
  569. X
  570. X    union {
  571. X    struct map_info_t    *Map_info;        /* map window info */
  572. X    struct mesg_info_t   *Mesg_info;    /* message window info */
  573. X    struct status_info_t *Status_info;  /* status window info */
  574. X    struct menu_info_t   *Menu_info;    /* menu window info */
  575. X    struct text_info_t   *Text_info;    /* menu window info */
  576. X    } Win_info;
  577. X};
  578. X
  579. X/* Defines to use for the window information union. */
  580. X#define map_information    Win_info.Map_info
  581. X#define mesg_information   Win_info.Mesg_info
  582. X#define status_information Win_info.Status_info
  583. X#define menu_information   Win_info.Menu_info
  584. X#define text_information   Win_info.Text_info
  585. X
  586. X
  587. X#define MAX_WINDOWS 20        /* max number of open windows */
  588. X
  589. X#define NHW_NONE 0        /* Unallocated window type.  Must be     */
  590. X                /* different from any other NHW_* type. */
  591. X
  592. X#define NO_CLICK 0        /* No click occured on the map window. Must */
  593. X                /* be different than CLICK_1 and CLICK_2.   */
  594. X
  595. X#define DEFAULT_MESSAGE_WIDTH 60/* width in chars of the message window */
  596. X
  597. X#define DISPLAY_FILE_SIZE 35    /* Max number of lines in the default    */
  598. X                /* file display window.            */
  599. X
  600. X#define MAX_KEY_STRING 64    /* String size for converting a keypress */
  601. X                /* event into a character(s)         */
  602. X
  603. X#define DEFAULT_LINES_DISPLAYED 12 /* # of lines displayed message window */
  604. X#define MAX_HISTORY 60        /* max history saved on message window */
  605. X
  606. X
  607. X/* Window variables (winX.c). */
  608. XE struct xwindow window_list[MAX_WINDOWS];
  609. XE XtAppContext   app_context;        /* context of application */
  610. XE Widget     toplevel;        /* toplevel widget */
  611. XE boolean     exit_x_event;        /* exit condition for event loop */
  612. X#define EXIT_ON_KEY_PRESS        0    /* valid values for exit_x_event */
  613. X#define EXIT_ON_KEY_OR_BUTTON_PRESS 1
  614. X#define EXIT_ON_EXIT            2
  615. X#define EXIT_ON_SENT_EVENT        3
  616. XE int click_x, click_y, click_button;
  617. X
  618. Xtypedef struct {
  619. X    Boolean slow;
  620. X    Boolean autofocus;
  621. X    Boolean message_line;
  622. X    String  icon;    /* name of desired icon */
  623. X} AppResources;
  624. X
  625. XE AppResources appResources;
  626. XE void (*input_func)();
  627. X
  628. Xextern struct window_procs X11_procs;
  629. X
  630. X/* Check for an invalid window id. */
  631. X#define check_winid(window)                    \
  632. X    if ((window) < 0 || (window) >= MAX_WINDOWS) {        \
  633. X        panic("illegal windid [%d] in %s at line %d",    \
  634. X        window, __FILE__, __LINE__);            \
  635. X    }
  636. X
  637. X
  638. X/* ### dialogs.c ### */
  639. XE Widget FDECL(CreateDialog, (Widget, String, XtCallbackProc, XtCallbackProc));
  640. XE void FDECL(SetDialogPrompt,(Widget, String));
  641. XE String FDECL(GetDialogResponse,(Widget));
  642. XE void FDECL(SetDialogResponse,(Widget, String));
  643. XE void FDECL(positionpopup,(Widget));
  644. X
  645. X/* ### winX.c ### */
  646. XE struct xwindow *FDECL(find_widget,(Widget));
  647. XE char FDECL(key_event_to_char,(XKeyEvent*));
  648. XE void FDECL(msgkey, (Widget, XtPointer, XEvent*));
  649. XE void FDECL(nh_XtPopup, (Widget, int, Widget));
  650. XE void FDECL(nh_XtPopdown, (Widget));
  651. XE void NDECL(win_X11_init);
  652. X
  653. X/* ### winmesg.c ### */
  654. XE void FDECL(set_message_height, (struct xwindow*, DIMENSION_P));
  655. XE void FDECL(set_message_slider, (struct xwindow*));
  656. XE void FDECL(create_message_window,(struct xwindow*, BOOLEAN_P, Widget));
  657. XE void FDECL(destroy_message_window,(struct xwindow*));
  658. XE void FDECL(display_message_window, (struct xwindow*));
  659. XE void FDECL(append_message,(struct xwindow*, const char*));
  660. XE void FDECL(set_last_pause, (struct xwindow*));
  661. X
  662. X/* ### winmap.c ### */
  663. XE void FDECL(check_cursor_visibility,(struct xwindow*));
  664. XE void FDECL(display_map_window,(struct xwindow*));
  665. XE void FDECL(clear_map_window,(struct xwindow*));
  666. XE void FDECL(extern_map_input,(XEvent*));
  667. XE void FDECL(set_map_size,(struct xwindow*, DIMENSION_P, DIMENSION_P));
  668. XE void FDECL(create_map_window,(struct xwindow*, BOOLEAN_P, Widget));
  669. XE void FDECL(destroy_map_window,(struct xwindow*));
  670. XE int  FDECL(x_event,(int));
  671. X
  672. X/* ### winmenu.c ### */
  673. XE void FDECL(menu_key,(Widget, XEvent*, String*, Cardinal*));
  674. XE void FDECL(create_menu_window,(struct xwindow*));
  675. XE void FDECL(destroy_menu_window,(struct xwindow*));
  676. X
  677. X/* ### winmisc.c ### */
  678. XE void FDECL(ps_key,(Widget, XEvent*, String*, Cardinal*)); /* player selection action */
  679. XE void FDECL(ec_key,(Widget, XEvent*, String*, Cardinal*)); /* extended command action */
  680. XE void NDECL(init_extended_commands_popup);
  681. X
  682. X/* ### winstatus.c ### */
  683. XE void FDECL(create_status_window,(struct xwindow*, BOOLEAN_P, Widget));
  684. XE void FDECL(destroy_status_window,(struct xwindow*));
  685. XE void FDECL(adjust_status,(struct xwindow*, const char*));
  686. XE void NDECL(null_out_status);
  687. XE void NDECL(check_turn_events);
  688. X
  689. X/* ### wintext.c ### */
  690. XE void FDECL(dismiss_text,(Widget, XEvent*, String*, Cardinal*));
  691. XE void FDECL(key_dismiss_text,(Widget, XEvent*, String*, Cardinal*));
  692. XE void FDECL(add_to_text_window,(struct xwindow*, int, const char*));
  693. XE void FDECL(display_text_window,(struct xwindow*, BOOLEAN_P));
  694. XE void FDECL(create_text_window,(struct xwindow*));
  695. XE void FDECL(destroy_text_window,(struct xwindow*));
  696. XE void FDECL(append_text_buffer,(struct text_buffer*, const char*, BOOLEAN_P));    /* text buffer routines */
  697. XE void FDECL(init_text_buffer,(struct text_buffer*));
  698. XE void FDECL(clear_text_buffer,(struct text_buffer*));
  699. XE void FDECL(free_text_buffer,(struct text_buffer*));
  700. X
  701. X/* ### winval.c ### */
  702. XE Widget FDECL(create_value,(Widget, const char*));
  703. XE void   FDECL(set_name,(Widget, char*));
  704. XE void   FDECL(set_name_width,(Widget, int));
  705. XE int    FDECL(get_name_width,(Widget));
  706. XE void   FDECL(set_value,(Widget, const char*));
  707. XE void   FDECL(set_value_width,(Widget, int));
  708. XE int    FDECL(get_value_width,(Widget));
  709. XE void   FDECL(hilight_value,(Widget));
  710. X
  711. X/* external declarations */
  712. XE void NDECL(X11_init_nhwindows);
  713. XE void NDECL(X11_player_selection);
  714. XE void NDECL(X11_askname);
  715. XE void NDECL(X11_get_nh_event) ;
  716. XE void FDECL(X11_exit_nhwindows, (const char *));
  717. XE void FDECL(X11_suspend_nhwindows, (const char *));
  718. XE void NDECL(X11_resume_nhwindows);
  719. XE winid FDECL(X11_create_nhwindow, (int));
  720. XE void FDECL(X11_clear_nhwindow, (winid));
  721. XE void FDECL(X11_display_nhwindow, (winid, BOOLEAN_P));
  722. XE void FDECL(X11_destroy_nhwindow, (winid));
  723. XE void FDECL(X11_curs, (winid,int,int));
  724. XE void FDECL(X11_putstr, (winid, int, const char *));
  725. XE void FDECL(X11_display_file, (const char *, BOOLEAN_P));
  726. XE void FDECL(X11_start_menu, (winid));
  727. XE void FDECL(X11_add_menu, (winid, CHAR_P, int, const char *));
  728. XE void FDECL(X11_end_menu, (winid, CHAR_P, const char *, const char *));
  729. XE char FDECL(X11_select_menu, (winid));
  730. XE void NDECL(X11_update_inventory);
  731. XE void NDECL(X11_mark_synch);
  732. XE void NDECL(X11_wait_synch);
  733. X#ifdef CLIPPING
  734. XE void FDECL(X11_cliparound, (int, int));
  735. X#endif
  736. XE void FDECL(X11_print_glyph, (winid,XCHAR_P,XCHAR_P,int));
  737. XE void FDECL(X11_raw_print, (const char *));
  738. XE void FDECL(X11_raw_print_bold, (const char *));
  739. XE int NDECL(X11_nhgetch);
  740. XE int FDECL(X11_nh_poskey, (int *, int *, int *));
  741. XE void NDECL(X11_nhbell);
  742. XE int NDECL(X11_doprev_message);
  743. XE char FDECL(X11_yn_function, (const char *, const char *, CHAR_P));
  744. XE void FDECL(X11_getlin, (const char *,char *));
  745. X#ifdef COM_COMPL
  746. XE void FDECL(X11_get_ext_cmd, (char *));
  747. X#endif /* COM_COMPL */
  748. XE void FDECL(X11_number_pad, (int));
  749. XE void NDECL(X11_delay_output);
  750. X
  751. X/* other defs that really should go away (they're tty specific) */
  752. XE void NDECL(X11_start_screen);
  753. XE void NDECL(X11_end_screen);
  754. X
  755. X#endif /* WINX_H */
  756. END_OF_FILE
  757. if test 11646 -ne `wc -c <'include/winX.h'`; then
  758.     echo shar: \"'include/winX.h'\" unpacked with wrong size!
  759. fi
  760. # end of 'include/winX.h'
  761. fi
  762. if test -f 'src/mondata.c' -a "${1}" != "-c" ; then 
  763.   echo shar: Will not clobber existing file \"'src/mondata.c'\"
  764. else
  765. echo shar: Extracting \"'src/mondata.c'\" \(10482 characters\)
  766. sed "s/^X//" >'src/mondata.c' <<'END_OF_FILE'
  767. X/*    SCCS Id: @(#)mondata.c    3.1    92/11/24    */
  768. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  769. X/* NetHack may be freely redistributed.  See license for details. */
  770. X
  771. X#include "hack.h"
  772. X#include "eshk.h"
  773. X#include "epri.h"
  774. X
  775. X/*    These routines provide basic data for any type of monster. */
  776. X
  777. X#ifdef OVL0
  778. X
  779. Xboolean
  780. Xattacktype(ptr, atyp)
  781. X    register struct    permonst    *ptr;
  782. X    register int atyp;
  783. X{
  784. X    int    i;
  785. X
  786. X    for(i = 0; i < NATTK; i++)
  787. X        if(ptr->mattk[i].aatyp == atyp) return(TRUE);
  788. X
  789. X    return(FALSE);
  790. X}
  791. X
  792. X#endif /* OVL0 */
  793. X#ifdef OVLB
  794. X
  795. Xboolean
  796. Xpoly_when_stoned(ptr)
  797. X    struct permonst *ptr;
  798. X{
  799. X    return (is_golem(ptr) && ptr != &mons[PM_STONE_GOLEM] &&
  800. X        !(mons[PM_STONE_GOLEM].geno & G_GENOD));    /* allow G_EXTINCT */
  801. X}
  802. X
  803. Xboolean
  804. Xresists_drli(ptr)    /* returns TRUE if monster is drain-life resistant */
  805. X
  806. X    register struct permonst *ptr;
  807. X{
  808. X    return(is_undead(ptr) || is_demon(ptr) || is_were(ptr));
  809. X}
  810. X
  811. X#endif /* OVLB */
  812. X#ifdef OVL0
  813. X
  814. Xboolean
  815. Xranged_attk(ptr)    /* returns TRUE if monster can attack at range */
  816. X    register struct permonst *ptr;
  817. X{
  818. X    register int    i, j;
  819. X    register int atk_mask = (1<<AT_BREA) | (1<<AT_SPIT) | (1<<AT_GAZE);
  820. X
  821. X    /* was: (attacktype(ptr, AT_BREA) || attacktype(ptr, AT_WEAP) ||
  822. X        attacktype(ptr, AT_SPIT) || attacktype(ptr, AT_GAZE) ||
  823. X        attacktype(ptr, AT_MAGC));
  824. X       but that's too slow -dlc
  825. X     */
  826. X    for(i = 0; i < NATTK; i++) {
  827. X        if((j=ptr->mattk[i].aatyp) >= AT_WEAP || (atk_mask & (1<<j)))
  828. X        return TRUE;
  829. X    }
  830. X
  831. X    return(FALSE);
  832. X}
  833. X
  834. Xboolean
  835. Xhates_silver(ptr)
  836. Xregister struct permonst *ptr;
  837. X/* returns TRUE if monster is especially affected by silver weapons */
  838. X{
  839. X    return (is_were(ptr) || ptr->mlet==S_VAMPIRE || is_demon(ptr) ||
  840. X        ptr == &mons[PM_SHADE] ||
  841. X        (ptr->mlet==S_IMP && ptr != &mons[PM_TENGU]));
  842. X}
  843. X
  844. X#endif /* OVL0 */
  845. X#ifdef OVL1
  846. X
  847. Xboolean
  848. Xcan_track(ptr)        /* returns TRUE if monster can track well */
  849. X    register struct permonst *ptr;
  850. X{
  851. X    if (uwep && uwep->oartifact == ART_EXCALIBUR)
  852. X        return TRUE;
  853. X    else
  854. X        return(haseyes(ptr));
  855. X}
  856. X
  857. X#endif /* OVL1 */
  858. X#ifdef OVLB
  859. X
  860. X#if defined(POLYSELF) || defined(MUSE)
  861. Xboolean
  862. Xsliparm(ptr)    /* creature will slide out of armor */
  863. X    register struct permonst *ptr;
  864. X{
  865. X    return is_whirly(ptr) || ptr->msize <= MZ_SMALL ||
  866. X        ptr == &mons[PM_GHOST];
  867. X}
  868. X
  869. Xboolean
  870. Xbreakarm(ptr)    /* creature will break out of armor */
  871. X    register struct permonst *ptr;
  872. X{
  873. X    return((bigmonst(ptr) || (ptr->msize > MZ_SMALL && !humanoid(ptr))
  874. X                    || ptr == &mons[PM_MARILITH]) && !sliparm(ptr));
  875. X    /* Marilith is about the only case of a monster which is otherwise
  876. X     * humanoid but cannot wear armor (too many arms).  Centaurs would
  877. X     * be another except that they are already accounted for by
  878. X     * bigmonst.
  879. X     */
  880. X}
  881. X#endif
  882. X#endif /* OVLB */
  883. X#ifdef OVL1
  884. X
  885. Xboolean
  886. Xsticks(ptr)    /* creature sticks other creatures it hits */
  887. X    register struct permonst *ptr;
  888. X{
  889. X    return(dmgtype(ptr,AD_STCK) || dmgtype(ptr,AD_WRAP) ||
  890. X        attacktype(ptr,AT_HUGS));
  891. X}
  892. X
  893. Xboolean
  894. Xdmgtype(ptr, dtyp)
  895. X    register struct    permonst    *ptr;
  896. X    register int dtyp;
  897. X{
  898. X    int    i;
  899. X
  900. X    for(i = 0; i < NATTK; i++)
  901. X        if(ptr->mattk[i].adtyp == dtyp) return TRUE;
  902. X
  903. X    return FALSE;
  904. X}
  905. X
  906. X/* returns the maximum damage a defender can do to the attacker via
  907. X * a passive defense */
  908. Xint
  909. Xmax_passive_dmg(mdef, magr)
  910. X    register struct monst *mdef, *magr;
  911. X{
  912. X    int    i, dmg = 0;
  913. X    uchar adtyp;
  914. X
  915. X    for(i = 0; i < NATTK; i++)
  916. X    if(mdef->data->mattk[i].aatyp == AT_NONE) {
  917. X        adtyp = mdef->data->mattk[i].adtyp;
  918. X        if((adtyp == AD_ACID && !resists_acid(magr->data)) ||
  919. X            (adtyp == AD_COLD && !resists_cold(magr->data)) ||
  920. X            (adtyp == AD_FIRE && !resists_fire(magr->data)) ||
  921. X            (adtyp == AD_ELEC && !resists_elec(magr->data))) {
  922. X        dmg = mdef->data->mattk[i].damn;
  923. X        if(!dmg) dmg = mdef->data->mlevel+1;
  924. X        dmg *= mdef->data->mattk[i].damd;
  925. X        } else dmg = 0;
  926. X
  927. X        return dmg;
  928. X    }
  929. X    return 0;
  930. X}
  931. X
  932. X#endif /* OVL1 */
  933. X#ifdef OVL0
  934. X
  935. Xint
  936. Xmonsndx(ptr)        /* return an index into the mons array */
  937. X    struct    permonst    *ptr;
  938. X{
  939. X    register int    i;
  940. X
  941. X    if(ptr == &playermon) return(-1);
  942. X
  943. X    i = (int)(ptr - &mons[0]);
  944. X    if(i < 0 || i >= NUMMONS) {    
  945. X        panic("monsndx - could not index monster (%lx)", (long)ptr);
  946. X        return FALSE;        /* will not get here */
  947. X    }
  948. X
  949. X    return(i);
  950. X}
  951. X
  952. X#endif /* OVL0 */
  953. X#ifdef OVL1
  954. X
  955. X
  956. Xint
  957. Xname_to_mon(str)
  958. Xchar *str;
  959. X{
  960. X    /* Be careful.  We must check the entire string in case it was
  961. X     * something such as "ettin zombie corpse".  The calling routine
  962. X     * doesn't know about the "corpse" until the monster name has
  963. X     * already been taken off the front, so we have to be able to
  964. X     * read the name with extraneous stuff such as "corpse" stuck on
  965. X     * the end.
  966. X     * This causes a problem for names which prefix other names such
  967. X     * as "ettin" on "ettin zombie".  In this case we want the _longest_
  968. X     * name which exists.
  969. X     * This also permits plurals created by adding suffixes such as 's'
  970. X     * or 'es'.  Other plurals must still be handled explicitly.
  971. X     */
  972. X    register int i;
  973. X    register int mntmp = -1;
  974. X    register char *s;
  975. X    char buf[BUFSZ];
  976. X    int len, slen;
  977. X
  978. X    Strcpy(buf, str);
  979. X    str = buf;
  980. X    if (!strncmp(str, "a ", 2)) str += 2;
  981. X    else if (!strncmp(str, "an ", 3)) str += 3;
  982. X
  983. X    /* Some irregular plurals */
  984. X    if (!strncmpi(str, "incubi", 6)) return PM_INCUBUS;
  985. X    if (!strncmpi(str, "succubi", 7)) return PM_SUCCUBUS;
  986. X    if (!strncmpi(str, "violet fungi", 12)) return PM_VIOLET_FUNGUS;
  987. X    if (!strncmpi(str, "homunculi", 9)) return PM_HOMUNCULUS;
  988. X    if (!strncmpi(str, "baluchitheria", 13)) return PM_BALUCHITHERIUM;
  989. X    if (!strncmpi(str, "lurkers above", 13)) return PM_LURKER_ABOVE;
  990. X    if (!strncmpi(str, "cavemen", 7)) return PM_CAVEMAN;
  991. X    if (!strncmpi(str, "cavewomen", 9)) return PM_CAVEWOMAN;
  992. X    if (!strncmpi(str, "zruties", 7)) return PM_ZRUTY;
  993. X    if (!strncmpi(str, "djinn", 5)) return PM_DJINNI;
  994. X    if (!strncmpi(str, "mumakil", 7)) return PM_MUMAK;
  995. X    if ((s = strstri(str, "vortices")) != 0)
  996. X        Strcpy(s+4, "ex");
  997. X    /* be careful with "ies"; "priest", "zombies" */
  998. X    else if ((s = strstri(str, "jellies")) != 0 ||
  999. X         (s = strstri(str, "mummies")) != 0)
  1000. X        Strcpy(s+4, "y");
  1001. X    /* luckily no monster names end in fe or ve with ves plurals */
  1002. X    else if ((s = strstri(str, "ves")) != 0)
  1003. X        Strcpy(s, "f");
  1004. X
  1005. X    slen = strlen(str);
  1006. X    for (len = 0, i = 0; i < NUMMONS; i++) {
  1007. X        register int m_i_len = strlen(mons[i].mname);
  1008. X        if (m_i_len > len && !strncmpi(mons[i].mname, str, m_i_len)) {
  1009. X        if (m_i_len == slen) return i;    /* exact match */
  1010. X        else if (slen > m_i_len &&
  1011. X            (str[m_i_len] == ' ' ||
  1012. X             !strcmpi(&str[m_i_len], "s") ||
  1013. X             !strncmpi(&str[m_i_len], "s ", 2) ||
  1014. X             !strcmpi(&str[m_i_len], "es") ||
  1015. X             !strncmpi(&str[m_i_len], "es ", 3))) {
  1016. X            mntmp = i;
  1017. X            len = m_i_len;
  1018. X        }
  1019. X        }
  1020. X    }
  1021. X    if (mntmp == -1) mntmp = title_to_mon(str, (int *)0, (int *)0);
  1022. X    return mntmp;
  1023. X}
  1024. X
  1025. X#endif /* OVL1 */
  1026. X#ifdef OVLB
  1027. X
  1028. X#ifdef POLYSELF
  1029. Xboolean
  1030. Xwebmaker(ptr)   /* creature can spin a web */
  1031. X    register struct permonst *ptr;
  1032. X{
  1033. X    return (ptr->mlet == S_SPIDER && ptr != &mons[PM_SCORPION]);
  1034. X}
  1035. X#endif
  1036. X
  1037. X#endif /* OVLB */
  1038. X#ifdef OVL2
  1039. X
  1040. X/* returns 3 values (0=male, 1=female, 2=none) */
  1041. Xint
  1042. Xgender(mtmp)
  1043. X    register struct monst *mtmp;
  1044. X{
  1045. X    if (is_neuter(mtmp->data)) return 2;
  1046. X    return mtmp->female;
  1047. X}
  1048. X
  1049. X#endif /* OVL2 */
  1050. X#ifdef OVLB
  1051. X
  1052. Xboolean
  1053. Xlevl_follower(mtmp)
  1054. Xregister struct monst *mtmp;
  1055. X{
  1056. X    return (mtmp->mtame || (mtmp->data->mflags2 & M2_STALK) || is_fshk(mtmp)
  1057. X        || (mtmp->iswiz && !mon_has_amulet(mtmp)));
  1058. X}
  1059. X
  1060. Xstruct permonst *
  1061. Xplayer_mon()
  1062. X{
  1063. X    switch (pl_character[0]) {
  1064. X        case 'A': return &mons[PM_ARCHEOLOGIST];
  1065. X        case 'B': return &mons[PM_BARBARIAN];
  1066. X        case 'C': if (flags.female) return &mons[PM_CAVEWOMAN];
  1067. X            else return &mons[PM_CAVEMAN];
  1068. X        case 'E': return &mons[PM_ELF];
  1069. X        case 'H': return &mons[PM_HEALER];
  1070. X        case 'K': return &mons[PM_KNIGHT];
  1071. X        case 'P': if (flags.female) return &mons[PM_PRIESTESS];
  1072. X            else return &mons[PM_PRIEST];
  1073. X        case 'R': return &mons[PM_ROGUE];
  1074. X        case 'S': return &mons[PM_SAMURAI];
  1075. X#ifdef TOURIST
  1076. X        case 'T': return &mons[PM_TOURIST];
  1077. X#endif
  1078. X        case 'V': return &mons[PM_VALKYRIE];
  1079. X        case 'W': return &mons[PM_WIZARD];
  1080. X        default: impossible("what are you?");
  1081. X            return &mons[PM_HUMAN];
  1082. X    }
  1083. X}
  1084. X
  1085. Xconst int grownups[][2] = { {PM_LITTLE_DOG, PM_DOG}, {PM_DOG, PM_LARGE_DOG},
  1086. X    {PM_HELL_HOUND_PUP, PM_HELL_HOUND}, {PM_KITTEN, PM_HOUSECAT},
  1087. X    {PM_HOUSECAT, PM_LARGE_CAT}, {PM_BABY_GRAY_DRAGON, PM_GRAY_DRAGON},
  1088. X    {PM_KOBOLD, PM_LARGE_KOBOLD}, {PM_LARGE_KOBOLD, PM_KOBOLD_LORD},
  1089. X    {PM_GNOME, PM_GNOME_LORD}, {PM_GNOME_LORD, PM_GNOME_KING},
  1090. X    {PM_DWARF, PM_DWARF_LORD}, {PM_DWARF_LORD, PM_DWARF_KING},
  1091. X    {PM_SMALL_MIMIC, PM_LARGE_MIMIC}, {PM_LARGE_MIMIC, PM_GIANT_MIMIC},
  1092. X    {PM_BAT, PM_GIANT_BAT},
  1093. X    {PM_LICH, PM_DEMILICH}, {PM_DEMILICH, PM_MASTER_LICH},
  1094. X    {PM_OGRE, PM_OGRE_LORD}, {PM_OGRE_LORD, PM_OGRE_KING},
  1095. X    {PM_VAMPIRE, PM_VAMPIRE_LORD},
  1096. X    {PM_BABY_RED_DRAGON, PM_RED_DRAGON},
  1097. X    {PM_BABY_WHITE_DRAGON, PM_WHITE_DRAGON},
  1098. X    {PM_BABY_BLUE_DRAGON, PM_BLUE_DRAGON},
  1099. X    {PM_BABY_GREEN_DRAGON, PM_GREEN_DRAGON},
  1100. X    {PM_BABY_ORANGE_DRAGON, PM_ORANGE_DRAGON},
  1101. X    {PM_BABY_BLACK_DRAGON, PM_BLACK_DRAGON},
  1102. X    {PM_BABY_YELLOW_DRAGON, PM_YELLOW_DRAGON},
  1103. X    {PM_RED_NAGA_HATCHLING, PM_RED_NAGA},
  1104. X    {PM_BLACK_NAGA_HATCHLING, PM_BLACK_NAGA},
  1105. X    {PM_GOLDEN_NAGA_HATCHLING, PM_GOLDEN_NAGA},
  1106. X    {PM_GUARDIAN_NAGA_HATCHLING, PM_GUARDIAN_NAGA},
  1107. X    {PM_BABY_PURPLE_WORM, PM_PURPLE_WORM},
  1108. X    {PM_BABY_LONG_WORM, PM_LONG_WORM},
  1109. X#ifdef ARMY
  1110. X    {PM_SOLDIER, PM_SERGEANT},
  1111. X    {PM_SERGEANT, PM_LIEUTENANT},
  1112. X    {PM_LIEUTENANT, PM_CAPTAIN},
  1113. X#endif
  1114. X    {PM_WATCHMAN, PM_WATCH_CAPTAIN},
  1115. X    {PM_BABY_CROCODILE, PM_CROCODILE},
  1116. X    {-1,-1}
  1117. X};
  1118. X
  1119. Xint
  1120. Xlittle_to_big(montype)
  1121. Xint montype;
  1122. X{
  1123. X#ifndef AIXPS2_BUG
  1124. X    register int i;
  1125. X    
  1126. X    for(i=0; grownups[i][0] >= 0; i++)
  1127. X        if(montype == grownups[i][0]) return grownups[i][1];
  1128. X    return montype;
  1129. X#else
  1130. X/* AIX PS/2 C-compiler 1.1.1 optimizer does not like the above for loop,
  1131. X * and causes segmentation faults at runtime.  (The problem does not
  1132. X * occur if -O is not used.)
  1133. X * lehtonen@cs.Helsinki.FI (Tapio Lehtonen) 28031990
  1134. X */
  1135. X    int i;
  1136. X    int monvalue;
  1137. X
  1138. X    monvalue = montype;
  1139. X    for(i=0; grownups[i][0] >= 0; i++)
  1140. X        if(montype == grownups[i][0]) monvalue = grownups[i][1];
  1141. X    
  1142. X    return monvalue;
  1143. X#endif
  1144. X}
  1145. X
  1146. Xint
  1147. Xbig_to_little(montype)
  1148. Xint montype;
  1149. X{
  1150. X    register int i;
  1151. X    
  1152. X    for(i=0; grownups[i][0] >= 0; i++)
  1153. X        if(montype == grownups[i][1]) return grownups[i][0];
  1154. X    return montype;
  1155. X}
  1156. X
  1157. X
  1158. Xconst char *
  1159. Xlocomotion(ptr, def)
  1160. Xconst struct permonst *ptr;
  1161. Xconst char *def;
  1162. X{
  1163. X    return (
  1164. X        is_floater(ptr) ? (const char *)"float" :
  1165. X        is_flyer(ptr)   ? (const char *)"fly" :
  1166. X        slithy(ptr)     ? (const char *)"slither" :
  1167. X        amorphous(ptr)  ? (const char *)"ooze" :
  1168. X        nolimbs(ptr)    ? (const char *)"crawl" :
  1169. X        def
  1170. X           );
  1171. X
  1172. X}
  1173. X
  1174. X#endif /* OVLB */
  1175. X
  1176. X/*mondata.c*/
  1177. END_OF_FILE
  1178. if test 10482 -ne `wc -c <'src/mondata.c'`; then
  1179.     echo shar: \"'src/mondata.c'\" unpacked with wrong size!
  1180. fi
  1181. # end of 'src/mondata.c'
  1182. fi
  1183. if test -f 'sys/mac/macmain.c' -a "${1}" != "-c" ; then 
  1184.   echo shar: Will not clobber existing file \"'sys/mac/macmain.c'\"
  1185. else
  1186. echo shar: Extracting \"'sys/mac/macmain.c'\" \(12965 characters\)
  1187. sed "s/^X//" >'sys/mac/macmain.c' <<'END_OF_FILE'
  1188. X/*    SCCS Id: @(#)macmain.c    3.1    92/12/04    */
  1189. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  1190. X/* NetHack may be freely redistributed.  See license for details. */
  1191. X
  1192. X/* main.c - Mac NetHack */
  1193. X
  1194. X#include "hack.h"
  1195. X
  1196. X#include <OSUtils.h>
  1197. X#include <files.h>
  1198. X#include <Types.h>
  1199. X#ifdef MAC_MPW32
  1200. X#include <String.h>
  1201. X#include <Strings.h>
  1202. X#endif
  1203. X#ifdef MAC_THINKC5
  1204. X#include <pascal.h>
  1205. X#endif
  1206. X#include <Dialogs.h>
  1207. X#include <Packages.h>
  1208. X#include <ToolUtils.h>
  1209. X#include <Resources.h>
  1210. X#include <SysEqu.h>
  1211. X#include <Errors.h>
  1212. X
  1213. X#ifndef O_RDONLY
  1214. X#include <fcntl.h>
  1215. X#endif
  1216. X
  1217. Xint NDECL(main);
  1218. Xvoid NDECL(ListGUnloads);
  1219. X
  1220. Xstatic void NDECL(process_options);
  1221. Xstatic void NDECL(whoami);
  1222. X
  1223. Xextern char * PtoCstr ( unsigned char * ) ;
  1224. Xextern unsigned char * CtoPstr ( char * ) ;
  1225. Xvoid SetFrameItem ( DialogPtr , short , short ) ;
  1226. X
  1227. Xextern void NDECL ( finder_file_request ) ;
  1228. X// void NDECL( askname ) ;
  1229. X
  1230. Xextern void NDECL ( InitMac ) ;
  1231. X
  1232. Xint
  1233. Xmain ( void )
  1234. X{
  1235. X    register int fd;
  1236. X
  1237. X    windowprocs = mac_procs ;
  1238. X    InitMac ( ) ;
  1239. X
  1240. X    hname = "Mac Hack" ;
  1241. X    hackpid = getpid();
  1242. X
  1243. X    initoptions();
  1244. X    init_nhwindows();
  1245. X    whoami();
  1246. X
  1247. X    /*
  1248. X     * It seems you really want to play.
  1249. X     */
  1250. X    setrandom();
  1251. X    u.uhp = 1;    /* prevent RIP on early quits */
  1252. X
  1253. X    process_options ( ) ;    /* emulate command line options */
  1254. X    finder_file_request ( ) ;
  1255. X
  1256. X#ifdef WIZARD
  1257. X    if (wizard)
  1258. X        Strcpy(plname, "wizard");
  1259. X    else
  1260. X#endif
  1261. X    if(!*plname || !strncmp(plname, "player", 4)
  1262. X            || !strncmp(plname, "games", 4))
  1263. X        askname();
  1264. X    plnamesuffix();        /* strip suffix from name; calls askname() */
  1265. X                /* again if suffix was whole name */
  1266. X                /* accepts any suffix */
  1267. X
  1268. X    Sprintf ( lock , "%d%s" , getuid ( ) , plname ) ;
  1269. X    getlock ( ) ;
  1270. X
  1271. X    /*
  1272. X     * Initialisation of the boundaries of the mazes
  1273. X     * Both boundaries have to be even.
  1274. X     */
  1275. X
  1276. X    x_maze_max = COLNO-1;
  1277. X    if (x_maze_max % 2)
  1278. X        x_maze_max--;
  1279. X    y_maze_max = ROWNO-1;
  1280. X    if (y_maze_max % 2)
  1281. X        y_maze_max--;
  1282. X
  1283. X    /*
  1284. X     *  Initialize the vision system.  This must be before mklev() on a
  1285. X     *  new game or before a level restore on a saved game.
  1286. X     */
  1287. X    vision_init();
  1288. X
  1289. X    display_gamewindows();
  1290. X
  1291. X    set_savefile_name();
  1292. X    uncompress(SAVEF);
  1293. X
  1294. X    if((fd = open_savefile()) >= 0 &&
  1295. X       /* if not up-to-date, quietly delete file via false condition */
  1296. X       (uptodate(fd) || delete_savefile())) {
  1297. X#ifdef WIZARD
  1298. X        /* Since wizard is actually flags.debug, restoring might
  1299. X         * overwrite it.
  1300. X         */
  1301. X        boolean remember_wiz_mode = wizard;
  1302. X#endif
  1303. X#ifdef NEWS
  1304. X        if(flags.news) display_file(NEWS, FALSE);
  1305. X#endif
  1306. X        pline("Restoring save file...");
  1307. X        mark_synch();    /* flush output */
  1308. X        if(!dorecover(fd))
  1309. X            goto not_recovered;
  1310. X#ifdef WIZARD
  1311. X        if(!wizard && remember_wiz_mode) wizard = TRUE;
  1312. X#endif
  1313. X        pline("Hello %s, welcome back to NetHack!", plname);
  1314. X        check_special_room(FALSE);
  1315. X
  1316. X#ifdef EXPLORE_MODE
  1317. X        if (discover)
  1318. X            You("are in non-scoring discovery mode.");
  1319. X#endif
  1320. X#if defined(EXPLORE_MODE) || defined(WIZARD)
  1321. X        if (discover || wizard) {
  1322. X            if(yn("Do you want to keep the save file?") == 'n')
  1323. X                (void) delete_savefile();
  1324. X            else {
  1325. X                compress(SAVEF);
  1326. X            }
  1327. X        }
  1328. X#endif
  1329. X        flags.move = 0;
  1330. X    } else {
  1331. Xnot_recovered:
  1332. X        player_selection();
  1333. X        newgame();
  1334. X        /* give welcome message before pickup messages */
  1335. X        pline("Hello %s, welcome to NetHack!", plname);
  1336. X#ifdef EXPLORE_MODE
  1337. X        if (discover)
  1338. X            You("are in non-scoring discovery mode.");
  1339. X#endif
  1340. X        flags.move = 0;
  1341. X        set_wear();
  1342. X        pickup(1);
  1343. X    }
  1344. X
  1345. X    flags.moonphase = phase_of_the_moon();
  1346. X    if(flags.moonphase == FULL_MOON) {
  1347. X        You("are lucky!  Full moon tonight.");
  1348. X        change_luck(1);
  1349. X    } else if(flags.moonphase == NEW_MOON) {
  1350. X        pline("Be careful!  New moon tonight.");
  1351. X    }
  1352. X    if(flags.friday13 = friday_13th()) {
  1353. X        pline("Watch out!  Bad things can happen on Friday the 13th.");
  1354. X        change_luck(-1);
  1355. X    }
  1356. X
  1357. X    initrack();
  1358. X
  1359. X    UndimMenuBar ( ) ; /* Yes, this is the place for it (!) */
  1360. X    
  1361. X    attemptingto("proceed");
  1362. X#if defined(MAC_MPW32) && !defined(MODEL_FAR)
  1363. X    UnloadAllSegments();                        /* Do this before naming residents */
  1364. X    IsResident( (Ptr) display_nhwindow );        /* Sample resident segments */
  1365. X    IsResident( (Ptr) rhack );
  1366. X    IsResident( (Ptr) engr_at );
  1367. X    IsResident( (Ptr) movemon );
  1368. X    IsResident( (Ptr) attacktype ) ;
  1369. X    IsResident( (Ptr) mac_get_nh_event ) ;
  1370. X#endif
  1371. X    moveloop();
  1372. X    /*NOTREACHED*/
  1373. X    return 0;
  1374. X}
  1375. X
  1376. X
  1377. X/*
  1378. X * This filter handles the movable-modal dialog
  1379. X *
  1380. X */
  1381. Xstatic pascal Boolean
  1382. XDragFilter ( DialogPtr dp , EventRecord * event , short * item )
  1383. X{
  1384. X    WindowPtr wp ;
  1385. X    short code ;
  1386. X    Rect r ;
  1387. X
  1388. X/*
  1389. X *    Handle shortcut keys
  1390. X *    enter, return -> OK
  1391. X *    clear, escape, period -> Cancel
  1392. X *    all others are handled default
  1393. X *
  1394. X */
  1395. X
  1396. X    if ( event -> what == keyDown ) {
  1397. X
  1398. X        char c = event -> message & 0xff ;
  1399. X        unsigned char b = ( event -> message >> 8 ) & 0xff ;
  1400. X
  1401. X        switch ( c ) {
  1402. X
  1403. X        case 3 :    /* 3 == Enter */
  1404. X        case 10 :    /* Newline */
  1405. X        case 13 :    /* Return */
  1406. X            * item = 1 ;
  1407. X            return 1 ;
  1408. X
  1409. X        case '.' :    /* Cmd-period - we allow only period */
  1410. X        case 27 :    /* Escape */
  1411. X            * item = 2 ;
  1412. X            return 1 ;
  1413. X        }
  1414. X
  1415. X        switch ( b ) {
  1416. X
  1417. X        case 0x4c :    /* Enter */
  1418. X        case 0x24 :    /* Return */
  1419. X            * item = 1 ;
  1420. X            return 1 ;
  1421. X
  1422. X        case 0x35 :    /* Escape */
  1423. X        case 0x47 :    /* Clear */
  1424. X            * item = 2 ;
  1425. X            return 1 ;
  1426. X        }
  1427. X
  1428. X        return 0 ;
  1429. X    }
  1430. X
  1431. X/*
  1432. X *    OK, don't handle others
  1433. X *
  1434. X */
  1435. X
  1436. X    if ( event -> what != mouseDown ) {
  1437. X
  1438. X        return 0 ;
  1439. X    }
  1440. X    code = FindWindow ( event -> where , & wp ) ;
  1441. X    if ( wp != dp || code != inDrag ) {
  1442. X
  1443. X        return 0 ;
  1444. X    }
  1445. X    r = ( * GetGrayRgn ( ) ) -> rgnBBox ;
  1446. X    InsetRect ( & r , 3 , 3 ) ;
  1447. X
  1448. X    DragWindow ( wp , event -> where , & r ) ;
  1449. X    SaveWindowPos ( wp ) ;
  1450. X
  1451. X    event -> what = nullEvent ;
  1452. X    return 1 ;
  1453. X}
  1454. X
  1455. X
  1456. X/*
  1457. X * plname is filled either by an option (-u Player  or  -uPlayer) or
  1458. X * explicitly (by being the wizard) or by askname.
  1459. X * It may still contain a suffix denoting pl_character.
  1460. X */
  1461. Xvoid
  1462. Xmac_askname(void) /* Code taken from getlin */
  1463. X{
  1464. X    ControlHandle    ctrl ;
  1465. X    DialogPtr        promptDialog ;
  1466. X    short            itemHit , type ;
  1467. X    Rect            box ;
  1468. X    Str255            pasStr ;
  1469. X
  1470. X    /*
  1471. X    ** Set the query line as parameter text.
  1472. X    */
  1473. X
  1474. X    ParamText ( "\PWho are you?" , "\p" , "\p" , "\p" ) ;
  1475. X
  1476. X    promptDialog = GetNewDialog ( 130 , ( Ptr ) NULL , ( WindowPtr ) -1 ) ;
  1477. X    ShowWindow ( promptDialog ) ;
  1478. X
  1479. X    InitCursor ( ) ;
  1480. X    SetFrameItem ( promptDialog , 6 , 1 ) ;
  1481. X    do {
  1482. X
  1483. X        ModalDialog ( ( ModalFilterProcPtr ) DragFilter , & itemHit ) ;
  1484. X
  1485. X    } while ( ( itemHit != 1 ) && ( itemHit != 2 ) ) ;
  1486. X
  1487. X    if ( itemHit == 1 ) {
  1488. X
  1489. X        /*
  1490. X        ** Get the text from the text edit item.
  1491. X        */
  1492. X
  1493. X        GetDItem ( promptDialog , 4 , & type , ( Handle * ) & ctrl , & box ) ;
  1494. X        GetIText ( ( Handle ) ctrl , pasStr ) ;
  1495. X
  1496. X        /*
  1497. X        ** Convert it to a 'C' string and copy it into the return value.
  1498. X        */
  1499. X
  1500. X        PtoCstr ( pasStr ) ;
  1501. X        strcpy ( plname , ( char * ) pasStr ) ;
  1502. X
  1503. X    /*
  1504. X     * Special check for debugging here
  1505. X     *
  1506. X     */
  1507. X#ifdef WIZARD
  1508. X        if ( ! strcmp ( plname , WIZARD ) ) {
  1509. X
  1510. X            flags . debug = 1 ;
  1511. X        }
  1512. X#endif
  1513. X
  1514. X    } else {
  1515. X
  1516. X        /*
  1517. X        ** Okay, we didn't want to run
  1518. X        */
  1519. X
  1520. X    /*    * ( short * ) DSErrCode = dsBadLaunch ; */
  1521. X        ExitToShell ( ) ;
  1522. X    }
  1523. X
  1524. X    DisposDialog ( promptDialog ) ;
  1525. X}
  1526. X
  1527. X
  1528. Xstatic void
  1529. Xprocess_options(void)
  1530. X{
  1531. X    int argc = 0 ;
  1532. X    char * foo [ ] = { "Mac Hack" , NULL } ;
  1533. X    char * * argv = foo ;
  1534. X    /*
  1535. X     * Process options.
  1536. X     */
  1537. X    while(argc > 1 && argv[1][0] == '-'){
  1538. X        argv++;
  1539. X        argc--;
  1540. X        switch(argv[0][1]){
  1541. X#if defined(WIZARD) || defined(EXPLORE_MODE)
  1542. X# ifndef EXPLORE_MODE
  1543. X        case 'X':
  1544. X# endif
  1545. X        case 'D':
  1546. X# ifdef WIZARD
  1547. X            wizard = TRUE ;
  1548. X            break ;
  1549. X# endif
  1550. X# ifdef EXPLORE_MODE
  1551. X        case 'X':
  1552. X            discover = TRUE;
  1553. X# endif
  1554. X            break;
  1555. X#endif
  1556. X#ifdef NEWS
  1557. X        case 'n':
  1558. X            flags.news = FALSE;
  1559. X            break;
  1560. X#endif
  1561. X        case 'u':
  1562. X            if(argv[0][2])
  1563. X              (void) strncpy(plname, argv[0]+2, sizeof(plname)-1);
  1564. X            else if(argc > 1) {
  1565. X              argc--;
  1566. X              argv++;
  1567. X              (void) strncpy(plname, argv[0], sizeof(plname)-1);
  1568. X            } else
  1569. X                raw_print("Player name expected after -u");
  1570. X            break;
  1571. X        case 'I':
  1572. X        case 'i':
  1573. X            if (!strncmpi(argv[0]+1, "IBM", 3))
  1574. X                switch_graphics(IBM_GRAPHICS);
  1575. X            break;
  1576. X        /*  case 'D': */
  1577. X        case 'd':
  1578. X            if (!strncmpi(argv[0]+1, "DEC", 3))
  1579. X                switch_graphics(DEC_GRAPHICS);
  1580. X            break;
  1581. X        default:
  1582. X            /* allow -T for Tourist, etc. */
  1583. X            (void) strncpy(pl_character, argv[0]+1,
  1584. X                sizeof(pl_character)-1);
  1585. X
  1586. X            /* raw_print("Unknown option: %s", *argv); */
  1587. X        }
  1588. X    }
  1589. X}
  1590. X
  1591. X
  1592. Xstatic void
  1593. Xwhoami ( void )
  1594. X{
  1595. X    /*TODO*/
  1596. X    donull ( ) ;
  1597. X}
  1598. X
  1599. X
  1600. X/*------------------- UnloadAllSegments and support stuff --------------------------*/
  1601. X/* Derived from MacApp source */
  1602. X
  1603. Xtypedef Handle **HandleListHandle;
  1604. Xtypedef Boolean **BoolListHandle;
  1605. Xtypedef short *ShortPtr, **ShortHandle;
  1606. X
  1607. Xshort FDECL(GetSegNumber,(ShortPtr));
  1608. Xvoid FDECL(InitSegMgmt,(void *));
  1609. Xpascal long NDECL(GetA5);
  1610. Xpascal short NDECL(GetCurJTOffset);
  1611. Xvoid NDECL(UnloadAllSegments);
  1612. Xvoid FDECL(IsResident,(void *));
  1613. Xvoid FDECL(NotResident, (void *));
  1614. X
  1615. Xshort              pMaxSegNum = 0,        /* Highest segment number */
  1616. X                   gCodeRefNum;            /* rsrc refnum of the application */
  1617. XHandleListHandle gCodeSegs;                /* List of code seg handles */
  1618. XBoolListHandle   gIsResidentSeg;        /* Resident flags */
  1619. X
  1620. X#define kLoaded   0x4EF9                /* if loaded then a JMP instruction */
  1621. X#define    kUnLoaded 0x3F3C                /* if unloaded then a LoadSeg trap */
  1622. X                                        /* Note: probably incorrect for -model far! */
  1623. X
  1624. X/* #define TRACKSEGS /* Utility to print a trace of segment load frequencies. Add
  1625. X   a call to ListGUnloads into terminate() in end.c to use it */
  1626. X
  1627. X#ifdef TRACKSEGS
  1628. X
  1629. Xlong      gUnloads[120];
  1630. Xchar      gSegNames[120][16];
  1631. X
  1632. Xvoid ListGUnloads(void)
  1633. X{
  1634. X  int i;
  1635. X  FILE *f;
  1636. X  
  1637. X  f = fopen("unloads","r+");
  1638. X  fprintf(f,"%d calls to UnloadAllSegments\n\n",gUnloads[0]);
  1639. X  for (i=1; i<=pMaxSegNum; i++) {
  1640. X     fprintf(f,"Unloaded %10s, segment %2d, %6d times\n",gSegNames[i],i,gUnloads[i]);
  1641. X  }
  1642. X  fclose(f);
  1643. X}
  1644. X
  1645. X#endif
  1646. X
  1647. Xshort GetSegNumber(ShortPtr aProc)
  1648. X/* Derives seg number from a procedure ptr */
  1649. X
  1650. X{
  1651. X    if (*aProc == kLoaded)                 /* loaded segment */
  1652. X        return(*--aProc);
  1653. X    else if (*aProc == kUnLoaded)          /* unloaded segment */
  1654. X        return(*++aProc);
  1655. X    else {
  1656. X        progerror("GetSegNumber was not passed an jump table address");
  1657. X        return(1);
  1658. X    }
  1659. X}
  1660. X
  1661. Xvoid InitSegMgmt(void * mainSeg)
  1662. X/* Initialise a list of handles to all the CODE segments and mark the mainseg as resident */
  1663. X{
  1664. X    short     i,
  1665. X            lastRsrc,
  1666. X            rsrcID,
  1667. X            oldResFile;
  1668. X    Handle  seg;
  1669. X    ResType rsrcType;
  1670. X    Str255  rsrcName;
  1671. X     
  1672. X    gCodeRefNum = HomeResFile(GetResource('CODE', 1));    
  1673. X    oldResFile = CurResFile();
  1674. X    UseResFile(gCodeRefNum);
  1675. X    
  1676. X    /* Discover the highest CODE rsrc ID: be ready for noncontiguous IDs */
  1677. X    lastRsrc = Count1Resources('CODE');    
  1678. X    SetResLoad(false);
  1679. X    for (i=1; i<=lastRsrc; i++) 
  1680. X        if (seg = Get1IndResource('CODE', i)) {
  1681. X            GetResInfo(seg, &rsrcID, &rsrcType, rsrcName);
  1682. X            if (rsrcID > pMaxSegNum) pMaxSegNum = rsrcID;
  1683. X        }
  1684. X        
  1685. X    /* Make handles of appropriate size to keep flags/segment handles */
  1686. X    SetResLoad(true);  /* In case we fail */
  1687. X    gCodeSegs = (HandleListHandle) NewHandle((pMaxSegNum+1) * sizeof(Handle));    
  1688. X    mustwork(MemError());
  1689. X    gIsResidentSeg = (BoolListHandle) NewHandle((pMaxSegNum+1) * sizeof(Boolean));
  1690. X    mustwork(MemError());
  1691. X    SetResLoad(false);    
  1692. X
  1693. X    #ifdef TRACKSEGS
  1694. X    gUnloads[0]=0;
  1695. X    #endif
  1696. X    for (i=1; i<=pMaxSegNum; i++) {
  1697. X       (*gIsResidentSeg)[i] = false;
  1698. X       (*gCodeSegs)[i] = Get1Resource('CODE',i);   /* Will be NIL if it doesn't exist */
  1699. X       #ifdef TRACKSEGS
  1700. X       {  /* Go get the segment name and save it */
  1701. X          short id;
  1702. X          ResType rType;
  1703. X          Str255 name;
  1704. X          char *cptr;
  1705. X          
  1706. X          GetResInfo((*gCodeSegs)[i],&id,&rType,&name);
  1707. X          if (name[0]>15) name[0]=15;
  1708. X          cptr = p2cstr(&name);
  1709. X          cptr = strcpy(&gSegNames[i], &name);
  1710. X          gUnloads[i] = 0;
  1711. X       }
  1712. X       #endif
  1713. X    }
  1714. X    SetResLoad(true);    
  1715. X    (*gIsResidentSeg)[GetSegNumber((ShortPtr)mainSeg)] = true;    
  1716. X    UseResFile(oldResFile);
  1717. X}
  1718. X
  1719. X#ifdef MAC_MPW32
  1720. Xpascal long GetA5(void) = { 0x2E8D };                    /* MOVE.L A5,(A7) */
  1721. Xpascal short GetCurJTOffset(void) = { 0x3EB8, 0x934 };   /* MOVE.W CurJTOffset,(SP) */
  1722. X#endif
  1723. X#ifdef MAC_THINKC5
  1724. Xpascal long GetA5(void) = { 0x2E8D };                    /* MOVE.L A5,(A7) */
  1725. Xpascal short GetCurJTOffset(void) = { 0x3EB8, 0x934 };   /* MOVE.W CurJTOffset,(SP) */
  1726. X#endif
  1727. X
  1728. Xvoid UnloadAllSegments(void)
  1729. X{
  1730. X  short     i,
  1731. X         oldResFile;
  1732. X  Handle seg;
  1733. X  long     jumpTablePtr;
  1734. X
  1735. X  jumpTablePtr = GetA5() + GetCurJTOffset();
  1736. X  oldResFile = CurResFile();
  1737. X  UseResFile(gCodeRefNum);
  1738. X#ifdef TRACKSEGS
  1739. X  gUnloads[0]++;
  1740. X#endif
  1741. X  for (i=1; i<=pMaxSegNum; i++)
  1742. X      if (!(*gIsResidentSeg)[i]) {
  1743. X          seg = (*gCodeSegs)[i];
  1744. X          if ((seg != (Handle) nil) && (*seg != (Ptr) nil))  /* Check it exists and hasn't been purged */
  1745. X              if (HGetState(seg) & 0x80)  {   /* Is it locked? => loaded */
  1746. X#ifdef TRACKSEGS
  1747. X                 gUnloads[i]++;
  1748. X#endif
  1749. X                 UnloadSeg( (void *) (jumpTablePtr + **(ShortHandle)seg + 2) );
  1750. X              }
  1751. X      }
  1752. X
  1753. X  UseResFile(oldResFile);
  1754. X}
  1755. X
  1756. Xvoid IsResident( void * routineaddr )
  1757. X/* We want to move this high up in the heap as it won't be shifted again, so... */
  1758. X{
  1759. X    int    segnum;
  1760. X    Handle theseg;
  1761. X    
  1762. X    segnum = GetSegNumber((ShortPtr)routineaddr);
  1763. X    theseg = (*gCodeSegs)[segnum];
  1764. X    UnloadSeg( routineaddr );
  1765. X    if (*theseg != nil) {
  1766. X       MoveHHi( theseg );  /* If it has been purged we can't do this */
  1767. X       HLock( theseg );
  1768. X    }
  1769. X    (*gIsResidentSeg)[segnum] = true;    
  1770. X}
  1771. X
  1772. Xvoid NotResident( void * routineaddr )
  1773. X{
  1774. X    (*gIsResidentSeg)[GetSegNumber((ShortPtr)routineaddr)] = false;    
  1775. X}
  1776. X
  1777. X/*macmain.c*/
  1778. END_OF_FILE
  1779. if test 12965 -ne `wc -c <'sys/mac/macmain.c'`; then
  1780.     echo shar: \"'sys/mac/macmain.c'\" unpacked with wrong size!
  1781. fi
  1782. # end of 'sys/mac/macmain.c'
  1783. fi
  1784. if test -f 'sys/share/termcap' -a "${1}" != "-c" ; then 
  1785.   echo shar: Will not clobber existing file \"'sys/share/termcap'\"
  1786. else
  1787. echo shar: Extracting \"'sys/share/termcap'\" \(5404 characters\)
  1788. sed "s/^X//" >'sys/share/termcap' <<'END_OF_FILE'
  1789. X#
  1790. X#    MS/PC-DOS ANSI.SYS termcap
  1791. X#
  1792. Xansi|color|ansi-color|ibm|ibmpc|ANSI.SYS color:\
  1793. X    :co#80:li#24:bs:pt:bl=^G:le=^H:do=^J:\
  1794. X    :cl=\E[H\E[2J:ce=\E[K:\
  1795. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  1796. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  1797. X    :ti=\E[0;44m:te=\E[0m:\
  1798. X    :so=\E[1;35;44m:se=\E[0;44m:\
  1799. X    :us=\E[1;31;44m:ue=\E[0;44m:\
  1800. X    :mb=\E[5m:md=\E[1m:me=\E[0;44m:
  1801. Xmono|ansi-mono|ANSI.SYS:\
  1802. X    :co#80:li#24:bs:pt:bl=^G:le=^H:do=^J:\
  1803. X    :cl=\E[H\E[2J:ce=\E[K:\
  1804. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  1805. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  1806. X    :so=\E[1m:se=\E[m:us=\E[4m:ue=\E[m:\
  1807. X    :mb=\E[5m:md=\E[1m:me=\E[m:
  1808. X#
  1809. X#    This is a termcap for NNANSI.SYS (New & Improved NANSI.SYS),
  1810. X#    a faster and more complete public domain replacement for
  1811. X#    ANSI.SYS, and two other ANSI.SYS replacements, NANSI.SYS and
  1812. X#    ZANSI.SYS.
  1813. X#
  1814. X#    NANSI and ZANSI support line insert (al) and delete (dl)
  1815. X#    and character insert (ic) and delete (dc) where ANSI.SYS
  1816. X#    does not.  NNANSI.SYS also supports clear to end of display
  1817. X#    (cd), does reverse video (mr) properly, and emulates SGR
  1818. X#    more fully, allowing correct end sequences for standout (se)
  1819. X#    and end of underline (ue).
  1820. X#
  1821. Xnnansi-mono|NNANSI.SYS:\
  1822. X    :co#80:li#25:bs:pt:bl=^G:le=^H:do=^J:\
  1823. X    :cl=\E[2J:cd=\E[J:ce=\E[K:\
  1824. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  1825. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  1826. X    :so=\E[1m:se=\E[2m:\
  1827. X    :us=\E[4m:ue=\E[24m:\
  1828. X    :mb=\E[5m:md=\E[1m:mh=\E[2m:mr=\E[7m:me=\E[m:\
  1829. X    :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:
  1830. Xnnansi|NNANSI.SYS color:\
  1831. X    :co#80:li#25:bs:pt:bl=^G:le=^H:do=^J:\
  1832. X    :cl=\E[2J:cd=\E[J:ce=\E[K:\
  1833. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  1834. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  1835. X    :ti=\E[0;44m:te=\E[0m:\
  1836. X    :so=\E[1;35;44m:se=\E[2;37m:\
  1837. X    :us=\E[4m:ue=\E[24m:\
  1838. X    :mb=\E[5m:md=\E[1m:mh=\E[2m:mr=\E[7m:me=\E[0;44m:\
  1839. X    :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:
  1840. Xnansi-mono|zansi-mono|N/ZANSI.SYS:\
  1841. X    :co#80:li#25:bs:pt:bl=^G:le=^H:do=^J:\
  1842. X    :cl=\E[2J:ce=\E[K:\
  1843. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  1844. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  1845. X    :ti=\E[0m:te=\E[0m:\
  1846. X    :so=\E[1;35m:se=\E[0m:\
  1847. X    :us=\E[1;31m:ue=\E[0m:\
  1848. X    :mb=\E[5m:md=\E[1m:mr=\E[7m:me=\E[m:\
  1849. X    :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:
  1850. Xnansi|zansi|N/ZANSI.SYS color:\
  1851. X    :co#80:li#25:bs:pt:bl=^G:le=^H:do=^J:\
  1852. X    :cl=\E[2J:ce=\E[K:\
  1853. X    :ho=\E[H:cm=\E[%i%d;%dH:\
  1854. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  1855. X    :ti=\E[0;44m:te=\E[0m:\
  1856. X    :so=\E[1;35;44m:se=\E[0;44m:\
  1857. X    :us=\E[1;31;44m:ue=\E[0;44m:\
  1858. X    :mb=\E[5m:md=\E[1m:mr=\E[7m:me=\E[0;44m:\
  1859. X    :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:
  1860. X#
  1861. X# For ST NetHack:
  1862. X#       for VT100/200/&c in VT52 mode, add :ti=\E[?2l:
  1863. Xvt52|atari|DEC VT52:\
  1864. X    :co#80:li#24:bs:pt:bl=^G:le=^H:do=^J:\
  1865. X    :cl=\EH\EJ:ce=\EK:cd=\EJ:\
  1866. X    :ho=\EH:cm=\EY%+ %+ :\
  1867. X    :up=\EA:do=\EB:le=\EC:ri=\ED:nd=\EC:\
  1868. X    :ku=\EA:kd=\EB:kl=\EC:kr=\ED:kb=^H:\
  1869. X    :sr=\EI:as=\EF:ae=\EG:
  1870. X#
  1871. X# For Amiga or VMS NetHack:
  1872. X#       VT100 or clone without the advanced video option installed
  1873. Xvt100|amiga|vt100-80|vt100-noavo|DEC VT100:\
  1874. X    :co#80:li#24:bs:pt:am:mi:bl=^G:le=^H:do=^J:xo:vt#3:\
  1875. X    :cl=50\E[H\E[J:ce=3\E[K:cd=50\E[J:\
  1876. X    :ho=\E[H:cm=5\E[%i%d;%dH:cs=\E[%i%d;%dr:\
  1877. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  1878. X    :UP=\E[%dA:DO=\E[%dB:LE=\E[%dC:RI=\E[%dD:\
  1879. X    :so=2\E[7m:se=2\E[m:us=2\E[4m:ue=2\E[m:\
  1880. X    :mb=2\E[5m:md=2\E[1m:mr=2\E[7m:me=2\E[m:\
  1881. X    :ti=4\E<\E(B\E)0:as=^N:ae=^O:\
  1882. X    :ks=\E[?1h\E=:ke=\E[?1l\E>:ku=\E[A:kd=\E[B:kl=\E[C:kr=\E[D:kb=^H:\
  1883. X    :kn#4:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:\
  1884. X    :sc=\E7:ec=\E8:sr=5\EM:
  1885. X#
  1886. X# VT102 and up:
  1887. X#       includes VT100 with advanced video option
  1888. Xvt102|vt102-80|vt100-avo|DEC VT102:\
  1889. X    :im=\E[4h:ei=\E[4l:al=5\E[L:dl=5\E[M:dc=5\E[P:\
  1890. X    :AL=9\E[%dL:DL=9\E[%dM:tc=vt100:
  1891. Xvt200|vt200-80|vt220|vt240|vt241|VT200_Series:\
  1892. X    :ic=5\E[@:tc=vt102:
  1893. Xvt300|vt300-80|vt320|vt330|vt340|VT300_Series:\
  1894. X    :tc=vt200:
  1895. Xvt400|vt400-80|vt420|VT400_Series:\
  1896. X    :tc=vt300:
  1897. X# VAXstations (should have full entries with no delays and 8-bit CSI's)
  1898. XVWS|UIS:tc=vt200:
  1899. XDECterm:tc=vt300:
  1900. X#
  1901. X# Wide screen (magnifying glass not included;-)
  1902. X#       note: vt100 w/o AVO only supports 14 lines when in 132-column mode
  1903. Xvt132|vt100-132:vt102-132:\
  1904. X    :co#132:ti=9\E<\E(B\E)0\E[?3h:tc=vt102:
  1905. Xvt200-132|vt300-132:\
  1906. X    :co#132:ti=9\E<\E(B\E)0\E[?3h:tc=vt200:
  1907. X#
  1908. X#
  1909. X# For really complete ANSI emulations (FANSI-CONSOLE?):
  1910. X#
  1911. XAX|ANSI X3.64|full ANSI X3.64 (1977) standard:\
  1912. X    :co#80:li#24:bs:pt:am:mi:bl=^G:le=^H:\
  1913. X    :cl=\E[2J:ce=\E[K:cd=\E[J:\
  1914. X    :ho=\E[H:cm=\E[%i%d;%dH:cs=\E[%i%d;%dr:\
  1915. X    :up=\E[A:do=\E[B:le=\E[C:ri=\E[D:nd=\E[C:\
  1916. X    :UP=\E[%dA:DO=\E[%dB:LE=\E[%dC:RI=\E[%dD:\
  1917. X    :so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m:\
  1918. X    :mb=\E[5m:md=\E[1m:mr=\E[7m:me=\E[m:as=^N:ae=^O:\
  1919. X    :ku=\E[A:kd=\E[B:kl=\E[C:kr=\E[D:kb=^H:\
  1920. X    :kn#4:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:\
  1921. X    :im=\E[4h:ei=\E[4l:al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:sf=\ED:sr=\EM:
  1922. X#
  1923. X# Display hacker's tool
  1924. X#
  1925. Xdebug|debugging entry:\
  1926. X    :ae=<ae>:AL=<AL%d>:al=<al>:am:as=<as>:bl=<bl>:bs:bt=<bt>:bw:CC=<CC>:\
  1927. X    :cd=<cd>:ce=<ce>:ch=<ch%d>:cl=<cl>:cm=<cm%d,%d>:co#80:cr=<cr>:\
  1928. X    :cs=<cs%d,%d>:ct=<ct>:cv=<cv%d>:da:db:DC=<DC%d>:dc=<dc>:DL=<DL%d>:\
  1929. X    :dl=<dl>:dm=<dm>:DO=<DO%d>:do=<do>:ds=<ds>:ec=<ec%d>:ed=<ed>:ei=<ei>:\
  1930. X    :es:fs=<fs>:ho=<ho>:hs:IC=<IC%d>:ic=<ic>:im=<im>:ip=<ip>:is=<is>:\
  1931. X    :it#8:ke=<ke>:LE=<LE%d>:le=<le>:li#24:ll=<ll>:mb=<mb>:md=<md>:me=<me>:\
  1932. X    :mh=<mh>:mi:mk=<mk>:mm=<mm>:mo=<mo>:mp=<mp>:mr=<mr>:ms=<ms>:nd=<nd>:\
  1933. X    :nw=<nw>:pc=<pc>:pf=<pf>:pO=<pO%d>:po=<po>:ps=<ps>:rc=<rc>:RI=<RI%d>:\
  1934. X    :rp=<rp%.%d>:rs=<rs>:sc=<sc>:se=<se>:SF=<SF%d>:sf=<sf>:so=<so>:\
  1935. X    :SR=<SR%d>:sr=<sr>:st=<st>:ta=<ta>:te=<te>:ti=<ti>:uc=<uc>:ue=<ue>:\
  1936. X    :UP=<UP%d>:up=<up>:us=<us>:vb=<vb>:ve=<ve>:vi=<vi>:vs=<vs>:
  1937. X#
  1938. Xdumb:\
  1939. X    :am:bl=^G:co#80:do=^J:nl=^M^J:
  1940. END_OF_FILE
  1941. if test 5404 -ne `wc -c <'sys/share/termcap'`; then
  1942.     echo shar: \"'sys/share/termcap'\" unpacked with wrong size!
  1943. fi
  1944. # end of 'sys/share/termcap'
  1945. fi
  1946. echo shar: End of archive 90 \(of 108\).
  1947. cp /dev/null ark90isdone
  1948. MISSING=""
  1949. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
  1950. 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
  1951. 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
  1952. 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 \
  1953. 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 \
  1954. 101 102 103 104 105 106 107 108 ; do
  1955.     if test ! -f ark${I}isdone ; then
  1956.     MISSING="${MISSING} ${I}"
  1957.     fi
  1958. done
  1959. if test "${MISSING}" = "" ; then
  1960.     echo You have unpacked all 108 archives.
  1961.     echo "Now execute 'rebuild.sh'"
  1962.     rm -f ark10[0-8]isdone ark[1-9]isdone ark[1-9][0-9]isdone
  1963. else
  1964.     echo You still need to unpack the following archives:
  1965.     echo "        " ${MISSING}
  1966. fi
  1967. ##  End of shell archive.
  1968. exit 0
  1969.