From decwrl!wyse!mips!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!uunet!zephyr.ens.tek.com!tekred!saab!billr Sat May 19 13:03:04 PDT 1990
Article 896 of comp.sources.games:
Path: decwrl!wyse!mips!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!uunet!zephyr.ens.tek.com!tekred!saab!billr
From: billr@saab.CNA.TEK.COM (Bill Randle)
Newsgroups: comp.sources.games
Subject: v09i074:  umoria3 - single player dungeon simulation (ver. 5.2), Part19/31
Message-ID: <5609@tekred.CNA.TEK.COM>
Date: 17 May 90 16:23:54 GMT
Sender: news@tekred.CNA.TEK.COM
Lines: 2866
Approved: billr@saab.CNA.TEK.COM

Submitted-by: wilson@ernie.Berkeley.EDU (Jim Wilson)
Posting-number: Volume 9, Issue 74
Archive-name: umoria3/Part19
Supersedes: umoria2: Volume 5, Issue 32-37,41-52,87



#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 19 (of 31)."
# Contents:  mac/moria.r mac/scrnmgr/ScrnMgr2.c source/signals.c
# Wrapped by billr@saab on Wed May 16 11:54:33 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'mac/moria.r' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mac/moria.r'\"
else
echo shar: Extracting \"'mac/moria.r'\" \(19759 characters\)
sed "s/^X//" >'mac/moria.r' <<'END_OF_FILE'
X#include "Types.r"
X
Xinclude "ScrnMgr.rsrc";
X
Xtype 'MRIA' as 'STR ';
X
Xtype 'CNFG' (256 : 257) {
X	longint;
X};
X
Xtype 'TEXT' {
X	string;
X};
X
Xresource 'MRIA' (0) {
X	"Moria 5.2.0 for the Macintosh: Implementation 2.0b1"
X};
X
Xresource 'BNDL' (128, purgeable) {
X	'MRIA',
X	0,
X	{ /* array TypeArray: 2 elements */
X		/* [1] */
X		'ICN#',
X		{ /* array IDArray: 3 elements */
X			/* [1] Application */
X			0, 128,
X			/* [2] Save file */
X			1, 129,
X			/* [3] Aux files */
X			2, 130
X		},
X		/* [2] */
X		'FREF',
X		{ /* array IDArray: 5 elements */
X			/* [1] Appilication */
X			0, 128,
X			/* [2] Save file */
X			1, 129,
X			/* [3] Info files */
X			2, 130,
X			/* [4] Score file */
X			3, 131,
X			/* [5] Config file */
X			4, 132
X		}
X	}
X};
X
Xresource 'FREF' (128, "Application", purgeable) {
X	'APPL',
X	0,
X	""
X};
X
Xresource 'FREF' (129, "Save Files", purgeable) {
X	'SAVE',
X	1,
X	""
X};
X
Xresource 'FREF' (130, "Info Files", purgeable) {
X	'TEXT',
X	2,
X	""
X};
X
Xresource 'FREF' (131, "Score File", purgeable) {
X	'SCOR',
X	2,
X	""
X};
X
Xresource 'FREF' (132, "Config File", purgeable) {
X	'CNFG',
X	2,
X	""
X};
X
Xresource 'ICON' (128, "Application", purgeable) {
X	$"00 01 00 00 00 02 80 00 00 04 40 00 00 08 20 00"
X	$"00 10 10 00 00 22 08 00 00 45 04 00 00 88 82 00"
X	$"01 05 15 00 02 02 A8 80 04 40 40 40 08 A8 80 20"
X	$"11 15 00 10 24 8A 00 28 40 51 3F 44 91 20 C0 8A"
X	$"40 00 80 51 24 41 30 22 10 01 C8 14 09 1E 7F 8F"
X	$"04 02 30 07 02 41 00 07 01 00 80 07 00 80 60 07"
X	$"00 40 1F E7 00 20 02 1F 00 10 04 07 00 08 08 00"
X	$"00 04 10 00 00 02 20 00 00 01 40 00 00 00 80"
X};
X
Xresource 'ICON' (256, "Command Set", purgeable) {
X	$"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
X	$"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
X	$"00 00 00 00 7F FF FF FE 80 00 00 01 9A AA AA A9"
X	$"80 00 00 01 95 55 55 59 80 00 00 01 9A AA AA A9"
X	$"80 00 00 01 85 7F FF 51 80 00 00 01 80 00 00 01"
X	$"7F FF FF FE"
X};
X
Xresource 'ICON' (257, "TEXT Editor", purgeable) {
X	$"0F FF FE 00 08 00 03 00 08 00 02 80 08 00 02 40"
X	$"08 00 02 20 08 00 02 10 08 00 03 F8 08 00 00 08"
X	$"08 00 00 08 08 07 C0 08 08 0F E0 08 08 18 30 08"
X	$"08 30 18 08 08 20 18 08 08 00 18 08 08 00 30 08"
X	$"08 00 60 08 08 00 C0 08 08 01 80 08 08 01 80 08"
X	$"08 01 80 08 08 01 80 08 08 00 00 08 08 01 80 08"
X	$"08 03 C0 08 08 01 80 08 08 00 00 08 08 00 00 08"
X	$"08 00 00 08 08 00 00 08 08 00 00 08 0F FF FF F8"
X};
X
Xresource 'ICN#' (128, "Application", purgeable) {
X	{ /* array: 2 elements */
X		/* [1] */
X		$"00 01 00 00 00 02 80 00 00 04 40 00 00 08 20 00"
X		$"00 10 10 00 00 22 08 00 00 45 04 00 00 88 82 00"
X		$"01 05 15 00 02 02 A8 80 04 40 40 40 08 A8 80 20"
X		$"11 15 00 10 24 8A 00 28 40 51 3F 44 91 20 C0 8A"
X		$"40 00 80 51 24 41 30 22 10 01 C8 14 09 1E 7F 8F"
X		$"04 02 30 07 02 41 00 07 01 00 80 07 00 80 60 07"
X		$"00 40 1F E7 00 20 02 1F 00 10 04 07 00 08 08 00"
X		$"00 04 10 00 00 02 20 00 00 01 40 00 00 00 80",
X		/* [2] */
X		$"00 01 00 00 00 03 80 00 00 07 C0 00 00 0F E0 00"
X		$"00 1F F0 00 00 3F F8 00 00 7F FC 00 00 FF FE 00"
X		$"01 FF FF 00 03 FF FF 80 07 FF FF C0 0F FF FF E0"
X		$"1F FF FF F0 3F FF FF F8 7F FF FF FC FF FF FF FE"
X		$"7F FF FF FF 3F FF FF FE 1F FF FF FC 0F FF FF FF"
X		$"07 FF FF FF 03 FF FF FF 01 FF FF FF 00 FF FF FF"
X		$"00 7F FF FF 00 3F FE 1F 00 1F FC 07 00 0F F8 00"
X		$"00 07 F0 00 00 03 E0 00 00 01 C0 00 00 00 80"
X	}
X};
X
Xresource 'ICN#' (129, "Save Files", purgeable) {
X	{ /* array: 2 elements */
X		/* [1] */
X		$"0F FF FE 00 08 00 03 00 08 00 02 80 08 00 02 40"
X		$"08 00 02 20 08 00 02 10 08 00 03 F8 08 00 00 08"
X		$"08 00 00 08 08 7F FE 08 08 FF FF 08 09 80 01 88"
X		$"09 9F F9 88 09 B0 09 88 09 B1 29 88 09 92 A9 88"
X		$"09 91 29 88 09 B0 49 88 09 B0 09 88 09 9F F9 88"
X		$"09 80 01 88 09 FF FF 88 09 FF FF 88 09 80 01 88"
X		$"08 00 00 08 09 12 64 88 09 B5 55 48 09 55 65 C8"
X		$"09 15 55 48 09 12 55 48 08 00 00 08 0F FF FF F8",
X		/* [2] */
X		$"0F FF FE 00 0F FF FF 00 0F FF FF 80 0F FF FF C0"
X		$"0F FF FF E0 0F FF FF F0 0F FF FF F8 0F FF FF F8"
X		$"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
X		$"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
X		$"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
X		$"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
X		$"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
X		$"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
X	}
X};
X
Xresource 'ICN#' (130, "Aux Files", purgeable) {
X	{ /* array: 2 elements */
X		/* [1] */
X		$"0F FF FE 00 08 00 03 00 08 00 02 80 09 FB AE 40"
X		$"08 00 02 20 08 00 02 10 09 F7 7B F8 08 00 00 08"
X		$"08 00 00 08 09 BB ED C8 08 00 00 08 08 00 00 08"
X		$"09 F7 B7 C8 08 00 00 08 08 00 00 08 09 B5 FD C8"
X		$"08 00 00 08 08 00 00 08 09 77 B6 C8 08 00 00 08"
X		$"08 00 00 08 09 EB B7 48 08 00 00 08 08 00 00 08"
X		$"08 00 00 08 09 12 64 88 09 B5 55 48 09 55 65 C8"
X		$"09 15 55 48 09 12 55 48 08 00 00 08 0F FF FF F8",
X		/* [2] */
X		$"0F FF FE 00 0F FF FF 00 0F FF FF 80 0F FF FF C0"
X		$"0F FF FF E0 0F FF FF F0 0F FF FF F8 0F FF FF F8"
X		$"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
X		$"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
X		$"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
X		$"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
X		$"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
X		$"0F FF FF F8 0F FF FF F8 0F FF FF F8 0F FF FF F8"
X	}
X};
X
Xresource 'DLOG' (128, "About", purgeable) {
X	{46, 26, 304, 274},
X	dBoxProc,
X	invisible,
X	noGoAway,
X	0x0,
X	128,
X	""
X};
X
Xresource 'DITL' (128, "About", purgeable) {
X	{	/* array DITLarray: 4 elements */
X		/* [1] */
X		{224, 192, 247, 235},
X		Button {
X			enabled,
X			"OK"
X		},
X		/* [2] */
X		{232, 224, 241, 233},
X		UserItem {
X			disabled
X		},
X		/* [3] */
X		{16, 8, 248, 184},
X		StaticText {
X			disabled,
X			"Moria for the Macintosh\n"
X			"Version 5.2.0\n"
X			"Implementation 2.0b1\n\n\n"
X			"Programmers:\n"
X			"Robert Alan Koeneke\n"
X			"Jimmey Wayne Todd\n\n"
X			"UNIX Port:\n"
X			"James E. Wilson\n\n"
X			"Macintosh Port:\n"
X			"Curtis W. McCauley"
X		},
X		/* [4] */
X		{16, 195, 48, 227},
X		Icon {
X			disabled,
X			128
X		}
X	}
X};
X
Xresource 'STR ' (128, "About Title", purgeable) {
X	"About Moria\311"
X};
X
Xresource 'CNFG' (256, "Command Set", purgeable) {
X	'-o\0x00\0x00'
X};
X
Xresource 'DLOG' (256, "Command Set", purgeable) {
X	{42, 34, 218, 404},
X	dBoxProc,
X	invisible,
X	noGoAway,
X	0x0,
X	256,
X	""
X};
X
Xresource 'DITL' (256, "Command Set", purgeable) {
X	{	/* array DITLarray: 9 elements */
X		/* [1] */
X		{24, 296, 48, 352},
X		Button {
X			enabled,
X			"OK"
X		},
X		/* [2] */
X		{64, 296, 88, 352},
X		Button {
X			enabled,
X			"Cancel"
X		},
X		/* [3] */
X		{40, 24, 56, 200},
X		RadioButton {
X			enabled,
X			"Rogue-Like Commands"
X		},
X		/* [4] */
X		{64, 24, 80, 200},
X		RadioButton {
X			enabled,
X			"Original Commands"
X		},
X		/* [5] */
X		{112, 72, 168, 352},
X		StaticText {
X			disabled,
X			"Choose the desired command set.  The change "
X			"will take effect when you start the next game."
X		},
X		/* [6] */
X		{16, 16, 96, 232},
X		UserItem {
X			disabled
X		},
X		/* [7] */
X		{8, 24, 24, 104},
X		StaticText {
X			enabled,
X			"Choose One"
X		},
X		/* [8] */
X		{32, 336, 40, 344},
X		UserItem {
X			disabled
X		},
X		/* [9] */
X		{112, 16, 144, 48},
X		Icon {
X			disabled,
X			256
X		}
X	}
X};
X
Xresource 'CNFG' (257, "TEXT Editor", purgeable) {
X	'MACA'
X};
X
Xresource 'DLOG' (257, "TEXT Editor", purgeable) {
X	{42, 34, 226, 426},
X	dBoxProc,
X	invisible,
X	noGoAway,
X	0x0,
X	257,
X	""
X};
X
Xresource 'DITL' (257, "TEXT Editor", purgeable) {
X	{	/* array DITLarray: 11 elements */
X		/* [1] */
X		{24, 320, 48, 376},
X		Button {
X			enabled,
X			"OK"
X		},
X		/* [2] */
X		{64, 320, 88, 376},
X		Button {
X			enabled,
X			"Cancel"
X		},
X		/* [3] */
X		{40, 24, 56, 200},
X		RadioButton {
X			enabled,
X			"MacWrite"
X		},
X		/* [4] */
X		{64, 24, 80, 176},
X		RadioButton {
X			enabled,
X			"Microsoft Word"
X		},
X		/* [5] */
X		{88, 24, 104, 176},
X		RadioButton {
X			enabled,
X			"Other:  File Creator"
X		},
X		/* [6] */
X		{88, 176, 104, 240},
X		EditText {
X			disabled,
X			""
X		},
X		/* [7] */
X		{136, 72, 176, 376},
X		StaticText {
X			disabled,
X			"Choose what kind of documents you want Moria "
X			"to create when it prints to a file."
X		},
X		/* [8] */
X		{16, 8, 120, 264},
X		UserItem {
X			disabled
X		},
X		/* [9] */
X		{8, 24, 24, 104},
X		StaticText {
X			enabled,
X			"Choose One"
X		},
X		/* [10] */
X		{32, 360, 40, 368},
X		UserItem {
X			disabled
X		},
X		/* [11] */
X		{136, 16, 168, 48},
X		Icon {
X			disabled,
X			257
X		}
X	}
X};
X
Xresource 'DLOG' (258, "Save, Quit, or Cancel", purgeable) {
X	{40, 40, 168, 318},
X	dBoxProc,
X	invisible,
X	noGoAway,
X	0x0,
X	258,
X	""
X};
X
Xresource 'DITL' (258, "Save, Quit, or Cancel", purgeable) {
X	{	/* array DITLarray: 6 elements */
X		/* [1] */
X		{64, 16, 84, 76},
X		Button {
X			enabled,
X			"Save"
X		},
X		/* [2] */
X		{96, 16, 116, 76},
X		Button {
X			enabled,
X			"Quit"
X		},
X		/* [3] */
X		{96, 200, 116, 260},
X		Button {
X			enabled,
X			"Cancel"
X		},
X		/* [4] */
X		{64, 200, 80, 216},
X		UserItem {
X			disabled
X		},
X		/* [5] */
X		{8, 56, 48, 264},
X		StaticText {
X			disabled,
X			"What do you want to do with the game in progress?"
X		},
X		/* [6] */
X		{8, 16, 40, 48},
X		Icon {
X			disabled,
X			0
X		}
X	}
X};
X
Xresource 'MENU' (129, "File") {
X	129,
X	textMenuProc,
X	0x7FFFFFC3,
X	enabled,
X	"File",
X	{	/* array: 7 elements */
X		/* [1] */
X		"New", noIcon, "N", "", plain,
X		/* [2] */
X		"Open\311", noIcon, "O", "", plain,
X		/* [3] */
X		"-", noIcon, "", "", plain,
X		/* [4] */
X		"Save", noIcon, "S", "", plain,
X		/* [5] */
X		"Save As\311", noIcon, "", "", plain,
X		/* [6] */
X		"-", noIcon, "", "", plain,
X		/* [7] */
X		"Quit", noIcon, "Q", "", plain
X	}
X};
X
Xresource 'MENU' (229, "File (No Keys)") {
X	229,
X	textMenuProc,
X	0x7FFFFFC3,
X	enabled,
X	"File",
X	{	/* array: 7 elements */
X		/* [1] */
X		"New", noIcon, "", "", plain,
X		/* [2] */
X		"Open\311", noIcon, "", "", plain,
X		/* [3] */
X		"-", noIcon, "", "", plain,
X		/* [4] */
X		"Save", noIcon, "", "", plain,
X		/* [5] */
X		"Save As\311", noIcon, "", "", plain,
X		/* [6] */
X		"-", noIcon, "", "", plain,
X		/* [7] */
X		"Quit", noIcon, "", "", plain
X	}
X};
X
Xresource 'MENU' (133, "Moria") {
X	133,
X	textMenuProc,
X	0x7FFFFF17,
X	enabled,
X	"Moria",
X	{	/* array: 5 elements */
X		/* [1] */
X		"Help\311", noIcon, "H", "", plain,
X		/* [2] */
X		"Command Set\311", noIcon, "", "", plain,
X		/* [3] */
X		"TEXT Editor\311", noIcon, "", "", plain,
X		/* [4] */
X		"-", noIcon, "", "", plain,
X		/* [5] */
X		"High Scores\311", noIcon, "", "", plain
X	}
X};
X
Xresource 'MENU' (233, "Moria (No Keys)") {
X	233,
X	textMenuProc,
X	0x7FFFFF17,
X	enabled,
X	"Moria",
X	{	/* array: 5 elements */
X		/* [1] */
X		"Help\311", noIcon, "", "", plain,
X		/* [2] */
X		"Command Set\311", noIcon, "", "", plain,
X		/* [3] */
X		"TEXT Editor\311", noIcon, "", "", plain,
X		/* [4] */
X		"-", noIcon, "", "", plain,
X		/* [5] */
X		"High Scores\311", noIcon, "", "", plain
X	}
X};
X
Xresource 'DLOG' (512, "Mac Help", purgeable) {
X	{40, 34, 310, 496},
X	dBoxProc,
X	invisible,
X	noGoAway,
X	0x0,
X	512,
X	""
X};
X
Xresource 'DITL' (512, "Mac Help", purgeable) {
X	{	/* array DITLarray: 6 elements */
X		/* [1] */
X		{16, 392, 36, 452},
X		Button {
X			enabled,
X			"Ok"
X		},
X		/* [2] */
X		{24, 432, 32, 440},
X		UserItem {
X			disabled
X		},
X		/* [3] */
X		{48, 8, 264, 440},
X		UserItem {
X			disabled
X		},
X		/* [4] */
X		{48, 439, 264, 455},
X		Control {
X			enabled,
X			512
X		},
X		/* [5] */
X		{8, 52, 40, 380},
X		StaticText {
X			disabled,
X			"Moria for the Macintosh Version 5.2.0"
X		},
X		/* [6] */
X		{8, 8, 40, 40},
X		Icon {
X			disabled,
X			128
X		}
X	}
X};
X
Xresource 'CNTL' (512, "Mac Help Scroll Bar", purgeable) {
X	{0, 0, 216, 16},
X	0,
X	visible,
X	0,
X	0,
X	scrollBarProc,
X	0,
X	""
X};
X
Xresource 'TEXT' (512, "Mac Help", purgeable) {
X	"This is an beta version of Mac Moria, implementation 2.0b1, which is "
X	"based on the Umoria 5.2.0 sources.  Please send comments and bug repor"
X	"ts to wilson@ernie.Berkeley.EDU (Jim Wilson) or 73230.224@compuserve.c"
X	"om (Curtis McCauley).\n\n"
X	"Users of previous versions o"
X	"f Mac Moria should discard the old program.  Otherwise, the Finder mig"
X	"ht get confused when you double-click on a saved game to start Moria.\n"
X	"\n*****************************\n\nMoria is a dungeon exploration game.  "
X	"The name comes from \322The Lord of the Rings\323 trilogy written by J. R. R"
X	". Tolkien.  Moria is pronounced with the accent on the first syllable,"
X	" e.g. MORE-ee-ah.  For details on the game itself, please read the Mor"
X	"ia Docs file that is distributed along with Moria.\n\nMoria was original"
X	"ly written for VAX/VMS systems.  As such,  it is heavily dependent on "
X	"the keyboard for game play.  The mouse is not used at all, except for "
X	"standard things like menus and dialogs.  To get a list of the availabl"
X	"e keyboard commands, hit the \324?\325 key while playing the game.\n\nSome of "
X	"the commands are specified as being control characters, i.e.  saving t"
X	"he game is ^X.  To type these characters hold down the control key and"
X	" then press the appropriate character key.  If you do not have a contr"
X	"ol key, use the command key (apple/cloverleaf key) instead of the cont"
X	"rol key.  If you prefer, you may enter these commands using two keystr"
X	"okes, by first typing the '^' key followed by the letter.\n\nThe game al"
X	"so uses the escape key (ESC) quite a bit.  If you do not have an escap"
X	"e key on your keyboard, you can use the ` key or the Clear key on the "
X	"numeric keypad instead.  An escape can also by typed as ^[, i.e. contr"
X	"ol (or command) left bracket.\n\nFile Menu\n\nThe game fully supports the "
X	"standard Macintosh file menu.  Use New to start playing a new game,  o"
X	"r Open to restart a previous game.   Save As will always ask you for t"
X	"he name of the file to save your character in.  Save will usually save"
X	" the game in a file with the same name as the name of the current char"
X	"acter.  If you are playing a new game, or have changed the name of you"
X	"r character, Save will instead ask you for the name of the save file. "
X	" The Quit option, of course, is used to exit the game.\n\nA game can onl"
X	"y be saved at the point where it is your turn to move.  At all other t"
X	"imes the Save command will not be available.\n\nThe File Menu is disable"
X	"d while saving and restoring games.  There is no cause for alarm if yo"
X	"u see this occur.  After the operation is completed, there will be a p"
X	"rompt that says \322press any key to continue\323.  After you press a key, t"
X	"he File Menu will be reenabled.\n\nIf your character dies, or you decide"
X	" to stop running him, you will be prompted via a standard file dialog "
X	"for the name of a file in which to save his memories.  Pressing cancel"
X	" will avoid saving the memories.\n\nEdit Menu\n\nThe Edit Menu items are n"
X	"ot used by the game.  The Edit menu is disabled unless there is a Desk"
X	" Accessory open.\n\nScreen/FontSize Menu\n\nIf you have a color system, th"
X	"e Color item allows you to choose the background and foreground colors"
X	" of the game window.  The game must use a constant width font, so only"
X	" the Monaco font is supported.  You can, however, specify which point "
X	"size that you want to use.  The menu will list every point size availa"
X	"ble on your Macintosh for the Monaco font.\n\nAdvanced users can choose "
X	"a different font by using ResEdit or a similar program to edit the STR"
X	" \"Font Name\" resource.\n\nMoria Menu\n\nHelp brings up this dialog.\n\nComma"
X	"nd Set allows you to choose between the original Moria command set and"
X	" an optional command set similar to the UNIX game Rogue.  The main dif"
X	"ference between the two is that the original command set uses the nume"
X	"ric keypad for movement, whereas the Rogue-like command set uses the \324"
X	"hjkl\325 keys for, respectively, left down up and right.  The program wil"
X	"l remember your setting and use it as a default the next time you star"
X	"t a new character.  The command set can be chosen for the current char"
X	"acter by using the set options ('=') command.\n\nNote that the numeric k"
X	"eypad, if your system has one, is always available for indicating dire"
X	"ctions, regardless of the command set chosen.  The arrow keys will wor"
X	"k as well.\n\nText Editor allows you to choose the type of TEXT file cre"
X	"ated by Moria, that is, it allows you to specify which application wil"
X	"l be used by the Finder when you open a TEXT file created by Moria.  Y"
X	"ou can choose MacWrite or Microsoft Word files.  You can also specify "
X	"the signature of the desired application if you prefer something else."
X	"\n\nHigh Scores displays all of the scores stored in the scorefile.  You"
X	" can clear these scores by just deleting the High Scores file.  This f"
X	"eature is not implemented.\n\nConfiguration Info\n\nMoria is fully Multifi"
X	"nder compatible/aware.  It requires 450 K of memory under Multifinder."
X	"  The game will run on any Macintosh with 1 Megabyte or more of memory"
X	".\n\nMoria comes with a documentation file, called Moria Docs.  The Mori"
X	"a Docs file is an explanation of the game system.  Please remember to "
X	"always distribute this file with the game, since it contains much impo"
X	"rtant information.\n\nMoria will create two files when it is run.  The H"
X	"igh Scores file keeps a list of the scores of all of the previous game"
X	"s.  If this file is not present, a new one will be created in the fold"
X	"er which contains the game.  This file can be kept either in the folde"
X	"r that contains the application, or in the System Folder.\n\nMoria also "
X	"creates a file called Moria Config in the System Folder.  This file co"
X	"ntains all of the configuration info for Moria, such as the size and l"
X	"ocation of windows, the font size, the command set, etc.  This file mu"
X	"st remain in the Sytem Folder.\n\nThe text displayed when Moria starts u"
X	"p is stored in the data fork of this program.  You can edit it with mo"
X	"st text editors by first changing the file type of the program from 'A"
X	"PPL' to 'TEXT' with ResEdit.  Remember to change the file type back ag"
X	"ain when you are through.  Be careful not to disturb the lines which b"
X	"egin with a '#'.\n\0x00"
X};
X
Xtype 'DFPR' {
X	unsigned hex integer = $600A;					/* branch around header */
X	unsigned hex integer;							/* flags */
X	unsigned literal longint;						/* resource type */
X	integer;										/* resource id */
X	integer;										/* version */
X	unsigned hex integer = $4EF9;					/* jump instruction */
X	unsigned hex longint = $0;						/* target address for jump */
X};
X
Xtype 'LDEF' as 'DFPR';
X
Xresource 'LDEF' (514, "High Scores", purgeable) {
X	$0, 'LDEF', 514, 0
X};
X	
Xresource 'DITL' (514, "High Scores", purgeable) {
X	{	/* array DITLarray: 5 elements */
X		/* [1] */
X		{15, 422, 35, 482},
X		Button {
X			enabled,
X			"Ok"
X		},
X		/* [2] */
X		{24, 464, 32, 472},
X		UserItem {
X			disabled
X		},
X		/* [3] */
X		{48, 2, 281, 490},
X		UserItem {
X			disabled
X		},
X		/* [4] */
X		{8, 56, 40, 336},
X		StaticText {
X			disabled,
X			"Moria High Scores\n"
X			"Positions ^0 to ^1"
X		},
X		/* [5] */
X		{8, 8, 40, 40},
X		Icon {
X			disabled,
X			128
X		}
X	}
X};
X
Xresource 'DLOG' (514, "High Scores", purgeable) {
X	{40, 34, 327, 526},
X	dBoxProc,
X	invisible,
X	noGoAway,
X	0x0,
X	514,
X	""
X};
X
Xresource 'DITL' (1024, "General Error", purgeable) {
X	{	/* array DITLarray: 2 elements */
X		/* [1] */
X		{80, 304, 100, 364},
X		Button {
X			enabled,
X			"Ok"
X		},
X		/* [2] */
X		{7, 68, 71, 364},
X		StaticText {
X			disabled,
X			"^0"
X		}
X	}
X};
X
Xresource 'ALRT' (1024, "General Error", purgeable) {
X	{42, 42, 148, 416},
X	1024,
X	{	/* array: 4 elements */
X		/* [1] */
X		OK, visible, sound1,
X		/* [2] */
X		OK, visible, sound1,
X		/* [3] */
X		OK, visible, sound1,
X		/* [4] */
X		OK, visible, sound1
X	}
X};
X
Xresource 'SIZE' (-1) {
X	dontSaveScreen,
X	acceptSuspendResumeEvents,
X	enableOptionSwitch,
X	canBackground,
X	multiFinderAware,
X	backgroundAndForeground,
X	dontGetFrontClicks,
X	ignoreChildDiedEvents,
X	not32BitCompatible,
X	reserved,
X	reserved,
X	reserved,
X	reserved,
X	reserved,
X	reserved,
X	reserved,
X	375 * 1024,
X	375 * 1024	
X};
END_OF_FILE
if test 19759 -ne `wc -c <'mac/moria.r'`; then
    echo shar: \"'mac/moria.r'\" unpacked with wrong size!
fi
# end of 'mac/moria.r'
fi
if test -f 'mac/scrnmgr/ScrnMgr2.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mac/scrnmgr/ScrnMgr2.c'\"
else
echo shar: Extracting \"'mac/scrnmgr/ScrnMgr2.c'\" \(31284 characters\)
sed "s/^X//" >'mac/scrnmgr/ScrnMgr2.c' <<'END_OF_FILE'
X
Xstatic void DoContentClick(whichWindow, cursorLoc)
XWindowPtr whichWindow;
XPoint *cursorLoc;
X
X{
X	int thePart;
X	ControlHandle theControl;
X	Point localCursor;
X	
X	if (whichWindow == theScreen.window) {
X		localCursor = *cursorLoc;
X		GlobalToLocal(&localCursor);
X		if (thePart = FindControl(localCursor, whichWindow, &theControl)) {
X			if (theControl == theScreen.hScrollHandle) 
X				DoHScroll(&localCursor, thePart);
X			else if (theControl == theScreen.vScrollHandle)
X				DoVScroll(&localCursor, thePart);
X		}
X		else
X			if (theScreen.mouseFlag) DoCharClick();
X	}
X	
X	return;
X}
X	
Xstatic void DoMouseDown(cursorLoc)
XPoint *cursorLoc;
X
X{
X	int part;
X	WindowPtr whichWindow;
X	
X	switch (part = FindWindow(*cursorLoc, &whichWindow)) {
X	
X		case inMenuBar:		DoMenuItem(MenuSelect(*cursorLoc));
X							break;
X							
X		case inDrag:		DoDrag(whichWindow, cursorLoc);
X							break;
X							
X		case inGrow:		DoGrow(whichWindow, cursorLoc);
X							break;
X							
X		case inSysWindow:	SystemClick(&theScreen.event, whichWindow);
X							break;
X							
X		case inContent:		if (whichWindow != FrontWindow())
X								SelectWindow(whichWindow);
X							else
X								DoContentClick(whichWindow, cursorLoc);
X							break;
X							
X		case inZoomIn:
X		case inZoomOut:		if (whichWindow == theScreen.window)
X								if (TrackBox(whichWindow, *cursorLoc, part))
X									DoZoom(whichWindow, part);
X							break;
X	
X		case inGoAway:		if (whichWindow == theScreen.window)
X								if (TrackGoAway(whichWindow, *cursorLoc)) {
X									if (theScreen.fileMenuProc != NULL)
X										(*theScreen.fileMenuProc)(closeBoxItem);
X									else
X										DoFileMenu(closeBoxItem);
X								}
X							break;
X							
X	}
X	
X	return;
X}
X
Xstatic void DoKeyDown(cmdFlag)
Xint cmdFlag;
X
X{
X	char keycode, modifiers, ascii;
X	char upper;
X	
X	if ( (theScreen.event.when > theScreen.keyFlush)		&&
X			(theScreen.window == FrontWindow())		&&
X			(((WindowPeek) theScreen.window)->visible) ) {
X			
X		ObscureCursor();
X			
X		keycode = (char) ((theScreen.event.message & keyCodeMask) >> 8);
X		
X		modifiers = (char) ((theScreen.event.modifiers & 0xFF00) >> 8);
X		modifiers &= ~maskModMouse;
X			
X		ascii = (char) (theScreen.event.message & charCodeMask);
X		if (theScreen.escMapFlag) {
X			if (ascii == BACKQUOTE) ascii = ESC;
X		}
X		if (cmdFlag) {
X			upper = ascii;
X			if ( (upper >= 'a') && (upper <= 'z') )
X				upper = 'A' + (upper - 'a');
X			if ( (upper >= '@') && (upper <= '_') )
X				ascii = upper - '@';
X		}
X		
X		PushQueue(keycode, modifiers, ascii, 0, 0);
X		
X	}
X		
X	return;
X}
X
Xstatic void DoUpdate(whichWindow)
XWindowPtr whichWindow;
X
X{
X	if (whichWindow == theScreen.window) {
X		UpdateScreen();
X	}
X	
X	return;
X}
X
Xstatic void DoActivate(whichWindow, activated)
XWindowPtr whichWindow;
XBoolean activated;
X
X{
X	MenuHandle menu;
X	
X	menu = GetMHandle(theScreen.cmdKeyFlag ? editID1 : editID2);
X	
X	if (whichWindow == theScreen.window) {
X	
X		if (activated) {
X			DisableItem(menu, undoItem);
X			DisableItem(menu, cutItem);
X			DisableItem(menu, copyItem);
X			DisableItem(menu, pasteItem);
X			DisableItem(menu, clearItem);
X			ShowControl(theScreen.vScrollHandle);
X			ShowControl(theScreen.hScrollHandle);
X			DrawGrowIcon(whichWindow);
X		}
X		else {
X			EnableItem(menu, undoItem);
X			EnableItem(menu, cutItem);
X			EnableItem(menu, copyItem);
X			EnableItem(menu, pasteItem);
X			EnableItem(menu, clearItem);
X			HideControl(theScreen.vScrollHandle);
X			HideControl(theScreen.hScrollHandle);
X			DrawGrowIcon(whichWindow);
X		}
X	}
X	
X	return;
X}
X
Xstatic void InvalScreenRect(d, r)
Xint d;
XRect *r;
X
X{
X	register int v;
X	register short *left, *right;
X	short rl, rt, rr, rb;
X	
X	if (d) {
X	
X		rl = r->left;
X		rt = r->top;
X		rr = r->right;
X		rb = r->bottom;
X		
X		left = *theScreen.updLeft + rt;
X		right = *theScreen.updRight + rt;
X		
X		for (v = rt; v < rb; v++, left++, right++) {
X			if (rl < *left) *left = rl;
X			if (rr > *right) *right = rr;
X		}
X		
X	}
X	
X	else {
X	
X		r->left *= theScreen.charPDims.h;
X		r->right *= theScreen.charPDims.h;
X		r->top *= theScreen.charPDims.v;
X		r->bottom *= theScreen.charPDims.v;
X	
X		SetOrigin(theScreen.origin.h, theScreen.origin.v);
X		InvalRect(r);
X		SetOrigin(0, 0);
X		
X	}
X	
X	return;
X}
X
Xstatic void InvalCursor(d)
Xint d;
X
X{
X	Rect curs;
X	
X	curs.left = curs.right = theScreen.cursor.h;
X	curs.top = curs.bottom = theScreen.cursor.v;
X	curs.right += 1;
X	curs.bottom += 1;
X	
X	if (d)
X		InvalScreenRect(d, &curs);
X	
X	else {
X	
X		curs.left *= theScreen.charPDims.h;
X		curs.right *= theScreen.charPDims.h;
X		curs.top = curs.bottom = curs.bottom * theScreen.charPDims.v;
X		curs.top -= theScreen.cursorLines;
X		
X		SetOrigin(theScreen.origin.h, theScreen.origin.v);
X		InvalRect(&curs);
X		SetOrigin(0, 0);
X		
X	}
X	
X	return;
X}
X
Xvoid XSetScreenChar(d, c, h, v)
Xint d;
Xchar c;
Xint h, v;
X
X{
X    int loc;
X    Rect area;
X	Point pos;
X	
X	pos.h = h;
X	pos.v = v;
X
X    if (PtInRect(pos, &theScreen.scrnCRect)) {
X
X		loc = v * theScreen.scrnCDims.h + h;
X		(*theScreen.chars)[loc] = c;
X	
X		area.left = area.right = h;
X		area.right += 1;
X		area.top = area.bottom = v;
X		area.bottom += 1;
X	
X		InvalScreenRect(d, &area);
X
X    }
X
X    return;
X}
X
Xvoid XSetScreenBuffer(d, c, row, bounds, h, v)
Xint d;
Xchar *c;
Xint row;
XRect *bounds;
Xint h, v;
X
X{
X    int i;
X    int wid;
X    int srcLoc, dstLoc;
X    char *srcC, *dstC;
X    Rect temp, area;
X
X    temp.right = temp.left = h;
X    temp.right += bounds->right - bounds->left;
X    temp.bottom = temp.top = v;
X    temp.bottom += bounds->bottom - bounds->top;
X
X    if (SectRect(&temp, &theScreen.scrnCRect, &area)) {
X
X		srcLoc = (area.top + bounds->top - v) * row +
X			 (area.left + bounds->left - h);
X		dstLoc = area.top * theScreen.scrnCDims.h + area.left;
X	
X		srcC = c + srcLoc;
X		dstC = *theScreen.chars + dstLoc;
X	
X		wid = area.right - area.left;
X	
X		if ( (wid == row) && (wid == theScreen.scrnCDims.h) ) {
X			wid *= (area.bottom - area.top);
X			memcpy(dstC, srcC, wid);
X		}
X
X		else {
X		
X			for (i = area.top; i < area.bottom; i++) {
X				memcpy(dstC, srcC, wid);
X				srcC += row;
X				dstC += theScreen.scrnCDims.h;
X			}
X			
X		}
X	
X		InvalScreenRect(d, &area);
X
X    }
X
X    return;
X}
X
Xvoid XSetScreenString(d, s, h, v)
Xint d;
Xchar *s;
Xint h, v;
X
X{
X    Rect bounds;
X
X    bounds.left = 0;
X    bounds.right = strlen(s);
X    bounds.top = 0;
X    bounds.bottom = 1;
X
X    XSetScreenBuffer(d, s, bounds.right, &bounds, h, v);
X
X    return;
X}
X
Xvoid XSetScreenCharAttr(d, c, a, h, v)
Xint d;
Xchar c;
Xchar a;
Xint h, v;
X
X{
X    int loc;
X    Rect area;
X	Point pos;
X	
X	pos.h = h;
X	pos.v = v;
X
X    if (PtInRect(pos, &theScreen.scrnCRect)) {
X
X		loc = v * theScreen.scrnCDims.h + h;
X		(*theScreen.chars)[loc] = c;
X		(*theScreen.attrs)[loc] = a;
X	
X		area.left = area.right = h;
X		area.right += 1;
X		area.top = area.bottom = v;
X		area.bottom += 1;
X	
X		InvalScreenRect(d, &area);
X
X    }
X
X    return;
X}
X
Xvoid XSetScreenBufferAttr(d, c, a, row, bounds, h, v)
Xint d;
Xchar *c;
Xchar a;
Xint row;
XRect *bounds;
Xint h, v;
X
X{
X    int i;
X    int wid;
X    int srcLoc, dstLoc;
X    char *srcC, *dstC;
X    char *dstA;
X    Rect temp, area;
X
X    temp.right = temp.left = h;
X    temp.right += bounds->right - bounds->left;
X    temp.bottom = temp.top = v;
X    temp.bottom += bounds->bottom - bounds->top;
X
X    if (SectRect(&temp, &theScreen.scrnCRect, &area)) {
X
X		srcLoc = (area.top + bounds->top - v) * row +
X			 (area.left + bounds->left - h);
X		dstLoc = area.top * theScreen.scrnCDims.h + area.left;
X	
X		srcC = c + srcLoc;
X		dstC = *theScreen.chars + dstLoc;
X	
X		dstA = *theScreen.attrs + dstLoc;
X	
X		wid = area.right - area.left;
X	
X		if ( (wid == row) && (wid == theScreen.scrnCDims.h) ) {
X			wid *= (area.bottom - area.top);
X			memcpy(dstC, srcC, wid);
X			memset(dstA, a, wid);
X		}
X	
X		else {
X		
X			for (i = area.top; i < area.bottom; i++) {
X				memcpy(dstC, srcC, wid);
X				memset(dstA, a, wid);
X				srcC += row;
X				dstC += theScreen.scrnCDims.h;
X				dstA += theScreen.scrnCDims.h;
X			}
X			
X		}
X	
X		InvalScreenRect(d, &area);
X
X    }
X
X    return;
X}
X
Xvoid XSetScreenStringAttr(d, s, a, h, v)
Xint d;
Xchar *s;
Xchar a;
Xint h, v;
X
X{
X    Rect bounds;
X
X    bounds.left = 0;
X    bounds.right = strlen(s);
X    bounds.top = 0;
X    bounds.bottom = 1;
X
X    XSetScreenBufferAttr(d, s, a, bounds.right, &bounds, h, v);
X
X    return;
X}
X
Xvoid XSetScreenImage(d, c, a, row, bounds, h, v)
Xint d;
Xchar *c;
Xchar *a;
Xint row;
XRect *bounds;
Xint h, v;
X
X{
X    int i;
X    int wid;
X    int srcLoc, dstLoc;
X    char *srcC, *dstC;
X    char *srcA, *dstA;
X    Rect temp, area;
X
X    temp.right = temp.left = h;
X    temp.right += bounds->right - bounds->left;
X    temp.bottom = temp.top = v;
X    temp.bottom += bounds->bottom - bounds->top;
X
X    if (SectRect(&temp, &theScreen.scrnCRect, &area)) {
X
X		srcLoc = (area.top + bounds->top - v) * row +
X			 (area.left + bounds->left - h);
X		dstLoc = area.top * theScreen.scrnCDims.h + area.left;
X	
X		srcC = c + srcLoc;
X		dstC = *theScreen.chars + dstLoc;
X	
X		srcA = a + srcLoc;
X		dstA = *theScreen.attrs + dstLoc;
X	
X		wid = area.right - area.left;
X	
X		if ( (wid == row) && (wid == theScreen.scrnCDims.h) ) {
X			wid *= (area.bottom - area.top);
X			memcpy(dstC, srcC, wid);
X			memcpy(dstA, srcA, wid);
X		}
X	
X		else {
X		
X			for (i = area.top; i < area.bottom; i++) {
X				memcpy(dstC, srcC, wid);
X				memcpy(dstA, srcA, wid);
X				srcC += row;
X				srcA += row;
X				dstC += theScreen.scrnCDims.h;
X				dstA += theScreen.scrnCDims.h;
X			}
X			
X		}
X	
X		InvalScreenRect(d, &area);
X
X    }
X
X    return;
X}
X
Xvoid XWriteScreenChar(d, c)
Xint d;
Xchar c;
X
X{
X	InvalCursor(d);
X	
X    XSetScreenChar(d, c, theScreen.cursor.h, theScreen.cursor.v);
X    theScreen.cursor.h++;
X	
X	InvalCursor(d);
X	
X    return;
X}
X
Xvoid XWriteScreenBuffer(d, c, row, bounds)
Xint d;
Xchar *c;
Xint row;
XRect *bounds;
X
X{
X    XSetScreenBuffer(d, c, row, bounds, theScreen.cursor.h, theScreen.cursor.v);
X    theScreen.cursor.h += bounds->right - bounds->left;
X    theScreen.cursor.v += bounds->bottom - bounds->top;
X	
X	InvalCursor(d);
X	
X    return;
X}
X
Xvoid XWriteScreenString(d, s)
Xint d;
Xchar *s;
X
X{
X    XSetScreenString(d, s, theScreen.cursor.h, theScreen.cursor.v);
X    theScreen.cursor.h += strlen(s);
X	
X	InvalCursor(d);
X	
X    return;
X}
X
Xvoid XWriteScreenCharAttr(d, c, a)
Xint d;
Xchar c;
Xchar a;
X
X{
X    XSetScreenCharAttr(d, c, a, theScreen.cursor.h, theScreen.cursor.v);
X    theScreen.cursor.h++;
X
X	InvalCursor(d);
X	
X    return;
X}
X
Xvoid XWriteScreenBufferAttr(d, c, a, row, bounds)
Xint d;
Xchar *c;
Xchar a;
Xint row;
XRect *bounds;
X
X{
X    XSetScreenBufferAttr(d, c, a, row, bounds, theScreen.cursor.h, theScreen.cursor.v);
X    theScreen.cursor.h += bounds->right - bounds->left;
X    theScreen.cursor.v += bounds->bottom - bounds->top;
X	
X	InvalCursor(d);
X	
X    return;
X}
X
Xvoid XWriteScreenStringAttr(d, s, a)
Xint d;
Xchar *s;
Xchar a;
X
X{
X    XSetScreenStringAttr(d, s, a, theScreen.cursor.h, theScreen.cursor.v);
X    theScreen.cursor.h += strlen(s);
X	
X	InvalCursor(d);
X	
X    return;
X}
X
Xvoid XWriteScreenImage(d, c, a, row, bounds)
Xint d;
Xchar *c;
Xchar *a;
Xint row;
XRect *bounds;
X
X{
X    XSetScreenImage(d, c, a, row, bounds, theScreen.cursor.h, theScreen.cursor.v);
X    theScreen.cursor.h += bounds->right - bounds->left;
X    theScreen.cursor.v += bounds->bottom - bounds->top;
X	
X	InvalCursor(d);
X	
X    return;
X}
X
Xvoid XFillScreen(d, c, a, bounds)
Xint d;
Xchar c;
Xchar a;
XRect *bounds;
X
X{
X    int i;
X    int wid;
X    int dstLoc;
X    char *dstC;
X    char *dstA;
X    Rect area;
X
X    if (SectRect(bounds, &theScreen.scrnCRect, &area)) {
X
X		dstLoc = area.top * theScreen.scrnCDims.h + area.left;
X	
X		dstC = *theScreen.chars + dstLoc;
X	
X		dstA = *theScreen.attrs + dstLoc;
X	
X		wid = area.right - area.left;
X	
X		if (wid == theScreen.scrnCDims.h) {
X			wid *= (area.bottom - area.top);
X			memset(dstC, c, wid);
X			memset(dstA, a, wid);
X		}
X	
X		else {
X		
X			for (i = area.top; i < area.bottom; i++) {
X				memset(dstC, c, wid);
X				memset(dstA, a, wid);
X				dstC += theScreen.scrnCDims.h;
X				dstA += theScreen.scrnCDims.h;
X			}
X			
X		}
X	
X		InvalScreenRect(d, &area);
X
X    }
X
X    return;
X}
X
Xvoid XEraseScreen(d, bounds)
Xint d;
XRect *bounds;
X
X{
X    XFillScreen(d, ' ', attrNormal, bounds);
X    return;
X}
X
Xstatic void ScrollScreenPositive(area, offset, factor)
XRect *area;
Xint offset;
Xint factor;
X
X{
X    int i, j;
X    int loc;
X	int nxt;
X    char *srcc, *dstc;
X    char *srca, *dsta;
X
X    loc = (area->bottom - 1) * theScreen.scrnCDims.h + area->right - 1;
X
X    dstc = *theScreen.chars + loc;
X    srcc = dstc - offset * factor;
X
X    dsta = *theScreen.attrs + loc;
X    srca = dsta - offset * factor;
X
X    nxt = theScreen.scrnCDims.h - (area->right - area->left);
X
X    for (j = area->bottom; j > area->top; j--) {
X		for (i = area->right; i > area->left; i--) {
X			*dstc-- = *srcc--;
X			*dsta-- = *srca--;
X		}
X		srcc -= nxt;
X		dstc -= nxt;
X		srca -= nxt;
X		dsta -= nxt;
X    }
X
X    return;
X}
X
Xstatic void ScrollScreenNegative(area, offset, factor)
XRect *area;
Xint offset;
Xint factor;
X
X{
X    int i, j;
X    int loc;
X	int nxt;
X    char *srcc, *dstc;
X    char *srca, *dsta;
X
X    loc = area->top * theScreen.scrnCDims.h + area->left;
X
X    dstc = *theScreen.chars + loc;
X    srcc = dstc - offset * factor;
X
X    dsta = *theScreen.chars + loc;
X    srca = dsta - offset * factor;
X
X    nxt = theScreen.scrnCDims.h - (area->right - area->left);
X
X    for (j = area->top; j < area->bottom; j++) {
X		for (i = area->left; i < area->right; i++) {
X			*dstc++ = *srcc++;
X			*dsta++ = *srca++;
X		}
X		srcc += nxt;
X		dstc += nxt;
X		srca += nxt;
X		dsta += nxt;
X    }
X
X    return;
X}
X
Xvoid XScrollScreen(d, dh, dv, bounds, attr)
Xint d;
Xint dh, dv;
XRect *bounds;
Xchar attr;
X
X{
X    int wid, dep;
X    Rect area, clear;
X
X    if (!dh && !dv) return;
X
X    if (SectRect(bounds, &theScreen.scrnCRect, &area)) {
X
X		wid = area.right - area.left;
X		dep = area.bottom - area.top;
X
X		if ( (ABS(dh) >= wid) || (ABS(dv) >= dep) )
X	
X			XFillScreen(d, ' ', attr, &area);
X	
X		else {
X	
X			if (dv > 0) {
X				clear = area;
X				clear.bottom = area.top += dv;
X				ScrollScreenPositive(&area, dv, theScreen.scrnCDims.h);
X				XFillScreen(d, ' ', attr, &clear);
X			}
X	
X			else if (dv < 0) {
X				clear = area;
X				clear.top = area.bottom += dv;
X				ScrollScreenNegative(&area, dv, theScreen.scrnCDims.h);
X				XFillScreen(d, ' ', attr, &clear);
X			}
X	
X			if (dh > 0) {
X				clear = area;
X				clear.right = area.left += dh;
X				ScrollScreenPositive(&area, dh, 1);
X				XFillScreen(d, ' ', attr, &clear);
X			}
X	
X			else if (dh < 0) {
X				clear = area;
X				clear.left = area.right += dh;
X				ScrollScreenNegative(&area, dh, 1);
X				XFillScreen(d, ' ', attr, &clear);
X			}
X	
X			InvalScreenRect(d, &area);
X	
X		}
X
X    }
X
X    return;
X}
X
Xvoid GetScreenCharAttr(c, a, h, v)
Xchar *c;
Xchar *a;
Xint h, v;
X
X{
X    int loc;
X	Point pos;
X	
X	pos.h = h;
X	pos.v = v;
X
X    if (PtInRect(pos, &theScreen.scrnCRect)) {
X
X		loc = v * theScreen.scrnCDims.h + h;
X		*c = (*theScreen.chars)[loc];
X		*a = (*theScreen.attrs)[loc];
X
X    }
X
X    return;
X}
X
Xvoid GetScreenImage(c, a, row, bounds, h, v)
Xchar *c;
Xchar *a;
Xint row;
XRect *bounds;
Xint h, v;
X
X{
X    int i;
X    int wid;
X    int srcLoc, dstLoc;
X    char *srcC, *dstC;
X    char *srcA, *dstA;
X    Rect temp, area;
X
X    temp.right = temp.left = h;
X    temp.right += bounds->right - bounds->left;
X    temp.bottom = temp.top = v;
X    temp.bottom += bounds->bottom - bounds->top;
X
X    if (SectRect(&temp, &theScreen.scrnCRect, &area)) {
X
X		dstLoc = (area.top + bounds->top - v) * row +
X			 (area.left + bounds->left - h);
X		srcLoc = area.top * theScreen.scrnCDims.h + area.left;
X	
X		dstC = c + dstLoc;
X		srcC = *theScreen.chars + srcLoc;
X	
X		dstA = a + dstLoc;
X		srcA = *theScreen.attrs + srcLoc;
X	
X		wid = area.right - area.left;
X	
X		if ( (wid == row) && (wid == theScreen.scrnCDims.h) ) {
X			wid *= (area.bottom - area.top);
X			memcpy(dstC, srcC, wid);
X			memcpy(dstA, srcA, wid);
X		}
X	
X		else {
X		
X			for (i = area.top; i < area.bottom; i++) {
X				memcpy(dstC, srcC, wid);
X				memcpy(dstA, srcA, wid);
X				dstC += row;
X				dstA += row;
X				srcC += theScreen.scrnCDims.h;
X				srcA += theScreen.scrnCDims.h;
X			}
X			
X		}
X	
X    }
X
X    return;
X}
X
Xvoid XMoveScreenCursor(d, h, v)
Xint d;
Xint h, v;
X
X{
X	InvalCursor(d);
X	
X    theScreen.cursor.h += h;
X    theScreen.cursor.v += v;
X	
X	InvalCursor(d);
X	
X    return;
X}
X
Xvoid XSetScreenCursor(d, h, v)
Xint d;
Xint h, v;
X
X{
X	InvalCursor(d);
X	
X    theScreen.cursor.h = h;
X    theScreen.cursor.v = v;
X	
X	InvalCursor(d);
X	
X    return;
X}
X
Xvoid GetScreenCursor(h, v)
Xint *h, *v;
X{
X    *h = theScreen.cursor.h;
X    *v = theScreen.cursor.v;
X    return;
X}
X
Xstatic int CheckCursorStatus()
X
X{
X	int oldStatus;
X	int changed;
X	
X	oldStatus = theScreen.cursorStatus;
X	
X	if (theScreen.cursorLevel <= 0)
X		theScreen.cursorStatus = 0;
X	else if (!theScreen.cursorBlink)
X		theScreen.cursorStatus = 1;
X	else if (theScreen.cursorChangeTick <= TickCount())
X		theScreen.cursorStatus = !oldStatus;
X		
X	changed = theScreen.cursorStatus != oldStatus;
X	
X	if (changed) {
X		theScreen.cursorChangeTick = TickCount() + theScreen.cursorBlink;
X		InvalCursor(0);
X	}
X	
X	return(changed);
X}
X
Xstatic void InvalDelayed()
X
X{
X	int v;
X	short *left, *right;
X	Rect inval;
X	
X	v = 0;
X	left = *theScreen.updLeft;
X	right = *theScreen.updRight;
X	
X	while (v < theScreen.scrnCDims.v) {
X	
X		if (!*right) {
X		
X			v++;
X			left++;
X			right++;
X			
X		}
X		
X		else {
X		
X			inval.top = v;
X			inval.left = *left;
X			inval.right = *right;
X			
X			do {
X				v++;
X				*left++ = theScreen.scrnCDims.h;
X				*right++ = 0;
X			} while ( (v < theScreen.scrnCDims.v) &&
X					  (*left == inval.left)		 &&
X					  (*right == inval.right)		);
X					  
X			inval.bottom = v;
X			
X			InvalScreenRect(0, &inval);
X			
X			left = *theScreen.updLeft + v;
X			right = *theScreen.updRight + v;
X			
X		}
X		
X	}
X	
X	return;
X	
X}
X
Xstatic void UpdateScreenLine(area, c, a, len)
XRect *area;
Xchar *c;
Xchar *a;
Xint len;
X
X{
X    int count;
X    char attr;
X    char *last, *prev;
X	short face;
X	Rect temp;
X	
X	temp = *area;
X
X    last = a + len;
X
X    while (a < last) {
X
X		attr = *a;
X	
X		prev = a;
X		while ( (a < last) && (*a == attr) ) a++;
X		count = a - prev;
X		
X		temp.right = temp.left + count * theScreen.charPDims.h;
X		
X		face = normal;
X		if (attr & attrUnderlined) face |= underline;
X		if (attr & attrItalicized) face |= italic;
X		TextFace(face);
X		
X		if (theScreen.colorFlag) {
X			ForeColor(colors[AttrFore(attr)]);
X			BackColor(colors[AttrBack(attr)]);
X		}
X		else {
X			ForeColor(
X				colors[
X					(AttrFore(attr) == attrColorBack) ?
X						theScreen.colorStdBack : theScreen.colorStdFore]);
X			BackColor(
X				colors[
X					(AttrBack(attr) == attrColorBack) ?
X						theScreen.colorStdBack : theScreen.colorStdFore]);
X		}
X		
X		EraseRect(&temp);
X		
X		DrawText(c, 0, count);
X		
X		temp.left = temp.right;
X	
X		c += count;
X
X    }
X
X    return;
X}
X
Xvoid UpdateScreen()
X
X{
X    int j;
X	int top, dep, left, wid;
X    Rect clear, area, curs;
X	RgnHandle vis;
X    char *c, *a;
X	int cursorLoc;
X	
X	InvalDelayed();
X
X    BeginUpdate(theScreen.window);
X	
X	SetOrigin(theScreen.origin.h, theScreen.origin.v);
X	
X	ClipRect(&theScreen.picLRect);
X	
X	if (!theScreen.colorFlag)
X		BackColor(colors[theScreen.colorStdBack]);
X	
X	if (theScreen.picLRect.top < theScreen.scrnLRect.top) {
X		clear = theScreen.picLRect;
X		clear.bottom = theScreen.scrnLRect.top;
X		EraseRect(&clear);
X	}
X	
X	if (theScreen.picLRect.left < theScreen.scrnLRect.left) {
X		clear = theScreen.picLRect;
X		clear.right = theScreen.scrnLRect.left;
X		EraseRect(&clear);
X	}
X	
X	if (theScreen.picLRect.right > theScreen.scrnLRect.right) {
X		clear = theScreen.picLRect;
X		clear.left = theScreen.scrnLRect.right;
X		EraseRect(&clear);
X	}
X	
X	if (theScreen.picLRect.bottom > theScreen.scrnLRect.bottom) {
X		clear = theScreen.picLRect;
X		clear.top = theScreen.scrnLRect.bottom;
X		EraseRect(&clear);
X	}
X	
X	ClipRect(&theScreen.drawLRect);
X	
X	vis = theScreen.window->visRgn;
X			 
X	top = theScreen.drawXCRect.top;
X	dep = theScreen.drawXCRect.bottom - top;
X	
X	left = theScreen.drawXCRect.left;
X	wid = theScreen.drawXCRect.right - left;
X	
X	HLock((Handle) theScreen.chars);
X	HLock((Handle) theScreen.attrs);
X
X    c = *theScreen.chars + top * theScreen.scrnCDims.h + left;
X    a = *theScreen.attrs + top * theScreen.scrnCDims.h + left;
X	
X	area = theScreen.drawXLRect;
X	area.bottom = area.top + theScreen.charPDims.v;
X
X    for (j = 0; j < dep; j++) {
X	
X		if (RectInRgn(&area, vis)) {
X			MoveTo(area.left, area.top + theScreen.info.ascent);
X			UpdateScreenLine(&area, c, a, wid);
X		}
X	
X		area.top = area.bottom;
X		area.bottom += theScreen.charPDims.v;
X	
X		c += theScreen.scrnCDims.h;
X		a += theScreen.scrnCDims.h;
X
X    }
X
X	HUnlock((Handle) theScreen.chars);
X	HUnlock((Handle) theScreen.attrs);
X	
X	if (theScreen.cursorStatus) {
X		curs.left = curs.right = theScreen.cursor.h * theScreen.charPDims.h;
X		curs.right += theScreen.charPDims.h;
X		curs.bottom = curs.top = (theScreen.cursor.v + 1) * theScreen.charPDims.v;
X		if (theScreen.cursorLines <= theScreen.charPDims.v)
X			curs.top -= theScreen.cursorLines;
X		else
X			curs.top -= theScreen.charPDims.v;
X		if (theScreen.colorFlag)
X			BackColor(colors[theScreen.cursorColor]);
X		else {
X			cursorLoc = theScreen.cursor.v * theScreen.scrnCDims.h + theScreen.cursor.h;
X			BackColor(
X				colors[
X					(AttrFore((*theScreen.attrs)[cursorLoc]) == attrColorBack) ?
X						theScreen.colorStdBack : theScreen.colorStdFore]);
X		}
X		EraseRect(&curs);
X	}
X
X	SetOrigin(0, 0);
X	
X	TextFace(normal);
X	
X	ForeColor(blackColor);
X	BackColor(whiteColor);
X
X    MoveTo(0, 0);
X	
X	ClipRect(&theScreen.window->portRect);
X	
X	UpdtControl(theScreen.window, theScreen.window->visRgn);
X	DrawGrowIcon(theScreen.window);
X	
X    EndUpdate(theScreen.window);
X
X    return;
X}
X
Xvoid IdleScreenMgr()
X
X{
X	int more;
X	short mask;
X	
X	do {
X		
X		mask = everyEvent;
X		if (theScreen.waitFlag) {
X			mask -= mDownMask;
X			mask -= keyDownMask;
X			mask -= autoKeyMask;
X		}
X		
X		if ( (!theScreen.backgrounding) && (theScreen.window == FrontWindow()) )
X			CheckCursorStatus();
X			
X		if (theScreen.wneImplemented) {
X			more = WaitNextEvent(mask, &theScreen.event, 0, NULL);
X		}
X		else {
X			SystemTask();
X			more = GetNextEvent(mask, &theScreen.event);
X		}
X		
X		if (more)
X			switch (theScreen.event.what) {
X			
X				case mouseDown:		DoMouseDown(&theScreen.event.where);
X									break;
X									
X				case autoKey:
X				case keyDown:		if (theScreen.event.modifiers & cmdKey) {
X										if (theScreen.cmdKeyFlag) {
X											if (theScreen.event.what != autoKey)
X												DoMenuItem(MenuKey(theScreen.event.message & charCodeMask));
X										}
X										else
X											DoKeyDown(true);
X									}
X									else
X										DoKeyDown(false);
X									break;
X									
X				case updateEvt:		DoUpdate((WindowPtr) theScreen.event.message);
X									break;
X									
X				case activateEvt:	DoActivate((WindowPtr) theScreen.event.message,
X											   theScreen.event.modifiers & activeFlag);
X									break;
X									
X				case osEvent:		if ((theScreen.event.message >> 24) == suspendResumeMessage) {
X										if (theScreen.event.message & resumeMask) {
X											theScreen.backgrounding = false;
X											DoActivate((WindowPtr) FrontWindow(), true);
X										}
X										else {
X											theScreen.backgrounding = true;
X											DoActivate((WindowPtr) FrontWindow(), false);
X										}
X									}
X									
X			}
X			
X	} while (more);
X		
X	return;
X}
X
Xvoid FlushScreenKeys()
X
X{
X	theScreen.keyFlush = theScreen.mouseFlush = TickCount();
X	FlushQueue();
X	return;
X}
X
Xint CountScreenKeys()
X
X{
X	return(LenQueue());
X}
X
Xint GetScreenKeys(keycode, modifiers, ascii, h, v)
Xchar *keycode;
Xchar *modifiers;
Xchar *ascii;
Xint *h;
Xint *v;
X
X{
X	int flag;
X	short th, tv;
X	
X	if (flag = PopQueue(keycode, modifiers, ascii, &th, &tv)) {
X		if (h != NULL) *h = th;
X		if (v != NULL) *v = tv;
X	}
X	
X	return(flag);
X}
X
Xvoid EnableScreenMouse(flag)
Xint flag;
X
X{
X	if ( (flag) && (!theScreen.mouseFlag) ) theScreen.mouseFlush = TickCount();
X	theScreen.mouseFlag = flag;
X	return;
X}
X
Xvoid ClipScreenMouse(area)
XRect *area;
X
X{
X	theScreen.mouseLRect = theScreen.mouseCRect = *area;
X	theScreen.mouseLRect.left *= theScreen.charPDims.h;
X	theScreen.mouseLRect.top *= theScreen.charPDims.v;
X	theScreen.mouseLRect.right *= theScreen.charPDims.h;
X	theScreen.mouseLRect.bottom *= theScreen.charPDims.v;
X	
X	return;
X}
X
Xvoid DefineScreenCursor(color, lines, blinkRate)
Xint color;
Xint lines;
Xint blinkRate;
X
X{
X	theScreen.cursorColor = color;
X	theScreen.cursorLines = lines;
X	theScreen.cursorBlink = blinkRate;
X	
X	InvalCursor(0);
X	
X	return;
X}
X
Xvoid HideScreenCursor()
X
X{
X	theScreen.cursorLevel--;
X	CheckCursorStatus();
X	return;
X}
X
Xvoid ShowScreenCursor()
X
X{
X	theScreen.cursorLevel++;
X	CheckCursorStatus();
X	return;
X}
X
Xvoid SetScreenAboutProc(procPtr)
Xvoid (*procPtr)();
X
X{
X	theScreen.aboutProc = procPtr;
X	return;
X}
X
Xvoid SetScreenQuitProc(procPtr, flag)
Xvoid (*procPtr)();
Xint flag;
X
X{
X	theScreen.quitProc = procPtr;
X	theScreen.quitReturns = flag;
X	return;
X}
X
Xint YesOrNo(text)
Xchar *text;
X
X{
X	DialogPtr theDialog;
X	short itemHit;
X	short itsType;
X	Handle itsHandle;
X	Rect itsRect;
X	Str255 ptext;
X	int h, v;
X	
X	theDialog = GetNewDialog(yesOrNoDlgID, nil, (WindowPtr) -1);
X	
X	CenterScreenDLOG(yesOrNoDlgID, fixHalf, fixThird, &h, &v);
X	MoveWindow((WindowPtr) theDialog, (short) h, (short) v, false);
X	
X	GetDItem(theDialog, ok, &itsType, &itsHandle, &itsRect);
X	InsetRect(&itsRect, -4, -4);
X	
X	SetDItem(theDialog, yesOrNoDfltBorder, userItem, (Handle) DrawDefaultBorder, &itsRect);
X	
X	if (text != NULL) {
X		strncpy(ptext, text, 255);
X		ptext[255] = '\0';
X		c2pstr(ptext);
X		GetDItem(theDialog, yesOrNoText, &itsType, &itsHandle, &itsRect);
X		SetIText(itsHandle, ptext);
X	}
X	
X	ShowWindow((WindowPtr) theDialog);
X
X	do {
X		ModalDialog(nil, &itemHit);
X	} while ( (itemHit != ok) && (itemHit != cancel) );
X
X	DisposDialog(theDialog);
X	
X	return(itemHit == ok);
X}
X
Xvoid ShowScreen(visible)
Xint visible;
X
X{
X	if (visible)
X		ShowWindow(theScreen.window);
X	else
X		HideWindow(theScreen.window);
X		
X	return;
X}
X
Xvoid GetScreenBounds(bounds)
XRect *bounds;
X
X{
X	Point mouse;
X	GDHandle gdh;
X	
X	if (!theScreen.env.hasColorQD) {
X		*bounds = qd.screenBits.bounds;
X		bounds->top += GetMBarHeight();
X	}
X		
X	else {
X	
X		*bounds = (*GetMainDevice())->gdRect;
X		
X		GetMouse(&mouse);
X		LocalToGlobal(&mouse);
X		
X		gdh = GetDeviceList();
X		
X		while (gdh != NULL) {
X		
X			if (PtInRect(mouse, &(*gdh)->gdRect)) {
X				*bounds = (*gdh)->gdRect;
X				if (gdh == GetMainDevice()) bounds->top += GetMBarHeight();
X				gdh = NULL;
X			}
X			
X			else
X				gdh = GetNextDevice(gdh);
X			
X		}
X		
X	}
X	
X	return;
X}
X
X
Xvoid CenterScreenDLOG(id, hRatio, vRatio, h, v)
Xint id;
XFixed hRatio, vRatio;
Xint *h, *v;
X
X{
X	int wid, hgt;
X	DialogTHndl d;
X	Rect bounds;
X	
X	d = (DialogTHndl) GetResource('DLOG', (short) id);
X	
X	if (d != NULL) {
X	
X		wid = (*d)->boundsRect.right - (*d)->boundsRect.left;
X		hgt = (*d)->boundsRect.bottom - (*d)->boundsRect.top;
X		
X		GetScreenBounds(&bounds);
X		
X		wid = (bounds.right - bounds.left) - wid;
X		hgt = (bounds.bottom - bounds.top) - hgt;
X		
X		*h = bounds.left + FixRound(hRatio * wid);
X		*v = bounds.top + FixRound(vRatio * hgt);
X		
X	}
X	
X	return;
X}
X
Xint DoScreenALRT(id, kind, hRatio, vRatio)
Xint id;
Xint kind;
XFixed hRatio, vRatio;
X
X{
X	int wid, hgt, h, v;
X	int item;
X	AlertTHndl a;
X	Rect bounds;
X	
X	a = (AlertTHndl) GetResource('ALRT', (short) id);
X	
X	if (a != NULL) {
X	
X		wid = (*a)->boundsRect.right - (*a)->boundsRect.left;
X		hgt = (*a)->boundsRect.bottom - (*a)->boundsRect.top;
X		
X		GetScreenBounds(&bounds);
X		
X		wid = (bounds.right - bounds.left) - wid;
X		hgt = (bounds.bottom - bounds.top) - hgt;
X		
X		h = bounds.left + FixRound(hRatio * wid) - (*a)->boundsRect.left;
X		v = bounds.top + FixRound(vRatio * hgt) - (*a)->boundsRect.top;
X		
X		OffsetRect(&(*a)->boundsRect, (short) h, (short) v);
X		
X		MoveHHi((Handle) a);
X		HLock((Handle) a);
X		
X		switch (kind) {
X			case akNormal:		item = Alert((short) id, NULL);			break;
X			case akStop:		item = StopAlert((short) id, NULL);		break;
X			case akNote:		item = NoteAlert((short) id, NULL);		break;
X			case akCaution:		item = CautionAlert((short) id, NULL);	break;
X		}
X		
X		HUnlock((Handle) a);
X		
X	}
X	
X	else
X	
X		item = -1;
X		
X	return(item);
X}
X
Xvoid ConfigScreenMgr(force, theType, theID, ConfigProc)
Xint force;
XResType theType;
Xint theID;
Xint (*ConfigProc)(Handle theData);
X
X{
X	short saveResFile, homeResFile;
X	short attrs;
X	short itsID;
X	ResType itsType;
X	Str255 itsName;
X	Handle theData;
X	
X	saveResFile = CurResFile();
X	UseResFile(theScreen.infoResFile);
X	
X	theData = GetResource(theType, (short) theID);
X	
X	if (theData != NULL) {
X	
X		homeResFile = HomeResFile(theData);
X		
X		if ( (theScreen.reconfigFlag) ||
X				(force) ||
X				(homeResFile != theScreen.infoResFile) ) {
X		
X			if ((*ConfigProc)(theData)) {
X			
X				if (homeResFile != theScreen.infoResFile) {
X					GetResInfo(theData, &itsID, &itsType, itsName);
X					attrs = GetResAttrs(theData);
X					attrs |= resChanged;
X					DetachResource(theData);
X					AddResource(theData, itsType, itsID, itsName);
X					SetResAttrs(theData, attrs);
X				}
X				else
X					ChangedResource(theData);
X					
X				WriteResource(theData);
X				
X			}
X			
X		}
X		
X	}
X	
X	UseResFile(saveResFile);
X	
X	return;
X}
X
Xstatic pascal void AnimateCursor()
X
X{
X	short next;
X	int oldA5;
X	
X	oldA5 = SetCurrentA5();
X	
X	next = (*theScreen.acur)->next + 1;
X	if (next >= (*theScreen.acur)->frames) next = 0;
X	SetCursor(*((*theScreen.acur)->table[next].cursHandle));
X	(*theScreen.acur)->next = next;
X	
X	theScreen.vbl.vblCount = (short) theScreen.waitRate;
X	
X	(void) SetA5(oldA5);
X	
X	return;
X}
X
Xvoid BeginScreenWait(rate)
Xint rate;
X
X{
X	if (!theScreen.waitFlag) {
X	
X		(*theScreen.acur)->next = 0;
X		
X		SetCursor(*((*theScreen.acur)->table[0].cursHandle));
X		ShowCursor();
X	
X		theScreen.waitFlag = true;
X		theScreen.waitRate = rate;
X		
X		theScreen.vbl.qType = vType;
X		theScreen.vbl.vblAddr = AnimateCursor;
X		theScreen.vbl.vblCount = (short) theScreen.waitRate;
X		theScreen.vbl.vblPhase = 0;
X		
X		(void) VInstall((QElemPtr) &theScreen.vbl);
X		
X	}
X	
X	return;
X}
X
Xvoid EndScreenWait()
X
X{
X	if (theScreen.waitFlag) {
X	
X		(void) VRemove((QElemPtr) &theScreen.vbl);
X		
X		theScreen.waitFlag = false;
X		
X		InitCursor();
X		
X	}
X	
X	return;
X}
X
XHandle GetFileMHandle()
X
X{
X	return((Handle) GetMHandle(theScreen.cmdKeyFlag ? fileID1 : fileID2));
X}
X
XHandle GetAppMHandle()
X
X{
X	return((Handle) GetMHandle(theScreen.cmdKeyFlag ? appID1 : appID2));
X}
X
Xint PushScreen()
X
X{
X	int errcode;
X	char **chars, **attrs;
X	SaveScreenHandle next;
X	OSErr oops;
X	
X	next = (SaveScreenHandle) NewHandle(sizeof(SaveScreenRec));
X	
X	if (next != NULL) {
X	
X		chars = theScreen.chars;
X		oops = HandToHand((Handle *) &chars);
X		
X		if (oops == noErr) {
X		
X			attrs = theScreen.attrs;
X			oops = HandToHand((Handle *) &attrs);
X			
X			if (oops == noErr) {
X			
X				(*next)->link = theScreen.stack;
X				(*next)->chars = chars;
X				(*next)->attrs = attrs;
X				(*next)->cursor = theScreen.cursor;
X				
X				theScreen.stack = next;
X				
X				errcode = scrnErrOk;
X				
X			}
X			
X			else {
X			
X				DisposHandle((Handle) chars);
X				DisposHandle((Handle) next);
X				
X				errcode = scrnErrNoMem;
X				
X			}
X			
X		}
X		
X		else {
X		
X			DisposHandle((Handle) next);
X			
X			errcode = scrnErrNoMem;
X			
X		}
X		
X	}
X	
X	else {
X	
X		errcode = scrnErrNoMem;
X		
X	}
X	
X	return(errcode);
X}
X
Xvoid PopScreen()
X
X{
X	if (theScreen.stack != NULL) {
X	
X		HLock((Handle) (*theScreen.stack)->chars);
X		HLock((Handle) (*theScreen.stack)->attrs);
X		
X		XSetScreenImage(0,
X			*(*theScreen.stack)->chars,
X			*(*theScreen.stack)->attrs,
X			theScreen.scrnCDims.h,
X			&theScreen.scrnCRect,
X			0, 0);
X			
X		XSetScreenCursor(0, (*theScreen.stack)->cursor.h, (*theScreen.stack)->cursor.v);
X		
X		DisposeStackTop();
X		
X		UpdateScreen();
X		
X	}
X	
X	return;
X}
END_OF_FILE
if test 31284 -ne `wc -c <'mac/scrnmgr/ScrnMgr2.c'`; then
    echo shar: \"'mac/scrnmgr/ScrnMgr2.c'\" unpacked with wrong size!
fi
# end of 'mac/scrnmgr/ScrnMgr2.c'
fi
if test -f 'source/signals.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'source/signals.c'\"
else
echo shar: Extracting \"'source/signals.c'\" \(5665 characters\)
sed "s/^X//" >'source/signals.c' <<'END_OF_FILE'
X/* signals.c: signal handlers
X
X   Copyright (c) 1989 James E. Wilson
X
X   This software may be copied and distributed for educational, research, and
X   not for profit purposes provided that this copyright and statement are
X   included in all such copies. */
X
X/* This signal package was brought to you by		-JEW-  */
X/* Completely rewritten by				-CJS- */
X
X/* Signals have no significance on the Mac */
X
X#ifdef MAC
X
Xvoid nosignals()
X{
X}
X
Xvoid signals()
X{
X}
X
Xvoid init_signals()
X{
X}
X
X#else /* a non-Mac system */
X
X#include <stdio.h>
X
X#ifdef ATARIST_MWC
X/* need these for atari st, but for unix, must include signals.h first,
X   or else suspend won't be properly declared */
X#include "config.h"
X#include "constant.h"
X#include "types.h"
X#include "externs.h"
X#endif
X
X/* skip most of the file on an ATARI ST */
X#ifndef ATARIST_MWC
X
X/* to get the SYS_V def if needed */
X#include "config.h"
X
X#if defined(SYS_V) && defined(lint)
X/* for AIX, prevent hundreds of unnecessary lint errors, define before
X   signal.h is included */
X#define _h_IEEETRAP
Xtypedef struct { int stuff; } fpvmach;
X#endif
X
X/* must include before externs.h, because that uses SIGTSTP */
X#include <signal.h>
X
X#include "constant.h"
X#include "types.h"
X#include "externs.h"
X
X#ifndef USG
X/* only needed for Berkeley UNIX */
X#include <sys/types.h>
X#include <sys/param.h>
X#endif
X
X#ifdef USG
X#ifndef ATARIST_MWC
X#include <string.h>
X#endif
X#else
X#ifndef VMS
X#include <strings.h>
X#endif
X#endif
X
X#ifdef USG
Xvoid exit();
Xunsigned sleep();
X#endif
X
Xstatic int error_sig = -1;
Xstatic int signal_count = 0;
X
X/*ARGSUSED*/
X#ifndef USG
Xstatic int signal_handler(sig, code, scp)
Xint sig, code;
Xstruct sigcontext *scp;
X{
X  int smask;
X
X  smask = sigsetmask(0) | (1 << sig);
X#else
Xstatic int signal_handler(sig)
Xint sig;
X{
X
X#endif
X  if(error_sig >= 0)	/* Ignore all second signals. */
X    {
X      if(++signal_count > 10)	/* Be safe. We will die if persistent enough. */
X	(void) signal(sig, SIG_DFL);
X      return;
X    }
X  error_sig = sig;
X
X  /* Allow player to think twice. Wizard may force a core dump. */
X  if (sig == SIGINT
X#ifndef MSDOS
X      || sig == SIGQUIT
X#endif
X      )
X    {
X      if (death)
X	(void) signal(sig, SIG_IGN);		/* Can't quit after death. */
X      else if (!character_saved && character_generated)
X	{
X	  if (!get_check("Really commit *Suicide*?"))
X	    {
X	      if (turn > 0)
X		disturb(1, 0);
X	      erase_line(0, 0);
X	      put_qio();
X	      error_sig = -1;
X#ifdef USG
X	      (void) signal(sig, signal_handler);/* Have to restore handler. */
X#else
X	      (void) sigsetmask(smask);
X#endif
X	      /* in case control-c typed during msg_print */
X	      if (wait_for_more)
X		put_buffer(" -more-", MSG_LINE, 0);
X	      put_qio();
X	      return;		/* OK. We don't quit. */
X	    }
X	  (void) strcpy(died_from, "Interrupting");
X	}
X      else
X	(void) strcpy(died_from, "Abortion");
X      prt("Interrupt!", 0, 0);
X      death = TRUE;
X      exit_game();
X    }
X  /* Die. */
X  prt(
X"OH NO!!!!!!  A gruesome software bug LEAPS out at you. There is NO defense!",
X      23, 0);
X  if (!death && !character_saved && character_generated)
X    {
X      panic_save = 1;
X      prt("Your guardian angel is trying to save you.", 0, 0);
X      (void) sprintf(died_from,"(panic save %d)",sig);
X      if (!save_char())
X	{
X	  (void) strcpy(died_from, "software bug");
X	  death = TRUE;
X	  turn = -1;
X	}
X    }
X  else
X    {
X      death = TRUE;
X      (void) _save_char(savefile);	/* Quietly save the memory anyway. */
X    }
X  restore_term();
X#ifndef MSDOS
X  /* always generate a core dump */
X  (void) signal(sig, SIG_DFL);
X  (void) kill(getpid(), sig);
X  (void) sleep(5);
X#endif
X  exit(1);
X}
X
X#endif /* ATARIST_MWC */
X
X#ifdef ATARIST_MWC
Xstatic int error_sig = -1;
X#endif
X
X#ifndef USG
Xstatic int mask;
X#endif
X
Xvoid nosignals()
X{
X#if !defined(ATARIST_MWC)
X#ifdef SIGTSTP
X  (void) signal(SIGTSTP, SIG_IGN);
X#ifndef USG
X  mask = sigsetmask(0);
X#endif
X#endif
X  if (error_sig < 0)
X    error_sig = 0;
X#endif
X}
X
Xvoid signals()
X{
X#if !defined(ATARIST_MWC)
X#ifdef SIGTSTP
X  (void) signal(SIGTSTP, suspend);
X#ifndef USG
X  (void) sigsetmask(mask);
X#endif
X#endif
X  if (error_sig == 0)
X    error_sig = -1;
X#endif
X}
X
X
Xvoid init_signals()
X{
X#ifndef ATARIST_MWC
X  (void) signal(SIGINT, signal_handler);
X  (void) signal(SIGFPE, signal_handler);
X#ifdef MSDOS
X  /* many fewer signals under MSDOS */
X#else
X  /* Ignore HANGUP, and let the EOF code take care of this case. */
X  (void) signal(SIGHUP, SIG_IGN);
X  (void) signal(SIGQUIT, signal_handler);
X  (void) signal(SIGILL, signal_handler);
X  (void) signal(SIGTRAP, signal_handler);
X  (void) signal(SIGIOT, signal_handler);
X#ifdef SIGEMT  /* in BSD systems */
X  (void) signal(SIGEMT, signal_handler);
X#endif
X#ifdef SIGDANGER /* in SYSV systems */
X  (void) signal(SIGDANGER, signal_handler);
X#endif
X  (void) signal(SIGKILL, signal_handler);
X  (void) signal(SIGBUS, signal_handler);
X  (void) signal(SIGSEGV, signal_handler);
X  (void) signal(SIGSYS, signal_handler);
X  (void) signal(SIGTERM, signal_handler);
X  (void) signal(SIGPIPE, signal_handler);
X#ifdef SIGXCPU	/* BSD */
X  (void) signal(SIGXCPU, signal_handler);
X#endif
X#ifdef SIGPWR /* SYSV */
X  (void) signal(SIGPWR, signal_handler);
X#endif
X#endif
X#endif
X}
X
Xvoid ignore_signals()
X{
X#if !defined(ATARIST_MWC)
X  (void) signal(SIGINT, SIG_IGN);
X#ifdef SIGQUIT
X  (void) signal(SIGQUIT, SIG_IGN);
X#endif
X#endif
X}
X
Xvoid default_signals()
X{
X#if !defined(ATARIST_MWC)
X  (void) signal(SIGINT, SIG_DFL);
X#ifdef SIGQUIT
X  (void) signal(SIGQUIT, SIG_DFL);
X#endif
X#endif
X}
X
Xvoid restore_signals()
X{
X#if !defined(ATARIST_MWC)
X  (void) signal(SIGINT, signal_handler);
X#ifdef SIGQUIT
X  (void) signal(SIGQUIT, signal_handler);
X#endif
X#endif
X}
X
X#endif /* big Mac conditional */
END_OF_FILE
if test 5665 -ne `wc -c <'source/signals.c'`; then
    echo shar: \"'source/signals.c'\" unpacked with wrong size!
fi
# end of 'source/signals.c'
fi
echo shar: End of archive 19 \(of 31\).
cp /dev/null ark19isdone
MISSING=""
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
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 31 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0


