home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume16 / nethck31 / part101 < prev    next >
Encoding:
Internet Message Format  |  1993-02-05  |  58.8 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: v16i109:  nethack31 - display oriented dungeons & dragons (Ver. 3.1), Part101/108
  5. Message-ID: <4474@master.CNA.TEK.COM>
  6. Date: 5 Feb 93 22:03:36 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 2221
  9. Approved: billr@saab.CNA.TEK.COM
  10. Xref: uunet comp.sources.games:1660
  11.  
  12. Submitted-by: izchak@linc.cis.upenn.edu (Izchak Miller)
  13. Posting-number: Volume 16, Issue 109
  14. Archive-name: nethack31/Part101
  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 101 (of 108)."
  27. # Contents:  dat/oracles.txt src/minion.c src/pline.c
  28. #   sys/amiga/splitter/arg.c sys/amiga/splitter/split.h
  29. #   sys/amiga/winami.p sys/atari/Makefile.utl sys/mac/maccurs.c
  30. #   sys/vms/oldcrtl.c util/recover.c
  31. # Wrapped by billr@saab on Wed Jan 27 16:09:30 1993
  32. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  33. if test -f 'dat/oracles.txt' -a "${1}" != "-c" ; then 
  34.   echo shar: Will not clobber existing file \"'dat/oracles.txt'\"
  35. else
  36. echo shar: Extracting \"'dat/oracles.txt'\" \(5623 characters\)
  37. sed "s/^X//" >'dat/oracles.txt' <<'END_OF_FILE'
  38. X-----
  39. XIf thy wand hath run out of charges, thou mayst zap it again and again; though
  40. Xnaught will happen at first, verily, thy persistence shall be rewarded, as
  41. Xone last charge may yet be wrested from it!
  42. X-----
  43. XThough the shopkeepers be wary, thieves have nevertheless stolen much by using
  44. Xtheir digging wands to hasten exits through the pavement.
  45. X-----
  46. XIf thou hast had trouble with rust on thy armor or weapons, thou shouldst
  47. Xknow that thou canst prevent this by, while in a confused state, reading the
  48. Xmagical parchments which normally are used to cause their enchantment.
  49. X-----
  50. XBehold the cockatrice, whose diminutive stature belies its hidden might.  The
  51. Xcockatrice can petrify any ordinary being it contacts--save those wise
  52. Xadventurers who eat a dead lizard or blob of acid when they feel themselves
  53. Xslowly turning to stone.
  54. X-----
  55. XWhile some wayfarers rely on finding finished armour in the dungeon, the
  56. Xresourceful consider dragon scales as truly enchanting raw material and
  57. Xrealize that dragon scale mail is an excellent investment.
  58. X-----
  59. XIt is well known among travelers that extra-healing draughts may clear thy
  60. Xsenses when thou art addled by hallucinations.  But never forget, the lowly
  61. Xpotion which makes one sick may be used for the same purpose.
  62. X-----
  63. XWhile the consumption of lizard flesh or water beloved of the gods may
  64. Xstraighten thy head after confusion, the application of the horn of a
  65. Xcreature of utmost purity can alleviate many other afflictions as well.
  66. X-----
  67. XIf thou wishest to travel quickly between distant levels, thou must be
  68. Xable to control thy teleports, and be confused, and read the scroll
  69. Xwhich usually teleports thyself around on the level.  Daring adventurers
  70. Xhave also performed the same feat sans need for scrolls or potions by
  71. Xstepping on the correct type of trap.
  72. X-----
  73. XAlmost all adventurers who come this way hope to pass the dread Medusa.  To
  74. Xdo this, the best advice is to keep thine eyes blindfolded and to cause the
  75. Xcreature to espy its own reflection in a mirror.
  76. X-----
  77. XAnd where it is written "ad aerarium", diligent searching will often reveal
  78. Xthe way to a trap which sends one to the Magic Memory Vault, where the riches
  79. Xof Croesus are stored; however, escaping from the vault with its gold is much
  80. Xharder than getting in.
  81. X-----
  82. XIt is well known that wily shopkeepers doth raise their prices whene'er they
  83. Xespy the garish apparel of the approaching tourist or the countenance of a
  84. Xdisfavored patron.  They favor the gentle of manner and the fair of face.
  85. XThe boor may expect unprofitable transactions.
  86. X----- SINKS
  87. XThe cliche of the kitchen sink swallowing any unfortunate rings that contact
  88. Xits pernicious surface reflecteth greater truth than many homilies, yet
  89. Xeven so, few hath developed the skill to identify enchanted rings by the
  90. Xtransfigurations effected upon the voracious device's frame.
  91. X-----
  92. XThe meat of enchanted creatures will ofttimes convey magical properties
  93. Xunto the consumer.  A fresh corpse of floating eye doth fetch a high
  94. Xprice among wizards for its utility in conferring Telepathy, by which
  95. Xthe sightless may locate surrounding minds.
  96. X-----
  97. XThe detection of blessings and curses is in the domain of the gods.  They will
  98. Xmake this information available to mortals who request it at their places of
  99. Xworship, or elsewhere for those mortals who devote themselves to the service
  100. Xof the gods.
  101. X-----
  102. XAt times, the gods may favor worthy supplicants with named blades whose
  103. Xpowers echo throughout legend.  Learned wayfarers can reproduce blades of
  104. Xelven lineage, hated of the orcs, without the need for such intervention.
  105. X-----
  106. XAdventurers searching for Medusa or the Wizard of Yendor needst not wait until
  107. Xtheir dungeon level corresponds with their enemies' to know their location.
  108. XEat a floating eye, blind thyself, and use a mirror in thine own direction,
  109. Xand provided thou art lucky, thou shalt know the approximate locations of
  110. Xthine enemies.
  111. X-----
  112. XThere are many stories of a mighty amulet, the origins of which are said
  113. Xto be ancient Yendor.  This amulet doth have awesome power, and the gods
  114. Xdesireth it greatly.  Mortals mayst tap only portions of its terrible
  115. Xabilities.  The stories tell of mortals seeing what their eyes cannot
  116. Xsee and seeking places of magical transportation, while having this
  117. Xamulet in their possession.  Others say a mortal must wear the amulet to
  118. Xobtain these powers.  But verily, such power comes at great cost, to
  119. Xpreserve the balance.
  120. X-----
  121. XIt is said that thou mayst gain entry to Moloch's sanctuary, if thou
  122. Xdarest, from a place where the ground vibrates in the deepest depths of
  123. XGehennom.  Thou needs must have the aid of three magical items.  The
  124. Xpure sound of a silver bell shall announce thee.  The terrible runes,
  125. Xread from Moloch's book, shall cause the earth to tremble mightily.  The
  126. Xlight of an enchanted candelabrum shall show thee the way.
  127. X-----
  128. XIn the nethermost recesses of the dungeon, there standeth a castle, wherein
  129. Xlayeth a wand of wishes.  If thou wouldst gain entry, bear with thee an
  130. Xinstrument of music, for the drawbridge may be charmed down with the proper
  131. Xmelody.  What notes comprise it only the gods know, but a musical mastermind
  132. Xmay yet succeed by witful improvization.  However, the less perspicacious are
  133. Xnot without recourse, should they be prepared to circumambulate the castle to
  134. Xthe postern.
  135. X----- ELBERETH
  136. XThe name of Elbereth may strike fear into the hearts of thine enemies, if
  137. Xthou doest write it upon the ground at thy feet.  If thou maintain the utmost
  138. Xcalm, thy safety will be aided greatly, but beware lest thy clumsy feet scuff
  139. Xthe inscription, cancelling its potence.
  140. X-----
  141. END_OF_FILE
  142. if test 5623 -ne `wc -c <'dat/oracles.txt'`; then
  143.     echo shar: \"'dat/oracles.txt'\" unpacked with wrong size!
  144. fi
  145. # end of 'dat/oracles.txt'
  146. fi
  147. if test -f 'src/minion.c' -a "${1}" != "-c" ; then 
  148.   echo shar: Will not clobber existing file \"'src/minion.c'\"
  149. else
  150. echo shar: Extracting \"'src/minion.c'\" \(5321 characters\)
  151. sed "s/^X//" >'src/minion.c' <<'END_OF_FILE'
  152. X/*    SCCS Id: @(#)minion.c    3.1    92/11/01    */
  153. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  154. X/* NetHack may be freely redistributed.  See license for details. */
  155. X
  156. X#include "hack.h"
  157. X#include "emin.h"
  158. X#include "epri.h"
  159. X
  160. Xvoid
  161. Xmsummon(ptr)        /* ptr summons a monster */
  162. X    register struct permonst *ptr;
  163. X{
  164. X    register int dtype = 0, cnt = 0;
  165. X
  166. X    if(is_dprince(ptr) || (ptr == &mons[PM_WIZARD_OF_YENDOR])) {
  167. X
  168. X        dtype = (!rn2(20)) ? dprince() : (!rn2(4)) ? dlord() : ndemon();
  169. X        cnt = (!rn2(4) && !is_dprince(&mons[dtype])) ? 2 : 1;
  170. X
  171. X    } else if(is_dlord(ptr)) {
  172. X
  173. X        dtype = (!rn2(50)) ? dprince() : (!rn2(20)) ? dlord() : ndemon();
  174. X        cnt = (!rn2(4) && is_ndemon(&mons[dtype])) ? 2 : 1;
  175. X
  176. X    } else if(is_ndemon(ptr)) {
  177. X
  178. X        dtype = (!rn2(20)) ? dlord() : (!rn2(6)) ? ndemon() : monsndx(ptr);
  179. X        cnt = 1;
  180. X    } else if(is_lminion(ptr)) {
  181. X
  182. X        dtype = (is_lord(ptr) && !rn2(20)) ? llord() :
  183. X             (is_lord(ptr) || !rn2(6)) ? lminion() : monsndx(ptr);
  184. X        cnt = (!rn2(4) && !is_lord(&mons[dtype])) ? 2 : 1;
  185. X
  186. X    }
  187. X
  188. X    if(!dtype) return;
  189. X
  190. X    while(cnt > 0) {
  191. X
  192. X        (void)makemon(&mons[dtype], u.ux, u.uy);
  193. X        cnt--;
  194. X    }
  195. X    return;
  196. X}
  197. X
  198. Xvoid
  199. Xsummon_minion(alignment, talk)
  200. X    aligntyp alignment;
  201. X    boolean talk;
  202. X{
  203. X    register struct monst *mon;
  204. X    int mnum;
  205. X
  206. X    switch(alignment) {
  207. X    case A_LAWFUL: {
  208. X    mnum = lminion();
  209. X    break;
  210. X    }
  211. X    case A_NEUTRAL: {
  212. X    mnum = PM_AIR_ELEMENTAL + rn2(4);
  213. X    break;
  214. X    }
  215. X    case A_CHAOTIC:
  216. X    mnum = ndemon();
  217. X    break;
  218. X    default:
  219. X    impossible("unaligned player?");
  220. X    mnum = ndemon();
  221. X    break;
  222. X    }
  223. X    if(mons[mnum].pxlth == 0) {
  224. X    struct permonst *pm = &mons[mnum];
  225. X    pm->pxlth = sizeof(struct emin);
  226. X    mon = makemon(pm, u.ux, u.uy);
  227. X    pm->pxlth = 0;
  228. X    if(mon) {
  229. X        mon->isminion = TRUE;
  230. X        EMIN(mon)->min_align = alignment;
  231. X    }
  232. X    } else if (mnum == PM_ANGEL) {
  233. X    mon = makemon(&mons[mnum], u.ux, u.uy);
  234. X    if (mon) {
  235. X        mon->isminion = TRUE;
  236. X        EPRI(mon)->shralign = alignment;    /* always A_LAWFUL here */
  237. X    }
  238. X    } else
  239. X    mon = makemon(&mons[mnum], u.ux, u.uy);
  240. X    if(mon) {
  241. X    if(talk) {
  242. X        pline("The voice of %s booms:", align_gname(alignment));
  243. X        verbalize("Thou shalt pay for thy indiscretion!");
  244. X        if(!Blind)
  245. X        pline("%s appears before you.", Amonnam(mon));
  246. X    }
  247. X    mon->mpeaceful = FALSE;
  248. X    /* don't call set_malign(); player was naughty */
  249. X    }
  250. X}
  251. X
  252. X#define    Athome    (Inhell && !mtmp->cham)
  253. X
  254. Xint
  255. Xdemon_talk(mtmp)        /* returns 1 if it won't attack. */
  256. Xregister struct monst *mtmp;
  257. X{
  258. X    long    demand, offer;
  259. X
  260. X    if(uwep && uwep->oartifact == ART_EXCALIBUR) {
  261. X        pline("%s looks very angry.", Amonnam(mtmp));
  262. X        mtmp->mpeaceful = mtmp->mtame = 0;
  263. X        newsym(mtmp->mx, mtmp->my);
  264. X        return 0;
  265. X    }
  266. X
  267. X    /* Slight advantage given. */
  268. X    if(is_dprince(mtmp->data) && mtmp->minvis) {
  269. X        mtmp->minvis = 0;
  270. X        if (!Blind) pline("%s appears before you.", Amonnam(mtmp));
  271. X        newsym(mtmp->mx,mtmp->my);
  272. X    }
  273. X    if(u.usym == S_DEMON) {    /* Won't blackmail their own. */
  274. X
  275. X        pline("%s says, \"Good hunting, %s.\" and vanishes.",
  276. X          Amonnam(mtmp), flags.female ? "Sister" : "Brother");
  277. X        rloc(mtmp);
  278. X        return(1);
  279. X    }
  280. X    demand = (u.ugold * (rnd(80) + 20 * Athome)) / 100;
  281. X    if(!demand)          /* you have no gold */
  282. X        return mtmp->mpeaceful = 0;
  283. X    else {
  284. X
  285. X        pline("%s demands %ld zorkmid%s for safe passage.",
  286. X          Amonnam(mtmp), demand, plur(demand));
  287. X
  288. X        if((offer = bribe(mtmp)) >= demand) {
  289. X        pline("%s vanishes, laughing about cowardly mortals.",
  290. X              Amonnam(mtmp));
  291. X        } else {
  292. X        if((long)rnd(40) > (demand - offer)) {
  293. X            pline("%s scowls at you menacingly, then vanishes.",
  294. X              Amonnam(mtmp));
  295. X        } else {
  296. X            pline("%s gets angry...", Amonnam(mtmp));
  297. X            return mtmp->mpeaceful = 0;
  298. X        }
  299. X        }
  300. X    }
  301. X    mongone(mtmp);
  302. X    return(1);
  303. X}
  304. X
  305. Xlong
  306. Xbribe(mtmp)
  307. Xstruct monst *mtmp;
  308. X{
  309. X    char buf[80];
  310. X    long offer;
  311. X
  312. X    getlin("How much will you offer?", buf);
  313. X    (void) sscanf(buf, "%ld", &offer);
  314. X
  315. X/*Michael Paddon -- fix for negative offer to monster*/    /*JAR880815 - */
  316. X     if(offer < 0L) {
  317. X         You("try to shortchange %s, but fumble.", 
  318. X             mon_nam(mtmp));
  319. X         offer = 0L;
  320. X     } else if(offer == 0L) {
  321. X        You("refuse.");
  322. X     } else if(offer >= u.ugold) {
  323. X        You("give %s all your gold.", mon_nam(mtmp));
  324. X        offer = u.ugold;
  325. X    } else You("give %s %ld zorkmid%s.", mon_nam(mtmp), offer,
  326. X           plur(offer));
  327. X
  328. X    u.ugold -= offer;
  329. X    mtmp->mgold += offer;
  330. X    flags.botl = 1;
  331. X    return(offer);
  332. X}
  333. X
  334. Xint
  335. Xdprince() {
  336. X    int    tryct, pm;
  337. X
  338. X    for(tryct = 0; tryct < 20; tryct++) {
  339. X        pm = rn1(PM_DEMOGORGON + 1 - PM_ORCUS, PM_ORCUS);
  340. X        if(!(mons[pm].geno & (G_GENOD | G_EXTINCT)))
  341. X        return(pm);
  342. X    }
  343. X    return(dlord());    /* approximate */
  344. X}
  345. X
  346. Xint
  347. Xdlord()
  348. X{
  349. X    int    tryct, pm;
  350. X
  351. X    for(tryct = 0; tryct < 20; tryct++) {
  352. X        pm = rn1(PM_YEENOGHU + 1 - PM_JUIBLEX, PM_JUIBLEX);
  353. X        if(!(mons[pm].geno & (G_GENOD | G_EXTINCT)))
  354. X        return(pm);
  355. X    }
  356. X    return(ndemon());    /* approximate */
  357. X}
  358. X
  359. X/* create lawful (good) lord */
  360. Xint
  361. Xllord()
  362. X{
  363. X    if(!(mons[PM_ARCHON].geno & (G_GENOD | G_EXTINCT)))
  364. X        return(PM_ARCHON);
  365. X
  366. X    return(lminion());    /* approximate */
  367. X}
  368. X
  369. Xint
  370. Xlminion()
  371. X{
  372. X    int    tryct;
  373. X    struct    permonst *ptr;
  374. X
  375. X    for(tryct = 0; tryct < 20; tryct++)
  376. X        if((ptr = mkclass(S_ANGEL,0)) && !is_lord(ptr))
  377. X        return(monsndx(ptr));
  378. X
  379. X    return(0);
  380. X}
  381. X
  382. Xint
  383. Xndemon()
  384. X{
  385. X    int    tryct;
  386. X    struct    permonst *ptr;
  387. X
  388. X    for (tryct = 0; tryct < 20; tryct++) {
  389. X        ptr = mkclass(S_DEMON, 0);
  390. X        if (is_ndemon(ptr))
  391. X        return(monsndx(ptr));
  392. X    }
  393. X
  394. X    return(0);
  395. X}
  396. X
  397. X/*minion.c*/
  398. END_OF_FILE
  399. if test 5321 -ne `wc -c <'src/minion.c'`; then
  400.     echo shar: \"'src/minion.c'\" unpacked with wrong size!
  401. fi
  402. # end of 'src/minion.c'
  403. fi
  404. if test -f 'src/pline.c' -a "${1}" != "-c" ; then 
  405.   echo shar: Will not clobber existing file \"'src/pline.c'\"
  406. else
  407. echo shar: Extracting \"'src/pline.c'\" \(5430 characters\)
  408. sed "s/^X//" >'src/pline.c' <<'END_OF_FILE'
  409. X/*    SCCS Id: @(#)pline.c    3.1    92/11/20    */
  410. X/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  411. X/* NetHack may be freely redistributed.  See license for details. */
  412. X
  413. X#define NEED_VARARGS /* Uses ... */    /* comment line for pre-compiled headers */
  414. X#include "hack.h"
  415. X#include "epri.h"
  416. X
  417. X#ifndef OVLB
  418. XSTATIC_DCL boolean no_repeat;
  419. X#else /* OVLB */
  420. XSTATIC_OVL boolean no_repeat = FALSE;
  421. X#endif /* OVLB */
  422. X
  423. X#ifdef OVLB
  424. Xstatic char *FDECL(You_buf, (int));
  425. X
  426. X/*VARARGS1*/
  427. X/* Note that these declarations rely on knowledge of the internals
  428. X * of the variable argument handling stuff in "tradstdc.h"
  429. X */
  430. X
  431. X#if defined(USE_STDARG) || defined(USE_VARARGS)
  432. Xstatic void FDECL(vpline, (const char *, va_list));
  433. X
  434. Xvoid
  435. Xpline VA_DECL(const char *, line)
  436. X    VA_START(line);
  437. X    VA_INIT(line, char *);
  438. X    vpline(line, VA_ARGS);
  439. X    VA_END();
  440. X}
  441. X
  442. X# ifdef USE_STDARG
  443. Xstatic void
  444. Xvpline(const char *line, va_list the_args) {
  445. X# else
  446. Xstatic void
  447. Xvpline(line, the_args) const char *line; va_list the_args; {
  448. X# endif
  449. X
  450. X#else    /* USE_STDARG | USE_VARARG */
  451. X
  452. X#define vpline pline
  453. X
  454. Xvoid
  455. Xpline VA_DECL(const char *, line)
  456. X#endif    /* USE_STDARG | USE_VARARG */
  457. X
  458. X    char pbuf[BUFSZ];
  459. X/* Do NOT use VA_START and VA_END in here... see above */
  460. X
  461. X    if(!line || !*line) return;
  462. X    if(!index(line, '%'))
  463. X        Strcpy(pbuf,line);
  464. X    else
  465. X        Vsprintf(pbuf,line,VA_ARGS);
  466. X    if(!flags.window_inited) {
  467. X        raw_print(pbuf);
  468. X        return;
  469. X    }
  470. X#ifndef MAC
  471. X    if(no_repeat && !strcmp(pbuf, toplines))
  472. X        return;
  473. X#endif /* MAC */
  474. X    if (vision_full_recalc) vision_recalc(0);
  475. X    if (u.ux) flush_screen(1);        /* %% */
  476. X    putstr(WIN_MESSAGE, 0, pbuf);
  477. X}
  478. X
  479. X/*VARARGS1*/
  480. Xvoid
  481. XNorep VA_DECL(const char *, line)
  482. X    VA_START(line);
  483. X    VA_INIT(line, const char *);
  484. X    no_repeat = TRUE;
  485. X    vpline(line, VA_ARGS);
  486. X    no_repeat = FALSE;
  487. X    VA_END();
  488. X    return;
  489. X}
  490. X
  491. X/* work buffer for You(), Your(), and verbalize() */
  492. Xstatic char *you_buf = 0;
  493. Xstatic int you_buf_siz = 0;
  494. X
  495. Xstatic char *
  496. XYou_buf(siz) int siz; {
  497. X    if (siz > you_buf_siz) {
  498. X        if (you_buf_siz > 0) free((genericptr_t) you_buf);
  499. X        you_buf_siz = siz + 10;
  500. X        you_buf = (char *) alloc((unsigned) you_buf_siz);
  501. X    }
  502. X    return you_buf;
  503. X}
  504. X
  505. X/*VARARGS1*/
  506. Xvoid
  507. XYou VA_DECL(const char *, line)
  508. X    char *tmp;
  509. X    VA_START(line);
  510. X    VA_INIT(line, const char *);
  511. X    tmp = You_buf((int)strlen(line) + 5);
  512. X    Strcpy(tmp, "You ");
  513. X    Strcat(tmp, line);
  514. X    vpline(tmp, VA_ARGS);
  515. X    VA_END();
  516. X}
  517. X
  518. X/*VARARGS1*/
  519. Xvoid
  520. XYour VA_DECL(const char *,line)
  521. X    char *tmp;
  522. X    VA_START(line);
  523. X    VA_INIT(line, const char *);
  524. X    tmp = You_buf((int)strlen(line) + 6);
  525. X    Strcpy(tmp, "Your ");
  526. X    Strcat(tmp, line);
  527. X    vpline(tmp, VA_ARGS);
  528. X    VA_END();
  529. X}
  530. X
  531. X/*VARARGS1*/
  532. Xvoid
  533. Xverbalize VA_DECL(const char *,line)
  534. X    char *tmp;
  535. X    if (!flags.soundok) return;
  536. X    VA_START(line);
  537. X    VA_INIT(line, const char *);
  538. X    tmp = You_buf((int)strlen(line) + 3);
  539. X    Strcpy(tmp, "\"");
  540. X    Strcat(tmp, line);
  541. X    Strcat(tmp, "\"");
  542. X    vpline(tmp, VA_ARGS);
  543. X    VA_END();
  544. X}
  545. X
  546. X/*VARARGS1*/
  547. X/* Note that these declarations rely on knowledge of the internals
  548. X * of the variable argument handling stuff in "tradstdc.h"
  549. X */
  550. X
  551. X#if defined(USE_STDARG) || defined(USE_VARARGS)
  552. Xstatic void FDECL(vraw_printf,(const char *,va_list));
  553. X
  554. Xvoid
  555. Xraw_printf VA_DECL(const char *, line)
  556. X    VA_START(line);
  557. X    VA_INIT(line, char *);
  558. X    vraw_printf(line, VA_ARGS);
  559. X    VA_END();
  560. X}
  561. X
  562. X# ifdef USE_STDARG
  563. Xstatic void
  564. Xvraw_printf(const char *line, va_list the_args) {
  565. X# else
  566. Xstatic void
  567. Xvraw_printf(line, the_args) const char *line; va_list the_args; {
  568. X# endif
  569. X
  570. X#else  /* USE_STDARG | USE_VARARG */
  571. X
  572. Xvoid
  573. Xraw_printf VA_DECL(const char *, line)
  574. X#endif
  575. X/* Do NOT use VA_START and VA_END in here... see above */
  576. X
  577. X    if(!index(line, '%'))
  578. X        raw_print(line);
  579. X    else {
  580. X        char pbuf[BUFSZ];
  581. X        Vsprintf(pbuf,line,VA_ARGS);
  582. X        raw_print(pbuf);
  583. X    }
  584. X}
  585. X
  586. X
  587. X/*VARARGS1*/
  588. Xvoid
  589. Ximpossible VA_DECL(const char *, s)
  590. X    VA_START(s);
  591. X    VA_INIT(s, const char *);
  592. X    vpline(s,VA_ARGS);
  593. X    pline("Program in disorder - perhaps you'd better Quit.");
  594. X    VA_END();
  595. X}
  596. X
  597. Xconst char *
  598. Xalign_str(alignment)
  599. X    aligntyp alignment;
  600. X{
  601. X    switch ((int)alignment) {
  602. X    case A_CHAOTIC: return "chaotic";
  603. X    case A_NEUTRAL: return "neutral";
  604. X    case A_LAWFUL:    return "lawful";
  605. X    case A_NONE:    return "unaligned";
  606. X    }
  607. X    return "unknown";
  608. X}
  609. X
  610. Xvoid
  611. Xmstatusline(mtmp)
  612. Xregister struct monst *mtmp;
  613. X{
  614. X    aligntyp alignment;
  615. X
  616. X    if (mtmp->ispriest || mtmp->data == &mons[PM_ALIGNED_PRIEST]
  617. X                || mtmp->data == &mons[PM_ANGEL])
  618. X        alignment = EPRI(mtmp)->shralign;
  619. X    else
  620. X        alignment = mtmp->data->maligntyp;
  621. X
  622. X    alignment = (alignment > 0) ? A_LAWFUL :
  623. X        (alignment < 0) ? A_CHAOTIC :
  624. X        A_NEUTRAL;
  625. X    pline("Status of %s (%s):  Level %d  Gold %lu  HP %d(%d) AC %d%s%s",
  626. X        mon_nam(mtmp),
  627. X        align_str(alignment),
  628. X        mtmp->m_lev,
  629. X        mtmp->mgold,
  630. X        mtmp->mhp,
  631. X        mtmp->mhpmax,
  632. X        find_mac(mtmp),
  633. X        mtmp->mcan ? ", cancelled" : "" ,
  634. X        mtmp->mtame ? ", tame" : "");
  635. X}
  636. X
  637. Xvoid
  638. Xustatusline()
  639. X{
  640. X    pline("Status of %s (%s%s):  Level %d  Gold %lu  HP %d(%d)  AC %d",
  641. X        plname,
  642. X            (u.ualign.record >= 20) ? "piously " :
  643. X            (u.ualign.record > 13) ? "devoutly " :
  644. X            (u.ualign.record > 8) ? "fervently " :
  645. X            (u.ualign.record > 3) ? "stridently " :
  646. X            (u.ualign.record == 3) ? "" :
  647. X            (u.ualign.record >= 1) ? "haltingly " :
  648. X            (u.ualign.record == 0) ? "nominally " :
  649. X                        "insufficiently ",
  650. X        align_str(u.ualign.type),
  651. X# ifdef POLYSELF
  652. X        u.mtimedone ? mons[u.umonnum].mlevel : u.ulevel,
  653. X        u.ugold,
  654. X        u.mtimedone ? u.mh : u.uhp,
  655. X        u.mtimedone ? u.mhmax : u.uhpmax,
  656. X# else
  657. X        u.ulevel,
  658. X        u.ugold,
  659. X        u.uhp,
  660. X        u.uhpmax,
  661. X# endif
  662. X        u.uac);
  663. X}
  664. X
  665. X#endif /* OVLB */
  666. X
  667. X/*pline.c*/
  668. END_OF_FILE
  669. if test 5430 -ne `wc -c <'src/pline.c'`; then
  670.     echo shar: \"'src/pline.c'\" unpacked with wrong size!
  671. fi
  672. # end of 'src/pline.c'
  673. fi
  674. if test -f 'sys/amiga/splitter/arg.c' -a "${1}" != "-c" ; then 
  675.   echo shar: Will not clobber existing file \"'sys/amiga/splitter/arg.c'\"
  676. else
  677. echo shar: Extracting \"'sys/amiga/splitter/arg.c'\" \(5283 characters\)
  678. sed "s/^X//" >'sys/amiga/splitter/arg.c' <<'END_OF_FILE'
  679. X/*    SCCS Id: @(#)arg.c        3.1   93/01/08
  680. X/*    Copyright (c) Kenneth Lorber, Bethesda, Maryland, 1992, 1993 */
  681. X/* NetHack may be freely redistributed.  See license for details. */
  682. X
  683. X/*
  684. X * arg.c - semi-generic argument parser
  685. X */
  686. X#include <exec/types.h>
  687. X#include <exec/lists.h>
  688. X#include <proto/exec.h>
  689. X#include <stdio.h>
  690. X#include <stdlib.h>
  691. X#include <ctype.h>
  692. X#include <string.h>
  693. X#include "arg.h"
  694. X
  695. Xstatic char *a_desc;
  696. Xstatic int a_argc;
  697. Xstatic char **a_argv;
  698. Xstatic int a_apos;
  699. Xstatic char more=0;
  700. Xstatic char *argp;
  701. X
  702. Xstatic char *arg_fillbuf(void);
  703. X/*static char *splitline(struct fentry *); L505 bug? see below */
  704. Xstatic char *splitline2(char *);
  705. X
  706. Xchar *argarg;
  707. X
  708. X#ifndef ARGLEN
  709. X#define ARGLEN 134        /* longest line we can deal with */
  710. X#endif
  711. X
  712. Xstatic struct List flist;    /* stack of files to read from */
  713. Xstruct fentry {            /* structures on that stack */
  714. X    struct Node node;
  715. X    FILE *fp;
  716. X    char *ptr;
  717. X    char buf[ARGLEN];
  718. X};
  719. X
  720. Xstatic char *splitline(struct fentry *); /* L505 bug? can't be above def  */
  721. X
  722. X#define ListHead(x) ((x).lh_Head)
  723. X#define ListEmpty(x) (!(x).lh_Head->ln_Succ)
  724. X
  725. X/*
  726. X * arg_init(description string, argc, argv)
  727. X * Called by user to initialize system - must be called before calling
  728. X * other entry points.  desc is getopt(3) style description string; argc and
  729. X * argv are the arguments to main().
  730. X */
  731. Xvoid arg_init(char *desc,int argc,char *argv[]){
  732. X    a_desc=desc;
  733. X    a_argc=argc;
  734. X    a_argv=argv;
  735. X    a_apos=0;
  736. X    NewList(&flist);
  737. X}
  738. X
  739. X/*
  740. X * arg_next(void)
  741. X * Called by user to return each argument.  See arg.h for exceptional return
  742. X * values - normally returns the argument flag found; if a flag takes an
  743. X * argument, the argument is returned in argarg.
  744. X * An argument beginning with @ is taken to be a file name from which to read
  745. X * further arguments - such files are held on a stack and read as found, then
  746. X * the previous file (or the command line) is continued.
  747. X * In an argument file, the following are recognized:
  748. X * #  as the first character of a line only, causes the line to be ignored
  749. X * @  recursively read arguments from another file
  750. X * \n embedded newline
  751. X * \r embedded carriage return
  752. X * \f embedded formfeed
  753. X * \b embedded backspace
  754. X * \  literal next character (except above)
  755. X * "  start/end double quoted string
  756. X * '  start/end single quoted string
  757. X */
  758. Xint arg_next(){
  759. X    char *cp;
  760. X    char key;
  761. X
  762. X    if(!more){                /* anything still buffered? */
  763. X        if(!(argp=arg_fillbuf())){    /* nothing more */
  764. X            argarg=0;        /* be neat */
  765. X            return(ARG_DONE);
  766. X        }
  767. X    }
  768. X    if(more ||(*argp=='-' && argp++)){
  769. X        for(cp=a_desc;*cp;cp++){
  770. X            if(*cp== *argp){
  771. X                key=*argp++;
  772. X                if(*++cp==':'){
  773. X                    if(*argp){
  774. X                        argarg=argp;
  775. X                    }else{
  776. X                        argarg=arg_fillbuf();
  777. X                        if(!argarg)return(ARG_ERROR);
  778. X                    }
  779. X                    more=0;
  780. X                }else{
  781. X                    argarg=0; /* doesn't take an arg */
  782. X                    more= *argp;
  783. X                }
  784. X                return((int) key);
  785. X            }
  786. X        }
  787. X        return(ARG_ERROR);    /* no such option */
  788. X    }else{
  789. X        argarg=argp;
  790. X        more=0;
  791. X        return(ARG_FREE);
  792. X    }
  793. X}
  794. X
  795. Xstatic char *arg_fillbuf(){
  796. X    char *p,*nlp;;
  797. X
  798. X    if(ListEmpty(flist)){
  799. X        if(++a_apos>a_argc)return(0);
  800. X        p=a_argv[a_apos];
  801. X    }else{
  802. X        struct fentry *f=(struct fentry *)ListHead(flist);
  803. X        if(!f->ptr){
  804. X            do{
  805. X                if(!fgets(f->buf,ARGLEN,f->fp)){
  806. X                    if(ferror(f->fp)){
  807. X                        fprintf(stderr,
  808. X                            "I/O error on @file\n");
  809. X                        return(0);
  810. X                    }
  811. X                    fclose(f->fp);
  812. X                    RemHead(&flist);
  813. X                    free(f);
  814. X                    return(arg_fillbuf());
  815. X                }
  816. X            }while(f->buf[0]=='#');    /* comment */
  817. X            if(nlp=strchr(f->buf,'\n'))*nlp='\0';
  818. X        }
  819. X        p=splitline(f);
  820. X        if(p== (char *)-1)return(0);        /* error */
  821. X        if(!p)return(arg_fillbuf());    /* skip blank line */
  822. X    }
  823. X    if(p && *p=='@'){
  824. X        struct fentry *f=calloc(sizeof(struct fentry),1);
  825. X        f->fp=fopen(++p,"r");
  826. X        if(!(f->fp)){
  827. X            fprintf(stderr,"Can't open @file '%s'\n",p);
  828. X            free(f);
  829. X            return(0);
  830. X        }
  831. X        AddHead(&flist,(struct Node *)f);
  832. X        return(arg_fillbuf());
  833. X    }
  834. X    return(p);
  835. X}
  836. X
  837. Xstatic char *splitline(struct fentry *f){
  838. X    char *out=(f->ptr?f->ptr:f->buf);
  839. X    char *ret;
  840. X    while(*out && isspace(*out))out++;
  841. X    if(!*out)return(0);    /* blank line or spaces at end */
  842. X    ret=out;
  843. X    while(*out && !isspace(*out)){
  844. X        switch(*out){
  845. X        case '\\':
  846. X        case '\"':
  847. X        case '\'':
  848. X            out=splitline2(out);
  849. X            if(!out)return((char *)-1);    /* error */
  850. X            break;
  851. X        default:
  852. X            out++;
  853. X            break;
  854. X        }
  855. X    }
  856. X    if(!*out){
  857. X        f->ptr=0;    /* this was last arg on current line */
  858. X    }else{
  859. X        *out='\0';
  860. X        f->ptr= ++out;
  861. X        if(!(*f->ptr))f->ptr=0;
  862. X    }
  863. X    return ret;
  864. X}
  865. X
  866. Xstatic char *splitline2(char *p){
  867. X    char *out=p;
  868. X    char c;
  869. X    char dq=0,sq=0;
  870. X    while(*p){
  871. X        switch(c= *p++){
  872. X        case '\\':
  873. X            switch(c= *p++){
  874. X            case 'n':    *out++='\n';break;
  875. X            case 'r':    *out++='\r';break;
  876. X            case 'f':    *out++='\f';break;
  877. X            case 'b':    *out++='\b';break;
  878. X            case 0:        p--;break;
  879. X            default:    *out++=c;break;
  880. X            }
  881. X            break;
  882. X        case '\"':    if(sq){
  883. X                    *out++=c;
  884. X                }else{
  885. X                    dq=1-dq;
  886. X                }
  887. X                break;
  888. X        case '\'':    if(dq){
  889. X                    *out++=c;
  890. X                }else{
  891. X                    sq=1-sq;
  892. X                }
  893. X                break;
  894. X        case ' ':    if(!sq && !dq){*out=0;return(p-1);}
  895. X                *out++=' ';
  896. X                break;
  897. X        default:    *out++=c;break;
  898. X        }
  899. X    }
  900. X    if(sq ||dq){
  901. X        fprintf(stderr,"Warning - quote error in @file\n");
  902. X        return((char *)-1);
  903. X    }
  904. X    *out=0;
  905. X    return(p);
  906. X}
  907. X
  908. X#ifdef DEBUG_ARG
  909. Xmain(int argc,char *argv[]){
  910. X    int x=0;
  911. X    arg_init(getenv("test_arg"),argc,argv);
  912. X    do{
  913. X        x=arg_next();
  914. X        printf("r=%d (%d)'%s'\n",x,argarg,argarg);
  915. X    }while(x >= 0);
  916. X}
  917. X#endif /* DEBUG_ARG */
  918. END_OF_FILE
  919. if test 5283 -ne `wc -c <'sys/amiga/splitter/arg.c'`; then
  920.     echo shar: \"'sys/amiga/splitter/arg.c'\" unpacked with wrong size!
  921. fi
  922. # end of 'sys/amiga/splitter/arg.c'
  923. fi
  924. if test -f 'sys/amiga/splitter/split.h' -a "${1}" != "-c" ; then 
  925.   echo shar: Will not clobber existing file \"'sys/amiga/splitter/split.h'\"
  926. else
  927. echo shar: Extracting \"'sys/amiga/splitter/split.h'\" \(5777 characters\)
  928. sed "s/^X//" >'sys/amiga/splitter/split.h' <<'END_OF_FILE'
  929. X/*    SCCS Id: @(#)split.h        3.1   93/01/08
  930. X/*    Copyright (c) Kenneth Lorber, Bethesda, Maryland, 1992, 1993      */
  931. X/* NetHack may be freely redistributed.  See license for details. */
  932. X
  933. X/*
  934. X * split.h
  935. X * Common definitions for binary file splitting and loading of split files.
  936. X */
  937. X
  938. X#define SVER    1    /* Basic file splitting capability */
  939. X/*#define SVER    2    /* */
  940. X/*#define SVER    3    /* */
  941. X
  942. X/* Nothing below this line should need to be modified. */
  943. X
  944. X#ifndef SVER
  945. X __SPLIT_H__SVER_MUST_BE_DEFINED
  946. X#endif
  947. X
  948. X#if SVER >= 2
  949. X    /* enable options */
  950. X#endif
  951. X
  952. X/* internal structures, etc */
  953. X
  954. X#include <exec/types.h>
  955. X#include <exec/lists.h>
  956. X#include <proto/exec.h>
  957. X/*#include "ldextern.h"*/
  958. X
  959. X        /* one for each file we need something from */
  960. Xstruct file_ {
  961. X    struct MinNode    node;        /* linkage */
  962. X    struct List    punits;        /* program units we need */
  963. X    int        fd;        /* fd (-1 if not open) */
  964. X    char *        name;        /* open(2)'able name */
  965. X};
  966. Xtypedef struct file_ file;
  967. X
  968. X        /* one for each program unit we need to load */
  969. Xstruct punit_ {
  970. X    struct MinNode    node;        /* linkage */
  971. X    int        libsize;    /* 0 if normal, libsize if library */
  972. X    struct block_ *    unit_header;
  973. X    struct List    hunks;        /* hunks in this program unit */
  974. X};
  975. Xtypedef struct punit_ punit;
  976. X
  977. X        /* one for each hunk we need to load */
  978. Xstruct hunk_ {
  979. X    struct MinNode    node;        /* linkage */
  980. X    struct List    reloc;        /* reloc8,16,32 */
  981. X    struct List    dreloc;        /* drelec8,16,32 */
  982. X    struct block_ *    rb;        /* ONE relocatable block */
  983. X    struct block_ *    name;        /* max ONE name */
  984. X    struct List    extsym;        /* external symbol entries */
  985. X    struct punit_ * punit;        /* back pointer */
  986. X    struct hunk_  * merge;        /* 0 if lone or last section, else next
  987. X                     * part in this (merged by name) hunk */
  988. X    struct hunk_  * jmptab;        /* alv's live here, if any do. If so,
  989. X                     * it's at the end of the chain */
  990. X    int    hunkstart:1;    /* lone hunk or start of a chain */
  991. X    int    hunkchain:1;    /* allocated to a chain */
  992. X    int    hunkgone:1;    /* hunk has been written */
  993. X    long    overlay;    /* 0 if root node */
  994. X    long     hunknum;    /* in output file */
  995. X    long    hunkoffset;    /* 0 unless not at start of chain */
  996. X};
  997. Xtypedef struct hunk_ hunk;
  998. X#define UNASSIGNED_HUNK    0x7ffffff0
  999. X
  1000. Xstruct block_ {
  1001. X    struct MinNode    node;    /* linkage */
  1002. X    struct swap_ *sw;    /* if !0, where to reload from disk */
  1003. X    int id;            /* if used */
  1004. X    long *b;        /* if !0, block of raw data (else swapped) */
  1005. X                /* (this should be replaced with a union) */
  1006. X};
  1007. Xtypedef struct block_ block;
  1008. X
  1009. X        /* This is used to keep memory usage down.  We don't read in
  1010. X         * the actual data until we are writing the output file. */
  1011. Xstruct swap_ {
  1012. X    file *f;
  1013. X    long pos;
  1014. X    long len;            /* in longs */
  1015. X};
  1016. Xtypedef struct swap_ swap;
  1017. X
  1018. X        /* When we need a list of lists. */
  1019. Xstruct listlist_ {
  1020. X    struct MinNode    node;        /* linkage */
  1021. X    int         id;
  1022. X    struct List    list;
  1023. X};
  1024. Xtypedef struct listlist_ listlist;
  1025. X
  1026. Xtypedef char flag;            /* TRUE or FALSE only */
  1027. X
  1028. X/* tracing system */
  1029. X#define MAXTRACEVAR    7
  1030. Xextern char trace[MAXTRACEVAR];
  1031. X#define LIST        if(trace[0])        /* -t0=1 */
  1032. X#define HASHSTAT    if(trace[1])        /* -t1=1 */
  1033. X#define HASHTBL        if(trace[1]>1)        /* -t1=2 */
  1034. X#define NAME        if(trace[2])        /* -t2=1 */
  1035. X#define OUT        if(trace[3])        /* -t3=1 */
  1036. X#define PROC        if(trace[4])        /* -t4=1 */
  1037. X#define LIB        if(trace[5])        /* -t5=1 */
  1038. X#define VLIB        if(trace[5]>1)        /* -t5=2 */
  1039. X#define OVER        if(trace[6])        /* -t6=1 */
  1040. X
  1041. X/* name_ (symbol table) system */
  1042. X#define HSIZE    128        /* MUST be power of two */
  1043. X#define HMASK    (HSIZE-1)
  1044. X
  1045. Xstruct nentry_ {        /* a name entry */
  1046. X    struct MinNode    next;    /* next ref or def in bucket */
  1047. X    struct hunk_ *defh;    /* hunk where defined, else 0 */
  1048. X    long defo;        /* offset value of definition */
  1049. X    char *name;        /* name */
  1050. X    short len;        /* len of name */
  1051. X    unsigned refflag:1;    /* just for input_check */
  1052. X    unsigned linkvar:1;    /* linker variable */
  1053. X    unsigned inroot:1;    /* forced into root node */
  1054. X};
  1055. Xtypedef struct nentry_ nentry;
  1056. X
  1057. X/* hunk numbers in the overlay file start at this value: */
  1058. X#define OVRHUNK_BASE 0x40000000
  1059. X#define OVRHUNK_MASK 0x0fffffff
  1060. X
  1061. X/* Lists */
  1062. X#define LIST_P struct List *
  1063. X#define NODE_P struct Node *
  1064. X
  1065. Xstruct Node *Head(struct List *);
  1066. Xstruct Node *Tail(struct List *);
  1067. Xstruct Node *Next(struct Node *);
  1068. Xstruct Node *Prev(struct Node *);
  1069. X
  1070. Xextern flag read_any_bss;
  1071. Xextern flag overlaying;
  1072. X
  1073. Xextern struct List *_fortemp;
  1074. X#define foreach(n,lp,t)    _fortemp=(struct List *)(lp);if(_fortemp)    \
  1075. X            for(n= t Head(_fortemp);n;            \
  1076. X              n= t Next((struct Node *)(n)))
  1077. X
  1078. X/* privates for splitter */
  1079. X
  1080. X/* structs */
  1081. Xstruct hheader {
  1082. X    int hcount;        /* table size */
  1083. X    int first;        /* first hunk # */
  1084. X    int last;        /* last hunk # */
  1085. X    int (*sizes)[];        /* size of each hunk */
  1086. X};
  1087. Xstruct shunk {
  1088. X    struct hunk_ *h;        /* linker hunk info */
  1089. X};
  1090. X
  1091. X/* externs */
  1092. Xextern char *ssubst(char *,const char *);
  1093. Xextern void panic(char *);
  1094. Xextern char *eos(char *);
  1095. Xextern void read_load_file(char *);
  1096. Xextern void write_code_file(void);
  1097. Xextern void write_data_file(void);
  1098. Xextern void write_dir_file(void);
  1099. Xextern int write_split_file(int);
  1100. Xextern void write_lreloc(struct hunk_ *,struct listlist_ *);
  1101. Xextern void wsf_hunk(struct hunk_ *);
  1102. Xextern void renumber(void);
  1103. Xextern int renumber2(int,int);
  1104. Xextern void write_header(void);
  1105. Xextern void owrite(void*,long);
  1106. Xextern void owrite_long(long);
  1107. Xextern void out_start(char *);
  1108. Xextern void out_stop(void);
  1109. Xextern void new_file(void);
  1110. X
  1111. Xvoid print_text_block(char *,struct block_ *);
  1112. Xvoid print_bin_block(struct block_ *);
  1113. Xstruct file_ *NewFile(char *);
  1114. Xstruct punit_ *NewPunit(void);
  1115. Xstruct hunk_ *NewHunk(void);
  1116. Xstruct listlist_ *NewListList(void);
  1117. Xstruct block_ *NewBlock(void);
  1118. Xlong *NewData(long);
  1119. Xint rderror(void);    /* should be void, but needs return val for ?: */
  1120. Xstruct block_ *ReadSimpleBlock(struct file_ *,int);
  1121. Xint TossSimpleBlock(struct file_ *);
  1122. Xstruct hunk_ *ReadHunk(struct file_ *);
  1123. Xvoid ReadReloc(struct file_ *,long,struct List *);
  1124. Xlong block_size(struct block_ *);
  1125. END_OF_FILE
  1126. if test 5777 -ne `wc -c <'sys/amiga/splitter/split.h'`; then
  1127.     echo shar: \"'sys/amiga/splitter/split.h'\" unpacked with wrong size!
  1128. fi
  1129. # end of 'sys/amiga/splitter/split.h'
  1130. fi
  1131. if test -f 'sys/amiga/winami.p' -a "${1}" != "-c" ; then 
  1132.   echo shar: Will not clobber existing file \"'sys/amiga/winami.p'\"
  1133. else
  1134. echo shar: Extracting \"'sys/amiga/winami.p'\" \(2515 characters\)
  1135. sed "s/^X//" >'sys/amiga/winami.p' <<'END_OF_FILE'
  1136. X/*    SCCS Id: @(#)winami.p    3.1 93/01/08             */
  1137. X/*    Copyright (c) Gregg Wonderly, Naperville, IL, 1992, 1993     */
  1138. X/* NetHack may be freely redistributed. See license for details. */
  1139. X/* winami.c */
  1140. Xvoid FDECL(amii_raw_print, (const char *));
  1141. Xvoid FDECL(amii_raw_print_bold, (const char *));
  1142. Xvoid FDECL(amii_start_menu, (winid ));
  1143. Xvoid FDECL(amii_add_menu, (winid  , char  , int  , const char *));
  1144. Xvoid FDECL(amii_end_menu, (winid  , char  , const char * , const char *));
  1145. Xchar FDECL(amii_select_menu, (winid ));
  1146. Xvoid NDECL(amii_update_inventory );
  1147. Xvoid NDECL(amii_mark_synch );
  1148. Xvoid NDECL(amii_wait_synch );
  1149. Xvoid NDECL(amii_setclipped );
  1150. Xvoid FDECL(amii_cliparound, (int  , int ));
  1151. Xvoid NDECL(amii_askname );
  1152. Xvoid NDECL(amii_player_selection );
  1153. Xvoid NDECL(flush_output );
  1154. Xvoid FDECL(amii_destroy_nhwindow, (winid ));
  1155. Xint FDECL(amii_create_nhwindow, (int ));
  1156. Xvoid NDECL(amii_init_nhwindows );
  1157. Xvoid FDECL(amii_get_ext_cmd, (char *));
  1158. Xchar FDECL(amii_yn_function, (const char * , const char * , char ));
  1159. Xvoid FDECL(amii_addtopl, (const char *));
  1160. Xvoid FDECL(TextSpaces, (struct RastPort * , int ));
  1161. Xvoid FDECL(amii_putstr, (winid  , int  , const char *));
  1162. Xvoid FDECL(amii_putsym, (winid  , int  , int  , CHAR_P ));
  1163. Xvoid FDECL(amii_clear_nhwindow, (winid ));
  1164. Xvoid FDECL(amii_exit_nhwindows, (const char *));
  1165. Xint FDECL(amii_nh_poskey, (int * , int * , int *));
  1166. Xint NDECL(amii_nhgetch );
  1167. Xvoid NDECL(amii_get_nh_event );
  1168. Xvoid NDECL(amii_remember_topl );
  1169. Xint NDECL(amii_doprev_message );
  1170. Xvoid FDECL(amii_display_nhwindow, (winid  , boolean ));
  1171. Xvoid FDECL(amii_display_file, (const char * , boolean ));
  1172. Xvoid FDECL(amii_curs, (winid  , int  , int ));
  1173. Xvoid FDECL(amii_print_glyph, (winid  , xchar  , xchar  , int ));
  1174. Xvoid FDECL(DoMenuScroll, (int  , int ));
  1175. Xvoid FDECL(DisplayData, (int  , int  , int ));
  1176. Xvoid FDECL(SetPropInfo, (struct Window * , struct Gadget * , long  , long  , long ));
  1177. Xvoid FDECL(kill_nhwindows, (int ));
  1178. Xvoid FDECL(amii_cl_end, (struct WinDesc * , int ));
  1179. Xvoid FDECL(cursor_off, (winid ));
  1180. Xvoid FDECL(cursor_on, (winid ));
  1181. Xvoid NDECL(amii_getret );
  1182. Xvoid FDECL(amii_getlin, (const char * , char *));
  1183. Xvoid FDECL(getlind, (const char * , char * , const char *));
  1184. Xvoid FDECL(amii_suspend_nhwindows, (char * ));
  1185. Xvoid NDECL(amii_resume_nhwindows);
  1186. Xvoid NDECL(amii_bell);
  1187. Xvoid NDECL(EditColor);
  1188. Xvoid FDECL(DrawCol, ( struct Window *, int, UWORD * ) );
  1189. Xvoid FDECL( DispCol, ( struct Window *w, int idx, UWORD * ) );
  1190. Xvoid NDECL( amii_setpens );
  1191. Xvoid FDECL( SetBorder, (struct Gadget *) );
  1192. Xvoid NDECL( port_help );
  1193. END_OF_FILE
  1194. if test 2515 -ne `wc -c <'sys/amiga/winami.p'`; then
  1195.     echo shar: \"'sys/amiga/winami.p'\" unpacked with wrong size!
  1196. fi
  1197. # end of 'sys/amiga/winami.p'
  1198. fi
  1199. if test -f 'sys/atari/Makefile.utl' -a "${1}" != "-c" ; then 
  1200.   echo shar: Will not clobber existing file \"'sys/atari/Makefile.utl'\"
  1201. else
  1202. echo shar: Extracting \"'sys/atari/Makefile.utl'\" \(5437 characters\)
  1203. sed "s/^X//" >'sys/atari/Makefile.utl' <<'END_OF_FILE'
  1204. X#    Makefile for NetHack's utility programs.
  1205. X#    Atari specific version
  1206. X
  1207. X# if your make doesn't define a default SHELL properly, you may need
  1208. X#    the line below (Atari users will need a bourne work-alike)
  1209. X# SHELL = /bin/sh
  1210. X
  1211. X# flags may have to be changed as required
  1212. X# flags for 286 Xenix:
  1213. X# CFLAGS = -Ml2t16 -O -LARGE -I../include
  1214. X# LFLAGS = -Ml -F 4000 -SEG 512
  1215. X
  1216. X# flags for 286 Microport SysV-AT
  1217. X# CFLAGS = -DDUMB -Ml -I../include
  1218. X# LFLAGS = -Ml
  1219. X
  1220. X# flags for Atari GCC
  1221. XCFLAGS = -O -I../include
  1222. XLFLAGS =
  1223. X
  1224. X# flags for debugging:
  1225. X# CFLAGS = -g -I../include
  1226. X
  1227. X
  1228. X# yacc/lex programs to use to generate *_comp.h, *_lex.c, and *_yacc.c.
  1229. X# if, instead of yacc/lex you have bison/flex, comment/uncomment the following.
  1230. X# YACC     = yacc
  1231. X# LEX      = lex
  1232. XYACC     = bison -y
  1233. XLEX      = flex
  1234. X# these are the names of the output files from YACC/LEX. Under MS-DOS
  1235. X# and similar systems, they may differ
  1236. X# YTABC = y.tab.c
  1237. X# YTABH = y.tab.h
  1238. X# LEXYYC = lex.yy.c
  1239. XYTABC = y_tab.c
  1240. XYTABH = y_tab.h
  1241. XLEXYYC = lexyy.c
  1242. X
  1243. X# Nothing below this line should have to be changed.
  1244. X
  1245. X# utility .c files
  1246. XMAKESRC = makedefs.c
  1247. XSPLEVSRC = lev_yacc.c lev_lex.c lev_main.c panic.c
  1248. XDGNCOMPSRC = dgn_yacc.c dgn_lex.c dgn_main.c
  1249. XUTILSRCS = $(MAKESRC) $(SPLEVSRC) $(DGNCOMPSRC)
  1250. X
  1251. X# object files for makedefs
  1252. XMAKEOBJS = makedefs.o ../src/monst.o ../src/objects.o
  1253. X
  1254. X# object files for special levels compiler
  1255. XSPLEVOBJS = lev_yacc.o lev_lex.o lev_main.o panic.o \
  1256. X    ../src/alloc.o ../src/drawing.o ../src/decl.o \
  1257. X    ../src/monst.o ../src/objects.o
  1258. X
  1259. X# object files for dungeon compiler
  1260. XDGNCOMPOBJS = dgn_yacc.o dgn_lex.o dgn_main.o panic.o ../src/alloc.o
  1261. X
  1262. X# object files for recovery utility
  1263. XRECOVOBJS = recover.o
  1264. X
  1265. X
  1266. X#    dependencies for makedefs
  1267. X#
  1268. Xmakedefs:    $(MAKEOBJS)
  1269. X    $(CC) $(LFLAGS) -o makedefs $(MAKEOBJS)
  1270. X
  1271. Xmakedefs.o:  ../include/config.h ../include/permonst.h ../include/objclass.h \
  1272. X        ../include/monsym.h ../include/artilist.h ../include/qtext.h \
  1273. X        ../include/patchlevel.h
  1274. X
  1275. X../include/onames.h: makedefs
  1276. X    ./makedefs -o
  1277. X../include/pm.h: makedefs
  1278. X    ./makedefs -p
  1279. X../src/monstr.c: makedefs
  1280. X    ./makedefs -m
  1281. X../include/vis_tab.h: makedefs
  1282. X    ./makedefs -z
  1283. X../src/vis_tab.c: makedefs
  1284. X    ./makedefs -z
  1285. X
  1286. Xlintdefs:
  1287. X    @lint -axbh -I../include -DLINT $(MAKESRC) ../src/monst.c ../src/objects.c | sed '/_flsbuf/d'
  1288. X
  1289. X
  1290. X# the src Makefile is responsible for knowing when to call this, since
  1291. X# it knows all about the main src and include files
  1292. X../include/date.h::
  1293. X    ./makedefs -v
  1294. X
  1295. X
  1296. X#    dependencies for lev_comp
  1297. X#
  1298. Xlev_comp:  $(SPLEVOBJS)
  1299. X    $(CC) $(LFLAGS) -o lev_comp $(SPLEVOBJS)
  1300. X
  1301. Xlev_yacc.o:  ../include/hack.h ../include/sp_lev.h
  1302. Xlev_main.o:  ../include/hack.h ../include/sp_lev.h ../include/termcap.h
  1303. Xpanic.o:     ../include/config.h
  1304. X
  1305. Xlev_lex.o:   ../include/hack.h ../include/lev_comp.h ../include/sp_lev.h lev_lex.c
  1306. X    $(CC) -c $(CFLAGS) lev_lex.c
  1307. X
  1308. X../include/lev_comp.h: lev_yacc.c
  1309. X
  1310. Xlev_yacc.c: lev_comp.y
  1311. X    $(YACC) -d lev_comp.y
  1312. X    mv $(YTABC) lev_yacc.c
  1313. X    mv $(YTABH) ../include/lev_comp.h
  1314. X
  1315. Xlev_lex.c: lev_comp.l
  1316. X    $(LEX) lev_comp.l
  1317. X    mv $(LEXYYC) lev_lex.c
  1318. X
  1319. X# with all of extern.h's functions to complain about, we drown in
  1320. X# 'defined but not used' without -u
  1321. Xlintlev:
  1322. X    @lint -axhu -I../include -DLINT $(SPLEVSRC) ../src/alloc.c ../src/monst.c ../src/objects.c | sed '/_flsbuf/d'
  1323. X
  1324. X
  1325. X#    dependencies for dgn_comp
  1326. X#
  1327. Xdgn_comp:  $(DGNCOMPOBJS)
  1328. X    $(CC) $(LFLAGS) -o dgn_comp $(DGNCOMPOBJS)
  1329. X
  1330. Xdgn_yacc.o:  ../include/config.h ../include/dgn_file.h
  1331. Xdgn_main.o:  ../include/config.h
  1332. X
  1333. Xdgn_lex.o:   ../include/config.h ../include/dgn_comp.h ../include/dgn_file.h dgn_lex.c
  1334. X    $(CC) -c $(CFLAGS)  dgn_lex.c
  1335. X
  1336. X
  1337. X../include/dgn_comp.h: dgn_yacc.c
  1338. X
  1339. Xdgn_yacc.c: dgn_comp.y
  1340. X    $(YACC) -d dgn_comp.y
  1341. X    mv $(YTABC) dgn_yacc.c
  1342. X    mv $(YTABH) ../include/dgn_comp.h
  1343. X
  1344. Xdgn_lex.c: dgn_comp.l
  1345. X    $(LEX) dgn_comp.l
  1346. X    mv $(LEXYYC) dgn_lex.c
  1347. X
  1348. X# with all of extern.h's functions to complain about, we drown in
  1349. X# 'defined but not used' without -u
  1350. Xlintdgn:
  1351. X    @lint -axhu -I../include -DLINT $(DGNCOMPSRC) panic.c ../src/alloc.c | sed '/_flsbuf/d'
  1352. X
  1353. X
  1354. X#    dependencies for recover
  1355. X#
  1356. Xrecover: $(RECOVOBJS)
  1357. X    $(CC) $(LFLAGS) -o recover $(RECOVOBJS)
  1358. X
  1359. Xrecover.o: ../include/config.h
  1360. X
  1361. X
  1362. X
  1363. X# using dependencies like
  1364. X#    ../src/foo::
  1365. X#        @( cd ../src ; $(MAKE) foo )
  1366. X# would always force foo to be up-to-date according to the src Makefile
  1367. X# when it's needed here.  unfortunately, some makes believe this syntax
  1368. X# means foo always changes, instead of foo should always be checked.
  1369. X# therefore, approximate via config.h dependencies, and hope that anybody
  1370. X# changing anything other than basic configuration also knows when not
  1371. X# to improvise things not in the instructions, like 'make makedefs' here
  1372. X# in util...
  1373. X
  1374. X# make sure object files from src are available when needed
  1375. X#
  1376. X../src/alloc.o: ../src/alloc.c ../include/config.h
  1377. X    @( cd ../src ; $(MAKE) alloc.o )
  1378. X../src/drawing.o: ../src/drawing.c ../include/config.h
  1379. X    @( cd ../src ; $(MAKE) drawing.o )
  1380. X../src/decl.o: ../src/decl.c ../include/config.h
  1381. X    @( cd ../src ; $(MAKE) decl.o )
  1382. X../src/monst.o: ../src/monst.c ../include/config.h
  1383. X    @( cd ../src ; $(MAKE) monst.o )
  1384. X../src/objects.o: ../src/objects.c ../include/config.h
  1385. X    @( cd ../src ; $(MAKE) objects.o )
  1386. X
  1387. X# make sure hack.h dependencies get transitive information
  1388. X../include/hack.h: ../include/config.h
  1389. X    @( cd ../src ; $(MAKE) ../include/hack.h )
  1390. X
  1391. Xtags: $(UTILSRCS)
  1392. X    @ctags -tw $(UTILSRCS)
  1393. X
  1394. Xclean:
  1395. X    rm -f *.o
  1396. X
  1397. Xspotless: clean
  1398. X    rm -f lev_lex.c lev_yacc.c dgn_lex.c dgn_yacc.c
  1399. X    rm -f ../include/lev_comp.h ../include/dgn_comp.h
  1400. X    rm -f makedefs lev_comp dgn_comp recover
  1401. END_OF_FILE
  1402. if test 5437 -ne `wc -c <'sys/atari/Makefile.utl'`; then
  1403.     echo shar: \"'sys/atari/Makefile.utl'\" unpacked with wrong size!
  1404. fi
  1405. # end of 'sys/atari/Makefile.utl'
  1406. fi
  1407. if test -f 'sys/mac/maccurs.c' -a "${1}" != "-c" ; then 
  1408.   echo shar: Will not clobber existing file \"'sys/mac/maccurs.c'\"
  1409. else
  1410. echo shar: Extracting \"'sys/mac/maccurs.c'\" \(5462 characters\)
  1411. sed "s/^X//" >'sys/mac/maccurs.c' <<'END_OF_FILE'
  1412. X/*    SCCS Id: @(#)maccurs.c    3.1    93/01/24          */
  1413. X/* Copyright (c) Jon W{tte, 1992.                  */
  1414. X/* NetHack may be freely redistributed.  See license for details. */
  1415. X
  1416. X#include "hack.h"
  1417. X
  1418. X#include <Folders.h>
  1419. X#include <Windows.h>
  1420. X#include <ToolUtils.h>
  1421. X#include <Resources.h>
  1422. X#include <Memory.h>
  1423. X#include <Files.h>
  1424. X
  1425. X#define DIV_FACTOR 3
  1426. X
  1427. Xstatic Boolean winFileInit = 0 ;
  1428. Xstatic unsigned char winFileName [ 32 ] ;
  1429. Xstatic long winFileDir ;
  1430. Xstatic short winFileVol ;
  1431. Xstatic Handle winFileContents = NULL ;
  1432. X
  1433. Xtypedef struct WinPosSave {
  1434. X    short            validPos ;
  1435. X    short            validSize ;
  1436. X    short            top ;
  1437. X    short            left ;
  1438. X    short            height ;
  1439. X    short            width ;
  1440. X} WinPosSave ;
  1441. X
  1442. Xstatic WinPosSave savePos [ kLastWindowKind + 1 ] ;
  1443. Xstatic WinPosSave usePos [ kLastWindowKind + 1 ] ;
  1444. X
  1445. X
  1446. X
  1447. Xstatic void
  1448. XInitWinFile ( void )
  1449. X{
  1450. X    StringHandle sh ;
  1451. X    long len ;
  1452. X    short ref = 0 ;
  1453. X
  1454. X    if ( winFileInit ) {
  1455. X        return ;
  1456. X    }
  1457. X/* We trust the glue. If there's an error, store in game dir. */
  1458. X    if ( FindFolder ( kOnSystemDisk , kPreferencesFolderType , kCreateFolder ,
  1459. X        & winFileVol , & winFileDir ) ) {
  1460. X        winFileVol = 0 ;
  1461. X        winFileDir = 0 ;
  1462. X    }
  1463. X    sh = GetString ( 128 ) ;
  1464. X    if ( sh && * sh ) {
  1465. X        BlockMove ( * sh , winFileName , * * sh + 1 ) ;
  1466. X        ReleaseResource ( sh ) ;
  1467. X    } else {
  1468. X        BlockMove ( "\PNetHack Windows" , winFileName , 16 ) ;
  1469. X    }
  1470. X    if ( HOpen ( winFileVol , winFileDir , winFileName , fsRdPerm , & ref ) ) {
  1471. X        return ;
  1472. X    }
  1473. X    len = sizeof ( savePos ) ;
  1474. X    if ( ! FSRead ( ref , & len , savePos ) ) {
  1475. X        winFileInit = 1 ;
  1476. X    }
  1477. X    BlockMove ( savePos , usePos , sizeof ( savePos ) ) ;
  1478. X    FSClose ( ref ) ;
  1479. X}
  1480. X
  1481. X
  1482. Xstatic void
  1483. XFlushWinFile ( void )
  1484. X{
  1485. X    short ref ;
  1486. X    long len ;
  1487. X
  1488. X    if ( ! winFileInit ) {
  1489. X        if ( ! winFileName [ 0 ] ) {
  1490. X            return ;
  1491. X        }
  1492. X        HCreate ( winFileVol , winFileDir , winFileName , MAC_CREATOR , PREF_TYPE ) ;
  1493. X        HCreateResFile ( winFileVol , winFileDir , winFileName ) ;
  1494. X    }
  1495. X    if ( HOpen ( winFileVol , winFileDir , winFileName , fsWrPerm , & ref ) ) {
  1496. X        return ;
  1497. X    }
  1498. X    winFileInit = 1 ;
  1499. X    len = sizeof ( savePos ) ;
  1500. X    ( void ) FSWrite ( ref , & len , savePos ) ; /* Don't care about error */
  1501. X    FSClose ( ref ) ;
  1502. X}
  1503. X
  1504. X
  1505. Xint
  1506. XclickSector ( int x , int y , int toX , int toY )
  1507. X{
  1508. X    Boolean isDown = 0 ;
  1509. X    Boolean isLeft = 0 ;
  1510. X    Boolean inHoriz = 0 ;
  1511. X    Boolean inVert = 0 ;
  1512. X
  1513. X    if ( toX == x && toY == y ) {
  1514. X
  1515. X        return 0 ; /* On the same spot */
  1516. X    }
  1517. X
  1518. X    if ( abs ( toY - y ) <= abs ( toX - x ) / DIV_FACTOR ) {
  1519. X
  1520. X        inHoriz = 1 ;
  1521. X    }
  1522. X    if ( abs ( toX - x ) <= abs ( toY - y ) / DIV_FACTOR ) {
  1523. X
  1524. X        inVert = 1 ;
  1525. X    }
  1526. X    if ( toY > y ) {
  1527. X
  1528. X        isDown = 1 ;
  1529. X    }
  1530. X    if ( toX < x ) {
  1531. X
  1532. X        isLeft = 1 ;
  1533. X    }
  1534. X
  1535. X    if ( inHoriz ) {
  1536. X
  1537. X        if ( isLeft ) {
  1538. X
  1539. X            return 7 ;
  1540. X        }
  1541. X        return 3 ;
  1542. X    }
  1543. X    if ( inVert ) {
  1544. X
  1545. X        if ( isDown ) {
  1546. X
  1547. X            return 5 ;
  1548. X        }
  1549. X        return 1 ;
  1550. X    }
  1551. X    if ( isDown ) {
  1552. X
  1553. X        if ( isLeft ) {
  1554. X
  1555. X            return 6 ;
  1556. X        }
  1557. X        return 4 ;
  1558. X
  1559. X    } else {
  1560. X
  1561. X        if ( isLeft ) {
  1562. X
  1563. X            return 8 ;
  1564. X        }
  1565. X        return 2 ;
  1566. X    }
  1567. X}
  1568. X
  1569. X
  1570. X
  1571. X
  1572. XBoolean
  1573. XRetrievePosition ( short kind , short * top , short * left )
  1574. X{
  1575. X    Point p ;
  1576. X
  1577. X    InitWinFile ( ) ;
  1578. X    if ( kind < 0 || kind > kLastWindowKind ) {
  1579. X        return 0 ;
  1580. X    }
  1581. X    if ( ! usePos [ kind ] . validPos ) {
  1582. X        return 0 ;
  1583. X    }
  1584. X    * top = usePos [ kind ] . top ;
  1585. X    * left = usePos [ kind ] . left ;
  1586. X    p . h = * left ;
  1587. X    p . v = * top ;
  1588. X    return PtInRgn ( p , GetGrayRgn ( ) ) ;
  1589. X}
  1590. X
  1591. X
  1592. XBoolean
  1593. XRetrieveSize ( short kind , short top , short left , short * height , short * width )
  1594. X{
  1595. X    Point p ;
  1596. X
  1597. X    InitWinFile ( ) ;
  1598. X    if ( kind < 0 || kind > kLastWindowKind ) {
  1599. X        return 0 ;
  1600. X    }
  1601. X    if ( ! usePos [ kind ] . validSize ) {
  1602. X        return 0 ;
  1603. X    }
  1604. X    * width = usePos [ kind ] . width ;
  1605. X    * height = usePos [ kind ] . height ;
  1606. X    p . h = left + * width ;
  1607. X    p . v = top + * height ;
  1608. X    return PtInRgn ( p , GetGrayRgn ( ) ) ;
  1609. X}
  1610. X
  1611. X
  1612. Xvoid
  1613. XSavePosition ( short kind , short top , short left )
  1614. X{
  1615. X    InitWinFile ( ) ;
  1616. X    if ( kind < 0 || kind > kLastWindowKind ) {
  1617. X        return ;
  1618. X    }
  1619. X    savePos [ kind ] . validPos = 1 ;
  1620. X    savePos [ kind ] . top = top ;
  1621. X    savePos [ kind ] . left = left ;
  1622. X    FlushWinFile ( ) ;
  1623. X}
  1624. X
  1625. X
  1626. Xvoid
  1627. XSaveSize ( short kind , short height , short width )
  1628. X{
  1629. X    InitWinFile ( ) ;
  1630. X    if ( kind < 0 || kind > kLastWindowKind ) {
  1631. X        return ;
  1632. X    }
  1633. X    savePos [ kind ] . validSize = 1 ;
  1634. X    savePos [ kind ] . width = width ;
  1635. X    savePos [ kind ] . height = height ;
  1636. X    FlushWinFile ( ) ;
  1637. X}
  1638. X
  1639. X
  1640. Xstatic short
  1641. XGetWinKind ( WindowPtr win )
  1642. X{
  1643. X    short kind ;
  1644. X    NhWindow * nhw = GetWRefCon ( win ) ;
  1645. X
  1646. X    if ( ! nhw || ( ( ( long ) nhw ) & 1 ) || nhw -> theWindow != win ) {
  1647. X        return -1 ;
  1648. X    }
  1649. X    kind = nhw -> kind ;
  1650. X    if ( kind < 0 || kind > NHW_TEXT ) {
  1651. X        return -1 ;
  1652. X    }
  1653. X    switch ( kind ) {
  1654. X    case NHW_MAP :
  1655. X        kind = kMapWindow ;
  1656. X        break ;
  1657. X    case NHW_STATUS :
  1658. X        kind = kStatusWindow ;
  1659. X        break ;
  1660. X    case NHW_MESSAGE :
  1661. X        kind = kMessageWindow ;
  1662. X        break ;
  1663. X    case NHW_MENU :
  1664. X        kind = kMenuWindow ;
  1665. X        break ;
  1666. X    default :
  1667. X        kind = kTextWindow ;
  1668. X        break ;
  1669. X    }
  1670. X
  1671. X    return kind ;
  1672. X}
  1673. X
  1674. X
  1675. XBoolean
  1676. XRetrieveWinPos ( WindowPtr win , short * top , short * left )
  1677. X{
  1678. X    short kind ;
  1679. X
  1680. X    kind = GetWinKind ( win ) ;
  1681. X    if ( kind < 0 || kind > kLastWindowKind ) {
  1682. X        return 0 ;
  1683. X    }
  1684. X    return RetrievePosition ( kind , top , left ) ;
  1685. X}
  1686. X
  1687. X
  1688. Xvoid
  1689. XSaveWindowPos ( WindowPtr win )
  1690. X{
  1691. X    short kind ;
  1692. X    GrafPtr gp ;
  1693. X    Point p = { 0 , 0 } ;
  1694. X
  1695. X    kind = GetWinKind ( win ) ;
  1696. X    if ( kind < 0 || kind > kLastWindowKind ) {
  1697. X        return ;
  1698. X    }
  1699. X    GetPort ( & gp ) ;
  1700. X    SetPort ( win ) ;
  1701. X    LocalToGlobal ( & p ) ;
  1702. X    SetPort ( gp ) ;
  1703. X    SavePosition ( kind , p . v , p . h ) ;
  1704. X}
  1705. X
  1706. X
  1707. Xvoid
  1708. XSaveWindowSize ( WindowPtr win )
  1709. X{
  1710. X    short kind , width , height ;
  1711. X
  1712. X    kind = GetWinKind ( win ) ;
  1713. X    width = win -> portRect . right - win -> portRect . left ;
  1714. X    height = win -> portRect . bottom - win -> portRect . top ;
  1715. X    SaveSize ( kind , height , width ) ;
  1716. X}
  1717. END_OF_FILE
  1718. if test 5462 -ne `wc -c <'sys/mac/maccurs.c'`; then
  1719.     echo shar: \"'sys/mac/maccurs.c'\" unpacked with wrong size!
  1720. fi
  1721. # end of 'sys/mac/maccurs.c'
  1722. fi
  1723. if test -f 'sys/vms/oldcrtl.c' -a "${1}" != "-c" ; then 
  1724.   echo shar: Will not clobber existing file \"'sys/vms/oldcrtl.c'\"
  1725. else
  1726. echo shar: Extracting \"'sys/vms/oldcrtl.c'\" \(5550 characters\)
  1727. sed "s/^X//" >'sys/vms/oldcrtl.c' <<'END_OF_FILE'
  1728. X/*       SCCS Id: @(#)oldcrtl.c   3.1      90/05/24
  1729. X/*        Pat Rankin  May'90                                       */
  1730. X/* VMS NetHack support, not needed for vms 4.6,4.7,or 5.x.        */
  1731. X
  1732. X#ifdef VERYOLD_VMS
  1733. X/*
  1734. X * The following routines are used by NetHack but were not available
  1735. X * from the C Run-Time Library (VAXCRTL) prior to VMS V4.6.
  1736. X *
  1737. X *      atexit, memcmp, memcpy, qsort, rename, vprintf, vsprintf
  1738. X *
  1739. X * Most of them are implemented here, but others will have to be worked
  1740. X * around in another fashion [such as '#define USE_OLDARGS' (even though
  1741. X * <varargs.h> is available) to avoid the need for vprintf & vsprintf].
  1742. X *
  1743. X */
  1744. X#define REG register
  1745. X#define const
  1746. X
  1747. X#ifndef SUPPRESS_MEM_FUNCS
  1748. X/* note: hand optimized for VAX (hardware pre-decrement & post-increment) */
  1749. X
  1750. X/* void *memset(void *, int, size_t) -- fill chunk of memory.
  1751. X*/
  1752. Xchar *memset( dst, fil, cnt )
  1753. XREG char *dst;
  1754. XREG char  fil;
  1755. XREG int   cnt;
  1756. X{
  1757. X    char *dst_p = dst;
  1758. X    while ( --cnt >= 0 )
  1759. X    *dst++ = fil;
  1760. X    return dst_p;
  1761. X}
  1762. X
  1763. X/* void *memcpy(void *, const void *, size_t) -- copy chunk of memory.
  1764. X*/
  1765. Xchar *memcpy( dst, src, cnt )
  1766. XREG char       *dst;
  1767. XREG const char *src;
  1768. XREG int        cnt;
  1769. X{
  1770. X    char *dst_p = dst;
  1771. X    while ( --cnt >= 0 )
  1772. X    *dst++ = *src++;
  1773. X    return dst_p;
  1774. X}
  1775. X
  1776. X/* void *memmove(void *, const void *, size_t) -- copy possibly overlapping mem.
  1777. X*/
  1778. Xchar *memmove( dst, src, cnt )
  1779. XREG char       *dst;
  1780. XREG const char *src;
  1781. XREG int        cnt;
  1782. X{
  1783. X    char *dst_p = dst;
  1784. X    if ( src == dst || cnt <= 0 ) {
  1785. X    ;       /* do nothing */
  1786. X    } else if ( dst < src || dst >= src + cnt ) {
  1787. X    while ( --cnt >= 0 )
  1788. X        *dst++ = *src++;
  1789. X    } else {    /* work backwards */
  1790. X    dst += cnt,  src += cnt;
  1791. X    while ( --cnt >= 0 )
  1792. X        *--dst = *--src;
  1793. X    }
  1794. X    return dst_p;
  1795. X}
  1796. X
  1797. X/* void *memchr(const void *, int, size_t) -- search for a byte.
  1798. X*/
  1799. Xchar *memchr( buf, byt, len )
  1800. XREG const char *buf;
  1801. XREG char        byt;
  1802. XREG int        len;
  1803. X{
  1804. X    while ( --len >= 0 )
  1805. X    if ( *buf++ == byt )    /* found */
  1806. X        return (char *)--buf;
  1807. X    return (char *)0;       /* not found */
  1808. X}
  1809. X
  1810. X/* int memcmp(const void *, const void *, size_t) -- compare two chunks.
  1811. X*/
  1812. Xint memcmp( buf1, buf2, len )
  1813. XREG const char *buf1;
  1814. XREG const char *buf2;
  1815. XREG int        len;
  1816. X{
  1817. X    while ( --len >= 0 )
  1818. X    if ( *buf1++ != *buf2++ )
  1819. X        return (*--buf1 - *--buf2);
  1820. X    return 0;   /* buffers matched */
  1821. X}
  1822. X#endif /*!SUPPRESS_MEM_FUNCS*/
  1823. X
  1824. X
  1825. X#ifndef SUPPRESS_ATEXIT
  1826. X/* int atexit(void (*)(void)) -- register an exit handler.
  1827. X*/
  1828. X#define MAX_EXIT_FUNCS 32       /* arbitrary (32 matches VAX C v3.x docs) */
  1829. Xstruct _ex_hndlr { long reserved, (*routine)(), arg_count, *arg1_addr; };
  1830. Xstatic int ex_cnt = 0;          /* number of handlers registered so far */
  1831. Xstatic struct { long dummy_arg; struct _ex_hndlr handler;   /*(black box)*/
  1832. X       } ex_data[MAX_EXIT_FUNCS];       /* static handler data */
  1833. X
  1834. Xint atexit( function )
  1835. X    int (*function)();          /* note: actually gets called with 1 arg */
  1836. X{
  1837. X    if ( ex_cnt < MAX_EXIT_FUNCS ) {
  1838. X    ex_data[ex_cnt].dummy_arg = 0;  /* ultimately receives exit reason */
  1839. X    ex_data[ex_cnt].handler.reserved  = 0;
  1840. X    ex_data[ex_cnt].handler.routine   = (long (*)()) function;
  1841. X    ex_data[ex_cnt].handler.arg_count = 1;          /*(required)*/
  1842. X    ex_data[ex_cnt].handler.arg1_addr = &ex_data[ex_cnt].dummy_arg;
  1843. X    SYS$DCLEXH( &ex_data[ex_cnt].handler);  /* declare exit handler */
  1844. X    return ++ex_cnt;        /*(non-zero)*/
  1845. X    } else
  1846. X    return 0;
  1847. X}
  1848. X#endif /*!SUPPRESS_ATEXIT*/
  1849. X
  1850. X
  1851. X#ifndef SUPPRESS_RENAME
  1852. X/* int rename(const char *, const char *) -- rename a file (on same device).
  1853. X*/
  1854. X#ifndef EVMSERR
  1855. X#include <errno.h>
  1856. X#define C$$TRANSLATE(status)    (errno = EVMSERR,  vaxc$errno = (status))
  1857. X#endif
  1858. X
  1859. Xint rename( old_name, new_name )
  1860. X    const char *old_name;
  1861. X    const char *new_name;
  1862. X{
  1863. X    struct _dsc { int len; const char *adr; } old_dsc, new_dsc;
  1864. X    unsigned long status, LIB$RENAME_FILE();
  1865. X
  1866. X    /* put strings into descriptors and call run-time library routine */
  1867. X    old_dsc.len = strlen( old_dsc.adr = old_name );
  1868. X    new_dsc.len = strlen( new_dsc.adr = new_name );
  1869. X    status = LIB$RENAME_FILE( &old_dsc, &new_dsc);  /* omit optional args */
  1870. X    if ( !(status & 1) ) {      /* even => failure */
  1871. X    C$$TRANSLATE(status);
  1872. X    return -1;
  1873. X    } else                      /*  odd => success */
  1874. X    return 0;
  1875. X}
  1876. X#endif /*!SUPPRESS_RENAME*/
  1877. X
  1878. X
  1879. X#ifndef SUPPRESS_QSORT
  1880. X/* void qsort(void *, size_t, size_t, int (*)()) -- sort arbitrary collection.
  1881. X*/
  1882. Xvoid qsort( base, count, size, compare )
  1883. X    char *base;
  1884. X    int   count;
  1885. XREG int   size;
  1886. X    int (*compare)();
  1887. X{
  1888. XREG int   i, cmp;
  1889. XREG char *next, *prev, *tmp = 0;
  1890. X    char  wrk_buf[512], *malloc();      /* assume no alloca() available */
  1891. X
  1892. X    /* just use a shuffle sort (tradeoff between efficiency & simplicity) */
  1893. X    /*  [Optimal if already sorted; worst case when initially reversed.]  */
  1894. X    for ( next = base, i = 1;  i < count;  i++ ) {
  1895. X    prev = next,  next += size;             /* increment front pointer */
  1896. X    if ( (cmp = (*compare)( next, prev)) < 0 ) {
  1897. X        /* found element out of order; move other(s) up then re-insert it */
  1898. X        if ( !tmp )  tmp = (size > sizeof wrk_buf ? malloc(size) : wrk_buf);
  1899. X        memcpy( tmp, next, size);           /* save smaller element */
  1900. X        while ( cmp < 0 ) {
  1901. X        memcpy( prev + size, prev, size);   /* move larger elem. up */
  1902. X        prev -= size;                   /* decrement back pointer */
  1903. X        cmp = (prev >= base ? (*compare)( tmp, prev) : 0);
  1904. X        }
  1905. X        memcpy( prev + size, tmp, size);    /* restore small element */
  1906. X    }
  1907. X    }
  1908. X    if ( tmp != 0 && tmp != wrk_buf )  free(tmp);
  1909. X    return;
  1910. X}
  1911. X#endif /*!SUPPRESS_QSORT*/
  1912. X
  1913. X#endif /*VERYOLD_VMS*/
  1914. END_OF_FILE
  1915. if test 5550 -ne `wc -c <'sys/vms/oldcrtl.c'`; then
  1916.     echo shar: \"'sys/vms/oldcrtl.c'\" unpacked with wrong size!
  1917. fi
  1918. # end of 'sys/vms/oldcrtl.c'
  1919. fi
  1920. if test -f 'util/recover.c' -a "${1}" != "-c" ; then 
  1921.   echo shar: Will not clobber existing file \"'util/recover.c'\"
  1922. else
  1923. echo shar: Extracting \"'util/recover.c'\" \(5503 characters\)
  1924. sed "s/^X//" >'util/recover.c' <<'END_OF_FILE'
  1925. X/* recover.c - NetHack version 3.1 */
  1926. X
  1927. X/*
  1928. X *  Utility for reconstructing NetHack save file from a set of individual
  1929. X *  level files.  Requires that the `checkpoint' option be enabled at the
  1930. X *  time NetHack creates those level files.
  1931. X */
  1932. X#include "config.h"
  1933. X#if !defined(O_WRONLY) && !defined(LSC) && !defined(AZTEC_C)
  1934. X#include <fcntl.h>
  1935. X#endif
  1936. X
  1937. X#ifndef VMS
  1938. X# ifdef exit
  1939. X#  undef exit
  1940. X# endif
  1941. X#ifdef MICRO
  1942. Xextern void FDECL(exit, (int));
  1943. X#endif
  1944. X#else    /* VMS */
  1945. Xextern int FDECL(vms_creat, (const char *,unsigned));
  1946. Xextern int FDECL(vms_open, (const char *,int,unsigned));
  1947. X#endif    /* VMS */
  1948. X
  1949. Xint FDECL(restore_savefile, (char *));
  1950. Xvoid FDECL(set_levelfile_name, (int));
  1951. Xint FDECL(open_levelfile, (int));
  1952. Xint FDECL(create_savefile, (char *));
  1953. Xvoid FDECL(copy_bytes, (int,int));
  1954. X
  1955. X#ifdef UNIX
  1956. X#define SAVESIZE    (PL_NSIZ + 13)    /* save/99999player.e */
  1957. X#else
  1958. X# ifdef VMS
  1959. X#define SAVESIZE    (PL_NSIZ + 22)    /* [.save]<uid>player.e;1 */
  1960. X# else
  1961. X#define SAVESIZE    FILENAME    /* from macconf.h or pcconf.h */
  1962. X# endif
  1963. X#endif
  1964. X
  1965. Xchar savename[SAVESIZE]; /* holds relative path of save file from playground */
  1966. X
  1967. X
  1968. Xint
  1969. Xmain(argc, argv)
  1970. Xint argc;
  1971. Xchar *argv[];
  1972. X{
  1973. X    int argno;
  1974. X    char *dir = (char *)0;
  1975. X
  1976. X    if (argc == 1 || (argc == 2 && !strcmp(argv[1], "-"))) {
  1977. X        (void) fprintf(stderr,
  1978. X                "Usage: %s [-d directory] base1 base2 ...\n",
  1979. X                argv[0]);
  1980. X        exit(1);
  1981. X    }
  1982. X
  1983. X    argno = 1;
  1984. X    if (!strncmp(argv[argno], "-d", 2)) {
  1985. X        dir = argv[argno]+2;
  1986. X        if (*dir == '=' || *dir == ':') dir++;
  1987. X        if (!*dir && argc > argno) {
  1988. X            argno++;
  1989. X            dir = argv[argno];
  1990. X        }
  1991. X        if (!*dir) {
  1992. X            (void) fprintf(stderr,
  1993. X            "%s: flag -d must be followed by a directory name.\n",
  1994. X            argv[0]);
  1995. X            exit(1);
  1996. X        }
  1997. X        argno++;
  1998. X    }
  1999. X
  2000. X    if (!dir) dir = getenv("NETHACKDIR");
  2001. X    if (!dir) dir = getenv("HACKDIR");
  2002. X#if defined(SECURE) && !defined(VMS)
  2003. X    if (dir
  2004. X# ifdef HACKDIR
  2005. X        && strcmp(dir, HACKDIR)
  2006. X# endif
  2007. X        ) {
  2008. X        (void) setgid(getgid());
  2009. X        (void) setuid(getuid());
  2010. X    }
  2011. X#endif    /* SECURE && !VMS */
  2012. X
  2013. X#ifdef HACKDIR
  2014. X    if (!dir) dir = HACKDIR;
  2015. X#endif
  2016. X
  2017. X    if (dir && chdir(dir) < 0) {
  2018. X        (void) fprintf(stderr, "%s: cannot chdir to %s.\n",
  2019. X                argv[0], dir);
  2020. X        exit(1);
  2021. X    }
  2022. X
  2023. X    while (argc > argno) {
  2024. X        (void) restore_savefile(argv[argno]);
  2025. X        argno++;
  2026. X    }
  2027. X#ifndef VMS
  2028. X    return 0;
  2029. X#else
  2030. X    return 1;       /* vms success */
  2031. X#endif /*VMS*/
  2032. X}
  2033. X
  2034. Xstatic char lock[256];
  2035. X
  2036. Xvoid
  2037. Xset_levelfile_name(lev)
  2038. Xint lev;
  2039. X{
  2040. X    char *tf;
  2041. X
  2042. X    tf = rindex(lock, '.');
  2043. X    if (!tf) {
  2044. X        tf = lock;
  2045. X        while (*tf) tf++;
  2046. X    }
  2047. X#ifdef VMS
  2048. X    (void) sprintf(tf, ".%d;1", lev);
  2049. X#else
  2050. X    (void) sprintf(tf, ".%d", lev);
  2051. X#endif
  2052. X}
  2053. X
  2054. Xint
  2055. Xopen_levelfile(lev)
  2056. Xint lev;
  2057. X{
  2058. X    int fd;
  2059. X
  2060. X    set_levelfile_name(lev);
  2061. X#ifdef MICRO
  2062. X    fd = open(lock, O_RDONLY | O_BINARY);
  2063. X#else
  2064. X    fd = open(lock, O_RDONLY, 0);
  2065. X#endif
  2066. X    return fd;
  2067. X}
  2068. X
  2069. Xint
  2070. Xcreate_savefile(savename)
  2071. Xchar *savename;
  2072. X{
  2073. X    int fd;
  2074. X
  2075. X#ifdef MICRO
  2076. X    fd = open(savename, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, FCMASK);
  2077. X#else
  2078. X    fd = creat(savename, FCMASK);
  2079. X#endif
  2080. X    return fd;
  2081. X}
  2082. X
  2083. Xvoid
  2084. Xcopy_bytes(ifd, ofd)
  2085. Xint ifd, ofd;
  2086. X{
  2087. X    char buf[BUFSIZ];
  2088. X    int nfrom, nto;
  2089. X
  2090. X    do {
  2091. X        nfrom = read(ifd, buf, BUFSIZ);
  2092. X        nto = write(ofd, buf, nfrom);
  2093. X        if (nto != nfrom) {
  2094. X            (void) fprintf(stderr, "file copy failed!\n");
  2095. X            exit(1);
  2096. X        }
  2097. X    } while (nfrom == BUFSIZ);
  2098. X}
  2099. X
  2100. Xint
  2101. Xrestore_savefile(basename)
  2102. Xchar *basename;
  2103. X{
  2104. X    int gfd, lfd, sfd;
  2105. X    int lev, savelev, hpid;
  2106. X    xchar levc;
  2107. X
  2108. X    /* level 0 file contains:
  2109. X     *    pid of creating process (ignored here)
  2110. X     *    level number for current level of save file
  2111. X     *    name of save file nethack would have created
  2112. X     *    and game state
  2113. X     */
  2114. X    (void) strcpy(lock, basename);
  2115. X    gfd = open_levelfile(0);
  2116. X    if (gfd < 0) {
  2117. X        (void) fprintf(stderr, "Cannot open level 0 for %s.\n", basename);
  2118. X        return(-1);
  2119. X    }
  2120. X    (void) read(gfd, (genericptr_t) &hpid, sizeof(hpid));
  2121. X    if (read(gfd, (genericptr_t) &savelev, sizeof(savelev))
  2122. X                            != sizeof(savelev)) {
  2123. X        (void) fprintf(stderr,
  2124. X        "Checkpointing was not in effect for %s -- recovery impossible.\n",
  2125. X        basename);
  2126. X        (void) close(gfd);
  2127. X        return(-1);
  2128. X    }
  2129. X    (void) read(gfd, (genericptr_t) savename, sizeof(savename));
  2130. X
  2131. X    /* save file should contain:
  2132. X     *    current level (including pets)
  2133. X     *    (non-level-based) game state
  2134. X     *    other levels
  2135. X     */
  2136. X    sfd = create_savefile(savename);
  2137. X    if (sfd < 0) {
  2138. X        (void) fprintf(stderr, "Cannot create savefile %s.\n", savename);
  2139. X        (void) close(gfd);
  2140. X        return(-1);
  2141. X    }
  2142. X
  2143. X    lfd = open_levelfile(savelev);
  2144. X    if (lfd < 0) {
  2145. X        (void) fprintf(stderr, "Cannot open level of save for %s.\n",
  2146. X                basename);
  2147. X        (void) close(gfd);
  2148. X        (void) close(sfd);
  2149. X        return(-1);
  2150. X    }
  2151. X
  2152. X    copy_bytes(lfd, sfd);
  2153. X    (void) close(lfd);
  2154. X    (void) unlink(lock);
  2155. X
  2156. X    copy_bytes(gfd, sfd);
  2157. X    (void) close(gfd);
  2158. X    set_levelfile_name(0);
  2159. X    (void) unlink(lock);
  2160. X
  2161. X    for (lev = 1; lev < 256; lev++) {
  2162. X        /* level numbers are kept in xchars in save.c, so the
  2163. X         * maximum level number (for the endlevel) must be < 256
  2164. X         */
  2165. X        if (lev != savelev) {
  2166. X            lfd = open_levelfile(lev);
  2167. X            if (lfd >= 0) {
  2168. X                /* any or all of these may not exist */
  2169. X                levc = (xchar) lev;
  2170. X                write(sfd, (genericptr_t) &levc, sizeof(levc));
  2171. X                copy_bytes(lfd, sfd);
  2172. X                (void) close(lfd);
  2173. X                (void) unlink(lock);
  2174. X            }
  2175. X        }
  2176. X    }
  2177. X
  2178. X    (void) close(sfd);
  2179. X
  2180. X#ifdef AMIGA
  2181. X            /* we need to create an icon for the saved game
  2182. X             * or HackWB won't notice the file.
  2183. X             */
  2184. X    {
  2185. X    char iconfile[FILENAME];
  2186. X    int in, out;
  2187. X
  2188. X    sprintf(iconfile,"%s.info",savename);
  2189. X    in=open("NetHack:default.icon",O_RDONLY);
  2190. X    out=open(iconfile,O_WRONLY | O_TRUNC | O_CREAT);
  2191. X    if(in > -1 && out > -1){
  2192. X        copy_bytes(in,out);
  2193. X    }
  2194. X    if(in > -1)close(in);
  2195. X    if(out > -1)close(out);
  2196. X    }
  2197. X#endif
  2198. X    return(0);
  2199. X}
  2200. X
  2201. X/*recover.c*/
  2202. END_OF_FILE
  2203. if test 5503 -ne `wc -c <'util/recover.c'`; then
  2204.     echo shar: \"'util/recover.c'\" unpacked with wrong size!
  2205. fi
  2206. # end of 'util/recover.c'
  2207. fi
  2208. echo shar: End of archive 101 \(of 108\).
  2209. cp /dev/null ark101isdone
  2210. MISSING=""
  2211. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
  2212. 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
  2213. 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
  2214. 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 \
  2215. 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 \
  2216. 101 102 103 104 105 106 107 108 ; do
  2217.     if test ! -f ark${I}isdone ; then
  2218.     MISSING="${MISSING} ${I}"
  2219.     fi
  2220. done
  2221. if test "${MISSING}" = "" ; then
  2222.     echo You have unpacked all 108 archives.
  2223.     echo "Now execute 'rebuild.sh'"
  2224.     rm -f ark10[0-8]isdone ark[1-9]isdone ark[1-9][0-9]isdone
  2225. else
  2226.     echo You still need to unpack the following archives:
  2227.     echo "        " ${MISSING}
  2228. fi
  2229. ##  End of shell archive.
  2230. exit 0
  2231.