home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume9 / umoria3 / part19 < prev    next >
Encoding:
Internet Message Format  |  1990-05-21  |  60.8 KB

  1. Path: uunet!zephyr.ens.tek.com!tekred!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v09i074:  umoria3 - single player dungeon simulation (ver. 5.2), Part19/31
  5. Message-ID: <5609@tekred.CNA.TEK.COM>
  6. Date: 17 May 90 16:23:54 GMT
  7. Sender: news@tekred.CNA.TEK.COM
  8. Lines: 2866
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: wilson@ernie.Berkeley.EDU (Jim Wilson)
  12. Posting-number: Volume 9, Issue 74
  13. Archive-name: umoria3/Part19
  14. Supersedes: umoria2: Volume 5, Issue 32-37,41-52,87
  15.  
  16.  
  17.  
  18. #! /bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 19 (of 31)."
  25. # Contents:  mac/moria.r mac/scrnmgr/ScrnMgr2.c source/signals.c
  26. # Wrapped by billr@saab on Wed May 16 11:54:33 1990
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'mac/moria.r' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'mac/moria.r'\"
  30. else
  31. echo shar: Extracting \"'mac/moria.r'\" \(19759 characters\)
  32. sed "s/^X//" >'mac/moria.r' <<'END_OF_FILE'
  33. X#include "Types.r"
  34. X
  35. Xinclude "ScrnMgr.rsrc";
  36. X
  37. Xtype 'MRIA' as 'STR ';
  38. X
  39. Xtype 'CNFG' (256 : 257) {
  40. X    longint;
  41. X};
  42. X
  43. Xtype 'TEXT' {
  44. X    string;
  45. X};
  46. X
  47. Xresource 'MRIA' (0) {
  48. X    "Moria 5.2.0 for the Macintosh: Implementation 2.0b1"
  49. X};
  50. X
  51. Xresource 'BNDL' (128, purgeable) {
  52. X    'MRIA',
  53. X    0,
  54. X    { /* array TypeArray: 2 elements */
  55. X        /* [1] */
  56. X        'ICN#',
  57. X        { /* array IDArray: 3 elements */
  58. X            /* [1] Application */
  59. X            0, 128,
  60. X            /* [2] Save file */
  61. X            1, 129,
  62. X            /* [3] Aux files */
  63. X            2, 130
  64. X        },
  65. X        /* [2] */
  66. X        'FREF',
  67. X        { /* array IDArray: 5 elements */
  68. X            /* [1] Appilication */
  69. X            0, 128,
  70. X            /* [2] Save file */
  71. X            1, 129,
  72. X            /* [3] Info files */
  73. X            2, 130,
  74. X            /* [4] Score file */
  75. X            3, 131,
  76. X            /* [5] Config file */
  77. X            4, 132
  78. X        }
  79. X    }
  80. X};
  81. X
  82. Xresource 'FREF' (128, "Application", purgeable) {
  83. X    'APPL',
  84. X    0,
  85. X    ""
  86. X};
  87. X
  88. Xresource 'FREF' (129, "Save Files", purgeable) {
  89. X    'SAVE',
  90. X    1,
  91. X    ""
  92. X};
  93. X
  94. Xresource 'FREF' (130, "Info Files", purgeable) {
  95. X    'TEXT',
  96. X    2,
  97. X    ""
  98. X};
  99. X
  100. Xresource 'FREF' (131, "Score File", purgeable) {
  101. X    'SCOR',
  102. X    2,
  103. X    ""
  104. X};
  105. X
  106. Xresource 'FREF' (132, "Config File", purgeable) {
  107. X    'CNFG',
  108. X    2,
  109. X    ""
  110. X};
  111. X
  112. Xresource 'ICON' (128, "Application", purgeable) {
  113. X    $"00 01 00 00 00 02 80 00 00 04 40 00 00 08 20 00"
  114. X    $"00 10 10 00 00 22 08 00 00 45 04 00 00 88 82 00"
  115. X    $"01 05 15 00 02 02 A8 80 04 40 40 40 08 A8 80 20"
  116. X    $"11 15 00 10 24 8A 00 28 40 51 3F 44 91 20 C0 8A"
  117. X    $"40 00 80 51 24 41 30 22 10 01 C8 14 09 1E 7F 8F"
  118. X    $"04 02 30 07 02 41 00 07 01 00 80 07 00 80 60 07"
  119. X    $"00 40 1F E7 00 20 02 1F 00 10 04 07 00 08 08 00"
  120. X    $"00 04 10 00 00 02 20 00 00 01 40 00 00 00 80"
  121. X};
  122. X
  123. Xresource 'ICON' (256, "Command Set", purgeable) {
  124. X    $"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
  125. X    $"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
  126. X    $"00 00 00 00 7F FF FF FE 80 00 00 01 9A AA AA A9"
  127. X    $"80 00 00 01 95 55 55 59 80 00 00 01 9A AA AA A9"
  128. X    $"80 00 00 01 85 7F FF 51 80 00 00 01 80 00 00 01"
  129. X    $"7F FF FF FE"
  130. X};
  131. X
  132. Xresource 'ICON' (257, "TEXT Editor", purgeable) {
  133. X    $"0F FF FE 00 08 00 03 00 08 00 02 80 08 00 02 40"
  134. X    $"08 00 02 20 08 00 02 10 08 00 03 F8 08 00 00 08"
  135. X    $"08 00 00 08 08 07 C0 08 08 0F E0 08 08 18 30 08"
  136. X    $"08 30 18 08 08 20 18 08 08 00 18 08 08 00 30 08"
  137. X    $"08 00 60 08 08 00 C0 08 08 01 80 08 08 01 80 08"
  138. X    $"08 01 80 08 08 01 80 08 08 00 00 08 08 01 80 08"
  139. X    $"08 03 C0 08 08 01 80 08 08 00 00 08 08 00 00 08"
  140. X    $"08 00 00 08 08 00 00 08 08 00 00 08 0F FF FF F8"
  141. X};
  142. X
  143. Xresource 'ICN#' (128, "Application", purgeable) {
  144. X    { /* array: 2 elements */
  145. X        /* [1] */
  146. X        $"00 01 00 00 00 02 80 00 00 04 40 00 00 08 20 00"
  147. X        $"00 10 10 00 00 22 08 00 00 45 04 00 00 88 82 00"
  148. X        $"01 05 15 00 02 02 A8 80 04 40 40 40 08 A8 80 20"
  149. X        $"11 15 00 10 24 8A 00 28 40 51 3F 44 91 20 C0 8A"
  150. X        $"40 00 80 51 24 41 30 22 10 01 C8 14 09 1E 7F 8F"
  151. X        $"04 02 30 07 02 41 00 07 01 00 80 07 00 80 60 07"
  152. X        $"00 40 1F E7 00 20 02 1F 00 10 04 07 00 08 08 00"
  153. X        $"00 04 10 00 00 02 20 00 00 01 40 00 00 00 80",
  154. X        /* [2] */
  155. X        $"00 01 00 00 00 03 80 00 00 07 C0 00 00 0F E0 00"
  156. X        $"00 1F F0 00 00 3F F8 00 00 7F FC 00 00 FF FE 00"
  157. X        $"01 FF FF 00 03 FF FF 80 07 FF FF C0 0F FF FF E0"
  158. X        $"1F FF FF F0 3F FF FF F8 7F FF FF FC FF FF FF FE"
  159. X        $"7F FF FF FF 3F FF FF FE 1F FF FF FC 0F FF FF FF"
  160. X        $"07 FF FF FF 03 FF FF FF 01 FF FF FF 00 FF FF FF"
  161. X        $"00 7F FF FF 00 3F FE 1F 00 1F FC 07 00 0F F8 00"
  162. X        $"00 07 F0 00 00 03 E0 00 00 01 C0 00 00 00 80"
  163. X    }
  164. X};
  165. X
  166. Xresource 'ICN#' (129, "Save Files", purgeable) {
  167. X    { /* array: 2 elements */
  168. X        /* [1] */
  169. X        $"0F FF FE 00 08 00 03 00 08 00 02 80 08 00 02 40"
  170. X        $"08 00 02 20 08 00 02 10 08 00 03 F8 08 00 00 08"
  171. X        $"08 00 00 08 08 7F FE 08 08 FF FF 08 09 80 01 88"
  172. X        $"09 9F F9 88 09 B0 09 88 09 B1 29 88 09 92 A9 88"
  173. X        $"09 91 29 88 09 B0 49 88 09 B0 09 88 09 9F F9 88"
  174. X        $"09 80 01 88 09 FF FF 88 09 FF FF 88 09 80 01 88"
  175. X        $"08 00 00 08 09 12 64 88 09 B5 55 48 09 55 65 C8"
  176. X        $"09 15 55 48 09 12 55 48 08 00 00 08 0F FF FF F8",
  177. X        /* [2] */
  178. X        $"0F FF FE 00 0F FF FF 00 0F FF FF 80 0F FF FF C0"
  179. X        $"0F FF FF E0 0F FF FF F0 0F FF FF F8 0F FF FF F8"
  180. X        $"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
  181. X        $"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
  182. X        $"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
  183. X        $"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
  184. X        $"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
  185. X        $"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
  186. X    }
  187. X};
  188. X
  189. Xresource 'ICN#' (130, "Aux Files", purgeable) {
  190. X    { /* array: 2 elements */
  191. X        /* [1] */
  192. X        $"0F FF FE 00 08 00 03 00 08 00 02 80 09 FB AE 40"
  193. X        $"08 00 02 20 08 00 02 10 09 F7 7B F8 08 00 00 08"
  194. X        $"08 00 00 08 09 BB ED C8 08 00 00 08 08 00 00 08"
  195. X        $"09 F7 B7 C8 08 00 00 08 08 00 00 08 09 B5 FD C8"
  196. X        $"08 00 00 08 08 00 00 08 09 77 B6 C8 08 00 00 08"
  197. X        $"08 00 00 08 09 EB B7 48 08 00 00 08 08 00 00 08"
  198. X        $"08 00 00 08 09 12 64 88 09 B5 55 48 09 55 65 C8"
  199. X        $"09 15 55 48 09 12 55 48 08 00 00 08 0F FF FF F8",
  200. X        /* [2] */
  201. X        $"0F FF FE 00 0F FF FF 00 0F FF FF 80 0F FF FF C0"
  202. X        $"0F FF FF E0 0F FF FF F0 0F FF FF F8 0F FF FF F8"
  203. X        $"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
  204. X        $"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
  205. X        $"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
  206. X        $"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
  207. X        $"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
  208. X        $"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
  209. X    }
  210. X};
  211. X
  212. Xresource 'DLOG' (128, "About", purgeable) {
  213. X    {46, 26, 304, 274},
  214. X    dBoxProc,
  215. X    invisible,
  216. X    noGoAway,
  217. X    0x0,
  218. X    128,
  219. X    ""
  220. X};
  221. X
  222. Xresource 'DITL' (128, "About", purgeable) {
  223. X    {    /* array DITLarray: 4 elements */
  224. X        /* [1] */
  225. X        {224, 192, 247, 235},
  226. X        Button {
  227. X            enabled,
  228. X            "OK"
  229. X        },
  230. X        /* [2] */
  231. X        {232, 224, 241, 233},
  232. X        UserItem {
  233. X            disabled
  234. X        },
  235. X        /* [3] */
  236. X        {16, 8, 248, 184},
  237. X        StaticText {
  238. X            disabled,
  239. X            "Moria for the Macintosh\n"
  240. X            "Version 5.2.0\n"
  241. X            "Implementation 2.0b1\n\n\n"
  242. X            "Programmers:\n"
  243. X            "Robert Alan Koeneke\n"
  244. X            "Jimmey Wayne Todd\n\n"
  245. X            "UNIX Port:\n"
  246. X            "James E. Wilson\n\n"
  247. X            "Macintosh Port:\n"
  248. X            "Curtis W. McCauley"
  249. X        },
  250. X        /* [4] */
  251. X        {16, 195, 48, 227},
  252. X        Icon {
  253. X            disabled,
  254. X            128
  255. X        }
  256. X    }
  257. X};
  258. X
  259. Xresource 'STR ' (128, "About Title", purgeable) {
  260. X    "About Moria\311"
  261. X};
  262. X
  263. Xresource 'CNFG' (256, "Command Set", purgeable) {
  264. X    '-o\0x00\0x00'
  265. X};
  266. X
  267. Xresource 'DLOG' (256, "Command Set", purgeable) {
  268. X    {42, 34, 218, 404},
  269. X    dBoxProc,
  270. X    invisible,
  271. X    noGoAway,
  272. X    0x0,
  273. X    256,
  274. X    ""
  275. X};
  276. X
  277. Xresource 'DITL' (256, "Command Set", purgeable) {
  278. X    {    /* array DITLarray: 9 elements */
  279. X        /* [1] */
  280. X        {24, 296, 48, 352},
  281. X        Button {
  282. X            enabled,
  283. X            "OK"
  284. X        },
  285. X        /* [2] */
  286. X        {64, 296, 88, 352},
  287. X        Button {
  288. X            enabled,
  289. X            "Cancel"
  290. X        },
  291. X        /* [3] */
  292. X        {40, 24, 56, 200},
  293. X        RadioButton {
  294. X            enabled,
  295. X            "Rogue-Like Commands"
  296. X        },
  297. X        /* [4] */
  298. X        {64, 24, 80, 200},
  299. X        RadioButton {
  300. X            enabled,
  301. X            "Original Commands"
  302. X        },
  303. X        /* [5] */
  304. X        {112, 72, 168, 352},
  305. X        StaticText {
  306. X            disabled,
  307. X            "Choose the desired command set.  The change "
  308. X            "will take effect when you start the next game."
  309. X        },
  310. X        /* [6] */
  311. X        {16, 16, 96, 232},
  312. X        UserItem {
  313. X            disabled
  314. X        },
  315. X        /* [7] */
  316. X        {8, 24, 24, 104},
  317. X        StaticText {
  318. X            enabled,
  319. X            "Choose One"
  320. X        },
  321. X        /* [8] */
  322. X        {32, 336, 40, 344},
  323. X        UserItem {
  324. X            disabled
  325. X        },
  326. X        /* [9] */
  327. X        {112, 16, 144, 48},
  328. X        Icon {
  329. X            disabled,
  330. X            256
  331. X        }
  332. X    }
  333. X};
  334. X
  335. Xresource 'CNFG' (257, "TEXT Editor", purgeable) {
  336. X    'MACA'
  337. X};
  338. X
  339. Xresource 'DLOG' (257, "TEXT Editor", purgeable) {
  340. X    {42, 34, 226, 426},
  341. X    dBoxProc,
  342. X    invisible,
  343. X    noGoAway,
  344. X    0x0,
  345. X    257,
  346. X    ""
  347. X};
  348. X
  349. Xresource 'DITL' (257, "TEXT Editor", purgeable) {
  350. X    {    /* array DITLarray: 11 elements */
  351. X        /* [1] */
  352. X        {24, 320, 48, 376},
  353. X        Button {
  354. X            enabled,
  355. X            "OK"
  356. X        },
  357. X        /* [2] */
  358. X        {64, 320, 88, 376},
  359. X        Button {
  360. X            enabled,
  361. X            "Cancel"
  362. X        },
  363. X        /* [3] */
  364. X        {40, 24, 56, 200},
  365. X        RadioButton {
  366. X            enabled,
  367. X            "MacWrite"
  368. X        },
  369. X        /* [4] */
  370. X        {64, 24, 80, 176},
  371. X        RadioButton {
  372. X            enabled,
  373. X            "Microsoft Word"
  374. X        },
  375. X        /* [5] */
  376. X        {88, 24, 104, 176},
  377. X        RadioButton {
  378. X            enabled,
  379. X            "Other:  File Creator"
  380. X        },
  381. X        /* [6] */
  382. X        {88, 176, 104, 240},
  383. X        EditText {
  384. X            disabled,
  385. X            ""
  386. X        },
  387. X        /* [7] */
  388. X        {136, 72, 176, 376},
  389. X        StaticText {
  390. X            disabled,
  391. X            "Choose what kind of documents you want Moria "
  392. X            "to create when it prints to a file."
  393. X        },
  394. X        /* [8] */
  395. X        {16, 8, 120, 264},
  396. X        UserItem {
  397. X            disabled
  398. X        },
  399. X        /* [9] */
  400. X        {8, 24, 24, 104},
  401. X        StaticText {
  402. X            enabled,
  403. X            "Choose One"
  404. X        },
  405. X        /* [10] */
  406. X        {32, 360, 40, 368},
  407. X        UserItem {
  408. X            disabled
  409. X        },
  410. X        /* [11] */
  411. X        {136, 16, 168, 48},
  412. X        Icon {
  413. X            disabled,
  414. X            257
  415. X        }
  416. X    }
  417. X};
  418. X
  419. Xresource 'DLOG' (258, "Save, Quit, or Cancel", purgeable) {
  420. X    {40, 40, 168, 318},
  421. X    dBoxProc,
  422. X    invisible,
  423. X    noGoAway,
  424. X    0x0,
  425. X    258,
  426. X    ""
  427. X};
  428. X
  429. Xresource 'DITL' (258, "Save, Quit, or Cancel", purgeable) {
  430. X    {    /* array DITLarray: 6 elements */
  431. X        /* [1] */
  432. X        {64, 16, 84, 76},
  433. X        Button {
  434. X            enabled,
  435. X            "Save"
  436. X        },
  437. X        /* [2] */
  438. X        {96, 16, 116, 76},
  439. X        Button {
  440. X            enabled,
  441. X            "Quit"
  442. X        },
  443. X        /* [3] */
  444. X        {96, 200, 116, 260},
  445. X        Button {
  446. X            enabled,
  447. X            "Cancel"
  448. X        },
  449. X        /* [4] */
  450. X        {64, 200, 80, 216},
  451. X        UserItem {
  452. X            disabled
  453. X        },
  454. X        /* [5] */
  455. X        {8, 56, 48, 264},
  456. X        StaticText {
  457. X            disabled,
  458. X            "What do you want to do with the game in progress?"
  459. X        },
  460. X        /* [6] */
  461. X        {8, 16, 40, 48},
  462. X        Icon {
  463. X            disabled,
  464. X            0
  465. X        }
  466. X    }
  467. X};
  468. X
  469. Xresource 'MENU' (129, "File") {
  470. X    129,
  471. X    textMenuProc,
  472. X    0x7FFFFFC3,
  473. X    enabled,
  474. X    "File",
  475. X    {    /* array: 7 elements */
  476. X        /* [1] */
  477. X        "New", noIcon, "N", "", plain,
  478. X        /* [2] */
  479. X        "Open\311", noIcon, "O", "", plain,
  480. X        /* [3] */
  481. X        "-", noIcon, "", "", plain,
  482. X        /* [4] */
  483. X        "Save", noIcon, "S", "", plain,
  484. X        /* [5] */
  485. X        "Save As\311", noIcon, "", "", plain,
  486. X        /* [6] */
  487. X        "-", noIcon, "", "", plain,
  488. X        /* [7] */
  489. X        "Quit", noIcon, "Q", "", plain
  490. X    }
  491. X};
  492. X
  493. Xresource 'MENU' (229, "File (No Keys)") {
  494. X    229,
  495. X    textMenuProc,
  496. X    0x7FFFFFC3,
  497. X    enabled,
  498. X    "File",
  499. X    {    /* array: 7 elements */
  500. X        /* [1] */
  501. X        "New", noIcon, "", "", plain,
  502. X        /* [2] */
  503. X        "Open\311", noIcon, "", "", plain,
  504. X        /* [3] */
  505. X        "-", noIcon, "", "", plain,
  506. X        /* [4] */
  507. X        "Save", noIcon, "", "", plain,
  508. X        /* [5] */
  509. X        "Save As\311", noIcon, "", "", plain,
  510. X        /* [6] */
  511. X        "-", noIcon, "", "", plain,
  512. X        /* [7] */
  513. X        "Quit", noIcon, "", "", plain
  514. X    }
  515. X};
  516. X
  517. Xresource 'MENU' (133, "Moria") {
  518. X    133,
  519. X    textMenuProc,
  520. X    0x7FFFFF17,
  521. X    enabled,
  522. X    "Moria",
  523. X    {    /* array: 5 elements */
  524. X        /* [1] */
  525. X        "Help\311", noIcon, "H", "", plain,
  526. X        /* [2] */
  527. X        "Command Set\311", noIcon, "", "", plain,
  528. X        /* [3] */
  529. X        "TEXT Editor\311", noIcon, "", "", plain,
  530. X        /* [4] */
  531. X        "-", noIcon, "", "", plain,
  532. X        /* [5] */
  533. X        "High Scores\311", noIcon, "", "", plain
  534. X    }
  535. X};
  536. X
  537. Xresource 'MENU' (233, "Moria (No Keys)") {
  538. X    233,
  539. X    textMenuProc,
  540. X    0x7FFFFF17,
  541. X    enabled,
  542. X    "Moria",
  543. X    {    /* array: 5 elements */
  544. X        /* [1] */
  545. X        "Help\311", noIcon, "", "", plain,
  546. X        /* [2] */
  547. X        "Command Set\311", noIcon, "", "", plain,
  548. X        /* [3] */
  549. X        "TEXT Editor\311", noIcon, "", "", plain,
  550. X        /* [4] */
  551. X        "-", noIcon, "", "", plain,
  552. X        /* [5] */
  553. X        "High Scores\311", noIcon, "", "", plain
  554. X    }
  555. X};
  556. X
  557. Xresource 'DLOG' (512, "Mac Help", purgeable) {
  558. X    {40, 34, 310, 496},
  559. X    dBoxProc,
  560. X    invisible,
  561. X    noGoAway,
  562. X    0x0,
  563. X    512,
  564. X    ""
  565. X};
  566. X
  567. Xresource 'DITL' (512, "Mac Help", purgeable) {
  568. X    {    /* array DITLarray: 6 elements */
  569. X        /* [1] */
  570. X        {16, 392, 36, 452},
  571. X        Button {
  572. X            enabled,
  573. X            "Ok"
  574. X        },
  575. X        /* [2] */
  576. X        {24, 432, 32, 440},
  577. X        UserItem {
  578. X            disabled
  579. X        },
  580. X        /* [3] */
  581. X        {48, 8, 264, 440},
  582. X        UserItem {
  583. X            disabled
  584. X        },
  585. X        /* [4] */
  586. X        {48, 439, 264, 455},
  587. X        Control {
  588. X            enabled,
  589. X            512
  590. X        },
  591. X        /* [5] */
  592. X        {8, 52, 40, 380},
  593. X        StaticText {
  594. X            disabled,
  595. X            "Moria for the Macintosh Version 5.2.0"
  596. X        },
  597. X        /* [6] */
  598. X        {8, 8, 40, 40},
  599. X        Icon {
  600. X            disabled,
  601. X            128
  602. X        }
  603. X    }
  604. X};
  605. X
  606. Xresource 'CNTL' (512, "Mac Help Scroll Bar", purgeable) {
  607. X    {0, 0, 216, 16},
  608. X    0,
  609. X    visible,
  610. X    0,
  611. X    0,
  612. X    scrollBarProc,
  613. X    0,
  614. X    ""
  615. X};
  616. X
  617. Xresource 'TEXT' (512, "Mac Help", purgeable) {
  618. X    "This is an beta version of Mac Moria, implementation 2.0b1, which is "
  619. X    "based on the Umoria 5.2.0 sources.  Please send comments and bug repor"
  620. X    "ts to wilson@ernie.Berkeley.EDU (Jim Wilson) or 73230.224@compuserve.c"
  621. X    "om (Curtis McCauley).\n\n"
  622. X    "Users of previous versions o"
  623. X    "f Mac Moria should discard the old program.  Otherwise, the Finder mig"
  624. X    "ht get confused when you double-click on a saved game to start Moria.\n"
  625. X    "\n*****************************\n\nMoria is a dungeon exploration game.  "
  626. X    "The name comes from \322The Lord of the Rings\323 trilogy written by J. R. R"
  627. X    ". Tolkien.  Moria is pronounced with the accent on the first syllable,"
  628. X    " e.g. MORE-ee-ah.  For details on the game itself, please read the Mor"
  629. X    "ia Docs file that is distributed along with Moria.\n\nMoria was original"
  630. X    "ly written for VAX/VMS systems.  As such,  it is heavily dependent on "
  631. X    "the keyboard for game play.  The mouse is not used at all, except for "
  632. X    "standard things like menus and dialogs.  To get a list of the availabl"
  633. X    "e keyboard commands, hit the \324?\325 key while playing the game.\n\nSome of "
  634. X    "the commands are specified as being control characters, i.e.  saving t"
  635. X    "he game is ^X.  To type these characters hold down the control key and"
  636. X    " then press the appropriate character key.  If you do not have a contr"
  637. X    "ol key, use the command key (apple/cloverleaf key) instead of the cont"
  638. X    "rol key.  If you prefer, you may enter these commands using two keystr"
  639. X    "okes, by first typing the '^' key followed by the letter.\n\nThe game al"
  640. X    "so uses the escape key (ESC) quite a bit.  If you do not have an escap"
  641. X    "e key on your keyboard, you can use the ` key or the Clear key on the "
  642. X    "numeric keypad instead.  An escape can also by typed as ^[, i.e. contr"
  643. X    "ol (or command) left bracket.\n\nFile Menu\n\nThe game fully supports the "
  644. X    "standard Macintosh file menu.  Use New to start playing a new game,  o"
  645. X    "r Open to restart a previous game.   Save As will always ask you for t"
  646. X    "he name of the file to save your character in.  Save will usually save"
  647. X    " the game in a file with the same name as the name of the current char"
  648. X    "acter.  If you are playing a new game, or have changed the name of you"
  649. X    "r character, Save will instead ask you for the name of the save file. "
  650. X    " The Quit option, of course, is used to exit the game.\n\nA game can onl"
  651. X    "y be saved at the point where it is your turn to move.  At all other t"
  652. X    "imes the Save command will not be available.\n\nThe File Menu is disable"
  653. X    "d while saving and restoring games.  There is no cause for alarm if yo"
  654. X    "u see this occur.  After the operation is completed, there will be a p"
  655. X    "rompt that says \322press any key to continue\323.  After you press a key, t"
  656. X    "he File Menu will be reenabled.\n\nIf your character dies, or you decide"
  657. X    " to stop running him, you will be prompted via a standard file dialog "
  658. X    "for the name of a file in which to save his memories.  Pressing cancel"
  659. X    " will avoid saving the memories.\n\nEdit Menu\n\nThe Edit Menu items are n"
  660. X    "ot used by the game.  The Edit menu is disabled unless there is a Desk"
  661. X    " Accessory open.\n\nScreen/FontSize Menu\n\nIf you have a color system, th"
  662. X    "e Color item allows you to choose the background and foreground colors"
  663. X    " of the game window.  The game must use a constant width font, so only"
  664. X    " the Monaco font is supported.  You can, however, specify which point "
  665. X    "size that you want to use.  The menu will list every point size availa"
  666. X    "ble on your Macintosh for the Monaco font.\n\nAdvanced users can choose "
  667. X    "a different font by using ResEdit or a similar program to edit the STR"
  668. X    " \"Font Name\" resource.\n\nMoria Menu\n\nHelp brings up this dialog.\n\nComma"
  669. X    "nd Set allows you to choose between the original Moria command set and"
  670. X    " an optional command set similar to the UNIX game Rogue.  The main dif"
  671. X    "ference between the two is that the original command set uses the nume"
  672. X    "ric keypad for movement, whereas the Rogue-like command set uses the \324"
  673. X    "hjkl\325 keys for, respectively, left down up and right.  The program wil"
  674. X    "l remember your setting and use it as a default the next time you star"
  675. X    "t a new character.  The command set can be chosen for the current char"
  676. X    "acter by using the set options ('=') command.\n\nNote that the numeric k"
  677. X    "eypad, if your system has one, is always available for indicating dire"
  678. X    "ctions, regardless of the command set chosen.  The arrow keys will wor"
  679. X    "k as well.\n\nText Editor allows you to choose the type of TEXT file cre"
  680. X    "ated by Moria, that is, it allows you to specify which application wil"
  681. X    "l be used by the Finder when you open a TEXT file created by Moria.  Y"
  682. X    "ou can choose MacWrite or Microsoft Word files.  You can also specify "
  683. X    "the signature of the desired application if you prefer something else."
  684. X    "\n\nHigh Scores displays all of the scores stored in the scorefile.  You"
  685. X    " can clear these scores by just deleting the High Scores file.  This f"
  686. X    "eature is not implemented.\n\nConfiguration Info\n\nMoria is fully Multifi"
  687. X    "nder compatible/aware.  It requires 450 K of memory under Multifinder."
  688. X    "  The game will run on any Macintosh with 1 Megabyte or more of memory"
  689. X    ".\n\nMoria comes with a documentation file, called Moria Docs.  The Mori"
  690. X    "a Docs file is an explanation of the game system.  Please remember to "
  691. X    "always distribute this file with the game, since it contains much impo"
  692. X    "rtant information.\n\nMoria will create two files when it is run.  The H"
  693. X    "igh Scores file keeps a list of the scores of all of the previous game"
  694. X    "s.  If this file is not present, a new one will be created in the fold"
  695. X    "er which contains the game.  This file can be kept either in the folde"
  696. X    "r that contains the application, or in the System Folder.\n\nMoria also "
  697. X    "creates a file called Moria Config in the System Folder.  This file co"
  698. X    "ntains all of the configuration info for Moria, such as the size and l"
  699. X    "ocation of windows, the font size, the command set, etc.  This file mu"
  700. X    "st remain in the Sytem Folder.\n\nThe text displayed when Moria starts u"
  701. X    "p is stored in the data fork of this program.  You can edit it with mo"
  702. X    "st text editors by first changing the file type of the program from 'A"
  703. X    "PPL' to 'TEXT' with ResEdit.  Remember to change the file type back ag"
  704. X    "ain when you are through.  Be careful not to disturb the lines which b"
  705. X    "egin with a '#'.\n\0x00"
  706. X};
  707. X
  708. Xtype 'DFPR' {
  709. X    unsigned hex integer = $600A;                    /* branch around header */
  710. X    unsigned hex integer;                            /* flags */
  711. X    unsigned literal longint;                        /* resource type */
  712. X    integer;                                        /* resource id */
  713. X    integer;                                        /* version */
  714. X    unsigned hex integer = $4EF9;                    /* jump instruction */
  715. X    unsigned hex longint = $0;                        /* target address for jump */
  716. X};
  717. X
  718. Xtype 'LDEF' as 'DFPR';
  719. X
  720. Xresource 'LDEF' (514, "High Scores", purgeable) {
  721. X    $0, 'LDEF', 514, 0
  722. X};
  723. X    
  724. Xresource 'DITL' (514, "High Scores", purgeable) {
  725. X    {    /* array DITLarray: 5 elements */
  726. X        /* [1] */
  727. X        {15, 422, 35, 482},
  728. X        Button {
  729. X            enabled,
  730. X            "Ok"
  731. X        },
  732. X        /* [2] */
  733. X        {24, 464, 32, 472},
  734. X        UserItem {
  735. X            disabled
  736. X        },
  737. X        /* [3] */
  738. X        {48, 2, 281, 490},
  739. X        UserItem {
  740. X            disabled
  741. X        },
  742. X        /* [4] */
  743. X        {8, 56, 40, 336},
  744. X        StaticText {
  745. X            disabled,
  746. X            "Moria High Scores\n"
  747. X            "Positions ^0 to ^1"
  748. X        },
  749. X        /* [5] */
  750. X        {8, 8, 40, 40},
  751. X        Icon {
  752. X            disabled,
  753. X            128
  754. X        }
  755. X    }
  756. X};
  757. X
  758. Xresource 'DLOG' (514, "High Scores", purgeable) {
  759. X    {40, 34, 327, 526},
  760. X    dBoxProc,
  761. X    invisible,
  762. X    noGoAway,
  763. X    0x0,
  764. X    514,
  765. X    ""
  766. X};
  767. X
  768. Xresource 'DITL' (1024, "General Error", purgeable) {
  769. X    {    /* array DITLarray: 2 elements */
  770. X        /* [1] */
  771. X        {80, 304, 100, 364},
  772. X        Button {
  773. X            enabled,
  774. X            "Ok"
  775. X        },
  776. X        /* [2] */
  777. X        {7, 68, 71, 364},
  778. X        StaticText {
  779. X            disabled,
  780. X            "^0"
  781. X        }
  782. X    }
  783. X};
  784. X
  785. Xresource 'ALRT' (1024, "General Error", purgeable) {
  786. X    {42, 42, 148, 416},
  787. X    1024,
  788. X    {    /* array: 4 elements */
  789. X        /* [1] */
  790. X        OK, visible, sound1,
  791. X        /* [2] */
  792. X        OK, visible, sound1,
  793. X        /* [3] */
  794. X        OK, visible, sound1,
  795. X        /* [4] */
  796. X        OK, visible, sound1
  797. X    }
  798. X};
  799. X
  800. Xresource 'SIZE' (-1) {
  801. X    dontSaveScreen,
  802. X    acceptSuspendResumeEvents,
  803. X    enableOptionSwitch,
  804. X    canBackground,
  805. X    multiFinderAware,
  806. X    backgroundAndForeground,
  807. X    dontGetFrontClicks,
  808. X    ignoreChildDiedEvents,
  809. X    not32BitCompatible,
  810. X    reserved,
  811. X    reserved,
  812. X    reserved,
  813. X    reserved,
  814. X    reserved,
  815. X    reserved,
  816. X    reserved,
  817. X    375 * 1024,
  818. X    375 * 1024    
  819. X};
  820. END_OF_FILE
  821. if test 19759 -ne `wc -c <'mac/moria.r'`; then
  822.     echo shar: \"'mac/moria.r'\" unpacked with wrong size!
  823. fi
  824. # end of 'mac/moria.r'
  825. fi
  826. if test -f 'mac/scrnmgr/ScrnMgr2.c' -a "${1}" != "-c" ; then 
  827.   echo shar: Will not clobber existing file \"'mac/scrnmgr/ScrnMgr2.c'\"
  828. else
  829. echo shar: Extracting \"'mac/scrnmgr/ScrnMgr2.c'\" \(31284 characters\)
  830. sed "s/^X//" >'mac/scrnmgr/ScrnMgr2.c' <<'END_OF_FILE'
  831. X
  832. Xstatic void DoContentClick(whichWindow, cursorLoc)
  833. XWindowPtr whichWindow;
  834. XPoint *cursorLoc;
  835. X
  836. X{
  837. X    int thePart;
  838. X    ControlHandle theControl;
  839. X    Point localCursor;
  840. X    
  841. X    if (whichWindow == theScreen.window) {
  842. X        localCursor = *cursorLoc;
  843. X        GlobalToLocal(&localCursor);
  844. X        if (thePart = FindControl(localCursor, whichWindow, &theControl)) {
  845. X            if (theControl == theScreen.hScrollHandle) 
  846. X                DoHScroll(&localCursor, thePart);
  847. X            else if (theControl == theScreen.vScrollHandle)
  848. X                DoVScroll(&localCursor, thePart);
  849. X        }
  850. X        else
  851. X            if (theScreen.mouseFlag) DoCharClick();
  852. X    }
  853. X    
  854. X    return;
  855. X}
  856. X    
  857. Xstatic void DoMouseDown(cursorLoc)
  858. XPoint *cursorLoc;
  859. X
  860. X{
  861. X    int part;
  862. X    WindowPtr whichWindow;
  863. X    
  864. X    switch (part = FindWindow(*cursorLoc, &whichWindow)) {
  865. X    
  866. X        case inMenuBar:        DoMenuItem(MenuSelect(*cursorLoc));
  867. X                            break;
  868. X                            
  869. X        case inDrag:        DoDrag(whichWindow, cursorLoc);
  870. X                            break;
  871. X                            
  872. X        case inGrow:        DoGrow(whichWindow, cursorLoc);
  873. X                            break;
  874. X                            
  875. X        case inSysWindow:    SystemClick(&theScreen.event, whichWindow);
  876. X                            break;
  877. X                            
  878. X        case inContent:        if (whichWindow != FrontWindow())
  879. X                                SelectWindow(whichWindow);
  880. X                            else
  881. X                                DoContentClick(whichWindow, cursorLoc);
  882. X                            break;
  883. X                            
  884. X        case inZoomIn:
  885. X        case inZoomOut:        if (whichWindow == theScreen.window)
  886. X                                if (TrackBox(whichWindow, *cursorLoc, part))
  887. X                                    DoZoom(whichWindow, part);
  888. X                            break;
  889. X    
  890. X        case inGoAway:        if (whichWindow == theScreen.window)
  891. X                                if (TrackGoAway(whichWindow, *cursorLoc)) {
  892. X                                    if (theScreen.fileMenuProc != NULL)
  893. X                                        (*theScreen.fileMenuProc)(closeBoxItem);
  894. X                                    else
  895. X                                        DoFileMenu(closeBoxItem);
  896. X                                }
  897. X                            break;
  898. X                            
  899. X    }
  900. X    
  901. X    return;
  902. X}
  903. X
  904. Xstatic void DoKeyDown(cmdFlag)
  905. Xint cmdFlag;
  906. X
  907. X{
  908. X    char keycode, modifiers, ascii;
  909. X    char upper;
  910. X    
  911. X    if ( (theScreen.event.when > theScreen.keyFlush)        &&
  912. X            (theScreen.window == FrontWindow())        &&
  913. X            (((WindowPeek) theScreen.window)->visible) ) {
  914. X            
  915. X        ObscureCursor();
  916. X            
  917. X        keycode = (char) ((theScreen.event.message & keyCodeMask) >> 8);
  918. X        
  919. X        modifiers = (char) ((theScreen.event.modifiers & 0xFF00) >> 8);
  920. X        modifiers &= ~maskModMouse;
  921. X            
  922. X        ascii = (char) (theScreen.event.message & charCodeMask);
  923. X        if (theScreen.escMapFlag) {
  924. X            if (ascii == BACKQUOTE) ascii = ESC;
  925. X        }
  926. X        if (cmdFlag) {
  927. X            upper = ascii;
  928. X            if ( (upper >= 'a') && (upper <= 'z') )
  929. X                upper = 'A' + (upper - 'a');
  930. X            if ( (upper >= '@') && (upper <= '_') )
  931. X                ascii = upper - '@';
  932. X        }
  933. X        
  934. X        PushQueue(keycode, modifiers, ascii, 0, 0);
  935. X        
  936. X    }
  937. X        
  938. X    return;
  939. X}
  940. X
  941. Xstatic void DoUpdate(whichWindow)
  942. XWindowPtr whichWindow;
  943. X
  944. X{
  945. X    if (whichWindow == theScreen.window) {
  946. X        UpdateScreen();
  947. X    }
  948. X    
  949. X    return;
  950. X}
  951. X
  952. Xstatic void DoActivate(whichWindow, activated)
  953. XWindowPtr whichWindow;
  954. XBoolean activated;
  955. X
  956. X{
  957. X    MenuHandle menu;
  958. X    
  959. X    menu = GetMHandle(theScreen.cmdKeyFlag ? editID1 : editID2);
  960. X    
  961. X    if (whichWindow == theScreen.window) {
  962. X    
  963. X        if (activated) {
  964. X            DisableItem(menu, undoItem);
  965. X            DisableItem(menu, cutItem);
  966. X            DisableItem(menu, copyItem);
  967. X            DisableItem(menu, pasteItem);
  968. X            DisableItem(menu, clearItem);
  969. X            ShowControl(theScreen.vScrollHandle);
  970. X            ShowControl(theScreen.hScrollHandle);
  971. X            DrawGrowIcon(whichWindow);
  972. X        }
  973. X        else {
  974. X            EnableItem(menu, undoItem);
  975. X            EnableItem(menu, cutItem);
  976. X            EnableItem(menu, copyItem);
  977. X            EnableItem(menu, pasteItem);
  978. X            EnableItem(menu, clearItem);
  979. X            HideControl(theScreen.vScrollHandle);
  980. X            HideControl(theScreen.hScrollHandle);
  981. X            DrawGrowIcon(whichWindow);
  982. X        }
  983. X    }
  984. X    
  985. X    return;
  986. X}
  987. X
  988. Xstatic void InvalScreenRect(d, r)
  989. Xint d;
  990. XRect *r;
  991. X
  992. X{
  993. X    register int v;
  994. X    register short *left, *right;
  995. X    short rl, rt, rr, rb;
  996. X    
  997. X    if (d) {
  998. X    
  999. X        rl = r->left;
  1000. X        rt = r->top;
  1001. X        rr = r->right;
  1002. X        rb = r->bottom;
  1003. X        
  1004. X        left = *theScreen.updLeft + rt;
  1005. X        right = *theScreen.updRight + rt;
  1006. X        
  1007. X        for (v = rt; v < rb; v++, left++, right++) {
  1008. X            if (rl < *left) *left = rl;
  1009. X            if (rr > *right) *right = rr;
  1010. X        }
  1011. X        
  1012. X    }
  1013. X    
  1014. X    else {
  1015. X    
  1016. X        r->left *= theScreen.charPDims.h;
  1017. X        r->right *= theScreen.charPDims.h;
  1018. X        r->top *= theScreen.charPDims.v;
  1019. X        r->bottom *= theScreen.charPDims.v;
  1020. X    
  1021. X        SetOrigin(theScreen.origin.h, theScreen.origin.v);
  1022. X        InvalRect(r);
  1023. X        SetOrigin(0, 0);
  1024. X        
  1025. X    }
  1026. X    
  1027. X    return;
  1028. X}
  1029. X
  1030. Xstatic void InvalCursor(d)
  1031. Xint d;
  1032. X
  1033. X{
  1034. X    Rect curs;
  1035. X    
  1036. X    curs.left = curs.right = theScreen.cursor.h;
  1037. X    curs.top = curs.bottom = theScreen.cursor.v;
  1038. X    curs.right += 1;
  1039. X    curs.bottom += 1;
  1040. X    
  1041. X    if (d)
  1042. X        InvalScreenRect(d, &curs);
  1043. X    
  1044. X    else {
  1045. X    
  1046. X        curs.left *= theScreen.charPDims.h;
  1047. X        curs.right *= theScreen.charPDims.h;
  1048. X        curs.top = curs.bottom = curs.bottom * theScreen.charPDims.v;
  1049. X        curs.top -= theScreen.cursorLines;
  1050. X        
  1051. X        SetOrigin(theScreen.origin.h, theScreen.origin.v);
  1052. X        InvalRect(&curs);
  1053. X        SetOrigin(0, 0);
  1054. X        
  1055. X    }
  1056. X    
  1057. X    return;
  1058. X}
  1059. X
  1060. Xvoid XSetScreenChar(d, c, h, v)
  1061. Xint d;
  1062. Xchar c;
  1063. Xint h, v;
  1064. X
  1065. X{
  1066. X    int loc;
  1067. X    Rect area;
  1068. X    Point pos;
  1069. X    
  1070. X    pos.h = h;
  1071. X    pos.v = v;
  1072. X
  1073. X    if (PtInRect(pos, &theScreen.scrnCRect)) {
  1074. X
  1075. X        loc = v * theScreen.scrnCDims.h + h;
  1076. X        (*theScreen.chars)[loc] = c;
  1077. X    
  1078. X        area.left = area.right = h;
  1079. X        area.right += 1;
  1080. X        area.top = area.bottom = v;
  1081. X        area.bottom += 1;
  1082. X    
  1083. X        InvalScreenRect(d, &area);
  1084. X
  1085. X    }
  1086. X
  1087. X    return;
  1088. X}
  1089. X
  1090. Xvoid XSetScreenBuffer(d, c, row, bounds, h, v)
  1091. Xint d;
  1092. Xchar *c;
  1093. Xint row;
  1094. XRect *bounds;
  1095. Xint h, v;
  1096. X
  1097. X{
  1098. X    int i;
  1099. X    int wid;
  1100. X    int srcLoc, dstLoc;
  1101. X    char *srcC, *dstC;
  1102. X    Rect temp, area;
  1103. X
  1104. X    temp.right = temp.left = h;
  1105. X    temp.right += bounds->right - bounds->left;
  1106. X    temp.bottom = temp.top = v;
  1107. X    temp.bottom += bounds->bottom - bounds->top;
  1108. X
  1109. X    if (SectRect(&temp, &theScreen.scrnCRect, &area)) {
  1110. X
  1111. X        srcLoc = (area.top + bounds->top - v) * row +
  1112. X             (area.left + bounds->left - h);
  1113. X        dstLoc = area.top * theScreen.scrnCDims.h + area.left;
  1114. X    
  1115. X        srcC = c + srcLoc;
  1116. X        dstC = *theScreen.chars + dstLoc;
  1117. X    
  1118. X        wid = area.right - area.left;
  1119. X    
  1120. X        if ( (wid == row) && (wid == theScreen.scrnCDims.h) ) {
  1121. X            wid *= (area.bottom - area.top);
  1122. X            memcpy(dstC, srcC, wid);
  1123. X        }
  1124. X
  1125. X        else {
  1126. X        
  1127. X            for (i = area.top; i < area.bottom; i++) {
  1128. X                memcpy(dstC, srcC, wid);
  1129. X                srcC += row;
  1130. X                dstC += theScreen.scrnCDims.h;
  1131. X            }
  1132. X            
  1133. X        }
  1134. X    
  1135. X        InvalScreenRect(d, &area);
  1136. X
  1137. X    }
  1138. X
  1139. X    return;
  1140. X}
  1141. X
  1142. Xvoid XSetScreenString(d, s, h, v)
  1143. Xint d;
  1144. Xchar *s;
  1145. Xint h, v;
  1146. X
  1147. X{
  1148. X    Rect bounds;
  1149. X
  1150. X    bounds.left = 0;
  1151. X    bounds.right = strlen(s);
  1152. X    bounds.top = 0;
  1153. X    bounds.bottom = 1;
  1154. X
  1155. X    XSetScreenBuffer(d, s, bounds.right, &bounds, h, v);
  1156. X
  1157. X    return;
  1158. X}
  1159. X
  1160. Xvoid XSetScreenCharAttr(d, c, a, h, v)
  1161. Xint d;
  1162. Xchar c;
  1163. Xchar a;
  1164. Xint h, v;
  1165. X
  1166. X{
  1167. X    int loc;
  1168. X    Rect area;
  1169. X    Point pos;
  1170. X    
  1171. X    pos.h = h;
  1172. X    pos.v = v;
  1173. X
  1174. X    if (PtInRect(pos, &theScreen.scrnCRect)) {
  1175. X
  1176. X        loc = v * theScreen.scrnCDims.h + h;
  1177. X        (*theScreen.chars)[loc] = c;
  1178. X        (*theScreen.attrs)[loc] = a;
  1179. X    
  1180. X        area.left = area.right = h;
  1181. X        area.right += 1;
  1182. X        area.top = area.bottom = v;
  1183. X        area.bottom += 1;
  1184. X    
  1185. X        InvalScreenRect(d, &area);
  1186. X
  1187. X    }
  1188. X
  1189. X    return;
  1190. X}
  1191. X
  1192. Xvoid XSetScreenBufferAttr(d, c, a, row, bounds, h, v)
  1193. Xint d;
  1194. Xchar *c;
  1195. Xchar a;
  1196. Xint row;
  1197. XRect *bounds;
  1198. Xint h, v;
  1199. X
  1200. X{
  1201. X    int i;
  1202. X    int wid;
  1203. X    int srcLoc, dstLoc;
  1204. X    char *srcC, *dstC;
  1205. X    char *dstA;
  1206. X    Rect temp, area;
  1207. X
  1208. X    temp.right = temp.left = h;
  1209. X    temp.right += bounds->right - bounds->left;
  1210. X    temp.bottom = temp.top = v;
  1211. X    temp.bottom += bounds->bottom - bounds->top;
  1212. X
  1213. X    if (SectRect(&temp, &theScreen.scrnCRect, &area)) {
  1214. X
  1215. X        srcLoc = (area.top + bounds->top - v) * row +
  1216. X             (area.left + bounds->left - h);
  1217. X        dstLoc = area.top * theScreen.scrnCDims.h + area.left;
  1218. X    
  1219. X        srcC = c + srcLoc;
  1220. X        dstC = *theScreen.chars + dstLoc;
  1221. X    
  1222. X        dstA = *theScreen.attrs + dstLoc;
  1223. X    
  1224. X        wid = area.right - area.left;
  1225. X    
  1226. X        if ( (wid == row) && (wid == theScreen.scrnCDims.h) ) {
  1227. X            wid *= (area.bottom - area.top);
  1228. X            memcpy(dstC, srcC, wid);
  1229. X            memset(dstA, a, wid);
  1230. X        }
  1231. X    
  1232. X        else {
  1233. X        
  1234. X            for (i = area.top; i < area.bottom; i++) {
  1235. X                memcpy(dstC, srcC, wid);
  1236. X                memset(dstA, a, wid);
  1237. X                srcC += row;
  1238. X                dstC += theScreen.scrnCDims.h;
  1239. X                dstA += theScreen.scrnCDims.h;
  1240. X            }
  1241. X            
  1242. X        }
  1243. X    
  1244. X        InvalScreenRect(d, &area);
  1245. X
  1246. X    }
  1247. X
  1248. X    return;
  1249. X}
  1250. X
  1251. Xvoid XSetScreenStringAttr(d, s, a, h, v)
  1252. Xint d;
  1253. Xchar *s;
  1254. Xchar a;
  1255. Xint h, v;
  1256. X
  1257. X{
  1258. X    Rect bounds;
  1259. X
  1260. X    bounds.left = 0;
  1261. X    bounds.right = strlen(s);
  1262. X    bounds.top = 0;
  1263. X    bounds.bottom = 1;
  1264. X
  1265. X    XSetScreenBufferAttr(d, s, a, bounds.right, &bounds, h, v);
  1266. X
  1267. X    return;
  1268. X}
  1269. X
  1270. Xvoid XSetScreenImage(d, c, a, row, bounds, h, v)
  1271. Xint d;
  1272. Xchar *c;
  1273. Xchar *a;
  1274. Xint row;
  1275. XRect *bounds;
  1276. Xint h, v;
  1277. X
  1278. X{
  1279. X    int i;
  1280. X    int wid;
  1281. X    int srcLoc, dstLoc;
  1282. X    char *srcC, *dstC;
  1283. X    char *srcA, *dstA;
  1284. X    Rect temp, area;
  1285. X
  1286. X    temp.right = temp.left = h;
  1287. X    temp.right += bounds->right - bounds->left;
  1288. X    temp.bottom = temp.top = v;
  1289. X    temp.bottom += bounds->bottom - bounds->top;
  1290. X
  1291. X    if (SectRect(&temp, &theScreen.scrnCRect, &area)) {
  1292. X
  1293. X        srcLoc = (area.top + bounds->top - v) * row +
  1294. X             (area.left + bounds->left - h);
  1295. X        dstLoc = area.top * theScreen.scrnCDims.h + area.left;
  1296. X    
  1297. X        srcC = c + srcLoc;
  1298. X        dstC = *theScreen.chars + dstLoc;
  1299. X    
  1300. X        srcA = a + srcLoc;
  1301. X        dstA = *theScreen.attrs + dstLoc;
  1302. X    
  1303. X        wid = area.right - area.left;
  1304. X    
  1305. X        if ( (wid == row) && (wid == theScreen.scrnCDims.h) ) {
  1306. X            wid *= (area.bottom - area.top);
  1307. X            memcpy(dstC, srcC, wid);
  1308. X            memcpy(dstA, srcA, wid);
  1309. X        }
  1310. X    
  1311. X        else {
  1312. X        
  1313. X            for (i = area.top; i < area.bottom; i++) {
  1314. X                memcpy(dstC, srcC, wid);
  1315. X                memcpy(dstA, srcA, wid);
  1316. X                srcC += row;
  1317. X                srcA += row;
  1318. X                dstC += theScreen.scrnCDims.h;
  1319. X                dstA += theScreen.scrnCDims.h;
  1320. X            }
  1321. X            
  1322. X        }
  1323. X    
  1324. X        InvalScreenRect(d, &area);
  1325. X
  1326. X    }
  1327. X
  1328. X    return;
  1329. X}
  1330. X
  1331. Xvoid XWriteScreenChar(d, c)
  1332. Xint d;
  1333. Xchar c;
  1334. X
  1335. X{
  1336. X    InvalCursor(d);
  1337. X    
  1338. X    XSetScreenChar(d, c, theScreen.cursor.h, theScreen.cursor.v);
  1339. X    theScreen.cursor.h++;
  1340. X    
  1341. X    InvalCursor(d);
  1342. X    
  1343. X    return;
  1344. X}
  1345. X
  1346. Xvoid XWriteScreenBuffer(d, c, row, bounds)
  1347. Xint d;
  1348. Xchar *c;
  1349. Xint row;
  1350. XRect *bounds;
  1351. X
  1352. X{
  1353. X    XSetScreenBuffer(d, c, row, bounds, theScreen.cursor.h, theScreen.cursor.v);
  1354. X    theScreen.cursor.h += bounds->right - bounds->left;
  1355. X    theScreen.cursor.v += bounds->bottom - bounds->top;
  1356. X    
  1357. X    InvalCursor(d);
  1358. X    
  1359. X    return;
  1360. X}
  1361. X
  1362. Xvoid XWriteScreenString(d, s)
  1363. Xint d;
  1364. Xchar *s;
  1365. X
  1366. X{
  1367. X    XSetScreenString(d, s, theScreen.cursor.h, theScreen.cursor.v);
  1368. X    theScreen.cursor.h += strlen(s);
  1369. X    
  1370. X    InvalCursor(d);
  1371. X    
  1372. X    return;
  1373. X}
  1374. X
  1375. Xvoid XWriteScreenCharAttr(d, c, a)
  1376. Xint d;
  1377. Xchar c;
  1378. Xchar a;
  1379. X
  1380. X{
  1381. X    XSetScreenCharAttr(d, c, a, theScreen.cursor.h, theScreen.cursor.v);
  1382. X    theScreen.cursor.h++;
  1383. X
  1384. X    InvalCursor(d);
  1385. X    
  1386. X    return;
  1387. X}
  1388. X
  1389. Xvoid XWriteScreenBufferAttr(d, c, a, row, bounds)
  1390. Xint d;
  1391. Xchar *c;
  1392. Xchar a;
  1393. Xint row;
  1394. XRect *bounds;
  1395. X
  1396. X{
  1397. X    XSetScreenBufferAttr(d, c, a, row, bounds, theScreen.cursor.h, theScreen.cursor.v);
  1398. X    theScreen.cursor.h += bounds->right - bounds->left;
  1399. X    theScreen.cursor.v += bounds->bottom - bounds->top;
  1400. X    
  1401. X    InvalCursor(d);
  1402. X    
  1403. X    return;
  1404. X}
  1405. X
  1406. Xvoid XWriteScreenStringAttr(d, s, a)
  1407. Xint d;
  1408. Xchar *s;
  1409. Xchar a;
  1410. X
  1411. X{
  1412. X    XSetScreenStringAttr(d, s, a, theScreen.cursor.h, theScreen.cursor.v);
  1413. X    theScreen.cursor.h += strlen(s);
  1414. X    
  1415. X    InvalCursor(d);
  1416. X    
  1417. X    return;
  1418. X}
  1419. X
  1420. Xvoid XWriteScreenImage(d, c, a, row, bounds)
  1421. Xint d;
  1422. Xchar *c;
  1423. Xchar *a;
  1424. Xint row;
  1425. XRect *bounds;
  1426. X
  1427. X{
  1428. X    XSetScreenImage(d, c, a, row, bounds, theScreen.cursor.h, theScreen.cursor.v);
  1429. X    theScreen.cursor.h += bounds->right - bounds->left;
  1430. X    theScreen.cursor.v += bounds->bottom - bounds->top;
  1431. X    
  1432. X    InvalCursor(d);
  1433. X    
  1434. X    return;
  1435. X}
  1436. X
  1437. Xvoid XFillScreen(d, c, a, bounds)
  1438. Xint d;
  1439. Xchar c;
  1440. Xchar a;
  1441. XRect *bounds;
  1442. X
  1443. X{
  1444. X    int i;
  1445. X    int wid;
  1446. X    int dstLoc;
  1447. X    char *dstC;
  1448. X    char *dstA;
  1449. X    Rect area;
  1450. X
  1451. X    if (SectRect(bounds, &theScreen.scrnCRect, &area)) {
  1452. X
  1453. X        dstLoc = area.top * theScreen.scrnCDims.h + area.left;
  1454. X    
  1455. X        dstC = *theScreen.chars + dstLoc;
  1456. X    
  1457. X        dstA = *theScreen.attrs + dstLoc;
  1458. X    
  1459. X        wid = area.right - area.left;
  1460. X    
  1461. X        if (wid == theScreen.scrnCDims.h) {
  1462. X            wid *= (area.bottom - area.top);
  1463. X            memset(dstC, c, wid);
  1464. X            memset(dstA, a, wid);
  1465. X        }
  1466. X    
  1467. X        else {
  1468. X        
  1469. X            for (i = area.top; i < area.bottom; i++) {
  1470. X                memset(dstC, c, wid);
  1471. X                memset(dstA, a, wid);
  1472. X                dstC += theScreen.scrnCDims.h;
  1473. X                dstA += theScreen.scrnCDims.h;
  1474. X            }
  1475. X            
  1476. X        }
  1477. X    
  1478. X        InvalScreenRect(d, &area);
  1479. X
  1480. X    }
  1481. X
  1482. X    return;
  1483. X}
  1484. X
  1485. Xvoid XEraseScreen(d, bounds)
  1486. Xint d;
  1487. XRect *bounds;
  1488. X
  1489. X{
  1490. X    XFillScreen(d, ' ', attrNormal, bounds);
  1491. X    return;
  1492. X}
  1493. X
  1494. Xstatic void ScrollScreenPositive(area, offset, factor)
  1495. XRect *area;
  1496. Xint offset;
  1497. Xint factor;
  1498. X
  1499. X{
  1500. X    int i, j;
  1501. X    int loc;
  1502. X    int nxt;
  1503. X    char *srcc, *dstc;
  1504. X    char *srca, *dsta;
  1505. X
  1506. X    loc = (area->bottom - 1) * theScreen.scrnCDims.h + area->right - 1;
  1507. X
  1508. X    dstc = *theScreen.chars + loc;
  1509. X    srcc = dstc - offset * factor;
  1510. X
  1511. X    dsta = *theScreen.attrs + loc;
  1512. X    srca = dsta - offset * factor;
  1513. X
  1514. X    nxt = theScreen.scrnCDims.h - (area->right - area->left);
  1515. X
  1516. X    for (j = area->bottom; j > area->top; j--) {
  1517. X        for (i = area->right; i > area->left; i--) {
  1518. X            *dstc-- = *srcc--;
  1519. X            *dsta-- = *srca--;
  1520. X        }
  1521. X        srcc -= nxt;
  1522. X        dstc -= nxt;
  1523. X        srca -= nxt;
  1524. X        dsta -= nxt;
  1525. X    }
  1526. X
  1527. X    return;
  1528. X}
  1529. X
  1530. Xstatic void ScrollScreenNegative(area, offset, factor)
  1531. XRect *area;
  1532. Xint offset;
  1533. Xint factor;
  1534. X
  1535. X{
  1536. X    int i, j;
  1537. X    int loc;
  1538. X    int nxt;
  1539. X    char *srcc, *dstc;
  1540. X    char *srca, *dsta;
  1541. X
  1542. X    loc = area->top * theScreen.scrnCDims.h + area->left;
  1543. X
  1544. X    dstc = *theScreen.chars + loc;
  1545. X    srcc = dstc - offset * factor;
  1546. X
  1547. X    dsta = *theScreen.chars + loc;
  1548. X    srca = dsta - offset * factor;
  1549. X
  1550. X    nxt = theScreen.scrnCDims.h - (area->right - area->left);
  1551. X
  1552. X    for (j = area->top; j < area->bottom; j++) {
  1553. X        for (i = area->left; i < area->right; i++) {
  1554. X            *dstc++ = *srcc++;
  1555. X            *dsta++ = *srca++;
  1556. X        }
  1557. X        srcc += nxt;
  1558. X        dstc += nxt;
  1559. X        srca += nxt;
  1560. X        dsta += nxt;
  1561. X    }
  1562. X
  1563. X    return;
  1564. X}
  1565. X
  1566. Xvoid XScrollScreen(d, dh, dv, bounds, attr)
  1567. Xint d;
  1568. Xint dh, dv;
  1569. XRect *bounds;
  1570. Xchar attr;
  1571. X
  1572. X{
  1573. X    int wid, dep;
  1574. X    Rect area, clear;
  1575. X
  1576. X    if (!dh && !dv) return;
  1577. X
  1578. X    if (SectRect(bounds, &theScreen.scrnCRect, &area)) {
  1579. X
  1580. X        wid = area.right - area.left;
  1581. X        dep = area.bottom - area.top;
  1582. X
  1583. X        if ( (ABS(dh) >= wid) || (ABS(dv) >= dep) )
  1584. X    
  1585. X            XFillScreen(d, ' ', attr, &area);
  1586. X    
  1587. X        else {
  1588. X    
  1589. X            if (dv > 0) {
  1590. X                clear = area;
  1591. X                clear.bottom = area.top += dv;
  1592. X                ScrollScreenPositive(&area, dv, theScreen.scrnCDims.h);
  1593. X                XFillScreen(d, ' ', attr, &clear);
  1594. X            }
  1595. X    
  1596. X            else if (dv < 0) {
  1597. X                clear = area;
  1598. X                clear.top = area.bottom += dv;
  1599. X                ScrollScreenNegative(&area, dv, theScreen.scrnCDims.h);
  1600. X                XFillScreen(d, ' ', attr, &clear);
  1601. X            }
  1602. X    
  1603. X            if (dh > 0) {
  1604. X                clear = area;
  1605. X                clear.right = area.left += dh;
  1606. X                ScrollScreenPositive(&area, dh, 1);
  1607. X                XFillScreen(d, ' ', attr, &clear);
  1608. X            }
  1609. X    
  1610. X            else if (dh < 0) {
  1611. X                clear = area;
  1612. X                clear.left = area.right += dh;
  1613. X                ScrollScreenNegative(&area, dh, 1);
  1614. X                XFillScreen(d, ' ', attr, &clear);
  1615. X            }
  1616. X    
  1617. X            InvalScreenRect(d, &area);
  1618. X    
  1619. X        }
  1620. X
  1621. X    }
  1622. X
  1623. X    return;
  1624. X}
  1625. X
  1626. Xvoid GetScreenCharAttr(c, a, h, v)
  1627. Xchar *c;
  1628. Xchar *a;
  1629. Xint h, v;
  1630. X
  1631. X{
  1632. X    int loc;
  1633. X    Point pos;
  1634. X    
  1635. X    pos.h = h;
  1636. X    pos.v = v;
  1637. X
  1638. X    if (PtInRect(pos, &theScreen.scrnCRect)) {
  1639. X
  1640. X        loc = v * theScreen.scrnCDims.h + h;
  1641. X        *c = (*theScreen.chars)[loc];
  1642. X        *a = (*theScreen.attrs)[loc];
  1643. X
  1644. X    }
  1645. X
  1646. X    return;
  1647. X}
  1648. X
  1649. Xvoid GetScreenImage(c, a, row, bounds, h, v)
  1650. Xchar *c;
  1651. Xchar *a;
  1652. Xint row;
  1653. XRect *bounds;
  1654. Xint h, v;
  1655. X
  1656. X{
  1657. X    int i;
  1658. X    int wid;
  1659. X    int srcLoc, dstLoc;
  1660. X    char *srcC, *dstC;
  1661. X    char *srcA, *dstA;
  1662. X    Rect temp, area;
  1663. X
  1664. X    temp.right = temp.left = h;
  1665. X    temp.right += bounds->right - bounds->left;
  1666. X    temp.bottom = temp.top = v;
  1667. X    temp.bottom += bounds->bottom - bounds->top;
  1668. X
  1669. X    if (SectRect(&temp, &theScreen.scrnCRect, &area)) {
  1670. X
  1671. X        dstLoc = (area.top + bounds->top - v) * row +
  1672. X             (area.left + bounds->left - h);
  1673. X        srcLoc = area.top * theScreen.scrnCDims.h + area.left;
  1674. X    
  1675. X        dstC = c + dstLoc;
  1676. X        srcC = *theScreen.chars + srcLoc;
  1677. X    
  1678. X        dstA = a + dstLoc;
  1679. X        srcA = *theScreen.attrs + srcLoc;
  1680. X    
  1681. X        wid = area.right - area.left;
  1682. X    
  1683. X        if ( (wid == row) && (wid == theScreen.scrnCDims.h) ) {
  1684. X            wid *= (area.bottom - area.top);
  1685. X            memcpy(dstC, srcC, wid);
  1686. X            memcpy(dstA, srcA, wid);
  1687. X        }
  1688. X    
  1689. X        else {
  1690. X        
  1691. X            for (i = area.top; i < area.bottom; i++) {
  1692. X                memcpy(dstC, srcC, wid);
  1693. X                memcpy(dstA, srcA, wid);
  1694. X                dstC += row;
  1695. X                dstA += row;
  1696. X                srcC += theScreen.scrnCDims.h;
  1697. X                srcA += theScreen.scrnCDims.h;
  1698. X            }
  1699. X            
  1700. X        }
  1701. X    
  1702. X    }
  1703. X
  1704. X    return;
  1705. X}
  1706. X
  1707. Xvoid XMoveScreenCursor(d, h, v)
  1708. Xint d;
  1709. Xint h, v;
  1710. X
  1711. X{
  1712. X    InvalCursor(d);
  1713. X    
  1714. X    theScreen.cursor.h += h;
  1715. X    theScreen.cursor.v += v;
  1716. X    
  1717. X    InvalCursor(d);
  1718. X    
  1719. X    return;
  1720. X}
  1721. X
  1722. Xvoid XSetScreenCursor(d, h, v)
  1723. Xint d;
  1724. Xint h, v;
  1725. X
  1726. X{
  1727. X    InvalCursor(d);
  1728. X    
  1729. X    theScreen.cursor.h = h;
  1730. X    theScreen.cursor.v = v;
  1731. X    
  1732. X    InvalCursor(d);
  1733. X    
  1734. X    return;
  1735. X}
  1736. X
  1737. Xvoid GetScreenCursor(h, v)
  1738. Xint *h, *v;
  1739. X{
  1740. X    *h = theScreen.cursor.h;
  1741. X    *v = theScreen.cursor.v;
  1742. X    return;
  1743. X}
  1744. X
  1745. Xstatic int CheckCursorStatus()
  1746. X
  1747. X{
  1748. X    int oldStatus;
  1749. X    int changed;
  1750. X    
  1751. X    oldStatus = theScreen.cursorStatus;
  1752. X    
  1753. X    if (theScreen.cursorLevel <= 0)
  1754. X        theScreen.cursorStatus = 0;
  1755. X    else if (!theScreen.cursorBlink)
  1756. X        theScreen.cursorStatus = 1;
  1757. X    else if (theScreen.cursorChangeTick <= TickCount())
  1758. X        theScreen.cursorStatus = !oldStatus;
  1759. X        
  1760. X    changed = theScreen.cursorStatus != oldStatus;
  1761. X    
  1762. X    if (changed) {
  1763. X        theScreen.cursorChangeTick = TickCount() + theScreen.cursorBlink;
  1764. X        InvalCursor(0);
  1765. X    }
  1766. X    
  1767. X    return(changed);
  1768. X}
  1769. X
  1770. Xstatic void InvalDelayed()
  1771. X
  1772. X{
  1773. X    int v;
  1774. X    short *left, *right;
  1775. X    Rect inval;
  1776. X    
  1777. X    v = 0;
  1778. X    left = *theScreen.updLeft;
  1779. X    right = *theScreen.updRight;
  1780. X    
  1781. X    while (v < theScreen.scrnCDims.v) {
  1782. X    
  1783. X        if (!*right) {
  1784. X        
  1785. X            v++;
  1786. X            left++;
  1787. X            right++;
  1788. X            
  1789. X        }
  1790. X        
  1791. X        else {
  1792. X        
  1793. X            inval.top = v;
  1794. X            inval.left = *left;
  1795. X            inval.right = *right;
  1796. X            
  1797. X            do {
  1798. X                v++;
  1799. X                *left++ = theScreen.scrnCDims.h;
  1800. X                *right++ = 0;
  1801. X            } while ( (v < theScreen.scrnCDims.v) &&
  1802. X                      (*left == inval.left)         &&
  1803. X                      (*right == inval.right)        );
  1804. X                      
  1805. X            inval.bottom = v;
  1806. X            
  1807. X            InvalScreenRect(0, &inval);
  1808. X            
  1809. X            left = *theScreen.updLeft + v;
  1810. X            right = *theScreen.updRight + v;
  1811. X            
  1812. X        }
  1813. X        
  1814. X    }
  1815. X    
  1816. X    return;
  1817. X    
  1818. X}
  1819. X
  1820. Xstatic void UpdateScreenLine(area, c, a, len)
  1821. XRect *area;
  1822. Xchar *c;
  1823. Xchar *a;
  1824. Xint len;
  1825. X
  1826. X{
  1827. X    int count;
  1828. X    char attr;
  1829. X    char *last, *prev;
  1830. X    short face;
  1831. X    Rect temp;
  1832. X    
  1833. X    temp = *area;
  1834. X
  1835. X    last = a + len;
  1836. X
  1837. X    while (a < last) {
  1838. X
  1839. X        attr = *a;
  1840. X    
  1841. X        prev = a;
  1842. X        while ( (a < last) && (*a == attr) ) a++;
  1843. X        count = a - prev;
  1844. X        
  1845. X        temp.right = temp.left + count * theScreen.charPDims.h;
  1846. X        
  1847. X        face = normal;
  1848. X        if (attr & attrUnderlined) face |= underline;
  1849. X        if (attr & attrItalicized) face |= italic;
  1850. X        TextFace(face);
  1851. X        
  1852. X        if (theScreen.colorFlag) {
  1853. X            ForeColor(colors[AttrFore(attr)]);
  1854. X            BackColor(colors[AttrBack(attr)]);
  1855. X        }
  1856. X        else {
  1857. X            ForeColor(
  1858. X                colors[
  1859. X                    (AttrFore(attr) == attrColorBack) ?
  1860. X                        theScreen.colorStdBack : theScreen.colorStdFore]);
  1861. X            BackColor(
  1862. X                colors[
  1863. X                    (AttrBack(attr) == attrColorBack) ?
  1864. X                        theScreen.colorStdBack : theScreen.colorStdFore]);
  1865. X        }
  1866. X        
  1867. X        EraseRect(&temp);
  1868. X        
  1869. X        DrawText(c, 0, count);
  1870. X        
  1871. X        temp.left = temp.right;
  1872. X    
  1873. X        c += count;
  1874. X
  1875. X    }
  1876. X
  1877. X    return;
  1878. X}
  1879. X
  1880. Xvoid UpdateScreen()
  1881. X
  1882. X{
  1883. X    int j;
  1884. X    int top, dep, left, wid;
  1885. X    Rect clear, area, curs;
  1886. X    RgnHandle vis;
  1887. X    char *c, *a;
  1888. X    int cursorLoc;
  1889. X    
  1890. X    InvalDelayed();
  1891. X
  1892. X    BeginUpdate(theScreen.window);
  1893. X    
  1894. X    SetOrigin(theScreen.origin.h, theScreen.origin.v);
  1895. X    
  1896. X    ClipRect(&theScreen.picLRect);
  1897. X    
  1898. X    if (!theScreen.colorFlag)
  1899. X        BackColor(colors[theScreen.colorStdBack]);
  1900. X    
  1901. X    if (theScreen.picLRect.top < theScreen.scrnLRect.top) {
  1902. X        clear = theScreen.picLRect;
  1903. X        clear.bottom = theScreen.scrnLRect.top;
  1904. X        EraseRect(&clear);
  1905. X    }
  1906. X    
  1907. X    if (theScreen.picLRect.left < theScreen.scrnLRect.left) {
  1908. X        clear = theScreen.picLRect;
  1909. X        clear.right = theScreen.scrnLRect.left;
  1910. X        EraseRect(&clear);
  1911. X    }
  1912. X    
  1913. X    if (theScreen.picLRect.right > theScreen.scrnLRect.right) {
  1914. X        clear = theScreen.picLRect;
  1915. X        clear.left = theScreen.scrnLRect.right;
  1916. X        EraseRect(&clear);
  1917. X    }
  1918. X    
  1919. X    if (theScreen.picLRect.bottom > theScreen.scrnLRect.bottom) {
  1920. X        clear = theScreen.picLRect;
  1921. X        clear.top = theScreen.scrnLRect.bottom;
  1922. X        EraseRect(&clear);
  1923. X    }
  1924. X    
  1925. X    ClipRect(&theScreen.drawLRect);
  1926. X    
  1927. X    vis = theScreen.window->visRgn;
  1928. X             
  1929. X    top = theScreen.drawXCRect.top;
  1930. X    dep = theScreen.drawXCRect.bottom - top;
  1931. X    
  1932. X    left = theScreen.drawXCRect.left;
  1933. X    wid = theScreen.drawXCRect.right - left;
  1934. X    
  1935. X    HLock((Handle) theScreen.chars);
  1936. X    HLock((Handle) theScreen.attrs);
  1937. X
  1938. X    c = *theScreen.chars + top * theScreen.scrnCDims.h + left;
  1939. X    a = *theScreen.attrs + top * theScreen.scrnCDims.h + left;
  1940. X    
  1941. X    area = theScreen.drawXLRect;
  1942. X    area.bottom = area.top + theScreen.charPDims.v;
  1943. X
  1944. X    for (j = 0; j < dep; j++) {
  1945. X    
  1946. X        if (RectInRgn(&area, vis)) {
  1947. X            MoveTo(area.left, area.top + theScreen.info.ascent);
  1948. X            UpdateScreenLine(&area, c, a, wid);
  1949. X        }
  1950. X    
  1951. X        area.top = area.bottom;
  1952. X        area.bottom += theScreen.charPDims.v;
  1953. X    
  1954. X        c += theScreen.scrnCDims.h;
  1955. X        a += theScreen.scrnCDims.h;
  1956. X
  1957. X    }
  1958. X
  1959. X    HUnlock((Handle) theScreen.chars);
  1960. X    HUnlock((Handle) theScreen.attrs);
  1961. X    
  1962. X    if (theScreen.cursorStatus) {
  1963. X        curs.left = curs.right = theScreen.cursor.h * theScreen.charPDims.h;
  1964. X        curs.right += theScreen.charPDims.h;
  1965. X        curs.bottom = curs.top = (theScreen.cursor.v + 1) * theScreen.charPDims.v;
  1966. X        if (theScreen.cursorLines <= theScreen.charPDims.v)
  1967. X            curs.top -= theScreen.cursorLines;
  1968. X        else
  1969. X            curs.top -= theScreen.charPDims.v;
  1970. X        if (theScreen.colorFlag)
  1971. X            BackColor(colors[theScreen.cursorColor]);
  1972. X        else {
  1973. X            cursorLoc = theScreen.cursor.v * theScreen.scrnCDims.h + theScreen.cursor.h;
  1974. X            BackColor(
  1975. X                colors[
  1976. X                    (AttrFore((*theScreen.attrs)[cursorLoc]) == attrColorBack) ?
  1977. X                        theScreen.colorStdBack : theScreen.colorStdFore]);
  1978. X        }
  1979. X        EraseRect(&curs);
  1980. X    }
  1981. X
  1982. X    SetOrigin(0, 0);
  1983. X    
  1984. X    TextFace(normal);
  1985. X    
  1986. X    ForeColor(blackColor);
  1987. X    BackColor(whiteColor);
  1988. X
  1989. X    MoveTo(0, 0);
  1990. X    
  1991. X    ClipRect(&theScreen.window->portRect);
  1992. X    
  1993. X    UpdtControl(theScreen.window, theScreen.window->visRgn);
  1994. X    DrawGrowIcon(theScreen.window);
  1995. X    
  1996. X    EndUpdate(theScreen.window);
  1997. X
  1998. X    return;
  1999. X}
  2000. X
  2001. Xvoid IdleScreenMgr()
  2002. X
  2003. X{
  2004. X    int more;
  2005. X    short mask;
  2006. X    
  2007. X    do {
  2008. X        
  2009. X        mask = everyEvent;
  2010. X        if (theScreen.waitFlag) {
  2011. X            mask -= mDownMask;
  2012. X            mask -= keyDownMask;
  2013. X            mask -= autoKeyMask;
  2014. X        }
  2015. X        
  2016. X        if ( (!theScreen.backgrounding) && (theScreen.window == FrontWindow()) )
  2017. X            CheckCursorStatus();
  2018. X            
  2019. X        if (theScreen.wneImplemented) {
  2020. X            more = WaitNextEvent(mask, &theScreen.event, 0, NULL);
  2021. X        }
  2022. X        else {
  2023. X            SystemTask();
  2024. X            more = GetNextEvent(mask, &theScreen.event);
  2025. X        }
  2026. X        
  2027. X        if (more)
  2028. X            switch (theScreen.event.what) {
  2029. X            
  2030. X                case mouseDown:        DoMouseDown(&theScreen.event.where);
  2031. X                                    break;
  2032. X                                    
  2033. X                case autoKey:
  2034. X                case keyDown:        if (theScreen.event.modifiers & cmdKey) {
  2035. X                                        if (theScreen.cmdKeyFlag) {
  2036. X                                            if (theScreen.event.what != autoKey)
  2037. X                                                DoMenuItem(MenuKey(theScreen.event.message & charCodeMask));
  2038. X                                        }
  2039. X                                        else
  2040. X                                            DoKeyDown(true);
  2041. X                                    }
  2042. X                                    else
  2043. X                                        DoKeyDown(false);
  2044. X                                    break;
  2045. X                                    
  2046. X                case updateEvt:        DoUpdate((WindowPtr) theScreen.event.message);
  2047. X                                    break;
  2048. X                                    
  2049. X                case activateEvt:    DoActivate((WindowPtr) theScreen.event.message,
  2050. X                                               theScreen.event.modifiers & activeFlag);
  2051. X                                    break;
  2052. X                                    
  2053. X                case osEvent:        if ((theScreen.event.message >> 24) == suspendResumeMessage) {
  2054. X                                        if (theScreen.event.message & resumeMask) {
  2055. X                                            theScreen.backgrounding = false;
  2056. X                                            DoActivate((WindowPtr) FrontWindow(), true);
  2057. X                                        }
  2058. X                                        else {
  2059. X                                            theScreen.backgrounding = true;
  2060. X                                            DoActivate((WindowPtr) FrontWindow(), false);
  2061. X                                        }
  2062. X                                    }
  2063. X                                    
  2064. X            }
  2065. X            
  2066. X    } while (more);
  2067. X        
  2068. X    return;
  2069. X}
  2070. X
  2071. Xvoid FlushScreenKeys()
  2072. X
  2073. X{
  2074. X    theScreen.keyFlush = theScreen.mouseFlush = TickCount();
  2075. X    FlushQueue();
  2076. X    return;
  2077. X}
  2078. X
  2079. Xint CountScreenKeys()
  2080. X
  2081. X{
  2082. X    return(LenQueue());
  2083. X}
  2084. X
  2085. Xint GetScreenKeys(keycode, modifiers, ascii, h, v)
  2086. Xchar *keycode;
  2087. Xchar *modifiers;
  2088. Xchar *ascii;
  2089. Xint *h;
  2090. Xint *v;
  2091. X
  2092. X{
  2093. X    int flag;
  2094. X    short th, tv;
  2095. X    
  2096. X    if (flag = PopQueue(keycode, modifiers, ascii, &th, &tv)) {
  2097. X        if (h != NULL) *h = th;
  2098. X        if (v != NULL) *v = tv;
  2099. X    }
  2100. X    
  2101. X    return(flag);
  2102. X}
  2103. X
  2104. Xvoid EnableScreenMouse(flag)
  2105. Xint flag;
  2106. X
  2107. X{
  2108. X    if ( (flag) && (!theScreen.mouseFlag) ) theScreen.mouseFlush = TickCount();
  2109. X    theScreen.mouseFlag = flag;
  2110. X    return;
  2111. X}
  2112. X
  2113. Xvoid ClipScreenMouse(area)
  2114. XRect *area;
  2115. X
  2116. X{
  2117. X    theScreen.mouseLRect = theScreen.mouseCRect = *area;
  2118. X    theScreen.mouseLRect.left *= theScreen.charPDims.h;
  2119. X    theScreen.mouseLRect.top *= theScreen.charPDims.v;
  2120. X    theScreen.mouseLRect.right *= theScreen.charPDims.h;
  2121. X    theScreen.mouseLRect.bottom *= theScreen.charPDims.v;
  2122. X    
  2123. X    return;
  2124. X}
  2125. X
  2126. Xvoid DefineScreenCursor(color, lines, blinkRate)
  2127. Xint color;
  2128. Xint lines;
  2129. Xint blinkRate;
  2130. X
  2131. X{
  2132. X    theScreen.cursorColor = color;
  2133. X    theScreen.cursorLines = lines;
  2134. X    theScreen.cursorBlink = blinkRate;
  2135. X    
  2136. X    InvalCursor(0);
  2137. X    
  2138. X    return;
  2139. X}
  2140. X
  2141. Xvoid HideScreenCursor()
  2142. X
  2143. X{
  2144. X    theScreen.cursorLevel--;
  2145. X    CheckCursorStatus();
  2146. X    return;
  2147. X}
  2148. X
  2149. Xvoid ShowScreenCursor()
  2150. X
  2151. X{
  2152. X    theScreen.cursorLevel++;
  2153. X    CheckCursorStatus();
  2154. X    return;
  2155. X}
  2156. X
  2157. Xvoid SetScreenAboutProc(procPtr)
  2158. Xvoid (*procPtr)();
  2159. X
  2160. X{
  2161. X    theScreen.aboutProc = procPtr;
  2162. X    return;
  2163. X}
  2164. X
  2165. Xvoid SetScreenQuitProc(procPtr, flag)
  2166. Xvoid (*procPtr)();
  2167. Xint flag;
  2168. X
  2169. X{
  2170. X    theScreen.quitProc = procPtr;
  2171. X    theScreen.quitReturns = flag;
  2172. X    return;
  2173. X}
  2174. X
  2175. Xint YesOrNo(text)
  2176. Xchar *text;
  2177. X
  2178. X{
  2179. X    DialogPtr theDialog;
  2180. X    short itemHit;
  2181. X    short itsType;
  2182. X    Handle itsHandle;
  2183. X    Rect itsRect;
  2184. X    Str255 ptext;
  2185. X    int h, v;
  2186. X    
  2187. X    theDialog = GetNewDialog(yesOrNoDlgID, nil, (WindowPtr) -1);
  2188. X    
  2189. X    CenterScreenDLOG(yesOrNoDlgID, fixHalf, fixThird, &h, &v);
  2190. X    MoveWindow((WindowPtr) theDialog, (short) h, (short) v, false);
  2191. X    
  2192. X    GetDItem(theDialog, ok, &itsType, &itsHandle, &itsRect);
  2193. X    InsetRect(&itsRect, -4, -4);
  2194. X    
  2195. X    SetDItem(theDialog, yesOrNoDfltBorder, userItem, (Handle) DrawDefaultBorder, &itsRect);
  2196. X    
  2197. X    if (text != NULL) {
  2198. X        strncpy(ptext, text, 255);
  2199. X        ptext[255] = '\0';
  2200. X        c2pstr(ptext);
  2201. X        GetDItem(theDialog, yesOrNoText, &itsType, &itsHandle, &itsRect);
  2202. X        SetIText(itsHandle, ptext);
  2203. X    }
  2204. X    
  2205. X    ShowWindow((WindowPtr) theDialog);
  2206. X
  2207. X    do {
  2208. X        ModalDialog(nil, &itemHit);
  2209. X    } while ( (itemHit != ok) && (itemHit != cancel) );
  2210. X
  2211. X    DisposDialog(theDialog);
  2212. X    
  2213. X    return(itemHit == ok);
  2214. X}
  2215. X
  2216. Xvoid ShowScreen(visible)
  2217. Xint visible;
  2218. X
  2219. X{
  2220. X    if (visible)
  2221. X        ShowWindow(theScreen.window);
  2222. X    else
  2223. X        HideWindow(theScreen.window);
  2224. X        
  2225. X    return;
  2226. X}
  2227. X
  2228. Xvoid GetScreenBounds(bounds)
  2229. XRect *bounds;
  2230. X
  2231. X{
  2232. X    Point mouse;
  2233. X    GDHandle gdh;
  2234. X    
  2235. X    if (!theScreen.env.hasColorQD) {
  2236. X        *bounds = qd.screenBits.bounds;
  2237. X        bounds->top += GetMBarHeight();
  2238. X    }
  2239. X        
  2240. X    else {
  2241. X    
  2242. X        *bounds = (*GetMainDevice())->gdRect;
  2243. X        
  2244. X        GetMouse(&mouse);
  2245. X        LocalToGlobal(&mouse);
  2246. X        
  2247. X        gdh = GetDeviceList();
  2248. X        
  2249. X        while (gdh != NULL) {
  2250. X        
  2251. X            if (PtInRect(mouse, &(*gdh)->gdRect)) {
  2252. X                *bounds = (*gdh)->gdRect;
  2253. X                if (gdh == GetMainDevice()) bounds->top += GetMBarHeight();
  2254. X                gdh = NULL;
  2255. X            }
  2256. X            
  2257. X            else
  2258. X                gdh = GetNextDevice(gdh);
  2259. X            
  2260. X        }
  2261. X        
  2262. X    }
  2263. X    
  2264. X    return;
  2265. X}
  2266. X
  2267. X
  2268. Xvoid CenterScreenDLOG(id, hRatio, vRatio, h, v)
  2269. Xint id;
  2270. XFixed hRatio, vRatio;
  2271. Xint *h, *v;
  2272. X
  2273. X{
  2274. X    int wid, hgt;
  2275. X    DialogTHndl d;
  2276. X    Rect bounds;
  2277. X    
  2278. X    d = (DialogTHndl) GetResource('DLOG', (short) id);
  2279. X    
  2280. X    if (d != NULL) {
  2281. X    
  2282. X        wid = (*d)->boundsRect.right - (*d)->boundsRect.left;
  2283. X        hgt = (*d)->boundsRect.bottom - (*d)->boundsRect.top;
  2284. X        
  2285. X        GetScreenBounds(&bounds);
  2286. X        
  2287. X        wid = (bounds.right - bounds.left) - wid;
  2288. X        hgt = (bounds.bottom - bounds.top) - hgt;
  2289. X        
  2290. X        *h = bounds.left + FixRound(hRatio * wid);
  2291. X        *v = bounds.top + FixRound(vRatio * hgt);
  2292. X        
  2293. X    }
  2294. X    
  2295. X    return;
  2296. X}
  2297. X
  2298. Xint DoScreenALRT(id, kind, hRatio, vRatio)
  2299. Xint id;
  2300. Xint kind;
  2301. XFixed hRatio, vRatio;
  2302. X
  2303. X{
  2304. X    int wid, hgt, h, v;
  2305. X    int item;
  2306. X    AlertTHndl a;
  2307. X    Rect bounds;
  2308. X    
  2309. X    a = (AlertTHndl) GetResource('ALRT', (short) id);
  2310. X    
  2311. X    if (a != NULL) {
  2312. X    
  2313. X        wid = (*a)->boundsRect.right - (*a)->boundsRect.left;
  2314. X        hgt = (*a)->boundsRect.bottom - (*a)->boundsRect.top;
  2315. X        
  2316. X        GetScreenBounds(&bounds);
  2317. X        
  2318. X        wid = (bounds.right - bounds.left) - wid;
  2319. X        hgt = (bounds.bottom - bounds.top) - hgt;
  2320. X        
  2321. X        h = bounds.left + FixRound(hRatio * wid) - (*a)->boundsRect.left;
  2322. X        v = bounds.top + FixRound(vRatio * hgt) - (*a)->boundsRect.top;
  2323. X        
  2324. X        OffsetRect(&(*a)->boundsRect, (short) h, (short) v);
  2325. X        
  2326. X        MoveHHi((Handle) a);
  2327. X        HLock((Handle) a);
  2328. X        
  2329. X        switch (kind) {
  2330. X            case akNormal:        item = Alert((short) id, NULL);            break;
  2331. X            case akStop:        item = StopAlert((short) id, NULL);        break;
  2332. X            case akNote:        item = NoteAlert((short) id, NULL);        break;
  2333. X            case akCaution:        item = CautionAlert((short) id, NULL);    break;
  2334. X        }
  2335. X        
  2336. X        HUnlock((Handle) a);
  2337. X        
  2338. X    }
  2339. X    
  2340. X    else
  2341. X    
  2342. X        item = -1;
  2343. X        
  2344. X    return(item);
  2345. X}
  2346. X
  2347. Xvoid ConfigScreenMgr(force, theType, theID, ConfigProc)
  2348. Xint force;
  2349. XResType theType;
  2350. Xint theID;
  2351. Xint (*ConfigProc)(Handle theData);
  2352. X
  2353. X{
  2354. X    short saveResFile, homeResFile;
  2355. X    short attrs;
  2356. X    short itsID;
  2357. X    ResType itsType;
  2358. X    Str255 itsName;
  2359. X    Handle theData;
  2360. X    
  2361. X    saveResFile = CurResFile();
  2362. X    UseResFile(theScreen.infoResFile);
  2363. X    
  2364. X    theData = GetResource(theType, (short) theID);
  2365. X    
  2366. X    if (theData != NULL) {
  2367. X    
  2368. X        homeResFile = HomeResFile(theData);
  2369. X        
  2370. X        if ( (theScreen.reconfigFlag) ||
  2371. X                (force) ||
  2372. X                (homeResFile != theScreen.infoResFile) ) {
  2373. X        
  2374. X            if ((*ConfigProc)(theData)) {
  2375. X            
  2376. X                if (homeResFile != theScreen.infoResFile) {
  2377. X                    GetResInfo(theData, &itsID, &itsType, itsName);
  2378. X                    attrs = GetResAttrs(theData);
  2379. X                    attrs |= resChanged;
  2380. X                    DetachResource(theData);
  2381. X                    AddResource(theData, itsType, itsID, itsName);
  2382. X                    SetResAttrs(theData, attrs);
  2383. X                }
  2384. X                else
  2385. X                    ChangedResource(theData);
  2386. X                    
  2387. X                WriteResource(theData);
  2388. X                
  2389. X            }
  2390. X            
  2391. X        }
  2392. X        
  2393. X    }
  2394. X    
  2395. X    UseResFile(saveResFile);
  2396. X    
  2397. X    return;
  2398. X}
  2399. X
  2400. Xstatic pascal void AnimateCursor()
  2401. X
  2402. X{
  2403. X    short next;
  2404. X    int oldA5;
  2405. X    
  2406. X    oldA5 = SetCurrentA5();
  2407. X    
  2408. X    next = (*theScreen.acur)->next + 1;
  2409. X    if (next >= (*theScreen.acur)->frames) next = 0;
  2410. X    SetCursor(*((*theScreen.acur)->table[next].cursHandle));
  2411. X    (*theScreen.acur)->next = next;
  2412. X    
  2413. X    theScreen.vbl.vblCount = (short) theScreen.waitRate;
  2414. X    
  2415. X    (void) SetA5(oldA5);
  2416. X    
  2417. X    return;
  2418. X}
  2419. X
  2420. Xvoid BeginScreenWait(rate)
  2421. Xint rate;
  2422. X
  2423. X{
  2424. X    if (!theScreen.waitFlag) {
  2425. X    
  2426. X        (*theScreen.acur)->next = 0;
  2427. X        
  2428. X        SetCursor(*((*theScreen.acur)->table[0].cursHandle));
  2429. X        ShowCursor();
  2430. X    
  2431. X        theScreen.waitFlag = true;
  2432. X        theScreen.waitRate = rate;
  2433. X        
  2434. X        theScreen.vbl.qType = vType;
  2435. X        theScreen.vbl.vblAddr = AnimateCursor;
  2436. X        theScreen.vbl.vblCount = (short) theScreen.waitRate;
  2437. X        theScreen.vbl.vblPhase = 0;
  2438. X        
  2439. X        (void) VInstall((QElemPtr) &theScreen.vbl);
  2440. X        
  2441. X    }
  2442. X    
  2443. X    return;
  2444. X}
  2445. X
  2446. Xvoid EndScreenWait()
  2447. X
  2448. X{
  2449. X    if (theScreen.waitFlag) {
  2450. X    
  2451. X        (void) VRemove((QElemPtr) &theScreen.vbl);
  2452. X        
  2453. X        theScreen.waitFlag = false;
  2454. X        
  2455. X        InitCursor();
  2456. X        
  2457. X    }
  2458. X    
  2459. X    return;
  2460. X}
  2461. X
  2462. XHandle GetFileMHandle()
  2463. X
  2464. X{
  2465. X    return((Handle) GetMHandle(theScreen.cmdKeyFlag ? fileID1 : fileID2));
  2466. X}
  2467. X
  2468. XHandle GetAppMHandle()
  2469. X
  2470. X{
  2471. X    return((Handle) GetMHandle(theScreen.cmdKeyFlag ? appID1 : appID2));
  2472. X}
  2473. X
  2474. Xint PushScreen()
  2475. X
  2476. X{
  2477. X    int errcode;
  2478. X    char **chars, **attrs;
  2479. X    SaveScreenHandle next;
  2480. X    OSErr oops;
  2481. X    
  2482. X    next = (SaveScreenHandle) NewHandle(sizeof(SaveScreenRec));
  2483. X    
  2484. X    if (next != NULL) {
  2485. X    
  2486. X        chars = theScreen.chars;
  2487. X        oops = HandToHand((Handle *) &chars);
  2488. X        
  2489. X        if (oops == noErr) {
  2490. X        
  2491. X            attrs = theScreen.attrs;
  2492. X            oops = HandToHand((Handle *) &attrs);
  2493. X            
  2494. X            if (oops == noErr) {
  2495. X            
  2496. X                (*next)->link = theScreen.stack;
  2497. X                (*next)->chars = chars;
  2498. X                (*next)->attrs = attrs;
  2499. X                (*next)->cursor = theScreen.cursor;
  2500. X                
  2501. X                theScreen.stack = next;
  2502. X                
  2503. X                errcode = scrnErrOk;
  2504. X                
  2505. X            }
  2506. X            
  2507. X            else {
  2508. X            
  2509. X                DisposHandle((Handle) chars);
  2510. X                DisposHandle((Handle) next);
  2511. X                
  2512. X                errcode = scrnErrNoMem;
  2513. X                
  2514. X            }
  2515. X            
  2516. X        }
  2517. X        
  2518. X        else {
  2519. X        
  2520. X            DisposHandle((Handle) next);
  2521. X            
  2522. X            errcode = scrnErrNoMem;
  2523. X            
  2524. X        }
  2525. X        
  2526. X    }
  2527. X    
  2528. X    else {
  2529. X    
  2530. X        errcode = scrnErrNoMem;
  2531. X        
  2532. X    }
  2533. X    
  2534. X    return(errcode);
  2535. X}
  2536. X
  2537. Xvoid PopScreen()
  2538. X
  2539. X{
  2540. X    if (theScreen.stack != NULL) {
  2541. X    
  2542. X        HLock((Handle) (*theScreen.stack)->chars);
  2543. X        HLock((Handle) (*theScreen.stack)->attrs);
  2544. X        
  2545. X        XSetScreenImage(0,
  2546. X            *(*theScreen.stack)->chars,
  2547. X            *(*theScreen.stack)->attrs,
  2548. X            theScreen.scrnCDims.h,
  2549. X            &theScreen.scrnCRect,
  2550. X            0, 0);
  2551. X            
  2552. X        XSetScreenCursor(0, (*theScreen.stack)->cursor.h, (*theScreen.stack)->cursor.v);
  2553. X        
  2554. X        DisposeStackTop();
  2555. X        
  2556. X        UpdateScreen();
  2557. X        
  2558. X    }
  2559. X    
  2560. X    return;
  2561. X}
  2562. END_OF_FILE
  2563. if test 31284 -ne `wc -c <'mac/scrnmgr/ScrnMgr2.c'`; then
  2564.     echo shar: \"'mac/scrnmgr/ScrnMgr2.c'\" unpacked with wrong size!
  2565. fi
  2566. # end of 'mac/scrnmgr/ScrnMgr2.c'
  2567. fi
  2568. if test -f 'source/signals.c' -a "${1}" != "-c" ; then 
  2569.   echo shar: Will not clobber existing file \"'source/signals.c'\"
  2570. else
  2571. echo shar: Extracting \"'source/signals.c'\" \(5665 characters\)
  2572. sed "s/^X//" >'source/signals.c' <<'END_OF_FILE'
  2573. X/* signals.c: signal handlers
  2574. X
  2575. X   Copyright (c) 1989 James E. Wilson
  2576. X
  2577. X   This software may be copied and distributed for educational, research, and
  2578. X   not for profit purposes provided that this copyright and statement are
  2579. X   included in all such copies. */
  2580. X
  2581. X/* This signal package was brought to you by        -JEW-  */
  2582. X/* Completely rewritten by                -CJS- */
  2583. X
  2584. X/* Signals have no significance on the Mac */
  2585. X
  2586. X#ifdef MAC
  2587. X
  2588. Xvoid nosignals()
  2589. X{
  2590. X}
  2591. X
  2592. Xvoid signals()
  2593. X{
  2594. X}
  2595. X
  2596. Xvoid init_signals()
  2597. X{
  2598. X}
  2599. X
  2600. X#else /* a non-Mac system */
  2601. X
  2602. X#include <stdio.h>
  2603. X
  2604. X#ifdef ATARIST_MWC
  2605. X/* need these for atari st, but for unix, must include signals.h first,
  2606. X   or else suspend won't be properly declared */
  2607. X#include "config.h"
  2608. X#include "constant.h"
  2609. X#include "types.h"
  2610. X#include "externs.h"
  2611. X#endif
  2612. X
  2613. X/* skip most of the file on an ATARI ST */
  2614. X#ifndef ATARIST_MWC
  2615. X
  2616. X/* to get the SYS_V def if needed */
  2617. X#include "config.h"
  2618. X
  2619. X#if defined(SYS_V) && defined(lint)
  2620. X/* for AIX, prevent hundreds of unnecessary lint errors, define before
  2621. X   signal.h is included */
  2622. X#define _h_IEEETRAP
  2623. Xtypedef struct { int stuff; } fpvmach;
  2624. X#endif
  2625. X
  2626. X/* must include before externs.h, because that uses SIGTSTP */
  2627. X#include <signal.h>
  2628. X
  2629. X#include "constant.h"
  2630. X#include "types.h"
  2631. X#include "externs.h"
  2632. X
  2633. X#ifndef USG
  2634. X/* only needed for Berkeley UNIX */
  2635. X#include <sys/types.h>
  2636. X#include <sys/param.h>
  2637. X#endif
  2638. X
  2639. X#ifdef USG
  2640. X#ifndef ATARIST_MWC
  2641. X#include <string.h>
  2642. X#endif
  2643. X#else
  2644. X#ifndef VMS
  2645. X#include <strings.h>
  2646. X#endif
  2647. X#endif
  2648. X
  2649. X#ifdef USG
  2650. Xvoid exit();
  2651. Xunsigned sleep();
  2652. X#endif
  2653. X
  2654. Xstatic int error_sig = -1;
  2655. Xstatic int signal_count = 0;
  2656. X
  2657. X/*ARGSUSED*/
  2658. X#ifndef USG
  2659. Xstatic int signal_handler(sig, code, scp)
  2660. Xint sig, code;
  2661. Xstruct sigcontext *scp;
  2662. X{
  2663. X  int smask;
  2664. X
  2665. X  smask = sigsetmask(0) | (1 << sig);
  2666. X#else
  2667. Xstatic int signal_handler(sig)
  2668. Xint sig;
  2669. X{
  2670. X
  2671. X#endif
  2672. X  if(error_sig >= 0)    /* Ignore all second signals. */
  2673. X    {
  2674. X      if(++signal_count > 10)    /* Be safe. We will die if persistent enough. */
  2675. X    (void) signal(sig, SIG_DFL);
  2676. X      return;
  2677. X    }
  2678. X  error_sig = sig;
  2679. X
  2680. X  /* Allow player to think twice. Wizard may force a core dump. */
  2681. X  if (sig == SIGINT
  2682. X#ifndef MSDOS
  2683. X      || sig == SIGQUIT
  2684. X#endif
  2685. X      )
  2686. X    {
  2687. X      if (death)
  2688. X    (void) signal(sig, SIG_IGN);        /* Can't quit after death. */
  2689. X      else if (!character_saved && character_generated)
  2690. X    {
  2691. X      if (!get_check("Really commit *Suicide*?"))
  2692. X        {
  2693. X          if (turn > 0)
  2694. X        disturb(1, 0);
  2695. X          erase_line(0, 0);
  2696. X          put_qio();
  2697. X          error_sig = -1;
  2698. X#ifdef USG
  2699. X          (void) signal(sig, signal_handler);/* Have to restore handler. */
  2700. X#else
  2701. X          (void) sigsetmask(smask);
  2702. X#endif
  2703. X          /* in case control-c typed during msg_print */
  2704. X          if (wait_for_more)
  2705. X        put_buffer(" -more-", MSG_LINE, 0);
  2706. X          put_qio();
  2707. X          return;        /* OK. We don't quit. */
  2708. X        }
  2709. X      (void) strcpy(died_from, "Interrupting");
  2710. X    }
  2711. X      else
  2712. X    (void) strcpy(died_from, "Abortion");
  2713. X      prt("Interrupt!", 0, 0);
  2714. X      death = TRUE;
  2715. X      exit_game();
  2716. X    }
  2717. X  /* Die. */
  2718. X  prt(
  2719. X"OH NO!!!!!!  A gruesome software bug LEAPS out at you. There is NO defense!",
  2720. X      23, 0);
  2721. X  if (!death && !character_saved && character_generated)
  2722. X    {
  2723. X      panic_save = 1;
  2724. X      prt("Your guardian angel is trying to save you.", 0, 0);
  2725. X      (void) sprintf(died_from,"(panic save %d)",sig);
  2726. X      if (!save_char())
  2727. X    {
  2728. X      (void) strcpy(died_from, "software bug");
  2729. X      death = TRUE;
  2730. X      turn = -1;
  2731. X    }
  2732. X    }
  2733. X  else
  2734. X    {
  2735. X      death = TRUE;
  2736. X      (void) _save_char(savefile);    /* Quietly save the memory anyway. */
  2737. X    }
  2738. X  restore_term();
  2739. X#ifndef MSDOS
  2740. X  /* always generate a core dump */
  2741. X  (void) signal(sig, SIG_DFL);
  2742. X  (void) kill(getpid(), sig);
  2743. X  (void) sleep(5);
  2744. X#endif
  2745. X  exit(1);
  2746. X}
  2747. X
  2748. X#endif /* ATARIST_MWC */
  2749. X
  2750. X#ifdef ATARIST_MWC
  2751. Xstatic int error_sig = -1;
  2752. X#endif
  2753. X
  2754. X#ifndef USG
  2755. Xstatic int mask;
  2756. X#endif
  2757. X
  2758. Xvoid nosignals()
  2759. X{
  2760. X#if !defined(ATARIST_MWC)
  2761. X#ifdef SIGTSTP
  2762. X  (void) signal(SIGTSTP, SIG_IGN);
  2763. X#ifndef USG
  2764. X  mask = sigsetmask(0);
  2765. X#endif
  2766. X#endif
  2767. X  if (error_sig < 0)
  2768. X    error_sig = 0;
  2769. X#endif
  2770. X}
  2771. X
  2772. Xvoid signals()
  2773. X{
  2774. X#if !defined(ATARIST_MWC)
  2775. X#ifdef SIGTSTP
  2776. X  (void) signal(SIGTSTP, suspend);
  2777. X#ifndef USG
  2778. X  (void) sigsetmask(mask);
  2779. X#endif
  2780. X#endif
  2781. X  if (error_sig == 0)
  2782. X    error_sig = -1;
  2783. X#endif
  2784. X}
  2785. X
  2786. X
  2787. Xvoid init_signals()
  2788. X{
  2789. X#ifndef ATARIST_MWC
  2790. X  (void) signal(SIGINT, signal_handler);
  2791. X  (void) signal(SIGFPE, signal_handler);
  2792. X#ifdef MSDOS
  2793. X  /* many fewer signals under MSDOS */
  2794. X#else
  2795. X  /* Ignore HANGUP, and let the EOF code take care of this case. */
  2796. X  (void) signal(SIGHUP, SIG_IGN);
  2797. X  (void) signal(SIGQUIT, signal_handler);
  2798. X  (void) signal(SIGILL, signal_handler);
  2799. X  (void) signal(SIGTRAP, signal_handler);
  2800. X  (void) signal(SIGIOT, signal_handler);
  2801. X#ifdef SIGEMT  /* in BSD systems */
  2802. X  (void) signal(SIGEMT, signal_handler);
  2803. X#endif
  2804. X#ifdef SIGDANGER /* in SYSV systems */
  2805. X  (void) signal(SIGDANGER, signal_handler);
  2806. X#endif
  2807. X  (void) signal(SIGKILL, signal_handler);
  2808. X  (void) signal(SIGBUS, signal_handler);
  2809. X  (void) signal(SIGSEGV, signal_handler);
  2810. X  (void) signal(SIGSYS, signal_handler);
  2811. X  (void) signal(SIGTERM, signal_handler);
  2812. X  (void) signal(SIGPIPE, signal_handler);
  2813. X#ifdef SIGXCPU    /* BSD */
  2814. X  (void) signal(SIGXCPU, signal_handler);
  2815. X#endif
  2816. X#ifdef SIGPWR /* SYSV */
  2817. X  (void) signal(SIGPWR, signal_handler);
  2818. X#endif
  2819. X#endif
  2820. X#endif
  2821. X}
  2822. X
  2823. Xvoid ignore_signals()
  2824. X{
  2825. X#if !defined(ATARIST_MWC)
  2826. X  (void) signal(SIGINT, SIG_IGN);
  2827. X#ifdef SIGQUIT
  2828. X  (void) signal(SIGQUIT, SIG_IGN);
  2829. X#endif
  2830. X#endif
  2831. X}
  2832. X
  2833. Xvoid default_signals()
  2834. X{
  2835. X#if !defined(ATARIST_MWC)
  2836. X  (void) signal(SIGINT, SIG_DFL);
  2837. X#ifdef SIGQUIT
  2838. X  (void) signal(SIGQUIT, SIG_DFL);
  2839. X#endif
  2840. X#endif
  2841. X}
  2842. X
  2843. Xvoid restore_signals()
  2844. X{
  2845. X#if !defined(ATARIST_MWC)
  2846. X  (void) signal(SIGINT, signal_handler);
  2847. X#ifdef SIGQUIT
  2848. X  (void) signal(SIGQUIT, signal_handler);
  2849. X#endif
  2850. X#endif
  2851. X}
  2852. X
  2853. X#endif /* big Mac conditional */
  2854. END_OF_FILE
  2855. if test 5665 -ne `wc -c <'source/signals.c'`; then
  2856.     echo shar: \"'source/signals.c'\" unpacked with wrong size!
  2857. fi
  2858. # end of 'source/signals.c'
  2859. fi
  2860. echo shar: End of archive 19 \(of 31\).
  2861. cp /dev/null ark19isdone
  2862. MISSING=""
  2863. 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 ; do
  2864.     if test ! -f ark${I}isdone ; then
  2865.     MISSING="${MISSING} ${I}"
  2866.     fi
  2867. done
  2868. if test "${MISSING}" = "" ; then
  2869.     echo You have unpacked all 31 archives.
  2870.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2871. else
  2872.     echo You still need to unpack the following archives:
  2873.     echo "        " ${MISSING}
  2874. fi
  2875. ##  End of shell archive.
  2876. exit 0
  2877.