home *** CD-ROM | disk | FTP | other *** search
- /*
- ANSIterm.c - ANSI terminal emulator with Intelligent modem
- support and file transfer protocols
-
- You are free to use this program as you see fit, with or
- without the copyright notices.
-
- (C) Copyright 1986, 1987, 1988, 1989, 1991 South Mountain Software, Inc.
-
- */
-
- #include <stdio.h> /* Standard terminal stuff */
- #include <dos.h>
- #include <stdlib.h>
- #include <string.h>
-
- #include "eclproto.h"
- #include "im.h" /* Intelligent modem services */
- #include "xm.h" /* XMODEM services */
- #include "xc.h" /* Communications services */
- #include "i86.h" /* int86 header for bios access */
- /* Keyboard definitions */
-
- #define FK1 0x3B00 /* Function key 1 */
- #define FK2 0x3C00 /* Function key 2 */
- #define FK3 0x3D00 /* Function key 3 */
- #define FK4 0x3E00 /* Function key 4 */
- #define FK5 0x3F00 /* Function key 5 */
- #define FK6 0x4000 /* Function key 6 */
- #define RUB1 0x08 /* Rubout */
- #define RUB2 0x7F /* Rubout */
- #define RET 0x0D /* CR */
-
- #define UP_ARROW 0x4800
- #define DOWN_ARROW 0x5000
- #define RIGHT_ARROW 0x4d00
- #define LEFT_ARROW 0x4b00
- #define BACKSPACE 0x0e08
- #define ESC 0x1b
- #ifndef SAVE_STATROW /* if non-zero, STATUSROW will not be
- overwritten. - this is default */
- #define SAVE_STATROW 23
- #endif
-
- /* Dirty definitions */
-
- #define CLEAN 0 /* <dirty> no cleanup necessary */
- #define CLRSCREEN 1 /* <dirty> clear screen */
- #define CLRSTATUS 2 /* <dirty> clear status part only */
-
- /* Miscellaneous */
-
- #define MIN_BUFFERS 8 /* Minimum buffers required */
- #define SCROLL 1 /* Scroll flag value */
- #define CLEARS 0 /* Clear the screen value */
- #define MAXFIELD 79 /* Maximum field */
- #define STATUSROW 24 /* Row address of status row */
- #define SCRWIDTH 79 /* Last column */
- #define STATCOLUMN 57 /* Starting column of rightmost status */
- #define STATWIDTH 22 /* Width of the rightmost status */
-
- /* Field indices (into the <text> array structure) */
-
- #define INTRO1 0 /* <text> structure entry */
- #define INTRO2 1
- #define INTRO3 2
- #define DATA_FILE 3
- #define ONLINEMSG 4
- #define DATA_DEFAUL 5
- #define MAIN_F1 6
- #define MAIN_F2 7
- #define MAIN_F3 8
- #define MAIN_F4 9
- #define DUMMY 10
- #define NOCONN 11
- #define NULL_STR 12
- #define DIALING 13
- #define INITMODEM 14
- #define HANGUP 15
- #define XUPLOAD 16
- #define XDOWNLOAD 17
- #define XEXIT 18
-
- #define XMODEM 19
- #define SESSION 20
- #define FAILED 21
- #define CANCELLD 22
- #define USERABORT 23
- #define FILEOPEN 24
- #define FILEIO 25
- #define GETUPLOAD 26
- #define GETDOWNLOAD 27
-
- #define COMPORT 28
- #define COMBAUD 37
- #define COMPARITY 47
- #define COMDATA 50
- #define COMSTOP 52
-
- #define COM_HELP 54
- #define COM_ACCEPT 55
- #define COM_ABORT 56
- #define COM_ACP 57
- #define YMODEM 58
- #define XM_CRC 59
- #define XM_1K 60
- #define KERMIT 61
- #define ZMODEM 62
- #define XMODEM_EXIT 63
- #define PRT_ON 64
- #define PRT_OFF 65
- #define NO_CARRIER 66
- #define NO_DIALTONE 67
- #define LINE_BUSY 68
- #define DWNLD_PATH 69
- #define NOMODOPEN 70
- #define CONN 71
-
- #define TABWIDTH 4 /* set a tab every TABWIDTH */
- #define LEFT_BRACKET '[' /* escape char for ANSI */
-
- /* external defined globals */
- extern int km_7bit[];
-
- /* forward function declarations */
- static int is_break(void); /* Test for the presence of a Ctrl-Break abort */
- static int eterm_init(void); /* Load in the default ETERM data configuration file */
- static int main_menu(int dirty_flag);
- static int donline(void); /* donline - display on-line status message */
- static int window_sc(int row,int row_count,int column,char attribute,int flag); /* SCROLL or CLEARS flag */
- static int dfield(int index);
- static int echo(char ch);
- static void sclear(int column);
- static void wclear(void);
- static int config(void);
- static int transfer(void);
- static int getinput(char *buffer);
- static void process_escape_sequence(int mode,char ch);
- static void delete_1_char(void);
- static int insert_1_char(void);
- static int term_curup(void);
- static int term_curdown(void);
- static int term_curfwd(void);
- static int term_clreol(void);
- static int term_clreos(void);
- static int term_curinsrt(void);
- static int term_curdelet(void);
- static int term_scroll(int up_row,int up_col,int low_row,int low_col,int dir);
- static int set_video_mode(void);
- static void memory_to_screen(unsigned words, unsigned offset,char *buffer);
- static void screen_to_memory(unsigned words,unsigned offset,char *buffer);
- static int prthelp(void);
-
- /* Module Globals */
- static int in_underscore_mode = 0; /* flag for ANSI */
- static int in_standout_mode = 0; /* flag for ANSI */
- static int command_in_progress = 0; /* flag to signal end of ESC sequence */
- static int waiting_for_bracket = 0; /* flag when '[' should be next char */
- static int ansi_first_num = 0; /* flag when working on numerics */
- static int num_ptr = 0; /* keeps place in numeric strings */
- static char num1[3], num2[3]; /* string buffers to hold numbers */
- static int int1, int2; /* integers formed from num strings */
- static int lprt_status = 0; /* 0 = no printer, else go to printer */
- static int video_mode = 0; /* current video mode set here */
- static char scrbuf[3*160]; /* buffer to hold 2 lines of screen */
- static int modem_type = IM_STANDARD_TYPE; /* default standard type modem */
- static int hwhs; /* Hardware Handshaking flag */
- static int uart_mode; /* enable/disable 16550 flag */
- static int trigger; /* 16550 receive interrupt trigger value */
-
-
- /*
- === constants ========================================================
- */
-
- static char config_file[]= "ETERM.DAT";
-
- static
- struct {
- int row; /* Row coordinate */
- int col; /* Column coordinate */
- int wid; /* Width */
- char *str; /* Character string */
- } text[] = {
- { 5, 9, 0, "South Mountain Software Terminal Emulator"}, /* INTRO1 */
- { 7, 9, 0, "Copyright (C) 1987, 1988, 1989, 1991 South Mountain Software, Inc."}, /* INTRO2 */
- { 9, 9, 0, "Revision 4.0"},
-
- { STATUSROW, STATCOLUMN, STATWIDTH, "Using ETERM.DAT setup" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "ANSI emulation" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Default setup" },
-
- { STATUSROW, 0, 11, "F1 TRANSFER" },
- { STATUSROW, 12, 8, "F2 Setup" },
- { STATUSROW, 21, 8, "F3 Clear" },
- { STATUSROW, 41, 13, "[Ctl-Brk]Exit" },
- { STATUSROW, STATCOLUMN - 2, 1, "\360" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "No connection" },
- { STATUSROW, 0, SCRWIDTH, "" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Dialing ..." },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Setup modem ..." },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Hanging up ..." },
-
- { STATUSROW, 0 , 11, "[F1] Upload" },
- { STATUSROW, 13, 13, "[F2] Download" },
- { STATUSROW, 27, 17, "[Ctrl-Break] Exit" },
-
- { STATUSROW, STATCOLUMN, STATWIDTH+2, "TRANSFER successful" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Session error" },
- { STATUSROW, STATCOLUMN, STATWIDTH+2, "TRANSFER failed" },
- { STATUSROW, STATCOLUMN, STATWIDTH+2, "TRANSFER cancelled" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "User aborted" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "File open error" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "File I/O error" },
- { STATUSROW, 0, STATCOLUMN - 1, "Upload filename: " },
- { STATUSROW, 0, STATCOLUMN - 1, "Download filename: " },
-
- { STATUSROW, 0, 9, "[F1] COM1" },
- { STATUSROW, 0, 9, "[F1] COM2" },
- { STATUSROW, 0, 9, "[F1] COM3" },
- { STATUSROW, 0, 9, "[F1] COM4" },
- { STATUSROW, 0, 9, "[F1] COM5" },
- { STATUSROW, 0, 9, "[F1] COM6" },
- { STATUSROW, 0, 9, "[F1] COM7" },
- { STATUSROW, 0, 9, "[F1] COM8" },
- { STATUSROW, 0, 9, "[F1] COM9" },
-
- { STATUSROW, 10, 9, "[F2] 57K " },
- { STATUSROW, 10, 9, "[F2] 115K" },
- { STATUSROW, 10, 9, "[F2] 300 " },
- { STATUSROW, 10, 9, "[F2] 600 " },
- { STATUSROW, 10, 9, "[F2] 1200" },
- { STATUSROW, 10, 9, "[F2] 2400" },
- { STATUSROW, 10, 9, "[F2] 4800" },
- { STATUSROW, 10, 9, "[F2] 9600" },
- { STATUSROW, 10, 9, "[F2] 19K " },
- { STATUSROW, 10, 9, "[F2] 38K " },
-
- { STATUSROW, 20, 12, "[F3] NO PAR" },
- { STATUSROW, 20, 12, "[F3] ODD PAR" },
- { STATUSROW, 20, 12, "[F3] EVN PAR" },
-
- { STATUSROW, 33, 11, "[F4] 7 DATA" },
- { STATUSROW, 33, 11, "[F4] 8 DATA" },
-
- { STATUSROW, 45, 11, "[F5] 1 STOP" },
- { STATUSROW, 45, 11, "[F5] 2 STOP" },
-
- { STATUSROW, STATCOLUMN, STATWIDTH, "\021\304\304\331 or Ctrl-Break" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Setup accepted" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Setup cancelled" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Accepted, reload ETERM" },
-
- { STATUSROW, 0, 11, "[F1] YMODEM" },
- { STATUSROW, 12, 15, "[F2] XMODEM/CRC" },
- { STATUSROW, 28, 14, "[F3] XMODEM-1K" },
- { STATUSROW, 43, 11, "[F4] KERMIT"},
- { STATUSROW, 55, 11, "[F5] ZMODEM"},
- { STATUSROW, 67, 13, "[Ctl-Brk]Exit" },
- { STATUSROW, 30,10, "F4 PRT ON "},
- { STATUSROW, 30,10, "F4 PRT OFF"},
-
- { STATUSROW, STATCOLUMN, STATWIDTH, "NO CARRIER" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "NO DIALTONE" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "BUSY - NO CONNECT" },
- { STATUSROW, 0, STATCOLUMN - 1, "Download Pathname: " },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Unable to open modem" },
-
-
- { STATUSROW, STATCOLUMN, STATWIDTH, "Connect 300" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Connect 600 Baud" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Connect 1200 Baud" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Connect 2400 Baud" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Connect 4800 Baud" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Connect 9600 Baud" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Connect 19200 Baud" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Connect 38400 Baud" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Connect 57K Baud" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Connect 115K Baud" },
- { 0, 0, 0, "" }
-
- };
- /*
- ======================================================================
- */
- /*
- === global data base =================================================
-
- ETERM.DAT Configuration data base format:
- */
-
- static int Port = COM1; /* Default communications port */
- static int Baud = BAUD1200; /* Default baud rate */
- static int Parity = NOPAR; /* Default parity */
- static int Data = DATA8; /* Default data bit size */
- static int Stop = STOP1; /* Default stop bit */
- static int attr_status = 0x70; /* Default attribute */
- static int attr_text = 0x07; /* Text window (emulator) attribute */
- static int max_ports; /* Maximum supported ports - rev 2.0 */
-
- static int dirty = CLRSCREEN; /* Clear screen initially */
-
-
-
- static char xmodeminfo[] =
- "Blocks transferred [%d] refused [%d] timeouts [%d] garbled [%d]";
-
- void main(
- int argc, /* Argument count */
- char *argv[]) /* Argument variables */
- {
- int status = 2; /* Index into status messages */
- int key; /* Scan code and ASCII key */
- char charin; /* character read in */
- int ic_delay;
- int err;
- int rc; /* return code */
-
- #ifdef MULTI_TEST
- unsigned address; /* used in setport debugging (F5) */
- int startport, irq;
- int board,
- int p_addr;
- #endif
-
- if (!((argc==4)||(argc==5)||(argc==6)||(argc==2)))
- {
- prthelp();
- return;
- }
- if(argc == 2)
- {
- if((argv[1][1] != 'd' && argv[1][1] != 'D')
- || (argv[1][0] != '/' && argv[1][0] != '-') )
- {
- prthelp();
- return;
- }
- }
-
-
- set_video_mode(); /* get/set video mode */
-
- switch (xc_entr(MIN_BUFFERS)) {
- case 0: /* Enough buffers are available */
- status = 0; /* Assume all is OK */
- max_ports = 9; /* hardcode maxports to COM9 */
- /* do port initialization */
- if(argc > 2 && argc <= 6)
- {
- hwhs = atoi(argv[1]);
- uart_mode = atoi(argv[2]);
- trigger = atoi(argv[3]);
- set_16550(Port,uart_mode,trigger);
- }
- else
- { /* see if /d or -D for default */
- if(argc == 2)
- {
- hwhs = uart_mode = trigger = 0;
- set_16550(Port,uart_mode,trigger);
- }
- }
-
- eterm_init();
- xck_link(); /* Enable Ctrl-Break processing */
-
- /* *** Optionally, dial the modem *** */
-
- if (argc>=5) {
- dfield(INITMODEM);
- modem_type = atoi(argv[4]);
- if (modem_type == IM_STANDARD_TYPE)
- ic_delay = 2;
- else
- ic_delay = 2;
- im_setmodem(Port,modem_type,ic_delay);
- rc = im_fopen(Port);
- if (rc == 0 && argc == 6) {
- im_spkr(Port,IM_SPKR_OFF);
- dfield(DIALING);
- rc = im_dial(Port, argv[5]);
- if (rc >= 0) {
- if (im_modem[Port].modem_type==IM_STANDARD_TYPE) {
- if (rc == IM_CONCT) {
- /* if newly connected Baud rate differs from
- initial, then change Baud rate */
- if (im_modem[Port].im_baud != Baud) {
- Baud = im_modem[Port].im_baud;
- xc_init(Port, Baud, NOPAR, DATA8, STOP1);
- }
- /* display correct connect message */
- dfield((CONN+(Baud)-2));
- }
- else
- dfield(NOCONN);
- }
- else {
- switch (rc) {
- case 3:
- dfield(NO_CARRIER);
- break;
- case 6:
- dfield(NO_DIALTONE);
- break;
- case 7:
- dfield(LINE_BUSY);
- break;
- default:
- /* display correct connect message */
- dfield((CONN+(Baud)-2));
- }
- }
- }
- else
- dfield(NOCONN);
- }
- else
- if(rc != 0)
- dfield(NOMODOPEN);
-
- }
-
- xct_link();
- xct_pend(20);
- wclear();
- xct_unlk();
-
- /* *** Process every key or incoming character *** */
-
- while (status == 0) {
- if (xck_keyt()) {
- if (dirty) {
- donline(); /* Change status message */
- dirty = CLEAN; /* Clear the refresh flag & screen */
- }
- switch (key = xck_getc()) {
- case FK1: /* File Transfer */
- transfer();
- main_menu(CLRSTATUS);
- break;
- case FK2: /* Setup */
- config();
- main_menu(CLRSTATUS);
- break;
- case FK3: /* Refresh */
- main_menu(CLRSTATUS);
- wclear();
- break;
- case FK4:
- lprt_status = (lprt_status) ? 0 : 1 ;
- if(lprt_status)
- dfield(PRT_ON);
- else
- dfield(PRT_OFF);
- break;
-
- /** code for FK5 and FK6 only used in debugging **/
- #ifdef RTS_TEST
- case FK5:
- xc_rts(Port,1);
- break;
- case FK6:
- xc_rts(Port,0);
- break;
- #endif
- #ifdef DTR_TEST
- case FK5:
- xc_dtr(Port,1);
- break;
- case FK6:
- xc_dtr(Port,0);
- break;
- #endif
- #ifdef MULTI_TEST
- case FK5:
- wclear();
- printf("\nenter 0 for MU440 or 1 for digibord or 2 for stargate\n: ");
- printf("enter 3 for stargate secondary, 4 for digimc 5 for setport\n: ");
- printf("enter 6 to quit this option\n");
- scanf("%d",&board);
- if(board != 6)
- {
- printf("enter starting port and irq: ");
- scanf("%d %d",&startport,&irq);
- printf("enter baud rate for port1 (300=2, 1200=4, 9600=7");
- scanf("%d",&Baud);
-
- printf("enter Port (COM1=0, COM2=1, ... COM9=8) : "); /*jhl 8-9-89*/
- scanf("%d",&Port);
- if(board == 1){
- printf("enter status port address in HEX: ");
- scanf("%x",&address);
- setdigi(1,address,irq,startport,0);
- /********** used for testing two digiboards
- if(1){
- printf("enter port address in hex or 0 for default: ");
- scanf("%x",&p_addr);
- if(p_addr) xc_cport(port1,p_addr);
- }
- **********/
- }
- if(board == 0) setast(1,0x2bf,irq,startport,0);
- if(board == 2) setstar(0,0x7f8,irq,startport,0);
- if(board == 3) setstar(1,0x580,irq,startport,0);
- if(board == 4) setdigimc(1,0xdbc0,irq,startport,0);
- if(board == 5)
- {
- printf("enter address in hex: ");
- scanf("%x",&address);
- setport(address,1,irq,startport,0);
- }
-
- xc_link(Port, hwhs);
- xc_init(Port, Baud, NOPAR, DATA8, STOP1);
- xc_dtr(Port,1);
- xc_rts(Port,1);
- wclear();
- }
- break;
- case FK6:
- xc_exit();
- xc_entr(8);
- set_16550(Port,uart_mode,trigger);
- eterm_init();
- xck_link();
- xct_link();
- xct_pend(20);
- wclear();
- xct_unlk();
- break;
- #endif
- #ifdef IM_DIAL_TEST
- case FK5:
- printf("im_baud = %d\n",im_baud);
- break;
- #endif
-
- case UP_ARROW:
- xc_putc(Port,ESC);
- xc_putc(Port,LEFT_BRACKET);
- xc_putc(Port,'A');
- break;
- case DOWN_ARROW:
- xc_putc(Port,ESC);
- xc_putc(Port,LEFT_BRACKET);
- xc_putc(Port,'B');
- break;
- case LEFT_ARROW:
- xc_putc(Port,ESC);
- xc_putc(Port,LEFT_BRACKET);
- xc_putc(Port,'D');
- break;
- case RIGHT_ARROW:
- xc_putc(Port,ESC);
- xc_putc(Port,LEFT_BRACKET);
- xc_putc(Port,'C');
- break;
- case BACKSPACE:
- xc_putc(Port,0x08);
- break;
- default: /* Send key out to the comm port */
- if (is_break())
- status = 1;
- else
- err = xc_putc(Port, (char) key);
- if(err < 0)
- printf("transmit error = %d\n",err);
- }
- }
- if (xc_test(Port)) { /* Display the incoming character */
- charin = (char)(xc_getc(Port));
-
- if (!command_in_progress){
- if (charin != ESC) /* is it ANSI ESC sequence */
- echo(charin);
- else{
- command_in_progress = 1;
- process_escape_sequence(0,'\0'); /* initialize esc codes */
- }
- }else
- process_escape_sequence(1,charin);
- }
- }
-
- /* *** Optionally, hang up the modem *** */
-
- if (argc==6) {
- dfield(HANGUP);
- im_commd(Port);
- im_hangu(Port);
- im_close(Port);
- }
- wclear(); /* Clear the entire thing */
- sclear(SCRWIDTH);
- xc_dtr(Port, 0);
- xc_rts(Port, 0);
- xc_unlk(Port);
- if (uart_mode)
- set_16550(Port,0,0); /* turn 16550 off */
- xc_exit(); /* Turn off interrupts (everything) */
- break;
- case -1:
- printf("XCOMMS is not properly installed\n");
- break;
- case -2:
- printf("Internal error - No XCOMMS\n");
- break;
- default:
- xc_exit(); /* Remove XCOMMS interrupt */
- printf("Not enough buffers are allocated for ETERM\n");
- break;
- }
- exit(0);
- }
-
-
- /*
- === support functions (in order of appearance) ======================
-
- is_break Check for Ctrl-Break
- eterm_init Initialize the screen display, optionally read in
- the ETERM.DAT configuration file
- main_menu Display main menu
- donline Display on-line message
- window_sc Perform a window scroll up or clear for an entire line
- or lines given the attribute
- dfield Display field on the bottom line using the
- attr_status attribute
- echo Echo the character on screen and optionally scroll
- sclear Status line clear up to specified column
- wclear Window text screen clear
- config Process the configuration options and save
- xmodem Transfer files up or down
- getinput A simple in-line response reader function
-
- ======================================================================
- */
- static int is_break(void) /* Test for the presence of a Ctrl-Break abort */
- {
- int status;
-
- status = xck_test();
- if (status) {
- while (xck_keyt())
- xck_getc();
- }
- return(status);
- }
-
-
- /*
- eterm_init - Initialize the screen display, optionally read in
- the ETERM.DAT configuration file
-
- */
-
-
- static int eterm_init(void) /* Load in the default ETERM data configuration file */
- {
- FILE *Stream;
- int setup_message;
- /* Clear both window areas */
- if ((Stream = fopen(config_file, "r")) != NULL) {
- setup_message = DATA_FILE;
- fread(&Port, sizeof(Port), 1, Stream);
- fread(&Baud, sizeof(Baud), 1, Stream);
- fread(&Parity, sizeof(Parity), 1, Stream);
- fread(&Data, sizeof(Data), 1, Stream);
- fread(&Stop, sizeof(Stop), 1, Stream);
- fread(&attr_status, sizeof(attr_status), 1, Stream);
- fread(&attr_text, sizeof(attr_text), 1, Stream);
-
- fclose(Stream);
- } else {
- setup_message = DATA_DEFAUL;
- }
- sclear(SCRWIDTH);
- wclear();
- dfield(setup_message);
-
- xcv_scur(text[INTRO1].row, text[INTRO1].col);
- puts(text[INTRO1].str);
- xcv_scur(text[INTRO2].row, text[INTRO2].col);
- puts(text[INTRO2].str);
- xcv_scur(text[INTRO3].row, text[INTRO3].col);
- puts(text[INTRO3].str);
- xcv_scur(0, 0); /* Home the cursor */
-
- main_menu(CLRSCREEN); /* On-line message with function keys */
-
- xc_link(Port, hwhs);
- xc_dtr(Port, 1); /* *** Rev 1.2 New *** */
- xc_rts(Port, 1); /* *** Rev 1.2 New *** */
- if(Baud < 2)
- Baud += BAUD38400 + 1;
- xc_init(Port, Baud, Parity, Data, Stop);
- return(0); /* Always successful! */
- }
-
- /* Display the main_menu options except for the status field (at the right).
- The dirty flag is passed and determines what to do when a character is
- either received or typed.
- */
- static int main_menu(int dirty_flag)
- {
- sclear(STATCOLUMN - 1);
- dfield(MAIN_F1);
- dfield(MAIN_F2);
- dfield(MAIN_F3);
- dfield(MAIN_F4);
- if(lprt_status)
- dfield(PRT_ON);
- else
- dfield(PRT_OFF);
- dirty = dirty_flag;
- return(0); /* Always successful! */
- }
-
-
- static int donline(void) /* donline - display on-line status message */
- {
- dfield(ONLINEMSG);
- return(0); /* Always successful! */
- }
-
-
- /*
- window_sc - perform a window scroll up or clear for an entire line
- or lines given the attribute
-
- To clear the bottom line, do this:
- window_sc(24, 1, SCRWIDTH, '\007', CLEARS);
- To scroll the upper 24 lines, do this:
- window_sc(0, 24, SCRWIDTH, '\007', SCROLL);
-
- The cursor address does NOT change!
-
- */
- static int window_sc(
- int row, /* Row address starting at 0 */
- int row_count, /* Number of rows to scroll or clear */
- int column, /* Last column number */
- char attribute, /* Attribute for the window */
- int flag) /* SCROLL or CLEARS flag */
- {
- xcv_scrl(row, 0, row + row_count - 1, column, attribute, flag);
- return(0); /* Always succeeds! */
- }
-
- /*
- dfield - display field on the bottom line using the
- attr_status attribute
-
- To display "F2 Download" at column 16 in a 20 column width
- pass a <text> structure array index that points to the
- entry:
-
-
- struct {
- int row;
- int col;
- int wid;
- char *str;
- } text[] = {
- . . .
- { STATUSROW, 0, STATCOLUMN - 1, "Download filename: " },
- . . .
-
- dfield(XDOWNLOAD);
-
- The cursor is not moved
-
- */
- static int dfield(
- int index) /* Index into text array */
- {
- char _string[MAXFIELD]; /* Maximum string field width */
- int i; /* Counter variable */
- int width = text[index].wid; /* Maximum LEGAL field width */
- int column = text[index].col; /* Number of columns */
- char *string = text[index].str;
- int oldrow, oldcol; /* Old cursor address */
-
- if (width > MAXFIELD)
- width = MAXFIELD; /* Specified field is too big */
- /* Create the fixed field */
- for (i = 0; (_string[i] = *string++); ++i)
- ;
- for (; (i < width); ++i)
- _string[i] = ' ';
- xcv_gcur(&oldrow, &oldcol); /* Save the cursor location */
-
- /* Write out the field */
- for (i = 0; (i < width); ++i) {
- xcv_scur(STATUSROW, column + i);
- xcv_chat(_string[i], attr_status);
- }
- xcv_scur(oldrow, oldcol); /* Restore the cursor */
- return(0); /* Always succeeds! */
- }
-
- static int echo( /* Display a character and optionally scroll up one line */
- char ch)
- {
-
- int oldrow, oldcol;
-
- if (lprt_status) /* send to printer if toggled on */
- fputc(ch,stdprn);
-
- if(ch != 0x09) /* horizontal tab */
- {
- if( (ch == 13) || (ch == 7) || (ch == 8) )
- xcv_wtty(ch);
- else if(ch == 10)
- {
- xcv_gcur(&oldrow,&oldcol);
- if(oldrow < SAVE_STATROW)
- xcv_wtty(ch);
- else
- {
- term_scroll(0,0,SAVE_STATROW,79,0);
- xcv_scur(SAVE_STATROW,0);
-
- }
- }
- else if(!in_standout_mode) /* not in reverse video mode? */
- {
- xcv_chat(ch,7);
- term_curfwd();
- }
- else
- {
- xcv_chat(ch,0x70);
- term_curfwd();
- }
- }
- else{
- xcv_gcur(&oldrow, &oldcol);
- if(oldcol < TABWIDTH) /* if not past first tab */
- xcv_scur(oldrow,TABWIDTH-1);
- term_curfwd();
- xcv_gcur(&oldrow, &oldcol);
- while(oldcol % TABWIDTH){
- term_curfwd();
- xcv_gcur(&oldrow, &oldcol);
- if(oldcol < TABWIDTH) /* handle case where wraps to new line */
- xcv_scur(oldrow,TABWIDTH);
- }
- }
- return(0); /* Always succeeds! */
- }
-
- static void sclear( /* Clear status line */
- int column) /* Last column */
- {
- window_sc(STATUSROW, 1, column, (char)attr_text, CLEARS);
-
- }
-
- static void wclear(void) /* Clear window text area */
- {
- xcv_scur(0, 0); /* Home cursor */
- window_sc(0, STATUSROW, SCRWIDTH, (char)attr_text, CLEARS);
- }
-
- static int config(void) /* Configure the comm port attributes onto disk file */
- {
- int message = 0;
- int ch;
- FILE *Stream;
- int old_port = Port; /* Save the old port */
- int port_exists;
-
-
- sclear(STATCOLUMN - 1);
- dfield(COM_HELP);
-
- while (message == 0) {
- dfield(COMPORT + Port);
- dfield(COMBAUD + Baud);
- dfield(COMPARITY + Parity);
- dfield(COMDATA + Data);
- dfield(COMSTOP + Stop);
- switch (ch = xck_getc()) {
- case FK1:
- if (++Port == max_ports)
- Port = 0;
- break;
- case FK2:
- if (++Baud > BAUD38400)
- Baud = 0;
- break;
- case FK3:
- if (++Parity > 2)
- Parity = 0;
- break;
- case FK4:
- if (++Data > 1)
- Data = 0;
- break;
- case FK5:
- if (++Stop > 1)
- Stop = 0;
- break;
- default:
- if (is_break())
- message = COM_ABORT;
- if ((ch & 0xFF) == RET) {
- if(Port < 2)
- {
- port_exists = xc_tport(Port);
- if(port_exists != 0)
- {
- wclear();
- printf("\n\aPort %d does not exist\n",Port);
- printf("Reset parameters for valid port\n");
- break;
- }
- }
- Stream = fopen(config_file, "w");
- fwrite(&Port, sizeof(Port), 1, Stream);
- fwrite(&Baud, sizeof(Baud), 1, Stream);
- fwrite(&Parity, sizeof(Parity), 1, Stream);
- fwrite(&Data, sizeof(Data), 1, Stream);
- fwrite(&Stop, sizeof(Stop), 1, Stream);
- fwrite(&attr_status, sizeof(attr_status), 1, Stream);
- fwrite(&attr_text, sizeof(attr_text), 1, Stream);
- fclose(Stream);
- if (old_port == Port) {
- if(Baud < 2)
- Baud += BAUD38400 + 1;
- xc_init(Port, Baud, Parity, Data, Stop);
- message = COM_ACCEPT;
- } else {
- message = COM_ACCEPT;
- xc_link(Port, hwhs);
- xc_dtr(Port, 1);
- xc_rts(Port, 1);
- if(Baud < 2)
- Baud += BAUD38400 + 1;
- xc_init(Port, Baud, Parity, Data, Stop);
- }
- }
- break;
- } /* End of character switch */
- } /* End of while loop */
- dfield(message);
- return(0);
- }
-
- static int transfer(void) /* Perform file protocol upload or download */
- {
- int exitflag = 2;
- int row, column;
- char answer[33];
- int transfer;
- int ret_value;
- int oldcol,oldrow;
- /* Ask the user to either upload or download */
-
- sclear(STATCOLUMN - 1);
- dfield(XUPLOAD);
- dfield(XDOWNLOAD);
- dfield(XEXIT);
- while (exitflag == 2) {
- switch (xck_getc()) {
- case FK1: /* Upload */
- exitflag = 0;
- break;
- case FK2: /* Download */
- exitflag = 1;
- break;
- default: /* Exit abnormally */
- if (is_break())
- exitflag = -1;
- }
- }
- if (exitflag == -1)
- dfield(USERABORT);
- else {
- /* *********** REV 2.0 ask the type of XMODEM transfer ********* */
- sclear(SCRWIDTH);
- dfield(YMODEM);
- dfield(XM_CRC);
- dfield(XM_1K);
- dfield(KERMIT);
- dfield(ZMODEM);
- dfield(XMODEM_EXIT);
- switch (xck_getc()) {
- case FK1: /* YMODEM */
- sclear(SCRWIDTH);
- if (exitflag == 0)
- dfield(GETUPLOAD);
- else
- dfield(DWNLD_PATH);
- xcv_gcur(&row, &column);
- xcv_scur(STATUSROW, 20);
- if (getinput(answer) < 0)
- {
- dfield(USERABORT);
- exitflag = -1;
- break;
- }
- transfer = 0;
- break;
- case FK2: /* XMODEM/CRC option*/
- sclear(SCRWIDTH);
- if (exitflag == 0)
- dfield(GETUPLOAD);
- else
- dfield(GETDOWNLOAD);
- xcv_gcur(&row, &column);
- xcv_scur(STATUSROW, 20);
- if (getinput(answer) <= 0)
- {
- dfield(USERABORT);
- exitflag = -1;
- break;
- }
- transfer = 1;
- break;
- case FK3: /* XMODEM 1K option*/
- sclear(SCRWIDTH);
- if (exitflag == 0)
- dfield(GETUPLOAD);
- else
- dfield(GETDOWNLOAD);
- xcv_gcur(&row, &column);
- xcv_scur(STATUSROW, 20);
- if (getinput(answer) <= 0)
- {
- dfield(USERABORT);
- exitflag = -1;
- break;
- }
- transfer = 2;
- break;
- case FK4: /* KERMIT */
- sclear(SCRWIDTH);
- if (exitflag == 0)
- dfield(GETUPLOAD);
- else
- dfield(DWNLD_PATH);
- xcv_gcur(&row, &column);
- xcv_scur(STATUSROW, 20);
- if (getinput(answer) < 0)
- {
- dfield(USERABORT);
- exitflag = -1;
- break;
- }
- transfer = 3;
- break;
- case FK5: /* ZMODEM */
- sclear(SCRWIDTH);
- if (exitflag == 0)
- dfield(GETUPLOAD);
- else
- dfield(DWNLD_PATH);
- xcv_gcur(&row, &column);
- xcv_scur(STATUSROW, 20);
- if (getinput(answer) < 0)
- {
- dfield(USERABORT);
- exitflag = -1;
- break;
- }
- transfer = 4;
- break;
- default: /* Exit abnormally */
- if (is_break()) {
- exitflag = -1;
- dfield(USERABORT);
- }
- }
- /* ************************************************************* */
-
- if (exitflag >= 0) {
- dfield(NULL_STR);
-
- if (exitflag == 0) { /* Execute upload/download */
- switch (transfer) {
- case 0:
- screen_to_memory(2*80,160 * 22,scrbuf);
- window_sc(22,23,SCRWIDTH,7,CLEARS);
- xcv_gcur(&oldcol,&oldrow);
- xcv_scur(22,0);
- ret_value = ym_putf(Port, answer, 1, 1);
- memory_to_screen(2*80,160 * 22,scrbuf);
- ret_value = (ret_value == 0) ? 0 : -2;
- xcv_scur(oldcol,oldrow);
- dfield(XMODEM - ret_value);
- break;
- case 1:
- dfield(XMODEM + (-xmk_putf(Port, answer, xmodeminfo, 1, XMODEM_128, XMODEM_CRC)));
- break;
- case 2:
- dfield(XMODEM + (-xmk_putf(Port, answer, xmodeminfo, 1, XMODEM_1K, XMODEM_CRC)));
- break;
- case 3:
- screen_to_memory(3*80,160 * 21,scrbuf);
- window_sc(21,23,SCRWIDTH,7,CLEARS);
- xcv_gcur(&oldcol,&oldrow);
- xcv_scur(21,0);
- if (Data==DATA7)
- km_7bit[Port] = 1;
- ret_value = km_putf(Port, answer, 1, 1);
- memory_to_screen(3*80,160 * 21,scrbuf);
- dfield(XMODEM - ret_value);
- xcv_scur(oldcol,oldrow);
- break;
- case 4:
- screen_to_memory(3*80,160 * 21,scrbuf);
- window_sc(21,23,SCRWIDTH,7,CLEARS);
- xcv_gcur(&oldcol,&oldrow);
- xcv_scur(21,0);
- ret_value = zm_putf(Port, answer, 1, 1);
- memory_to_screen(3*80,160 * 21,scrbuf);
- dfield(XMODEM - ret_value);
- xcv_scur(oldcol,oldrow);
- break;
- }
- } else {
- switch (transfer) {
- case 0:
- screen_to_memory(2*80,160 * 22,scrbuf);
- window_sc(22,23,SCRWIDTH,7,CLEARS);
- xcv_gcur(&oldcol,&oldrow);
- xcv_scur(22,0);
- ret_value = ym_getf(Port,answer, 1, 1);
- memory_to_screen(2*80,160 * 22,scrbuf);
- ret_value = (ret_value == 0) ? 0 : -2;
- dfield(XMODEM - ret_value);
- xcv_scur(oldcol,oldrow);
- break;
- case 1:
- dfield(XMODEM + (-xmk_getf(Port, answer, xmodeminfo, 1, XMODEM_128, XMODEM_CRC)));
- break;
- case 2:
- dfield(XMODEM + (-xmk_getf(Port, answer, xmodeminfo, 1, XMODEM_1K, XMODEM_CRC)));
- break;
- case 3:
- screen_to_memory(3*80,160 * 21,scrbuf);
- window_sc(21,23,SCRWIDTH,7,CLEARS);
- xcv_gcur(&oldcol,&oldrow);
- xcv_scur(21,0);
- if (Data==DATA7)
- km_7bit[Port] = 1;
- ret_value = km_getf(Port, answer, 1, 1);
- memory_to_screen(3*80,160 * 21,scrbuf);
- dfield(XMODEM - ret_value);
- xcv_scur(oldcol,oldrow);
- break;
- case 4:
- screen_to_memory(3*80,160 * 21,scrbuf);
- window_sc(21,23,SCRWIDTH,7,CLEARS);
- xcv_gcur(&oldcol,&oldrow);
- xcv_scur(21,0);
- ret_value = zm_getf(Port, answer, 1, 1);
- memory_to_screen(3*80,160 * 21,scrbuf);
- dfield(XMODEM - ret_value);
- xcv_scur(oldcol,oldrow);
- break;
- }
- }
- }
- }
- xcv_scur(row, column);
- return(exitflag);
- }
-
-
- /*
- getinput - Given the character string buffer address, accept the
- user input string and return the number of characters entered. Accept
- input at the current cursor location.
- Returns:
-
- 0 Only Enter key pressed
- >0 The character string of n characters returned
- -1 Ctrl-Break pressed
- */
- static int getinput(
- char *buffer)
- {
- int i = 0;
- int exitflag = 0;
- char ch;
- int row, column;
-
- while (exitflag == 0) {
- if (is_break()) {
- i = -1;
- break;
- }
- switch ((ch = (char)xck_getc()) & 0xFF) {
- case RET:
- buffer[i] = '\000';
- exitflag = 1; /* Exit file entry */
- break;
- case RUB1:
- case RUB2:
- if (i) {
- --i;
- xcv_gcur(&row, &column);
- xcv_scur(row, column - 1);
- xcv_wtty(' ');
- xcv_scur(row, column - 1);
- }
- break;
- default:
- buffer[i++] = ch;
- xcv_wtty(ch);
- }
- }
- return(i); /* Return size of answer */
- }
-
- /* process ANSI control sequences */
-
-
- static void process_escape_sequence(
- int mode, /* 0 = initialize strings, 1 = in_progress */
- char ch) /* current character being processed */
- {
-
-
- if(mode == 0)
- {
- int1 = int2 = 0;
- num1[0] = num1[1] = num1[2] = '\0'; /* force string to nulls */
- num2[0] = num2[1] = num2[2] = '\0'; /* force string to nulls */
- waiting_for_bracket = 1;
- return;
- }
-
- if(waiting_for_bracket) /* '[' should follow ESC or not a valid
- ESC sequence. Note 'G' sequences are
- an exception to this but not processed
- here. */
- {
- if(ch == LEFT_BRACKET)
- {
- waiting_for_bracket = 0;
- ansi_first_num = 0;
- num_ptr = 0;
- return;
- }
- else
- { /* not a valid sequence */
- waiting_for_bracket = 0;
- command_in_progress = 0;
- return;
- }
- }
-
-
- switch (ch)
- {
- case 'L': /* insert lines */
- term_curinsrt();
- command_in_progress = 0; break;
- case 'K': /* clear to end of line */
- term_clreol();
- command_in_progress = 0; break;
- case 'H': /* home cursor or position cursor */
-
-
- if(num1[0] == '\0' && num2[0] == '\0')
- {
- xcv_scur(0,0);
- command_in_progress = 0; break;
- }
- else
- {
- int1 = atoi(num1);
- int2 = atoi(num2);
- xcv_scur(int1-1,int2-1);
- command_in_progress = 0; break;
- }
- case 'P': /* delete character */
- delete_1_char();
- command_in_progress = 0; break;
- case 'M': /* delete line */
- term_curdelet();
- command_in_progress = 0; break;
- case 'B': /* cursor down one line */
- term_curdown();
- command_in_progress = 0; break;
- case 'Z': /* back tab */
- command_in_progress = 0; break; /* **** NA **** */
- case 'm': /* begin/end underscore(standout) mode */
- in_underscore_mode = (in_underscore_mode) ? 0 : 1;
- in_standout_mode = (in_standout_mode) ? 0 : 1;
- command_in_progress = 0; break;
-
- /* there is some confusion because of 2 'J' codes in termcap. */
- /* the other one is for clear to end of display */
-
- case 'J': /* clear screen, home cursor */
- if(num1[0] == '2'){
- term_scroll(0,0,SAVE_STATROW,79,2);
- xcv_scur(0,0);
- }else{
- term_clreos();
- }
- command_in_progress = 0; break;
- case 'C': /* cursor right */
- term_curfwd(); /* will advance cursor to new line */
- command_in_progress = 0; break;
- case 'A': /* cursor up */
- term_curup();
- command_in_progress = 0; break;
- case '@': /* insert character */
- insert_1_char();
- command_in_progress = 0; break;
- case 'S': /* scroll forward */
- term_scroll(0,0,SAVE_STATROW,79,0);
- command_in_progress = 0; break;
- case 'T': /* scroll backward */
- term_scroll(0,0,SAVE_STATROW,79,1);
- command_in_progress = 0; break;
-
- case '0': case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9':
-
- if(ansi_first_num == 0)
- {
- num1[num_ptr++] = ch;
- if(num_ptr > 2) /* invalid number */
- {
- command_in_progress = 0;
- return;
- }
- }
- else
- {
- num2[num_ptr++] = ch;
- if(num_ptr > 2) /* invalid number */
- {
- command_in_progress = 0;
- return;
- }
- }
- break;
- case ';': /* number separator */
- num_ptr = 0;
- ansi_first_num = 1;
- break;
-
- default:
- waiting_for_bracket = 0;
- command_in_progress = 0;
- return;
- }
- }
-
-
- static void delete_1_char(void) /* delet a character on the screen */
- {
- char buf[162];
- int row, col;
- int i;
-
- xcv_gcur(&row,&col);
- screen_to_memory(80,row*160,buf);
- buf[161] = buf[159];
- buf[160] = ' ';
- for(i=col*2;i<160;i++)
- {
- buf[i] = buf[i+2];
- }
- memory_to_screen(80,row*160,buf);
- return;
- }
-
- static int insert_1_char(void)
- {
- char buf[160];
- int row, col;
- int i,j;
-
- xcv_gcur(&row,&col);
- screen_to_memory(80,row*160,buf);
- j = (col * 2) + 2;
- for(i=159;i>=j;i--)
- {
- buf[i] = buf[i-2];
- }
- buf[(col*2)] = ' ';
- memory_to_screen(80,row*160,buf);
- return(0);
- }
-
-
-
- /* function to move cursor up one line */
- static int term_curup(void)
- {
- int row,col; /* current cursor position retrieved */
-
- xcv_gcur(&row,&col); /* get current cursor position */
- if (row == 0) /* cannot go up beyond first row */
- return(-1);
- else
- xcv_scur(row-1,col);
- return(0);
- }
-
-
- /* function to move cursor down one row */
- static int term_curdown(void)
- {
- int row,col; /* current cursor position retrieved */
-
- xcv_gcur(&row,&col); /* get current cursor position */
- if (row == SAVE_STATROW) /* cannot go down past last row */
- return(-1);
- else
- xcv_scur(row+1,col);
- return(0);
- }
-
-
- /* advance cursor one position. if past eol, go to next row, col 1 */
- static int term_curfwd(void)
- {
- int row,col; /* current cursor position retrieved */
-
- xcv_gcur(&row,&col); /* get current cursor position */
- if (col >= 79){ /* is cursor in last column position */
- if ( row >= SAVE_STATROW ) /* cannot advance past last row */
- {
- term_scroll(0,0,SAVE_STATROW,79,0);
- xcv_scur(SAVE_STATROW,0);
-
- }
- else
- xcv_scur(row+1,0); /* advance to next row */
- }else
- xcv_scur(row,col+1);
- return(0);
- }
-
-
- /* clear from cursor to end of line */
- static int term_clreol(void)
- {
- int row,col; /* current cursor position retrieved */
- int i,j; /* local work variables */
-
- xcv_gcur(&row,&col); /* get current cursor position */
- i = 80 - col; /* number of columns to clear */
- for(j=0;j<i;j++)
- {
- xcv_chat(' ',7); /* use write character and attribute function */
- if(j < (i-1)) /* don't want to advance past eol */
- term_curfwd();
- }
- xcv_scur(row,col);
- return(0);
- }
-
-
-
- /* clear from cursor to end of screen */
- static int term_clreos(void)
- {
- int row,col; /* current cursor position retrieved */
-
- term_clreol(); /* clear first line to eol */
- xcv_gcur(&row,&col); /* get cursor position */
- if(row == SAVE_STATROW)
- return(0);
- else
- term_scroll(row+1,0,SAVE_STATROW,79,2); /* scroll to clear */
- xcv_scur(row,col);
- return(0);
- }
-
-
- /* insert one line from cursor */
- static int term_curinsrt(void)
- {
- int row,col; /* current cursor position retrieved with xcv_gcur */
- xcv_gcur(&row,&col);
- term_scroll(row,0,SAVE_STATROW,79,1);
- return(0);
- }
-
-
-
- /* delete 1 row starting at row passed*/
- static int term_curdelet(void)
- {
- int row,col; /* current cursor position retrieved with xcv_gcur */
- xcv_gcur(&row,&col);
- term_scroll(row,0,SAVE_STATROW,79,0);
- return(0);
- }
-
- /* do BIOS call to scroll down or up */
-
- static int term_scroll( /* function to scroll a window on the screen */
- int up_row, /* the row of the upper left hand corner of the window */
- int up_col, /* the column of the upper left hand corner */
- int low_row, /* the row of the lower right hand corner of the window */
- int low_col, /* the column of the lower right hand corner */
- int dir) /* the direction to scroll; 0 for up, 1 for down, 2 to clear */
-
- {
- union i86_reg regs;
- if (dir == 0)
- {
- regs.breg.AH=6;
- regs.breg.AL= 1;
- }
- else if (dir == 1)
- {
- regs.breg.AH=7;
- regs.breg.AL= 1;
- }
- else if (dir == 2)
- {
- regs.breg.AH=6;
- regs.breg.AL= 0;
- }
- regs.breg.BH = 7;
- regs.breg.CH = (char)up_row;
- regs.breg.CL = (char)up_col;
- regs.breg.DH = (char)low_row;
- regs.breg.DL = (char)low_col;
- i86_int(0x10,®s);
- return(0);
- }
-
- static int set_video_mode(void) /* gets and/or sets video mode to 80 column */
- {
- union i86_reg regs;
- regs.breg.AH=0x0f;
- i86_int(0x10,®s);
- if(regs.breg.AL == 7) /* mono adapter */
- {
- video_mode = 7;
- }
- else /* color adapter */
- {
- regs.breg.AH = 0; /* set video mode function */
- regs.breg.AL = 3; /* 80 col color mode */
- i86_int(0x10,®s);
- video_mode = 3;
- }
- return(0);
- }
-
- /* memory_to_screen() and screen_to_memory() move data from/to video ram */
-
- static void memory_to_screen(
- unsigned words,
- unsigned offset,
- char *buffer)
- {
- void far *address; /* used to point to video ram */
- unsigned segment; /* video ram segment */
- unsigned bufseg,bufoff; /* buffer segment and offset */
-
- if(video_mode == 7)
- segment = 0xb000; /* mono */
- else
- segment = 0xb800; /* color */
-
- address = (void far *)buffer;
- bufseg = FP_SEG(address);
- bufoff = FP_OFF(address);
- movedata(bufseg,bufoff,segment,offset,words*2);
- }
-
-
- static void screen_to_memory(
- unsigned words,
- unsigned offset,
- char *buffer)
- {
- void far *address; /* used to point to video ram */
- unsigned segment; /* video ram segment */
- unsigned bufseg,bufoff; /* buffer segment and offset */
-
- if(video_mode == 7)
- segment = 0xb000; /* mono */
- else
- segment = 0xb800; /* color */
-
- address = (void far *)buffer;
- bufseg = FP_SEG(address);
- bufoff = FP_OFF(address);
- movedata(segment,offset,bufseg,bufoff,words*2);
- }
-
- static int prthelp(void)
- {
- printf("\nFORMAT : \nansiterm [hwhs] [mode] [trig] OR ansiterm [hwhs] [mode] [trig] [mt] [num]");
- printf("\n OR ansiterm /d (for defaults)");
- printf("\nWHERE:\n hwhs: Hardware Handshaking");
- printf("\n 0 = Hardware Handshaking is disabled (default)");
- printf("\n 1 = Both CTS (Clear to Send) and DSR (Data Set Ready)");
- printf("\n are used for Hardware Handshaking");
- printf("\n 2 = Only CTS is used for Hardware Handshaking");
- printf("\n 3 = Only DSR is used for Hardware Handshaking");
- printf("\n mode: Serial Port UART Chip mode (use 0 if you do not have a 16550)");
- printf("\n 0 = NS16550A Character mode, FIFOs Disabled (default)");
- printf("\n 1 = NS16550A FIFOs Enabled ");
- printf("\n trig: NS16550A FIFO Receive buffer trigger level (use 0 if no 16550)");
- printf("\n 0 = Generate interrupt after 1 character received (default)");
- printf("\n 1 = Generate interrupt after 4 characters received");
- printf("\n 2 = Generate interrupt after 8 characters received");
- printf("\n 3 = Generate interrupt after 14 characters received");
- printf("\n mt: modem type");
- printf("\n 0 = Hayes Ultra; 1 = USR Courier; 2 = Microcom QX or UDS Fastalk;");
- printf("\n 3 = Telebit; 4 = MultiTech; 5 = GVC SM96;");
- printf("\n 6 = Ventel; 7 = Digicom Systems; 8 = Generic type;");
- printf("\n 9 = Standard type (default);");
- printf("\n num: Telephone number for modem to dial (default is NO number to dial)");
- return(0);
- }