home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume16 / nethck31 / part95 < prev    next >
Encoding:
Internet Message Format  |  1993-02-05  |  58.0 KB

  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: v16i103:  nethack31 - display oriented dungeons & dragons (Ver. 3.1), Part95/108
  5. Message-ID: <4468@master.CNA.TEK.COM>
  6. Date: 5 Feb 93 22:03:01 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 2265
  9. Approved: billr@saab.CNA.TEK.COM
  10. Xref: uunet comp.sources.games:1654
  11.  
  12. Submitted-by: izchak@linc.cis.upenn.edu (Izchak Miller)
  13. Posting-number: Volume 16, Issue 103
  14. Archive-name: nethack31/Part95
  15. Supersedes: nethack3p9: Volume 10, Issue 46-108
  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 95 (of 108)."
  27. # Contents:  Files include/display.h src/allmain.c src/mcastu.c
  28. #   sys/mac/mactopl.c sys/share/pcsys.c
  29. # Wrapped by billr@saab on Wed Jan 27 16:09:26 1993
  30. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  31. if test -f 'Files' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'Files'\"
  33. else
  34. echo shar: Extracting \"'Files'\" \(9012 characters\)
  35. sed "s/^X//" >'Files' <<'END_OF_FILE'
  36. XThis is a listing of all files in a full NetHack 3.1 distribution, organized
  37. Xin their standard manner on a UNIX system.  It indicates which files are
  38. Xnecessary for which versions, so that you can tell which files may be deleted
  39. Xfrom or not transferred to your system if you wish.
  40. X
  41. X
  42. X(files in top directory)
  43. XFiles           Porting         README
  44. X
  45. Xdat:
  46. X(files for all versions)
  47. XArch.des        Barb.des        Caveman.des     Elf.des         Healer.des
  48. XKnight.des      Priest.des      Rogue.des       Samurai.des     Tourist.des
  49. XValkyrie.des    Wizard.des      bigroom.des     castle.des      cmdhelp
  50. Xdata.base       dungeon.def     endgame.des     gehennom.des    help
  51. Xhh              history         knox.des        license         medusa.des
  52. Xmines.des       opthelp         oracle.des      oracles.txt     quest.txt
  53. Xrumors.fal      rumors.tru      tower.des       wizhelp         yendor.des
  54. X
  55. Xdoc:
  56. X(files for all versions)
  57. XGuidebook.mn    Guidebook.tex   Guidebook.txt   dgn_comp.6      lev_comp.6
  58. Xnethack.6       recover.6       tmac.n          window.doc
  59. X
  60. Xinclude:
  61. X(files for all versions)
  62. Xalign.h         amiconf.h       artifact.h      artilist.h      attrib.h
  63. Xcolor.h         config.h        coord.h         decl.h          def_os2.h
  64. Xdgn_file.h      display.h       dungeon.h       edog.h          emin.h
  65. Xengrave.h       epri.h          eshk.h          extern.h        flag.h
  66. Xfunc_tab.h      global.h        hack.h          lev.h           macconf.h
  67. Xmail.h          mfndpos.h       micro.h         mkroom.h        monattk.h
  68. Xmondata.h       monflag.h       monst.h         monsym.h        obj.h
  69. Xobjclass.h      os2conf.h       patchlevel.h    pcconf.h        permonst.h
  70. Xprop.h          qtext.h         quest.h         rect.h          rm.h
  71. Xsp_lev.h        spell.h         system.h        termcap.h       tosconf.h
  72. Xtradstdc.h      trampoli.h      trap.h          unixconf.h      vault.h
  73. Xvision.h        vmsconf.h       winami.h        winprocs.h      wintype.h
  74. Xyou.h           youprop.h
  75. X(file for tty versions)
  76. Xwintty.h
  77. X(files for X versions)
  78. XWindow.h        WindowP.h       winX.h
  79. X
  80. Xsrc:
  81. X(files for all versions)
  82. Xallmain.c       alloc.c         apply.c         artifact.c      attrib.c
  83. Xball.c          bones.c         botl.c          cmd.c           dbridge.c
  84. Xdecl.c          detect.c        display.c       do.c            do_name.c
  85. Xdo_wear.c       dog.c           dogmove.c       dokick.c        dothrow.c
  86. Xdrawing.c       dungeon.c       eat.c           end.c           engrave.c
  87. Xexper.c         explode.c       extralev.c      files.c         fountain.c
  88. Xhack.c          hacklib.c       invent.c        lock.c          mail.c
  89. Xmakemon.c       mcastu.c        mhitm.c         mhitu.c         minion.c
  90. Xmklev.c         mkmap.c         mkmaze.c        mkobj.c         mkroom.c
  91. Xmon.c           mondata.c       monmove.c       monst.c         mplayer.c
  92. Xmthrowu.c       muse.c          music.c         o_init.c        objects.c
  93. Xobjnam.c        options.c       pager.c         pickup.c        pline.c
  94. Xpolyself.c      potion.c        pray.c          priest.c        quest.c
  95. Xquestpgr.c      read.c          rect.c          restore.c       rip.c
  96. Xrnd.c           rumors.c        save.c          shk.c           shknam.c
  97. Xsit.c           sounds.c        sp_lev.c        spell.c         steal.c
  98. Xtimeout.c       topten.c        track.c         trap.c          u_init.c
  99. Xuhitm.c         vault.c         version.c       vision.c        weapon.c
  100. Xwere.c          wield.c         windows.c       wizard.c        worm.c
  101. Xworn.c          write.c         zap.c
  102. X
  103. Xsys/amiga:
  104. X(files for Amiga version)
  105. XHackWB.uu       Install.ami     Makefile.ami    NHinfo.uu       NetHack.cnf
  106. XNewGame.uu      amidos.c        amidos.p        amifont.uu      amifont8.uu
  107. Xamigst.c        amii.hlp        amimenu.c       amirip.c        amiwbench.c
  108. Xamiwind.c       amiwind.p       ask.uu          char.c          charwin.uu
  109. Xcolors.uu       colorwin.c      dflticon.uu     hackwb.hlp      ifchange
  110. Xrandwin.c       randwin.uu      scroll.uu       string.uu       wb.c
  111. Xwbcli.c         wbdata.c        wbdefs.h        wbprotos.h      wbstruct.h
  112. Xwbwin.c         wbwin.uu        winami.c        winami.p
  113. X
  114. Xsys/amiga/splitter:
  115. X(more files for Amiga version)
  116. Xamiout.h        arg.c           arg.h           loader.c        multi.c
  117. Xmulti.h         split.doc       split.h         splitter.c
  118. X
  119. Xsys/atari:
  120. X(files for Atari version)
  121. XInstall.tos     Makefile.utl    atari.cnf       atarifnt.uue    nethack.mnu
  122. Xsetup.g         tos.c
  123. X
  124. Xsys/mac:
  125. X(files for Macintosh version)
  126. XInstall.mpw     MacHelp         NHmake.hqx      NHrez.hqx       NHrsrc.hqx
  127. XNHsound.hqx     News            hack.h          maccurs.c       macerrs.c
  128. Xmacfile.c       macmain.c       macsnd.c        mactopl.c       macunix.c
  129. Xmacwin.c        mgetline.c      mhdump.c        mmodal.c        mstring.c
  130. X
  131. Xsys/msdos:
  132. X(files for MSDOS versions)
  133. XInstall.dos     MakeGCC.src     MakeGCC.utl     MakeMSC.src     MakeMSC.utl
  134. XMakefile.dat    exesmurf.c      exesmurf.doc    maintovl.doc    msdos.c
  135. Xovlmgr.asm      ovlmgr.doc      ovlmgr.uu       setup.bat       trampoli.c
  136. X(files for running MSDOS binary under Windows)
  137. Xnhico.uu        nhpif.uu
  138. X
  139. Xsys/os2:
  140. X(files for OS/2 version)
  141. XInstall.os2     Makefile.os2    nhpmico.uu      os2.c
  142. X
  143. Xsys/share:
  144. X(files for MSDOS and OS/2 versions)
  145. XMakefile.lib    NetHack.cnf     termcap.uu
  146. X(file for MSDOS, OS/2, Amiga, and Atari versions)
  147. Xpcmain.c
  148. X(files for MSDOS, OS/2 and Atari versions)
  149. Xpcsys.c         pctty.c         pcunix.c
  150. X(Berkeley random number file, which may be included in any version)
  151. Xrandom.c
  152. X(file for MSDOS, OS/2 and VMS versions)
  153. Xtermcap
  154. X(lex/yacc output for special level and dungeon compilers)
  155. Xdgn_comp.h      dgn_lex.c       dgn_yacc.c      lev_comp.h      lev_lex.c
  156. Xlev_yacc.c
  157. X
  158. Xsys/unix:
  159. X(files for UNIX versions)
  160. XInstall.unx     Makefile.dat    Makefile.doc    Makefile.src    Makefile.top
  161. XMakefile.utl    ioctl.c         nethack.sh      setup.sh        unixmain.c
  162. Xunixtty.c       unixunix.c
  163. X(files for replacement cpp, apparently only needed by some UNIX systems)
  164. Xcpp1.shr        cpp2.shr        cpp3.shr
  165. X(file for sound driver for 386 UNIX)
  166. Xsnd86unx.shr
  167. X
  168. Xsys/vms:
  169. X(files for VMS version)
  170. XInstall.vms     Makefile.dat    Makefile.doc    Makefile.src    Makefile.top
  171. XMakefile.utl    install.com     lev_lex.h       nethack.com     oldcrtl.c
  172. Xspec_lev.com    vmsbuild.com    vmsfiles.c      vmsmail.c       vmsmain.c
  173. Xvmsmisc.c       vmstty.c        vmsunix.c
  174. X(GNU termcap files that support VMS version)
  175. Xgnutermcap.c    gnutparam.c
  176. X
  177. Xutil:
  178. X(files for all versions)
  179. Xdgn_main.c      lev_main.c      makedefs.c      panic.c         recover.c
  180. X(lex/yacc input for special level and dungeon compilers)
  181. Xdgn_comp.l      dgn_comp.y      lev_comp.l      lev_comp.y
  182. X
  183. Xwin/tty:
  184. X(files for tty versions)
  185. Xgetline.c       termcap.c       topl.c          wintty.c
  186. X
  187. Xwin/X11:
  188. X(files for X versions)
  189. XInstall.X11     NetHack.ad      Window.c        dialogs.c       ibm.bdf
  190. Xnethack.rc      nh10.bdf        nh32icon        nh56icon        nh72icon
  191. XwinX.c          winmap.c        winmenu.c       winmesg.c       winmisc.c
  192. Xwinstat.c       wintext.c       winval.c
  193. X
  194. X
  195. X
  196. XThis is a list of files produced by auxiliary programs.  They can all be
  197. Xregenerated from the files in the distribution.
  198. X
  199. Xdat:
  200. X(files generated by makedefs at playground creation time)
  201. Xdata            dungeon.pdf     options         oracles         quest.dat
  202. Xrumors
  203. X(file generated by dgn_comp at playground creation time)
  204. Xdungeon
  205. X(files generated by lev_comp at playground creation time)
  206. XA-filla.lev     A-fillb.lev     A-goal.lev      A-locate.lev    A-start.lev
  207. XB-filla.lev     B-fillb.lev     B-goal.lev      B-locate.lev    B-start.lev
  208. XC-filla.lev     C-fillb.lev     C-goal.lev      C-locate.lev    C-start.lev
  209. XE-filla.lev     E-fillb.lev     E-goal.lev      E-locate.lev    E-start.lev
  210. XH-filla.lev     H-fillb.lev     H-goal.lev      H-locate.lev    H-start.lev
  211. XK-filla.lev     K-fillb.lev     K-goal.lev      K-locate.lev    K-start.lev
  212. XP-filla.lev     P-fillb.lev     P-goal.lev      P-locate.lev    P-start.lev
  213. XR-filla.lev     R-fillb.lev     R-goal.lev      R-locate.lev    R-start.lev
  214. XS-filla.lev     S-fillb.lev     S-goal.lev      S-locate.lev    S-start.lev
  215. XT-filla.lev     T-fillb.lev     T-goal.lev      T-locate.lev    T-start.lev
  216. XV-filla.lev     V-fillb.lev     V-goal.lev      V-locate.lev    V-start.lev
  217. XW-filla.lev     W-fillb.lev     W-goal.lev      W-locate.lev    W-start.lev
  218. Xair.lev         asmodeus.lev    astral.lev      baalz.lev       bigroom.lev
  219. Xcastle.lev      earth.lev       fakewiz1.lev    fakewiz2.lev    fire.lev
  220. Xjuiblex.lev     knox.lev        medusa-1.lev    medusa-2.lev    mine_end.lev
  221. Xminefill.lev    minetown.lev    oracle.lev      orcus.lev       sanctum.lev
  222. Xtower1.lev      tower2.lev      tower3.lev      valley.lev      water.lev
  223. Xwizard1.lev     wizard2.lev     wizard3.lev
  224. X
  225. Xinclude:
  226. X(files generated by makedefs at compile time)
  227. Xdate.h          onames.h        pm.h            vis_tab.h
  228. X
  229. Xsrc:
  230. X(files generated by makedefs at compile time)
  231. Xmonstr.c        vis_tab.c
  232. END_OF_FILE
  233. if test 9012 -ne `wc -c <'Files'`; then
  234.     echo shar: \"'Files'\" unpacked with wrong size!
  235. fi
  236. # end of 'Files'
  237. fi
  238. if test -f 'include/display.h' -a "${1}" != "-c" ; then 
  239.   echo shar: Will not clobber existing file \"'include/display.h'\"
  240. else
  241. echo shar: Extracting \"'include/display.h'\" \(9078 characters\)
  242. sed "s/^X//" >'include/display.h' <<'END_OF_FILE'
  243. X/*    SCCS Id: @(#)display.h    3.1    92/07/11          */
  244. X/* Copyright (c) Dean Luick, with acknowledgements to Kevin Darcy */
  245. X/* and Dave Cohrs, 1990.                      */
  246. X/* NetHack may be freely redistributed.  See license for details. */
  247. X
  248. X#ifndef DISPLAY_H
  249. X#define DISPLAY_H
  250. X
  251. X#ifndef VISION_H
  252. X#include "vision.h"
  253. X#endif
  254. X
  255. X#ifndef MONDATA_H
  256. X#include "mondata.h"    /* for mindless() */
  257. X#endif
  258. X
  259. X#ifndef INVISIBLE_OBJECTS
  260. X#define vobj_at(x,y) (level.objects[x][y])
  261. X#endif
  262. X
  263. X/*
  264. X * sensemon()
  265. X *  
  266. X * Returns true if the hero can sense the given monster.  This includes
  267. X * monsters that are hiding or mimicing other monsters.
  268. X */
  269. X#define sensemon(mon) (        /* The hero can always sense a monster IF:  */\
  270. X    (!mindless(mon->data)) &&    /* 1. the monster has a brain to sense AND  */\
  271. X      ((Blind && Telepat) ||    /* 2a. hero is blind and telepathic OR      */\
  272. X                    /* 2b. hero is wearing a telepathy inducing */\
  273. X                /*     object and in range            */\
  274. X      ((HTelepat & (WORN_HELMET|WORN_AMUL|W_ART)) &&                  \
  275. X    (distu(mon->mx, mon->my) <= (BOLT_LIM * BOLT_LIM))))              \
  276. X)
  277. X
  278. X
  279. X/*
  280. X * mon_visible()
  281. X *  
  282. X * Returns true if the hero can see the monster.  It is assumed that the
  283. X * hero can physically see the location of the monster.  The function
  284. X * vobj_at() returns a pointer to an object that the hero can see there.
  285. X */
  286. X#define mon_visible(mon) (        /* The hero can see the monster        */\
  287. X                    /* IF the monster            */\
  288. X    (!mon->minvis || See_invisible) &&    /* 1. is not invisible AND        */\
  289. X    (!mon->mundetected)            /* 2. not an undetected hider        */\
  290. X)
  291. X
  292. X
  293. X/*
  294. X * canseemon()
  295. X *  
  296. X * This is the globally used canseemon().  It is not called within the display
  297. X * routines.
  298. X */
  299. X#define canseemon(mon) (cansee(mon->mx, mon->my) && mon_visible(mon))
  300. X
  301. X
  302. X/*
  303. X * canspotmon(mon)
  304. X *
  305. X * This is sensemon() or mon_visible() except that hiding under objects
  306. X * is considered irrelevant for this special case.
  307. X */
  308. X#define canspotmon(mon)    \
  309. X    (mon && (Blind ? sensemon(mon) : (!mon->minvis || See_invisible)))
  310. X
  311. X/*
  312. X * is_safepet(mon)
  313. X *
  314. X * A special case check used in attack() and domove().  Placing the
  315. X * definition here is convenient.
  316. X */
  317. X#define is_safepet(mon)    \
  318. X    (mon && mon->mtame && canspotmon(mon) && flags.safe_dog \
  319. X        && !Confusion && !Hallucination && !Stunned)
  320. X
  321. X
  322. X/*
  323. X * canseeself()
  324. X *  
  325. X * This returns true if the hero can see her/himself.
  326. X *
  327. X * The u.uswallow check assumes that you can see yourself even if you are
  328. X * invisible.  If not, then we don't need the check.
  329. X */
  330. X#ifdef POLYSELF
  331. X#define canseeself()    (Blind || u.uswallow || (!Invisible && !u.uundetected))
  332. X#else
  333. X#define canseeself()    (Blind || u.uswallow || !Invisible)
  334. X#endif
  335. X
  336. X
  337. X/*
  338. X * random_monster()
  339. X * random_object()
  340. X *  
  341. X * Respectively return a random monster or object number.
  342. X */
  343. X#define random_monster() rn2(NUMMONS)
  344. X#define random_object()  (rn2(NROFOBJECTS) + 1)
  345. X
  346. X
  347. X/*
  348. X * what_obj()
  349. X * what_mon()
  350. X *  
  351. X * If hallucinating, choose a random object/monster, otherwise, use the one
  352. X * given.
  353. X */
  354. X#define what_obj(obj)    (Hallucination ? random_object()  : obj)
  355. X#define what_mon(mon)    (Hallucination ? random_monster() : mon)
  356. X
  357. X
  358. X/*
  359. X * covers_objects()
  360. X * covers_traps()
  361. X *  
  362. X * These routines are true if what is really at the given location will
  363. X * "cover" any objects or traps that might be there.
  364. X */
  365. X#define covers_objects(xx,yy)                              \
  366. X    ((is_pool(xx,yy) && !Underwater) || (levl[xx][yy].typ == LAVAPOOL))
  367. X
  368. X#define covers_traps(xx,yy)    covers_objects(xx,yy)
  369. X
  370. X
  371. X/*
  372. X * tmp_at() control calls.
  373. X */
  374. X#define DISP_BEAM   (-1)  /* Keep all glyphs showing & clean up at end. */
  375. X#define DISP_FLASH  (-2)  /* Clean up each glyph before displaying new one. */
  376. X#define DISP_CHANGE (-3)  /* Change glyph. */
  377. X#define DISP_END    (-4)  /* Clean up. */
  378. X
  379. X
  380. X/* Total number of cmap indices in the sheild_static[] array. */
  381. X#define SHIELD_COUNT 21
  382. X
  383. X
  384. X/*
  385. X *  display_self()
  386. X *  
  387. X *  Display the hero.  This has degenerated down to this.  Perhaps there is
  388. X *  more needed here, but I can't think of any cases.
  389. X */
  390. X#ifdef POLYSELF
  391. X#define display_self()                        \
  392. X    show_glyph(u.ux, u.uy,                    \
  393. X    u.usym == 0 ? objnum_to_glyph(GOLD_PIECE) :        \
  394. X    monnum_to_glyph((u.umonnum < 0 ? u.umonster : u.umonnum)))
  395. X#else
  396. X#define display_self()                        \
  397. X    show_glyph(u.ux, u.uy,                    \
  398. X    u.usym == 0 ? objnum_to_glyph(GOLD_PIECE) :        \
  399. X    monnum_to_glyph(u.umonster))
  400. X#endif
  401. X
  402. X
  403. X/*
  404. X * A glyph is an abstraction that represents a _unique_ monster, object,
  405. X * dungeon part, or effect.  The uniqueness is important.  For example,
  406. X * It is not enough to have four (one for each "direction") zap beam glyphs,
  407. X * we need a set of four for each beam type.  Why go to so much trouble?
  408. X * Because it is possible that any given window dependent display driver
  409. X * [print_glyph()] can produce something different for each type of glyph.
  410. X * That is, a beam of cold and a beam of fire would not only be different
  411. X * colors, but would also be represented by different symbols.
  412. X *
  413. X * Glyphs are grouped for easy accessibility:
  414. X *
  415. X * monster    Represents all the wild (not tame) monsters.  Count: NUMMONS.
  416. X *
  417. X * pet        Represents all of the tame monsters.  Count: NUMMONS
  418. X *
  419. X * corpse    One for each monster.  Count: NUMMONS
  420. X *
  421. X * object    One for each object.  Count: NROFOBJECTS+1 (we need the +1
  422. X *        because NROFOBJECTS does not include the illegal object)
  423. X *
  424. X * trap        One for each trap type.  Count: TRAPNUM
  425. X *
  426. X * cmap        One for each entry in the character map.  The character map
  427. X *        is the dungeon features and other miscellaneous things.
  428. X *        Count: MAXPCHARS
  429. X *
  430. X * zap beam    A set of four (there are four directions) for each beam type.
  431. X *        The beam type is shifted over 2 positions and the direction
  432. X *        is stored in the lower 2 bits.  Count: NUM_ZAP << 2
  433. X *
  434. X * swallow    A set of eight for each monster.  The eight positions rep-
  435. X *        resent those surrounding the hero.  The monster number is
  436. X *        shifted over 3 positions and the swallow position is stored
  437. X *        in the lower three bits.  Count: NUMMONS << 3
  438. X *
  439. X * The following are offsets used to convert to and from a glyph.
  440. X */
  441. X#define NUM_ZAP    8    /* number of zap beam types */
  442. X
  443. X#define GLYPH_MON_OFF        0
  444. X#define GLYPH_PET_OFF       (NUMMONS        + GLYPH_MON_OFF)
  445. X#define GLYPH_BODY_OFF       (NUMMONS        + GLYPH_PET_OFF)
  446. X#define GLYPH_OBJ_OFF       (NUMMONS        + GLYPH_BODY_OFF)
  447. X#define GLYPH_TRAP_OFF      (NROFOBJECTS+1  + GLYPH_OBJ_OFF)
  448. X#define GLYPH_CMAP_OFF      (TRAPNUM        + GLYPH_TRAP_OFF)
  449. X#define GLYPH_ZAP_OFF      (MAXPCHARS      + GLYPH_CMAP_OFF)
  450. X#define GLYPH_SWALLOW_OFF ((NUM_ZAP << 2) + GLYPH_ZAP_OFF)
  451. X
  452. X#define MAX_GLYPH       ((NUMMONS << 3) + GLYPH_SWALLOW_OFF)
  453. X
  454. X
  455. X#define mon_to_glyph(mon) ((int) what_mon(monsndx((mon)->data))+GLYPH_MON_OFF)
  456. X#define pet_to_glyph(mon) ((int) what_mon(monsndx((mon)->data))+GLYPH_PET_OFF)
  457. X
  458. X/* This has the unfortunate side effect of needing a global variable    */
  459. X/* to store a result. 'otg_temp' is defined and declared in decl.{ch}.    */
  460. X#define obj_to_glyph(obj)                              \
  461. X    (Hallucination ?                                  \
  462. X    ((otg_temp = random_object()) == CORPSE ?                  \
  463. X        random_monster() + GLYPH_BODY_OFF :                      \
  464. X        otg_temp + GLYPH_OBJ_OFF)    :                      \
  465. X    ((obj)->otyp == CORPSE ?                          \
  466. X        (int) (obj)->corpsenm + GLYPH_BODY_OFF :                  \
  467. X        (int) (obj)->otyp + GLYPH_OBJ_OFF))
  468. X
  469. X#define trap_to_glyph(trap)    ((int) (trap)->ttyp + GLYPH_TRAP_OFF)
  470. X#define cmap_to_glyph(cmap_idx)    ((int) (cmap_idx)   + GLYPH_CMAP_OFF)
  471. X
  472. X/* Not affected by hallucination.  Gives a generic body for CORPSE */
  473. X#define objnum_to_glyph(onum)    ((int) (onum) + GLYPH_OBJ_OFF)
  474. X#define monnum_to_glyph(mnum)    ((int) (mnum) + GLYPH_MON_OFF)
  475. X#define petnum_to_glyph(mnum)    ((int) (mnum) + GLYPH_PET_OFF)
  476. X
  477. X
  478. X/*
  479. X * Change the given glyph into it's given type.  Note:
  480. X *    1) Pets are animals and are converted to the proper monster number.
  481. X *    2) Bodies are all mapped into the generic CORPSE object
  482. X *    3) glyph_to_swallow() does not return a showsyms[] index, but an
  483. X *       offset from the first swallow symbol.
  484. X *    4) These functions assume that the glyph type has already been
  485. X *       determined.  That is, you have checked it with a glyph_is_XXXX()
  486. X *       call.
  487. X */
  488. X#define glyph_to_mon(glyph)    ((int) ((glyph) < GLYPH_PET_OFF ?          \
  489. X                glyph - GLYPH_MON_OFF : glyph - GLYPH_PET_OFF))
  490. X#define glyph_to_obj(glyph)    ((int) ((glyph) < GLYPH_OBJ_OFF ?          \
  491. X                CORPSE : (glyph) - GLYPH_OBJ_OFF))
  492. X#define glyph_to_trap(glyph)    ((int) (glyph) - GLYPH_TRAP_OFF)
  493. X#define glyph_to_cmap(glyph)    ((int) (glyph) - GLYPH_CMAP_OFF)
  494. X#define glyph_to_swallow(glyph) (((glyph) - GLYPH_SWALLOW_OFF) & 0x7)
  495. X
  496. X/*
  497. X * Return true if the given glyph is what we want.  Note that bodies are
  498. X * considered objects.
  499. X */
  500. X#define glyph_is_monster(glyph)                              \
  501. X    ((glyph) >= GLYPH_MON_OFF && (glyph) < GLYPH_BODY_OFF)
  502. X#define glyph_is_object(glyph)                              \
  503. X    ((glyph) >= GLYPH_BODY_OFF && (glyph) < GLYPH_TRAP_OFF)
  504. X#define glyph_is_trap(glyph)                              \
  505. X    ((glyph) >= GLYPH_TRAP_OFF && (glyph) < GLYPH_CMAP_OFF)
  506. X#define glyph_is_cmap(glyph)                              \
  507. X    ((glyph) >= GLYPH_CMAP_OFF && (glyph) < GLYPH_ZAP_OFF)
  508. X#define glyph_is_swallow(glyph) \
  509. X    ((glyph) >= GLYPH_SWALLOW_OFF && (glyph) < MAX_GLYPH)
  510. X
  511. X#endif /* DISPLAY_H */
  512. END_OF_FILE
  513. if test 9078 -ne `wc -c <'include/display.h'`; then
  514.     echo shar: \"'include/display.h'\" unpacked with wrong size!
  515. fi
  516. # end of 'include/display.h'
  517. fi
  518. if test -f 'src/allmain.c' -a "${1}" != "-c" ; then 
  519.   echo shar: Will not clobber existing file \"'src/allmain.c'\"
  520. else
  521. echo shar: Extracting \"'src/allmain.c'\" \(8946 characters\)
  522. sed "s/^X//" >'src/allmain.c' <<'END_OF_FILE'
  523. X/*    SCCS Id: @(#)allmain.c    3.1    92/11/13    */
  524. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  525. X/* NetHack may be freely redistributed.  See license for details. */
  526. X
  527. X/* various code that was replicated in *main.c */
  528. X
  529. X#include "hack.h"
  530. X
  531. X#ifndef NO_SIGNAL
  532. X#include <signal.h>
  533. X#endif
  534. X
  535. X#ifdef OVL0
  536. X
  537. Xvoid
  538. Xmoveloop()
  539. X{
  540. X#ifdef MICRO
  541. X    char ch;
  542. X    int abort_lev;
  543. X#endif
  544. X    int moverate = 0;
  545. X    boolean didmove = 0;
  546. X
  547. X    /* Note:  these initializers don't do anything except guarantee that
  548. X        we're linked properly.
  549. X    */
  550. X    decl_init();
  551. X    monst_init();
  552. X    monstr_init();    /* monster strengths */
  553. X    objects_init();
  554. X
  555. X#ifdef MULDGN
  556. X    quest_init();    /* set up dynamic quest data */
  557. X#endif
  558. X
  559. X    (void) encumber_msg(); /* in case they auto-picked up something */
  560. X
  561. X    for(;;) {
  562. X#ifdef CLIPPING
  563. X        cliparound(u.ux, u.uy);
  564. X#endif
  565. X#if defined(MAC_MPW32) && !defined(MODEL_FAR)
  566. X        UnloadAllSegments();  /* Marks non-resident segments as purgeable */
  567. X#endif
  568. X        get_nh_event();
  569. X
  570. X        didmove = flags.move;
  571. X        if(flags.move) {    /* actual time passed */
  572. X            int wtcap;
  573. X
  574. X            if (u.utotype) deferred_goto();
  575. X            wtcap = encumber_msg();
  576. X
  577. X#ifdef SOUNDS
  578. X            dosounds();
  579. X#endif
  580. X
  581. X            if(moverate <= 0) {
  582. X            /* calculate how much time passed. */
  583. X            int moveamt = 0;
  584. X            if(Fast & ~INTRINSIC) moveamt = 6;
  585. X            else if(Fast) moveamt = 8;
  586. X            else moveamt = 12;
  587. X
  588. X            switch(wtcap) {
  589. X            case UNENCUMBERED: break;
  590. X            case SLT_ENCUMBER: moveamt = (moveamt * 4) / 3; break;
  591. X            case MOD_ENCUMBER: moveamt *= 2; break;
  592. X            case HVY_ENCUMBER: moveamt *= 4; break;
  593. X            default: moveamt *= 12; break;
  594. X            }
  595. X            moverate += moveamt;
  596. X            settrack();
  597. X            }
  598. X
  599. X            if(moverate > 0) {
  600. X            movemon();
  601. X            /* a monster may have levteleported player -dlc */
  602. X            if (u.utotype) deferred_goto();
  603. X            if(!rn2(u.uevent.udemigod ? 25 :
  604. X                (depth(&u.uz) >
  605. X                 depth(&stronghold_level))
  606. X                ? 50 : 70))
  607. X                (void) makemon((struct permonst *)0, 0, 0);
  608. X            ++monstermoves;
  609. X            remove_cadavers(&fobj);
  610. X            remove_cadavers(&invent);
  611. X            moverate -= 12;
  612. X            }
  613. X            if(Glib) glibr();
  614. X            nh_timeout();
  615. X            ++moves;
  616. X            if (u.ublesscnt)  u.ublesscnt--;
  617. X            if(flags.time) flags.botl = 1;
  618. X#ifdef POLYSELF
  619. X            if (u.mtimedone && u.mh < u.mhmax) {
  620. X            if (u.mh < 1) {
  621. X                rehumanize();
  622. X                moverate = 0;
  623. X            } else if (Regeneration ||
  624. X                 (wtcap < MOD_ENCUMBER && !(moves%20))) {
  625. X                flags.botl = 1;
  626. X                u.mh++;
  627. X            }
  628. X            } else
  629. X#endif
  630. X            if(u.uhp < u.uhpmax) {
  631. X            if(u.ulevel > 9) {
  632. X                int heal;
  633. X
  634. X                if(HRegeneration ||
  635. X                   (!(moves%3) &&
  636. X                (wtcap < MOD_ENCUMBER || !flags.mv))) {
  637. X                flags.botl = 1;
  638. X                if (ACURR(A_CON) <= 12) heal = 1;
  639. X                else heal = rnd((int) ACURR(A_CON)-12);
  640. X                if (heal > u.ulevel-9) heal = u.ulevel-9;
  641. X                u.uhp += heal;
  642. X                if(u.uhp > u.uhpmax)
  643. X                    u.uhp = u.uhpmax;
  644. X                }
  645. X            } else if(HRegeneration ||
  646. X                  ((wtcap < MOD_ENCUMBER || !flags.mv) &&
  647. X                   (!(moves%((MAXULEV+12)/(u.ulevel+2)+1))))) {
  648. X                flags.botl = 1;
  649. X                u.uhp++;
  650. X            }
  651. X            }
  652. X
  653. X            if (wtcap > MOD_ENCUMBER && flags.mv) {
  654. X            if(!(wtcap < EXT_ENCUMBER ? moves%30 : moves%10)) {
  655. X                if(u.uhp > 1) {
  656. X                u.uhp--;
  657. X                } else {
  658. X                pline("You pass out from exertion!");
  659. X                exercise(A_CON, FALSE);
  660. X                nomul(-10);
  661. X                u.usleep = 1;
  662. X                }
  663. X            }
  664. X            }
  665. X
  666. X            if ((u.uen < u.uenmax) &&
  667. X            ((wtcap < MOD_ENCUMBER &&
  668. X              (!(moves%((MAXULEV + 1 - u.ulevel) *
  669. X                    (pl_character[0] == 'W' ? 3 : 4) / 2))))
  670. X             || Energy_regeneration)) {
  671. X            u.uen +=
  672. X                rn1((int)(ACURR(A_WIS) + ACURR(A_INT)) / 10 + 1,1);
  673. X            if (u.uen > u.uenmax)  u.uen = u.uenmax;
  674. X            flags.botl = 1;
  675. X            }
  676. X
  677. X            if(!u.uinvulnerable) {
  678. X            if(Teleportation && !rn2(85)) tele();
  679. X#ifdef POLYSELF
  680. X            if(Polymorph && !rn2(100)) {
  681. X                if (multi >= 0) {
  682. X                if (occupation)
  683. X                    stop_occupation();
  684. X                else
  685. X                    nomul(0);
  686. X                }
  687. X                polyself();
  688. X                moverate = 0;
  689. X            } else if (u.ulycn >= 0 && !rn2(80 - (20 * night()))) {
  690. X                if (multi >= 0) {
  691. X                if (occupation)
  692. X                    stop_occupation();
  693. X                else
  694. X                    nomul(0);
  695. X                }
  696. X                you_were();
  697. X                moverate = 0;
  698. X            }
  699. X#endif
  700. X            }
  701. X
  702. X            if(Searching && multi >= 0) (void) dosearch0(1);
  703. X            do_storms();
  704. X            hatch_eggs();
  705. X            burn_lamps();
  706. X            gethungry();
  707. X            exerchk();
  708. X            invault();
  709. X            amulet();
  710. X            if (!rn2(40+(int)(ACURR(A_DEX)*3))) 
  711. X            u_wipe_engr(rnd(3));
  712. X            if (u.uevent.udemigod && !u.uinvulnerable) {
  713. X            if (u.udg_cnt) u.udg_cnt--;
  714. X            if (!u.udg_cnt) {
  715. X                intervene();
  716. X                u.udg_cnt = rn1(200, 50);
  717. X            }
  718. X            }
  719. X            restore_attrib();
  720. X            /* underwater and waterlevel vision are done here */
  721. X            if (Is_waterlevel(&u.uz))
  722. X            movebubbles();
  723. X            else if (Underwater)
  724. X            under_water(0);
  725. X
  726. X        }
  727. X        if(multi < 0) {
  728. X            if(!++multi){
  729. X                pline(nomovemsg ? nomovemsg :
  730. X                    (const char *)"You can move again.");
  731. X                nomovemsg = 0;
  732. X                u.usleep = 0;
  733. X                if(afternmv) (*afternmv)();
  734. X                afternmv = 0;
  735. X            }
  736. X        }
  737. X
  738. X        find_ac();
  739. X        if(!flags.mv || Blind) {
  740. X            /* redo monsters if hallu or wearing a helm of telepathy */
  741. X            if (Hallucination ||
  742. X            (HTelepat & (WORN_HELMET|WORN_AMUL|W_ART)))
  743. X            see_monsters();
  744. X
  745. X            /* redo objects if hallucinating */
  746. X            if (Hallucination) see_objects();
  747. X
  748. X            /* update swallowed display */
  749. X            if (Hallucination && u.uswallow) swallowed(0);
  750. X
  751. X            if (vision_full_recalc) vision_recalc(0);    /* vision! */
  752. X        }
  753. X        if(flags.botl || flags.botlx) bot();
  754. X
  755. X        flags.move = 1;
  756. X
  757. X        if(multi >= 0 && occupation) {
  758. X#ifdef MICRO
  759. X            abort_lev = 0;
  760. X            if (kbhit()) {
  761. X                if ((ch = Getchar()) == ABORT)
  762. X                    abort_lev++;
  763. X# ifdef REDO
  764. X                else
  765. X                    pushch(ch);
  766. X# endif /* REDO */
  767. X            }
  768. X            if (!abort_lev && (*occupation)() == 0)
  769. X#else
  770. X            if ((*occupation)() == 0)
  771. X#endif
  772. X                occupation = 0;
  773. X            if(
  774. X#ifdef MICRO
  775. X               abort_lev ||
  776. X#endif
  777. X               monster_nearby()) {
  778. X                stop_occupation();
  779. X                reset_eat();
  780. X            }
  781. X#ifdef MICRO
  782. X            if (!(++occtime % 7))
  783. X                display_nhwindow(WIN_MAP, FALSE);
  784. X#endif
  785. X            continue;
  786. X        }
  787. X
  788. X        if((u.uhave.amulet || Clairvoyant) && !In_endgame(&u.uz) &&
  789. X                        !(moves%15) && !rn2(2))
  790. X            do_vicinity_map();
  791. X
  792. X        if(u.utrap && u.utraptype == TT_LAVA) {
  793. X            if(!is_lava(u.ux,u.uy))
  794. X            u.utrap = 0;
  795. X            else {
  796. X            u.utrap -= 1<<8;
  797. X            if(u.utrap < 1<<8) {
  798. X                killer_format = KILLED_BY;
  799. X                killer = "molten lava";
  800. X                You("sink below the surface and suffocate.");
  801. X                done(DROWNING); /*whatever*/
  802. X            } else if(didmove && !u.umoved) {
  803. X                Norep("You sink deeper into the lava.");
  804. X                u.utrap += rnd(4);
  805. X            }
  806. X            }
  807. X        }
  808. X
  809. X        u.umoved = FALSE;
  810. X        if(!didmove || moverate <= 0) {
  811. X            if(multi > 0) {
  812. X            lookaround();
  813. X            if(!multi) {    /* lookaround may clear multi */
  814. X                flags.move = 0;
  815. X                continue;
  816. X            }
  817. X            if(flags.mv) {
  818. X                if(multi < COLNO && !--multi)
  819. X                    flags.mv = flags.run = 0;
  820. X                domove();
  821. X            } else {
  822. X                --multi;
  823. X                rhack(save_cm);
  824. X            }
  825. X            } else if(multi == 0) {
  826. X#ifdef MAIL
  827. X            ckmailstatus();
  828. X#endif
  829. X            rhack(NULL);
  830. X            }
  831. X        }
  832. X        if (vision_full_recalc) vision_recalc(0);    /* vision! */
  833. X        if(multi && multi%7 == 0)
  834. X            display_nhwindow(WIN_MAP, FALSE);
  835. X    }
  836. X}
  837. X
  838. X#endif /* OVL0 */
  839. X#ifdef OVL1
  840. X
  841. Xvoid
  842. Xstop_occupation()
  843. X{
  844. X    if(occupation) {
  845. X        You("stop %s.", occtxt);
  846. X        occupation = 0;
  847. X/* fainting stops your occupation, there's no reason to sync.
  848. X        sync_hunger();
  849. X*/
  850. X#ifdef REDO
  851. X        nomul(0);
  852. X        pushch(0);
  853. X#endif
  854. X    }
  855. X}
  856. X
  857. X#endif /* OVL1 */
  858. X#ifdef OVLB
  859. X
  860. Xvoid
  861. Xdisplay_gamewindows()
  862. X{
  863. X    WIN_MESSAGE = create_nhwindow(NHW_MESSAGE);
  864. X    WIN_STATUS = create_nhwindow(NHW_STATUS);
  865. X    WIN_MAP = create_nhwindow(NHW_MAP);
  866. X    WIN_INVEN = create_nhwindow(NHW_MENU);
  867. X
  868. X#ifdef MAC
  869. X    /*
  870. X     * This _is_ the right place for this - maybe we will
  871. X     * have to split display_gamewindows into create_gamewindows
  872. X     * and show_gamewindows to get rid of this ifdef...
  873. X     */
  874. X    SanePositions ( ) ;
  875. X#endif
  876. X
  877. X    /*
  878. X     * The mac port is not DEPENDENT on the order of these
  879. X     * displays, but it looks a lot better this way...
  880. X     */
  881. X    display_nhwindow(WIN_STATUS, FALSE);
  882. X    display_nhwindow(WIN_MESSAGE, FALSE);
  883. X    display_nhwindow(WIN_MAP, FALSE);
  884. X}
  885. X
  886. Xvoid
  887. Xnewgame()
  888. X{
  889. X#ifdef MFLOPPY
  890. X    gameDiskPrompt();
  891. X#endif
  892. X
  893. X    fobj = invent = migrating_objs = (struct obj *)0;
  894. X    fmon = migrating_mons = (struct monst *)0;
  895. X    ftrap = 0;
  896. X    flags.ident = 1;
  897. X
  898. X    if(wiz1_level.dlevel == 0) init_dungeons();
  899. X    init_objects();
  900. X    u_init();
  901. X
  902. X#ifndef NO_SIGNAL
  903. X    (void) signal(SIGINT, (SIG_RET_TYPE) done1);
  904. X#endif
  905. X#ifdef NEWS
  906. X    if(flags.news) display_file(NEWS, FALSE);
  907. X#endif
  908. X#ifdef MULDGN
  909. X    load_qtlist();    /* load up the quest text info */
  910. X    if(flags.legacy && moves == 1) com_pager(1);
  911. X#endif
  912. X    mklev();
  913. X    u_on_upstairs();
  914. X    check_special_room(FALSE);
  915. X    vision_reset();        /* set up internals for level (after mklev) */
  916. X
  917. X    flags.botlx = 1;
  918. X
  919. X    /* Move the monster from under you or else
  920. X     * makedog() will fail when it calls makemon().
  921. X     *             - ucsfcgl!kneller
  922. X     */
  923. X    if(MON_AT(u.ux, u.uy)) mnexto(m_at(u.ux, u.uy));
  924. X
  925. X#ifdef CLIPPING
  926. X    cliparound(u.ux, u.uy);
  927. X#endif
  928. X    (void) makedog();
  929. X    docrt();
  930. X
  931. X#ifdef INSURANCE
  932. X    save_currentstate();
  933. X#endif
  934. X    return;
  935. X}
  936. X
  937. X#endif /* OVLB */
  938. X
  939. X/*allmain.c*/
  940. END_OF_FILE
  941. if test 8946 -ne `wc -c <'src/allmain.c'`; then
  942.     echo shar: \"'src/allmain.c'\" unpacked with wrong size!
  943. fi
  944. # end of 'src/allmain.c'
  945. fi
  946. if test -f 'src/mcastu.c' -a "${1}" != "-c" ; then 
  947.   echo shar: Will not clobber existing file \"'src/mcastu.c'\"
  948. else
  949. echo shar: Extracting \"'src/mcastu.c'\" \(8760 characters\)
  950. sed "s/^X//" >'src/mcastu.c' <<'END_OF_FILE'
  951. X/*    SCCS Id: @(#)mcastu.c    3.1    90/09/21
  952. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  953. X/* NetHack may be freely redistributed.  See license for details. */
  954. X
  955. X#include    "hack.h"
  956. X
  957. X#ifdef OVL0
  958. X
  959. Xstatic void FDECL(cursetxt,(struct monst *));
  960. Xconst char *spelltyp[] = {
  961. X    "shower of missiles",
  962. X    "fireball",
  963. X    "sleep ray",
  964. X    "cone of cold",
  965. X    "finger of death",
  966. X    "bolt of lightning",
  967. X    "",
  968. X    "",
  969. X    "",
  970. X    ""
  971. X};
  972. X
  973. Xstatic
  974. Xvoid
  975. Xcursetxt(mtmp)
  976. X    register struct monst *mtmp;
  977. X{
  978. X    if(canseemon(mtmp)) {
  979. X        if ((Invis && !perceives(mtmp->data) &&
  980. X                (mtmp->mux != u.ux || mtmp->muy != u.uy))
  981. X#ifdef POLYSELF
  982. X            || u.usym == S_MIMIC_DEF || u.uundetected
  983. X#endif
  984. X                                    )
  985. X        pline("%s points and curses in your general direction.",
  986. X                Monnam(mtmp));
  987. X        else if (Displaced && (mtmp->mux != u.ux || mtmp->muy != u.uy))
  988. X        pline("%s points and curses at your displaced image.",
  989. X                Monnam(mtmp));
  990. X        else
  991. X        pline("%s points at you, then curses.", Monnam(mtmp));
  992. X    } else if((!(moves%4) || !rn2(4)) && flags.soundok) 
  993. X        Norep("You hear a mumbled curse.");
  994. X}
  995. X
  996. X#endif /* OVL0 */
  997. X#ifdef OVLB
  998. X
  999. Xint
  1000. Xcastmu(mtmp, mattk)    /* monster casts spell at you */
  1001. X    register struct monst *mtmp;
  1002. X    register struct attack *mattk;
  1003. X{
  1004. X    int    dmg, ml = mtmp->m_lev;
  1005. X
  1006. X    if(mtmp->mcan || mtmp->mspec_used || !ml) {  /* could not attack */
  1007. X        cursetxt(mtmp);
  1008. X        return(0);
  1009. X    } else {
  1010. X        nomul(0);
  1011. X        if(rn2(ml*10) < (mtmp->mconf ? 100 : 20)) {    /* fumbled attack */
  1012. X        if(canseemon(mtmp)
  1013. X#ifdef SOUNDS
  1014. X                && flags.soundok
  1015. X#endif
  1016. X                            )
  1017. X            pline("The air crackles around %s.", mon_nam(mtmp));
  1018. X        return(0);
  1019. X        }
  1020. X    }
  1021. X/*
  1022. X *    As these are spells, the damage is related to the level
  1023. X *    of the monster casting the spell.
  1024. X */
  1025. X    if (mattk->damd)
  1026. X        dmg = d((int)((ml/3) + mattk->damn), (int)mattk->damd);
  1027. X    else dmg = d((int)((ml/3) + 1), 6);
  1028. X    if (Half_spell_damage) dmg = (dmg+1) / 2;
  1029. X
  1030. X    switch(mattk->adtyp)   {
  1031. X
  1032. X        case AD_FIRE:
  1033. X        pline("You're enveloped in flames.");
  1034. X        if(Fire_resistance) {
  1035. X            shieldeff(u.ux, u.uy);
  1036. X            pline("But you resist the effects.");
  1037. X            dmg = 0;
  1038. X        }
  1039. X        break;
  1040. X        case AD_COLD:
  1041. X        pline("You're covered in frost.");
  1042. X        if(Cold_resistance) {
  1043. X            shieldeff(u.ux, u.uy);
  1044. X            pline("But you resist the effects.");
  1045. X            dmg = 0;
  1046. X        }
  1047. X        break;
  1048. X        case AD_MAGM:
  1049. X        You("are hit by a shower of missiles!");
  1050. X        if(Antimagic) {
  1051. X            shieldeff(u.ux, u.uy);
  1052. X            pline("The missiles bounce off!");
  1053. X            dmg = 0;
  1054. X        } else dmg = d((int)mtmp->m_lev/2 + 1,6);
  1055. X        break;
  1056. X        case AD_SPEL:    /* random spell */
  1057. X
  1058. X        mtmp->mspec_used = 10 - mtmp->m_lev;
  1059. X        if (mtmp->mspec_used < 2) mtmp->mspec_used = 2;
  1060. X        switch(rn2((int)mtmp->m_lev)) {
  1061. X            case 22:
  1062. X            case 21:
  1063. X            case 20:
  1064. X            pline("Oh no, %s's using the touch of death!",
  1065. X                  humanoid(mtmp->data)
  1066. X                  ? (mtmp->female ? "she" : "he")
  1067. X                  : "it"
  1068. X                 );
  1069. X#ifdef POLYSELF
  1070. X            if (is_undead(uasmon))
  1071. X                You("seem no deader than before.");
  1072. X            else
  1073. X#endif
  1074. X            if (!Antimagic && rn2(ml) > 12) {
  1075. X
  1076. X                if(Hallucination)
  1077. X                You("have an out of body experience.");
  1078. X                else  {
  1079. X                killer_format = KILLED_BY_AN;
  1080. X                killer = "touch of death";
  1081. X                done(DIED);
  1082. X                }
  1083. X            } else {
  1084. X                if(Antimagic) shieldeff(u.ux, u.uy);
  1085. X                pline("Lucky for you, it didn't work!");
  1086. X            }
  1087. X            dmg = 0;
  1088. X            break;
  1089. X            case 19:
  1090. X            case 18:
  1091. X            if(mtmp->iswiz && flags.no_of_wizards == 1) {
  1092. X                pline("Double Trouble...");
  1093. X                clonewiz();
  1094. X                dmg = 0;
  1095. X                break;
  1096. X            } /* else fall into the next case */
  1097. X            case 17:
  1098. X            case 16:
  1099. X            case 15:
  1100. X            if(mtmp->iswiz)
  1101. X                verbalize("Destroy the thief, my pets!");
  1102. X            nasty(mtmp);    /* summon something nasty */
  1103. X            /* fall into the next case */
  1104. X            case 14:        /* aggravate all monsters */
  1105. X            case 13:
  1106. X            aggravate();
  1107. X            dmg = 0;
  1108. X            break;
  1109. X            case 12:        /* curse random items */
  1110. X            case 11:
  1111. X            case 10:
  1112. X            rndcurse();
  1113. X            dmg = 0;
  1114. X            break;
  1115. X            case 9:
  1116. X            case 8:        /* destroy armor */
  1117. X            if (Antimagic) {
  1118. X                shieldeff(u.ux, u.uy);
  1119. X                pline("A field of force surrounds you!");
  1120. X            } else if(!destroy_arm(some_armor()))
  1121. X                Your("skin itches.");
  1122. X            dmg = 0;
  1123. X            break;
  1124. X            case 7:
  1125. X            case 6:        /* drain strength */
  1126. X            if(Antimagic) {
  1127. X                shieldeff(u.ux, u.uy);
  1128. X                You("feel momentarily weakened.");
  1129. X            } else {
  1130. X                You("suddenly feel weaker!");
  1131. X                dmg = ml - 6;
  1132. X                if(Half_spell_damage) dmg = (dmg+1) / 2;
  1133. X                losestr(rnd(dmg));
  1134. X                if(u.uhp < 1)
  1135. X                done_in_by(mtmp);
  1136. X            }
  1137. X            dmg = 0;
  1138. X            break;
  1139. X            case 5:        /* make invisible if not */
  1140. X            case 4:
  1141. X            if(!mtmp->minvis) {
  1142. X                if(canseemon(mtmp) && !See_invisible)
  1143. X                pline("%s suddenly disappears!",
  1144. X                      Monnam(mtmp));
  1145. X                mtmp->minvis = 1;
  1146. X                newsym(mtmp->mx,mtmp->my);
  1147. X                dmg = 0;
  1148. X                break;
  1149. X            } /* else fall into the next case */
  1150. X            case 3:        /* stun */
  1151. X            if(Antimagic) {
  1152. X                shieldeff(u.ux, u.uy);
  1153. X                if(!Stunned)
  1154. X                You("feel momentarily disoriented.");
  1155. X                make_stunned(1L, FALSE);
  1156. X            } else {
  1157. X                if (Stunned)
  1158. X                You("struggle to keep your balance.");
  1159. X                else
  1160. X                You("reel....");
  1161. X                dmg = d(ACURR(A_DEX) < 12 ? 6 : 4, 4);
  1162. X                if(Half_spell_damage) dmg = (dmg+1) / 2;
  1163. X                make_stunned(HStun + dmg, FALSE);
  1164. X            }
  1165. X            dmg = 0;
  1166. X            break;
  1167. X            case 2:        /* haste self */
  1168. X            if(mtmp->mspeed == MSLOW)    mtmp->mspeed = 0;
  1169. X            else                mtmp->mspeed = MFAST;
  1170. X            dmg = 0;
  1171. X            break;
  1172. X            case 1:        /* cure self */
  1173. X            if(mtmp->mhp < mtmp->mhpmax) {
  1174. X                if((mtmp->mhp += rnd(8)) > mtmp->mhpmax)
  1175. X                mtmp->mhp = mtmp->mhpmax;
  1176. X                dmg = 0;
  1177. X                break;
  1178. X            } /* else fall through to default case */
  1179. X            default:        /* psi bolt */
  1180. X            if(Antimagic) {
  1181. X                shieldeff(u.ux, u.uy);
  1182. X                You("get a slight %sache.",body_part(HEAD));
  1183. X                dmg = 1;
  1184. X            } else {
  1185. X                if (dmg <= 10)
  1186. X                Your("brain is on fire!");
  1187. X                else Your("%s suddenly aches!", body_part(HEAD));
  1188. X            }
  1189. X            break;
  1190. X        }
  1191. X        break;
  1192. X        
  1193. X        case AD_CLRC:    /* clerical spell */
  1194. X
  1195. X        mtmp->mspec_used = 10 - mtmp->m_lev;
  1196. X        if (mtmp->mspec_used < 2) mtmp->mspec_used = 2;
  1197. X        switch(rn2((int)mtmp->m_lev)) {
  1198. X            /* Other ideas: lightning bolts, towers of flame,
  1199. X                    gush of water  -3. */
  1200. X
  1201. X            default:        /* confuse */
  1202. X            if(Antimagic) {
  1203. X                shieldeff(u.ux, u.uy);
  1204. X                You("feel momentarily dizzy.");
  1205. X            } else {
  1206. X                dmg = (int)mtmp->m_lev;
  1207. X                if(Half_spell_damage) dmg = (dmg+1) / 2;
  1208. X                make_confused(HConfusion + dmg, TRUE);
  1209. X            }
  1210. X            dmg = 0;
  1211. X            break;
  1212. X            case 12:        /* curse random items */
  1213. X            case 11:
  1214. X            case 10:
  1215. X            rndcurse();
  1216. X            dmg = 0;
  1217. X            break;
  1218. X            case 9:
  1219. X            case 8:        /* insects */
  1220. X            /* Try for insects, and if there are none
  1221. X               left, go for (sticks to) snakes.  -3. */
  1222. X            {
  1223. X            int i;
  1224. X            struct permonst *pm = mkclass(S_ANT,0);
  1225. X            struct monst *mtmp2;
  1226. X            char let = (pm ? S_ANT : S_SNAKE);
  1227. X  
  1228. X            for (i = 0; i <= (int) mtmp->m_lev; i++)
  1229. X               if ((pm = mkclass(let,0)) &&
  1230. X                    (mtmp2 = makemon(pm, u.ux, u.uy))) {
  1231. X                mtmp2->msleep = mtmp2->mpeaceful =
  1232. X                    mtmp2->mtame = 0;
  1233. X                set_malign(mtmp2);
  1234. X                }
  1235. X            }            
  1236. X            dmg = 0;
  1237. X            break;
  1238. X            case 6:
  1239. X            case 7:        /* blindness */
  1240. X            if (!Blinded) {
  1241. X                pline("Scales cover your eyes!");
  1242. X                make_blinded(Half_spell_damage ? 100L:200L, FALSE);
  1243. X                dmg = 0;
  1244. X                break;
  1245. X            }
  1246. X            case 4:
  1247. X            case 5:        /* wound */
  1248. X            if(Antimagic) {
  1249. X                shieldeff(u.ux, u.uy);
  1250. X                Your("skin itches badly for a moment.");
  1251. X                dmg = 0;
  1252. X            } else {
  1253. X                pline("Wounds appear on your body!");
  1254. X                dmg = d(2,8) + 1;
  1255. X                if (Half_spell_damage) dmg = (dmg+1) / 2;
  1256. X            }
  1257. X            break;
  1258. X            case 3:        /* hold */
  1259. X            if(Antimagic) {
  1260. X                shieldeff(u.ux, u.uy);
  1261. X                if(multi >= 0)
  1262. X                You("stiffen briefly.");
  1263. X                nomul(-1);
  1264. X             } else {
  1265. X                if (multi >= 0)    
  1266. X                    You("are frozen in place!");
  1267. X                dmg = 4 + (int)mtmp->m_lev;
  1268. X                if (Half_spell_damage) dmg = (dmg+1) / 2;
  1269. X                nomul(-dmg);
  1270. X            }
  1271. X            dmg = 0;
  1272. X            break;
  1273. X            case 2:
  1274. X            case 1:        /* cure self */
  1275. X            if(mtmp->mhp < mtmp->mhpmax) {
  1276. X                if((mtmp->mhp += rnd(8)) > mtmp->mhpmax)
  1277. X                mtmp->mhp = mtmp->mhpmax;
  1278. X                dmg = 0;
  1279. X                break;
  1280. X            } /* else fall through to default case */
  1281. X        }
  1282. X    }
  1283. X    if(dmg) mdamageu(mtmp, dmg);
  1284. X    return(1);
  1285. X}
  1286. X
  1287. X#endif /* OVLB */
  1288. X#ifdef OVL0
  1289. X
  1290. Xint
  1291. Xbuzzmu(mtmp, mattk)        /* monster uses spell (ranged) */
  1292. X    register struct monst *mtmp;
  1293. X    register struct attack  *mattk;
  1294. X{
  1295. X    if(mtmp->mcan || mattk->adtyp > AD_SPC2) {
  1296. X        cursetxt(mtmp);
  1297. X        return(0);
  1298. X    }
  1299. X    if(lined_up(mtmp) && rn2(3)) {
  1300. X        nomul(0);
  1301. X        if(mattk->adtyp && (mattk->adtyp < 11)) { /* no cf unsigned >0 */
  1302. X        if(canseemon(mtmp))
  1303. X            pline("%s zaps you with a %s!", Monnam(mtmp),
  1304. X              spelltyp[mattk->adtyp-1]);
  1305. X        buzz((int) (-10 - (mattk->adtyp-1)), (int)mattk->damn,
  1306. X             mtmp->mx, mtmp->my, sgn(tbx), sgn(tby));
  1307. X        } else impossible("Monster spell %d cast", mattk->adtyp-1);
  1308. X    }
  1309. X    return(1);
  1310. X}
  1311. X
  1312. X#endif /* OVL0 */
  1313. X
  1314. X/*mcastu.c*/
  1315. END_OF_FILE
  1316. if test 8760 -ne `wc -c <'src/mcastu.c'`; then
  1317.     echo shar: \"'src/mcastu.c'\" unpacked with wrong size!
  1318. fi
  1319. # end of 'src/mcastu.c'
  1320. fi
  1321. if test -f 'sys/mac/mactopl.c' -a "${1}" != "-c" ; then 
  1322.   echo shar: Will not clobber existing file \"'sys/mac/mactopl.c'\"
  1323. else
  1324. echo shar: Extracting \"'sys/mac/mactopl.c'\" \(8925 characters\)
  1325. sed "s/^X//" >'sys/mac/mactopl.c' <<'END_OF_FILE'
  1326. X/*    SCCS Id: @(#)mactopl.c    3.1    91/07/23
  1327. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  1328. X/* NetHack may be freely redistributed.  See license for details. */
  1329. X
  1330. X#include "hack.h"
  1331. X#include <Dialogs.h>
  1332. X#include <OSUtils.h>
  1333. X#include <Packages.h>
  1334. X
  1335. X// int NDECL(mac_doprev_message);
  1336. X// char FDECL(yn_function,(const char *, const char *, CHAR_P));
  1337. X
  1338. Xint FDECL ( try_key_queue , ( char * ) ) ;
  1339. X
  1340. Xextern void SetFrameItem ( DialogPtr , short , short ) ;
  1341. Xextern void FlashButton ( DialogPtr , short ) ;
  1342. X
  1343. Xextern char * PtoCstr ( unsigned char * ) ;
  1344. Xextern unsigned char * CtoPstr ( char * ) ;
  1345. X
  1346. Xvoid FDECL ( enter_topl_mode , ( char * ) ) ;
  1347. Xvoid FDECL ( leave_topl_mode , ( char * ) ) ;
  1348. Xvoid FDECL ( topl_set_resp , ( char * , char ) ) ;
  1349. X
  1350. Xextern winid inSelect ;
  1351. Xextern short frame_corner ;
  1352. X
  1353. Xint
  1354. Xmac_doprev_message(void)
  1355. X{
  1356. X    NhWindow * aWin = & theWindows [ WIN_MESSAGE ] ;
  1357. X    char * start , * stop ;
  1358. X
  1359. X    if ( ! WIN_MESSAGE )
  1360. X        return 0 ;
  1361. X
  1362. X    stop = * aWin -> windowText ;
  1363. X    start = * aWin -> windowText + aWin -> textBase - 2 ;
  1364. X
  1365. X    while ( start > stop && * start != 10 && * start != 13 )
  1366. X        start -- ;
  1367. X
  1368. X    if ( start <= stop )
  1369. X        aWin -> textBase = 0L ;
  1370. X    else
  1371. X        aWin -> textBase = start - stop + 1 ;
  1372. X    if ( aWin -> textBase > aWin -> windowTextLen )
  1373. X        aWin -> textBase = aWin -> windowTextLen ;
  1374. X
  1375. X    display_nhwindow ( WIN_MESSAGE , FALSE ) ;
  1376. X    InvalRect ( & ( aWin -> theWindow -> portRect ) ) ;
  1377. X
  1378. X    return 0 ;
  1379. X}
  1380. X
  1381. X
  1382. Xchar
  1383. Xqueued_resp(char *resp)
  1384. X{
  1385. X    char buf[30];
  1386. X    if (try_key_queue(&buf)) {
  1387. X        if (!resp || strchr(resp, buf[0]))
  1388. X            return buf[0];
  1389. X        if (digit(buf[0]) && strchr(resp, '#')) {
  1390. X            yn_number = atoi(buf);
  1391. X            return '#';
  1392. X        }
  1393. X    }
  1394. X    return '\0';
  1395. X}
  1396. X
  1397. X
  1398. X#define YN_DLOG 133
  1399. X#define YNQ_DLOG 134
  1400. X#define YNAQ_DLOG 135
  1401. X#define YNNAQ_DLOG 136
  1402. X
  1403. Xstatic int yn_user_item [ ] = { 5 , 6 , 7 , 8 } ;
  1404. Xstatic short gEnterItem , gEscItem ;
  1405. Xstatic const char * gRespStr = NULL ;
  1406. Xstatic char gDef = 0 ;
  1407. Xstatic short dlogID ;
  1408. X
  1409. X
  1410. Xstatic void
  1411. XSetEnterItem ( DialogPtr dp , const short newEnterItem )
  1412. X{
  1413. X    short kind ;
  1414. X    Handle item ;
  1415. X    Rect r , r2 ;
  1416. X
  1417. X    if ( gEnterItem != newEnterItem ) {
  1418. X
  1419. X        GetDItem ( dp , gEnterItem , & kind , & item , & r2 ) ;
  1420. X        InsetRect ( & r2 , - 4 , - 4 ) ;
  1421. X        EraseRect ( & r2 ) ;
  1422. X        InvalRect ( & r2 ) ;
  1423. X
  1424. X        gEnterItem = newEnterItem ;
  1425. X
  1426. X        GetDItem ( dp , newEnterItem , & kind , & item , & r2 ) ;
  1427. X        frame_corner = kind == ctrlItem + btnCtrl ? 16 : 0 ;
  1428. X        InsetRect ( & r2 , - 4 , - 4 ) ;
  1429. X        InvalRect ( & r2 ) ;
  1430. X        r = r2 ;
  1431. X        GetDItem ( dp , yn_user_item [ dlogID - YN_DLOG ] , & kind , & item , & r2 ) ;
  1432. X        SetDItem ( dp , yn_user_item [ dlogID - YN_DLOG ] , kind , item , & r ) ;
  1433. X    }
  1434. X}
  1435. X
  1436. X
  1437. Xstatic void
  1438. Xdo_tabbing ( DialogPtr dp )
  1439. X{
  1440. X    SetEnterItem(dp, gEnterItem == 1 ? strlen(gRespStr) : gEnterItem - 1);
  1441. X}
  1442. X
  1443. X
  1444. Xstatic void
  1445. Xset_yn_number(DialogPtr dp)
  1446. X{
  1447. X    if (gRespStr && gRespStr[gEnterItem-1] == '#') {
  1448. X        short k;
  1449. X        Handle h;
  1450. X        Rect r;
  1451. X        Str255 s;
  1452. X        GetDItem(dp, gEnterItem, &k, &h, &r);
  1453. X        GetIText(h, s);
  1454. X        if (s[0])
  1455. X            StringToNum(s, &yn_number);
  1456. X    }
  1457. X}
  1458. X
  1459. X
  1460. Xpascal Boolean
  1461. XYNAQFilter ( DialogPtr dp , EventRecord * ev , short * itemHit )
  1462. X{
  1463. X    unsigned char code ;
  1464. X    char ch ;
  1465. X    char * re = gRespStr ;
  1466. X
  1467. X    if ( ev -> what != keyDown ) {
  1468. X
  1469. X        return 0 ;
  1470. X    }
  1471. X    code = ( ev -> message & 0xff00 ) >> 8 ;
  1472. X    ch = ev -> message & 0xff ;
  1473. X
  1474. X    switch ( code ) {
  1475. X
  1476. X    case 0x24 :
  1477. X    case 0x4c :
  1478. X        set_yn_number ( dp ) ;
  1479. X        * itemHit = gEnterItem ;
  1480. X        FlashButton ( dp , * itemHit ) ;
  1481. X        return 1 ;
  1482. X
  1483. X    case 0x35 :
  1484. X    case 0x47 :
  1485. X        * itemHit = gEscItem ;
  1486. X        FlashButton ( dp , * itemHit ) ;
  1487. X        return 1 ;
  1488. X
  1489. X    case 0x30 :
  1490. X        do_tabbing ( dp ) ;
  1491. X        return 0 ;
  1492. X    }
  1493. X    switch ( ch ) {
  1494. X
  1495. X    case '\r' :
  1496. X    case '\n' :
  1497. X    case ' ' :
  1498. X    case 3 :
  1499. X        set_yn_number ( dp ) ;
  1500. X        * itemHit = gEnterItem ;
  1501. X        FlashButton ( dp , * itemHit ) ;
  1502. X        return 1 ;
  1503. X
  1504. X    case 9 :
  1505. X        do_tabbing ( dp ) ;
  1506. X        return 0 ;
  1507. X
  1508. X    case 27 :
  1509. X        * itemHit = gEscItem ;
  1510. X        FlashButton ( dp , * itemHit ) ;
  1511. X        return 1 ;
  1512. X
  1513. X    case CHAR_BS :
  1514. X    case 28 : case 29 : case 30 : case 31 : /* the four arrow keys */
  1515. X    case '0' : case '1' : case '2' : case '3' : case '4' :
  1516. X    case '5' : case '6' : case '7' : case '8' : case '9' :
  1517. X    {    char * loc = strchr ( gRespStr , '#' ) ;
  1518. X        if ( loc ) {
  1519. X            SetEnterItem( dp , loc - gRespStr + 1 ) ;
  1520. X            return 0; /* Dialog Manager will then put this key into the text field. */
  1521. X        }
  1522. X    }
  1523. X    }
  1524. X
  1525. X    while ( * re ) {
  1526. X
  1527. X        if ( * re == ch ) {
  1528. X
  1529. X            * itemHit = ( re - gRespStr ) + 1 ;
  1530. X            FlashButton ( dp , * itemHit ) ;
  1531. X            return 1 ;
  1532. X        }
  1533. X        re ++ ;
  1534. X    }
  1535. X
  1536. X    nhbell ( ) ;
  1537. X    ev -> what = nullEvent ;
  1538. X    return 0 ;
  1539. X}
  1540. X
  1541. X
  1542. Xstatic char
  1543. Xdo_question_dialog ( char * query , int dlog , int defbut , char * resp )
  1544. X{
  1545. X    Str255 p ;
  1546. X    DialogPtr dp ;
  1547. X    short item ;
  1548. X
  1549. X    char c = queued_resp ( resp ) ;
  1550. X    if ( c )
  1551. X        return c ;
  1552. X
  1553. X    dlogID = dlog ;
  1554. X    strcpy ( p , query ) ;
  1555. X    ParamText ( CtoPstr ( p ) , NULL , NULL , NULL ) ;
  1556. X    dp = mv_get_new_dialog ( dlog ) ;
  1557. X    if ( ! dp ) {
  1558. X
  1559. X        return 0 ;
  1560. X    }
  1561. X    SetPort ( dp ) ;
  1562. X    ShowWindow ( dp ) ;
  1563. X
  1564. X    gEscItem = strlen ( resp ) ;
  1565. X    gEnterItem = defbut ;
  1566. X    gRespStr = resp ;
  1567. X
  1568. X    SetFrameItem ( dp , yn_user_item [ dlogID - YN_DLOG ] , gEnterItem ) ;
  1569. X
  1570. X    InitCursor ( ) ;
  1571. X    mv_modal_dialog ( YNAQFilter , & item ) ;
  1572. X    mv_close_dialog ( dp ) ;
  1573. X    return resp [ item - 1 ] ;
  1574. X}
  1575. X
  1576. X
  1577. Xpascal Boolean
  1578. XOneCharDLOGFilter ( DialogPtr dp , EventRecord * ev , short * item )
  1579. X{
  1580. X    char ch ;
  1581. X    short k ;
  1582. X    Handle h ;
  1583. X    Rect r ;
  1584. X    unsigned char com [ 2 ] ;
  1585. X
  1586. X    if ( ev -> what != keyDown ) {
  1587. X
  1588. X        return 0 ;
  1589. X    }
  1590. X    ch = ev -> message & 0xff ;
  1591. X
  1592. X    com [ 0 ] = 1 ;
  1593. X    com [ 1 ] = ch ;
  1594. X
  1595. X    if ( ch == 27 ) {
  1596. X
  1597. X        GetDItem ( dp , 4 , & k , & h , & r ) ;
  1598. X        SetIText ( h , com ) ;
  1599. X        * item = 2 ;
  1600. X        FlashButton ( dp , 2 ) ;
  1601. X        return 1 ;
  1602. X    }
  1603. X    if ( ! gRespStr || strchr ( gRespStr , ch ) ) {
  1604. X
  1605. X        GetDItem ( dp , 4 , & k , & h , & r ) ;
  1606. X        SetIText ( h , com ) ;
  1607. X        * item = 1 ;
  1608. X        FlashButton ( dp , 1 ) ;
  1609. X        return 1 ;
  1610. X    }
  1611. X    if ( ch == 10 || ch == 13 || ch == 3 || ch == 32 ) {
  1612. X
  1613. X        com [ 1 ] = gDef ;
  1614. X        GetDItem ( dp , 4 , & k , & h , & r ) ;
  1615. X        SetIText ( h , com ) ;
  1616. X        * item = 1 ;
  1617. X        FlashButton ( dp , 1 ) ;
  1618. X        return 1 ;
  1619. X    }
  1620. X    if ( ch > 32 && ch < 127 ) {
  1621. X
  1622. X        GetDItem ( dp , 4 , & k , & h , & r ) ;
  1623. X        SetIText ( h , com ) ;
  1624. X        * item = 1 ;
  1625. X        FlashButton ( dp , 1 ) ;
  1626. X        return 1 ;
  1627. X    }
  1628. X    nhbell ( ) ;
  1629. X    ev -> what = nullEvent ;
  1630. X    return 1 ;
  1631. X}
  1632. X
  1633. X
  1634. Xstatic char
  1635. Xgeneric_yn_function ( query , resp , def )
  1636. Xconst char * query , * resp ;
  1637. Xchar def ;
  1638. X{
  1639. X    DialogPtr dp ;
  1640. X    short k , item ;
  1641. X    Handle h ;
  1642. X    Rect r ;
  1643. X    unsigned char com [ 32 ] = { 1 , 27 } ; // margin for getitext
  1644. X    Str255 pQuery ;
  1645. X
  1646. X    char c = queued_resp ( resp ) ;
  1647. X    if ( c )
  1648. X        return c ;
  1649. X
  1650. X    dp = mv_get_new_dialog ( 137 ) ;
  1651. X    if ( ! dp ) {
  1652. X
  1653. X        return 0 ;
  1654. X    }
  1655. X    SetPort ( dp ) ;
  1656. X    ShowWindow ( dp ) ;
  1657. X    InitCursor ( ) ;
  1658. X    SetFrameItem ( dp , 6 , 1 ) ;
  1659. X    if ( def ) {
  1660. X
  1661. X        com [ 1 ] = def ;
  1662. X    }
  1663. X    strcpy ( ( char * ) pQuery , query ) ;
  1664. X    if ( resp && * resp ) {
  1665. X
  1666. X        strcat ( ( char * ) pQuery , " (" ) ;
  1667. X        strcat ( ( char * ) pQuery , resp ) ;
  1668. X        strcat ( ( char * ) pQuery , ")" ) ;
  1669. X    }
  1670. X    ParamText ( CtoPstr ( pQuery ) , NULL , NULL , NULL ) ;
  1671. X    GetDItem ( dp , 4 , & k , & h , & r ) ;
  1672. X    SetIText ( h , com ) ;
  1673. X    SelIText ( dp , 4 , 0 , 0x7fff ) ;
  1674. X    InitCursor ( ) ;
  1675. X    SetFrameItem ( dp , 6 , 1 ) ;
  1676. X    gRespStr = resp ;
  1677. X    gDef = def ;
  1678. X    do {
  1679. X
  1680. X        mv_modal_dialog ( OneCharDLOGFilter , & item ) ;
  1681. X
  1682. X    } while ( item != 1 && item != 2 ) ;
  1683. X    GetIText ( h , com ) ;
  1684. X
  1685. X    mv_close_dialog ( dp ) ;
  1686. X    if ( item == 2 || ! com [ 0 ] ) {
  1687. X
  1688. X        return 27 ; // escape
  1689. X    }
  1690. X    return com [ 1 ] ;
  1691. X}
  1692. X
  1693. X
  1694. Xstatic char
  1695. Xynaq_dialog ( query , resp , def )
  1696. Xconst char * query , * resp ;
  1697. Xchar def ;
  1698. X{
  1699. X    int dia = 0 ;
  1700. X
  1701. X    if ( resp ) {
  1702. X
  1703. X        if ( ! strcmp ( resp , ynchars ) ) {
  1704. X
  1705. X            dia = YN_DLOG ;
  1706. X        }
  1707. X        if ( ! strcmp ( resp , ynqchars ) ) {
  1708. X
  1709. X            dia = YNQ_DLOG ;
  1710. X        }
  1711. X        if ( ! strcmp ( resp , ynaqchars ) ) {
  1712. X
  1713. X            dia = YNAQ_DLOG ;
  1714. X        }
  1715. X        if ( ! strcmp ( resp , ynNaqchars ) ) {
  1716. X
  1717. X            dia = YNNAQ_DLOG ;
  1718. X        }
  1719. X    }
  1720. X    if ( ! dia ) {
  1721. X
  1722. X        return generic_yn_function ( query , resp , def ) ;
  1723. X    }
  1724. X
  1725. X    return do_question_dialog ( query , dia ,
  1726. X        ( strchr ( resp , def ) - resp ) + 1 , resp ) ;
  1727. X}
  1728. X
  1729. X
  1730. Xchar
  1731. Xtopl_yn_function(query,resp, def)
  1732. Xconst char *query,*resp;
  1733. Xchar def;
  1734. X{
  1735. X    char buf[30];
  1736. X    char c = queued_resp(resp);
  1737. X    if (!c) {
  1738. X        enter_topl_mode(query);
  1739. X        topl_set_resp(resp, def);
  1740. X
  1741. X        do {
  1742. X            c = nhgetch();
  1743. X            if (c && resp && !strchr(resp, c)) {
  1744. X                nhbell();
  1745. X                c = '\0';
  1746. X            }
  1747. X        } while (!c);
  1748. X
  1749. X        topl_set_resp("", '\0');
  1750. X        leave_topl_mode(&buf);
  1751. X        if (c == '#')
  1752. X            yn_number = atoi(buf);
  1753. X    }
  1754. X    return c;
  1755. X}
  1756. X
  1757. X
  1758. Xchar
  1759. Xpopup_yn_function(query,resp, def)
  1760. Xconst char *query,*resp;
  1761. Xchar def;
  1762. X{
  1763. X    char ch [ 2 ] ;
  1764. X
  1765. X    if ( ch [ 0 ] = ynaq_dialog ( query , resp , def ) ) {
  1766. X
  1767. X        return ch [ 0 ] ;
  1768. X    }
  1769. X
  1770. X    return topl_yn_function(query, resp, def);
  1771. X}
  1772. X
  1773. X
  1774. Xchar
  1775. Xmac_yn_function(query,resp, def)
  1776. Xconst char *query,*resp;
  1777. Xchar def;
  1778. X/*
  1779. X *   Generic yes/no function. 'def' is the default (returned by space or
  1780. X *   return; 'esc' returns 'q', or 'n', or the default, depending on
  1781. X *   what's in the string. The 'query' string is printed before the user
  1782. X *   is asked about the string.
  1783. X *   If resp is NULL, any single character is accepted and returned.
  1784. X */
  1785. X{
  1786. X    if (flags.popup_dialog)
  1787. X        return popup_yn_function(query, resp, def);
  1788. X    else
  1789. X        return topl_yn_function(query, resp, def);
  1790. X}
  1791. X
  1792. X/*topl.c*/
  1793. END_OF_FILE
  1794. if test 8925 -ne `wc -c <'sys/mac/mactopl.c'`; then
  1795.     echo shar: \"'sys/mac/mactopl.c'\" unpacked with wrong size!
  1796. fi
  1797. # end of 'sys/mac/mactopl.c'
  1798. fi
  1799. if test -f 'sys/share/pcsys.c' -a "${1}" != "-c" ; then 
  1800.   echo shar: Will not clobber existing file \"'sys/share/pcsys.c'\"
  1801. else
  1802. echo shar: Extracting \"'sys/share/pcsys.c'\" \(8230 characters\)
  1803. sed "s/^X//" >'sys/share/pcsys.c' <<'END_OF_FILE'
  1804. X/*    SCCS Id: @(#)pcsys.c    3.1    93/01/01
  1805. X/* NetHack may be freely redistributed.  See license for details. */
  1806. X
  1807. X/*
  1808. X *  System related functions for MSDOS, OS/2 and TOS
  1809. X */
  1810. X
  1811. X#define NEED_VARARGS
  1812. X#include "hack.h"
  1813. X#include "wintty.h"
  1814. X
  1815. X#include <ctype.h>
  1816. X#include <fcntl.h>
  1817. X#ifndef __GO32__
  1818. X#include <process.h>
  1819. X#else
  1820. X#define P_WAIT          0
  1821. X#define P_NOWAIT        1
  1822. X#endif
  1823. X#ifdef TOS
  1824. X#include <osbind.h>
  1825. X#endif
  1826. X
  1827. Xstatic boolean NDECL(record_exists);
  1828. X#ifndef TOS
  1829. Xstatic boolean NDECL(comspec_exists);
  1830. X#endif
  1831. X
  1832. X# ifdef MICRO
  1833. X
  1834. Xvoid
  1835. Xflushout()
  1836. X{
  1837. X    (void) fflush(stdout);
  1838. X    return;
  1839. X}
  1840. X
  1841. Xstatic const char *COMSPEC = 
  1842. X#  ifdef TOS
  1843. X"SHELL";
  1844. X#  else
  1845. X"COMSPEC";
  1846. X#  endif
  1847. X
  1848. X#define getcomspec() getenv(COMSPEC)
  1849. X
  1850. X#  ifdef SHELL
  1851. Xint
  1852. Xdosh()
  1853. X{
  1854. X    extern char orgdir[];
  1855. X    char *comspec;
  1856. X
  1857. X    if (comspec = getcomspec()) {
  1858. X#   ifndef TOS    /* TOS has a variety of shells */
  1859. X        suspend_nhwindows("To return to NetHack, enter \"exit\" at the system prompt.\n");
  1860. X#   else
  1861. X        suspend_nhwindows((char *)0);
  1862. X#   endif /* TOS */
  1863. X        chdirx(orgdir, 0);
  1864. X        if (spawnl(P_WAIT, comspec, comspec, NULL) < 0) {
  1865. X            raw_printf("Can't spawn \"%s\"!", comspec);
  1866. X            getreturn("to continue");
  1867. X        }
  1868. X#   ifdef TOS
  1869. X/* Some shells (e.g. Gulam) turn the cursor off when they exit */
  1870. X        if (flags.BIOS)
  1871. X            (void)Cursconf(1, -1);
  1872. X#   endif
  1873. X        get_scr_size(); /* maybe the screen mode changed (TH) */
  1874. X        resume_nhwindows();
  1875. X        chdirx(hackdir, 0);
  1876. X    } else
  1877. X        pline("Can't find %s.",COMSPEC);
  1878. X    return 0;
  1879. X}
  1880. X#  endif /* SHELL */
  1881. X
  1882. X#  ifdef MFLOPPY
  1883. X
  1884. Xvoid
  1885. Xeraseall(path, files)
  1886. Xconst char *path, *files;
  1887. X{
  1888. X    char buf[PATHLEN];
  1889. X    char *foundfile;
  1890. X
  1891. X    foundfile = foundfile_buffer(); 
  1892. X        Sprintf(buf, "%s%s", path, files);
  1893. X    if (findfirst(buf))
  1894. X        do {
  1895. X               Sprintf(buf, "%s%s", path, foundfile); 
  1896. X        (void) unlink(buf);
  1897. X        } while (findnext());
  1898. X    return;
  1899. X}
  1900. X
  1901. X/*
  1902. X * Rewritten for version 3.3 to be faster
  1903. X */
  1904. Xvoid
  1905. Xcopybones(mode)
  1906. Xint mode;
  1907. X{
  1908. X    char from[PATHLEN], to[PATHLEN], last[13];
  1909. X    char *frompath, *topath;
  1910. X    char *foundfile;
  1911. X#  ifndef TOS
  1912. X    int status;
  1913. X    char copy[8], *comspec;
  1914. X    extern saveprompt;
  1915. X#  endif
  1916. X
  1917. X    if (!ramdisk)
  1918. X        return;
  1919. X
  1920. X    /* Find the name of the last file to be transferred
  1921. X     */
  1922. X    frompath = (mode != TOPERM) ? permbones : levels;
  1923. X    foundfile = foundfile_buffer();
  1924. X    last[0] = '\0';
  1925. X    Sprintf(from, "%s%s", frompath, allbones);
  1926. X    topath = (mode == TOPERM) ? permbones : levels;
  1927. X#  ifdef TOS
  1928. X    eraseall(topath, allbones);
  1929. X#  endif
  1930. X    if (findfirst(from))
  1931. X        do {
  1932. X#  ifdef TOS
  1933. X            Sprintf(from, "%s%s", frompath, foundfile); 
  1934. X            Sprintf(to, "%s%s", topath, foundfile);
  1935. X            if (_copyfile(from, to))
  1936. X                goto error_copying;
  1937. X#  endif
  1938. X            Strcpy(last, foundfile);
  1939. X        } while (findnext());
  1940. X#  ifdef TOS
  1941. X    else
  1942. X        return;
  1943. X#  else
  1944. X    if (last[0]) {
  1945. X        Sprintf(copy, "%cC copy",switchar());
  1946. X
  1947. X        /* Remove any bones files in `to' directory.
  1948. X         */
  1949. X        eraseall(topath, allbones);
  1950. X
  1951. X        /* Copy `from' to `to' */
  1952. X        Sprintf(to, "%s%s", topath, allbones);
  1953. X        comspec = getcomspec();
  1954. X        status =spawnl(P_WAIT, comspec, comspec, copy, from,
  1955. X            to, "> nul", NULL);
  1956. X    } else
  1957. X        return;
  1958. X#  endif /* TOS */
  1959. X
  1960. X    /* See if the last file got there.  If so, remove the ramdisk bones
  1961. X     * files.
  1962. X     */
  1963. X    Sprintf(to, "%s%s", topath, last);
  1964. X    if (findfirst(to)) {
  1965. X        if (mode == TOPERM)
  1966. X            eraseall(frompath, allbones);
  1967. X        return;
  1968. X    }
  1969. X
  1970. X#  ifdef TOS
  1971. Xerror_copying:
  1972. X#  endif
  1973. X    /* Last file didn't get there.
  1974. X     */
  1975. X    Sprintf(to, "%s%s", topath, allbones);
  1976. X    msmsg("Can't copy \"%s\" to \"%s\" -- ", from, to);
  1977. X#  ifndef TOS
  1978. X    if (status < 0)
  1979. X        msmsg("can't spawn \"%s\"!", comspec);
  1980. X    else
  1981. X#  endif
  1982. X        msmsg((freediskspace(topath) < filesize(from)) ?
  1983. X            "insufficient disk space." : "bad path(s)?");
  1984. X    if (mode == TOPERM) {
  1985. X        msmsg("Bones will be left in \"%s\"\n",
  1986. X            *levels ? levels : hackdir);
  1987. X    } else {
  1988. X        /* Remove all bones files on the RAMdisk */
  1989. X        eraseall(levels, allbones);
  1990. X        playwoRAMdisk();
  1991. X    }
  1992. X    return;
  1993. X}
  1994. X
  1995. Xvoid
  1996. XplaywoRAMdisk()
  1997. X{
  1998. X    int c;
  1999. X
  2000. X    msmsg("Do you wish to play without a RAMdisk? [yn] (n)");
  2001. X
  2002. X    /* Set ramdisk false *before* exit-ing (because msexit calls
  2003. X     * copybones)
  2004. X     */
  2005. X    ramdisk = FALSE;
  2006. X    c = tgetch(); if (c == 'Y') c = 'y';
  2007. X    if (c != 'y') {
  2008. X        settty("Be seeing you...\n");
  2009. X        exit(0);
  2010. X    }
  2011. X    set_lock_and_bones();
  2012. X    return;
  2013. X}
  2014. X
  2015. Xint
  2016. XsaveDiskPrompt(start)
  2017. Xint start;
  2018. X{
  2019. X    extern saveprompt;
  2020. X    char buf[BUFSIZ], *bp;
  2021. X    char qbuf[QBUFSZ];
  2022. X
  2023. X    int fd;
  2024. X
  2025. X    if (saveprompt) {
  2026. X        /* Don't prompt if you can find the save file */
  2027. X        if ((fd = open_savefile()) >= 0) {
  2028. X            (void) close(fd);
  2029. X            return 1;
  2030. X        }
  2031. X        clear_nhwindow(WIN_MESSAGE);
  2032. X        pline("If save file is on a save disk, insert that disk now.");
  2033. X        mark_synch();
  2034. X        Sprintf(qbuf,"File name (default \"%s\"%s) ?", SAVEF,
  2035. X            start ? "" : ", <Esc> cancels save");
  2036. X        getlin(qbuf, buf);
  2037. X        clear_nhwindow(WIN_MESSAGE);
  2038. X        if (!start && *buf == '\033')
  2039. X            return 0;
  2040. X
  2041. X        /* Strip any whitespace. Also, if nothing was entered except
  2042. X         * whitespace, do not change the value of SAVEF.
  2043. X         */
  2044. X        for (bp = buf; *bp; bp++)
  2045. X            if (!isspace(*bp)) {
  2046. X                strncpy(SAVEF, bp, PATHLEN);
  2047. X                break;
  2048. X            }
  2049. X    }
  2050. X    return 1;
  2051. X}
  2052. X
  2053. X#endif /* MFLOPPY */
  2054. X
  2055. X/* Return 1 if the record file was found */
  2056. Xstatic boolean
  2057. Xrecord_exists()
  2058. X{
  2059. X    FILE *fp;
  2060. X
  2061. X    fp = fopen_datafile(RECORD, "r");
  2062. X    if (fp) {
  2063. X        fclose(fp);
  2064. X        return TRUE;
  2065. X    }
  2066. X    return FALSE;
  2067. X}
  2068. X
  2069. X#  ifdef TOS
  2070. X#define comspec_exists() 1
  2071. X#  else
  2072. X/* Return 1 if the comspec was found */
  2073. Xstatic boolean
  2074. Xcomspec_exists()
  2075. X{
  2076. X    int fd;
  2077. X    char *comspec;
  2078. X
  2079. X    if (comspec = getcomspec())
  2080. X        if ((fd = open(comspec, O_RDONLY)) >= 0) {
  2081. X            (void) close(fd);
  2082. X            return TRUE;
  2083. X        }
  2084. X    return FALSE;
  2085. X}
  2086. X# endif
  2087. X
  2088. X#ifdef MFLOPPY
  2089. X/* Prompt for game disk, then check for record file.
  2090. X */
  2091. Xvoid
  2092. XgameDiskPrompt()
  2093. X{
  2094. X    extern int saveprompt;
  2095. X
  2096. X    if (saveprompt) {
  2097. X        if (record_exists() && comspec_exists())
  2098. X            return;
  2099. X        (void) putchar('\n');
  2100. X        getreturn("when the game disk has been inserted");
  2101. X    }
  2102. X    if (comspec_exists() && record_exists())
  2103. X        return;
  2104. X
  2105. X    if (!comspec_exists())
  2106. X        msmsg("\n\nWARNING: can't find command processor \"%s\"!\n", getcomspec());
  2107. X        if (!record_exists())
  2108. X        msmsg("\n\nWARNING: can't find record file \"%s\"!\n", RECORD);
  2109. X    msmsg("If the game disk is not in, insert it now.\n");
  2110. X    getreturn("to continue");
  2111. X    return;
  2112. X}
  2113. X# endif
  2114. X# endif /* MFLOPPY */
  2115. X
  2116. X/*
  2117. X * Add a backslash to any name not ending in /, \ or :   There must
  2118. X * be room for the \
  2119. X */
  2120. Xvoid
  2121. Xappend_slash(name)
  2122. Xchar *name;
  2123. X{
  2124. X    char *ptr;
  2125. X
  2126. X    if (!*name)
  2127. X        return;
  2128. X    ptr = name + (strlen(name) - 1);
  2129. X    if (*ptr != '\\' && *ptr != '/' && *ptr != ':') {
  2130. X        *++ptr = '\\';
  2131. X        *++ptr = '\0';
  2132. X    }
  2133. X    return;
  2134. X}
  2135. X
  2136. Xvoid
  2137. Xgetreturn(str)
  2138. Xconst char *str;
  2139. X{
  2140. X# ifdef TOS
  2141. X    msmsg("Hit <Return> %s.", str);
  2142. X# else
  2143. X    msmsg("Hit <Enter> %s.", str);
  2144. X# endif
  2145. X    while (Getchar() != '\n') ;
  2146. X    return;
  2147. X}
  2148. X
  2149. Xvoid
  2150. Xmsmsg VA_DECL(const char *, fmt)
  2151. X    VA_START(fmt);
  2152. X    VA_INIT(fmt, const char *);
  2153. X    Vprintf(fmt, VA_ARGS);
  2154. X    flushout();
  2155. X    VA_END();
  2156. X    return;
  2157. X}
  2158. X
  2159. X/*
  2160. X * Follow the PATH, trying to fopen the file.
  2161. X */
  2162. X#  ifdef TOS
  2163. X#   ifdef __MINT__
  2164. X#define PATHSEP ':'
  2165. X#   else
  2166. X#define PATHSEP    ','
  2167. X#   endif
  2168. X#  else
  2169. X#define PATHSEP    ';'
  2170. X#  endif
  2171. X
  2172. XFILE *
  2173. Xfopenp(name, mode)
  2174. Xconst char *name, *mode;
  2175. X{
  2176. X    char buf[BUFSIZ], *bp, *pp, lastch = 0;
  2177. X    FILE *fp;
  2178. X
  2179. X    /* Try the default directory first.  Then look along PATH.
  2180. X     */
  2181. X    Strcpy(buf, name);
  2182. X    if (fp = fopen(buf, mode))
  2183. X        return fp;
  2184. X    else {
  2185. X        pp = getenv("PATH");
  2186. X        while (pp && *pp) {
  2187. X            bp = buf;
  2188. X            while (*pp && *pp != PATHSEP)
  2189. X                lastch = *bp++ = *pp++;
  2190. X            if (lastch != '\\' && lastch != '/')
  2191. X                *bp++ = '\\';
  2192. X            Strcpy(bp, name);
  2193. X            if (fp = fopen(buf, mode))
  2194. X                return fp;
  2195. X            if (*pp)
  2196. X                pp++;
  2197. X        }
  2198. X    }
  2199. X#  ifdef OS2_CODEVIEW /* one more try for hackdir */
  2200. X    Strcpy(buf,hackdir);
  2201. X    append_slash(buf);
  2202. X    Strcat(buf,name);
  2203. X    if(fp = fopen(buf,mode))
  2204. X        return fp;
  2205. X#  endif
  2206. X    return (FILE *)0;
  2207. X}
  2208. X
  2209. X/* Chdir back to original directory
  2210. X */
  2211. X#undef exit
  2212. X# ifdef TOS
  2213. Xextern boolean run_from_desktop;    /* set in pcmain.c */
  2214. X# endif
  2215. X
  2216. Xvoid exit(int);
  2217. X
  2218. Xvoid
  2219. Xmsexit(code)
  2220. Xint code;
  2221. X{
  2222. X# ifdef CHDIR
  2223. X    extern char orgdir[];
  2224. X# endif
  2225. X
  2226. X    flushout();
  2227. X# ifndef TOS
  2228. X    enable_ctrlP();        /* in case this wasn't done */
  2229. X# endif
  2230. X# ifdef MFLOPPY
  2231. X    if (ramdisk) copybones(TOPERM);
  2232. X# endif
  2233. X# ifdef CHDIR
  2234. X    chdir(orgdir);        /* chdir, not chdirx */
  2235. X    chdrive(orgdir);
  2236. X# endif
  2237. X# ifdef TOS
  2238. X    if (run_from_desktop)
  2239. X        getreturn("to continue"); /* so the user can read the score list */
  2240. X#  ifdef TEXTCOLOR
  2241. X    if (colors_changed)
  2242. X        restore_colors();
  2243. X#  endif
  2244. X# endif
  2245. X    exit(code);
  2246. X    return;
  2247. X}
  2248. END_OF_FILE
  2249. if test 8230 -ne `wc -c <'sys/share/pcsys.c'`; then
  2250.     echo shar: \"'sys/share/pcsys.c'\" unpacked with wrong size!
  2251. fi
  2252. # end of 'sys/share/pcsys.c'
  2253. fi
  2254. echo shar: End of archive 95 \(of 108\).
  2255. cp /dev/null ark95isdone
  2256. MISSING=""
  2257. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
  2258. 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
  2259. 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
  2260. 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 \
  2261. 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 \
  2262. 101 102 103 104 105 106 107 108 ; do
  2263.     if test ! -f ark${I}isdone ; then
  2264.     MISSING="${MISSING} ${I}"
  2265.     fi
  2266. done
  2267. if test "${MISSING}" = "" ; then
  2268.     echo You have unpacked all 108 archives.
  2269.     echo "Now execute 'rebuild.sh'"
  2270.     rm -f ark10[0-8]isdone ark[1-9]isdone ark[1-9][0-9]isdone
  2271. else
  2272.     echo You still need to unpack the following archives:
  2273.     echo "        " ${MISSING}
  2274. fi
  2275. ##  End of shell archive.
  2276. exit 0
  2277.