/************************************************************************
*									*
*		TELINK's memory and defines				*
*									*
*		   T. Jennings 30 June 83				*
*									*
*									*
************************************************************************/

#define cprintf printf	/* for BDS C */

/* Default command states and other configurable things. */

#define	DEFBAUD 0	/* default baudrate: 0= 300baud, 1 =1200 2= 9600. */
#define	DEFDUP 0	/* 0 = full duplex, 1 = half duplex, */
#define	DEFANS 0	/* 0 = originate mode, 1 = answer mode */
#define	DEFPLS 0	/* 0 = Touch Tone, 1 = pulse, */
#define	DEFLF 0		/* 0 = no LF after CR, 1 = LF after every CR typed */
#define DEFFILTER 1	/* 0 = dont filter control characters, 1= do filter */
#define DEFPARITY 0	/* 0 = none, 1 = odd, 2 = even parity */
#define DEFBATCH 1	/* 1 = batch mode, 0 = single file mode */

/* %%%% DANGER %%%% Don't change any #defines after here! %%%% */

/* NOTE: the guard character #define is not used, but is imbedded in the
string output to the Smartmodem. See functions modem_init() and hangup() 
in 'smart12.c'. */

#define	GUARD 31	/* Smartmodem 1200 escape character */

#define NUL 0
#define	NULL 0
#define CNTRLB 2
#define CNTRLC 3
#define CNTRLE 5
#define TAB 9
#define LF 0x0a
#define CR 0x0d
#define CNTRLQ 17
#define CNTRLS 19
#define CNTRLZ 26
#define DEL 127
#define BS 8
#define ESC 0x1b

/* Characters used for file transmission. */

#define EOT 4			/* no more blocks or files */
#define ACK 6			/* good acknowledge */
#define SYN 22			/* start of info block */
#define SOH 1			/* start of data block */
#define NAK 21			/* bad acknowledge */
#define TIMEOUT -1		/* no char received */
#define OKNMCH ACK		/* good filename acknowledge */
#define BDNMCH 'u'		/* bad filename acknowledge */
#define EOFCHAR CNTRLZ		/* end of filename */

/* Fancy numbers for TELINK internal stuff. */

#define CMD 0			/* line where commands appear */
#define CPMSIZ 128 		/* CP/M record size, */
#define TELINK 1		/* file transmission modes, */
#define MODEM7 2
#define XMODEM 3

/* Sort of logical things. */

#define	FALSE 0
#define	TRUE -1
#define	NONE 0
#define	ERROR -1
#define OK 0

/* File buffers */

int filbuf;				/* xmit/rcv file buffer */
int txtbuf;				/* input text file buffer */
int sndbuf;				/* output text file buffer */
int phones;				/* telephone file */
int batfile;				/* setup batch file, == 0 if none */

/* Other things */

char xffcb[36];				/* holds search fcb */
char chrbuf[256];			/* buffer for text collection */
#define chrbufsiz 256			/* how big it is, */
unsigned count;				/* characters in the text buffer, */
unsigned chrcount;			/* total saved */

char parflg;				/* see DEFPARITY */
char stopchar;				/* char used to abort functions */
char cmdchar;				/* The ESCape character, */

unsigned sps;				/* modem input fudge factor, */
char buffer[CPMSIZ];			/* file I/O buffer, */
char linebuf[80];			/* console line input */
char savname[20];			/* text collection filename */
char dirfile[20];			/* telephone directory filename */
char batname[20];			/* batch file name */
char filter;				/* if true, suppress control chars */
char autolf;				/* if true, send LFs after CR's */
char halfdup;				/* half/full duplex if true/false */
char savflg;				/* true is collecting text to a file, */
char debug;				/* flag to enable/disable new features */

/* File transmission flags, etc. */

unsigned filemode;			/* transfer type; XMODEM, MODEM7, TELINK */
char statflg;				/* 1= send file stats, 0= dont */
char batflg;				/* 1= batch mode, 0= single mode, */
unsigned chksum;			/* file transmission checksum */
unsigned sector;			/* sector being sent/recieved */
unsigned newsec;			/* sector # from the other modem */
unsigned secchk;			/* sector check from other modem */
unsigned newsum;			/* checksum from other modem */
unsigned firstchar;			/* first block char during file rcv */
unsigned ackchar;			/* ACK/NAK for current block, */
unsigned blknum;			/* displayed block number */
unsigned errors;			/* # block transmission	errors */
unsigned retrymax;			/* max. blk transmission errors */

char guard;				/* Smartmodem 1200 guard char */
int answer;				/* true if answer mode */
int pulse;				/* true if pulse dialing */
int rate;				/* Current baud rate */

/* our screen stuff. */

int lines;				/* total lines on screen, */
int top;				/* top line number */
int bottom;				/* last line #, */
int cols;				/* total screen columns, */
int cl[25];				/* current line indices */
char screen[25][80];			/* the screen image */
int line,column;			/* where our virtual cursor is */
int top_line_dirty;			/* true if top line contains status */
                                                                  
