Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!brl-adm!rutgers!mit-eddie!ll-xn!ames!ucbcad!ucbvax!decvax!decwrl!cookie.dec.com!wecker
From: wecker@cookie.dec.com (DAVE  CUM GRANO SALIS  WECKER)
Newsgroups: comp.sys.amiga
Subject: VT100 (v2.4 DBW 861214) Part 1 of 2
Message-ID: <6917@decwrl.DEC.COM>
Date: Sun, 14-Dec-86 20:59:11 EST
Article-I.D.: decwrl.6917
Posted: Sun Dec 14 20:59:11 1986
Date-Received: Tue, 16-Dec-86 18:56:24 EST
Sender: daemon@decwrl.DEC.COM
Organization: Digital Equipment Corporation
Lines: 2453

#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar:	Shell Archiver
#	Run the following text with /bin/sh to create:
#	readme
#	vt100.doc
#	makefile
#	vt100.h
#	vt100.c
#	init.c
# This archive created: Sun Dec 14 17:42:23 1986
echo shar: extracting readme
sed 's/^XX//' << \SHAR_EOF > readme
XXThis archive contains a vt100 emulator with KERMIT and XMODEM file
XXtransfer protocols by Dave Wecker (V2.4 DBW 861214).
XX
XXThanks:
XX-------
XX	To everyone who sent in code and suggestions!
XX
XXReleases:
XX---------
XX	v2.4 861214 DBW - lots of fixes/additions
XX	v2.3 861101 DBW - minor bug fixes
XX	v2.2 861012 DBW - more of the same
XX 	v2.1 860915 DBW - new features (see README)
XX	v2.0 860823 DBW - Major rewrite
XX	v1.1 860720 DBW	- Switches, 80 cols, colors, bug fixes
XX	v1.0 860712 DBW	- First version released
XX
XXUsage:
XX------
XX	Please read VT100.DOC for usage information and examples.
XX
XXRelease Notes:
XX--------------
XXv2.4 861214 DBW - lots of fixes/additions
XX	- Beep should now work under Lattice
XX	- CreatePort now passes longs (as it should always have)
XX	- Nested comments in KERMIT.C removed
XX	- Beep volume of 0 (DisplayBeep) now works
XX	- snum[] declaration in KERMIT.C fixed
XX	- multi_xfer is now void and return fixed (in kermit)
XX	- "." can no longer get "stuck" as the break key
XX
XX	- RIGHT-AMIGA-keys have been added for most menu items
XX	- The ALT key is now an EIGHTth bit shifter
XX	- Control-@, Control-2, Control-space send the NULL character
XX	- Control-6 now sends Control-^
XX	- Control-- and Control-? now sends Control-_
XX	- Cursor application mode ([?1h and [?1l) now work
XX	- XMODEM now masks the eighth bit if parity is other than NONE
XX
XXv2.3 861101 DBW - minor bug fixes:
XX
XX	- added p_wbcolors to allow workbench colors on custom screen
XX	  (In the init file you can specify WBCOLORS to be NO (use color
XX	   definitions in INIT FILE or VT100.H) or YES (use WORKBENCH
XX	   colors for everything)).
XX	- "$" now sends a kermit-bye (like it says in VT100.DOC).
XX	- made window/screen heights more reasonable
XX	- Added ANSI insert line and delete line (L and
XX	  M) to speed up various editors (like emacs).
XX	  NOTE: This is NOT a VT100 sequence (new extension).
XX	- ctrl-space now also sends a null (along with ^@ and ^`)
XX	- RAWKEY fixed in WINDOW.C
XX	- p_wrap fixed in WINDOW.C
XX	- removed WRDMAX from VT100.H
XX	- fixed exit with no params in SCRIPT.C
XX	- fixed parity comparisons in KERMIT.C
XX	- init file [n+1] changed to [nplus1] to make Lattice happy.
XX	- cursoron(), cursoroff() changed to one routine cursorflip().
XX	- long lines shortened to less than 80 characters (for gateways).
XX	- blanks following exit (or comments) now work in scripts.
XX
XXv2.2 861012 DBW - more of the same:
XX
XX	- The INIT file "exit" can now chain to a script
XX	- The SCRIPT command "exit" can now chain to another script
XX	- Hangup menu item now works.
XX	- Autowrap can now be set from VT100.H, VT100.INIT ([?7h l)
XX	- Control-G is now handled with an audible beep
XX	- Script now used "^chr" to send control characters
XX	- The graphics "box" character (a) was added
XX	- Control-@ and Control-` now send the NULL character
XX	- Alternate color for BOLD has been re-instated by popular demand
XX	- Menus have been cleaned up.
XX	- Lattice compilation cleaned up.
XX	- No more wordsize parameter since PARITY takes care of all cases
XX	- Function keys can now call scripts
XX	- Double shift keys are now handled correctly.
XX	- Version has been added to the title bar (for bug reports).
XX
XXv2.1 860915 DBW - new features / bug fixes
XX
XX	- Now identifies as a VT100 (including the response to Z)
XX	- Cursor color now gets read in as hex (instead of decimal)
XX	- REPORTMOUSE taken out of definitions (not needed)
XX	- XON/XOFF now being handled by the device driver instead of me
XX	- Literal escape characters have been replaced with \033
XX	- At init time the user can now specify the input BUFFER size
XX	  (typically between 512 and 2048 bytes) depending on baud rate
XX	- Script files are now case insensitive for commands
XX	- XMODEM now turns off the driver XON/XOFF during transfers
XX	- Graphic rendition now done by the OS instead of me.
XX	- Initialization files are now searched for in S: instead of C:
XX	- Forward GOTO bug fixed in the script package.
XX	- Keypad can now be used in both numeric and application mode
XX	- General purpose cleanup() routine added for all exits.
XX	- Utility menu added (sendbreak, hangup, change directory).
XX	  NOTE: hangup is not implemented yet.
XX	- Full wild card support in file transfers (see vt100.doc).
XX	- Kermit cleaned up with better filename handling (from host).
XX	- Script now has CD (changed directory) and SB (send break) commands
XX	- Added Parity and Wordsize choices in VT100.H, VT100.INIT, menu
XX	  and scripts. (Generates parity from a table).
XX	- Added 8th bit quoting in KERMIT when using 7 bit words (ODD or
XX	  EVEN parity).
XX	- Break time can be set from VT100.H, VT100.INIT or a script file.
XX	- Transfer mode (image or CRLF) can now be set from a script file.
XX	- Control characters in escape sequences now act like a true VT100.
XX	- F10 now works from init files.
XX	- Right (or Left) AMIGA with period (".") sends a BREAK to the host
XX	  from the keyboard.
XX	- XMODEM status kept down to one line for a file transfer.
XX
XXv2.0 860823 DBW	- Major rewrite:
XX
XX	- Emulator now compiles under either MANX or LATTICE by defining
XX	  the appropriate compiler type in VT100.H.
XX	- Sped up code to an effective baud rate of (about) 8k. This means
XX	  that clear text at 4800 baud should be no problem.
XX	- Added XON/XOFF generation so that characters should not get lost
XX	  any more at 9600 baud (when receiving clear text).
XX	- Got rid of all command line switches and environment variables.
XX	  Instead upon invocation the program searches first for any file
XX	  named on the command line, then looks for VT100.INIT in the
XX	  current directory and finally searches for C:VT100.INIT.
XX	  All parameters can be set in the init file, and a sample VT100.INIT
XX	  is provided in VT100.DOC that shows all possible options.
XX	- All parameters that are set by VT100.INIT are defined in VT100.H
XX	  (variables starting with "p_"). This allows you to compile your
XX	  own defaults into the code.
XX	- You can now set the number of lines (for all you EMACS freaks :-).
XX	  On an interlaced screen this gives you upto a 48 line terminal.
XX	- WORKBENCH colors are NEVER touched.
XX	- In an attempt to keep the size down, the color palette menu item
XX	  has been removed (current). Code is about 36K in size with a
XX	  run time image (using workbench screen) of about 88k.
XX	- Many bugs fixed including reverse scrolling with descenders,
XX	  reverse video at end of line, clearing with scrolling regions,
XX		... and 20 or more others.
XX	- File capture now no longer sends the filename to the host.
XX	- BOLD ([1m) has now been added by using an additional color
XX	  when you specify a depth of 2 (instead of 1) bitplane.
XX	- UNDERLINE ([4m) has now been added.
XX	- The handling of remote (host) escape sequences has been completly
XX	  re-written (thanks to Dawn Banks for all the work).
XX	- Function keys (and shifted function keys) can now be bound to
XX	  arbitrary strings (Jim Ravan gets his macros). See VT100.DOC
XX	  for details.
XX	- Cursor has no been reduced to the size of a normal character for
XX	  easier readability.
XX	- XMODEM has been improved (by Steve Drew) to use a timer device
XX	  (for timeouts) and to abort immediately if the user types .
XX	- KERMIT has been completely re-written and appears to work fine,
XX	  thanks to the efforts of Steve Drew.
XX	- New menu item allows script file support. Module written by
XX	  Steve Drew. See VT100.DOC for details.
XX
XXKnown problems:
XX---------------
XX	- Wraping a line at the end of a scrolling region will not scroll
XX	  correctly.
XX
XX	- Caps get locked on after a volume is requested during a file xfer
XX	  (I have not looked into this one yet).
XX
XX	- Cursor hot spot sometimes moves on custom screen.
XX	  (I've seen this one, and don't understand it).
XX
XXSuggestions/bug fixes not implemented:
XX--------------------------------------
XX	- "Custom colors are getting ignored"
XX
XX	  Wrong... you probably forgot to say "WBCOLORS NO" in the INIT file.
XX
XX	- "ASCII capture uses synchronous I/O so capture of game playing
XX	  is jerky"
XX
XX	  This change MAY be made if someone else wants to write the code.
XX
XX	- "Beep should be in stereo"
XX
XX	  I am trying to use as FEW system resources as possible, therefore
XX	  beep only ties up 1 of the 4 possible channels.
XX
XXInstallation:
XX-------------
XX	The files in this archive may be extracted by the bourne shell
XX	(/bin/sh) or the shar program using the "unshar switch (-u)",
XX	contact me if you need a copy of this version of shar.
XX
XX	REMEMBER: Set the correct compiler definition in VT100.H
XX
XXFiles:
XX------
XX	README		- this file
XX
XX	vt100.doc	- documentation for the terminal emulator
XX
XX	makefile	- make file for the emulator (under MANX AZTEC-C)
XX
XX	vt100.h		- include file used by all other modules
XX
XX	window.c	- manager for window and keyboard
XX
XX	vt100.c		- main module, handles menus
XX
XX	remote.c	- handle remote characters (vt100 emulation)
XX
XX	kermit.c	- kermit protocol (to transfer text files on VMS
XX			  select the CRLF option on the transfer mode menu,
XX			  otherwise use image mode).
XX
XX	init.c		- startup code
XX
XX	xmodem.c	- xmodem protocol that understands AMIGA binary and
XX			  text file formats (automatically).
XX
XX	script.c	- script control package
XX
XX	expand.c	- filename expansion (wildcards) and dir setting
XX
XXContact:
XX--------
XXPlease send bugs/comments/suggestions/praise to:
XX
XX	Dave Wecker at	ENET:	COOKIE::WECKER
XX			ARPA:	wecker%cookie.dec.com@decwrl.dec.com
XX			USENET:	{decvax|decwrl}!cookie.dec.com!wecker
XX			SNAIL:	Dave Wecker
XX				115 Palm Springs Drive
XX				Colorado Springs, CO  80908
SHAR_EOF
if test 9408 -ne "`wc -c readme`"
then
echo shar: error transmitting readme '(should have been 9408 characters)'
fi
echo shar: extracting vt100.doc
sed 's/^XX//' << \SHAR_EOF > vt100.doc
XXThis is the documentation file for the VT100 terminal emulator by Dave
XXWecker (V2.4 DBW 861214). Comments/suggestions/bugs/problems/praise
XXshould be sent to:
XX
XX	Dave Wecker at	ENET:	COOKIE::WECKER
XX			ARPA:	wecker%cookie.dec.com@decwrl.dec.com
XX			USENET:	{decvax|decwrl}!cookie.dec.com!wecker
XX			SNAIL:	Dave Wecker
XX				115 Palm Springs Drive
XX				Colorado Springs, CO  80908
XX
XXMulti-file transfer, the new version of KERMIT and script support were
XXcontributed by Steve Drew (Aug 20 1986). If you wish to thank Steve
XXdirectly he can be contacted through:
XX
XX    	Steve Drew at	ENET:    CGFSV1::DREW
XX    			ARPA:    drew%cfgsv1.dec.com@decwrl.dec.com
XX    			USENET:  decvax!decwrl!cgfsv1.dec.com!drew    
XX
XXMany other pieces of code/suggestions have been sent in..
XX
XX	thanks to all!
XX
XXProgram startup:
XX----------------
XX	1> vt100 [initfile]
XX
XX		- At startup, the program will search for an initialization
XX		  file to execute. It will first look for the specified
XX		  "initfile", then VT100.INIT (in the current directory)
XX		  and finally S:VT100.INIT. The format for the init file
XX		  is described later in this document.
XX
XX		- The init file controls the setting of initial defaults
XX		  and screen and macro definitions.
XX
XX		- If none of the files (listed above) are found, the
XX		  built-in defaults (defined in VT100.H as variables,
XX		  beginning with "p_") are used.
XX
XX		- All commands are either menu or script based. Scripts
XX		  are described below.
XX
XXMenus (Commands in parenthesis are keyboard bindings: Right-Amiga-chr):
XX-----------------------------------------------------------------------
XXFile 	  			- file transfers
XX	Ascii Capture		- Begin/end a script of the current session
XX	Ascii Send		- Type a file to the host
XX	Xmodem Receive	(A-V)	- Receive a file using XMODEM protocol
XX	Xmodem Send	(A-^)	- Send    a file using XMODEM protocol
XX	Kermit Get	(A-G)	- Receive files from a host KERMIT SERVER
XX	Kermit Receive	(A-R)	- Receive files from a host KERMIT
XX	Kermit Send	(A-S)	- Send    files to   a host KERMIT [SERVER]
XX	Kermit Bye	(A-B)	- Terminate a host KERMIT SERVER
XXComm Setup			- Setup communications
XX	Baud Rate		- Set the terminal baud rate
XX		300, 
XX		1200,	(A-L)
XX		2400,	(A-H)
XX		4800,
XX		9600
XX	Parity			- Type of parity
XX		NONE, 	(A-X)
XX		MARK,
XX		SPACE,
XX		EVEN,	(A-E)
XX		ODD	(A-O)
XX	Xfer Mode
XX		Image	(A-I)	- Send files verbatim (for UNIX hosts or
XX				  binary files)
XX		Text	(A-T)	- Send CR LF as line terminator and strip
XX				  CR on received files (VMS text).
XXScript 	  			- Script commands
XX	Execute file		- Start up an asynchronous script file
XX	Abort Execution		- Terminate a script file
XXUtility   			- Utility commands
XX	Send Break	(A-.)	- send a break to the host
XX	Hang Up			- close line (not implemented yet)
XX	Change Dir	(A-D)	- change the local directory (for transfers)
XX
XXKeypad mapping (in application mode):
XX-------------------------------------
XX
XX		AMIGA		VT100		comments
XX		-------		-------		---------------------------
XX		0-9	==	0-9
XX		.	==	.
XX		ENTER	==	ENTER		(basically, flip the bottom
XX		-	==	,		 2 keys up to get a VT100)
XX		HELP	==	-		(only free key around)
XX		f1-f4	==	PF1-PF4		(or any rebinding you do)
XX		arrows	==	arrows
XX
XXNote:	Right AMIGA key in conjunction with a period (".")
XX	will send a break to the host.
XX
XX	CTRL in conjunction with an at-sign ("@") a two ("2") or a
XX	space (" ") will send a NULL to the host.
XX
XX	CTRL in conjunction with a six  ("6") will send a CTRL-^
XX	CTRL in conjunction with a dash ("-") or question mark ("?")
XX		will send a CTRL-_ to the host.
XX
XXInitialization file example:
XX----------------------------
XXHere is a (hopefully) self-explanatory VT100.INIT file with all
XXoptions used:
XX
XX#####################################################################
XX#
XX#	VT100 sample initialization file
XX#	v2.4 861214 DBW	- Dave Wecker standard defaults
XX#
XX# Hash mark at the beginning of a line denotes a comment.
XX# White space (space(s) or tab(s)) delimit fields.
XX# Case ignored except for function key bindings.
XX#
XX# All items in this file overide variables of the same name in VT100.H
XX# (all variables in vt100.h have a "p_" prepended to them)
XX#
XX#####################################################################
XX#
XXBAUD		2400		# Anything after required fields is ignored
XXSCREEN		CUSTOM		# may be CUSTOM or WORKBENCH
XXINTERLACE	ON		# ON for CUSTOM or interlaced workbench
XXDEPTH		1		# number of bit planes to use (1 or 2)
XXWBCOLORS	YES		# ignore custom colors and use defaults
XXFOREGROUND	950		# Colors are only used on the custom screen
XXBACKGROUND	000		# Colors are in hex RGB from 000 to FFF
XXBOLD		a00		# Color for bold highlighting (in custom)
XXCURSOR		00a		# Color for cursor (in custom screen)
XXLINES		48		# normal <= 24 interlaced <= 48
XXMODE		CRLF		# IMAGE or CRLF (for KERMIT transfers)
XXBUFFER		512		# 512 <= Input buffer size <= 2048
XXPARITY		NONE		# NONE (= 8 bit), MARK, SPACE, ODD or EVEN
XXBREAK		750000		# Length for break key in microseconds
XXVOLUME		64		# Beep Volume (0 = Visual Beep)
XXWRAP		OFF		# Auto wrap ON or OFF
XXKEYSCRIPT	7E		# Hex value for script introducer
XX#
XX# Function bindings (strings to type when any of F1 - F10 are pressed)
XX#	f	= function key
XX#	F	= shifted function key
XX#
XX# The string specified must be delimited and uses one special char:
XX#	^	= control next character
XX#	^^	= up arrow
XX#
XX# Sample control characters:
XX#	^[	= escape	^M	= carriage return
XX#	^J	= line feed	^L	= form feed
XX#
XX# If the first character of the string is a script introducer
XX# (KEYSCRIPT) then the string is interpreted as a script filename
XX# to be executed when the key is pressed.
XX#
XX# Examples of bindings:
XX#
XXf1	"^[OP"			# f1-f4 = PF1 - PF4 on a VT100
XXf2	"^[OQ"
XXf3	"^[OR"
XXf4	"^[OS"
XX#
XX# f5,6,7 = scripts to execute (assuming that KEYSCRIPT = '~' = 0x7E)
XX#
XXf5	"~df1:vt100_source/dialwork.script"
XXf6	"~df1:vt100_source/sendvt100.script"
XXf7	"~df1:vt100_source/getpics.script"
XX#
XXf8	"MAIL^M"		# Reads my mail (note embedded )
XXf9	"NOTE^M"		# Reads conferences
XXF1	"$2400!"		# dials the phone to work
XXF2	"$bbs1!"		# dials the phone to billboard 1
XXF3	"$bbs2!"		# dials the phone to billboard 2
XXF4	"$bbs3!"		# dials the phone to billboard 3
XX#
XX# all done with init, now execute script as startup sequence
XX#
XXexit df1:vt100_source/dialwork.script
XX
XXMulti file Xfers:
XX-----------------
XXThe VT100 emulator now supports multiple file transfers. This is
XXspecified by using a comma (",") between file names when using XMODEM
XXor KERMIT. (NOTE: host XMODEM's normally CANNOT support multiple file
XXtransfers).
XX
XXWhen specifying a file name to recieve by default the directory path
XXis stripped of the filename when sent to the host but is kept for the
XXlocal file spec. eg:
XX
XX        receive file: ram:file.txt,df1:newfile.bin,$
XX
XXwill ask the server for file.txt and put it in ram:, and get
XXnewfile.bin and put it on df1: (see explanation of "$" below). If you
XXdo a single file transfer you will get another prompt for the remote
XXname e.g.:
XX
XX        receive file: ram:file.txt
XX        remote file name[file.txt] userdisk1:wantfile.txt
XX
XXThe same rules apply to sending multiple files therefore if you are
XXdoing multi file transfers make sure the host server is connected to
XXthe desired directory.
XX
XXIn addition KERMIT now supports wildcards (* = any number of
XXcharacters, ? = any single character). Examples:
XX
XX	send:	*.c,*.h,*.doc
XX	get:	*.c,*.h,$
XX
XXKERMIT receive is now smart enough to use the host filename so no
XXfilename needs to be specified on the AMIGA's side.
XX
XXScript file operation:
XX----------------------
XXThe script file can be invoked by selecting 'execute file' from the
XXscript menu. At any time you can abort the script file by selecting
XX'Abort Execution'.
XX
XXDuring the time script file is running the terminal emulation is still
XXactive and you may type simulataneous to the script file. This may be
XXdesired if your script file is WAITing for a string or is DELAYing for
XXa period of time etc.
XX
XXScript file Commands (case insensitive):
XX------------------------------------------------------------
XX#	Commented line
XX   Format:
XX	# comment		 may not be on same line as a command.
XX   Example:
XX	# this is a comment
XX------------------------------------------------------------
XXASCII_SEND Send an ascii file to the host.
XX   Format:
XX	(same format as CAPTURE)
XX------------------------------------------------------------
XXBAUD 	Set baud rate
XX   Format:
XX	BAUD rate		Sets the baud rate for send/receive
XX   Example:
XX	BAUD 2400		Sets the baud rate at 2400 baud
XX------------------------------------------------------------
XXBT	Set the break time (for an SB command)
XX   Format:
XX	BT value		Value is in micro-seconds
XX   Example:
XX	BT 750000
XX------------------------------------------------------------
XXCAPTURE	To start/stop ascii file capture.
XX   Format:
XX	CAPTURE	file		Start ascii capturing
XX	CAPTURE			End ascii capturing
XX   Example:
XX	CAPTURE foo.bar		Starts capture of file foo.bar
XX	CAPTURE			Ends ascii capture of file foo.bar
XX------------------------------------------------------------
XXCD 	To change the local directory
XX   Format:
XX	CD	newdir		set a new directory for file transfers
XX   Example:
XX	CD	DF1:foo/bar	set the directory as specified
XX------------------------------------------------------------
XXDELAY 	Suspends script file for a specified time
XX   Format:        
XX        DELAY 	n		Suspends execution for n seconds
XX   Example:
XX	DELAY	2		Suspends for 2 seconds
XX------------------------------------------------------------
XXEXIT	Ends execution of the current script file.
XX   Format:
XX	EXIT			Exit the current script
XX	EXIT VT100		Exit vt100 program
XX	EXIT newscript		Exit this script and start up newscript
XX   Example:
XX	EXIT DF1:FOO.BAR	Exit the current script and start FOO.BAR
XX------------------------------------------------------------
XXGOTO	Jumps to a different part of the script file.
XX   Format:
XX	GOTO label		Jumps to a line beginning with label:
XX				Jumps may be forward or backward.
XX   Example:
XX	FOO:			Sets up a label
XX	GOTO FOO		Jumps to FOO
XX------------------------------------------------------------
XXKB  	Send a BYE packet to a host KERMIT server (shut down server).
XX   Format:
XX	KB
XX------------------------------------------------------------
XXKG  	Gets files from host. (which is running as a server).
XX   Format:
XX	(same format as KS)
XX------------------------------------------------------------
XXKR  	Receives a file from kermit host (not running as server)
XX   Format:
XX	(same format as KS)
XX------------------------------------------------------------
XXKS  	Sends files via kermit to the host.
XX   Format:
XX	KS file			Send one file
XX	KS file1,file2,...	Send multiple files
XX	KS file1,file2,...,$	Send multiple files and shut down server
XX   Example:
XX	KS foo.bar		sends foo.bar (note no quoting is used)
XX	KS foo1,foo2,foo3	sends three files
XX	KS foo1,foo2,foo3,$	sends three files and shuts down server
XX------------------------------------------------------------
XXON	Peforms a command every time a string is received
XX   Format:
XX        ON      "string"  cmd	Execute cmd when string is received.
XX				Only one ON string may be installed at a
XX				time.
XX
XX  				If cmd is a GOTO and we were previously
XX				WAITing for a string the WAIT is aborted and
XX				execution resumes at the new label.
XX
XX              			If cmd is not SEND and we were previously
XX				DELAYing, then the DELAY is aborted and the
XX				cmd is executed, followed by the next command
XX				after the DELAY.
XX
XX				If cmd is a SEND and we were previously
XX				DELAYing, then the DELAY is continued.
XX   Example:
XX        ON  "LOSS CARRIER" GOTO RESTART
XX				If modem drops carrier, try to redial
XX        ON  "--more--" SEND " "
XX				Send a space every time --more-- is received
XX------------------------------------------------------------
XXPARITY	Sets the parity
XX   Format:
XX	PARITY	type		Set the parity type
XX   Example:
XX	PARITY	NONE		no parity
XX	PARITY	MARK		mark parity
XX	PARITY	SPACE		space parity
XX	PARITY	ODD		odd parity
XX	PARITY	EVEN		even parity
XX------------------------------------------------------------
XXSEND 	Sends a string or character to the host.
XX   Format:
XX	SEND    "string"	Sends a string to the host. Beginning and
XX				ending double quotes (") are required. A
XX				carat (^) may be used to send control chars.
XX				Two carats transmits a carat character.
XX        SEND    chr           	Sends a single character.
XX        SEND    ^chr   	    	Sends a single control character. The chr
XX				is NOT case sensitve
XX   Example:
XX	SEND	"mail"		Send the string mail
XX	SEND    "dir^M"		Send the string dir followed by a 
XX	SEND	a		Send the letter a
XX	SEND	^C		Send a control C
XX	SEND	"abc^^def"	Send the string abc^def
XX	SEND	^^		Send a control-uparrow
XX	SEND	"		Send the '"' character
XX------------------------------------------------------------
XXSB	Sends a break character to the host
XX   Format:
XX	SB			Note that any pending character to send
XX   Example:				is aborted by this call
XX	SB
XX------------------------------------------------------------
XXTM	Set a transfer mode for KERMIT to use
XX   Format:
XX	TM type			type of transfers to perform
XX   Example:
XX	TM IMAGE		image mode transfers
XX	TM CRLF			 text transfers (VMS Kermit).
XX------------------------------------------------------------
XXWAIT 	Suspends the script file until a certain string is received.
XX   Format:
XX	WAIT	"string"	Same rules for string as SEND
XX	WAIT			Enter an endless wait. Usually used after
XX				some "ON" commands have been set up. Can
XX				still aborted via the script menu.
XX   Example:
XX        WAIT    "User:"    	Waits for the string User:
XX        WAIT               	Waits forever
XX------------------------------------------------------------
XXXR  	Receives a file via XMODEM.
XX   Format:
XX	(same format as KS)
XX------------------------------------------------------------
XXXS  	Sends a file via XMODEM.
XX   Format:
XX	(same format as KS)
XX------------------------------------------------------------
XX
XX
XXScript file examples:
XX--------------------
XX###################################################################
XX# Script to dial work (dialwork.script)
XX#	v2.4	861214	DBW
XX###################################################################
XX#
XX# Make sure that we have all the parameters we want
XX#
XX	DELAY	2
XX	BAUD	2400
XX	PARITY	NONE
XX	TM	CRLF
XX	BT	750000
XX	SB
XX#
XX# First get the modem's attention:
XX#
XXStart:
XX	DELAY 1
XX	ON "Ready" GOTO Dial
XX	SEND ^B
XX	DELAY 2
XX	GOTO Start
XX#
XX# Now dial the 2400 baud line to work:
XX#
XXDial:
XX	ON "Attached" GOTO Login
XX	SEND "$2400!"
XX	DELAY 30
XX	GOTO Start
XX#
XX# We got attached, so keep hitting return until the Gandalf terminal
XX# handler wakes up:
XX#
XXLogin:
XX	ON "enter" GOTO Gandalf
XX	DELAY 1
XX	SEND ^M
XX	GOTO Login
XX#
XX# Now connect from the Gandalf to the terminal server (ts1):
XX# (when it asks for a password I need to type the password 
XX# manually here)
XX#
XXGandalf:
XX	DELAY 2
XX	SEND "ts1^M"
XX	WAIT "class start"
XX#
XX# Keep sending 's until the LAT prompts for a username:
XX#
XXWaitLat:
XX	DELAY 2
XX	ON "username>" GOTO Lat
XX	SEND ^M
XX	GOTO WaitLat
XX#
XX# Tell the LAT that it's me, and connect to the "cookie cluster"
XX# (my host systems). Tell the cluster my user name.
XX# (when it asks for a password I need to type the password
XX# manually here)
XX#
XXLat:
XX	SEND "wecker^M"
XX	DELAY 1
XX	SEND "connect cookie^M"
XX	WAIT "Username:"
XX	SEND "WECKER^M"
XX	WAIT "at home"
XX	SEND "^M^M^M"
XX#
XX# Got through all the LOGIN garbage, so let's do some work.
XX#
XX	WAIT "$ "
XX#
XX# Now go back to the LAT and connect to my workstation
XX#
XX	SEND "^]connect child^M"
XX	WAIT "login:"
XX	SEND "wecker^M"
XX	WAIT "at home"
XX	SEND "^M^M^M"
XX#
XX# Leave us on VMS
XX#
XX	SEND ^^
XX	DELAY 2
XX#
XX# Go run the next script
XX#
XX	EXIT df1:vt100_source/sendvt100.script
XX
XX#####################################################################
XX# Script to upload the terminal emulator sources (sendvt100.script)
XX#	v2.4	861214	DBW
XX#####################################################################
XX#
XX# Make sure that we have all the parameters we want
XX#
XX	DELAY	2
XX	PARITY	NONE
XX	TM	IMAGE
XX#
XX# Get into the right directory and upload to my U**X workstation
XX#
XX	CD df1:vt100_source
XX	SEND ^^
XX	SEND "cd ~/amiga/vt100^M"
XX	SEND "rm -f *^M"
XX	WAIT "% "
XX	DELAY 2
XX#
XX# Send the readme file for the terminal emulator via XMODEM:
XX#
XX	SEND "xmodem -r readme^M"
XX	DELAY 3
XX	XS readme
XX	WAIT "% "
XX#
XX# Send the other terminal emulator files via KERMIT:
XX#
XX	DELAY 1
XX	SEND "kermit -x^M"
XX	DELAY 3
XX	KS vt100.doc,makefile,vt100.h,*.c
XX	DELAY 2
XX	KB
XX	WAIT "% "
XX#
XX# We popped out of server mode, so send the compiled code
XX#
XX	DELAY 1
XX	SEND "kermit -i -x^M"
XX	DELAY 3
XX	KS vt100
XX	DELAY 2
XX	KB
XX	WAIT "% "
XX#
XX# Now build the target shar files
XX#
XX	SEND "shar -a readme vt100.doc makefile vt100.h vt100.c init.c "
XX	SEND "> vt100_24a.shar^M"
XX	SEND "shar -a script.c remote.c window.c expand.c kermit.c xmodem.c "
XX	SEND "> vt100_24b.shar^M"
XX#
XX# Time to pull copies over to VMS
XX#
XX	SEND ^^
XX	SEND "swi [wecker.amiga]^M"
XX	SEND "cop child::"
XX	SEND "
XX	SEND "/staff/wecker/amiga/vt100/vt100_24a.shar"
XX	SEND "
XX	SEND " []vt100_24a.shar^M"
XX	WAIT "$ "
XX	SEND "cop child::"
XX	SEND "
XX	SEND "/staff/wecker/amiga/vt100/vt100_24b.shar"
XX	SEND "
XX	SEND " []vt100_24b.shar^M"
XX	WAIT "$ "
XX	SEND "cop child::"
XX	SEND "
XX	SEND "/staff/wecker/amiga/vt100/vt100"
XX	SEND "
XX	SEND " []vt100_24.bin^M"
XX	WAIT "$ "
XX#
XX# Make them available to the world
XX#
XX	SEND "pub vt100_24*.*^M"
XX	WAIT "$ "
XX#
XX# All done so go to the next script
XX#
XX	EXIT df1:vt100_source/getpics.script
XX
XX###################################################################
XX# Script to download images (getpics.script)
XX#	v2.4	861214	DBW
XX###################################################################
XX#
XX# Make sure that we have all the parameters we want
XX#
XX	DELAY	2
XX	PARITY	NONE
XX	TM	CRLF
XX#
XX# Get into the right directory and download
XX#
XX	CD RAY:
XX	SEND "swi [wecker.render]^M"
XX	SEND "kermit server^M"
XX	DELAY 3
XX	KG *.img
XX	DELAY 2
XX	KB
XX	WAIT "$ "
XX#
XX# Now get out of the emulator
XX#
XX	EXIT VT100
XX
SHAR_EOF
if test 17610 -ne "`wc -c vt100.doc`"
then
echo shar: error transmitting vt100.doc '(should have been 17610 characters)'
fi
echo shar: extracting makefile
sed 's/^XX//' << \SHAR_EOF > makefile
XX######################################################################
XX#
XX# Makefile to build vt100 terminal emulator
XX#
XX#	v2.4 861214 DBW - lots of fixes/additions (see readme file)
XX#	v2.3 861101 DBW - minor bug fixes
XX#	v2.2 861012 DBW	- more of the same
XX#	v2.1 860915 DBW - new features (see README)
XX#	     860823 DBW - Integrated and rewrote lots of code
XX#	v2.0 860809 DBW	- Major release.. LOTS of changes
XX# 	v1.1 860720 DBW	- Switches, 80 cols, colors, bug fixes
XX# 	v1.0 860712 DBW	- First version released
XX#
XX#
XX# Don't forget to define the right compiler (MANX or LATTICE) in VT100.H
XX#
XX######################################################################
XX
XXOBJS	= vt100.o init.o window.o xmodem.o remote.o \
XX	  kermit.o script.o expand.o
XX
XXINCL	= vt100.h
XX#INCL	= 
XX
XXvt100	: $(OBJS)
XX	copy df0:lib/c.lib ram:
XX	ln -v -o vt100 $(OBJS) ram:c.lib
XX	delete ram:#?.lib
XX
XXvt100.o	: vt100.c $(INCL)
XX	cc +Hvt100.syms vt100.c
XX
XXinit.o	: init.c $(INCL)
XX	cc +Ivt100.syms init.c
XX
XXwindow.o : window.c $(INCL)
XX	cc +Ivt100.syms window.c
XX
XXxmodem.o : xmodem.c $(INCL)
XX	cc +Ivt100.syms xmodem.c
XX
XXremote.o : remote.c $(INCL)
XX	cc +Ivt100.syms remote.c
XX
XXkermit.o : kermit.c $(INCL)
XX	cc +Ivt100.syms kermit.c
XX
XXscript.o : script.c $(INCL)
XX	cc +Ivt100.syms script.c
XX
XXexpand.o : expand.c $(INCL)
XX	cc +Ivt100.syms expand.c
XX
XX
SHAR_EOF
if test 1295 -ne "`wc -c makefile`"
then
echo shar: error transmitting makefile '(should have been 1295 characters)'
fi
echo shar: extracting vt100.h
sed 's/^XX//' << \SHAR_EOF > vt100.h
XX/*********************************************************************
XX *  a terminal program that has ascii and xmodem transfer capability
XX *
XX *	v2.4 861214 DBW - lots of fixes/additions (see readme file)
XX *	v2.3 861101 DBW - minor bug fixes
XX *	v2.2 861012 DBW - more of the same
XX *	v2.1 860915 DBW - new features (see README)
XX *	     860823 DBW - Integrated and rewrote lots of code
XX *	v2.0 860809 DBW	- Major release.. LOTS of changes
XX *	v1.1 860720 DBW	- Switches, 80 cols, colors, bug fixes
XX *	v1.0 860712 DBW	- First version released
XX *
XX *  use esc to abort xmodem transfer
XX *
XX *  written by Michael Mounier
XX *  new version by Dave Wecker 860621
XX ********************************************************************/
XX
XX/* ########  define the compiler type here ######## */
XX#define	LATTICE	0
XX#define MANX	1
XX
XX/*  compiler diretives to fetch the necessary header files */
XX#include 
XX#include 
XX#include 
XX#include 
XX#include 
XX#include 
XX#include 
XX#include 
XX#include 
XX#include 
XX#include 
XX#include 
XX#include 
XX#include 
XX#include 
XX#include 
XX#include 
XX#include 
XX#include 
XX
XX#if MANX
XX#include 
XX#undef NULL
XX#define   NULL   ((void *)0)
XX#endif
XX
XX#define INTUITION_REV 1L
XX#define GRAPHICS_REV  1L
XX
XX/* things for xmodem send and recieve */
XX#define GOODREAD    0
XX#define TIMEOUT	    1
XX#define USERABORT   2
XX#define SECSIZ   0x80
XX#define TTIME_SHORT 5        /* number of seconds for short timeout */
XX#define TTIME_LONG  50	     /* number of seconds for long  timeout */
XX#define TTIME_KERMIT 10	     /* number of seconds for KERMIT timeout*/
XX#define BufSize  0x200       /* Text buffer for XMODEM */
XX#define ERRORMAX 10          /* Max errors before abort */
XX#define RETRYMAX 10          /* Maximum retrys before abort */
XX#define SOH      1           /* Start of sector char */
XX#define EOT      4           /* end of transmission char */
XX#define ACK      6           /* acknowledge sector transmission */
XX#define NAK      21          /* error in transmission detected */
XX
XX#define FILEMAX 8    /* number of file menu items */
XX#define COMMAX 3     /* number of communication sub menus */
XX#define RSMAX 5      /* speed menu items */
XX#define PARMAX 5     /* parity items */
XX#define XFMAX 2      /* transfer mode items */
XX#define SCRIPTMAX 2  /* script menu items */
XX#define UTILMAX 3    /* utility menu */
XX#define MAXMENU 4    /* total number of menu entries */
XX
XX#define FSF_REVERSE 256	/* fake font style to flag INVERSVID mode */
XX
XX/* things for script support */
XX
XX#define GOTOLABEL   1
XX#define	NEXTCOMMAND 0
XX#define ONCOMMAND   2
XX
XX#define	WAIT_TIMER  2
XX#define WAIT_STRING 1
XX
XX/* things for 'beep' support */
XX#define BEEPSIZE    10L
XX#define BEEPFREQ    1000L
XX#define COLORCLOCK  3579545L
XX
XXextern struct MsgPort *CreatePort();
XXextern char *malloc(),*strcpy(),*fgets();
XXextern long ftell();
XX
XX#ifdef MODULE_MAIN
XXchar    bufr[BufSize];
XXint     fd, timeout = FALSE, ttime;
XXint	multi = FALSE, server;
XXlong    bytes_xferred;
XXchar	MyDir[60];
XXstruct IntuitionBase *IntuitionBase;
XXstruct GfxBase *GfxBase;
XX
XXstruct NewScreen NewScreen = {
XX   0L,0L,640L,200L,1L,       /* left, top, width, height, depth */
XX   0,1,HIRES,    /* DetailPen, BlockPen, ViewModes */
XX   CUSTOMSCREEN,NULL,   /* Type, Font */
XX   (UBYTE *)"VT100", /* Title */
XX   NULL,NULL };         /* Gadgets, Bitmap */
XX
XXstruct NewWindow NewWindow = {
XX   0,0L,640L,200L,     /* left, top, width, height */
XX   0,1,              /* detailpen, blockpen */
XX   MENUPICK | CLOSEWINDOW | RAWKEY | NEWSIZE,
XX   SMART_REFRESH | ACTIVATE | BORDERLESS |
XX   WINDOWCLOSE | WINDOWDEPTH | WINDOWDRAG, /* Flags */
XX   NULL,NULL,        /* FirstGadget, CheckMark */
XX   (UBYTE *)"VT100 (v2.4 861214 DBW) Terminal Window",
XX   NULL,             /* set screen after open screen */
XX   NULL,             /* bitmap */
XX   640L, 200L, 640L, 200L,/* minw, minh, maxw, maxh */
XX   CUSTOMSCREEN      /* Type */
XX   };
XX
XXstruct Screen *myscreen;            /* ptr to applications screen */
XXstruct Window *mywindow;            /* ptr to applications window */
XXstruct ViewPort *myviewport;
XXstruct IntuiMessage *NewMessage;    /* msg structure for GetMsg() */
XXstruct Preferences  *Prefs;	    /* preferences from GetPrefs() */
XX
XXstruct MenuItem FileItem[FILEMAX];
XXstruct IntuiText FileText[FILEMAX];
XXstruct MenuItem CommItem[COMMAX];
XXstruct IntuiText CommText[COMMAX];
XXstruct MenuItem RSItem[RSMAX];
XXstruct IntuiText RSText[RSMAX];
XXstruct MenuItem ParItem[PARMAX];
XXstruct IntuiText ParText[PARMAX];
XXstruct MenuItem XFItem[XFMAX];
XXstruct IntuiText XFText[XFMAX];
XXstruct MenuItem ScriptItem[SCRIPTMAX];
XXstruct IntuiText ScriptText[SCRIPTMAX];
XXstruct MenuItem UtilItem[UTILMAX];
XXstruct IntuiText UtilText[UTILMAX];
XXstruct Menu menu[MAXMENU];
XXstruct IOExtSer *Read_Request;
XXchar *rs_in;
XXstruct IOExtSer *Write_Request;
XXchar rs_out[2];
XXstruct timerequest Timer;
XXstruct MsgPort *Timer_Port = NULL;
XXstruct timerequest Script_Timer;
XXstruct MsgPort *Script_Timer_Port = NULL;
XXstruct IOAudio Audio_Request;
XXstruct MsgPort *Audio_Port = NULL;
XXUBYTE  *BeepWave;
XXUBYTE  Audio_AllocMap[4] = { 1, 8, 2, 4 };
XXint want_message;
XXint x,y,curmode,keyapp,curapp;
XXint MINX	= 0;
XXint MAXX	= 632;
XXint MINY	= 14;
XXint MAXY	= 198;
XXint top		= 14;
XXint bot		= 198;
XXint savx	= 0;
XXint savy	= 14;
XXint savmode	= 0;
XXint nlmode	= 0;
XXint alt		= 0;
XXint savalt	= 0;
XXint a[2]	= { 0, 0 };
XXint sa[2]	= { 0, 0 };
XXint  inesc	= -1;
XXint  inctrl	= -1;
XXint  private	= 0;
XXint  badseq	= 0;
XXchar *blanks	=
XX    "                                                      ";
XXint  maxcol	= 79;
XX
XX/*************************** defaults *******************************/
XXint	p_baud	     = 2400;	    /* baud rate */
XXint	p_screen     = 1;	    /* 0 = WORKBENCH,	    1 = CUSTOM */
XXint	p_wbcolors   = 1;	    /* 0 = Custom, 1 = Workbench colors */
XXint	p_interlace  = 1;	    /* 0 = no interlace,    1 = interlace */
XXint	p_depth	     = 1;	    /* number of bit planes (1 or 2) */
XXint	p_foreground = 0x950;	    /* default foreground RGB color */
XXint	p_background = 0x000;	    /* default background RGB color */
XXint	p_bold	     = 0x900;	    /* default BOLD       RGB color */
XXint	p_cursor     = 0x009;	    /* default Cursor	  RGB color */
XXint	p_lines	     = 48;	    /* number of lines on the screen */
XXint	p_mode	     = 1;	    /* 0 = image, 1 = CRLF (for kermit) */
XXint	p_buffer     = 512;	    /* read buffer size (>= 512 bytes) */
XXint     p_parity     = 0;	    /* 0=none,1=mark,2=space,3=even,4=odd */
XXlong	p_break	     = 750000;	    /* break time (in micro seconds) */
XXint	p_volume     = 64;	    /* beep volume (0 = DisplayBeep) */
XXint	p_wrap	     = 0;	    /* 0 = truncate, 1 = wrap long lines */
XXchar	p_keyscript  = 0x7E;	    /* function key script introducer = ~ */
XXchar	*p_f[10]     = {	    /* function key defaults */
XX    "\033OP","\033OQ","\033OR","\033OS",
XX    "f5","f6","f7","f8","f9","f10" };
XX
XXchar	*p_F[10]     = {	    /* shifted function key defaults */
XX    "F1","F2","F3","F4","F5",
XX    "F6","F7","F8","F9","F10"};
XX
XX/* for script file */
XXint script_on;
XXint script_wait;
XXvoid setserbaud(), setparams(), handle_menupick();
XX
XX#else /* not MODULE_MAIN */
XX
XXextern int     multi;		    /* flags multi file transfers */
XXextern int     server;
XXextern int     want_message;
XXextern char    bufr[BufSize];
XXextern int     fd, timeout, ttime;
XXextern long    bytes_xferred;
XXextern char    MyDir[60];
XX
XXextern struct IntuitionBase *IntuitionBase;
XXextern struct GfxBase *GfxBase;
XX
XXextern struct NewScreen NewScreen;
XXextern struct NewWindow NewWindow;
XXextern struct Screen *myscreen;
XXextern struct Window *mywindow;
XXextern struct ViewPort *myviewport;
XXextern struct IntuiMessage *NewMessage;
XXextern struct Preferences  *Prefs;
XXextern struct MenuItem FileItem[FILEMAX];
XXextern struct IntuiText FileText[FILEMAX];
XXextern struct MenuItem CommItem[COMMAX];
XXextern struct IntuiText CommText[COMMAX];
XXextern struct MenuItem RSItem[RSMAX];
XXextern struct IntuiText RSText[RSMAX];
XXextern struct MenuItem ParItem[PARMAX];
XXextern struct IntuiText ParText[PARMAX];
XXextern struct MenuItem XFItem[XFMAX];
XXextern struct IntuiText XFText[XFMAX];
XXextern struct MenuItem ScriptItem[SCRIPTMAX];
XXextern struct IntuiText ScriptText[SCRIPTMAX];
XXextern struct MenuItem UtilItem[UTILMAX];
XXextern struct IntuiText UtilText[UTILMAX];
XXextern struct Menu menu[MAXMENU];
XXextern struct timerequest Timer, Script_Timer;
XXextern struct MsgPort *Timer_Port, *Script_Timer_Port;
XXextern struct IOExtSer *Read_Request;
XXextern char *rs_in;
XXextern struct IOExtSer *Write_Request;
XXextern char rs_out[2];
XXextern int x,y,curmode,keyapp,curapp;
XXextern int MINX,MAXX,MINY,MAXY,top,bot,savx,savy;
XXextern int savmode,nlmode,alt,savalt,a[2],sa[2];
XXextern int inesc,inctrl,private,badseq,maxcol;
XXextern char *blanks;
XXextern struct IOAudio Audio_Request;
XXextern struct MsgPort *Audio_Port;
XXextern UBYTE  *BeepWave;
XXextern UBYTE  Audio_AllocMap[4];
XX
XXextern int p_baud,p_screen,p_interlace,p_depth,p_buffer,p_wbcolors;
XXextern int p_foreground,p_background,p_bold,p_cursor,p_lines,p_mode;
XXextern int p_parity,p_volume,p_wrap,p_keyscript;
XXextern long p_break;
XXextern char *p_f[10],*p_F[10];
XXextern int script_on;
XXextern int script_wait;
XX
XXextern int do_send(),do_capture(),cleanup();
XXextern void setserpar(), setserbaud(), setparams(),
XX	handle_menupick();
XX
XX#endif /* not MODULE_MAIN */
XX
XX#ifndef MODULE_INIT
XXextern void InitDevs(),InitFileItems(),InitCommItems(),
XX	 InitScriptItems(),InitUtilItems(),InitMenu();
XXextern char *InitDefaults();
XX#endif
XX
XX#ifndef MODULE_WINDOW
XXextern	void filename(),emits(),emit(),emitbatch(),cursorflip();
XXextern	int  toasc();
XX#endif
XX
XX#ifndef MODULE_XMODEM
XXextern	void sendchar(),sendstring(),sendbreak();
XXextern	int  readchar(),XMODEM_Read_File(),XMODEM_Send_File();
XX#endif
XX
XX#ifndef MODULE_REMOTE
XXextern	void doremote(),doindex();
XX#endif
XX
XX#ifndef MODULE_KERMIT
XXextern	int	doksend(),dokreceive(), saybye();
XXextern	void	multi_xfer();
XX#endif
XX
XX#ifndef MODULE_SCRIPT
XXextern int script_start(), chk_script(), exit_script(),
XX    do_script_cmd();
XX#endif
XX
XX#ifndef MODULE_EXPAND
XXextern char **expand();
XXextern int  set_dir(), free_expand();
XX#endif
XX
SHAR_EOF
if test 10265 -ne "`wc -c vt100.h`"
then
echo shar: error transmitting vt100.h '(should have been 10265 characters)'
fi
echo shar: extracting vt100.c
sed 's/^XX//' << \SHAR_EOF > vt100.c
XX/********************************************************************
XX *  vt100 terminal emulator with xmodem transfer capability
XX *
XX *	v2.4 861214 DBW - lots of fixes/additions (see readme file)
XX *	v2.3 861101 DBW - minor bug fixes
XX *	v2.2 861012 DBW - more of the same
XX *	v2.1 860915 DBW - new features (see README)
XX *	     860901 ACS - Added Parity and Word Length and support code
XX *	     860823 DBW - Integrated and rewrote lots of code
XX *	v2.0 860809 DBW - Major rewrite
XX *	v1.1 860720 DBW	- Switches, 80 cols, colors, bug fixes
XX *	v1.0 860712 DBW	- First version released
XX *
XX *  use  to abort xmodem or kermit transfers
XX *
XX *  written by Michael Mounier
XX *  new version by Dave Wecker
XX *******************************************************************/
XX
XX/*  all includes defines and globals */
XX#define MODULE_MAIN 1
XX#include "vt100.h"
XX
XX/******************************************************/
XX/*                   Main Program                     */
XX/*                                                    */
XX/*      This is the main body of the program.         */
XX/******************************************************/
XX
XXchar lookahead[80];
XXFILE *tranr = NULL;
XXFILE *trans = NULL;
XXint capture,send;
XXchar name[80];
XXstruct MsgPort *mySerPort;
XX
XXmain(argc,argv)
XXint	argc;
XXchar	**argv;
XX    {
XX    ULONG class;
XX    unsigned int code;
XX    int KeepGoing,i,la,dola,actual;
XX    char c,*ptr;
XX
XX    ptr = InitDefaults(argc,argv);
XX    InitDevs();
XX    InitFileItems();
XX    InitCommItems();
XX    InitScriptItems();
XX    InitUtilItems();
XX    InitMenu();
XX    SetMenuStrip(mywindow,&menu[0]);
XX
XX    MyDir[0]  =	    '\000';
XX    KeepGoing =	    TRUE;
XX    capture   =	    FALSE;
XX    send      =	    FALSE;
XX    maxcol    =	    MAXX / 8;
XX    la	      =	    0;
XX    x	      =	    MINX ; 
XX    y	      =	    MINY; 
XX    curmode   =	    FS_NORMAL;
XX    keyapp    =	    0;
XX    curapp    =	    0;
XX    script_on =     FALSE;
XX    script_wait=    TRUE;
XX    SetAPen(mywindow->RPort,1L);
XX    cursorflip();
XX    cursorflip();    
XX    emit(12);
XX    mySerPort = Read_Request->IOSer.io_Message.mn_ReplyPort;
XX    SendIO(Read_Request);
XX
XX    /* see if we had a startup script */
XX    if (ptr != NULL) script_start(ptr);
XX
XX    while( KeepGoing )
XX	    {
XX	    /* wait for window message or serial port message */
XX	    cursorflip();
XX	    if (script_wait)	/* if script ready dont wait here */
XX		Wait(
XX		 (1L << mySerPort->mp_SigBit) |
XX		 (1L << mywindow->UserPort->mp_SigBit) |
XX		 (1L << Script_Timer_Port->mp_SigBit));
XX	    cursorflip();
XX	    
XX	    /* do ascii file send */
XX	    if (send)
XX		{
XX		if ((c=getc(trans)) != EOF) {
XX		    if (c == '\n') c = '\r';
XX		    sendchar(c);
XX		    }
XX		else {
XX		    fclose(trans);
XX		    emits("\nFile Sent\n");
XX		    send=FALSE;
XX		    }
XX		}
XX
XX	    /* see if there are any characters from the host */
XX	    if (CheckIO(Read_Request)) {
XX		WaitIO(Read_Request);
XX		c = rs_in[0] & 0x7F;
XX		doremote(c);
XX		if (script_on) chk_script(c);
XX	        if (capture && c != 10) {
XX	      	    if (c == 13) c = 10;
XX		    putc(c , tranr);
XX		    }
XX		Read_Request->IOSer.io_Command = SDCMD_QUERY;
XX		DoIO(Read_Request);
XX		Read_Request->IOSer.io_Command = CMD_READ;
XX		actual = (int)Read_Request->IOSer.io_Actual;
XX		if (actual > 0) {
XX		    if (inesc   <  0 &&
XX			inctrl  <  0 &&
XX			a[alt]  == 0 &&
XX			capture == FALSE) dola = 1;
XX		    else dola = 0;
XX		    Read_Request->IOSer.io_Length =
XX			Read_Request->IOSer.io_Actual;
XX		    DoIO(Read_Request);
XX		    Read_Request->IOSer.io_Length = 1;
XX
XX		    for (i = 0; i < actual; i++) {
XX			c=rs_in[i] & 0x7f;
XX			if (script_on) chk_script(c);
XX
XX			if (dola == 1) {
XX			    if (c >= ' ' && c <= '~' && la < 80)
XX				lookahead[la++] = c;
XX			    else {
XX				if (la > 0) {
XX				    emitbatch(la,lookahead);
XX				    la = 0;
XX				    }
XX				doremote(c);
XX				dola = 0;
XX				}
XX			    }
XX			else {
XX			    doremote(c);
XX			    if (inesc   <  0 &&
XX				inctrl  <  0 &&
XX				a[alt]  == 0 &&
XX				capture == FALSE) dola = 1;
XX			    if (capture && c != 10) {
XX				if (c == 13) c = 10;
XX				putc(c , tranr);
XX				}
XX			    }
XX			}
XX
XX		    /* dump anything left in the lookahead buffer */
XX		    if (la > 0) {
XX			emitbatch(la,lookahead);
XX			la = 0;
XX			}
XX		    }
XX		SendIO(Read_Request);
XX		}
XX
XX	    while((NewMessage = 
XX		    (struct IntuiMessage *)GetMsg(mywindow->UserPort))
XX			!= FALSE) {
XX		class = NewMessage->Class;
XX		code = NewMessage->Code;
XX		ReplyMsg( NewMessage );
XX		switch( class )
XX		    {
XX		    case CLOSEWINDOW:
XX		    KeepGoing = FALSE;
XX		    break;
XX
XX		    case RAWKEY:
XX		    c = toasc(code,0);
XX		    break;
XX
XX		    case NEWSIZE:
XX		    emit(12);
XX		    break;
XX
XX		    case MENUPICK:
XX		    handle_menupick(class,code);
XX		    break;				    
XX		    }   /* end of switch (class) */
XX		}   /* end of while ( newmessage )*/
XX
XX            if (!script_wait || 
XX                 (CheckIO(&Script_Timer) && 
XX		    script_wait == WAIT_TIMER))
XX		do_script_cmd(NEXTCOMMAND);
XX	    }  /* end while ( keepgoing ) */
XX		
XX    /*   It must be time to quit, so we have to clean
XX    *   up and exit.
XX    */
XX
XX    cleanup("",0);
XX
XX    } /* end of main */
XX
XX/* cleanup code */
XX
XXcleanup(reason, fault)
XXchar *reason;
XXint fault;
XX    {
XX    switch(fault) {
XX	case 0:		/* quitting close everything */
XX	ClearMenuStrip( mywindow ); 
XX	CloseDevice(&Audio_Request);
XX
XX	case 8:		/* error opening audio */
XX	DeletePort(Audio_Port);
XX	FreeMem(BeepWave,BEEPSIZE);
XX	CloseDevice(&Timer);
XX
XX	case 7:		/* error opening timer */
XX	DeletePort(Timer_Port);  
XX	CloseDevice(&Script_Timer);
XX	DeletePort(Script_Timer_Port);
XX
XX	case 6:		/* error opening write device */
XX	DeletePort(Write_Request->IOSer.io_Message.mn_ReplyPort);
XX	FreeMem(Write_Request,(long)sizeof(*Write_Request));
XX	CloseDevice(Read_Request);
XX
XX	case 5:		/* error opening read device */
XX	DeletePort(Read_Request->IOSer.io_Message.mn_ReplyPort);
XX	FreeMem(Read_Request,(long)sizeof(*Read_Request));
XX	CloseWindow( mywindow );
XX
XX	case 4:		/* error opening window */
XX	if (p_screen != 0) CloseScreen( myscreen );
XX
XX	case 3:		/* error opening screen */
XX	case 2:		/* error opening graphics library */
XX	case 1:		/* error opening intuition */
XX	default:
XX	if (*reason) puts (reason);
XX	}
XX    exit(fault);
XX    } 
XX
XXdo_capture(file)
XXchar *file;
XX    {
XX    if (capture == TRUE)
XX        {
XX        capture=FALSE;
XX        fclose(tranr);
XX        emits("\nEnd File Capture\n");
XX        }
XX    else
XX        {
XX        if (file == NULL) {
XX            emits("\nAscii Capture:");
XX            filename(name);
XX	    } 
XX	else strcpy(name, file);
XX        if ((tranr=fopen(name,"w")) == 0) {
XX	    capture=FALSE;
XX	    emits("\nError Opening File\n");
XX	    return(FALSE);
XX	    }
XX	capture=TRUE;
XX        }
XX    }
XX
XXdo_send(file)
XXchar *file;
XX    {
XX    if (send == TRUE)
XX	{ 
XX        send=FALSE;
XX        fclose(trans);
XX        emits("\nFile Send Cancelled\n");
XX        }
XX    else
XX        {
XX        if (file == NULL) {
XX            emits("\nAscii Send:");
XX            filename(name);
XX            }
XX	else strcpy(name, file);
XX        if ((trans=fopen(name,"r")) == 0) {
XX   	    send=FALSE;
XX	    emits("\nError Opening File\n");
XX	    return(FALSE);
XX	    }
XX	send=TRUE;
XX	}
XX    }
XX
XXvoid setparams()
XX    {
XX    Read_Request->IOSer.io_Command = 
XX	Write_Request->IOSer.io_Command = 
XX	    SDCMD_SETPARAMS;
XX    DoIO(Read_Request); DoIO(Write_Request);
XX    Read_Request->IOSer.io_Command = CMD_READ;
XX    SendIO(Read_Request);
XX    Write_Request->IOSer.io_Command = CMD_WRITE;
XX    }
XX
XXvoid hangup ()
XX    {
XX    AbortIO(Read_Request);
XX    CloseDevice (Read_Request);
XX    Timer.tr_time.tv_secs=0L;
XX    Timer.tr_time.tv_micro=750000L;
XX    DoIO((char *) &Timer.tr_node);
XX    OpenDevice (SERIALNAME,NULL,Read_Request,NULL);
XX    setparams();
XX    }
XX
XXvoid setserbaud(baud, redomenu)
XXint baud;
XXLONG redomenu;
XX    {
XX    AbortIO(Read_Request);
XX    Write_Request->io_Baud = Read_Request->io_Baud = baud;
XX    setparams();
XX    p_baud = baud;
XX    if (redomenu) {
XX	ClearMenuStrip( mywindow );         /* Remove old menu */
XX	InitCommItems();                    /* Re-do comm menu   */
XX	SetMenuStrip(mywindow,&menu[0]);    /* Re-display the menu */	
XX	}
XX    }
XX
XXvoid handle_menupick(class, code)
XXULONG class;
XXunsigned int code;
XX    {
XX    unsigned int menunum, itemnum, subnum;
XX
XX    if (code == MENUNULL) return;
XX
XX    menunum = MENUNUM( code );
XX    itemnum = ITEMNUM( code );
XX    subnum  = SUBNUM( code );
XX    switch( menunum ) {
XX	case 0:
XX	switch( itemnum ) {
XX	    case 0:
XX	    do_capture(NULL);
XX	    break;
XX
XX	    case 1:
XX	    do_send(NULL);
XX	    break;
XX
XX	    case 2:
XX	    if (p_parity > 0) {
XX		emits("\nParity setting prevents this\n");
XX		break;
XX		}
XX	    emits("\nXmodem Receive:");
XX	    filename(name);
XX	    multi_xfer(name,XMODEM_Read_File,0);
XX	    break;
XX
XX	    case 3:
XX	    if (p_parity > 0) {
XX		emits("\nParity setting prevents this\n");
XX		break;
XX		}
XX	    emits("\nXmodem Send:");
XX	    filename(name);
XX	    multi_xfer(name,XMODEM_Send_File,1);
XX	    break;
XX
XX	    case 4:
XX	    server = TRUE;
XX	    emits("\nKermit GET remote file(s):");
XX	    filename(name);
XX	    multi_xfer(name,dokreceive,0);
XX            break;
XX
XX	    case 5:
XX	    multi_xfer("",dokreceive,0);
XX	    break;
XX
XX	    case 6:
XX	    server = TRUE;
XX	    emits("\nKermit Send local name:");
XX	    filename(name);
XX	    multi_xfer(name,doksend,1);
XX	    break;
XX
XX	    case 7:
XX	    saybye();
XX	    break;
XX	    }
XX	break;
XX
XX	case 1:
XX	switch( itemnum ) {
XX	    case 0:
XX	    switch( subnum ) {
XX		case 0:
XX		setserbaud(300, FALSE);
XX		break;
XX
XX		case 1:
XX		setserbaud(1200, FALSE);
XX		break;
XX
XX		case 2:
XX		setserbaud(2400, FALSE);
XX		break;
XX
XX		case 3:
XX		setserbaud(4800, FALSE);
XX		break;
XX
XX		case 4:
XX		setserbaud(9600, FALSE);
XX		break;
XX		}
XX	    break;	    
XX
XX	    case 1:
XX	    /* Set  Parity */
XX	    p_parity = subnum;
XX	    break;
XX
XX	    case 2:
XX	    /* set transfer mode */
XX	    p_mode = subnum;
XX	    break;
XX	    }
XX	break;
XX
XX	case 2:
XX	if (!itemnum && !script_on) {
XX	    emits("Script file name: ");
XX	    filename(name);
XX	    script_start(name);
XX	    }
XX	if (itemnum && script_on) exit_script();
XX	break;
XX
XX	case 3:
XX	switch( itemnum ) {
XX	    case 0:
XX	    sendbreak();
XX	    break;
XX
XX	    case 1:
XX	    hangup();
XX	    break;
XX
XX	    case 2:
XX	    emits("\nDirectory [");
XX	    emits(MyDir);
XX	    emits("]: ");
XX	    filename(name);
XX	    set_dir(name);
XX	    break;
XX	    }
XX
XX	break;
XX	} /* end of switch ( menunum ) */
XX    }
XX
SHAR_EOF
if test 10134 -ne "`wc -c vt100.c`"
then
echo shar: error transmitting vt100.c '(should have been 10134 characters)'
fi
echo shar: extracting init.c
sed 's/^XX//' << \SHAR_EOF > init.c
XX/***************************************************************
XX * vt100 - terminal emulator - initialization
XX *
XX *	v2.4 861214 DBW - lots of fixes/additions (see readme file)
XX *	v2.3 861101 DBW - minor bug fixes
XX *	v2.2 861012 DBW - more of the same
XX *	v2.1 860915 DBW - new features (see README)
XX *	     860901 ACS	- Added Parity and Word Length and support code
XX *	     860823 DBW - Integrated and rewrote lots of code
XX *	v2.0 860809 DBW - Major rewrite
XX *	v1.1 860720 DBW	- Switches, 80 cols, colors, bug fixes
XX *	v1.0 860712 DBW	- First version released
XX *
XX ***************************************************************/
XX
XX#define MODULE_INIT 1
XX#include "vt100.h"
XX
XXchar line[256];
XXstatic char cmds[] = "V^GRSBLHXEOIT.D";
XX
XXchar *InitDefaults(argc,argv)
XXint	argc;
XXchar	**argv;
XX    {
XX    FILE    *fd;
XX    char    scr[32],delim,macro[256],c0,*ptr,*ptr2;
XX    int	    i,j,k;
XX    long    li;
XX
XX    if (((argc > 1) && (fd=fopen(argv[1],"r")) != 0) ||
XX	(fd=fopen("vt100.init","r")) != 0 ||
XX	(fd=fopen("s:vt100.init","r")) != 0) {
XX	while (fgets(line,256,fd) != 0) {
XX	    if ((c0 = line[0]) == '#') continue;
XX	    if ((c0|' ') == 'e') break;
XX	    switch (c0|' ') {
XX		case 'b':
XX		if ((line[1]|' ') == 'o') {
XX		    /* bold color */
XX		    if (sscanf(line,"%s %x",scr,&i) == 2) p_bold = i;
XX		    break;
XX		    }
XX		if ((line[1]|' ') == 'u') {
XX		    /* buffer size */
XX		    if (sscanf(line,"%s %d",scr,&i) == 2) p_buffer = i;
XX		    if (p_buffer < 512) p_buffer = 512;
XX		    break;
XX		    }
XX		if ((line[1]|' ') == 'r') {
XX		    /* break time */
XX		    if (sscanf(line,"%s %ld",scr,&li) == 2) p_break = li;
XX		    break;
XX		    }
XX		if ((line[1]|' ') != 'a') break;
XX		switch(line[2]|' ') {
XX		    /* baud rate */
XX		    case 'u':
XX		    if (sscanf(line,"%s %d",scr,&i) == 2)
XX			switch (i) {
XX			    case  300:
XX			    case 1200:
XX			    case 2400:
XX			    case 4800:
XX			    case 9600:	p_baud = i; break;
XX			    }
XX		    break;
XX
XX		    /* background */
XX		    case 'c':
XX		    if (sscanf(line,"%s %x",scr,&i) == 2) p_background = i;
XX		    break;
XX		    }
XX		break;
XX
XX		/* screen type */
XX		case 's':
XX		if (sscanf(line,"%s %s",scr,scr) == 2) {
XX		    if ((scr[0]|' ') == 'w') p_screen = 0;
XX		    else		     p_screen = 1;
XX		    }
XX		break;
XX
XX		/* number of lines */
XX		case 'l':
XX		if (sscanf(line,"%s %d",scr,&i) == 2) p_lines = i;
XX		break;
XX
XX		/* screen depth */
XX		case 'd':
XX		if (sscanf(line,"%s %d",scr,&i) == 2) p_depth = i;
XX		break;
XX
XX		/* cursor color */
XX		case 'c':
XX		if (sscanf(line,"%s %x",scr,&i) == 2) p_cursor = i;
XX		break;
XX
XX		/* interlace type */
XX		case 'i':
XX		if (sscanf(line,"%s %s",scr,scr) == 2) {
XX		    if ((scr[1]|' ') == 'n') p_interlace = 1;
XX		    else		     p_interlace = 0;
XX		    }
XX		break;
XX
XX		case 'f':
XX		switch (line[1]|' ') {
XX
XX		    /* foreground color */
XX		    case 'o':
XX    		    if (sscanf(line,"%s %x",scr,&i) == 2) p_foreground = i;
XX		    break;
XX
XX		    /* function key */
XX		    default:
XX		    if (sscanf(&line[1],"%d",&i) != 1) break;
XX		    if (i < 1 || i > 10) break;
XX		    delim = 0;
XX		    for (j=(i==10?3:2); line[j] != 0 &&
XX			      (line[j] == ' ' || line[j] == '\t'); j++) ;
XX		    if (line[j] == 0) {
XX			if (c0 == 'f') p_f[i-1] = NULL;
XX			else	       p_F[i-1] = NULL;
XX			break;
XX			}
XX		    delim = line[j];
XX		    k = 0;
XX		    macro[0] = 0;
XX		    while (line[++j] != delim) {
XX			if (line[j] == 0) {
XX			    if (fgets(line,256,fd) == 0) {
XX				line[0] = delim;
XX				line[1] = 0;
XX				}
XX			    j = -1;
XX			    continue;
XX			    }
XX			if (line[j] == '^' && line[++j] != '^')
XX			    macro[k++] = (line[j]|' ') - 0x60;
XX			else if (line[j] != '\n') macro[k++] = line[j];
XX			macro[k]   = 0;
XX			}
XX		    ptr = malloc(k+1);
XX		    if (c0 == 'f') p_f[i-1] = ptr;
XX		    else	   p_F[i-1] = ptr;
XX		    strcpy(ptr,macro);
XX		    break;
XX		    }
XX		break;
XX
XX		case 'k':
XX		/*keyscript*/
XX		if (sscanf(line,"%s %x",scr,&i) == 2)
XX		    p_keyscript = i & 0x7F;
XX		break;
XX
XX		case 'm':
XX		if (sscanf(line,"%s %s",scr,scr) == 2) {
XX		    if ((scr[0]|' ') == 'i')	p_mode = 0;
XX		    else			p_mode = 1;
XX		    }
XX		break;
XX
XX		case 'p': /*parity*/
XX		if (sscanf(line,"%s %s",scr,scr) == 2)
XX		    switch(*scr|' ') {
XX			case 'n':   p_parity =  0; break;
XX			case 'm':   p_parity =	1; break;
XX			case 's':   p_parity =  2; break;
XX			case 'e':   p_parity =  3; break;
XX			case 'o':   p_parity =  4; break;
XX			}
XX		break;
XX
XX		case 'v': /*volume*/
XX		if (sscanf(line,"%s %d",scr,&i) == 2)
XX		    if (i >= 0) p_volume = i;
XX		break;
XX
XX		case 'w':
XX		/*wrap*/
XX		if ((line[1]|' ') == 'r') {
XX		    if (sscanf(line,"%s %s",scr,scr) == 2) {
XX			if ((scr[1]|' ') == 'n') p_wrap = 1;
XX			else			 p_wrap = 0;
XX			}
XX		    }
XX
XX		/* workbench or custom colors */
XX		else if ((line[1]|' ') == 'b' &&
XX			 sscanf(line,"%s %s",scr,scr) == 2) {
XX		    if ((scr[0]|' ') == 'n') p_wbcolors = 0;
XX		    else		     p_wbcolors = 1;
XX		    }
XX		break;
XX		}
XX	    }
XX	fclose(fd);
XX	}
XX    /* Now set up all the screen info as necessary */
XX    if (p_interlace == 0) {
XX	if (p_lines > 24) p_lines = 24;
XX	MINY = 14;
XX	NewWindow.Height    = (long)((p_lines*8)+8);
XX	}
XX    else {
XX	if (p_lines > 48) p_lines = 48;
XX	MINY = 16;
XX	NewScreen.ViewModes |= LACE;
XX	NewWindow.Height    = (long)((p_lines*8)+10);
XX	}
XX    NewWindow.MinHeight = NewWindow.Height;
XX    NewWindow.MaxHeight = NewWindow.Height;
XX    NewWindow.TopEdge   = 0L;
XX    MAXY = ((p_lines-1)*8) + MINY;
XX    top  = MINY;
XX    bot	 = MAXY;
XX    savx = MINX;
XX    savy = MINY;
XX    if (p_screen == 1) {
XX	if (p_depth > 2) p_depth = 2;
XX	if (p_depth < 1) p_depth = 1;
XX	NewScreen.Depth	    = (long)p_depth;
XX	NewScreen.Height    = (long)((p_lines*8)+16);
XX	if (p_interlace == 1)
XX	    NewScreen.TopEdge   = (long)(400 - NewScreen.Height);
XX	else
XX	    NewScreen.TopEdge   = (long)(208 - NewScreen.Height);
XX	}
XX    else {
XX	p_depth			= 2L;
XX	NewWindow.TopEdge	= 0L;
XX	NewWindow.Screen	= NULL;
XX	NewWindow.Type		= WBENCHSCREEN;
XX	}
XX    /* see if we exit with a startup script */
XX    if ((c0|' ') == 'e') {
XX	ptr = &line[0];
XX	while (*ptr != '\000' && *ptr != ' ' && *ptr != '\t') ptr++;
XX	if (*ptr == '\000') return(NULL);
XX	while (*ptr != '\000' && (*ptr == ' ' || *ptr == '\t')) ptr++;
XX	if (*ptr == '\000') return(NULL);
XX	ptr2 = ptr;	
XX	while (*ptr2 != '\000' && *ptr2 != ' ' &&
XX	       *ptr2 != '\t'   && *ptr2 != '\n') ptr2++;
XX	*ptr2 = '\000';
XX	return(ptr);
XX	}
XX    else return(NULL);
XX    }
XX
XXvoid InitDevs()
XX{
XXUSHORT	colors[4];
XXint	i;
XXBYTE	*b,*c;
XX
XXIntuitionBase = (struct IntuitionBase *)
XX    OpenLibrary("intuition.library", INTUITION_REV);
XXif( IntuitionBase == NULL )
XX    cleanup("can't open intuition",1);
XX
XXGfxBase = (struct GfxBase *)
XX    OpenLibrary("graphics.library",GRAPHICS_REV);
XXif( GfxBase == NULL )
XX    cleanup("can't open graphics library",2);
XX
XXif (p_screen == 1) {
XX    if ((myscreen = (struct Screen *)OpenScreen(&NewScreen)) == NULL)
XX	cleanup("can't open screen",3);
XX    NewWindow.Screen = myscreen;
XX    }
XX
XXif(( mywindow = (struct Window *)OpenWindow(&NewWindow) ) == NULL)
XX    cleanup("can't open window",4);
XX
XXmyviewport   = (struct ViewPort *)ViewPortAddress(mywindow);
XX
XXif (p_screen != 0 && p_wbcolors == 0) {
XX    colors[0] = p_background;
XX    colors[1] = p_foreground;
XX    colors[2] = p_bold;
XX    colors[3] = p_cursor;
XX    if (p_depth == 1)
XX	LoadRGB4(myviewport,(struct ColorMap *)colors,2L);
XX    else
XX	LoadRGB4(myviewport,(struct ColorMap *)colors,4L);
XX    }
XX
XXRead_Request = (struct IOExtSer *)
XX    AllocMem((long)sizeof(*Read_Request),MEMF_PUBLIC|MEMF_CLEAR);
XXRead_Request->io_SerFlags = 0L;
XXRead_Request->IOSer.io_Message.mn_ReplyPort = CreatePort(0L,0L);
XXif(OpenDevice(SERIALNAME,NULL,Read_Request,NULL))
XX    cleanup("Cant open Read device",5);
XXrs_in = malloc(p_buffer+1);
XXRead_Request->io_SerFlags = 0L;
XXRead_Request->io_Baud	  = p_baud;
XXRead_Request->io_ReadLen  = 8L;
XXRead_Request->io_WriteLen = 8L;
XXRead_Request->io_CtlChar  = 0x11130000L;
XXRead_Request->io_RBufLen  = p_buffer;
XXRead_Request->io_BrkTime  = p_break;
XXRead_Request->IOSer.io_Command = SDCMD_SETPARAMS;
XXDoIO(Read_Request);
XXRead_Request->IOSer.io_Command = CMD_READ;
XXRead_Request->IOSer.io_Length  = 1;
XXRead_Request->IOSer.io_Data    = (APTR) &rs_in[0];
XX
XXWrite_Request = (struct IOExtSer *)
XX    AllocMem((long)sizeof(*Write_Request),MEMF_PUBLIC|MEMF_CLEAR);
XXb = (BYTE *)Read_Request;
XXc = (BYTE *)Write_Request;
XXfor (i=0;iIOSer.io_Message.mn_ReplyPort = CreatePort(0L,0L);
XXWrite_Request->IOSer.io_Command = CMD_WRITE;
XXWrite_Request->IOSer.io_Length  = 1;
XXWrite_Request->IOSer.io_Data    = (APTR) &rs_out[0];
XX
XXTimer_Port = CreatePort("Timer Port",0L);
XXScript_Timer_Port = CreatePort("Timer Port",0L);
XX
XXif (OpenDevice(TIMERNAME, UNIT_VBLANK, (char *) &Timer, 0) ||
XX    OpenDevice(TIMERNAME, UNIT_VBLANK, (char *) &Script_Timer, 0)) 
XX	cleanup("can't open timer device",7);
XX
XXTimer.tr_node.io_Message.mn_ReplyPort = Timer_Port;
XXTimer.tr_node.io_Command = TR_ADDREQUEST;
XXTimer.tr_node.io_Flags = 0;
XXTimer.tr_node.io_Error = 0;
XX
XXScript_Timer.tr_node.io_Message.mn_ReplyPort = Script_Timer_Port;
XXScript_Timer.tr_node.io_Command = TR_ADDREQUEST;
XXScript_Timer.tr_node.io_Flags = 0;
XXScript_Timer.tr_node.io_Error = 0;
XX
XXBeepWave   = (UBYTE *)AllocMem(BEEPSIZE,(long)(MEMF_CHIP|MEMF_CLEAR));
XXif (BeepWave != 0) BeepWave[0] = 100;
XX
XXAudio_Port = CreatePort("Audio Port",0L);
XX
XXAudio_Request.ioa_Request.io_Message.mn_ReplyPort   = Audio_Port;
XXAudio_Request.ioa_Request.io_Message.mn_Node.ln_Pri = 85;
XXAudio_Request.ioa_Data		    = Audio_AllocMap;
XXAudio_Request.ioa_Length	    = (ULONG) sizeof(Audio_AllocMap);
XX
XXif (OpenDevice(AUDIONAME, NULL, (char *) &Audio_Request, NULL))
XX	cleanup("can't open audio device",8);
XX
XXAudio_Request.ioa_Request.io_Command	= CMD_WRITE;
XXAudio_Request.ioa_Request.io_Flags	= ADIOF_PERVOL;
XXAudio_Request.ioa_Data		= BeepWave;
XXAudio_Request.ioa_Length	= BEEPSIZE;
XXAudio_Request.ioa_Period	= COLORCLOCK / (BEEPSIZE * BEEPFREQ);
XXAudio_Request.ioa_Volume	= p_volume;
XXAudio_Request.ioa_Cycles	= 100;
XX}
XX
XX/*****************************************************************/
XX/*    The following function initializes the structure arrays    */
XX/*   needed to provide the File menu topic.                      */
XX/*****************************************************************/
XXvoid InitFileItems()
XX    {
XX    int	    n,nplus1;
XX
XX/* initialize each menu item and IntuiText with loop */
XXfor( n=0; n= 2 && n <= 7) {
XX	FileItem[n].Command  = cmds[n-2];
XX	FileItem[n].Flags   |= COMMSEQ;
XX	}
XX    else FileItem[n].Command = 0;
XX    FileItem[n].SubItem = NULL;
XX    FileItem[n].NextSelect = 0;
XX
XX    FileText[n].FrontPen = 0;
XX    FileText[n].BackPen = 1;
XX    FileText[n].DrawMode = JAM2;/* render in fore and background */
XX    FileText[n].LeftEdge = 0;
XX    FileText[n].TopEdge = 1;
XX    FileText[n].ITextFont = NULL;
XX    FileText[n].NextText = NULL;
XX    }
XXFileItem[FILEMAX-1].NextItem = NULL;
XX
XX/* initialize text for specific menu items */
XX
XXFileText[0].IText = (UBYTE *)"Ascii  Capture";
XXFileText[1].IText = (UBYTE *)"Ascii  Send";
XXFileText[2].IText = (UBYTE *)"Xmodem Receive";
XXFileText[3].IText = (UBYTE *)"Xmodem Send";
XXFileText[4].IText = (UBYTE *)"Kermit Get";
XXFileText[5].IText = (UBYTE *)"Kermit Receive";
XXFileText[6].IText = (UBYTE *)"Kermit Send";
XXFileText[7].IText = (UBYTE *)"Kermit BYE";
XX}
XX
XX/******************************************************************
XX/*			Main Comm menu
XX/*		set up for Baud & Parity submenus
XX/******************************************************************/
XXvoid InitCommItems()
XX    {
XX    int	    n,nplus1;
XX
XX/* initialize each menu item and IntuiText with loop */
XXfor( n=0; n= 1 && n <= 2) {
XX	RSItem[n].Command    = cmds[n+5];
XX	RSItem[n].Flags	    |= COMMSEQ;
XX	}
XX    else RSItem[n].Command = 0;
XX    RSItem[n].SubItem = NULL;
XX    RSItem[n].NextSelect = 0;
XX
XX    RSText[n].FrontPen = 0;
XX    RSText[n].BackPen = 1;
XX    RSText[n].DrawMode = JAM2;     /* render in fore and background */
XX    RSText[n].LeftEdge = 0;
XX    RSText[n].TopEdge = 1;
XX    RSText[n].ITextFont = NULL;
XX    RSText[n].NextText = NULL;
XX    }
XXRSItem[RSMAX-1].NextItem = NULL;
XX
XX/* select baud item chekced */
XXswitch (p_baud) {
XX    case 300:	n = 0; break;
XX    case 1200:	n = 1; break;
XX    case 2400:	n = 2; break;
XX    case 4800:	n = 3; break;
XX    case 9600:	n = 4; break;
XX    default:	n = 2; p_baud = 2400;
XX    }
XXRSItem[n].Flags |= CHECKED;
XX
XX/* initialize text for specific menu items */
XXRSText[0].IText = (UBYTE *)"   300";
XXRSText[1].IText = (UBYTE *)"  1200";
XXRSText[2].IText = (UBYTE *)"  2400";
XXRSText[3].IText = (UBYTE *)"  4800";
XXRSText[4].IText = (UBYTE *)"  9600";
XX
XX/*****************************************************************/
XX/*    The following initializes the structure arrays		 */
XX/*   needed to provide the Parity   Submenu topic.               */
XX/*****************************************************************/
XX
XXfor( n=0; n