;:ts=8
;/**************************************************************
;**********
;*  a terminal program that has ascii and xmodem transfer capabi
;lity
;*
;*  use esc to abort xmodem transfer
;*
;*  written by Michael Mounier
;*
;*  Modification History -  ( these mods by Steve Allen)
;*   Feb 1986    - added Half-duplex and Echoplex
;*               - added timing to and fixed bugs in XMODEM rece
;ive
;*               - changed Ascii Send to Prompted Upload
;*               - added Command-Key sequences to menu
;*   March 86    - added function-keys
;*               - changed keyboard and screen io to console.dev
;ice,
;*                 which allows ansi standard vt-100 emulation
;***************************************************************
;*********/
;
;/*  compiler directives to fetch the necessary header files */
;
;#include <libraries/dos.h>
;#include <devices/serial.h>
;#include <fcntl.h>
;
;#include "con.h"         /* which will manage console i/o  */
	global	_readbuf,2
	global	_ConPort,4
	global	_ReadPort,4
	global	_WriteMsg,4
	global	_ReadMsg,4
	public	_InitConsole
_InitConsole:
	link	a5,#.2
	movem.l	.3,-(sp)
	clr.l	-(a7)
	pea	.1+0
	jsr	_CreatePort
	add.w	#8,a7
	move.l	d0,_ConPort
	tst.l	d0
	bne	.4
	move.l	#0,d0
.5
	movem.l	(sp)+,.3
	unlk	a5
	rts
.4
	clr.l	-(a7)
	pea	.1+10
	jsr	_CreatePort
	add.w	#8,a7
	move.l	d0,_ReadPort
	tst.l	d0
	beq	.6
	move.l	_ConPort,-(a7)
	jsr	_CreateStdIO
	add.w	#4,a7
	move.l	d0,_WriteMsg
	tst.l	d0
	beq	.7
	move.l	_ReadPort,-(a7)
	jsr	_CreateStdIO
	add.w	#4,a7
	move.l	d0,_ReadMsg
	tst.l	d0
	beq	.8
	move.l	_WriteMsg,a6
	move.l	8(a5),40(a6)
	move.l	_WriteMsg,a6
	move.l	#128,36(a6)
	clr.l	-(a7)
	move.l	_WriteMsg,-(a7)
	clr.l	-(a7)
	pea	.1+19
	jsr	_OpenDevice
	lea	16(a7),a7
	tst.l	d0
	bne	.9
	move.l	_WriteMsg,a6
	move.w	#3,28(a6)
	move.l	_ReadMsg,a6
	move.l	_WriteMsg,a1
	move.l	20(a1),20(a6)
	move.l	_ReadMsg,a6
	move.l	_WriteMsg,a1
	move.l	24(a1),24(a6)
	move.l	_ReadMsg,a6
	move.w	#2,28(a6)
	move.l	_ReadMsg,a6
	lea	_readbuf,a1
	move.l	a1,40(a6)
	move.l	_ReadMsg,a6
	move.l	#1,36(a6)
	move.l	_ReadMsg,-(a7)
	jsr	_SendIO
	add.w	#4,a7
	move.l	_ReadMsg,d0
	bra	.5
.10
	move.l	_WriteMsg,-(a7)
	jsr	_CloseDevice
	add.w	#4,a7
.9
	move.l	_ReadMsg,-(a7)
	jsr	_DeleteStdIO
	add.w	#4,a7
.8
	move.l	_WriteMsg,-(a7)
	jsr	_DeleteStdIO
	add.w	#4,a7
.7
	move.l	_ReadPort,-(a7)
	jsr	_RemPort
	add.w	#4,a7
.6
	move.l	_ConPort,-(a7)
	jsr	_RemPort
	add.w	#4,a7
	move.l	#0,d0
	bra	.5
.2	equ	0
.3	reg	
.1
	dc.b	119,114,105,116,101,112,111,114,116,0,114,101,97,100,112
	dc.b	111,114,116,0,99,111,110,115,111,108,101,46,100,101,118
	dc.b	105,99,101,0
	ds	0
	public	_CloseConsole
_CloseConsole:
	link	a5,#.12
	movem.l	.13,-(sp)
	move.l	_WriteMsg,-(a7)
	jsr	_CloseDevice
	add.w	#4,a7
	move.l	_ReadMsg,-(a7)
	jsr	_DeleteStdIO
	add.w	#4,a7
	move.l	_WriteMsg,-(a7)
	jsr	_DeleteStdIO
	add.w	#4,a7
	move.l	_ReadPort,-(a7)
	jsr	_RemPort
	add.w	#4,a7
	move.l	_ConPort,-(a7)
	jsr	_RemPort
	add.w	#4,a7
.14
	movem.l	(sp)+,.13
	unlk	a5
	rts
.12	equ	0
.13	reg	
	public	_PutChar
_PutChar:
	link	a5,#.15
	movem.l	.16,-(sp)
	move.l	_WriteMsg,a6
	lea	9(a5),a1
	move.l	a1,40(a6)
	move.l	_WriteMsg,a6
	move.l	#1,36(a6)
	move.l	_WriteMsg,-(a7)
	jsr	_DoIO
	add.w	#4,a7
.17
	movem.l	(sp)+,.16
	unlk	a5
	rts
.15	equ	0
.16	reg	
	public	_PutString
_PutString:
	link	a5,#.18
	movem.l	.19,-(sp)
	move.l	_WriteMsg,a6
	move.l	8(a5),40(a6)
	move.l	_WriteMsg,a6
	move.l	#-1,36(a6)
	move.l	_WriteMsg,-(a7)
	jsr	_DoIO
	add.w	#4,a7
.20
	movem.l	(sp)+,.19
	unlk	a5
	rts
.18	equ	0
.19	reg	
	public	_CursorXY
_CursorXY:
	link	a5,#.21
	movem.l	.22,-(sp)
	move.w	#155,-(a7)
	jsr	_PutChar
	add.w	#2,a7
	move.w	8(a5),-(a7)
	move.w	10(a5),-(a7)
	pea	.11+0
	pea	_PutChar
	jsr	_format
	lea	12(a7),a7
.23
	movem.l	(sp)+,.22
	unlk	a5
	rts
.21	equ	-24
.22	reg	
.11
	dc.b	37,100,59,37,100,72,0
	ds	0
	public	_PutSequence
_PutSequence:
	link	a5,#.25
	movem.l	.26,-(sp)
	move.w	#155,-(a7)
	jsr	_PutChar
	add.w	#2,a7
	move.l	8(a5),-(a7)
	jsr	_PutString
	add.w	#4,a7
.27
	movem.l	(sp)+,.26
	unlk	a5
	rts
.25	equ	0
.26	reg	
	public	_CheckKey
_CheckKey:
	link	a5,#.28
	movem.l	.29,-(sp)
	move.l	_ReadPort,-(a7)
	jsr	_GetMsg
	add.w	#4,a7
	tst.l	d0
	bne	.30
	move.l	#0,d0
.31
	movem.l	(sp)+,.29
	unlk	a5
	rts
.30
	move.b	_readbuf,-1(a5)
	move.l	_ReadMsg,-(a7)
	jsr	_SendIO
	add.w	#4,a7
	move.b	-1(a5),d0
	bra	.31
.28	equ	-2
.29	reg	
	public	_GetKey
_GetKey:
	link	a5,#.32
	movem.l	.33,-(sp)
.34
	move.l	_ReadPort,-(a7)
	jsr	_GetMsg
	add.w	#4,a7
	tst.l	d0
	bne	.35
	move.l	_ReadPort,-(a7)
	jsr	_WaitPort
	add.w	#4,a7
	bra	.34
.35
	move.b	_readbuf,-1(a5)
	move.l	_ReadMsg,-(a7)
	jsr	_SendIO
	add.w	#4,a7
	move.b	-1(a5),d0
.36
	movem.l	(sp)+,.33
	unlk	a5
	rts
.32	equ	-2
.33	reg	
	public	_GetLine
_GetLine:
	link	a5,#.37
	movem.l	.38,-(sp)
	clr.w	-4(a5)
	tst.l	8(a5)
	beq	.39
	move.l	8(a5),-(a7)
	jsr	_PutString
	add.w	#4,a7
.39
	move.w	-4(a5),d3
	move.l	12(a5),a6
	clr.b	(a6,d3.w)
.40
	jsr	_GetKey
	move.b	d0,-1(a5)
	move.l	#0,d3
	move.b	d0,d3
	cmp.w	#13,d3
	beq	.41
	move.l	#0,d0
	move.b	-1(a5),d0
	bra	.42
.44
.45
	move.l	#0,d0
.46
	movem.l	(sp)+,.38
	unlk	a5
	rts
.47
	cmp.w	#0,-4(a5)
	ble	.48
	sub.w	#1,-4(a5)
	move.w	-4(a5),d3
	move.l	12(a5),a6
	clr.b	(a6,d3.w)
	move.w	#8,-(a7)
	jsr	_PutChar
	add.w	#2,a7
	move.w	#32,-(a7)
	jsr	_PutChar
	add.w	#2,a7
	move.w	#8,-(a7)
	jsr	_PutChar
	add.w	#2,a7
.48
	bra	.43
.49
	move.l	#0,d3
	move.b	-1(a5),d3
	cmp.w	#32,d3
	bcs	.50
	move.l	#0,d3
	move.b	-1(a5),d3
	cmp.w	#127,d3
	bcc	.50
	move.w	-4(a5),d3
	add.w	#1,-4(a5)
	move.l	12(a5),a6
	move.b	-1(a5),(a6,d3.w)
	move.w	-4(a5),d3
	move.l	12(a5),a6
	clr.b	(a6,d3.w)
	move.l	#0,d3
	move.b	-1(a5),d3
	move.w	d3,-(a7)
	jsr	_PutChar
	add.w	#2,a7
.50
	bra	.43
.42
	sub.l	#3,d0
	beq	.44
	sub.l	#5,d0
	beq	.47
	sub.l	#16,d0
	beq	.45
	bra	.49
.43
	bra	.40
.41
	move.w	#10,-(a7)
	jsr	_PutChar
	add.w	#2,a7
	move.l	#1,d0
	bra	.46
.37	equ	-4
.38	reg	
;
;#define INTUITION_REV NULL
;#define GRAPHICS_REV NULL
;
;/* things for xmodem send and receive */
;#define SECSIZ   128             /* This many bytes in an xmode
;m block */
;#define BufSize  SECSIZ*2  /* We'll follow two blocks (for chop
;) */
;#define ERRORMAX 10        /* Max errors before abort */
;#define RETRYMAX 10       /* Maximum retrys before abort */
;#define SOH      1       /* Start of sector char */
;#define EOT      4      /* end of transmission char */
;#define ACK      6     /* acknowledge sector transmission */
;#define NAK      21   /* error in transmission detected */
;#define CAN      24
;#define CR       13
;#define BELL    'G'&0x1f
;#define CPM_EOF  26
;
;  /* things for function keys */
;#define NUMKEYS 10                  /* number of function keys 
;*/
;#define KEYSIZE 40                  /* maximum length of any on
;e string */
;#define BUFSIZE KEYSIZE * NUMKEYS   /* size of total buffer */
;
;#define HEADER 0xaa                 /* must be first byte of fi
;le */
;
;UBYTE
;    c,character,prompt,
	global	_c,1
	global	_character,1
	global	_prompt,1
;    bufr[BufSize], numstring[5],
	global	_bufr,256
	global	_numstring,5
;    *keybuf,*KeyOffset;
	global	_keybuf,4
	global	_KeyOffset,4
;static int
;    fd,
	bss	_fd,2
;    timeout = FALSE,
	dseg
	ds	0
_timeout:
	dc.w	0
	cseg
;    cancel,
	bss	_cancel,2
;    LOCAL, ECHO,
	bss	_LOCAL,2
	bss	_ECHO,2
;    waiting,
	bss	_waiting,2
;    OnKey=FALSE;
	dseg
	ds	0
_OnKey:
	dc.w	0
	cseg
;static long
;    bytes_xferred;
	bss	_bytes_xferred,4
;
;UBYTE ModemRead();  /* C demands this non-integer declaration *
;/
;                    /* 'cause ModemRead is used before it is de
;fined */
;
;struct IOStdReq *KeyPort;
	global	_KeyPort,4
;
;/*   Intuition always wants to see these declarations */
;struct IntuitionBase *IntuitionBase;
	global	_IntuitionBase,4
;struct GfxBase *GfxBase;
	global	_GfxBase,4
;
;
;
;/* my window structure */
;struct NewWindow NewWindow = {
	dseg
	ds	0
	public	_NewWindow
_NewWindow:
	ds.b	0
;   0,0,640,200, /* left, top, width, height */
	dc.w	0
	dc.w	0
	dc.w	640
	dc.w	200
;   0,1,         /* detail, block pens */
	dc.b	0
	dc.b	1
;   CLOSEWINDOW | MENUPICK,
	dc.l	$0300
;   WINDOWCLOSE | SMART_REFRESH | ACTIVATE | WINDOWDEPTH | BORDE
;RLESS,
	dc.l	$180c
;   NULL,       /* firstgadget */
	dc.l	$0000
;   NULL,       /* checkmark */
	dc.l	$0000
;   (UBYTE *)"Terminal", /* title */
	dc.l	.24+0
;   0,          /* screen */
	dc.l	$0000
;   NULL,       /* bitmap */
	dc.l	$0000
;   0,0,        /* min x,y */
	dc.w	0
	dc.w	0
;   640, 200,   /* max x,y */
	dc.w	640
	dc.w	200
;   WBENCHSCREEN  /* type */
;};
	dc.w	1
	cseg
.24
	dc.b	84,101,114,109,105,110,97,108,0
	ds	0
;
;struct Window *mywindow;             /* ptr to applications win
	global	_mywindow,4
;dow */
;struct IntuiMessage *NewMessage;    /* msg structure for GetMsg
	global	_NewMessage,4
;() */
;
;/*****************************************************
;*                     File Menu
;*****************************************************/
;
;/* define maximum number of menu items */
;#define FILEMAX 5
;
;/*   declare storage space for menu items and
; *   their associated IntuiText structures
; */
;struct MenuItem FileItem[FILEMAX];
	global	_FileItem,170
;struct IntuiText FileText[FILEMAX];
	global	_FileText,100
;
;/**************************************************************
;***/
;/*    The following function initializes the structure arrays  
;  */
;/*   needed to provide the File menu topic.                    
;  */
;/**************************************************************
;***/
;InitFileItems()
;{
	public	_InitFileItems
_InitFileItems:
	link	a5,#.52
	movem.l	.53,-(sp)
;short n;
;
;/* initialize each menu item and IntuiText with loop */
;for( n=0; n<FILEMAX; n++ )
	clr.w	-2(a5)
.56
;   {
;   FileItem[n].NextItem = &FileItem[n]+1;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FileItem,a6
	move.w	-2(a5),d2
	muls	#34,d2
	lea	_FileItem+34,a1
	add.l	a1,d2
	move.l	d2,(a6,d3.l)
;   FileItem[n].LeftEdge = 0;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FileItem+4,a6
	clr.w	(a6,d3.l)
;   FileItem[n].TopEdge = 11 * n;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FileItem+6,a6
	move.w	-2(a5),d2
	mulu	#11,d2
	move.w	d2,(a6,d3.l)
;   FileItem[n].Width = 135 + COMMWIDTH;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FileItem+8,a6
	move.w	#162,(a6,d3.l)
;   FileItem[n].Height = 11;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FileItem+10,a6
	move.w	#11,(a6,d3.l)
;   FileItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHBOX | COMMS
;EQ;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FileItem+12,a6
	move.w	#150,(a6,d3.l)
;   FileItem[n].MutualExclude = 0;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FileItem+14,a6
	clr.l	(a6,d3.l)
;   FileItem[n].ItemFill = (APTR)&FileText[n];
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FileItem+18,a6
	move.w	-2(a5),d2
	muls	#20,d2
	lea	_FileText,a1
	add.l	a1,d2
	move.l	d2,(a6,d3.l)
;   FileItem[n].SelectFill = NULL;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FileItem+22,a6
	clr.l	(a6,d3.l)
;   FileItem[n].Command = 0;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FileItem+26,a6
	clr.b	(a6,d3.l)
;   FileItem[n].SubItem = NULL;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FileItem+28,a6
	clr.l	(a6,d3.l)
;   FileItem[n].NextSelect = 0;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FileItem+32,a6
	clr.w	(a6,d3.l)
;
;   FileText[n].FrontPen = 0;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_FileText,a6
	clr.b	(a6,d3.l)
;   FileText[n].BackPen = 1;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_FileText+1,a6
	move.b	#1,(a6,d3.l)
;   FileText[n].DrawMode = JAM2;     /* render in fore and backg
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_FileText+2,a6
	move.b	#1,(a6,d3.l)
;round */
;   FileText[n].LeftEdge = 0;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_FileText+4,a6
	clr.w	(a6,d3.l)
;   FileText[n].TopEdge = 1;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_FileText+6,a6
	move.w	#1,(a6,d3.l)
;   FileText[n].ITextFont = NULL;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_FileText+8,a6
	clr.l	(a6,d3.l)
;   FileText[n].NextText = NULL;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_FileText+16,a6
	clr.l	(a6,d3.l)
;   }
.54
	add.w	#1,-2(a5)
	cmp.w	#5,-2(a5)
	blt	.56
.55
;FileItem[FILEMAX-1].NextItem = NULL;
	clr.l	_FileItem+136
;
;/* initialize text for specific menu items */
;FileText[0].IText = (UBYTE *)"Ascii Capture";
	lea	.51+0,a6
	move.l	a6,_FileText+12
;FileText[1].IText = (UBYTE *)"Ascii Transmit";
	lea	.51+14,a6
	move.l	a6,_FileText+32
;FileText[2].IText = (UBYTE *)"Xmodem Receive";
	lea	.51+29,a6
	move.l	a6,_FileText+52
;FileText[3].IText = (UBYTE *)"Xmodem Send";
	lea	.51+44,a6
	move.l	a6,_FileText+72
;FileText[4].IText = (UBYTE *)"Prompt";
	lea	.51+56,a6
	move.l	a6,_FileText+92
;
;FileItem[0].Command = 'c';
	move.b	#99,_FileItem+26
;FileItem[1].Command = 't';
	move.b	#116,_FileItem+60
;FileItem[2].Command = 'r';
	move.b	#114,_FileItem+94
;FileItem[3].Command = 's';
	move.b	#115,_FileItem+128
;FileItem[4].Command = 'p';
	move.b	#112,_FileItem+162
;
;return( 0 );
	move.l	#0,d0
.57
	movem.l	(sp)+,.53
	unlk	a5
	rts
;}
.52	equ	-2
.53	reg	
.51
	dc.b	65,115,99,105,105,32,67,97,112,116,117,114,101,0,65
	dc.b	115,99,105,105,32,84,114,97,110,115,109,105,116,0,88
	dc.b	109,111,100,101,109,32,82,101,99,101,105,118,101,0,88
	dc.b	109,111,100,101,109,32,83,101,110,100,0,80,114,111,109
	dc.b	112,116,0
	ds	0
;
;/*****************************************************/
;/*                BaudRate  Menu                     */
;/*****************************************************/
;
;/* define maximum number of menu items */
;#define RSMAX 5
;
;/*   declare storage space for menu items and
; *   their associated IntuiText structures
; */
;struct MenuItem RSItem[RSMAX];
	global	_RSItem,170
;struct IntuiText RSText[RSMAX];
	global	_RSText,100
;
;/**************************************************************
;***/
;/*    The following function initializes the structure arrays  
;  */
;/*   needed to provide the BaudRate menu topic.                
;  */
;/**************************************************************
;***/
;InitRSItems()
;{
	public	_InitRSItems
_InitRSItems:
	link	a5,#.59
	movem.l	.60,-(sp)
;short n;
;
;/* initialize each menu item and IntuiText with loop */
;for( n=0; n<RSMAX; n++ )
	clr.w	-2(a5)
.63
;   {
;   RSItem[n].NextItem = &RSItem[n]+1;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_RSItem,a6
	move.w	-2(a5),d2
	muls	#34,d2
	lea	_RSItem+34,a1
	add.l	a1,d2
	move.l	d2,(a6,d3.l)
;   RSItem[n].LeftEdge = 0;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_RSItem+4,a6
	clr.w	(a6,d3.l)
;   RSItem[n].TopEdge = 11 * n;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_RSItem+6,a6
	move.w	-2(a5),d2
	mulu	#11,d2
	move.w	d2,(a6,d3.l)
;   RSItem[n].Width = 85;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_RSItem+8,a6
	move.w	#85,(a6,d3.l)
;   RSItem[n].Height = 11;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_RSItem+10,a6
	move.w	#11,(a6,d3.l)
;   RSItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHBOX | CHECKIT
;;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_RSItem+12,a6
	move.w	#147,(a6,d3.l)
;   RSItem[n].MutualExclude = (~(1 << n));
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_RSItem+14,a6
	move.l	#1,d2
	move.w	-2(a5),d1
	asl.w	d1,d2
	not.w	d2
	ext.l	d2
	move.l	d2,(a6,d3.l)
;   RSItem[n].ItemFill = (APTR)&RSText[n];
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_RSItem+18,a6
	move.w	-2(a5),d2
	muls	#20,d2
	lea	_RSText,a1
	add.l	a1,d2
	move.l	d2,(a6,d3.l)
;   RSItem[n].SelectFill = NULL;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_RSItem+22,a6
	clr.l	(a6,d3.l)
;   RSItem[n].Command = 0;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_RSItem+26,a6
	clr.b	(a6,d3.l)
;   RSItem[n].SubItem = NULL;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_RSItem+28,a6
	clr.l	(a6,d3.l)
;   RSItem[n].NextSelect = 0;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_RSItem+32,a6
	clr.w	(a6,d3.l)
;
;   RSText[n].FrontPen = 0;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_RSText,a6
	clr.b	(a6,d3.l)
;   RSText[n].BackPen = 1;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_RSText+1,a6
	move.b	#1,(a6,d3.l)
;   RSText[n].DrawMode = JAM2;     /* render in fore and backgro
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_RSText+2,a6
	move.b	#1,(a6,d3.l)
;und */
;   RSText[n].LeftEdge = 0;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_RSText+4,a6
	clr.w	(a6,d3.l)
;   RSText[n].TopEdge = 1;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_RSText+6,a6
	move.w	#1,(a6,d3.l)
;   RSText[n].ITextFont = NULL;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_RSText+8,a6
	clr.l	(a6,d3.l)
;   RSText[n].NextText = NULL;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_RSText+16,a6
	clr.l	(a6,d3.l)
;   }
.61
	add.w	#1,-2(a5)
	cmp.w	#5,-2(a5)
	blt	.63
.62
;RSItem[RSMAX-1].NextItem = NULL;
	clr.l	_RSItem+136
;/* 300 baud item checked */
;RSItem[0].Flags = ITEMTEXT | ITEMENABLED | HIGHBOX | CHECKIT | 
;CHECKED;
	move.w	#403,_RSItem+12
;
;/* initialize text for specific menu items */
;RSText[0].IText = (UBYTE *)"   300";
	lea	.58+0,a6
	move.l	a6,_RSText+12
;RSText[1].IText = (UBYTE *)"   1200";
	lea	.58+7,a6
	move.l	a6,_RSText+32
;RSText[2].IText = (UBYTE *)"   2400";
	lea	.58+15,a6
	move.l	a6,_RSText+52
;RSText[3].IText = (UBYTE *)"   4800";
	lea	.58+23,a6
	move.l	a6,_RSText+72
;RSText[4].IText = (UBYTE *)"   9600";
	lea	.58+31,a6
	move.l	a6,_RSText+92
;
;return( 0 );
	move.l	#0,d0
.64
	movem.l	(sp)+,.60
	unlk	a5
	rts
;}
.59	equ	-2
.60	reg	
.58
	dc.b	32,32,32,51,48,48,0,32,32,32,49,50,48,48,0
	dc.b	32,32,32,50,52,48,48,0,32,32,32,52,56,48,48
	dc.b	0,32,32,32,57,54,48,48,0
	ds	0
;
;/***************************************************
;*                 Mode menu         (feb.86)
;****************************************************/
;struct MenuItem ModeItem[3];
	global	_ModeItem,102
;struct IntuiText Modetext[3];
	global	_Modetext,60
;
;initmode()
;{
	public	_initmode
_initmode:
	link	a5,#.66
	movem.l	.67,-(sp)
;short n;
;
;for ( n=0; n<3; n++)
	clr.w	-2(a5)
.70
;
;{
; ModeItem[n].NextItem = &ModeItem[n+1];
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_ModeItem,a6
	move.w	-2(a5),d2
	add.w	#1,d2
	muls	#34,d2
	lea	_ModeItem,a1
	add.l	a1,d2
	move.l	d2,(a6,d3.l)
; ModeItem[n].LeftEdge = 0;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_ModeItem+4,a6
	clr.w	(a6,d3.l)
; ModeItem[n].TopEdge = 11 * n;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_ModeItem+6,a6
	move.w	-2(a5),d2
	mulu	#11,d2
	move.w	d2,(a6,d3.l)
; ModeItem[n].Width = 85 + COMMWIDTH;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_ModeItem+8,a6
	move.w	#112,(a6,d3.l)
; ModeItem[n].Height = 11;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_ModeItem+10,a6
	move.w	#11,(a6,d3.l)
; ModeItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHBOX | CHECKIT
; | COMMSEQ;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_ModeItem+12,a6
	move.w	#151,(a6,d3.l)
; ModeItem[n].MutualExclude = (~(1 << n));
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_ModeItem+14,a6
	move.l	#1,d2
	move.w	-2(a5),d1
	asl.w	d1,d2
	not.w	d2
	ext.l	d2
	move.l	d2,(a6,d3.l)
; ModeItem[n].ItemFill = (APTR) &Modetext[n];
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_ModeItem+18,a6
	move.w	-2(a5),d2
	muls	#20,d2
	lea	_Modetext,a1
	add.l	a1,d2
	move.l	d2,(a6,d3.l)
; ModeItem[n].SelectFill = NULL;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_ModeItem+22,a6
	clr.l	(a6,d3.l)
; ModeItem[n].Command = 0;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_ModeItem+26,a6
	clr.b	(a6,d3.l)
; ModeItem[n].SubItem = NULL;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_ModeItem+28,a6
	clr.l	(a6,d3.l)
; ModeItem[n].NextSelect = 0;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_ModeItem+32,a6
	clr.w	(a6,d3.l)
;
; Modetext[n].FrontPen = 0;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_Modetext,a6
	clr.b	(a6,d3.l)
; Modetext[n].BackPen = 1;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_Modetext+1,a6
	move.b	#1,(a6,d3.l)
; Modetext[n].DrawMode = JAM2;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_Modetext+2,a6
	move.b	#1,(a6,d3.l)
; Modetext[n].LeftEdge = 0;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_Modetext+4,a6
	clr.w	(a6,d3.l)
; Modetext[n].TopEdge = 1;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_Modetext+6,a6
	move.w	#1,(a6,d3.l)
; Modetext[n].ITextFont = NULL;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_Modetext+8,a6
	clr.l	(a6,d3.l)
; Modetext[n].NextText = NULL;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_Modetext+16,a6
	clr.l	(a6,d3.l)
;}
.68
	add.w	#1,-2(a5)
	cmp.w	#3,-2(a5)
	blt	.70
.69
;
;ModeItem[2].NextItem = NULL;
	clr.l	_ModeItem+68
;
;/* default is Terminal mode  (full duplex)  */
;ModeItem[1].Flags |= CHECKED;
	or.w	#256,_ModeItem+46
;LOCAL = 0;
	clr.w	_LOCAL
;ECHO = 0;
	clr.w	_ECHO
;
;Modetext[0].IText = (UBYTE *)"    Half";
	lea	.65+0,a6
	move.l	a6,_Modetext+12
;Modetext[1].IText = (UBYTE *)"    Full";
	lea	.65+9,a6
	move.l	a6,_Modetext+32
;Modetext[2].IText = (UBYTE *)"    Echo";
	lea	.65+18,a6
	move.l	a6,_Modetext+52
;
;ModeItem[0].Command = 'h';
	move.b	#104,_ModeItem+26
;ModeItem[1].Command = 'f';
	move.b	#102,_ModeItem+60
;ModeItem[2].Command = 'e';
	move.b	#101,_ModeItem+94
;
;}     /* end initmode */
.71
	movem.l	(sp)+,.67
	unlk	a5
	rts
.66	equ	-2
.67	reg	
.65
	dc.b	32,32,32,32,72,97,108,102,0,32,32,32,32,70,117
	dc.b	108,108,0,32,32,32,32,69,99,104,111,0
	ds	0
;
;/******************** Initialize FKey Menu ********************
;**/
;#define FKMAX 1
;
;struct MenuItem FKitem[FKMAX];
	global	_FKitem,34
;struct IntuiText FKtext[FKMAX];
	global	_FKtext,20
;
;InitFKey()
;{
	public	_InitFKey
_InitFKey:
	link	a5,#.73
	movem.l	.74,-(sp)
;int x;
;for (x=0;x<FKMAX;x++)
	clr.w	-2(a5)
.77
;{
; FKitem[x].NextItem = NULL;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FKitem,a6
	clr.l	(a6,d3.l)
; FKitem[x].LeftEdge = 0;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FKitem+4,a6
	clr.w	(a6,d3.l)
; FKitem[x].TopEdge = 12 * x;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FKitem+6,a6
	move.w	-2(a5),d2
	mulu	#12,d2
	move.w	d2,(a6,d3.l)
; FKitem[x].Width = 100 + COMMWIDTH;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FKitem+8,a6
	move.w	#127,(a6,d3.l)
; FKitem[x].Height = 12;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FKitem+10,a6
	move.w	#12,(a6,d3.l)
; FKitem[x].Flags = ITEMENABLED | HIGHCOMP | ITEMTEXT | COMMSEQ;
;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FKitem+12,a6
	move.w	#86,(a6,d3.l)
; FKitem[x].MutualExclude = NULL;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FKitem+14,a6
	clr.l	(a6,d3.l)
; FKitem[x].ItemFill = (APTR) &FKtext[x];
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FKitem+18,a6
	move.w	-2(a5),d2
	muls	#20,d2
	lea	_FKtext,a1
	add.l	a1,d2
	move.l	d2,(a6,d3.l)
; FKitem[x].SelectFill = NULL;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FKitem+22,a6
	clr.l	(a6,d3.l)
; FKitem[x].Command = NULL;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FKitem+26,a6
	clr.b	(a6,d3.l)
; FKitem[x].SubItem = NULL;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FKitem+28,a6
	clr.l	(a6,d3.l)
; FKitem[x].NextSelect = NULL;
	move.w	-2(a5),d3
	muls	#34,d3
	lea	_FKitem+32,a6
	clr.w	(a6,d3.l)
;
; FKtext[x].FrontPen = 0;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_FKtext,a6
	clr.b	(a6,d3.l)
; FKtext[x].BackPen = 1;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_FKtext+1,a6
	move.b	#1,(a6,d3.l)
; FKtext[x].DrawMode = JAM2;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_FKtext+2,a6
	move.b	#1,(a6,d3.l)
; FKtext[x].LeftEdge = 0;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_FKtext+4,a6
	clr.w	(a6,d3.l)
; FKtext[x].TopEdge = 1;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_FKtext+6,a6
	move.w	#1,(a6,d3.l)
; FKtext[x].ITextFont = NULL;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_FKtext+8,a6
	clr.l	(a6,d3.l)
; FKtext[x].NextText = NULL;
	move.w	-2(a5),d3
	muls	#20,d3
	lea	_FKtext+16,a6
	clr.l	(a6,d3.l)
;}
.75
	add.w	#1,-2(a5)
	cmp.w	#1,-2(a5)
	blt	.77
.76
;FKtext[0].IText = (UBYTE *)"F-Key Load";
	lea	.72+0,a6
	move.l	a6,_FKtext+12
;FKitem[0].Command = 'k';
	move.b	#107,_FKitem+26
;}
.78
	movem.l	(sp)+,.74
	unlk	a5
	rts
.73	equ	-2
.74	reg	
.72
	dc.b	70,45,75,101,121,32,76,111,97,100,0
	ds	0
;
;/***************************************************/
;/*                Menu Definition                  */
;/*                                                 */
;/*      This section of code is where the simple   */
;/*   menu definition goes.                         */
;/***************************************************/
;
;/* current number of available menu topics */
;#define MAXMENU 4
;
;/*   declaration of menu structure array for
; *   number of current topics.  Intuition
; *   will use the address of this array to
; *   set and clear the menus associated with
; *   the window.
; */
;struct Menu menu[MAXMENU];
	global	_menu,120
;
;/**************************************************************
;********/
;/*   The following function initializes the Menu structure arra
;y with */
;/*  appropriate values for our simple menu strip.  Review the m
;anual  */
;/*  if you need to know what each value means.                 
;       */
;/**************************************************************
;********/
;InitMenu()
;{
	public	_InitMenu
_InitMenu:
	link	a5,#.80
	movem.l	.81,-(sp)
;menu[0].NextMenu = &menu[1];
	lea	_menu+30,a6
	move.l	a6,_menu
;menu[0].LeftEdge = 5;
	move.w	#5,_menu+4
;menu[0].TopEdge = 0;
	clr.w	_menu+6
;menu[0].Width = 50;
	move.w	#50,_menu+8
;menu[0].Height = 10;
	move.w	#10,_menu+10
;menu[0].Flags = MENUENABLED;
	move.w	#1,_menu+12
;menu[0].MenuName = "File";           /* text for menu-bar displ
	lea	.79+0,a6
	move.l	a6,_menu+14
;ay */
;menu[0].FirstItem = &FileItem[0];    /* pointer to first item i
	lea	_FileItem,a6
	move.l	a6,_menu+18
;n list */
;
;menu[1].NextMenu = &menu[2];
	lea	_menu+60,a6
	move.l	a6,_menu+30
;menu[1].LeftEdge = 65;
	move.w	#65,_menu+34
;menu[1].TopEdge = 0;
	clr.w	_menu+36
;menu[1].Width = 85;
	move.w	#85,_menu+38
;menu[1].Height = 10;
	move.w	#10,_menu+40
;menu[1].Flags = MENUENABLED;
	move.w	#1,_menu+42
;menu[1].MenuName = "BaudRate";        /* text for menu-bar disp
	lea	.79+5,a6
	move.l	a6,_menu+44
;lay */
;menu[1].FirstItem = &RSItem[0];    /* pointer to first item in 
	lea	_RSItem,a6
	move.l	a6,_menu+48
;list */
;
;menu[2].NextMenu = &menu[3];
	lea	_menu+90,a6
	move.l	a6,_menu+60
;menu[2].LeftEdge = 150;
	move.w	#150,_menu+64
;menu[2].TopEdge = 0;
	clr.w	_menu+66
;menu[2].Width = 60;
	move.w	#60,_menu+68
;menu[2].Height = 10;
	move.w	#10,_menu+70
;menu[2].Flags = MENUENABLED;
	move.w	#1,_menu+72
;menu[2].MenuName = "Mode";
	lea	.79+14,a6
	move.l	a6,_menu+74
;menu[2].FirstItem = &ModeItem[0];
	lea	_ModeItem,a6
	move.l	a6,_menu+78
;
;menu[3].NextMenu = NULL;
	clr.l	_menu+90
;menu[3].LeftEdge = 210;
	move.w	#210,_menu+94
;menu[3].TopEdge = 0;
	clr.w	_menu+96
;menu[3].Width = 50;
	move.w	#50,_menu+98
;menu[3].Height = 10;
	move.w	#10,_menu+100
;menu[3].Flags = MENUENABLED;
	move.w	#1,_menu+102
;menu[3].MenuName = "FKeys";
	lea	.79+19,a6
	move.l	a6,_menu+104
;menu[3].FirstItem = &FKitem[0];
	lea	_FKitem,a6
	move.l	a6,_menu+108
;}
.82
	movem.l	(sp)+,.81
	unlk	a5
	rts
.80	equ	0
.81	reg	
.79
	dc.b	70,105,108,101,0,66,97,117,100,82,97,116,101,0,77
	dc.b	111,100,101,0,70,75,101,121,115,0
	ds	0
;
;/* declarations for the serial stuff */
;struct IOExtSer *Read_Request;
	global	_Read_Request,4
;UBYTE rs_in[2];
	global	_rs_in,2
;struct IOExtSer *Write_Request;
	global	_Write_Request,4
;UBYTE rs_out[2];
	global	_rs_out,2
;
;/******************************************************/
;/*                   Main Program                     */
;/*                                                    */
;/*      This is the main body of the program.         */
;/******************************************************/
;
;main()
;{
	public	_main
_main:
	link	a5,#.84
	movem.l	.85,-(sp)
;ULONG class,waitmask;
;USHORT code,menunum,itemnum;
;int KeepGoing,capture,send;
;UBYTE c,name[32];
;FILE *tranr,*trans;
;
;IntuitionBase = OpenLibrary("intuition.library", INTUITION_REV)
;;
	clr.l	-(a7)
	pea	.83+0
	jsr	_OpenLibrary
	add.w	#8,a7
	move.l	d0,_IntuitionBase
;if( IntuitionBase == NULL )
;   {
	tst.l	_IntuitionBase
	bne	.86
;   puts("can't open intuition\n");
	pea	.83+18
	jsr	_puts
	add.w	#4,a7
;   exit(TRUE);
	pea	1
	jsr	_exit
	add.w	#4,a7
;   }
;
;GfxBase = OpenLibrary("graphics.library",GRAPHICS_REV);
.86
	clr.l	-(a7)
	pea	.83+40
	jsr	_OpenLibrary
	add.w	#8,a7
	move.l	d0,_GfxBase
;if( GfxBase == NULL )
;   {
	tst.l	_GfxBase
	bne	.87
;   puts("can't open graphics library\n");
	pea	.83+57
	jsr	_puts
	add.w	#4,a7
;   exit(TRUE);
	pea	1
	jsr	_exit
	add.w	#4,a7
;   }
;
;
;if(( mywindow = OpenWindow(&NewWindow) ) == NULL)
.87
;   {
	pea	_NewWindow
	jsr	_OpenWindow
	add.w	#4,a7
	move.l	d0,_mywindow
	tst.l	d0
	bne	.88
;   puts("can't open window\n");
	pea	.83+86
	jsr	_puts
	add.w	#4,a7
;   exit(TRUE);
	pea	1
	jsr	_exit
	add.w	#4,a7
;   }
;
;if(( KeyPort = InitConsole(mywindow) ) == FALSE)
.88
;   { puts("Can't open console\n");
	move.l	_mywindow,-(a7)
	jsr	_InitConsole
	add.w	#4,a7
	move.l	d0,_KeyPort
	tst.l	d0
	bne	.89
	pea	.83+105
	jsr	_puts
	add.w	#4,a7
;     goto q7;
	bra	.90
;    }
;
;Read_Request = (struct IOExtSer *)AllocMem((long)sizeof(*Read_R
.89
;equest),
;  (long)MEMF_PUBLIC|MEMF_CLEAR);
	pea	65537
	pea	82
	jsr	_AllocMem
	add.w	#8,a7
	move.l	d0,_Read_Request
;if (Read_Request == NULL) goto q6;
	tst.l	_Read_Request
	beq	.91
;
;Read_Request->io_SerFlags = SERF_SHARED;
	move.l	_Read_Request,a6
	move.b	#32,79(a6)
;Read_Request->io_CtlChar = 0x11130501;
	move.l	_Read_Request,a6
	move.l	#286459137,48(a6)
;Read_Request->IOSer.io_Message.mn_ReplyPort = CreatePort("Read_
;RS",NULL);
	move.l	_Read_Request,a6
	move.l	a6,-(sp)
	clr.l	-(a7)
	pea	.83+125
	jsr	_CreatePort
	add.w	#8,a7
	move.l	(sp)+,a6
	move.l	d0,14(a6)
;if(OpenDevice(SERIALNAME,NULL,Read_Request,NULL))
;   {
	clr.l	-(a7)
	move.l	_Read_Request,-(a7)
	clr.l	-(a7)
	pea	.83+133
	jsr	_OpenDevice
	lea	16(a7),a7
	tst.l	d0
	beq	.92
;   puts("Can't open Read device\n");
	pea	.83+147
	jsr	_puts
	add.w	#4,a7
;   goto q4;
	bra	.93
;   }
;
;Read_Request->io_Baud = 300;
.92
	move.l	_Read_Request,a6
	move.l	#300,60(a6)
;Read_Request->io_ReadLen = 8;
	move.l	_Read_Request,a6
	move.b	#8,76(a6)
;Read_Request->io_WriteLen = 8;
	move.l	_Read_Request,a6
	move.b	#8,77(a6)
;Read_Request->IOSer.io_Command = SDCMD_SETPARAMS;
	move.l	_Read_Request,a6
	move.w	#11,28(a6)
;DoIO(Read_Request);
	move.l	_Read_Request,-(a7)
	jsr	_DoIO
	add.w	#4,a7
;Read_Request->IOSer.io_Command = CMD_READ;
	move.l	_Read_Request,a6
	move.w	#2,28(a6)
;Read_Request->IOSer.io_Length = 1;
	move.l	_Read_Request,a6
	move.l	#1,36(a6)
;Read_Request->IOSer.io_Data = &rs_in[0];
	move.l	_Read_Request,a6
	lea	_rs_in,a1
	move.l	a1,40(a6)
;
;
;Write_Request = (struct IOExtSer *)AllocMem((long)sizeof(*Write
;_Request),
;  (long)MEMF_PUBLIC|MEMF_CLEAR);
	pea	65537
	pea	82
	jsr	_AllocMem
	add.w	#8,a7
	move.l	d0,_Write_Request
;if (Write_Request == NULL) goto q3;
	tst.l	_Write_Request
	beq	.94
;
;Write_Request->io_SerFlags = SERF_SHARED | SERF_XDISABLED;
	move.l	_Write_Request,a6
	move.b	#160,79(a6)
;Write_Request->io_CtlChar = 0x11130501;
	move.l	_Write_Request,a6
	move.l	#286459137,48(a6)
;Write_Request->IOSer.io_Message.mn_ReplyPort = CreatePort("Writ
;e_RS",NULL);
	move.l	_Write_Request,a6
	move.l	a6,-(sp)
	clr.l	-(a7)
	pea	.83+171
	jsr	_CreatePort
	add.w	#8,a7
	move.l	(sp)+,a6
	move.l	d0,14(a6)
;if(OpenDevice(SERIALNAME,NULL,Write_Request,NULL))
;   {
	clr.l	-(a7)
	move.l	_Write_Request,-(a7)
	clr.l	-(a7)
	pea	.83+180
	jsr	_OpenDevice
	lea	16(a7),a7
	tst.l	d0
	beq	.95
;   puts("Can't open Write device\n");
	pea	.83+194
	jsr	_puts
	add.w	#4,a7
;   goto q1;
	bra	.96
;   }
;Write_Request->io_Baud = 300;
.95
	move.l	_Write_Request,a6
	move.l	#300,60(a6)
;Write_Request->io_ReadLen = 8;
	move.l	_Write_Request,a6
	move.b	#8,76(a6)
;Write_Request->io_WriteLen = 8;
	move.l	_Write_Request,a6
	move.b	#8,77(a6)
;Write_Request->IOSer.io_Command = SDCMD_SETPARAMS;
	move.l	_Write_Request,a6
	move.w	#11,28(a6)
;DoIO(Write_Request);
	move.l	_Write_Request,-(a7)
	jsr	_DoIO
	add.w	#4,a7
;
;Write_Request->IOSer.io_Command = CMD_WRITE;
	move.l	_Write_Request,a6
	move.w	#3,28(a6)
;Write_Request->IOSer.io_Length = 1;
	move.l	_Write_Request,a6
	move.l	#1,36(a6)
;Write_Request->IOSer.io_Data =  &rs_out[0];
	move.l	_Write_Request,a6
	lea	_rs_out,a1
	move.l	a1,40(a6)
;
;if (( keybuf= AllocMem((long)BUFSIZE,
;     (long)MEMF_PUBLIC | MEMF_CLEAR))== NULL)
; { puts("Can't get memory for function keys\n");
	pea	65537
	pea	400
	jsr	_AllocMem
	add.w	#8,a7
	move.l	d0,_keybuf
	tst.l	d0
	bne	.97
	pea	.83+219
	jsr	_puts
	add.w	#4,a7
;   CloseDevice(Write_Request);
	move.l	_Write_Request,-(a7)
	jsr	_CloseDevice
	add.w	#4,a7
;q1:   DeletePort(Write_Request->IOSer.io_Message.mn_ReplyPort);
.96
;
	move.l	_Write_Request,a6
	move.l	14(a6),-(a7)
	jsr	_DeletePort
	add.w	#4,a7
;q2:   FreeMem(Write_Request,(long)sizeof(*Write_Request));
.98
	pea	82
	move.l	_Write_Request,-(a7)
	jsr	_FreeMem
	add.w	#8,a7
;q3:   CloseDevice(Read_Request);
.94
	move.l	_Read_Request,-(a7)
	jsr	_CloseDevice
	add.w	#4,a7
;q4:   DeletePort(Read_Request->IOSer.io_Message.mn_ReplyPort);
.93
	move.l	_Read_Request,a6
	move.l	14(a6),-(a7)
	jsr	_DeletePort
	add.w	#4,a7
;
;q5:   FreeMem(Read_Request,(long)sizeof(*Read_Request));
.99
	pea	82
	move.l	_Read_Request,-(a7)
	jsr	_FreeMem
	add.w	#8,a7
;q6:   CloseConsole();
.91
	jsr	_CloseConsole
;q7:   CloseWindow( mywindow );
.90
	move.l	_mywindow,-(a7)
	jsr	_CloseWindow
	add.w	#4,a7
;      CloseLibrary(GfxBase);
	move.l	_GfxBase,-(a7)
	jsr	_CloseLibrary
	add.w	#4,a7
;      CloseLibrary(IntuitionBase);
	move.l	_IntuitionBase,-(a7)
	jsr	_CloseLibrary
	add.w	#4,a7
;   exit(TRUE);
	pea	1
	jsr	_exit
	add.w	#4,a7
;  }
;
;
;InitFileItems();
.97
	jsr	_InitFileItems
;InitRSItems();
	jsr	_InitRSItems
;initmode();
	jsr	_initmode
;InitMenu();
	jsr	_InitMenu
;InitFKey();
	jsr	_InitFKey
;SetMenuStrip(mywindow,&menu[0]);
	pea	_menu
	move.l	_mywindow,-(a7)
	jsr	_SetMenuStrip
	add.w	#8,a7
;
;capture=FALSE;
	clr.w	-18(a5)
;waiting=send=FALSE;
	clr.w	-20(a5)
	clr.w	_waiting
;prompt = 0;
	clr.b	_prompt
;
;BeginIO(Read_Request);
	move.l	_Read_Request,-(a7)
	jsr	_BeginIO
	add.w	#4,a7
;
;PutChar(12);
	move.w	#12,-(a7)
	jsr	_PutChar
	add.w	#2,a7
;
; waitmask = (1L << Read_Request->IOSer.io_Message.mn_ReplyPort-
;>mp_SigBit)
; | ( 1L << mywindow->UserPort->mp_SigBit)
; | (1L << KeyPort->io_Message.mn_ReplyPort->mp_SigBit);
	move.l	_Read_Request,a6
	move.l	14(a6),a1
	move.l	#0,d3
	move.b	15(a1),d3
	move.l	#1,d2
	asl.l	d3,d2
	move.l	_mywindow,a6
	move.l	86(a6),a1
	move.l	#0,d3
	move.b	15(a1),d3
	move.l	#1,d1
	asl.l	d3,d1
	or.l	d1,d2
	move.l	_KeyPort,a6
	move.l	14(a6),a1
	move.l	#0,d3
	move.b	15(a1),d3
	move.l	#1,d1
	asl.l	d3,d1
	or.l	d1,d2
	move.l	d2,-8(a5)
;
;if (LoadKeys("init.key"))           /* did the default f-keys l
;oad? */
;PutString("Function Keys Loaded...\n");
	pea	.83+255
	jsr	_LoadKeys
	add.w	#4,a7
	tst.w	d0
	beq	.100
	pea	.83+264
	jsr	_PutString
	add.w	#4,a7
;
;KeepGoing = TRUE;
.100
	move.w	#1,-16(a5)
;while( KeepGoing )
.101
	tst.w	-16(a5)
	beq	.102
;     {
;
;     if ((send | OnKey) == 0)
;     Wait(waitmask);
	move.w	-20(a5),d3
	or.w	_OnKey,d3
	tst.w	d3
	bne	.103
	move.l	-8(a5),-(a7)
	jsr	_Wait
	add.w	#4,a7
;
;     if (send)
.103
;       {
	tst.w	-20(a5)
	beq	.104
;
;         if (waiting == FALSE)
;          {  int c;
	move.w	_waiting,d3
	ext.l	d3
	tst.l	d3
	bne	.105
;             if ((c=getc(trans)) != EOF)
;              { if (c == '\n')
	move.l	-62(a5),-(a7)
	jsr	_getc
	add.w	#4,a7
	move.w	d0,-64(a5)
	cmp.w	#-1,d0
	beq	.106
;                 { sendchar(CR);  /* switch in carriage return 
	cmp.w	#10,-64(a5)
	bne	.107
	move.w	#13,-(a7)
	jsr	_sendchar
	add.w	#2,a7
; */
;                   if (prompt) waiting=TRUE;
	tst.b	_prompt
	beq	.108
	move.w	#1,_waiting
;                  }
.108
;                else sendchar(c);
	bra	.109
.107
	move.w	-64(a5),-(a7)
	jsr	_sendchar
	add.w	#2,a7
.109
;               }
;            else
	bra	.110
.106
;              {
;                fclose(trans);
	move.l	-62(a5),-(a7)
	jsr	_fclose
	add.w	#4,a7
;                PutString("\nFile Sent\n");
	pea	.83+289
	jsr	_PutString
	add.w	#4,a7
;                send=waiting=FALSE;
	clr.w	_waiting
	clr.w	-20(a5)
;               }
.110
;           }     /* end (if not waiting) */
;         }       /* end (if send) */
.105
;
;     if (OnKey)  /* if doing function-key  (Mar.86) */
.104
;       {
	tst.w	_OnKey
	beq	.111
;    if ((c=*KeyOffset++)== 0) /* then end of this F-key string 
;*/
;             OnKey=FALSE;
	move.l	_KeyOffset,a6
	add.l	#1,_KeyOffset
	move.b	(a6),-21(a5)
	move.l	#0,d3
	move.b	-21(a5),d3
	tst.w	d3
	bne	.112
	clr.w	_OnKey
;         else sendchar(c);
	bra	.113
.112
	move.l	#0,d3
	move.b	-21(a5),d3
	move.w	d3,-(a7)
	jsr	_sendchar
	add.w	#2,a7
.113
;        }
;
;
;   while (c=CheckKey())
.111
.114
	jsr	_CheckKey
	move.b	d0,-21(a5)
	tst.b	d0
	beq	.115
;   {                      /*  User has touched the keyboard */
;
;     if (c == CSI)
;      { character = GetKey();
	move.l	#0,d3
	move.b	-21(a5),d3
	cmp.w	#155,d3
	bne	.116
	jsr	_GetKey
	move.b	d0,_character
;        while ((c=GetKey()) != '~')
.117
	jsr	_GetKey
	move.b	d0,-21(a5)
	move.l	#0,d3
	move.b	d0,d3
	cmp.w	#126,d3
	beq	.118
;              ;
	bra	.117
.118
;
;        if (character == '?')
;         {
	move.l	#0,d3
	move.b	_character,d3
	cmp.w	#63,d3
	bne	.119
;           PutString("AMIGA Term ATERM6\n\n");
	pea	.83+301
	jsr	_PutString
	add.w	#4,a7
;
;           PutString("\nPrompt character is ");
	pea	.83+321
	jsr	_PutString
	add.w	#4,a7
;           if (prompt == 0) PutChar('0');
	move.l	#0,d3
	move.b	_prompt,d3
	tst.w	d3
	bne	.120
	move.w	#48,-(a7)
	jsr	_PutChar
	add.w	#2,a7
;            else keychar(prompt);
	bra	.121
.120
	move.l	#0,d3
	move.b	_prompt,d3
	move.w	d3,-(a7)
	jsr	_keychar
	add.w	#2,a7
.121
;           PutString("\n\n");
	pea	.83+343
	jsr	_PutString
	add.w	#4,a7
;           DoContents();              /* display function keys 
	jsr	_DoContents
;*/
;          }
;         else if ((character >= 0x30) && (character < 0x3a))
	bra	.122
.119
;          { KeyOffset = keybuf+(KEYSIZE*(character-'0'));
	move.l	#0,d3
	move.b	_character,d3
	cmp.w	#48,d3
	bcs	.123
	move.l	#0,d3
	move.b	_character,d3
	cmp.w	#58,d3
	bcc	.123
	move.l	#0,d3
	move.b	_character,d3
	sub.w	#48,d3
	mulu	#40,d3
	move.l	#0,d2
	move.w	d3,d2
	add.l	_keybuf,d2
	move.l	d2,_KeyOffset
;            OnKey = TRUE;
	move.w	#1,_OnKey
;           }
;        }    /* end if CSI */
.123
.122
;      else
	bra	.124
.116
;       {
;         rs_out[0] = c;
	move.b	-21(a5),_rs_out
;         DoIO(Write_Request);
	move.l	_Write_Request,-(a7)
	jsr	_DoIO
	add.w	#4,a7
;         if (LOCAL) PutChar(c=='\r'?'\n':c);
	tst.w	_LOCAL
	beq	.125
	move.l	#0,d3
	move.b	-21(a5),d3
	cmp.w	#13,d3
	bne	.126
	move.l	#10,d3
	bra	.127
.126
	move.l	#0,d3
	move.b	-21(a5),d3
.127
	move.w	d3,-(a7)
	jsr	_PutChar
	add.w	#2,a7
;        }
.125
.124
;    }      /* end while CheckKey() */
	bra	.114
.115
;
;     if(CheckIO(Read_Request))
;       {
	move.l	_Read_Request,-(a7)
	jsr	_CheckIO
	add.w	#4,a7
	tst.l	d0
	beq	.128
;        WaitIO(Read_Request);
	move.l	_Read_Request,-(a7)
	jsr	_WaitIO
	add.w	#4,a7
;        c=rs_in[0] & 0x7f;
	move.l	#0,d3
	move.b	_rs_in,d3
	and.w	#127,d3
	move.b	d3,-21(a5)
;        BeginIO(Read_Request);
	move.l	_Read_Request,-(a7)
	jsr	_BeginIO
	add.w	#4,a7
;        if (c!='\n')             /* don't print LF */
;        PutChar(c=='\r'?'\n':c); /* convert CR into CR/LF */
	move.l	#0,d3
	move.b	-21(a5),d3
	cmp.w	#10,d3
	beq	.129
	move.l	#0,d3
	move.b	-21(a5),d3
	cmp.w	#13,d3
	bne	.130
	move.l	#10,d3
	bra	.131
.130
	move.l	#0,d3
	move.b	-21(a5),d3
.131
	move.w	d3,-(a7)
	jsr	_PutChar
	add.w	#2,a7
;        if (ECHO)
.129
;         {
	tst.w	_ECHO
	beq	.132
;          rs_out[0] = c;       /* must do this way: sendchar() 
	move.b	-21(a5),_rs_out
;also */
;          DoIO(Write_Request); /* PutChar()s if LOCAL, and call
	move.l	_Write_Request,-(a7)
	jsr	_DoIO
	add.w	#4,a7
;ing sendchar() */
;          }                    /* would do a double-PutChar() i
;n EchoPlex */
;
;        if (waiting) if (c==prompt) waiting = FALSE;
.132
	tst.w	_waiting
	beq	.133
	move.l	#0,d3
	move.b	-21(a5),d3
	move.l	#0,d2
	move.b	_prompt,d2
	cmp.w	d2,d3
	bne	.134
	clr.w	_waiting
;        if (capture)
.134
.133
;            if (c > 31 && c < 127 || c == '\n') /* assumes CR/L
	tst.w	-18(a5)
	beq	.135
;F sequence */
;                                   /* trash them mangy ctl char
;s */
;                putc(c , tranr);
	move.l	#0,d3
	move.b	-21(a5),d3
	cmp.w	#31,d3
	bls	.138
	move.l	#0,d3
	move.b	-21(a5),d3
	cmp.w	#127,d3
	bcs	.137
.138
	move.l	#0,d3
	move.b	-21(a5),d3
	cmp.w	#10,d3
	bne	.136
.137
	move.l	-58(a5),-(a7)
	move.l	#0,d3
	move.b	-21(a5),d3
	move.w	d3,-(a7)
	jsr	_putc
	add.w	#6,a7
;        }
.136
.135
;
;     while( NewMessage=(struct IntuiMessage *)GetMsg(mywindow->
.128
.139
;UserPort) )
	move.l	_mywindow,a6
	move.l	86(a6),-(a7)
	jsr	_GetMsg
	add.w	#4,a7
	move.l	d0,_NewMessage
	tst.l	d0
	beq	.140
;          {
;          class = NewMessage->Class;
	move.l	_NewMessage,a6
	move.l	20(a6),-4(a5)
;          code = NewMessage->Code;
	move.l	_NewMessage,a6
	move.w	24(a6),-10(a5)
;          ReplyMsg( NewMessage );
	move.l	_NewMessage,-(a7)
	jsr	_ReplyMsg
	add.w	#4,a7
;          switch( class )
	move.l	-4(a5),d0
	bra	.141
;                {
;                case CLOSEWINDOW:
.143
;                   /*   User is ready to quit, so indicate
;                   *   that execution should terminate
;                   *   with next iteration of the loop.
;                   */
;                   KeepGoing = FALSE;
	clr.w	-16(a5)
;                break;
	bra	.142
;
;                case NEWSIZE:
.144
;                   PutChar(12);
	move.w	#12,-(a7)
	jsr	_PutChar
	add.w	#2,a7
;                break;
	bra	.142
;
;                case MENUPICK:
.145
;                   if ( code != MENUNULL )
;                       {
	move.l	#0,d3
	move.w	-10(a5),d3
	cmp.l	#65535,d3
	beq	.146
;                       menunum = MENUNUM( code );
	move.l	#0,d3
	move.w	-10(a5),d3
	and.l	#31,d3
	move.w	d3,-12(a5)
;                       itemnum = ITEMNUM( code );
	move.l	#0,d3
	move.w	-10(a5),d3
	asr.l	#5,d3
	and.l	#63,d3
	move.w	d3,-14(a5)
;                       switch( menunum )
	move.l	#0,d0
	move.w	-12(a5),d0
	bra	.147
;                             {
;                             case 0:
.149
;                                switch( itemnum )
	move.l	#0,d0
	move.w	-14(a5),d0
	bra	.150
;                                      {
;                                      case 0:
.152
;                                         if (capture)
;                                          {
	tst.w	-18(a5)
	beq	.153
;                                             capture=FALSE;
	clr.w	-18(a5)
;                                             fclose(tranr);
	move.l	-58(a5),-(a7)
	jsr	_fclose
	add.w	#4,a7
;                                             PutString("\nEnd F
;ile Capture\n");
	pea	.83+346
	jsr	_PutString
	add.w	#4,a7
;                                            }
;                                         else
	bra	.154
.153
;                                           {
;                                             if (GetLine("\nAsc
;ii Capture: ",name))
;                                              {
	pea	-53(a5)
	pea	.83+365
	jsr	_GetLine
	add.w	#8,a7
	tst.w	d0
	beq	.155
;                                                if ((tranr=fope
;n(name,"w")) == 0)
;                                                    {
	pea	.83+382
	pea	-53(a5)
	jsr	_fopen
	add.w	#8,a7
	move.l	d0,-58(a5)
	tst.l	d0
	bne	.156
;                                                      capture=F
;ALSE;
	clr.w	-18(a5)
;                                                      PutString
;("\nError Opening File\n");
	pea	.83+384
	jsr	_PutString
	add.w	#4,a7
;                                                      break;
	bra	.151
;                                                     }
;                                                 capture=TRUE;
.156
	move.w	#1,-18(a5)
;
;                                                }
;                                              else PutString("\
	bra	.157
.155
;nAborted\n");
	pea	.83+405
	jsr	_PutString
	add.w	#4,a7
.157
;                                             }
.154
;                                      break;
	bra	.151
;                                      case 1:
.158
;                                         if (send)
;                                             {
	tst.w	-20(a5)
	beq	.159
;                                             send=waiting=FALSE
;;
	clr.w	_waiting
	clr.w	-20(a5)
;                                             fclose(trans);
	move.l	-62(a5),-(a7)
	jsr	_fclose
	add.w	#4,a7
;                                             PutString("\nFile 
;Send Cancelled\n");
	pea	.83+415
	jsr	_PutString
	add.w	#4,a7
;                                             }
;                                         else
	bra	.160
.159
;                                           if (GetLine("\nAscii
; Send: ",name))
;                                              {
	pea	-53(a5)
	pea	.83+437
	jsr	_GetLine
	add.w	#8,a7
	tst.w	d0
	beq	.161
;                                                if ((trans=fope
;n(name,"r")) == 0)
;                                                 { send=FALSE;
	pea	.83+451
	pea	-53(a5)
	jsr	_fopen
	add.w	#8,a7
	move.l	d0,-62(a5)
	tst.l	d0
	bne	.162
	clr.w	-20(a5)
;
;                                                   PutString("\
;nError Opening File\n");
	pea	.83+453
	jsr	_PutString
	add.w	#4,a7
;                                                   break;
	bra	.151
;                                                  }
;                                                send=TRUE;
.162
	move.w	#1,-20(a5)
;                                                waiting=FALSE;
	clr.w	_waiting
;
;                                               }
;                                            else PutString("\nA
	bra	.163
.161
;borted\n");
	pea	.83+474
	jsr	_PutString
	add.w	#4,a7
.163
.160
;                                      break;
	bra	.151
;                                      case 2:
.164
;                                         if (GetLine("\nXmodem 
;Receive:",name))
;                                          {
	pea	-53(a5)
	pea	.83+484
	jsr	_GetLine
	add.w	#8,a7
	tst.w	d0
	beq	.165
;
;                                         /* disable ^Q/^S trapp
;ing */
;                                            AbortIO(Read_Reques
;t);
	move.l	_Read_Request,-(a7)
	jsr	_AbortIO
	add.w	#4,a7
;                                            Read_Request->io_Se
;rFlags |= SERF_XDISABLED;
	move.l	_Read_Request,a6
	or.b	#128,79(a6)
;                                            Read_Request->IOSer
;.io_Command = SDCMD_SETPARAMS;
	move.l	_Read_Request,a6
	move.w	#11,28(a6)
;                                            DoIO(Read_Request);
;
	move.l	_Read_Request,-(a7)
	jsr	_DoIO
	add.w	#4,a7
;                                            Read_Request->IOSer
;.io_Command = CMD_READ;
	move.l	_Read_Request,a6
	move.w	#2,28(a6)
;                                            BeginIO(Read_Reques
;t);
	move.l	_Read_Request,-(a7)
	jsr	_BeginIO
	add.w	#4,a7
;
;                                           XMODEM_Read_File(nam
;e);
	pea	-53(a5)
	jsr	_XMODEM_Read_File
	add.w	#4,a7
;
;                                         /* Re-enable ^Q/^S tra
;pping */
;                                            AbortIO(Read_Reques
;t);
	move.l	_Read_Request,-(a7)
	jsr	_AbortIO
	add.w	#4,a7
;                                            Read_Request->io_Se
;rFlags &=(~SERF_XDISABLED);
	move.l	_Read_Request,a6
	and.b	#127,79(a6)
;                                            Read_Request->IOSer
;.io_Command = SDCMD_SETPARAMS;
	move.l	_Read_Request,a6
	move.w	#11,28(a6)
;                                            DoIO(Read_Request);
;
	move.l	_Read_Request,-(a7)
	jsr	_DoIO
	add.w	#4,a7
;                                            Read_Request->IOSer
;.io_Command = CMD_READ;
	move.l	_Read_Request,a6
	move.w	#2,28(a6)
;                                            BeginIO(Read_Reques
;t);
	move.l	_Read_Request,-(a7)
	jsr	_BeginIO
	add.w	#4,a7
;                                           DisplayBeep(NULL);
	clr.l	-(a7)
	jsr	_DisplayBeep
	add.w	#4,a7
;                                            } else PutString("\
	bra	.166
.165
;nAborted\n");
	pea	.83+501
	jsr	_PutString
	add.w	#4,a7
.166
;                                      break;
	bra	.151
;                                      case 3:
.167
;                                       if (GetLine("\nXmodem Se
;nd: ",name))
;                                        { if (XMODEM_Send_File(
	pea	-53(a5)
	pea	.83+511
	jsr	_GetLine
	add.w	#8,a7
	tst.w	d0
	beq	.168
;name))
;                                             {
	pea	-53(a5)
	jsr	_XMODEM_Send_File
	add.w	#4,a7
	tst.w	d0
	beq	.169
;                                             PutString("\nSent 
;File\n");
	pea	.83+526
	jsr	_PutString
	add.w	#4,a7
;                                             DisplayBeep(NULL);
;
	clr.l	-(a7)
	jsr	_DisplayBeep
	add.w	#4,a7
;                                             }
;                                           else
	bra	.170
.169
;                                             {
;                                             close(fd);
	move.w	_fd,-(a7)
	jsr	_close
	add.w	#2,a7
;                                             PutString("\nXmode
;m Send Failed\n");
	pea	.83+538
	jsr	_PutString
	add.w	#4,a7
;                                             DisplayBeep(NULL);
;
	clr.l	-(a7)
	jsr	_DisplayBeep
	add.w	#4,a7
;                                             }
.170
;                                         }
;                                       else PutString("\nAborte
	bra	.171
.168
;d\n");
	pea	.83+559
	jsr	_PutString
	add.w	#4,a7
.171
;                                      break;
	bra	.151
;                                      case 4:      /* new promp
.172
;t */
;                                         PutString("New Prompt 
;Character: ");
	pea	.83+569
	jsr	_PutString
	add.w	#4,a7
;                                         if ((c = GetKey()) == 
;'0')
;                                          prompt = 0;
	jsr	_GetKey
	move.b	d0,-21(a5)
	move.l	#0,d3
	move.b	d0,d3
	cmp.w	#48,d3
	bne	.173
	clr.b	_prompt
;                                          else prompt = c;
	bra	.174
.173
	move.b	-21(a5),_prompt
.174
;                                         keychar(c);
	move.l	#0,d3
	move.b	-21(a5),d3
	move.w	d3,-(a7)
	jsr	_keychar
	add.w	#2,a7
;                                         PutChar('\n');
	move.w	#10,-(a7)
	jsr	_PutChar
	add.w	#2,a7
;                                       break;
	bra	.151
;                                      }
.175
	dc.w	.152-.176-2
	dc.w	.158-.176-2
	dc.w	.164-.176-2
	dc.w	.167-.176-2
	dc.w	.172-.176-2
.150
	cmp.l	#5,d0
	bcc	.151
	asl.l	#1,d0
	move.w	.175(pc,d0.w),d0
.176
	jmp	(pc,d0.w)
.151
;                             break;
	bra	.148
;
;                             case 1:
.177
;                                AbortIO(Read_Request);
	move.l	_Read_Request,-(a7)
	jsr	_AbortIO
	add.w	#4,a7
;                                switch( itemnum )
	move.l	#0,d0
	move.w	-14(a5),d0
	bra	.178
;                                      {
;                                      case 0:
.180
;                                         Read_Request->io_Baud 
;= 300;
	move.l	_Read_Request,a6
	move.l	#300,60(a6)
;                                      break;
	bra	.179
;                                      case 1:
.181
;                                         Read_Request->io_Baud 
;= 1200;
	move.l	_Read_Request,a6
	move.l	#1200,60(a6)
;                                      break;
	bra	.179
;                                      case 2:
.182
;                                         Read_Request->io_Baud 
;= 2400;
	move.l	_Read_Request,a6
	move.l	#2400,60(a6)
;                                      break;
	bra	.179
;                                      case 3:
.183
;                                         Read_Request->io_Baud 
;= 4800;
	move.l	_Read_Request,a6
	move.l	#4800,60(a6)
;                                      break;
	bra	.179
;                                      case 4:
.184
;                                         Read_Request->io_Baud 
;= 9600;
	move.l	_Read_Request,a6
	move.l	#9600,60(a6)
;                                      break;
	bra	.179
;                                      }
.185
	dc.w	.180-.186-2
	dc.w	.181-.186-2
	dc.w	.182-.186-2
	dc.w	.183-.186-2
	dc.w	.184-.186-2
.178
	cmp.l	#5,d0
	bcc	.179
	asl.l	#1,d0
	move.w	.185(pc,d0.w),d0
.186
	jmp	(pc,d0.w)
.179
;                                Read_Request->IOSer.io_Command 
;= SDCMD_SETPARAMS;
	move.l	_Read_Request,a6
	move.w	#11,28(a6)
;                                DoIO(Read_Request);
	move.l	_Read_Request,-(a7)
	jsr	_DoIO
	add.w	#4,a7
;                                Read_Request->IOSer.io_Command 
;= CMD_READ;
	move.l	_Read_Request,a6
	move.w	#2,28(a6)
;                                BeginIO(Read_Request);
	move.l	_Read_Request,-(a7)
	jsr	_BeginIO
	add.w	#4,a7
;                             break;
	bra	.148
;                            case 2:                /*  "Mode" *
.187
;/
;                              switch( itemnum)
	move.l	#0,d0
	move.w	-14(a5),d0
	bra	.188
;                              {
;                               case 0:  /* Half Duplex */
.190
;                                ECHO = 0;
	clr.w	_ECHO
;                                LOCAL = 1;
	move.w	#1,_LOCAL
;                                break;
	bra	.189
;                               case 1:  /* Full Duplex */
.191
;                                ECHO = 0;
	clr.w	_ECHO
;                                LOCAL = 0;
	clr.w	_LOCAL
;                                break;
	bra	.189
;                               case 2:  /* EchoPlex  */
.192
;                                ECHO = 1;
	move.w	#1,_ECHO
;                                LOCAL = 1;
	move.w	#1,_LOCAL
;                               }
	bra	.189
.188
	tst.l	d0
	beq	.190
	sub.l	#1,d0
	beq	.191
	sub.l	#1,d0
	beq	.192
.189
;                             break;
	bra	.148
;                             case 3:    /* load function-keys (
.193
;mar.86) */
;                               if (GetLine("Function-Key file n
;ame: ",name))
;                                { if (LoadKeys(name))
	pea	-53(a5)
	pea	.83+592
	jsr	_GetLine
	add.w	#8,a7
	tst.w	d0
	beq	.194
;                                  PutString("Loaded\n");
	pea	-53(a5)
	jsr	_LoadKeys
	add.w	#4,a7
	tst.w	d0
	beq	.195
	pea	.83+617
	jsr	_PutString
	add.w	#4,a7
;                                  else PutString("Couldn't load
	bra	.196
.195
; that file\n");
	pea	.83+625
	jsr	_PutString
	add.w	#4,a7
.196
;                                 } else PutChar('\n');
	bra	.197
.194
	move.w	#10,-(a7)
	jsr	_PutChar
	add.w	#2,a7
.197
;                             } /* end of switch ( menunum ) */
	bra	.148
.198
	dc.w	.149-.199-2
	dc.w	.177-.199-2
	dc.w	.187-.199-2
	dc.w	.193-.199-2
.147
	cmp.l	#4,d0
	bcc	.148
	asl.l	#1,d0
	move.w	.198(pc,d0.w),d0
.199
	jmp	(pc,d0.w)
.148
;
;                       }    /*  end of if ( not null ) */
;                }   /* end of switch (class) */
.146
	bra	.142
.141
	sub.l	#2,d0
	beq	.144
	sub.l	#254,d0
	beq	.145
	sub.l	#256,d0
	beq	.143
.142
;          }   /* end of while ( newmessage )*/
	bra	.139
.140
;     }  /* end while ( keepgoing ) */
	bra	.101
.102
;
;/*   It must be time to quit, so we have to clean
;*   up and exit.
;*/
;
;CloseDevice(Read_Request);
	move.l	_Read_Request,-(a7)
	jsr	_CloseDevice
	add.w	#4,a7
;DeletePort(Read_Request->IOSer.io_Message.mn_ReplyPort);
	move.l	_Read_Request,a6
	move.l	14(a6),-(a7)
	jsr	_DeletePort
	add.w	#4,a7
;FreeMem(Read_Request,(long)sizeof(*Read_Request));
	pea	82
	move.l	_Read_Request,-(a7)
	jsr	_FreeMem
	add.w	#8,a7
;FreeMem(keybuf,(long)BUFSIZE);
	pea	400
	move.l	_keybuf,-(a7)
	jsr	_FreeMem
	add.w	#8,a7
;CloseDevice(Write_Request);
	move.l	_Write_Request,-(a7)
	jsr	_CloseDevice
	add.w	#4,a7
;DeletePort(Write_Request->IOSer.io_Message.mn_ReplyPort);
	move.l	_Write_Request,a6
	move.l	14(a6),-(a7)
	jsr	_DeletePort
	add.w	#4,a7
;FreeMem(Write_Request,(long)sizeof(*Write_Request));
	pea	82
	move.l	_Write_Request,-(a7)
	jsr	_FreeMem
	add.w	#8,a7
;ClearMenuStrip( mywindow );
	move.l	_mywindow,-(a7)
	jsr	_ClearMenuStrip
	add.w	#4,a7
;CloseWindow( mywindow );
	move.l	_mywindow,-(a7)
	jsr	_CloseWindow
	add.w	#4,a7
;CloseConsole();
	jsr	_CloseConsole
;CloseLibrary(GfxBase);
	move.l	_GfxBase,-(a7)
	jsr	_CloseLibrary
	add.w	#4,a7
;CloseLibrary(IntuitionBase);
	move.l	_IntuitionBase,-(a7)
	jsr	_CloseLibrary
	add.w	#4,a7
;exit();
	jsr	_exit
;} /* end of main */
.200
	movem.l	(sp)+,.85
	unlk	a5
	rts
.84	equ	-64
.85	reg	
.83
	dc.b	105,110,116,117,105,116,105,111,110,46,108,105,98,114,97
	dc.b	114,121,0,99,97,110,39,116,32,111,112,101,110,32,105
	dc.b	110,116,117,105,116,105,111,110,10,0,103,114,97,112,104
	dc.b	105,99,115,46,108,105,98,114,97,114,121,0,99,97,110
	dc.b	39,116,32,111,112,101,110,32,103,114,97,112,104,105,99
	dc.b	115,32,108,105,98,114,97,114,121,10,0,99,97,110,39
	dc.b	116,32,111,112,101,110,32,119,105,110,100,111,119,10,0
	dc.b	67,97,110,39,116,32,111,112,101,110,32,99,111,110,115
	dc.b	111,108,101,10,0,82,101,97,100,95,82,83,0,115,101
	dc.b	114,105,97,108,46,100,101,118,105,99,101,0,67,97,110
	dc.b	39,116,32,111,112,101,110,32,82,101,97,100,32,100,101
	dc.b	118,105,99,101,10,0,87,114,105,116,101,95,82,83,0
	dc.b	115,101,114,105,97,108,46,100,101,118,105,99,101,0,67
	dc.b	97,110,39,116,32,111,112,101,110,32,87,114,105,116,101
	dc.b	32,100,101,118,105,99,101,10,0,67,97,110,39,116,32
	dc.b	103,101,116,32,109,101,109,111,114,121,32,102,111,114,32
	dc.b	102,117,110,99,116,105,111,110,32,107,101,121,115,10,0
	dc.b	105,110,105,116,46,107,101,121,0,70,117,110,99,116,105
	dc.b	111,110,32,75,101,121,115,32,76,111,97,100,101,100,46
	dc.b	46,46,10,0,10,70,105,108,101,32,83,101,110,116,10
	dc.b	0,65,77,73,71,65,32,84,101,114,109,32,65,84,69
	dc.b	82,77,54,10,10,0,10,80,114,111,109,112,116,32,99
	dc.b	104,97,114,97,99,116,101,114,32,105,115,32,0,10,10
	dc.b	0,10,69,110,100,32,70,105,108,101,32,67,97,112,116
	dc.b	117,114,101,10,0,10,65,115,99,105,105,32,67,97,112
	dc.b	116,117,114,101,58,32,0,119,0,10,69,114,114,111,114
	dc.b	32,79,112,101,110,105,110,103,32,70,105,108,101,10,0
	dc.b	10,65,98,111,114,116,101,100,10,0,10,70,105,108,101
	dc.b	32,83,101,110,100,32,67,97,110,99,101,108,108,101,100
	dc.b	10,0,10,65,115,99,105,105,32,83,101,110,100,58,32
	dc.b	0,114,0,10,69,114,114,111,114,32,79,112,101,110,105
	dc.b	110,103,32,70,105,108,101,10,0,10,65,98,111,114,116
	dc.b	101,100,10,0,10,88,109,111,100,101,109,32,82,101,99
	dc.b	101,105,118,101,58,0,10,65,98,111,114,116,101,100,10
	dc.b	0,10,88,109,111,100,101,109,32,83,101,110,100,58,32
	dc.b	0,10,83,101,110,116,32,70,105,108,101,10,0,10,88
	dc.b	109,111,100,101,109,32,83,101,110,100,32,70,97,105,108
	dc.b	101,100,10,0,10,65,98,111,114,116,101,100,10,0,78
	dc.b	101,119,32,80,114,111,109,112,116,32,67,104,97,114,97
	dc.b	99,116,101,114,58,32,0,70,117,110,99,116,105,111,110
	dc.b	45,75,101,121,32,102,105,108,101,32,110,97,109,101,58
	dc.b	32,0,76,111,97,100,101,100,10,0,67,111,117,108,100
	dc.b	110,39,116,32,108,111,97,100,32,116,104,97,116,32,102
	dc.b	105,108,101,10,0
	ds	0
;
;/**************************************************************
;******/
;/*           terminal-mode character send                      
;     */
;/**************************************************************
;******/
;
;sendchar(ch)
;  UBYTE ch;
	public	_sendchar
_sendchar:
	link	a5,#.202
	movem.l	.203,-(sp)
;  {
;    rs_out[0] = ch;
	move.b	9(a5),_rs_out
;    DoIO(Write_Request);
	move.l	_Write_Request,-(a7)
	jsr	_DoIO
	add.w	#4,a7
;    if (LOCAL)
;    if(ch!='\n')
	tst.w	_LOCAL
	beq	.204
;    PutChar(ch=='\r'?'\n':ch);  /* if Half-Duplex or Echo-plex 
	move.l	#0,d3
	move.b	9(a5),d3
	cmp.w	#10,d3
	beq	.205
	move.l	#0,d3
	move.b	9(a5),d3
	cmp.w	#13,d3
	bne	.206
	move.l	#10,d3
	bra	.207
.206
	move.l	#0,d3
	move.b	9(a5),d3
.207
	move.w	d3,-(a7)
	jsr	_PutChar
	add.w	#2,a7
;*/
;   }
.205
.204
.208
	movem.l	(sp)+,.203
	unlk	a5
	rts
.202	equ	0
.203	reg	
;
;/**************************************************************
;/
;/* send char and read char functions for the xmodem function */
;
;/************************************************************/
;
;
;/*    purge() is called whenever an error is detected.
;     Its function is to flush the input buffer, and wait
;     until the sender has finished sending a block.
;     This ensures that the sender will see the NAK
;     sent by the error routine.
;*/
;
;void purge(purgetime)
;    int purgetime;      /* number of ticks @ 50 per second */
	public	_purge
_purge:
	link	a5,#.209
	movem.l	.210,-(sp)
;   {
;
;    do  ModemRead(purgetime);
.213
	move.w	8(a5),-(a7)
	jsr	_ModemRead
	add.w	#2,a7
;    while (timeout == FALSE);       /* Wait for the line to cle
.211
	move.w	_timeout,d3
	ext.l	d3
	tst.l	d3
	beq	.213
.212
;ar */
;   }
.214
	movem.l	(sp)+,.210
	unlk	a5
	rts
.209	equ	0
.210	reg	
;
;
;
;     /* ModemSend() is simply sendchar() without local echo
;      */
;
;void ModemSend(c)
;    UBYTE c;
	public	_ModemSend
_ModemSend:
	link	a5,#.215
	movem.l	.216,-(sp)
;    { rs_out[0] = c;
	move.b	9(a5),_rs_out
;      DoIO(Write_Request);
	move.l	_Write_Request,-(a7)
	jsr	_DoIO
	add.w	#4,a7
;     }
.217
	movem.l	(sp)+,.216
	unlk	a5
	rts
.215	equ	0
.216	reg	
;
;/*     ModemRead()  gets a character from the serial port withi
;n a
;      specified number of ticks (tick = 1/50 second). DateStamp
;()
;      returns a 3-byte integer date consisting of day, minute, 
;ticks.
;      ModemRead() will function correctly as long as the date i
;s set
;      and a day boundary isn't crossed.
;*/
;
;
;    UBYTE
;ModemRead(MAXTICKS)
;   int MAXTICKS;              /* number of ticks @ 50 per secon
	public	_ModemRead
_ModemRead:
	link	a5,#.218
	movem.l	.219,-(sp)
;d */
;  {
;   static long startime[3], endtime[3];
	bss	.220,12
	bss	.221,12
;   UBYTE c;
;
;   timeout = FALSE;
	clr.w	_timeout
;   DateStamp(startime);
	pea	.220
	jsr	_DateStamp
	add.w	#4,a7
;   do {
.224
;       if ((c=CheckKey()) == 0x1b)  /* ESC cancels xmodem tranx
;fer */
;             { cancel = TRUE;
	jsr	_CheckKey
	move.b	d0,-1(a5)
	move.l	#0,d3
	move.b	d0,d3
	cmp.w	#27,d3
	bne	.225
	move.w	#1,_cancel
;               return (0);  /* This will tend to force an error
	move.l	#0,d0
.226
	movem.l	(sp)+,.219
	unlk	a5
	rts
;        */
;              }             /* when <esc> pressed 'midst block 
;receive */
;       if (CheckIO(Read_Request))
.225
;        { WaitIO(Read_Request);
	move.l	_Read_Request,-(a7)
	jsr	_CheckIO
	add.w	#4,a7
	tst.l	d0
	beq	.227
	move.l	_Read_Request,-(a7)
	jsr	_WaitIO
	add.w	#4,a7
;          c = rs_in[0];
	move.b	_rs_in,-1(a5)
;          BeginIO(Read_Request);
	move.l	_Read_Request,-(a7)
	jsr	_BeginIO
	add.w	#4,a7
;          return c;             /* Character came in on time */
	move.b	-1(a5),d0
	bra	.226
;
;         }
;       DateStamp(endtime);
.227
	pea	.221
	jsr	_DateStamp
	add.w	#4,a7
;       endtime[2] -= startime[2];
	move.l	.220+8,d3
	sub.l	d3,.221+8
;        if ( endtime[1] -= startime[1] ) /* did minutes count c
;hange? */
;        endtime[2] += endtime[1] * 3000; /* number of ticks in 
	move.l	.220+4,d3
	sub.l	d3,.221+4
	tst.l	.221+4
	beq	.228
	move.l	.221+4,d0
	move.l	#3000,d1
	jsr	.mulu#
	add.l	d0,.221+8
;minute */
;      }
.228
;   while (endtime[2] < MAXTICKS);
.222
	move.w	8(a5),d3
	ext.l	d3
	move.l	.221+8,d2
	cmp.l	d3,d2
	blt	.224
.223
;     /* else character not received on time */
;   timeout = TRUE;
	move.w	#1,_timeout
;   return (0);
	move.l	#0,d0
	bra	.226
;  }
.218	equ	-2
.219	reg	
;
;
;
;/*   CloseEmUp() closes a receive file, ending Xmodem receive.
;
;     It also performs a 'chop' function, testing for
;     zero, 0xff, and CP/M_EOF (ctrol-z).
;     To implement the chop function, a two-block buffer
;     is maintained, with the basic pointer being bufr[offset],
;
;     with offset toggled 0,SECSIZ,0, etc.
;     During file receive, writes lag reads by one block: e.g.,
;
;     when block # 3 is received, block # 2 is written.
;     If block # 3 is the final block, CloseEmUp() will
;     chop any invalid characters, write the block, and
;     close the file.
;*/
;
;CloseEmUp(fd,bufr,offset,ourblock)
;
;int fd,offset, ourblock;
	public	_CloseEmUp
_CloseEmUp:
	link	a5,#.229
	movem.l	.230,-(sp)
;UBYTE *bufr;
;
;{
;   int i,x;
;   ULONG size=0;
	clr.l	-8(a5)
;   UBYTE c,numstring[7];
;
; offset = offset ? 0 : SECSIZ ;  /* toggle offset */
	tst.w	14(a5)
	beq	.231
	clr.w	14(a5)
	bra	.232
.231
	move.w	#128,14(a5)
.232
;
; if (ourblock)                     /* skip if no data at all */
;
;  {
	tst.w	16(a5)
	beq	.233
;    i = SECSIZ - 1;
	move.w	#127,-2(a5)
;    c = bufr[offset + i];       /* c gets last char in block */
	move.w	14(a5),d3
	add.w	-2(a5),d3
	move.l	10(a5),a6
	move.b	(a6,d3.w),-9(a5)
;
;    if ( (c == 0) || (c == CPM_EOF) || (c == 0xff) )
;      {
	move.l	#0,d3
	move.b	-9(a5),d3
	tst.w	d3
	beq	.235
	move.l	#0,d3
	move.b	-9(a5),d3
	cmp.w	#26,d3
	beq	.235
	move.l	#0,d3
	move.b	-9(a5),d3
	cmp.w	#255,d3
	bne	.234
.235
;        while (bufr[ offset+(--i) ] == c)  /* Chop those useles
.236
	sub.w	#1,-2(a5)
	move.w	-2(a5),d3
	add.w	14(a5),d3
	move.l	10(a5),a6
	move.l	#0,d2
	move.b	(a6,d3.w),d2
	move.l	#0,d3
	move.b	-9(a5),d3
	cmp.w	d3,d2
	bne	.237
;s bytes! */
;                   ;
	bra	.236
.237
;       }
;    if ((c = write(fd, bufr+offset, ++i)) != i)
.234
;       PutString("Error writing final block\n");
	add.w	#1,-2(a5)
	move.w	-2(a5),-(a7)
	move.w	14(a5),d3
	ext.l	d3
	add.l	10(a5),d3
	move.l	d3,-(a7)
	move.w	8(a5),-(a7)
	jsr	_write
	add.w	#8,a7
	move.b	d0,-9(a5)
	move.l	#0,d3
	move.b	d0,d3
	cmp.w	-2(a5),d3
	beq	.238
	pea	.201+0
	jsr	_PutString
	add.w	#4,a7
;    x = SECSIZ - i;
.238
	move.w	#128,d3
	sub.w	-2(a5),d3
	move.w	d3,-4(a5)
;    format(PutChar,"%d bytes chopped from final block\n",&x);
	pea	-4(a5)
	pea	.201+27
	pea	_PutChar
	jsr	_format
	lea	12(a7),a7
;
;    size=(--ourblock)*(long)SECSIZ;
	sub.w	#1,16(a5)
	move.w	16(a5),d3
	ext.l	d3
	asl.l	#7,d3
	move.l	d3,-8(a5)
;    size += i;
	move.w	-2(a5),d3
	ext.l	d3
	add.l	d3,-8(a5)
;    format(PutChar,"File size: %ld\n",&size);
	pea	-8(a5)
	pea	.201+62
	pea	_PutChar
	jsr	_format
	lea	12(a7),a7
;   }
;
; close(fd);
.233
	move.w	8(a5),-(a7)
	jsr	_close
	add.w	#2,a7
;}
.239
	movem.l	(sp)+,.230
	unlk	a5
	rts
.229	equ	-16
.230	reg	
.201
	dc.b	69,114,114,111,114,32,119,114,105,116,105,110,103,32,102
	dc.b	105,110,97,108,32,98,108,111,99,107,10,0,37,100,32
	dc.b	98,121,116,101,115,32,99,104,111,112,112,101,100,32,102
	dc.b	114,111,109,32,102,105,110,97,108,32,98,108,111,99,107
	dc.b	10,0,70,105,108,101,32,115,105,122,101,58,32,37,108
	dc.b	100,10,0
	ds	0
;
;
;/**************************************/
;/* xmodem send and receive functions */
;/************************************/
;
;            /* These time constants are for benefit of
;               CompuServe and other packet-switching networks
;               that must be allowed more "slack time"
;               due to inherent delays in system.
;             */
;
;#define Blocktime 20*50 /* Wait 20 seconds for start of block *
;/
;#define Chartime   2*50 /* Wait 2 seconds for chars when gettin
;g block */
;
;
;XMODEM_Read_File(file)
;
;char *file;
	public	_XMODEM_Read_File
_XMODEM_Read_File:
	link	a5,#.241
	movem.l	.242,-(sp)
;
;{
;int ourblock, errors, checksum, offset, x,i;
;UBYTE c,blockin;
;
;if ( (fd = creat(file,0)) == -1)
;   { PutString("Cannot open file\n");
	clr.w	-(a7)
	move.l	8(a5),-(a7)
	jsr	_creat
	add.w	#6,a7
	move.w	d0,_fd
	cmp.w	#-1,d0
	bne	.243
	pea	.240+0
	jsr	_PutString
	add.w	#4,a7
;     return FALSE;
	move.l	#0,d0
.244
	movem.l	(sp)+,.242
	unlk	a5
	rts
;    }
;else PutString("Receiving file \n");
.243
	pea	.240+18
	jsr	_PutString
	add.w	#4,a7
;
;         /* Input file now open */
;
;offset = ourblock = errors = cancel = 0;
	clr.w	_cancel
	clr.w	-4(a5)
	clr.w	-2(a5)
	clr.w	-8(a5)
;
;
;ModemSend(NAK);
	move.w	#21,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;                        /*  MAIN LOOP STARTS HERE  */
;loop:
.245
;
;c = ModemRead(Blocktime);
	move.w	#1000,-(a7)
	jsr	_ModemRead
	add.w	#2,a7
	move.b	d0,-13(a5)
;
;   if (cancel)
;   { PutString("Xmodem cancelled\n");
	tst.w	_cancel
	beq	.246
	pea	.240+35
	jsr	_PutString
	add.w	#4,a7
;     close(fd);
	move.w	_fd,-(a7)
	jsr	_close
	add.w	#2,a7
;     purge(Chartime);
	move.w	#100,-(a7)
	jsr	_purge
	add.w	#2,a7
;     ModemSend(CAN);
	move.w	#24,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;     return(FALSE);
	move.l	#0,d0
	bra	.244
;    }
;
;   if (timeout)
.246
;   { PutString("timed out waiting for block start\n");
	tst.w	_timeout
	beq	.247
	pea	.240+53
	jsr	_PutString
	add.w	#4,a7
;     goto error;
	bra	.248
;    }
;
; if(c == CAN)    /*Sender just quit*/
.247
;   { purge(Chartime);
	move.l	#0,d3
	move.b	-13(a5),d3
	cmp.w	#24,d3
	bne	.249
	move.w	#100,-(a7)
	jsr	_purge
	add.w	#2,a7
;     PutString("Sender aborted transfer\n");
	pea	.240+88
	jsr	_PutString
	add.w	#4,a7
;     CloseEmUp(fd,bufr,offset,ourblock);
	move.w	-2(a5),-(a7)
	move.w	-8(a5),-(a7)
	pea	_bufr
	move.w	_fd,-(a7)
	jsr	_CloseEmUp
	lea	10(a7),a7
;     return(FALSE);
	move.l	#0,d0
	bra	.244
;    }
; if (c == EOT)   /*Sender is finished */
.249
;   {
	move.l	#0,d3
	move.b	-13(a5),d3
	cmp.w	#4,d3
	bne	.250
;     CloseEmUp(fd,bufr,offset,ourblock);   /* chop and write la
	move.w	-2(a5),-(a7)
	move.w	-8(a5),-(a7)
	pea	_bufr
	move.w	_fd,-(a7)
	jsr	_CloseEmUp
	lea	10(a7),a7
;st block */
;     PutString("Transfer Completed\n");
	pea	.240+113
	jsr	_PutString
	add.w	#4,a7
;     ModemSend(ACK);
	move.w	#6,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;     return(TRUE);
	move.l	#1,d0
	bra	.244
;    }
; if (c != SOH)
.250
;   { purge(Chartime);
	move.l	#0,d3
	move.b	-13(a5),d3
	cmp.w	#1,d3
	beq	.251
	move.w	#100,-(a7)
	jsr	_purge
	add.w	#2,a7
;     PutString("not a valid header\n");
	pea	.240+133
	jsr	_PutString
	add.w	#4,a7
;     goto error;
	bra	.248
;    }
;      /*Sender has a block for us */
;      /* block receive follows here */
;blockin = ModemRead(Chartime);  /* get block number */
.251
	move.w	#100,-(a7)
	jsr	_ModemRead
	add.w	#2,a7
	move.b	d0,-14(a5)
;   if (timeout)
;   { purge(Chartime);
	tst.w	_timeout
	beq	.252
	move.w	#100,-(a7)
	jsr	_purge
	add.w	#2,a7
;     PutString("Didn't get block# in time\n");
	pea	.240+153
	jsr	_PutString
	add.w	#4,a7
;     goto error;
	bra	.248
;    }
;c = ModemRead(Chartime);       /* get 1/blocknumber */
.252
	move.w	#100,-(a7)
	jsr	_ModemRead
	add.w	#2,a7
	move.b	d0,-13(a5)
;   if (timeout)
;   { purge(Chartime);
	tst.w	_timeout
	beq	.253
	move.w	#100,-(a7)
	jsr	_purge
	add.w	#2,a7
;     PutString("Timed out waiting for 1/block#\n");
	pea	.240+180
	jsr	_PutString
	add.w	#4,a7
;     goto error;
	bra	.248
;    }
;
;if ( ( (UBYTE)~c) != blockin)  /* block # got lunched */
.253
;   { purge(Chartime);
	move.b	-13(a5),d3
	not.b	d3
	move.l	#0,d2
	move.b	d3,d2
	move.l	#0,d3
	move.b	-14(a5),d3
	cmp.w	d3,d2
	beq	.254
	move.w	#100,-(a7)
	jsr	_purge
	add.w	#2,a7
;     PutString("block complement didn't match\n");
	pea	.240+212
	jsr	_PutString
	add.w	#4,a7
;     goto error;
	bra	.248
;    }
;            /* Here comes a block of data  */
;
;checksum = 0;
.254
	clr.w	-6(a5)
;
;for (i = 0; i < SECSIZ; i++ )
	clr.w	-12(a5)
.257
; {
;   c = ModemRead(Chartime);
	move.w	#100,-(a7)
	jsr	_ModemRead
	add.w	#2,a7
	move.b	d0,-13(a5)
;     if (timeout)
;      { purge(Chartime);
	tst.w	_timeout
	beq	.258
	move.w	#100,-(a7)
	jsr	_purge
	add.w	#2,a7
;        PutString("Timed out during block\n");
	pea	.240+243
	jsr	_PutString
	add.w	#4,a7
;        goto error;
	bra	.248
;       }
;   bufr[offset+i] = c;
.258
	move.w	-8(a5),d3
	add.w	-12(a5),d3
	lea	_bufr,a6
	move.b	-13(a5),(a6,d3.w)
;   checksum += c;
	move.l	#0,d3
	move.b	-13(a5),d3
	add.w	d3,-6(a5)
;  }
.255
	add.w	#1,-12(a5)
	cmp.w	#128,-12(a5)
	blt	.257
.256
;
;            /* Here comes the checksum */
;c = ModemRead(Chartime);
	move.w	#100,-(a7)
	jsr	_ModemRead
	add.w	#2,a7
	move.b	d0,-13(a5)
;   if (timeout)
;   { purge(Chartime);
	tst.w	_timeout
	beq	.259
	move.w	#100,-(a7)
	jsr	_purge
	add.w	#2,a7
;     PutString("Timed out waiting for checksum\n");
	pea	.240+267
	jsr	_PutString
	add.w	#4,a7
;     goto error;
	bra	.248
;    }
;if (c != (checksum & 0xff) ) /* checksums don't match */
.259
;  {
	move.l	#0,d3
	move.b	-13(a5),d3
	move.w	-6(a5),d2
	and.w	#255,d2
	cmp.w	d2,d3
	beq	.260
;   purge(Chartime);
	move.w	#100,-(a7)
	jsr	_purge
	add.w	#2,a7
;   PutString("checksum error\n");
	pea	.240+299
	jsr	_PutString
	add.w	#4,a7
;   goto error;
	bra	.248
;   }
;
;      /* Block has been received OK: Now check back on blocknum
;ber */
;
;switch ( (UBYTE) (blockin - (ourblock & 0xff)) )
.260
	move.l	#0,d3
	move.b	-14(a5),d3
	move.w	-2(a5),d2
	and.w	#255,d2
	sub.w	d2,d3
	move.l	#0,d0
	move.b	d3,d0
	bra	.261
;{
; case (0):       /* Duplicate block */
.263
;  {
;   format(PutChar,"\nDuplicate block # %d\n",&ourblock);
	pea	-2(a5)
	pea	.240+315
	pea	_PutChar
	jsr	_format
	lea	12(a7),a7
;   errors = 0;
	clr.w	-4(a5)
;   ModemSend(ACK);
	move.w	#6,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;   goto loop;
	bra	.245
;  }
; case (1):      /* New block */
.264
;  {
;   ourblock++;           /* Update our block count */
	add.w	#1,-2(a5)
;   PutChar(0x0b);        /* do a vertical tab */
	move.w	#11,-(a7)
	jsr	_PutChar
	add.w	#2,a7
;   format(PutChar,"Received block # %d     \n",&ourblock);
	pea	-2(a5)
	pea	.240+338
	pea	_PutChar
	jsr	_format
	lea	12(a7),a7
;
;   offset = offset ? 0 : SECSIZ;                  /* toggle off
	tst.w	-8(a5)
	beq	.265
	clr.w	-8(a5)
	bra	.266
.265
	move.w	#128,-8(a5)
.266
;set */
;   if (ourblock != 1)
;   {                                              /* Write it o
	cmp.w	#1,-2(a5)
	beq	.267
;ut */
;     if ( (x = (write(fd, bufr+offset, SECSIZ)) ) != SECSIZ)
;       { close(fd);
	move.w	#128,-(a7)
	move.w	-8(a5),d3
	ext.l	d3
	lea	_bufr,a6
	add.l	a6,d3
	move.l	d3,-(a7)
	move.w	_fd,-(a7)
	jsr	_write
	add.w	#8,a7
	move.w	d0,-10(a5)
	cmp.w	#128,d0
	beq	.268
	move.w	_fd,-(a7)
	jsr	_close
	add.w	#2,a7
;         PutString("Error writing to file.\n");
	pea	.240+364
	jsr	_PutString
	add.w	#4,a7
;         PutString("Transfer aborted.\n");
	pea	.240+388
	jsr	_PutString
	add.w	#4,a7
;         ModemSend(CAN);
	move.w	#24,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;         return(FALSE);
	move.l	#0,d0
	bra	.244
;        }
;    }
.268
;   errors = 0;
.267
	clr.w	-4(a5)
;   ModemSend(ACK);
	move.w	#6,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;   goto loop;
	bra	.245
;  }
;default:
.269
;    break;     /* fall through to error: */
	bra	.262
;}
.261
	tst.l	d0
	beq	.263
	sub.l	#1,d0
	beq	.264
	bra	.269
.262
;purge(Chartime);
	move.w	#100,-(a7)
	jsr	_purge
	add.w	#2,a7
;PutString("Block numbers didn't agree\n");
	pea	.240+407
	jsr	_PutString
	add.w	#4,a7
;
;                  /* ERROR ROUTINE STARTS HERE */
;error:
.248
;
;if (cancel)
;   { PutString("XModem cancelled\n");
	tst.w	_cancel
	beq	.270
	pea	.240+435
	jsr	_PutString
	add.w	#4,a7
;     close(fd);
	move.w	_fd,-(a7)
	jsr	_close
	add.w	#2,a7
;     ModemSend(CAN);
	move.w	#24,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;     return(FALSE);
	move.l	#0,d0
	bra	.244
;    }
;
; errors++;
.270
	add.w	#1,-4(a5)
;
; if (errors == 10) /* then abort */
;   {
	cmp.w	#10,-4(a5)
	bne	.271
;     PutString(" 10 Errors. Transfer cancelled.\n");
	pea	.240+453
	jsr	_PutString
	add.w	#4,a7
;     close(fd);
	move.w	_fd,-(a7)
	jsr	_close
	add.w	#2,a7
;     ModemSend(CAN);
	move.w	#24,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;     return(FALSE);
	move.l	#0,d0
	bra	.244
;    }
; format(PutChar,"Error # %d\n",&errors);
.271
	pea	-4(a5)
	pea	.240+486
	pea	_PutChar
	jsr	_format
	lea	12(a7),a7
; ModemSend(NAK);
	move.w	#21,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
; goto loop;
	bra	.245
;
;} /* end of XMODEM_Read_File()  */
.241	equ	-14
.242	reg	
.240
	dc.b	67,97,110,110,111,116,32,111,112,101,110,32,102,105,108
	dc.b	101,10,0,82,101,99,101,105,118,105,110,103,32,102,105
	dc.b	108,101,32,10,0,88,109,111,100,101,109,32,99,97,110
	dc.b	99,101,108,108,101,100,10,0,116,105,109,101,100,32,111
	dc.b	117,116,32,119,97,105,116,105,110,103,32,102,111,114,32
	dc.b	98,108,111,99,107,32,115,116,97,114,116,10,0,83,101
	dc.b	110,100,101,114,32,97,98,111,114,116,101,100,32,116,114
	dc.b	97,110,115,102,101,114,10,0,84,114,97,110,115,102,101
	dc.b	114,32,67,111,109,112,108,101,116,101,100,10,0,110,111
	dc.b	116,32,97,32,118,97,108,105,100,32,104,101,97,100,101
	dc.b	114,10,0,68,105,100,110,39,116,32,103,101,116,32,98
	dc.b	108,111,99,107,35,32,105,110,32,116,105,109,101,10,0
	dc.b	84,105,109,101,100,32,111,117,116,32,119,97,105,116,105
	dc.b	110,103,32,102,111,114,32,49,47,98,108,111,99,107,35
	dc.b	10,0,98,108,111,99,107,32,99,111,109,112,108,101,109
	dc.b	101,110,116,32,100,105,100,110,39,116,32,109,97,116,99
	dc.b	104,10,0,84,105,109,101,100,32,111,117,116,32,100,117
	dc.b	114,105,110,103,32,98,108,111,99,107,10,0,84,105,109
	dc.b	101,100,32,111,117,116,32,119,97,105,116,105,110,103,32
	dc.b	102,111,114,32,99,104,101,99,107,115,117,109,10,0,99
	dc.b	104,101,99,107,115,117,109,32,101,114,114,111,114,10,0
	dc.b	10,68,117,112,108,105,99,97,116,101,32,98,108,111,99
	dc.b	107,32,35,32,37,100,10,0,82,101,99,101,105,118,101
	dc.b	100,32,98,108,111,99,107,32,35,32,37,100,32,32,32
	dc.b	32,32,10,0,69,114,114,111,114,32,119,114,105,116,105
	dc.b	110,103,32,116,111,32,102,105,108,101,46,10,0,84,114
	dc.b	97,110,115,102,101,114,32,97,98,111,114,116,101,100,46
	dc.b	10,0,66,108,111,99,107,32,110,117,109,98,101,114,115
	dc.b	32,100,105,100,110,39,116,32,97,103,114,101,101,10,0
	dc.b	88,77,111,100,101,109,32,99,97,110,99,101,108,108,101
	dc.b	100,10,0,32,49,48,32,69,114,114,111,114,115,46,32
	dc.b	84,114,97,110,115,102,101,114,32,99,97,110,99,101,108
	dc.b	108,101,100,46,10,0,69,114,114,111,114,32,35,32,37
	dc.b	100,10,0
	ds	0
;
;
;#define WaitTime 20*50  /* Wait this long for NAKs (20 seconds)
;*/
;
;XMODEM_Send_File(file)
;    char *file;
	public	_XMODEM_Send_File
_XMODEM_Send_File:
	link	a5,#.273
	movem.l	.274,-(sp)
;{
;    int i, x, j,
;         size,
;         errors=0, blocknum=1;
	clr.w	-10(a5)
	move.w	#1,-12(a5)
;    char numb[10];
;    UBYTE sectnum=1,c,checksum;
	move.b	#1,-23(a5)
;    cancel=FALSE;
	clr.w	_cancel
;    if ((fd = open(file, O_RDONLY)) == -1)
;      {
	clr.w	-(a7)
	move.l	8(a5),-(a7)
	jsr	_open
	add.w	#6,a7
	move.w	d0,_fd
	cmp.w	#-1,d0
	bne	.275
;         PutString("Cannot Open Send File\n");
	pea	.272+0
	jsr	_PutString
	add.w	#4,a7
;         ModemSend(CAN);
	move.w	#24,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;         return FALSE;
	move.l	#0,d0
.276
	movem.l	(sp)+,.274
	unlk	a5
	rts
;        }
;    else
.275
;        PutString("Sending File\n");
	pea	.272+23
	jsr	_PutString
	add.w	#4,a7
;
;       for (errors=0;errors<10;errors++)
	clr.w	-10(a5)
.279
;        { c=ModemRead(WaitTime);
	move.w	#1000,-(a7)
	jsr	_ModemRead
	add.w	#2,a7
	move.b	d0,-24(a5)
;          if (cancel)
;           { PutString("Aborted\n");
	tst.w	_cancel
	beq	.280
	pea	.272+37
	jsr	_PutString
	add.w	#4,a7
;             return(FALSE);
	move.l	#0,d0
	bra	.276
;            }
;          if (timeout)
.280
;           { PutString("...nothing yet...\n");
	tst.w	_timeout
	beq	.281
	pea	.272+46
	jsr	_PutString
	add.w	#4,a7
;            }
;          else if (c == CAN)
	bra	.282
.281
;           { PutString("Receiver has cancelled.\n");
	move.l	#0,d3
	move.b	-24(a5),d3
	cmp.w	#24,d3
	bne	.283
	pea	.272+65
	jsr	_PutString
	add.w	#4,a7
;             return(FALSE);
	move.l	#0,d0
	bra	.276
;            }
;          else if (c != NAK)
.283
;           { PutString("Got something, but not NAK\n");
	move.l	#0,d3
	move.b	-24(a5),d3
	cmp.w	#21,d3
	beq	.284
	pea	.272+90
	jsr	_PutString
	add.w	#4,a7
;            }
;          else break;        /* got first NAK */
	bra	.285
.284
	bra	.278
.285
.282
;         }
.277
	add.w	#1,-10(a5)
	cmp.w	#10,-10(a5)
	blt	.279
.278
;           if (errors == 10)
;            { PutString("Quitting after 10 errors\n");
	cmp.w	#10,-10(a5)
	bne	.286
	pea	.272+118
	jsr	_PutString
	add.w	#4,a7
;              ModemSend(CAN);
	move.w	#24,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;              return(FALSE);
	move.l	#0,d0
	bra	.276
;             }
;   XS0:    /* get a block into the buffer */
.286
.287
;
;#asm
      move.l   #_bufr,a0      ; zero out the memory buffer
      move.w   #31,d0         ; set up for 128 bytes
loop  clr.l    (a0)+
      dbf      d0,loop
;
;      size = read(fd,bufr,SECSIZ);
	move.w	#128,-(a7)
	pea	_bufr
	move.w	_fd,-(a7)
	jsr	_read
	add.w	#8,a7
	move.w	d0,-8(a5)
;      if (size == 0)
;       { ModemSend(EOT);
	tst.w	-8(a5)
	bne	.288
	move.w	#4,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;         close(fd);
	move.w	_fd,-(a7)
	jsr	_close
	add.w	#2,a7
;         return(TRUE);
	move.l	#1,d0
	bra	.276
;        }
;      if (size == -1)
.288
;       { PutString("Error reading file\n");
	cmp.w	#-1,-8(a5)
	bne	.289
	pea	.272+144
	jsr	_PutString
	add.w	#4,a7
;         close(fd);
	move.w	_fd,-(a7)
	jsr	_close
	add.w	#2,a7
;         ModemSend(CAN);
	move.w	#24,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;         return(FALSE);
	move.l	#0,d0
	bra	.276
;        }
;      errors = 0;
.289
	clr.w	-10(a5)
;   XS1:          /* send a block */
.290
;
;         ModemSend(SOH);
	move.w	#1,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;         ModemSend(sectnum);
	move.l	#0,d3
	move.b	-23(a5),d3
	move.w	d3,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;         ModemSend(~sectnum);
	move.b	-23(a5),d3
	not.b	d3
	move.l	#0,d2
	move.b	d3,d2
	move.w	d2,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;         checksum = 0;
	clr.b	-25(a5)
;
;         for (j=0;j<SECSIZ;j++)
	clr.w	-6(a5)
.293
;          {
;             ModemSend(bufr[j]);
	move.w	-6(a5),d3
	lea	_bufr,a6
	move.l	#0,d2
	move.b	(a6,d3.w),d2
	move.w	d2,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;             checksum += bufr[j];
	move.w	-6(a5),d3
	lea	_bufr,a6
	move.b	(a6,d3.w),d2
	add.b	d2,-25(a5)
;            }
.291
	add.w	#1,-6(a5)
	cmp.w	#128,-6(a5)
	blt	.293
.292
;         ModemSend(checksum);
	move.l	#0,d3
	move.b	-25(a5),d3
	move.w	d3,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;
;         c = ModemRead(WaitTime);
	move.w	#1000,-(a7)
	jsr	_ModemRead
	add.w	#2,a7
	move.b	d0,-24(a5)
;         if (cancel)
;           { ModemSend(CAN);
	tst.w	_cancel
	beq	.294
	move.w	#24,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;             PutString("Aborted.\n");
	pea	.272+164
	jsr	_PutString
	add.w	#4,a7
;             return(FALSE);
	move.l	#0,d0
	bra	.276
;            }
;         if (c==CAN)
.294
;           { PutString("Receiver cancelled.\n");
	move.l	#0,d3
	move.b	-24(a5),d3
	cmp.w	#24,d3
	bne	.295
	pea	.272+174
	jsr	_PutString
	add.w	#4,a7
;             return(FALSE);
	move.l	#0,d0
	bra	.276
;            }
;         if ((timeout) || (c != ACK))
.295
;          { errors++;
	tst.w	_timeout
	bne	.297
	move.l	#0,d3
	move.b	-24(a5),d3
	cmp.w	#6,d3
	beq	.296
.297
	add.w	#1,-10(a5)
;            format(PutChar,"Error # %d\n",&errors);
	pea	-10(a5)
	pea	.272+195
	pea	_PutChar
	jsr	_format
	lea	12(a7),a7
;            if (errors == 10)
;             { ModemSend(CAN);
	cmp.w	#10,-10(a5)
	bne	.298
	move.w	#24,-(a7)
	jsr	_ModemSend
	add.w	#2,a7
;               return(FALSE);
	move.l	#0,d0
	bra	.276
;              }
;            goto XS1;       /*  try again  */
.298
	bra	.290
;           }
;
;            PutChar(0x0b);           /* do a reverse linefeed *
.296
	move.w	#11,-(a7)
	jsr	_PutChar
	add.w	#2,a7
;/
;            PutSequence("K");
	pea	.272+207
	jsr	_PutSequence
	add.w	#4,a7
;            format(PutChar,"Block %d sent\n",&blocknum);
	pea	-12(a5)
	pea	.272+209
	pea	_PutChar
	jsr	_format
	lea	12(a7),a7
;            sectnum++;
	add.b	#1,-23(a5)
;            blocknum++;
	add.w	#1,-12(a5)
;            goto XS0;
	bra	.287
; }                    /* end XMODEM_send */
.273	equ	-26
.274	reg	
.272
	dc.b	67,97,110,110,111,116,32,79,112,101,110,32,83,101,110
	dc.b	100,32,70,105,108,101,10,0,83,101,110,100,105,110,103
	dc.b	32,70,105,108,101,10,0,65,98,111,114,116,101,100,10
	dc.b	0,46,46,46,110,111,116,104,105,110,103,32,121,101,116
	dc.b	46,46,46,10,0,82,101,99,101,105,118,101,114,32,104
	dc.b	97,115,32,99,97,110,99,101,108,108,101,100,46,10,0
	dc.b	71,111,116,32,115,111,109,101,116,104,105,110,103,44,32
	dc.b	98,117,116,32,110,111,116,32,78,65,75,10,0,81,117
	dc.b	105,116,116,105,110,103,32,97,102,116,101,114,32,49,48
	dc.b	32,101,114,114,111,114,115,10,0,69,114,114,111,114,32
	dc.b	114,101,97,100,105,110,103,32,102,105,108,101,10,0,65
	dc.b	98,111,114,116,101,100,46,10,0,82,101,99,101,105,118
	dc.b	101,114,32,99,97,110,99,101,108,108,101,100,46,10,0
	dc.b	69,114,114,111,114,32,35,32,37,100,10,0,75,0,66
	dc.b	108,111,99,107,32,37,100,32,115,101,110,116,10,0
	ds	0
;
;/**************************************************************
;*******
;**        Some routines concerned with the function keys       
;     **
;***************************************************************
;******/
;
;/************* Attempt to load a Function-Key file ************
;******/
;
;LoadKeys(keyfile)    /* returns (BOOL) success  */
;
;   char *keyfile;  /* the filename */
	public	_LoadKeys
_LoadKeys:
	link	a5,#.300
	movem.l	.301,-(sp)
; {
;      FILE *fp;
;      UBYTE c;
;      int i;
;   if ((fp=fopen(keyfile,"r")) == NULL)
;     return(FALSE);
	pea	.299+0
	move.l	8(a5),-(a7)
	jsr	_fopen
	add.w	#8,a7
	move.l	d0,-4(a5)
	tst.l	d0
	bne	.302
	move.l	#0,d0
.303
	movem.l	(sp)+,.301
	unlk	a5
	rts
;   if ((c=fgetc(fp)) != HEADER)  /* gotta be a valid key file! 
.302
;*/
;    { fclose(fp);
	move.l	-4(a5),-(a7)
	jsr	_getc
	add.w	#4,a7
	move.b	d0,-5(a5)
	move.l	#0,d3
	move.b	d0,d3
	cmp.w	#170,d3
	beq	.304
	move.l	-4(a5),-(a7)
	jsr	_fclose
	add.w	#4,a7
;      return(FALSE);
	move.l	#0,d0
	bra	.303
;     }
;   for (i=0;i<BUFSIZE;i++)
.304
	clr.w	-8(a5)
.307
;    {
;      if ((c=fgetc(fp)) == EOF)
;       { fclose(fp);
	move.l	-4(a5),-(a7)
	jsr	_getc
	add.w	#4,a7
	move.b	d0,-5(a5)
	move.l	#0,d3
	move.b	d0,d3
	cmp.w	#-1,d3
	bne	.308
	move.l	-4(a5),-(a7)
	jsr	_fclose
	add.w	#4,a7
;         return(FALSE);
	move.l	#0,d0
	bra	.303
;        }
;      else keybuf[i] = c;
.308
	move.w	-8(a5),d3
	move.l	_keybuf,a6
	move.b	-5(a5),(a6,d3.w)
;     }
.305
	add.w	#1,-8(a5)
	cmp.w	#400,-8(a5)
	blt	.307
.306
;    fclose(fp);
	move.l	-4(a5),-(a7)
	jsr	_fclose
	add.w	#4,a7
;    return(TRUE);    /* ahh, success! */
	move.l	#1,d0
	bra	.303
;  }
.300	equ	-8
.301	reg	
.299
	dc.b	114,0
	ds	0
;/************ Display Function-Key contents **********/
;
;DoContents()
;
; {
	public	_DoContents
_DoContents:
	link	a5,#.310
	movem.l	.311,-(sp)
;   int x;
;   UBYTE c;
;  for (x=0;x<NUMKEYS;x++)
	clr.w	-2(a5)
.314
;  {
;    KeyOffset = keybuf+(KEYSIZE * x);
	move.w	-2(a5),d3
	mulu	#40,d3
	ext.l	d3
	add.l	_keybuf,d3
	move.l	d3,_KeyOffset
;    PrintKeyNum(x);
	move.w	-2(a5),-(a7)
	jsr	_PrintKeyNum
	add.w	#2,a7
;    while ( c = *KeyOffset++ )
.315
	move.l	_KeyOffset,a6
	add.l	#1,_KeyOffset
	move.b	(a6),-3(a5)
	tst.b	-3(a5)
	beq	.316
;      keychar(c);
	move.l	#0,d3
	move.b	-3(a5),d3
	move.w	d3,-(a7)
	jsr	_keychar
	add.w	#2,a7
	bra	.315
.316
;    PutChar('\n');
	move.w	#10,-(a7)
	jsr	_PutChar
	add.w	#2,a7
;   }
.312
	add.w	#1,-2(a5)
	cmp.w	#10,-2(a5)
	blt	.314
.313
; }
.317
	movem.l	(sp)+,.311
	unlk	a5
	rts
.310	equ	-4
.311	reg	
;
;/************ Print the function-key number **************/
;/*              format example: F7:                     */
;
;PrintKeyNum(keynum)
;    int keynum;
	public	_PrintKeyNum
_PrintKeyNum:
	link	a5,#.318
	movem.l	.319,-(sp)
; {
;   keynum++;
	add.w	#1,8(a5)
;   PutChar('F');
	move.w	#70,-(a7)
	jsr	_PutChar
	add.w	#2,a7
;  if (keynum == 10)
;   PutString("10: ");
	cmp.w	#10,8(a5)
	bne	.320
	pea	.309+0
	jsr	_PutString
	add.w	#4,a7
;  else
	bra	.321
.320
;   { PutChar(keynum + '0');
	move.w	8(a5),d3
	add.w	#48,d3
	move.w	d3,-(a7)
	jsr	_PutChar
	add.w	#2,a7
;     PutString(":  ");
	pea	.309+5
	jsr	_PutString
	add.w	#4,a7
;    }
.321
;  }
.322
	movem.l	(sp)+,.319
	unlk	a5
	rts
.318	equ	0
.319	reg	
.309
	dc.b	49,48,58,32,0,58,32,32,0
	ds	0
;
;/*********** Print a character from function-key string *******
;*****/
;
;keychar(key)
;   UBYTE key;
	public	_keychar
_keychar:
	link	a5,#.324
	movem.l	.325,-(sp)
; {
;   if (key < 32) /* control character? */
;    {
	move.l	#0,d3
	move.b	9(a5),d3
	cmp.w	#32,d3
	bcc	.326
;      switch (key)
	move.l	#0,d0
	move.b	9(a5),d0
	bra	.327
;      { case 0:
.329
;        PutChar('0');
	move.w	#48,-(a7)
	jsr	_PutChar
	add.w	#2,a7
;        break;
	bra	.328
;        case 8:
.330
;        PutString("<BS>");
	pea	.323+0
	jsr	_PutString
	add.w	#4,a7
;        break;
	bra	.328
;        case 9:
.331
;        PutString("<TAB>");
	pea	.323+5
	jsr	_PutString
	add.w	#4,a7
;        break;
	bra	.328
;       case 10:
.332
;        PutString("<NL>");
	pea	.323+11
	jsr	_PutString
	add.w	#4,a7
;        break;
	bra	.328
;       case 13:
.333
;        PutString("<CR>");
	pea	.323+16
	jsr	_PutString
	add.w	#4,a7
;        break;
	bra	.328
;       case 27:
.334
;        PutString("<ESC>");
	pea	.323+21
	jsr	_PutString
	add.w	#4,a7
;        break;
	bra	.328
;       default:
.335
;        PutChar('^');
	move.w	#94,-(a7)
	jsr	_PutChar
	add.w	#2,a7
;        PutChar(key + 0x40);
	move.l	#0,d3
	move.b	9(a5),d3
	add.w	#64,d3
	move.w	d3,-(a7)
	jsr	_PutChar
	add.w	#2,a7
;       }
	bra	.328
.336
.327
	tst.l	d0
	beq	.329
	sub.l	#8,d0
	beq	.330
	sub.l	#1,d0
	beq	.331
	sub.l	#1,d0
	beq	.332
	sub.l	#3,d0
	beq	.333
	sub.l	#14,d0
	beq	.334
	bra	.335
.328
;      }
;   else PutChar(key);
	bra	.338
.326
	move.l	#0,d3
	move.b	9(a5),d3
	move.w	d3,-(a7)
	jsr	_PutChar
	add.w	#2,a7
.338
;  }
.339
	movem.l	(sp)+,.325
	unlk	a5
	rts
.324	equ	0
.325	reg	
.323
	dc.b	60,66,83,62,0,60,84,65,66,62,0,60,78,76,62
	dc.b	0,60,67,82,62,0,60,69,83,67,62,0
	ds	0
	public	_read
	public	_open
	public	_creat
	public	_write
	public	_ClearMenuStrip
	public	_close
	public	_DisplayBeep
	public	_AbortIO
	public	_ReplyMsg
	public	_putc
	public	_fclose
	public	_getc
	public	_BeginIO
	public	_SetMenuStrip
	public	_CloseLibrary
	public	_CloseWindow
	public	_FreeMem
	public	_exit
	public	_puts
	public	_format
	public	_RemPort
	public	_CloseDevice
	public	_SendIO
	public	_WaitPort
	public	_WaitIO
	public	_Wait
	public	_OpenWindow
	public	_OpenLibrary
	public	_OpenDevice
	public	_GetMsg
	public	_DoIO
	public	_DeleteStdIO
	public	_DeletePort
	public	_DateStamp
	public	_CreateStdIO
	public	_CreatePort
	public	_CheckIO
	public	_AllocMem
	public	_fopen
	public	.begin
	dseg
	cseg
	end
