home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sources / games / 175 < prev    next >
Encoding:
Internet Message Format  |  1992-08-20  |  56.5 KB

  1. Path: sparky!uunet!zephyr.ens.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v14i045:  umoria4 - single player dungeon simulation (ver. 5.5), Part13/39
  5. Message-ID: <3403@master.CNA.TEK.COM>
  6. Date: 20 Aug 92 18:04:22 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 2138
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: grabiner@math.harvard.edu (David Grabiner)
  12. Posting-number: Volume 14, Issue 45
  13. Archive-name: umoria4/Part13
  14. Supersedes: umoria3: Volume 9, Issue 55-97; Volume 10, Issue 15-17
  15. Environment: Curses, Unix, Mac, MS-DOS, Atari-ST, Amiga, VMS
  16.  
  17.  
  18.  
  19. #! /bin/sh
  20. # This is a shell archive.  Remove anything before this line, then unpack
  21. # it by saving it into a file and typing "sh file".  To overwrite existing
  22. # files, type "sh file -c".  You can also feed this as standard input via
  23. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  24. # will see the following message at the end:
  25. #        "End of archive 13 (of 39)."
  26. # Contents:  CHANGES ibmpc/make/makefile.top source/io.c
  27. # Wrapped by billr@saab on Thu Aug 20 09:11:29 1992
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'CHANGES' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'CHANGES'\"
  31. else
  32. echo shar: Extracting \"'CHANGES'\" \(15638 characters\)
  33. sed "s/^X//" >'CHANGES' <<'END_OF_FILE'
  34. X::::::: 1991 ::::::::
  35. X---------- 1/4
  36. Xspells.c: light_area(), always light area immediately next to player even if
  37. X    in a room, could be standing on the edge of a room
  38. Xmonsters.c: Grave Wight, no longer has confusion spell, no other wight/wraith
  39. X    has it
  40. Xmisc2.c: get_spell(), when enter invalid character, print "You don't know
  41. X    that prayer." instead of "spell" for priests/etc.
  42. Xcreature.c: make_attack(), creatures which are repelled should not be confused
  43. X    because they did not hit the player
  44. Xdeath.c: exit_game(), delete #ifndef TURBOC around the restore_term() call
  45. Xio.c: restore_term(), delete the call to clear() in the MSDOS code, it was
  46. X    trying to use curses after curses had been exited
  47. X---------- 1/22
  48. Xfiles.c: call pause_line(23) after printing hours file
  49. Xconstant.h, config.h: constant.h should always be included before config.h,
  50. X    because some systems redefine constants in config.h
  51. Xrnd.c: include config.h after constant.h
  52. Xmain.c, misc2.c, save.c, signals.c: include constants.h before config.h
  53. Xmisc2.c, vms/getch.c: new function user_name() for VMS, fix get_name()
  54. X    in misc2.c to call it
  55. X------- 1/30
  56. Xmoria2.c: hit_trap(), add msg_print(CNIL) for the trap door case
  57. X-------- 2/4
  58. Xio.c: for ATARIST_MWC, use 240 instead of '#' for walls
  59. Xsave.c: for ATARIST_MWC, convert 240 to '#' when saving, and '#' to 240
  60. X    when loading, to avoid conversion problems
  61. X--------- 2/8
  62. Xcreate.c: monval(), cast i to int, otherwise some compilers do the arithmetic
  63. X    with unsigned characters
  64. X--------- 2/19
  65. Xmakefile: add new macro CURSES, define it for BSD/SYS V/and Xenix
  66. Xconfig.h: add config info for XENIX, define SYS_V and unix, only undefine
  67. X    register for MSC versions less than 600 (6.00?)
  68. Xcreature.c: mon_move, comment out register decl for r_ptr for XENIX systems
  69. X    to avoid a compiler bug
  70. Xmisc2.c: place_gold, comment out register decl for t_ptr for XENIX systems
  71. X    to avoid a compiler bug
  72. Xunix.c: ifdef out include of termio.h, for XENIX add include of sys/types.h
  73. X    and define bzero as memset, test for unix or M_XENIX at the top
  74. XMakefile: add optional commands to install target which chown/chgrp everythin
  75. X    to bin, and put pointer to it at the top
  76. X---------- 2/25
  77. Xutil/score: Two new utilities, prscore to print scorefiles, and delscore to
  78. X    delete one entry from a scorefile.
  79. Xconfig.h: add MORIA_* macros for the Atari ST with GCC
  80. Xdeath.c, externs.h, io.c, main.c, signals.c, variable.c: Apply Atari ST/GCC
  81. X    patches from Scott Kolodzieski.
  82. X-------- 3/1
  83. Xdeath.c: Amiga must open/close scorefile like MSDOS&VMS
  84. Xio.c: init_curses(),restore_term(), fix bugs in AMIGA code,
  85. X    add code to release resources
  86. Xamiga/*: updated versions of amiga source files, from
  87. X    cg37717@lion.eng.clemson.edu, Corey Gehman
  88. Xatari_st/curscomp: complete rewrite of the curses code by Hildo Biersma
  89. Xstore2.c: get_haggle(), do not accept an increment value of zero, turn off
  90. X    increment flag instead of accepting it
  91. X-------- 3/2
  92. Xstore2.c: store_purchase(), store_prt_gold call was inside `if' now after,
  93. X    did not update gold if store had 13 items and you bought the 13th
  94. X-------- 3/11
  95. Xmoria1.c: sub3_move_light(), don't print over old location if find_flag
  96. X    is true, unless find_prself is also true, this speeds up movement
  97. X    in find mode by eliminating unnecessary drawing of characters
  98. Xmoria2.c: hit_trap(), call move_light() for the teleport trap case, to light
  99. X    up the trap
  100. Xmisc1.c, save.c, treasure.c: change ATARIST_MWC ifdefs for using graphic
  101. X    character to ATARI_ST which is true for both MWC and TC
  102. Xio.c: remove all ATARIST_MWC diffs which were needed for the old non-standard
  103. X    curses, change the rest to be ATARI_ST, since both MWC and TC need them
  104. X-------- 3/14
  105. Xsource/*: add Mac THINK C support
  106. Xmac/dumpres/*: add Mac THINK C support
  107. Xmac/scrnmgr/*: add Mac Think C support
  108. Xmoria1.c: find_init(), when !light_flag and !find_prself, must erase the
  109. X    player's '@', because sub3_move_light() won't, see 3/11 change above
  110. X------- 3/15
  111. Xmac/*: add Mac THINK C support
  112. X*: put file name and 1991 copyrights in all source files
  113. X------- 3/23
  114. Xsave.c: prevent resurrection of a total winner character
  115. Xconstants.h, creature.c, monsters.c, recall.c: add new flag CM_ONLY_MAGIC,
  116. X    set this flag in creature.c, check the flag in recall.c, allows
  117. X    recall to print movement speed for Quylthulgs
  118. Xcreature.c: when a wand is drained of charges, inscribe it as {empty} if
  119. X    it is not known2
  120. X-------- 3/24
  121. Xfiles.c, ibmpc/ms_misc.c: ifdefed out msdos_intro(), since that routine is
  122. X    obsolete now
  123. Xdoc/moria.6: add -S option to list at the top
  124. Xibmpc/CONFIG.DOC: update for Umoria 5.x, remove kneller's address, and put in
  125. X    my address
  126. X------- 3/25
  127. Xconfig.h, constant.h, */*.c: move VMS definition for ESCAPE from config.h
  128. X    to constant.h, now all files include config.h before constant.h
  129. X*: linted all sources files, changed version numbers to 5.3
  130. X------- 3/30
  131. Xvms/*, ibmpc/ms_misc.c, config.h, death.c, dungeon.c, externs.h, files.c,
  132. Xio.c, save.c: merge in changes from Ralph Waters, which are needed to compile
  133. X    the sources under VMS and IBM-PC/Turbo C.
  134. Xmoria2.c, store2.c, *.c: get_item(), show_inven() take new parameter mask,
  135. X    if mask is non-zero, they only list items indicated by mask array,
  136. X    store_sell() calculates a mask based on what store will buy
  137. Xstore2.c: purchase_haggle(), sell_haggle(), if the auto increment is larger
  138. X    than the difference between the store's offer and the player's offer,
  139. X    then set the auto increment to the exact difference
  140. Xdungeon.c, externs.h, moria1.c, moria2.c, variable.c: eliminate search_flag,
  141. X    it was redundant, replace all uses with (py.flags.status & PY_SEARCH)
  142. Xtables.c: remove good armor items from armory, to force players to search for
  143. X    them in the dungeons, hard leather boots, iron helm, partial plate,
  144. X    full plate
  145. Xmisc1.c: alloc_monster(), always create dragons sleeping here, to give the
  146. X    player a sporting chance
  147. Xmoria1.c: inven_command(), when pack not empty and show_weights flag true,
  148. X    display capacity along with weigth carried on first line of inventory
  149. Xspells.c: build_wall(), permanently light walls created within range of
  150. X    player's lamp
  151. Xspells.c: earthquake(), fix it to act just like build_wall when a monster is
  152. X    trapped in a wall
  153. Xcreature.c, externs.h: movement_rate(), now static
  154. X*: release 5.3.1 sources
  155. X------- 4/27
  156. Xms_misc.c, externs.h: change declarations of warn() to match definition,
  157. X    change declaration and definition of error() to match warn(),
  158. Xexterns.h: fix declarations for sleep(), find_init(), show_inven(), get_item()
  159. Xdeath.c: display_scores(), don't set player_uid for non UNIX/VMS system
  160. X    duplicate_character(), ifdef out code which is unreachable for non
  161. X    UNIX/VMS system, make all returns have a value
  162. Xsets.c: set_null(), add a #pragma argused for TURBO C
  163. Xms_misc.c: fix three lines that had an assignment inside an if
  164. Xexterns.h: add prototypes/declarations for VMS files getch.c and uexit.c
  165. Xmoria1.c: see_wall(), change ATARIST_MWC ifdef to ATARI_ST
  166. Xatari_st/curscomp/curses.c: winsch(), first loop ran in wrong direction
  167. Xexterns.h: add declarations for atari st functions
  168. Xatari_st/moria.prj: new file, TC project file for Umoria
  169. Xdeath.c: highscores (), change fseed to fseek, typing error
  170. Xcreature.c, death.c, desc.c, dungeon.c, files.c, io.c, moria1.c, moria2.c,
  171. X    store2.c, wizard.c, atarist.c: include stdlib.h if ATARIST_TC to get
  172. X    prototypes for standard library functions
  173. Xgenerate.c: for ATARIST_TC, include <string.h>
  174. Xatarist/curscomp/curses.h: change mvadd* macros from compound statements to
  175. X    conditional expressions, so that all returns values are error checked
  176. Xio.c: for ATARIST_TC, include ext.h to properly define (?) sleep
  177. Xconfig.h: for ATARIST_TC, define index strchr
  178. Xsave.c: sv_write()/get_char(), define t_ptr for both MSDOS and ATARI_ST;
  179. X    get_char(), change ATARIST_MWC ifdef around chmod call to ATARI_ST
  180. X    include time.h for ATARIST_TC
  181. Xunix/Makefile: change ONWER to OWNER
  182. Xcreature.c: creatures(), give moves to monsters trapped in rock, so that they
  183. X    will die/dig out immediately, mon_move() if a monster in rock is
  184. X    already dead, don't kill it again
  185. X*: update address info in all files
  186. Xio.c: change __GNU_C_ to __GNUC__
  187. Xconfig.h: the test for undefining 'register' was wrong, it was undefing it
  188. X    for all non-MSC compilers
  189. Xmoria2.c: tunnel(), heavy weapon code wrong, eliminate >>2 of penalty, add
  190. X    penalty instead of subtracting it
  191. Xhelp.c: ident_char(), add period after Giant Frog.
  192. Xmonsters.c: novice priest, change sleep from 10 to 5 to match other novice 'p'
  193. Xmoria1.c, store2.c, *.c: get_item() new parameter 'message', when invalid
  194. X    letter hit, print this message if non-zero instead of beeping,
  195. X    store_sell() pass message "I do not buy such items.", fix all other
  196. X    callers to pass CNIL
  197. X-------- 4/28
  198. Xmisc2.c, files.c: put_misc2(), file_character(), when player at max level,
  199. X    don't print a number for Exp to Adv, instead print ******
  200. Xio.c: msg_print(), put multiple messages on the same line if they are short
  201. X    enough
  202. X------- 5/22
  203. Xexterns.h: ifdef out declaration of sprintf for NeXT
  204. Xio.c (init_curses): correct atarist/GNUC code for signal call, ifdef was wrong
  205. X------- 7/6
  206. Xspells.c (unlight_area): Unlight all floor spaces with `lr' set, instead of
  207. X    just the room floors spaces.  This darkens the doorways.
  208. Xmoria1.c (light_room): Add code to set the fm flag, necessary so that the
  209. X    above fix does not unlight doors that it shouldn't.
  210. Xio.c (msg_print): Don't combine NULL messages with other messages.
  211. Xsave.c (get_char): Use msg_print when printing the `departed spirit' message.
  212. X-------- 7/26
  213. Xstore2.c (purchase_haggle, sell_haggle): If the automatic increment plus the
  214. X    last offer passes the shop keepers current ask, then clear the incr.
  215. X-------- 10/5
  216. X*: Add changes needed to prevent warnings from the IBM-PC TURBO C compiler.
  217. Xmisc[1234].c, moria[1234].c: misc[12].c and moria[12].c were each split into
  218. X    two files, because they were too large for TURBO C's integrated
  219. X    environment
  220. X*: adjust all makefiles, externs.h, etc to account for new moria/misc files
  221. XTCCONFIG.TCU, TCPICK.TCU: new files, uuencoded copies of Turbo C setup files
  222. Xconfig.h, ms_misc.c: New define USING_TCIO, used to prevent including curses.h
  223. X    in ms_misc.c.  Defaults to defined if using TURBOC on an IBM-PC.
  224. Xio.c: delete special purpose AMIGA code, it now uses curses
  225. Xamiga/amiga.h: Deleted.
  226. Xamiga/amiga.c: Delete all curses stubs.
  227. X-------- 10/6
  228. Xmacrsrc.h: change type of resType, ResID to long
  229. Xmacrsrc.c: eliminated search_flag from macrsrc.c (see 3/30 changes)
  230. Xconfig.h: put back switches RSRC, RSRC_PART1 and RSRC_PART2
  231. XScrnMgr.ro: changed def of MBAR #228 (fixes crash on Mac Plus) and INFO #1
  232. X    (Make default window be full screen)
  233. XScrnMgr.c: check for reconfig flag enabled for THINK_C, add recognition
  234. X    of MacClassic (and LC?) keyboard, now assumes unknown keyboard type
  235. X    has control key, other misc cleanups
  236. Xmoria.ro: changes version string
  237. Xmacconf.c: config.h included for consistency
  238. Xmac.c: added support for 8-column tabs
  239. Xmac/Install.doc: new file, installation instructions for THINK C
  240. Xmacconf.c, machelp.c, macscore.c scrnmgr.c: covered up error in THINK C
  241. X    includes files OK/Cancel for ok/cancel
  242. Xdeath.c, save.c: delete setmode calls for IBM-PC, instead open files in binary
  243. X    mode
  244. X--------- 10/12
  245. X*: Changed version number to 5.4.
  246. Xsave.c: change code to accept savefiles with version numbers greater than the
  247. X    version number of the game, savefile format frozen as of 5.2.2
  248. Xexterns.h: ifdef out the troublesome sprintf declaration
  249. Xconfig.h: force `unix' to be defined for unix systems, since some stupid
  250. X    systems (e.g. AIX) don't already define it
  251. X--------- 10/15
  252. Xexterns.h, moria4.c, ms_misc.c: correct typos discovered under MSDOS
  253. X--------- 10/19
  254. Xspells.doc, exp.doc: New documentation files.
  255. X--------- 10/26
  256. Xvms/uexit.c, externs.h, io.c, signals.c: Define uexit as void, and ifdef out
  257. X    exit declarations when VMS.
  258. Xvms/moria.opt: add misc[34].obj and moria[34].obj
  259. Xibmpc/ms_misc.c: correct typo in error()
  260. Xpr_items.c, pr_monst.c: main now returns 0
  261. XCONFIG.DOC, TERMCAP, ms_ansi.c: use le/do instead of obsolete bc/xd
  262. Xdragon.inf: moved from util/weapons to doc, and updated it to be accurate
  263. Xspoilers: Update from USENET FAQ posting.
  264. X--------- 11/17
  265. Xio.c: ifdef out code checking for 8 char TABS, because it assumes that the
  266. X    screen is exactly 80 characters wide
  267. Xmoria[12].[ms/txt]: Correct a few typos.
  268. X*: Fix all file permissions.
  269. X::::::: 1992 ::::::::
  270. XMaintenance taken over by David Grabiner
  271. X--------- 7/16
  272. Xmoria4.c: bash(), use random direction if player is confused
  273. Xspells.c: fire_ball(), fire_bolt(), don't update recall if monster not lit;
  274. X    this can happen if bolt hits an invisible monster
  275. Xspells.c: speed_monsters(), sleep_monsters2(), dispel_creature(), 
  276. X    turn_undead(), only affect creatures within MAX_SIGHT 
  277. Xspells.c: mass_poly(), area of effect should be <= MAX_SIGHT, was <
  278. Xspells.c: destroy_area(), remove light from player's spot
  279. Xgenerate.c: build_tunnel(), added code from Richard Wesson to allow
  280. X    tunnel to go through wall that is only two spaces thick,
  281. X    otherwise two adjacent treasure rooms could not be connected
  282. Xspells.c: enchant(), add new variable limit, chance of failure is now
  283. X    (plusses/limit), with very slight chance of success over limit
  284. Xscrolls.c: when enchanting melee weapons to damage, set limit to weapon's
  285. X    maximum damage, otherwise use 10 to give behavior similar to old method
  286. Xmisc2.c: magic_treasure(), make standard deviation of damage bonus on a melee 
  287. X    weapon proportional to weapon's maximum damage; these changes mean
  288. X    that daggers can no longer become powerful weapons
  289. Xtreasure.c: the Zweihander has now become a great weapon, value increased from
  290. X    1000 to 1500
  291. Xexterns.h: fix declaration for enchant()
  292. Xstaffs.c, wands.c: give everyone a slight chance to use difficult wands and
  293. X    staffs, otherwise a warrior will never be able to use many items
  294. X--------- 7/23
  295. Xdeath.c: print_tomb(), insert msg_print(CNIL) so that "You are using:" and
  296. X    "You are carrying:" don't get combined as one message; this made it
  297. X    impossible to see the equipment list
  298. Xstore2.c: haggle_insults(), insert msg_print(CNIL) so that insult is always
  299. X    recognizable
  300. Xstore2.c: purchase_haggle() and sell_haggle(), new variable didnt_haggle,
  301. X    don't call updatebargain if no haggle
  302. Xstore1.c: noneedtobargain(), changed to sliding scale, (good-3*bad) must
  303. X    be more than 5 + (price/50) to skip haggling, so that haggling for
  304. X    cheap items is over quickly, but can still eventually skip
  305. X    haggle for all items
  306. Xstore1.c: updatebargain(), now update for all items worth >9 gold, instead
  307. X    of just 10-999, since it is now possible to skip haggling for more
  308. X    valuable items as well
  309. X--------- 7/25
  310. Xmoria4.c: bash(), unsuccessful bash takes a turn; otherwise, you can
  311. X    attempt to bash in different directions while confused or to locate
  312. X    invisible monsters; eliminate variable no_bash
  313. X--------- 7/27
  314. Xcheck all above changes
  315. Xmoria4.c: bash(), get "You bash at empty space" method when bashing a
  316. X    wall, corrected to "nothing interesting    happens"; this also
  317. X    prevents bashing from locating a secret door
  318. X--------- 8/9
  319. Xmerge in all changes from 5.4.0 to 5.4.1
  320. Xcreature.c: update attack information only if monster is visible; update
  321. X    death information even if monster is not visible, since
  322. X    information will be on tombstone
  323. X*: change version number to 5.5.0
  324. X--------- 8/12
  325. Xspells.c: enchant(), guard against randint(0) if called with limit of 0
  326. X    (it shouldn't be).
  327. Xmoria4.c: throw_object(), py_bash(), don't do negative damage
  328. Xshortnam.sed, spells.c: fire_ball(), fix spelling of "envelops"
  329. Xdoc/faq: remove old spoilers file, and put current FAQ here instead
  330. X*: put my name (DJG) in credits as contact
  331. X*: change copyright date in all source files to 1992
  332. X---------- 8/13
  333. Xrelease umoria 5.5.0
  334. END_OF_FILE
  335. if test 15638 -ne `wc -c <'CHANGES'`; then
  336.     echo shar: \"'CHANGES'\" unpacked with wrong size!
  337. fi
  338. # end of 'CHANGES'
  339. fi
  340. if test -f 'ibmpc/make/makefile.top' -a "${1}" != "-c" ; then 
  341.   echo shar: Will not clobber existing file \"'ibmpc/make/makefile.top'\"
  342. else
  343. echo shar: Extracting \"'ibmpc/make/makefile.top'\" \(1420 characters\)
  344. sed "s/^X//" >'ibmpc/make/makefile.top' <<'END_OF_FILE'
  345. XMODEL =        L
  346. X
  347. XOP =        M
  348. X
  349. XREDIR =        w$(OP)
  350. X
  351. XOPFLAG =    -DMSDOS=1 -DPC_CURSES=1 -DANSI=1
  352. X
  353. XOBJ =        o$(OP)
  354. X
  355. XFLAG =        -A$(MODEL) -Zp -W3 -Os -Gs -Gt32 -I.. $(OPFLAG)
  356. X
  357. XCFLAG =        $(FLAG)
  358. X
  359. XLFLAG =        /STACK:16383 /E $(MODEL)curses
  360. X
  361. XSRC1 =    \
  362. X    ibmpc\ms_ansi.c\
  363. X    ibmpc\ms_misc.c\
  364. X    misc\flock.c\
  365. X    misc\funckeys.c\
  366. X    misc\nomacio.c\
  367. X    source\create.c\
  368. X    source\creature.c\
  369. X    source\death.c\
  370. X    source\desc.c\
  371. X    source\dungeon.c
  372. X
  373. XSRC2 =    \
  374. X    source\eat.c\
  375. X    source\files.c\
  376. X    source\generate.c\
  377. X    source\help.c\
  378. X    source\io.c\
  379. X    source\magic.c\
  380. X    source\main.c\
  381. X    source\misc1.c\
  382. X    source\misc2.c\
  383. X    source\monsters.c
  384. X
  385. XSRC3 =    \
  386. X    source\moria1.c\
  387. X    source\moria2.c\
  388. X    source\potions.c\
  389. X    source\prayer.c\
  390. X    source\recall.c\
  391. X    source\rnd.c\
  392. X    source\save.c\
  393. X    source\scrolls.c\
  394. X    source\sets.c\
  395. X    source\signals.c
  396. X
  397. XSRC4 =    \
  398. X    source\spells.c\
  399. X    source\staffs.c\
  400. X    source\store1.c\
  401. X    source\store2.c\
  402. X    source\treasure.c\
  403. X    source\undef.c\
  404. X    source\variable.c\
  405. X    source\wands.c\
  406. X    source\wizard.c
  407. X
  408. Xtags:    $(SRC1) $(SRC2) $(SRC3) $(SRC4)
  409. X    ctags -o sgat ibmpc\*.c misc\*.c source\*.c
  410. X    sort -u sgat > tags
  411. X    rm -f sgat
  412. X
  413. Xall:
  414. X    cd ibmpc
  415. X    make MODEL=$(MODEL) OP=$(OP) OBJ=$(OBJ) REDIR=$(REDIR) \
  416. X        FLAG="$(FLAG)" ibmpc.mak
  417. X    cd ..\misc
  418. X    make MODEL=$(MODEL) OP=$(OP) OBJ=$(OBJ) REDIR=$(REDIR) \
  419. X        FLAG="$(FLAG)" misc.mak
  420. X    cd ..\source
  421. X    make MODEL=$(MODEL) OP=$(OP) OBJ=$(OBJ) REDIR=$(REDIR) \
  422. X        FLAG="$(FLAG)" source.mak
  423. X    cd ..\$(OBJ)
  424. X    cl $(CFLAG) -Feumoria.exe *.$(OBJ) /link $(LFLAG);
  425. X    cd ..
  426. X
  427. END_OF_FILE
  428. if test 1420 -ne `wc -c <'ibmpc/make/makefile.top'`; then
  429.     echo shar: \"'ibmpc/make/makefile.top'\" unpacked with wrong size!
  430. fi
  431. # end of 'ibmpc/make/makefile.top'
  432. fi
  433. if test -f 'source/io.c' -a "${1}" != "-c" ; then 
  434.   echo shar: Will not clobber existing file \"'source/io.c'\"
  435. else
  436. echo shar: Extracting \"'source/io.c'\" \(35784 characters\)
  437. sed "s/^X//" >'source/io.c' <<'END_OF_FILE'
  438. X/* source/io.c: terminal I/O code, uses the curses package
  439. X
  440. X   Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke
  441. X
  442. X   This software may be copied and distributed for educational, research, and
  443. X   not for profit purposes provided that this copyright and statement are
  444. X   included in all such copies. */
  445. X
  446. X#include <stdio.h>
  447. X#ifndef STDIO_LOADED
  448. X#define STDIO_LOADED
  449. X#endif
  450. X
  451. X#include "config.h"
  452. X
  453. X#if defined(atarist) && defined(__GNUC__)
  454. X#include <osbind.h>
  455. X#endif
  456. X
  457. X#ifdef MSDOS
  458. X#include <process.h>
  459. X#endif
  460. X
  461. X#ifdef AMIGA
  462. X/* detach from cli process */
  463. Xlong _stack = 30000;
  464. Xlong _priority = 0;
  465. Xlong _BackGroundIO = 1;
  466. Xchar *_procname = "Moria";
  467. X#endif
  468. X
  469. X#if defined(NLS) && defined(lint)
  470. X/* for AIX, don't let curses include the NL stuff */
  471. X#undef NLS
  472. X#endif
  473. X
  474. X#if !defined(GEMDOS)
  475. X#ifdef MAC
  476. X#ifdef THINK_C
  477. X#include "ScrnMgr.h"
  478. X#else
  479. X#include <scrnmgr.h>
  480. X#endif
  481. X#else
  482. X#include <curses.h>
  483. X#endif
  484. X#else    /* GEMDOS i.e. Atari ST */
  485. X#include "curses.h"
  486. Xlong wgetch();
  487. X#ifdef ATARIST_TC
  488. X#include <tos.h>    /* TC */
  489. X#include <ext.h>
  490. X#else
  491. X#include <osbind.h>    /* MWC */
  492. X#endif
  493. Xchar *getenv();
  494. X#endif
  495. X
  496. X/* These are included after curses.h to avoid redefintion warnings for
  497. X   TRUE, FALSE, and NULL.  */
  498. X
  499. X#include "constant.h"
  500. X#include "types.h"
  501. X#include "externs.h"
  502. X
  503. X#include <ctype.h>
  504. X
  505. X#if defined(SYS_V) && defined(lint)
  506. X/* for AIX, prevent hundreds of unnecessary lint errors, must define before
  507. X   signal.h is included */
  508. X#define _h_IEEETRAP
  509. Xtypedef struct { int stuff; } fpvmach;
  510. X#endif
  511. X
  512. X#if defined(MSDOS)
  513. X#if defined(ANSI)
  514. X#include "ms_ansi.h"
  515. X#endif
  516. X#else /* not msdos */
  517. X#if !defined(ATARI_ST) && !defined(MAC) && !defined(AMIGA)
  518. X#ifndef VMS
  519. X#include <sys/ioctl.h>
  520. X#endif
  521. X#include <signal.h>
  522. X#endif
  523. X#endif
  524. X
  525. X#ifndef USG
  526. X/* only needed for Berkeley UNIX */
  527. X#include <sys/param.h>
  528. X#include <sys/file.h>
  529. X#include <sys/types.h>
  530. X#endif
  531. X
  532. X#ifdef USG
  533. X#ifndef ATARI_ST
  534. X#include <string.h>
  535. X#else
  536. X#include "string.h"
  537. X#endif
  538. X#if 0
  539. X/* Used to include termio.h here, but that caused problems on some systems,
  540. X   as curses.h includes it also above.  */
  541. X#if !defined(MAC) && !defined(MSDOS) && !defined(ATARI_ST)
  542. X#if !defined(AMIGA) && !defined(VMS)
  543. X#include <termio.h>
  544. X#endif
  545. X#endif
  546. X#endif
  547. X#else /* ! USG */
  548. X#include <strings.h>
  549. X#if defined(atarist) && defined(__GNUC__)
  550. X/* doesn't have sys/wait.h */
  551. X#else
  552. X#include <sys/wait.h>
  553. X#endif
  554. X#endif
  555. X
  556. X#ifdef ATARIST_TC
  557. X/* Include this to get prototypes for standard library functions.  */
  558. X#include <stdlib.h>
  559. X#endif
  560. X
  561. X#if defined(SYS_V) && defined(lint)
  562. Xstruct screen { int dumb; };
  563. X#endif
  564. X
  565. X/* Fooling lint. Unfortunately, c defines all the TIO.      -CJS-
  566. X   constants to be long, and lint expects them to be int. Also,
  567. X   ioctl is sometimes called with just two arguments. The
  568. X   following definition keeps lint happy. It may need to be
  569. X   reset for different systems.     */
  570. X#ifndef MAC
  571. X#ifdef lint
  572. X#ifdef Pyramid
  573. X/* Pyramid makes constants greater than 65535 into long! Gakk! -CJS- */
  574. X/*ARGSUSED*/
  575. X/*VARARGS2*/
  576. Xstatic Ioctl(i, l, p) long l; char *p; { return 0; }
  577. X#else
  578. X/*ARGSUSED*/
  579. X/*VARARGS2*/
  580. Xstatic Ioctl(i, l, p) char *p; { return 0; }
  581. X#endif
  582. X#define ioctl        Ioctl
  583. X#endif
  584. X
  585. X#if !defined(USG) && defined(lint)
  586. X/* This use_value hack is for curses macros which return a value,
  587. X   but don't shut up about it when you try to tell them (void).     */
  588. X/* only needed for Berkeley UNIX */
  589. Xint Use_value;
  590. X#define use_value   Use_value +=
  591. X#else
  592. X#define use_value
  593. X#endif
  594. X
  595. X#if defined(SYS_V) && defined(lint)
  596. X/* This use_value2 hack is for curses macros which use a conditional
  597. X   expression, and which say null effect even if you cast to (void). */
  598. X/* only needed for SYS V */
  599. Xint Use_value2;
  600. X#define use_value2  Use_value2 +=
  601. X#else
  602. X#define use_value2
  603. X#endif
  604. X
  605. X#endif
  606. X
  607. X#ifndef MAC
  608. Xchar *getenv();
  609. X#endif
  610. X
  611. X#ifndef VMS
  612. X#ifdef USG
  613. Xvoid exit();
  614. X#if defined(__TURBOC__)
  615. Xvoid sleep();
  616. X#else
  617. X#ifndef AMIGA
  618. Xunsigned sleep();
  619. X#endif
  620. X#endif
  621. X#endif
  622. X#endif
  623. X
  624. X#ifdef ultrix
  625. Xvoid exit();
  626. Xvoid sleep();
  627. X#endif
  628. X
  629. X#if !defined(MAC) && !defined(MSDOS) && !defined(ATARI_ST) && !defined(VMS)
  630. X#ifndef AMIGA
  631. X#ifdef USG
  632. Xstatic struct termio save_termio;
  633. X#else
  634. Xstatic struct ltchars save_special_chars;
  635. Xstatic struct sgttyb save_ttyb;
  636. Xstatic struct tchars save_tchars;
  637. Xstatic int save_local_chars;
  638. X#endif
  639. X#endif
  640. X#endif
  641. X
  642. X#ifndef MAC
  643. Xstatic int curses_on = FALSE;
  644. Xstatic WINDOW *savescr;        /* Spare window for saving the screen. -CJS-*/
  645. X#ifdef VMS
  646. Xstatic WINDOW *tempscr;        /* Spare window for VMS CTRL('R'). */
  647. X#endif
  648. X#endif
  649. X
  650. X#ifdef MAC
  651. X/* Attributes of normal and hilighted characters */
  652. X#define ATTR_NORMAL    attrNormal
  653. X#define ATTR_HILITED    attrReversed
  654. X#endif
  655. X
  656. X#ifndef MAC
  657. X#ifdef SIGTSTP
  658. X/* suspend()                               -CJS-
  659. X   Handle the stop and start signals. This ensures that the log
  660. X   is up to date, and that the terminal is fully reset and
  661. X   restored.  */
  662. Xint suspend()
  663. X{
  664. X#ifdef USG
  665. X  /* for USG systems with BSDisms that have SIGTSTP defined, but don't
  666. X     actually implement it */
  667. X#else
  668. X  struct sgttyb tbuf;
  669. X  struct ltchars lcbuf;
  670. X  struct tchars cbuf;
  671. X  int lbuf;
  672. X  long time();
  673. X
  674. X  py.misc.male |= 2;
  675. X  (void) ioctl(0, TIOCGETP, (char *)&tbuf);
  676. X  (void) ioctl(0, TIOCGETC, (char *)&cbuf);
  677. X  (void) ioctl(0, TIOCGLTC, (char *)&lcbuf);
  678. X#if !defined(atarist) && !defined(__GNUC__)
  679. X  (void) ioctl(0, TIOCLGET, (char *)&lbuf);
  680. X#endif
  681. X  restore_term();
  682. X  (void) kill(0, SIGSTOP);
  683. X  curses_on = TRUE;
  684. X  (void) ioctl(0, TIOCSETP, (char *)&tbuf);
  685. X  (void) ioctl(0, TIOCSETC, (char *)&cbuf);
  686. X  (void) ioctl(0, TIOCSLTC, (char *)&lcbuf);
  687. X#if !defined(atarist) && !defined(__GNUC__)
  688. X  (void) ioctl(0, TIOCLSET, (char *)&lbuf);
  689. X#endif
  690. X  (void) wrefresh(curscr);
  691. X  py.misc.male &= ~2;
  692. X#endif
  693. X  return 0;
  694. X}
  695. X#endif
  696. X#endif
  697. X
  698. X/* initializes curses routines */
  699. Xvoid init_curses()
  700. X#ifdef MAC
  701. X{
  702. X  /* Primary initialization is done in mac.c since game is restartable */
  703. X  /* Only need to clear the screen here */
  704. X  Rect scrn;
  705. X
  706. X  scrn.left = scrn.top = 0;
  707. X  scrn.right = SCRN_COLS;
  708. X  scrn.bottom = SCRN_ROWS;
  709. X  EraseScreen(&scrn);
  710. X  UpdateScreen();
  711. X}
  712. X#else
  713. X{
  714. X  int i, y, x;
  715. X
  716. X#ifdef AMIGA
  717. X  if (opentimer() == 0)
  718. X    {
  719. X      (void) printf ("Could not open timer device.\n");
  720. X      exit (1);
  721. X    }
  722. X#endif
  723. X
  724. X#ifndef USG
  725. X  (void) ioctl(0, TIOCGLTC, (char *)&save_special_chars);
  726. X  (void) ioctl(0, TIOCGETP, (char *)&save_ttyb);
  727. X  (void) ioctl(0, TIOCGETC, (char *)&save_tchars);
  728. X#if !defined(atarist) && !defined(__GNUC__)
  729. X  (void) ioctl(0, TIOCLGET, (char *)&save_local_chars);
  730. X#endif
  731. X#else
  732. X#if !defined(VMS) && !defined(MSDOS) && !defined(ATARI_ST)
  733. X#ifndef AMIGA
  734. X  (void) ioctl(0, TCGETA, (char *)&save_termio);
  735. X#endif
  736. X#endif
  737. X#endif
  738. X
  739. X  /* PC curses returns ERR */
  740. X#if defined(USG) && !defined(PC_CURSES) && !defined(AMIGA)
  741. X  if (initscr() == NULL)
  742. X#else
  743. X  if (initscr() == ERR)
  744. X#endif
  745. X    {
  746. X      (void) printf("Error allocating screen in curses package.\n");
  747. X      exit(1);
  748. X    }
  749. X  if (LINES < 24 || COLS < 80)     /* Check we have enough screen. -CJS- */
  750. X    {
  751. X      (void) printf("Screen too small for moria.\n");
  752. X      exit (1);
  753. X    }
  754. X#ifdef SIGTSTP
  755. X#if defined(atarist) && defined(__GNUC__)
  756. X  (void) signal (SIGTSTP, (__Sigfunc)suspend);
  757. X#else
  758. X  (void) signal (SIGTSTP, suspend);
  759. X#endif
  760. X#endif
  761. X  if (((savescr = newwin (0, 0, 0, 0)) == NULL)
  762. X#ifdef VMS
  763. X      || ((tempscr = newwin (0, 0, 0, 0)) == NULL))
  764. X#else
  765. X    )
  766. X#endif
  767. X    {
  768. X      (void) printf ("Out of memory in starting up curses.\n");
  769. X      exit_game();
  770. X    }
  771. X  (void) clear();
  772. X  (void) refresh();
  773. X  moriaterm ();
  774. X
  775. X#if 0
  776. X  /* This assumes that the terminal is 80 characters wide, which is not
  777. X     guaranteed to be true.  */
  778. X
  779. X  /* check tab settings, exit with error if they are not 8 spaces apart */
  780. X  (void) move(0, 0);
  781. X  for (i = 1; i < 10; i++)
  782. X    {
  783. X      (void) addch('\t');
  784. X      getyx(stdscr, y, x);
  785. X      if (y != 0 || x != i*8)
  786. X    break;
  787. X    }
  788. X  if (i != 10)
  789. X    {
  790. X      msg_print("Tabs must be set 8 spaces apart.");
  791. X      exit_game();
  792. X    }
  793. X#endif
  794. X}
  795. X#endif
  796. X
  797. X/* Set up the terminal into a suitable state for moria.     -CJS- */
  798. Xvoid moriaterm()
  799. X#ifdef MAC
  800. X/* Nothing to do on Mac */
  801. X{
  802. X}
  803. X#else
  804. X{
  805. X#if !defined(MSDOS) && !defined(ATARI_ST) && !defined(VMS)
  806. X#ifndef AMIGA
  807. X#ifdef USG
  808. X  struct termio tbuf;
  809. X#else
  810. X  struct ltchars lbuf;
  811. X  struct tchars buf;
  812. X#endif
  813. X#endif
  814. X#endif
  815. X
  816. X  curses_on = TRUE;
  817. X#ifndef BSD4_3
  818. X  use_value crmode();
  819. X#else
  820. X#ifdef VMS
  821. X  use_value vms_crmode ();
  822. X#else
  823. X  use_value cbreak();
  824. X#endif
  825. X#endif
  826. X  use_value noecho();
  827. X  /* can not use nonl(), because some curses do not handle it correctly */
  828. X#ifdef MSDOS
  829. X  msdos_raw();
  830. X#else
  831. X#ifdef AMIGA
  832. X  init_color (0,   0,   0,   0);    /* pen 0 - black */
  833. X  init_color (1,1000,1000,1000);    /* pen 1 - white */
  834. X  init_color (2,   0, 300, 700);    /* pen 2 - blue */
  835. X  init_color (3,1000, 500,   0);    /* pen 3 - orange */
  836. X#else
  837. X#if !defined(ATARI_ST) && !defined(VMS)
  838. X#ifdef USG
  839. X  (void) ioctl(0, TCGETA, (char *)&tbuf);
  840. X  /* disable all of the normal special control characters */
  841. X  tbuf.c_cc[VINTR] = (char)3; /* control-C */
  842. X  tbuf.c_cc[VQUIT] = (char)-1;
  843. X  tbuf.c_cc[VERASE] = (char)-1;
  844. X  tbuf.c_cc[VKILL] = (char)-1;
  845. X  tbuf.c_cc[VEOF] = (char)-1;
  846. X
  847. X  /* don't know what these are for */
  848. X  tbuf.c_cc[VEOL] = (char)-1;
  849. X#ifdef VEOL2
  850. X  tbuf.c_cc[VEOL2] = (char)-1;
  851. X#endif
  852. X
  853. X  /* stuff needed when !icanon, i.e. cbreak/raw mode */
  854. X  tbuf.c_cc[VMIN] = 1;  /* Input should wait for at least 1 char */
  855. X  tbuf.c_cc[VTIME] = 0; /* no matter how long that takes. */
  856. X
  857. X  (void) ioctl(0, TCSETA, (char *)&tbuf);
  858. X#else
  859. X  /* disable all of the special characters except the suspend char, interrupt
  860. X     char, and the control flow start/stop characters */
  861. X  (void) ioctl(0, TIOCGLTC, (char *)&lbuf);
  862. X  lbuf.t_suspc = (char)26; /* control-Z */
  863. X  lbuf.t_dsuspc = (char)-1;
  864. X  lbuf.t_rprntc = (char)-1;
  865. X  lbuf.t_flushc = (char)-1;
  866. X  lbuf.t_werasc = (char)-1;
  867. X  lbuf.t_lnextc = (char)-1;
  868. X  (void) ioctl(0, TIOCSLTC, (char *)&lbuf);
  869. X
  870. X  (void) ioctl (0, TIOCGETC, (char *)&buf);
  871. X  buf.t_intrc = (char)3; /* control-C */
  872. X  buf.t_quitc = (char)-1;
  873. X  buf.t_startc = (char)17; /* control-Q */
  874. X  buf.t_stopc = (char)19; /* control-S */
  875. X  buf.t_eofc = (char)-1;
  876. X  buf.t_brkc = (char)-1;
  877. X  (void) ioctl(0, TIOCSETC, (char *)&buf);
  878. X#endif
  879. X#endif
  880. X#endif
  881. X#endif
  882. X
  883. X#ifdef ATARIST_TC
  884. X  raw ();
  885. X#endif
  886. X}
  887. X#endif
  888. X
  889. X
  890. X/* Dump IO to buffer                    -RAK-    */
  891. Xvoid put_buffer(out_str, row, col)
  892. Xchar *out_str;
  893. Xint row, col;
  894. X#ifdef MAC
  895. X{
  896. X  /* The screen manager handles writes past the edge ok */
  897. X  DSetScreenCursor(col, row);
  898. X  DWriteScreenStringAttr(out_str, ATTR_NORMAL);
  899. X}
  900. X#else
  901. X{
  902. X  vtype tmp_str;
  903. X
  904. X  /* truncate the string, to make sure that it won't go past right edge of
  905. X     screen */
  906. X  if (col > 79)
  907. X    col = 79;
  908. X  (void) strncpy (tmp_str, out_str, 79 - col);
  909. X  tmp_str [79 - col] = '\0';
  910. X
  911. X  if (mvaddstr(row, col, tmp_str) == ERR)
  912. X    {
  913. X      abort();
  914. X      /* clear msg_flag to avoid problems with unflushed messages */
  915. X      msg_flag = 0;
  916. X      (void) sprintf(tmp_str, "error in put_buffer, row = %d col = %d\n",
  917. X             row, col);
  918. X      prt(tmp_str, 0, 0);
  919. X      bell();
  920. X      /* wait so user can see error */
  921. X      (void) sleep(2);
  922. X    }
  923. X}
  924. X#endif
  925. X
  926. X
  927. X/* Dump the IO buffer to terminal            -RAK-    */
  928. Xvoid put_qio()
  929. X{
  930. X  screen_change = TRUE;       /* Let inven_command know something has changed. */
  931. X#ifdef MAC
  932. X  UpdateScreen();
  933. X#else
  934. X  (void) refresh();
  935. X#endif
  936. X}
  937. X
  938. X/* Put the terminal in the original mode.               -CJS- */
  939. Xvoid restore_term()
  940. X#ifdef MAC
  941. X/* Nothing to do on Mac */
  942. X{
  943. X}
  944. X#else
  945. X{
  946. X#ifdef AMIGA
  947. X  closetimer ();
  948. X#endif
  949. X
  950. X  if (!curses_on)
  951. X    return;
  952. X  put_qio();  /* Dump any remaining buffer */
  953. X#ifdef MSDOS
  954. X  (void) sleep(2);   /* And let it be read. */
  955. X#endif
  956. X#ifdef VMS
  957. X  clear_screen();
  958. X  pause_line(15);
  959. X#endif
  960. X  /* this moves curses to bottom right corner */
  961. X  mvcur(stdscr->_cury, stdscr->_curx, LINES-1, 0);
  962. X  endwin();  /* exit curses */
  963. X  (void) fflush (stdout);
  964. X#ifdef MSDOS
  965. X  msdos_noraw();
  966. X#endif
  967. X  /* restore the saved values of the special chars */
  968. X#ifdef USG
  969. X#if !defined(MSDOS) && !defined(ATARI_ST) && !defined(VMS)
  970. X#ifndef AMIGA
  971. X  (void) ioctl(0, TCSETA, (char *)&save_termio);
  972. X#endif
  973. X#endif
  974. X#else
  975. X  (void) ioctl(0, TIOCSLTC, (char *)&save_special_chars);
  976. X  (void) ioctl(0, TIOCSETP, (char *)&save_ttyb);
  977. X  (void) ioctl(0, TIOCSETC, (char *)&save_tchars);
  978. X#if !defined(atarist) && !defined(__GNUC__)
  979. X  (void) ioctl(0, TIOCLSET, (char *)&save_local_chars);
  980. X#endif
  981. X#endif
  982. X  curses_on = FALSE;
  983. X}
  984. X#endif
  985. X
  986. X
  987. Xvoid shell_out()
  988. X#if defined(atarist) && defined(__GNUC__)
  989. X{ char fail_message[80], arg_list[1], *p;
  990. X  int  escape_code;
  991. X
  992. X  save_screen();
  993. X  clear_screen();
  994. X  use_value nocbreak();         /* Must remember to reset terminal modes   */
  995. X  use_value echo();             /* or shell i/o will be quite messed up!   */
  996. X
  997. X  p = (char *)getenv("SHELL");
  998. X  if (p != (char *)NULL)
  999. X    { put_buffer("Escaping to Shell\n",0,0);
  1000. X      put_qio();
  1001. X      arg_list[0]=0;
  1002. X      escape_code = Pexec(0,p,arg_list,0);   /* Launch the shell.          */
  1003. X
  1004. X      if (escape_code != 0)
  1005. X         { sprintf(fail_message,"Pexec() error code = %d\n",escape_code);
  1006. X           put_buffer(fail_message,0,0);
  1007. X           put_qio();
  1008. X       sleep(5);
  1009. X     }
  1010. X    }
  1011. X  use_value cbreak();        /* Reset the terminal back to CBREAK/NOECHO   */
  1012. X  use_value noecho();
  1013. X  clear_screen();            /* Do not want shell data on screen.          */
  1014. X  restore_screen();
  1015. X}
  1016. X
  1017. X#else
  1018. X
  1019. X#ifdef MAC
  1020. X{
  1021. X  alert_error("This command is not implemented on the Macintosh.");
  1022. X}
  1023. X#else
  1024. X#if defined(AMIGA) || defined(ATARIST_TC)
  1025. X{
  1026. X  put_buffer("This command is not implemented.\n", 0, 0);
  1027. X}
  1028. X#else
  1029. X#ifdef VMS /* TPP */
  1030. X{
  1031. X  int val, istat;
  1032. X  char *str;
  1033. X
  1034. X  save_screen();
  1035. X  /* clear screen and print 'exit' message */
  1036. X  clear_screen();
  1037. X  put_buffer("[Entering subprocess, type 'EOJ' to resume your game.]\n",
  1038. X         0, 0);
  1039. X  put_qio();
  1040. X
  1041. X  use_value vms_nocrmode();
  1042. X  use_value echo();
  1043. X  ignore_signals();
  1044. X
  1045. X  istat = lib$spawn();
  1046. X  if (!istat)
  1047. X    lib$signal (istat);
  1048. X
  1049. X  restore_signals();
  1050. X  use_value vms_crmode();
  1051. X  use_value noecho();
  1052. X  /* restore the cave to the screen */
  1053. X  restore_screen();
  1054. X  put_buffer("Welcome back to UMoria.\n", 0, 0);
  1055. X  save_screen();
  1056. X  clear_screen();
  1057. X  put_qio();
  1058. X  restore_screen();
  1059. X  (void) wrefresh(curscr);
  1060. X}
  1061. X#else
  1062. X{
  1063. X#ifdef USG
  1064. X#if !defined(MSDOS) && !defined(ATARI_ST) && !defined(AMIGA)
  1065. X  struct termio tbuf;
  1066. X#endif
  1067. X#else
  1068. X  struct sgttyb tbuf;
  1069. X  struct ltchars lcbuf;
  1070. X  struct tchars cbuf;
  1071. X  int lbuf;
  1072. X#endif
  1073. X#ifdef MSDOS
  1074. X  char    *comspec, key;
  1075. X#else
  1076. X#ifdef ATARI_ST
  1077. X  char comstr[80];
  1078. X  char *str;
  1079. X  extern char **environ;
  1080. X#else
  1081. X  int val;
  1082. X  char *str;
  1083. X#endif
  1084. X#endif
  1085. X
  1086. X  save_screen();
  1087. X  /* clear screen and print 'exit' message */
  1088. X  clear_screen();
  1089. X#ifndef ATARI_ST
  1090. X  put_buffer("[Entering shell, type 'exit' to resume your game.]\n",0,0);
  1091. X#else
  1092. X  put_buffer("[Escaping to shell]\n",0,0);
  1093. X#endif
  1094. X  put_qio();
  1095. X
  1096. X#ifdef USG
  1097. X#if !defined(MSDOS) && !defined(ATARI_ST) && !defined(AMIGA)
  1098. X  (void) ioctl(0, TCGETA, (char *)&tbuf);
  1099. X#endif
  1100. X#else
  1101. X  (void) ioctl(0, TIOCGETP, (char *)&tbuf);
  1102. X  (void) ioctl(0, TIOCGETC, (char *)&cbuf);
  1103. X  (void) ioctl(0, TIOCGLTC, (char *)&lcbuf);
  1104. X  (void) ioctl(0, TIOCLGET, (char *)&lbuf);
  1105. X#endif
  1106. X  /* would call nl() here if could use nl()/nonl(), see moriaterm() */
  1107. X#ifndef BSD4_3
  1108. X  use_value nocrmode();
  1109. X#else
  1110. X#ifdef VMS
  1111. X  use_value vms_nocrmode ();
  1112. X#else
  1113. X  use_value nocbreak();
  1114. X#endif
  1115. X#endif
  1116. X#ifdef MSDOS
  1117. X  use_value msdos_noraw();
  1118. X#endif
  1119. X  use_value echo();
  1120. X  ignore_signals();
  1121. X#ifdef MSDOS        /*{*/
  1122. X  if ((comspec = getenv("COMSPEC")) == CNIL
  1123. X  ||  spawnl(P_WAIT, comspec, comspec, CNIL) < 0) {
  1124. X    clear_screen();    /* BOSS key if shell failed */
  1125. X    put_buffer("M:\\> ", 0, 0);
  1126. X    do {
  1127. X      key = inkey();
  1128. X    } while (key != '!');
  1129. X  }
  1130. X
  1131. X#else        /* MSDOS }{*/
  1132. X#ifndef ATARI_ST
  1133. X  val = fork();
  1134. X  if (val == 0)
  1135. X    {
  1136. X#endif
  1137. X      default_signals();
  1138. X#ifdef USG
  1139. X#if !defined(MSDOS) && !defined(ATARI_ST) && !defined(AMIGA)
  1140. X      (void) ioctl(0, TCSETA, (char *)&save_termio);
  1141. X#endif
  1142. X#else
  1143. X      (void) ioctl(0, TIOCSLTC, (char *)&save_special_chars);
  1144. X      (void) ioctl(0, TIOCSETP, (char *)&save_ttyb);
  1145. X      (void) ioctl(0, TIOCSETC, (char *)&save_tchars);
  1146. X      (void) ioctl(0, TIOCLSET, (char *)&save_local_chars);
  1147. X#endif
  1148. X#ifndef MSDOS
  1149. X      /* close scoreboard descriptor */
  1150. X      /* it is not open on MSDOS machines */
  1151. X      (void) fclose(highscore_fp);
  1152. X#endif
  1153. X      if (str = getenv("SHELL"))
  1154. X#ifndef ATARI_ST
  1155. X    (void) execl(str, str, (char *) 0);
  1156. X#else
  1157. X    system(str);
  1158. X#endif
  1159. X      else
  1160. X#ifndef ATARI_ST
  1161. X    (void) execl("/bin/sh", "sh", (char *) 0);
  1162. X#endif
  1163. X      msg_print("Cannot execute shell.");
  1164. X#ifndef ATARI_ST
  1165. X      exit(1);
  1166. X    }
  1167. X  if (val == -1)
  1168. X    {
  1169. X      msg_print("Fork failed. Try again.");
  1170. X      return;
  1171. X    }
  1172. X#ifdef USG
  1173. X  (void) wait((int *) 0);
  1174. X#else
  1175. X  (void) wait((union wait *) 0);
  1176. X#endif
  1177. X#endif /* ATARI_ST */
  1178. X#endif         /* MSDOS }*/
  1179. X  restore_signals();
  1180. X  /* restore the cave to the screen */
  1181. X  restore_screen();
  1182. X#ifndef BSD4_3
  1183. X  use_value crmode();
  1184. X#else
  1185. X#ifdef VMS
  1186. X  use_value vms_crmode ();
  1187. X#else
  1188. X  use_value cbreak();
  1189. X#endif
  1190. X#endif
  1191. X  use_value noecho();
  1192. X  /* would call nonl() here if could use nl()/nonl(), see moriaterm() */
  1193. X#ifdef MSDOS
  1194. X  msdos_raw();
  1195. X#endif
  1196. X  /* disable all of the local special characters except the suspend char */
  1197. X  /* have to disable ^Y for tunneling */
  1198. X#ifdef USG
  1199. X#if !defined(MSDOS) && !defined(ATARI_ST)
  1200. X  (void) ioctl(0, TCSETA, (char *)&tbuf);
  1201. X#endif
  1202. X#else
  1203. X  (void) ioctl(0, TIOCSLTC, (char *)&lcbuf);
  1204. X  (void) ioctl(0, TIOCSETP, (char *)&tbuf);
  1205. X  (void) ioctl(0, TIOCSETC, (char *)&cbuf);
  1206. X  (void) ioctl(0, TIOCLSET, (char *)&lbuf);
  1207. X#endif
  1208. X  (void) wrefresh(curscr);
  1209. X}
  1210. X#endif
  1211. X#endif
  1212. X#endif
  1213. X#endif
  1214. X
  1215. X/* Returns a single character input from the terminal.    This silently -CJS-
  1216. X   consumes ^R to redraw the screen and reset the terminal, so that this
  1217. X   operation can always be performed at any input prompt.  inkey() never
  1218. X   returns ^R.    */
  1219. Xchar inkey()
  1220. X#ifdef MAC
  1221. X/* The Mac does not need ^R, so it just consumes it */
  1222. X/* This routine does nothing special with direction keys */
  1223. X/* Just returns their keypad ascii value (e.g. '0'-'9') */
  1224. X/* Compare with inkeydir() below */
  1225. X{
  1226. X  char ch;
  1227. X  int dir;
  1228. X  int shift_flag, ctrl_flag;
  1229. X
  1230. X  put_qio();
  1231. X  command_count = 0;
  1232. X
  1233. X  do {
  1234. X    macgetkey(&ch, FALSE);
  1235. X  } while (ch == CTRL('R'));
  1236. X
  1237. X  dir = extractdir(ch, &shift_flag, &ctrl_flag);
  1238. X  if (dir != -1)
  1239. X    ch = '0' + dir;
  1240. X
  1241. X  return(ch);
  1242. X}
  1243. X#else
  1244. X{
  1245. X  int i;
  1246. X#ifdef VMS
  1247. X  vtype tmp_str;
  1248. X#endif
  1249. X
  1250. X  put_qio();            /* Dump IO buffer        */
  1251. X  command_count = 0;  /* Just to be safe -CJS- */
  1252. X  while (TRUE)
  1253. X    {
  1254. X#ifdef MSDOS
  1255. X      i = msdos_getch();
  1256. X#else
  1257. X#ifdef VMS
  1258. X      i = vms_getch ();
  1259. X#else
  1260. X      i = getch();
  1261. X#if defined(atarist) && defined(__GNUC__)
  1262. X/* for some reason a keypad number produces an initial negative number. */
  1263. X      if (i<0) i = getch();
  1264. X#endif
  1265. X#endif
  1266. X#endif
  1267. X
  1268. X#ifdef VMS
  1269. X      if (i == 27) /* if ESCAPE key, then we probably have a keypad key */
  1270. X    {
  1271. X      i = vms_getch();
  1272. X      if (i == 'O') /* Now it is definitely a numeric keypad key */
  1273. X        {
  1274. X          i = vms_getch();
  1275. X          switch (i)
  1276. X        {
  1277. X          case 'p': i = '0'; break;
  1278. X          case 'q' : i = '1'; break;
  1279. X          case 'r' : i = '2'; break;
  1280. X          case 's' : i = '3'; break;
  1281. X          case 't' : i = '4'; break;
  1282. X          case 'u' : i = '5'; break;
  1283. X          case 'v' : i = '6'; break;
  1284. X          case 'w' : i = '7'; break;
  1285. X          case 'x' : i = '8'; break;
  1286. X          case 'y' : i = '9'; break;
  1287. X          case 'm' : i = '-'; break;
  1288. X          case 'M' : i = 10; break; /* Enter = RETURN */
  1289. X          case 'n' : i = '.'; break;
  1290. X          default : while (kbhit()) (void) vms_getch();
  1291. X          }
  1292. X        }
  1293. X      else
  1294. X        {
  1295. X          while (kbhit())
  1296. X        (void) vms_getch();
  1297. X        }
  1298. X    }
  1299. X#endif /* VMS */
  1300. X
  1301. X      /* some machines may not sign extend. */
  1302. X      if (i == EOF)
  1303. X    {
  1304. X      eof_flag++;
  1305. X      /* avoid infinite loops while trying to call inkey() for a -more-
  1306. X         prompt. */
  1307. X      msg_flag = FALSE;
  1308. X
  1309. X      (void) refresh ();
  1310. X      if (!character_generated || character_saved)
  1311. X        exit_game();
  1312. X      disturb(1, 0);
  1313. X      if (eof_flag > 100)
  1314. X        {
  1315. X          /* just in case, to make sure that the process eventually dies */
  1316. X          panic_save = 1;
  1317. X          (void) strcpy(died_from, "(end of input: panic saved)");
  1318. X          if (!save_char())
  1319. X        {
  1320. X          (void) strcpy(died_from, "panic: unexpected eof");
  1321. X          death = TRUE;
  1322. X        }
  1323. X          exit_game();
  1324. X        }
  1325. X      return ESCAPE;
  1326. X    }
  1327. X      if (i != CTRL('R'))
  1328. X    return (char)i;
  1329. X#ifdef VMS
  1330. X      /* Refresh does not work right under VMS, so use a brute force. */
  1331. X      overwrite (stdscr, tempscr);
  1332. X      clear_screen();
  1333. X      put_qio();
  1334. X      overwrite (tempscr, stdscr);
  1335. X      touchwin (stdscr);
  1336. X      (void) wrefresh (stdscr);
  1337. X#endif
  1338. X      (void) wrefresh (curscr);
  1339. X      moriaterm();
  1340. X    }
  1341. X}
  1342. X#endif
  1343. X
  1344. X
  1345. X#ifdef MAC
  1346. Xchar inkeydir()
  1347. X/* The Mac does not need ^R, so it just consumes it */
  1348. X/* This routine translates the direction keys in rogue-like mode */
  1349. X/* Compare with inkeydir() below */
  1350. X{
  1351. X  char ch;
  1352. X  int dir;
  1353. X  int shift_flag, ctrl_flag;
  1354. X  static char tab[9] = {
  1355. X    'b',        'j',        'n',
  1356. X    'h',        '.',        'l',
  1357. X    'y',        'k',        'u'
  1358. X  };
  1359. X  static char shifttab[9] = {
  1360. X    'B',        'J',        'N',
  1361. X    'H',        '.',        'L',
  1362. X    'Y',        'K',        'U'
  1363. X  };
  1364. X  static char ctrltab[9] = {
  1365. X    CTRL('B'),    CTRL('J'),    CTRL('N'),
  1366. X    CTRL('H'),    '.',        CTRL('L'),
  1367. X    CTRL('Y'),    CTRL('K'),    CTRL('U')
  1368. X  };
  1369. X
  1370. X  put_qio();
  1371. X  command_count = 0;
  1372. X
  1373. X  do {
  1374. X    macgetkey(&ch, FALSE);
  1375. X  } while (ch == CTRL('R'));
  1376. X
  1377. X  dir = extractdir(ch, &shift_flag, &ctrl_flag);
  1378. X
  1379. X  if (dir != -1) {
  1380. X    if (!rogue_like_commands) {
  1381. X      ch = '0' + dir;
  1382. X    }
  1383. X    else {
  1384. X      if (ctrl_flag)
  1385. X    ch = ctrltab[dir - 1];
  1386. X      else if (shift_flag)
  1387. X    ch = shifttab[dir - 1];
  1388. X      else
  1389. X    ch = tab[dir - 1];
  1390. X    }
  1391. X  }
  1392. X
  1393. X  return(ch);
  1394. X}
  1395. X#endif
  1396. X
  1397. X
  1398. X/* Flush the buffer                    -RAK-    */
  1399. Xvoid flush()
  1400. X#ifdef MAC
  1401. X{
  1402. X/* Removed put_qio() call.  Reduces flashing.  Doesn't seem to hurt. */
  1403. X  FlushScreenKeys();
  1404. X}
  1405. X#else
  1406. X{
  1407. X#if defined(MSDOS)
  1408. X  while (kbhit())
  1409. X    (void) getch();
  1410. X#else
  1411. X#ifdef VMS
  1412. X  while (kbhit ())
  1413. X    (void) vms_getch();
  1414. X#else
  1415. X  /* the code originally used ioctls, TIOCDRAIN, or TIOCGETP/TIOCSETP, or
  1416. X     TCGETA/TCSETAF, however this occasionally resulted in loss of output,
  1417. X     the happened especially often when rlogin from BSD to SYS_V machine,
  1418. X     using check_input makes the desired effect a bit clearer */
  1419. X  /* wierd things happen on EOF, don't try to flush input in that case */
  1420. X  if (!eof_flag)
  1421. X    while (check_input(0));
  1422. X#endif
  1423. X#endif
  1424. X
  1425. X  /* used to call put_qio() here to drain output, but it is not necessary */
  1426. X}
  1427. X#endif
  1428. X
  1429. X
  1430. X/* Clears given line of text                -RAK-    */
  1431. Xvoid erase_line(row, col)
  1432. Xint row;
  1433. Xint col;
  1434. X#ifdef MAC
  1435. X{
  1436. X  Rect line;
  1437. X
  1438. X  if (row == MSG_LINE && msg_flag)
  1439. X    msg_print(CNIL);
  1440. X
  1441. X  line.left = col;
  1442. X  line.top = row;
  1443. X  line.right = SCRN_COLS;
  1444. X  line.bottom = row + 1;
  1445. X  DEraseScreen(&line);
  1446. X}
  1447. X#else
  1448. X{
  1449. X  if (row == MSG_LINE && msg_flag)
  1450. X    msg_print(CNIL);
  1451. X  (void) move(row, col);
  1452. X  clrtoeol();
  1453. X}
  1454. X#endif
  1455. X
  1456. X
  1457. X/* Clears screen */
  1458. Xvoid clear_screen()
  1459. X#ifdef MAC
  1460. X{
  1461. X  Rect area;
  1462. X
  1463. X  if (msg_flag)
  1464. X    msg_print(CNIL);
  1465. X
  1466. X  area.left = area.top = 0;
  1467. X  area.right = SCRN_COLS;
  1468. X  area.bottom = SCRN_ROWS;
  1469. X  DEraseScreen(&area);
  1470. X}
  1471. X#else
  1472. X{
  1473. X  if (msg_flag)
  1474. X    msg_print(CNIL);
  1475. X#ifdef VMS
  1476. X  /* Clear doesn't work right under VMS, so use brute force. */
  1477. X  (void) clearok (stdscr, TRUE);
  1478. X  (void) wclear(stdscr);
  1479. X  (void) clearok (stdscr, FALSE);
  1480. X#else
  1481. X  (void) clear();
  1482. X#endif
  1483. X}
  1484. X#endif
  1485. X
  1486. Xvoid clear_from (row)
  1487. Xint row;
  1488. X#ifdef MAC
  1489. X{
  1490. X  Rect area;
  1491. X
  1492. X  area.left = 0;
  1493. X  area.top = row;
  1494. X  area.right = SCRN_COLS;
  1495. X  area.bottom = SCRN_ROWS;
  1496. X  DEraseScreen(&area);
  1497. X}
  1498. X#else
  1499. X{
  1500. X  (void) move(row, 0);
  1501. X  clrtobot();
  1502. X}
  1503. X#endif
  1504. X
  1505. X
  1506. X/* Outputs a char to a given interpolated y, x position    -RAK-    */
  1507. X/* sign bit of a character used to indicate standout mode. -CJS */
  1508. Xvoid print(ch, row, col)
  1509. Xchar ch;
  1510. Xint row;
  1511. Xint col;
  1512. X#ifdef MAC
  1513. X{
  1514. X  char cnow, anow;
  1515. X
  1516. X  row -= panel_row_prt;/* Real co-ords convert to screen positions */
  1517. X  col -= panel_col_prt;
  1518. X
  1519. X  GetScreenCharAttr(&cnow, &anow, col, row);    /* Check current */
  1520. X
  1521. X  /* If char is already set, ignore op */
  1522. X  if ((cnow != ch) || (anow != ATTR_NORMAL))
  1523. X    DSetScreenCharAttr(ch & 0x7F,
  1524. X               (ch & 0x80) ? attrReversed : attrNormal,
  1525. X               col, row);
  1526. X}
  1527. X#else
  1528. X{
  1529. X  vtype tmp_str;
  1530. X
  1531. X  row -= panel_row_prt;/* Real co-ords convert to screen positions */
  1532. X  col -= panel_col_prt;
  1533. X  if (mvaddch (row, col, ch) == ERR)
  1534. X    {
  1535. X      abort();
  1536. X      /* clear msg_flag to avoid problems with unflushed messages */
  1537. X      msg_flag = 0;
  1538. X      (void) sprintf(tmp_str, "error in print, row = %d col = %d\n",
  1539. X             row, col);
  1540. X      prt(tmp_str, 0, 0);
  1541. X      bell ();
  1542. X      /* wait so user can see error */
  1543. X      (void) sleep(2);
  1544. X    }
  1545. X}
  1546. X#endif
  1547. X
  1548. X
  1549. X/* Moves the cursor to a given interpolated y, x position    -RAK-    */
  1550. Xvoid move_cursor_relative(row, col)
  1551. Xint row;
  1552. Xint col;
  1553. X#ifdef MAC
  1554. X{
  1555. X  row -= panel_row_prt;/* Real co-ords convert to screen positions */
  1556. X  col -= panel_col_prt;
  1557. X
  1558. X  DSetScreenCursor(col, row);
  1559. X}
  1560. X#else
  1561. X{
  1562. X  vtype tmp_str;
  1563. X
  1564. X  row -= panel_row_prt;/* Real co-ords convert to screen positions */
  1565. X  col -= panel_col_prt;
  1566. X  if (move (row, col) == ERR)
  1567. X    {
  1568. X      abort();
  1569. X      /* clear msg_flag to avoid problems with unflushed messages */
  1570. X      msg_flag = 0;
  1571. X      (void) sprintf(tmp_str,
  1572. X             "error in move_cursor_relative, row = %d col = %d\n",
  1573. X             row, col);
  1574. X      prt(tmp_str, 0, 0);
  1575. X      bell();
  1576. X      /* wait so user can see error */
  1577. X      (void) sleep(2);
  1578. X    }
  1579. X}
  1580. X#endif
  1581. X
  1582. X
  1583. X/* Print a message so as not to interrupt a counted command. -CJS- */
  1584. Xvoid count_msg_print(p)
  1585. Xchar *p;
  1586. X{
  1587. X  int i;
  1588. X
  1589. X  i = command_count;
  1590. X  msg_print(p);
  1591. X  command_count = i;
  1592. X}
  1593. X
  1594. X
  1595. X/* Outputs a line to a given y, x position        -RAK-    */
  1596. Xvoid prt(str_buff, row, col)
  1597. Xchar *str_buff;
  1598. Xint row;
  1599. Xint col;
  1600. X#ifdef MAC
  1601. X{
  1602. X  Rect line;
  1603. X
  1604. X  if (row == MSG_LINE && msg_flag)
  1605. X    msg_print(CNIL);
  1606. X
  1607. X  line.left = col;
  1608. X  line.top = row;
  1609. X  line.right = SCRN_COLS;
  1610. X  line.bottom = row + 1;
  1611. X  DEraseScreen(&line);
  1612. X
  1613. X  put_buffer(str_buff, row, col);
  1614. X}
  1615. X#else
  1616. X{
  1617. X  if (row == MSG_LINE && msg_flag)
  1618. X    msg_print(CNIL);
  1619. X  (void) move(row, col);
  1620. X  clrtoeol();
  1621. X  put_buffer(str_buff, row, col);
  1622. X}
  1623. X#endif
  1624. X
  1625. X
  1626. X/* move cursor to a given y, x position */
  1627. Xvoid move_cursor(row, col)
  1628. Xint row, col;
  1629. X#ifdef MAC
  1630. X{
  1631. X  DSetScreenCursor(col, row);
  1632. X}
  1633. X#else
  1634. X{
  1635. X  (void) move (row, col);
  1636. X}
  1637. X#endif
  1638. X
  1639. X
  1640. X/* Outputs message to top line of screen                */
  1641. X/* These messages are kept for later reference.     */
  1642. Xvoid msg_print(str_buff)
  1643. Xchar *str_buff;
  1644. X{
  1645. X  register int old_len, new_len;
  1646. X  int combine_messages = FALSE;
  1647. X  char in_char;
  1648. X#ifdef MAC
  1649. X  Rect line;
  1650. X#endif
  1651. X
  1652. X  if (msg_flag)
  1653. X    {
  1654. X      old_len = strlen(old_msg[last_msg]) + 1;
  1655. X
  1656. X      /* If the new message and the old message are short enough, we want
  1657. X     display them together on the same line.  So we don't flush the old
  1658. X     message in this case.  */
  1659. X     
  1660. X      if (str_buff)
  1661. X    new_len = strlen (str_buff);
  1662. X      else
  1663. X    new_len = 0;
  1664. X
  1665. X      if (! str_buff || (new_len + old_len + 2 >= 73))
  1666. X    {
  1667. X      /* ensure that the complete -more- message is visible. */
  1668. X      if (old_len > 73)
  1669. X        old_len = 73;
  1670. X      put_buffer(" -more-", MSG_LINE, old_len);
  1671. X      /* let sigint handler know that we are waiting for a space */
  1672. X      wait_for_more = 1;
  1673. X      do
  1674. X        {
  1675. X          in_char = inkey();
  1676. X        }
  1677. X      while ((in_char != ' ') && (in_char != ESCAPE) && (in_char != '\n')
  1678. X         && (in_char != '\r'));
  1679. X      wait_for_more = 0;
  1680. X    }
  1681. X      else
  1682. X    combine_messages = TRUE;
  1683. X    }
  1684. X
  1685. X  if (! combine_messages)
  1686. X    {
  1687. X#ifdef MAC
  1688. X      line.left = 0;
  1689. X      line.top = MSG_LINE;
  1690. X      line.right = SCRN_COLS;
  1691. X      line.bottom = MSG_LINE+1;
  1692. X      DEraseScreen(&line);
  1693. X#else
  1694. X      (void) move(MSG_LINE, 0);
  1695. X      clrtoeol();
  1696. X#endif
  1697. X    }
  1698. X
  1699. X  /* Make the null string a special case.  -CJS- */
  1700. X  if (str_buff)
  1701. X    {
  1702. X      command_count = 0;
  1703. X      msg_flag = TRUE;
  1704. X
  1705. X      /* If the new message and the old message are short enough, display
  1706. X     them on the same line.  */
  1707. X      
  1708. X      if (combine_messages)
  1709. X    {
  1710. X      put_buffer (str_buff, MSG_LINE, old_len + 2);
  1711. X      strcat (old_msg[last_msg], "  ");
  1712. X      strcat (old_msg[last_msg], str_buff);
  1713. X    }
  1714. X      else
  1715. X    {
  1716. X      put_buffer(str_buff, MSG_LINE, 0);
  1717. X      last_msg++;
  1718. X      if (last_msg >= MAX_SAVE_MSG)
  1719. X        last_msg = 0;
  1720. X      (void) strncpy(old_msg[last_msg], str_buff, VTYPESIZ);
  1721. X      old_msg[last_msg][VTYPESIZ - 1] = '\0';
  1722. X    }
  1723. X    }
  1724. X  else
  1725. X    msg_flag = FALSE;
  1726. X}
  1727. X
  1728. X
  1729. X/* Used to verify a choice - user gets the chance to abort choice.  -CJS- */
  1730. Xint get_check(prompt)
  1731. Xchar *prompt;
  1732. X{
  1733. X  int res;
  1734. X#ifdef MAC
  1735. X  long y, x;        /* ??? Should change to int or short.  */
  1736. X#else
  1737. X  int y, x;
  1738. X#endif
  1739. X
  1740. X  prt(prompt, 0, 0);
  1741. X#ifdef MAC
  1742. X  GetScreenCursor(&x, &y);
  1743. X#else
  1744. X  getyx(stdscr, y, x);
  1745. X#if defined(lint)
  1746. X  /* prevent message 'warning: y is unused' */
  1747. X  x = y;
  1748. X#endif
  1749. X#ifdef LINT_ARGS
  1750. X  /* prevent message about y never used for MSDOS systems */
  1751. X  res = y;
  1752. X#endif
  1753. X#endif
  1754. X
  1755. X  if (x > 73)
  1756. X    (void) move(0, 73);
  1757. X#ifdef MAC
  1758. X  DWriteScreenStringAttr(" [y/n]", ATTR_NORMAL);
  1759. X#else
  1760. X  (void) addstr(" [y/n]");
  1761. X#endif
  1762. X  do
  1763. X    {
  1764. X      res = inkey();
  1765. X    }
  1766. X  while(res == ' ');
  1767. X  erase_line(0, 0);
  1768. X  if (res == 'Y' || res == 'y')
  1769. X    return TRUE;
  1770. X  else
  1771. X    return FALSE;
  1772. X}
  1773. X
  1774. X/* Prompts (optional) and returns ord value of input char    */
  1775. X/* Function returns false if <ESCAPE> is input    */
  1776. Xint get_com(prompt, command)
  1777. Xchar *prompt;
  1778. Xchar *command;
  1779. X{
  1780. X  int res;
  1781. X
  1782. X  if (prompt)
  1783. X    prt(prompt, 0, 0);
  1784. X  *command = inkey();
  1785. X  if (*command == ESCAPE)
  1786. X    res = FALSE;
  1787. X  else
  1788. X    res = TRUE;
  1789. X  erase_line(MSG_LINE, 0);
  1790. X  return(res);
  1791. X}
  1792. X
  1793. X#ifdef MAC
  1794. X/* Same as get_com(), but translates direction keys from keypad */
  1795. Xint get_comdir(prompt, command)
  1796. Xchar *prompt;
  1797. Xchar *command;
  1798. X{
  1799. X  int res;
  1800. X
  1801. X  if (prompt)
  1802. X    prt(prompt, 0, 0);
  1803. X  *command = inkeydir();
  1804. X  if (*command == ESCAPE)
  1805. X    res = FALSE;
  1806. X  else
  1807. X    res = TRUE;
  1808. X  erase_line(MSG_LINE, 0);
  1809. X  return(res);
  1810. X}
  1811. X#endif
  1812. X
  1813. X
  1814. X/* Gets a string terminated by <RETURN>        */
  1815. X/* Function returns false if <ESCAPE> is input    */
  1816. Xint get_string(in_str, row, column, slen)
  1817. Xchar *in_str;
  1818. Xint row, column, slen;
  1819. X{
  1820. X  register int start_col, end_col, i;
  1821. X  char *p;
  1822. X  int flag, aborted;
  1823. X#ifdef MAC
  1824. X  Rect area;
  1825. X#endif
  1826. X
  1827. X  aborted = FALSE;
  1828. X  flag    = FALSE;
  1829. X#ifdef MAC
  1830. X  area.left = column;
  1831. X  area.top = row;
  1832. X  area.right = column + slen;
  1833. X  area.bottom = row + 1;
  1834. X  DEraseScreen(&area);
  1835. X  DSetScreenCursor(column, row);
  1836. X#else
  1837. X  (void) move(row, column);
  1838. X  for (i = slen; i > 0; i--)
  1839. X    (void) addch(' ');
  1840. X  (void) move(row, column);
  1841. X#endif
  1842. X  start_col = column;
  1843. X  end_col = column + slen - 1;
  1844. X  if (end_col > 79)
  1845. X    {
  1846. X      slen = 80 - column;
  1847. X      end_col = 79;
  1848. X    }
  1849. X  p = in_str;
  1850. X  do
  1851. X    {
  1852. X      i = inkey();
  1853. X      switch(i)
  1854. X    {
  1855. X    case ESCAPE:
  1856. X      aborted = TRUE;
  1857. X      break;
  1858. X    case CTRL('J'): case CTRL('M'):
  1859. X      flag    = TRUE;
  1860. X      break;
  1861. X    case DELETE: case CTRL('H'):
  1862. X      if (column > start_col)
  1863. X        {
  1864. X          column--;
  1865. X          put_buffer(" ", row, column);
  1866. X          move_cursor(row, column);
  1867. X          *--p = '\0';
  1868. X        }
  1869. X      break;
  1870. X    default:
  1871. X      if (!isprint(i) || column > end_col)
  1872. X        bell();
  1873. X      else
  1874. X        {
  1875. X#ifdef MAC
  1876. X          DSetScreenCursor(column, row);
  1877. X          DWriteScreenCharAttr((char) i, ATTR_NORMAL);
  1878. X#else
  1879. X          use_value2 mvaddch(row, column, (char)i);
  1880. X#endif
  1881. X          *p++ = i;
  1882. X          column++;
  1883. X        }
  1884. X      break;
  1885. X    }
  1886. X    }
  1887. X  while ((!flag) && (!aborted));
  1888. X  if (aborted)
  1889. X    return(FALSE);
  1890. X  /* Remove trailing blanks    */
  1891. X  while (p > in_str && p[-1] == ' ')
  1892. X    p--;
  1893. X  *p = '\0';
  1894. X  return(TRUE);
  1895. X}
  1896. X
  1897. X
  1898. X/* Pauses for user response before returning        -RAK-    */
  1899. Xvoid pause_line(prt_line)
  1900. Xint prt_line;
  1901. X{
  1902. X  prt("[Press any key to continue.]", prt_line, 23);
  1903. X  (void) inkey();
  1904. X  erase_line(prt_line, 0);
  1905. X}
  1906. X
  1907. X
  1908. X/* Pauses for user response before returning        -RAK-    */
  1909. X/* NOTE: Delay is for players trying to roll up "perfect"    */
  1910. X/*    characters.  Make them wait a bit.            */
  1911. Xvoid pause_exit(prt_line, delay)
  1912. Xint prt_line;
  1913. Xint delay;
  1914. X{
  1915. X  char dummy;
  1916. X
  1917. X  prt("[Press any key to continue, or Q to exit.]", prt_line, 10);
  1918. X  dummy = inkey();
  1919. X  if (dummy == 'Q')
  1920. X    {
  1921. X      erase_line(prt_line, 0);
  1922. X#ifndef MSDOS        /* PCs are slow enough as is  -dgk */
  1923. X      if (delay > 0)  (void) sleep((unsigned)delay);
  1924. X#else
  1925. X      /* prevent message about delay unused */
  1926. X      dummy = delay;
  1927. X#endif
  1928. X#ifdef MAC
  1929. X      enablefilemenu(FALSE);
  1930. X      exit_game();
  1931. X      enablefilemenu(TRUE);
  1932. X#else
  1933. X      exit_game();
  1934. X#endif
  1935. X    }
  1936. X  erase_line(prt_line, 0);
  1937. X}
  1938. X
  1939. X#ifdef MAC
  1940. Xvoid save_screen()
  1941. X{
  1942. X  mac_save_screen();
  1943. X}
  1944. X
  1945. Xvoid restore_screen()
  1946. X{
  1947. X  mac_restore_screen();
  1948. X}
  1949. X#else
  1950. Xvoid save_screen()
  1951. X{
  1952. X  overwrite(stdscr, savescr);
  1953. X}
  1954. X
  1955. Xvoid restore_screen()
  1956. X{
  1957. X  overwrite(savescr, stdscr);
  1958. X  touchwin(stdscr);
  1959. X}
  1960. X#endif
  1961. X
  1962. Xvoid bell()
  1963. X{
  1964. X  put_qio();
  1965. X
  1966. X  /* The player can turn off beeps if he/she finds them annoying.  */
  1967. X  if (! sound_beep_flag)
  1968. X    return;
  1969. X
  1970. X#ifdef MAC
  1971. X  mac_beep();
  1972. X#else
  1973. X  (void) write(1, "\007", 1);
  1974. X#endif
  1975. X}
  1976. X
  1977. X/* definitions used by screen_map() */
  1978. X/* index into border character array */
  1979. X#define TL 0    /* top left */
  1980. X#define TR 1
  1981. X#define BL 2
  1982. X#define BR 3
  1983. X#define HE 4    /* horizontal edge */
  1984. X#define VE 5
  1985. X
  1986. X/* character set to use */
  1987. X#ifdef MSDOS
  1988. X# ifdef ANSI
  1989. X#   define CH(x)    (ansi ? screen_border[0][x] : screen_border[1][x])
  1990. X# else
  1991. X#   define CH(x)    (screen_border[1][x])
  1992. X# endif
  1993. X#else
  1994. X#   define CH(x)    (screen_border[0][x])
  1995. X#endif
  1996. X
  1997. X  /* Display highest priority object in the RATIO by RATIO area */
  1998. X#define    RATIO 3
  1999. X
  2000. Xvoid screen_map()
  2001. X{
  2002. X  register int    i, j;
  2003. X  static int8u screen_border[2][6] = {
  2004. X    {'+', '+', '+', '+', '-', '|'},    /* normal chars */
  2005. X    {201, 187, 200, 188, 205, 186}    /* graphics chars */
  2006. X  };
  2007. X  int8u map[MAX_WIDTH / RATIO + 1];
  2008. X  int8u tmp;
  2009. X  int priority[256];
  2010. X  int row, orow, col, myrow, mycol = 0;
  2011. X#ifndef MAC
  2012. X  char prntscrnbuf[80];
  2013. X#endif
  2014. X
  2015. X  for (i = 0; i < 256; i++)
  2016. X    priority[i] = 0;
  2017. X  priority['<'] = 5;
  2018. X  priority['>'] = 5;
  2019. X  priority['@'] = 10;
  2020. X#ifdef MSDOS
  2021. X  priority[wallsym] = -5;
  2022. X  priority[floorsym] = -10;
  2023. X#else
  2024. X#ifndef ATARI_ST
  2025. X  priority['#'] = -5;
  2026. X#else
  2027. X  priority[(unsigned char)240] = -5;
  2028. X#endif
  2029. X  priority['.'] = -10;
  2030. X#endif
  2031. X  priority['\''] = -3;
  2032. X  priority[' '] = -15;
  2033. X
  2034. X  save_screen();
  2035. X  clear_screen();
  2036. X#ifdef MAC
  2037. X  DSetScreenCursor(0, 0);
  2038. X  DWriteScreenCharAttr(CH(TL), ATTR_NORMAL);
  2039. X  for (i = 0; i < MAX_WIDTH / RATIO; i++)
  2040. X    DWriteScreenCharAttr(CH(HE), ATTR_NORMAL);
  2041. X  DWriteScreenCharAttr(CH(TR), ATTR_NORMAL);
  2042. X#else
  2043. X  use_value2 mvaddch(0, 0, CH(TL));
  2044. X  for (i = 0; i < MAX_WIDTH / RATIO; i++)
  2045. X    (void) addch(CH(HE));
  2046. X  (void) addch(CH(TR));
  2047. X#endif
  2048. X  orow = -1;
  2049. X  map[MAX_WIDTH / RATIO] = '\0';
  2050. X  for (i = 0; i < MAX_HEIGHT; i++)
  2051. X    {
  2052. X      row = i / RATIO;
  2053. X      if (row != orow)
  2054. X    {
  2055. X      if (orow >= 0)
  2056. X        {
  2057. X#ifdef MAC
  2058. X          DSetScreenCursor(0, orow+1);
  2059. X          DWriteScreenCharAttr(CH(VE), ATTR_NORMAL);
  2060. X          DWriteScreenString((char *) map);
  2061. X          DWriteScreenCharAttr(CH(VE), ATTR_NORMAL);
  2062. X#else
  2063. X          /* can not use mvprintw() on ibmpc, because PC-Curses is horribly
  2064. X         written, and mvprintw() causes the fp emulation library to be
  2065. X         linked with PC-Moria, makes the program 10K bigger */
  2066. X          (void) sprintf(prntscrnbuf,"%c%s%c",CH(VE), map, CH(VE));
  2067. X          use_value2 mvaddstr(orow+1, 0, prntscrnbuf);
  2068. X#endif
  2069. X        }
  2070. X      for (j = 0; j < MAX_WIDTH / RATIO; j++)
  2071. X        map[j] = ' ';
  2072. X      orow = row;
  2073. X    }
  2074. X      for (j = 0; j < MAX_WIDTH; j++)
  2075. X    {
  2076. X      col = j / RATIO;
  2077. X      tmp = loc_symbol(i, j);
  2078. X      if (priority[map[col]] < priority[tmp])
  2079. X        map[col] = tmp;
  2080. X      if (map[col] == '@')
  2081. X        {
  2082. X          mycol = col + 1; /* account for border */
  2083. X          myrow = row + 1;
  2084. X        }
  2085. X    }
  2086. X    }
  2087. X  if (orow >= 0)
  2088. X    {
  2089. X#ifdef MAC
  2090. X      DSetScreenCursor(0, orow+1);
  2091. X      DWriteScreenCharAttr(CH(VE), ATTR_NORMAL);
  2092. X      DWriteScreenString((char *) map);
  2093. X      DWriteScreenCharAttr(CH(VE), ATTR_NORMAL);
  2094. X#else
  2095. X      (void) sprintf(prntscrnbuf,"%c%s%c",CH(VE), map, CH(VE));
  2096. X      use_value2 mvaddstr(orow+1, 0, prntscrnbuf);
  2097. X#endif
  2098. X    }
  2099. X#ifdef MAC
  2100. X  DSetScreenCursor(0, orow + 2);
  2101. X  DWriteScreenCharAttr(CH(BL), ATTR_NORMAL);
  2102. X  for (i = 0; i < MAX_WIDTH / RATIO; i++)
  2103. X    DWriteScreenCharAttr(CH(HE), ATTR_NORMAL);
  2104. X  DWriteScreenCharAttr(CH(BR), ATTR_NORMAL);
  2105. X#else
  2106. X  use_value2 mvaddch(orow + 2, 0, CH(BL));
  2107. X  for (i = 0; i < MAX_WIDTH / RATIO; i++)
  2108. X    (void) addch(CH(HE));
  2109. X  (void) addch(CH(BR));
  2110. X#endif
  2111. X
  2112. X#ifdef MAC
  2113. X  DSetScreenCursor(23, 23);
  2114. X  DWriteScreenStringAttr("Hit any key to continue", ATTR_NORMAL);
  2115. X  if (mycol > 0)
  2116. X    DSetScreenCursor(mycol, myrow);
  2117. X#else
  2118. X  use_value2 mvaddstr(23, 23, "Hit any key to continue");
  2119. X  if (mycol > 0)
  2120. X    (void) move(myrow, mycol);
  2121. X#endif
  2122. X  (void) inkey();
  2123. X  restore_screen();
  2124. X}
  2125. END_OF_FILE
  2126. if test 35784 -ne `wc -c <'source/io.c'`; then
  2127.     echo shar: \"'source/io.c'\" unpacked with wrong size!
  2128. fi
  2129. # end of 'source/io.c'
  2130. fi
  2131. echo shar: End of archive 13 \(of 39\).
  2132. cp /dev/null ark13isdone
  2133. MISSING=""
  2134. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 ; do
  2135.     if test ! -f ark${I}isdone ; then
  2136.     MISSING="${MISSING} ${I}"
  2137.     fi
  2138. done
  2139. if test "${MISSING}" = "" ; then
  2140.     echo You have unpacked all 39 archives.
  2141.     echo "Now run "bldfiles.sh" to build split files"
  2142.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2143. else
  2144.     echo You still need to unpack the following archives:
  2145.     echo "        " ${MISSING}
  2146. fi
  2147. ##  End of shell archive.
  2148. exit 0
  2149.