home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-04-04 | 56.4 KB | 2,295 lines |
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 1 (of 3)."
- # Contents: 8250dtr.h 8250nsc.h 8250xon.h MANIFEST README _kb.h
- # ctrl_brk.c ctrl_brk.h delay.c delay.h dependnt.h drop_dtr.c
- # makefile.msc makefile.tcc makefile.ztc mdm_init.c monitor.c
- # monitor.h msc.asm options.h printer.c printer.h queue.c queue.h
- # screen.h timer.c timer.h tkb.c version.h vt100.h
- # Wrapped by jb@deneb on Sat Mar 24 10:42:16 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f '8250dtr.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'8250dtr.h'\"
- else
- echo shar: Extracting \"'8250dtr.h'\" \(928 characters\)
- sed "s/^X//" >'8250dtr.h' <<'END_OF_FILE'
- X/*
- X * 8250DTR.H
- X *
- X * Include file for Function Prototyping of 8250DTR.C Module
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X */
- X
- extern int dtr8250_get_status (void),
- X dtr8250_modem_status (void),
- X dtr8250_read (void),
- X dtr8250_timed_read (int),
- X dtr8250_write (char);
- extern void dtr8250_dtnr (void),
- X dtr8250_init (int, int),
- X dtr8250_lines (void),
- X dtr8250_port_enable (void),
- X dtr8250_port_init (char *),
- X dtr8250_term (int),
- X dtr8250_write_break (void);
- END_OF_FILE
- if test 928 -ne `wc -c <'8250dtr.h'`; then
- echo shar: \"'8250dtr.h'\" unpacked with wrong size!
- fi
- # end of '8250dtr.h'
- fi
- if test -f '8250nsc.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'8250nsc.h'\"
- else
- echo shar: Extracting \"'8250nsc.h'\" \(4099 characters\)
- sed "s/^X//" >'8250nsc.h' <<'END_OF_FILE'
- X/*
- X * 8250NSC.H
- X *
- X * National SemiConducter 8250
- X *
- X * Serial Chip Routine Defines & Globals
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X */
- X
- X/*
- X * Intel 8259a interrupt controller addresses and constants
- X */
- X
- X# define INT_cntrl 0x20
- X# define INT_mask 0x21
- X# define INT_port_enable 0xEF
- X# define EOI_word 0x20
- X
- X
- X/*
- X * Constants used to enable and disable interrupts from the
- X * 8250 - they are stored in PORT_command
- X */
- X
- X# define RX_enable 0x0D /* Enable Rcv & RLS Interrupt */
- X# define TX_enable 0x0E /* Enable Xmit & RLS Interrupt */
- X# define RX_TX_enable 0x0F /* Enable Rcv, Xmit & RLS Interrupt */
- X# define ERROR_reset 0xF1
- X# define LCR_DLAB 0x80
- X
- X
- X/*
- X * 8250 register offsets - should be added to value in PORT_address
- X */
- X
- X# define IER 1 /* interrupt enable offset */
- X# define IIR 2 /* interupt identification register */
- X# define LCR 3 /* line control register */
- X# define MCR 4 /* modem control register */
- X# define LSR 5 /* line status register */
- X# define MSR 6 /* modem status register */
- X
- X
- X/*
- X * The following constants are primarily for documentaiton purposes
- X * to show what the values sent to the 8250 Control Registers do to
- X * the chip.
- X *
- X *
- X * INTERRUPT ENABLE REGISTER
- X */
- X
- X# define IER_Received_Data 1
- X# define IER_Xmt_Hld_Reg_Empty (1<<1)
- X# define IER_Recv_Line_Status (1<<2)
- X# define IER_Modem_Status (1<<3)
- X# define IER_Not_Used 0xF0
- X
- X
- X/*
- X * INTERRUPT IDENTIFICATION REGISTER
- X */
- X
- X# define IIR_receive 4
- X# define IIR_transmit 2
- X# define IIR_mstatus 0
- X# define IIR_rls 6
- X# define IIR_complete 1
- X# define IIR_Not_Used 0xF8
- X
- X
- X/*
- X * LINE CONTROL REGISTER
- X */
- X
- X# define LCR_Word_Length_Mask 3
- X# define LCR_Stop_Bits (1<<2)
- X# define LCR_Parity_Enable (1<<3)
- X# define LCR_Even_Parity (1<<4)
- X# define LCR_Stick_Parity (1<<5)
- X# define LCR_Set_Break (1<<6)
- X# define LCR_Divisor_Latch_Access (1<<7) /* Divisor Latch - must be set to 1
- X * to get to the divisor latches of
- X * the baud rate generator - must
- X * be set to 0 to access the
- X * Receiver Buffer Register and
- X * the Transmit Holding Register
- X */
- X
- X
- X/*
- X * MODEM CONTROL REGISTER
- X */
- X
- X# define MCR_dtr 1
- X# define MCR_rts (1<<1)
- X# define MCR_Out_1 (1<<2)
- X# define MCR_Out_2 (1<<3) /* MUST BE ASSERTED TO ENABLE INTERRRUPTS */
- X# define MCR_Loop_Back (1<<4)
- X# define MCR_Not_Used (7<<1)
- X
- X
- X/*
- X * LINE STATUS REGISTER
- X */
- X
- X# define LSR_Data_Ready 1
- X# define LSR_Overrun_Error (1<<1)
- X# define LSR_Parity_Error (1<<2)
- X# define LSR_Framing_Error (1<<3)
- X# define LSR_Break_Interrupt (1<<4)
- X# define LSR_THR_Empty (1<<5) /* Transmitter Holding Register */
- X# define LSR_TSR_Empty (1<<6) /* Transmitter Shift Register */
- X# define LSR_Not_Used (1<<7)
- X
- X
- X/*
- X * MODEM STATUS REGISTER
- X */
- X
- X# define MSR_Delta_CTS 1
- X# define MSR_Delta_DSR (1<<1)
- X# define MSR_TERD (1<<2) /* Trailing Edge Ring Detect */
- X# define MSR_Delta_RLSD (1<<3) /* Received Line Signal Detect */
- X# define MSR_CTS (1<<4) /* Clear to Send */
- X# define MSR_DSR (1<<5) /* Data Set Ready */
- X# define MSR_RD (1<<6) /* Ring Detect */
- X# define MSR_RLSD (1<<7) /* Received Line Signal Detect */
- END_OF_FILE
- if test 4099 -ne `wc -c <'8250nsc.h'`; then
- echo shar: \"'8250nsc.h'\" unpacked with wrong size!
- fi
- # end of '8250nsc.h'
- fi
- if test -f '8250xon.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'8250xon.h'\"
- else
- echo shar: Extracting \"'8250xon.h'\" \(976 characters\)
- sed "s/^X//" >'8250xon.h' <<'END_OF_FILE'
- X/*
- X * 8250XON.H
- X *
- X * Include file for Function Prototyping of 8250XON.C Module
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X */
- X
- X
- extern int ioctl_set_xoff (char *),
- X xon8250_get_status (void),
- X xon8250_init (int, int),
- X xon8250_port_init (char *),
- X xon8250_read (void),
- X xon8250_timed_read (int),
- X xon8250_write (char),
- X xon8250_write_buffer_empty (void),
- X xon8250_xoff_sent (void);
- extern void xon8250_dtnr (void),
- X xon8250_port_enable (void),
- X xon8250_term (int),
- X xon8250_write_break (void);
- END_OF_FILE
- if test 976 -ne `wc -c <'8250xon.h'`; then
- echo shar: \"'8250xon.h'\" unpacked with wrong size!
- fi
- # end of '8250xon.h'
- fi
- if test -f 'MANIFEST' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'MANIFEST'\"
- else
- echo shar: Extracting \"'MANIFEST'\" \(1230 characters\)
- sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
- X File Name Archive # Description
- X-----------------------------------------------------------
- X 8250dtr.c 2
- X 8250dtr.h 1
- X 8250nsc.h 1
- X 8250xon.c 2
- X 8250xon.h 1
- X MANIFEST 1 This shipping list
- X README 1
- X _kb.c 2
- X _kb.h 1
- X ctrl_brk.c 1
- X ctrl_brk.h 1
- X delay.c 1
- X delay.h 1
- X dependnt.h 1
- X drop_dtr.c 1
- X makefile.msc 1
- X makefile.tcc 1
- X makefile.ztc 1
- X mdm_init.c 1
- X monitor.c 1
- X monitor.h 1
- X msc.asm 1
- X options.c 2
- X options.h 1
- X printer.c 1
- X printer.h 1
- X queue.c 1
- X queue.h 1
- X screen.c 2
- X screen.h 1
- X timer.c 1
- X timer.h 1
- X tkb.c 1
- X version.h 1
- X vt100.c 3
- X vt100.h 1
- END_OF_FILE
- if test 1230 -ne `wc -c <'MANIFEST'`; then
- echo shar: \"'MANIFEST'\" unpacked with wrong size!
- fi
- # end of 'MANIFEST'
- fi
- if test -f 'README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'README'\"
- else
- echo shar: Extracting \"'README'\" \(1605 characters\)
- sed "s/^X//" >'README' <<'END_OF_FILE'
- X 8250
- X Serial Chip
- X Support Routines
- X
- The files in this archive are a collection of tools I have used to
- muck about with serial i/o on the PC. The code compiles under
- TurboC V1.5 (and also 2.0 I think), as well as Microsoft C V5.x,
- DataLight C, and Zortech C. The various makefiles are included to
- make life easy.
- X
- This code is copyrighted by myself and you may use it in any way
- you see fit as long as you don't charge money for it and as long
- as the copyright notices remain in the sources.
- X
- There are several programs which can be made:
- X
- X 1. MDM_INIT - a little program to both tweek the serial port
- X and initialize a modem. as an example if you had a Hayes
- X on COM1: and you wanted to set it up at 2400 baud
- X autoanswer you could enter:
- X
- X mdm_init -b2400 -pn -d8 "S0=3"
- X
- X 2. MONITOR - looks at the data on a serial line and
- X displays the data on the screen (or if you redirect
- X stdout, it will place it in a file). Use the command
- X
- X monitor ?
- X
- X to get a succinct description of the command line
- X arguments.
- X
- X 3. VT100 - a real simple vt100 terminal emulator - all it
- X does is more or less emulate a vt100 (no alternate
- X character sets and it's missing some (most?) of the DEC
- X private stuff). <Alt>F10 exits the program, <Alt>F9 spawns
- X DOS (use the dos exit command to get back to the program),
- X and <Alt>F8 sends a break. Use the command
- X
- X vt100 ?
- X
- X to get a succinct description of the command line
- X arguments.
- X
- X --- jb ---
- X Oct 11, 1989
- END_OF_FILE
- if test 1605 -ne `wc -c <'README'`; then
- echo shar: \"'README'\" unpacked with wrong size!
- fi
- # end of 'README'
- fi
- if test -f '_kb.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'_kb.h'\"
- else
- echo shar: Extracting \"'_kb.h'\" \(3200 characters\)
- sed "s/^X//" >'_kb.h' <<'END_OF_FILE'
- X/*
- X * _KB.H
- X *
- X * Keyboard i/o Handler
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X */
- X
- X/* control key translations */
- X
- X# define CTLX 0x4000
- X# define META 0x8000
- X# define up_char 240
- X# define down_char 241
- X# define right_char 242
- X# define left_char 243
- X
- X
- X# define home_char META | 69 /* ESC O E */
- X# define ctl_home_char META | 70 /* ESC O F */
- X# define pageup_char META | 71 /* ESC O G */
- X# define ctl_pu_char META | 72 /* ESC O H */
- X# define ctl_rt_char META | 73 /* ESC O I */
- X# define pagedown_char META | 74 /* ESC O J */
- X# define ctl_pd_char META | 75 /* ESC O K */
- X# define end_char META | 76 /* ESC O L */
- X# define ctl_end_char META | 77 /* ESC O M */
- X# define ctl_lft_char META | 78 /* ESC O N */
- X
- X# define Ins_char 206
- X# define Del_char 207
- X# define NextWord_char 208
- X# define PrevWord_char 209
- X
- X# define M1 210
- X# define M2 211
- X# define M3 212
- X# define M4 213
- X# define M5 214
- X# define M6 215
- X# define M7 216
- X# define M8 217
- X# define M9 218
- X# define M10 219
- X# define M11 220
- X# define M12 221
- X# define M13 222
- X# define M14 223
- X# define M15 224
- X# define M16 225
- X# define M17 226
- X# define M18 227
- X# define M19 228
- X# define M20 229
- X# define M21 230
- X# define M22 231
- X# define M23 232
- X# define M24 233
- X# define M25 234
- X# define M26 235
- X# define M27 236
- X# define M28 237
- X# define M29 238
- X# define M30 239
- X# define M31 240
- X# define M32 241
- X# define M33 242
- X# define M34 243
- X# define M35 244
- X# define M36 245
- X# define M37 246
- X# define M38 247
- X# define M39 248
- X# define M40 249
- X
- X
- X#define NUL 0
- X#define ENQ 5
- X#define BEL 7
- X#define BS 8
- X#define HT 9
- X#define LF 10
- X#define VT 11
- X#define FF 12
- X#define CR 13
- X#define SO 14
- X#define SI 15
- X#define XON 17
- X#define XOFF 19
- X#define CAN 24
- X#define SUB 26
- X#define ESC 27
- X#define DEL 127
- X#define DC2 18
- X#define DC4 20
- X#define TAB 9
- X#define DEL1 207
- X
- X
- X/*
- X Keyboard input characters after scan code translation
- X*/
- X
- X#define PF1 210
- X#define PF2 211
- X#define PF3 212
- X#define PF4 213
- X#define PF5 214
- X#define PF6 215
- X#define PF7 216
- X#define PF8 217
- X#define PF9 218
- X#define PF10 219
- X
- X#define SPF1 230
- X#define SPF2 231
- X#define SPF3 232
- X#define SPF4 233
- X#define SPF5 234
- X#define SPF6 235
- X#define SPF7 236
- X#define SPF8 237
- X#define SPF9 238
- X#define SPF10 239
- X#define APF1 220
- X#define APF2 221
- X#define APF3 222
- X#define APF4 223
- X#define APF5 224
- X#define APF6 225
- X#define APF7 226
- X#define APF8 227
- X#define APF9 228
- X#define APF10 229
- X
- X#define HCHAR 200
- X#define UPCHAR 240
- X#define DNCHAR 241
- X#define RTCHAR 242
- X#define LFCHAR 243
- X#define INSCHAR 206
- X#define DELCHAR 207
- X#define BOLCHAR 200
- X#define EOLCHAR 201
- X#define PGUCHAR 202
- X#define PGDCHAR 203
- X#define NWCHAR 208
- X#define PWCHAR 209
- X
- extern int _kb (void);
- END_OF_FILE
- if test 3200 -ne `wc -c <'_kb.h'`; then
- echo shar: \"'_kb.h'\" unpacked with wrong size!
- fi
- # end of '_kb.h'
- fi
- if test -f 'ctrl_brk.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ctrl_brk.c'\"
- else
- echo shar: Extracting \"'ctrl_brk.c'\" \(1104 characters\)
- sed "s/^X//" >'ctrl_brk.c' <<'END_OF_FILE'
- X/*
- X * CTRL_BRK.C
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X */
- X
- X#include "dependnt.h"
- X
- X#if (defined (DLC))
- int
- brk_handler ()
- X{
- X return (1);
- X}
- X#else
- int cb_happened = 0;
- void (interrupt far * brk_save_vec) (void);
- void interrupt far
- brk_handler (void)
- X{
- X cb_happened = 1;
- X}
- X#endif
- X
- static int ctrl_brk_blocked = 0;
- void
- trap_ctrl_break (void)
- X{
- X if (ctrl_brk_blocked)
- X return;
- X ctrl_brk_blocked = 1;
- X#if (defined (DLC))
- X int_intercept (0x23, &brk_handler, 128);
- X#else
- X brk_save_vec = getvect (0x23);
- X setvect (0x23, brk_handler);
- X#endif
- X}
- X
- void
- release_ctrl_break (void)
- X{
- X if (!ctrl_brk_blocked)
- X return;
- X ctrl_brk_blocked = 0;
- X#if (defined (DLC))
- X int_restore (0x23);
- X#else
- X setvect (0x23, brk_save_vec);
- X#endif
- X}
- X
- END_OF_FILE
- if test 1104 -ne `wc -c <'ctrl_brk.c'`; then
- echo shar: \"'ctrl_brk.c'\" unpacked with wrong size!
- fi
- # end of 'ctrl_brk.c'
- fi
- if test -f 'ctrl_brk.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'ctrl_brk.h'\"
- else
- echo shar: Extracting \"'ctrl_brk.h'\" \(497 characters\)
- sed "s/^X//" >'ctrl_brk.h' <<'END_OF_FILE'
- X/*
- X * CTRL_BRK.H
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X */
- X
- extern void trap_ctrl_break (void),
- X release_ctrl_break (void);
- END_OF_FILE
- if test 497 -ne `wc -c <'ctrl_brk.h'`; then
- echo shar: \"'ctrl_brk.h'\" unpacked with wrong size!
- fi
- # end of 'ctrl_brk.h'
- fi
- if test -f 'delay.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'delay.c'\"
- else
- echo shar: Extracting \"'delay.c'\" \(1745 characters\)
- sed "s/^X//" >'delay.c' <<'END_OF_FILE'
- X/*
- X * DELAY.C
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X *
- X * This module implements a more or less machine independent delay
- X * loop - the general idea is we kinda tie the delay loop to the
- X * Timer Interrupt to get a general idea of how big the loop counter
- X * has to be to count off a millisecond. Crude eh?
- X */
- X
- X/*
- X * We'll take the stand-alone testing stuff out entirely
- X * one of these days.
- X */
- X
- unsigned long int timer_read ();
- X
- X#if (defined (TEST))
- X# include <stdio.h>
- X# include <time.h>
- main ()
- X{
- X long starttime, stoptime;
- X DELAY_init ();
- X printf ("\n\nBegin %d millisecond delay\n\n", 30000);
- X time (&starttime);
- X DELAY_loop (30000);
- X time (&stoptime);
- X printf ("End - Elapsed time = %ld\n", stoptime - starttime);
- X timer_term ();
- X}
- X
- X#endif
- X
- X
- static unsigned int DELAY_millisecond;
- void
- DELAY_init (void)
- X{
- X static d_init = 0;
- X long l;
- X if (d_init)
- X return;
- X d_init = 0;
- X timer_init ();
- X timer_set ();
- X while (timer_read () == 0L);
- X timer_set ();
- X for (l = 0L; l != -1L; l++)
- X if (timer_read () == 3)
- X break;
- X l *= 197;
- X DELAY_millisecond = (int) ((l + 5000) / 10000);
- X}
- static unsigned int _DELAY_cnt, _DELAY_ix;
- X
- int
- DELAY_loop (int msc)
- X{
- X for (_DELAY_ix = 0; _DELAY_ix < msc; _DELAY_ix++)
- X for (_DELAY_cnt = 0; _DELAY_cnt < DELAY_millisecond; _DELAY_cnt++);
- X return (msc);
- X}
- END_OF_FILE
- if test 1745 -ne `wc -c <'delay.c'`; then
- echo shar: \"'delay.c'\" unpacked with wrong size!
- fi
- # end of 'delay.c'
- fi
- if test -f 'delay.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'delay.h'\"
- else
- echo shar: Extracting \"'delay.h'\" \(464 characters\)
- sed "s/^X//" >'delay.h' <<'END_OF_FILE'
- X/*
- X * DELAY.H
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X */
- void DELAY_init (void);
- int DELAY_loop (int);
- X
- END_OF_FILE
- if test 464 -ne `wc -c <'delay.h'`; then
- echo shar: \"'delay.h'\" unpacked with wrong size!
- fi
- # end of 'delay.h'
- fi
- if test -f 'dependnt.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'dependnt.h'\"
- else
- echo shar: Extracting \"'dependnt.h'\" \(1626 characters\)
- sed "s/^X//" >'dependnt.h' <<'END_OF_FILE'
- X/*
- X * DEPENDNT.H
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X *
- X * This stuff is used so that the same source will compile
- X * and run under either Zortech C , Turbo C, or Microsoft C.
- X * We are attempting to localize differences in interrupt handling
- X * as well as memory and i/o port handling diffferences here.
- X */
- X
- X#if (!defined (DEPENDENTSTUFF))
- X# define DEPENDENTSTUFF
- X# if (defined (DLC))
- X# define inbyte(address) inp(address)
- X# define outbyte(address, value) outp(address, value)
- X# define enable int_on
- X# define disable int_off
- X# define peekmem(seg,offset,var) peek(seg,offset,&var,2)
- X# define setraw(fp) fp->_flag &= ~_IOTRAN
- X# define setcooked(fp) fp->_flag |= _IOTRAN
- X# else
- X# include <dos.h>
- X# if (!defined (__TURBOC__))
- X# define getvect(i) _dos_getvect(i)
- X# define setvect(i,v) _dos_setvect(i,v)
- X# define setraw(fp)
- X# define setcooked(fp)
- X# define peekmem(seg,offset,var) peekmem(seg,offset,&var)
- X# else
- X# define setraw(fp) fp->flags |= _F_BIN
- X# define setcooked(fp) fp->flag &= ~_F_BIN
- X# define inbyte(address) inportb(address)
- X# define outbyte(address, value) outportb(address, value)
- X# define peekmem(seg,offset, var) var=peek(seg,offset)
- X# endif
- X# endif
- X#endif
- END_OF_FILE
- if test 1626 -ne `wc -c <'dependnt.h'`; then
- echo shar: \"'dependnt.h'\" unpacked with wrong size!
- fi
- # end of 'dependnt.h'
- fi
- if test -f 'drop_dtr.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'drop_dtr.c'\"
- else
- echo shar: Extracting \"'drop_dtr.c'\" \(1051 characters\)
- sed "s/^X//" >'drop_dtr.c' <<'END_OF_FILE'
- X/*
- X * DROP_DTR.C
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X */
- X#include <stdlib.h>
- X#include "dependnt.h"
- X#include "timer.h"
- void dtnr (int);
- X
- main (int argc, char *argv [])
- X{
- X if (argc > 1)
- X dtnr (atoi (argv [1]));
- X else
- X dtnr (1);
- X}
- X
- X
- X
- X
- X/*----------------------------- dtnr () -----------------------------*/
- X/*
- X *
- X */
- X# define MCR 4 /* modem control register */
- unsigned PORT_addr;
- char MCR_save = 0;
- void
- dtnr (int channel)
- X{
- X int Dos_address;
- X unsigned i;
- X Dos_address = (channel - 1) * 2;
- X DELAY_init ();
- X peekmem (0x40, Dos_address, PORT_addr);
- X MCR_save = inbyte (PORT_addr+MCR);
- X outbyte (PORT_addr+MCR, 0);
- X DELAY_loop (1000);
- X outbyte (PORT_addr+MCR, MCR_save);
- X}
- X
- END_OF_FILE
- if test 1051 -ne `wc -c <'drop_dtr.c'`; then
- echo shar: \"'drop_dtr.c'\" unpacked with wrong size!
- fi
- # end of 'drop_dtr.c'
- fi
- if test -f 'makefile.msc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'makefile.msc'\"
- else
- echo shar: Extracting \"'makefile.msc'\" \(1492 characters\)
- sed "s/^X//" >'makefile.msc' <<'END_OF_FILE'
- X#
- X# Makefile for various Serial Port Handler Programs
- X#
- X# 8250xxx.*
- X#
- X# Written for
- X# The MicroSoft C Compiler
- X#
- X# CopyRight 1989
- X#
- X# John Birchfield
- X#
- X#
- X# MONITOR - a simple line monitor program
- X#
- X# MDM_INIT - a modem initialization program
- X#
- X# VT100 - self explanitory
- X#
- X
- CFLAGS = -AS -J -Gs
- X
- IOBJS = mdm_init.obj 8250xon.obj timer.obj queue.obj \
- X ctrl_brk.obj msc.obj
- X
- MOBJS = monitor.obj options.obj 8250xon.obj queue.obj \
- X ctrl_brk.obj _kb.obj msc.obj timer.obj
- X
- VOBJS = vt100.obj queue.obj screen.obj 8250xon.obj \
- X ctrl_brk.obj _kb.obj timer.obj options.obj msc.obj
- X
- X.c.obj :
- X cl -c $(CFLAGS) $<
- X
- all : drop_dtr laser mdm_init monitor vt100
- X
- drop_dtr : drop_dtr.exe
- X
- mdm_init : mdm_init.exe
- X
- monitor : monitor.exe
- X
- vt100 : vt100.exe
- X
- drop_dtr.exe : drop_dtr.obj timer.obj msc.obj
- X cl $(CFLAGS) drop_dtr.obj timer.obj msc.obj
- X
- mdm_init.exe : $(IOBJS)
- X cl $(CFLAGS) $(IOBJS)
- X
- monitor.exe : $(MOBJS)
- X cl $(CFLAGS) $(MOBJS)
- X
- vt100.exe : $(VOBJS)
- X cl $(VOBJS) -link /ST:8192
- X
- msc.obj : msc.asm
- X masm -ml msc.asm;
- X
- vt100.obj : vt100.c
- X cl $(CFLAGS) -DSTANDALONE -c vt100.c
- X
- X$(MOBJS) :
- X
- X$(VOBJS) :
- X
- clean :
- X del *.obj
- X del *.map
- X
- archive :
- X chmod -r comm_io.arc
- X pkarc -u comm_io *.c *.h *.asm *.rsp *.cmd makefile.*
- X chmod -a *.c *.h *.rsp makefile.*
- END_OF_FILE
- if test 1492 -ne `wc -c <'makefile.msc'`; then
- echo shar: \"'makefile.msc'\" unpacked with wrong size!
- fi
- # end of 'makefile.msc'
- fi
- if test -f 'makefile.tcc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'makefile.tcc'\"
- else
- echo shar: Extracting \"'makefile.tcc'\" \(1654 characters\)
- sed "s/^X//" >'makefile.tcc' <<'END_OF_FILE'
- X#
- X# Makefile for various Serial Port Handler Programs
- X#
- X# 8250xxx.*
- X#
- X# Written for
- X# The Turbo C Compiler
- X#
- X# CopyRight 1988
- X#
- X# John Birchfield
- X#
- X#
- X# MONITOR - a simple line monitor program
- X#
- X# MDM_INIT - a modem initialization program
- X#
- X# VT100 - self explanitory
- X#
- X
- CFLAGS = -mt -K -DSTANDALONE
- BINDIR = /bin
- X
- IOBJS = mdm_init.obj 8250xon.obj timer.obj \
- X queue.obj ctrl_brk.obj
- X
- MOBJS = monitor.obj options.obj 8250xon.obj queue.obj \
- X ctrl_brk.obj _kb.obj timer.obj
- X
- VOBJS = vt100.obj queue.obj screen.obj 8250xon.obj \
- X ctrl_brk.obj _kb.obj timer.obj options.obj
- X
- X
- X.c.obj :
- X tcc -c $(CFLAGS) $<
- X
- all : drop_dtr laser mdm_init monitor vt100
- X
- drop_dtr : drop_dtr.com
- X
- mdm_init : mdm_init.com
- X
- monitor : monitor.com
- X
- vt100 : vt100.com
- X
- drop_dtr.com : drop_dtr.obj timer.obj
- X tcc $(CFLAGS) -f- drop_dtr.obj timer.obj
- X $(BINDIR)/exe2bin drop_dtr.exe drop_dtr.com
- X del drop_dtr.exe
- X
- mdm_init.com : $(IOBJS)
- X tcc $(CFLAGS) -f- $(IOBJS)
- X $(BINDIR)/exe2bin mdm_init.exe mdm_init.com
- X del mdm_init.exe
- X
- monitor.com : $(MOBJS)
- X tcc $(CFLAGS) -f- $(MOBJS)
- X $(BINDIR)/exe2bin monitor.exe monitor.com
- X del monitor.exe
- X
- vt100.com : $(VOBJS)
- X tcc $(CFLAGS) -f- $(VOBJS)
- X $(BINDIR)/exe2bin vt100.exe vt100.com
- X del vt100.exe
- X
- X$(MOBJS) :
- X
- X$(VOBJS) :
- X
- clean :
- X del *.obj
- X del *.map
- X
- archive :
- X $(BINDIR)/chmod -r comm_io.arc
- X $(BINDIR)/pkarc -u comm_io *.c *.h *.asm *.rsp *.cmd makefile.*
- X $(BINDIR)/chmod -a *.c *.h *.rsp makefile.*
- END_OF_FILE
- if test 1654 -ne `wc -c <'makefile.tcc'`; then
- echo shar: \"'makefile.tcc'\" unpacked with wrong size!
- fi
- # end of 'makefile.tcc'
- fi
- if test -f 'makefile.ztc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'makefile.ztc'\"
- else
- echo shar: Extracting \"'makefile.ztc'\" \(1763 characters\)
- sed "s/^X//" >'makefile.ztc' <<'END_OF_FILE'
- X#
- X# Makefile for various Serial Port Handler Programs
- X#
- X# 8250xxx.*
- X#
- X# Written for
- X#
- X# The Zortech C Compiler
- X#
- X# Copyright 1989
- X#
- X# John Birchfield
- X#
- X#
- X# MONITOR - a simple line monitor program
- X#
- X# MDM_INIT - a modem initialization program
- X#
- X# VT100 - self explanitory
- X#
- X# Invoke with -dDLC if using the Zortech v2.0 compiler
- X#
- X# Invoke with CFLAGS=-dLINT <modulename> to invoke Formal Parameter
- X# checking a la ANSI C...
- X# or if you want both an exact invokation to compile the Monitor
- X# module would be:
- X#
- X# make "CFLAGS=-dLINT -dDLC -o" monitor
- X
- X#CFLAGS = -mti -J -S -DLINT -DDLC -DSTANDALONE
- CFLAGS = -g -J -S -DLINT -DDLC -DSTANDALONE
- X
- IOBJS = mdm_init.obj 8250xon.obj timer.obj queue.obj \
- X ctrl_brk.obj
- X
- MOBJS = monitor.obj options.obj 8250xon.obj queue.obj \
- X timer.obj ctrl_brk.obj _kb.obj
- X
- VOBJS = vt100.obj queue.obj screen.obj 8250xon.obj \
- X ctrl_brk.obj _kb.obj timer.obj options.obj
- X
- X.c.obj :
- X ztc -c $(CFLAGS) $<
- X
- X
- X
- all : drop_dtr mdm_init laser monitor vt100
- X
- drop_dtr : drop_dtr.com
- X
- mdm_init : mdm_init.com
- X
- monitor : monitor.com
- X
- vt100 : vt100.com
- X
- drop_dtr.com : drop_dtr.obj timer.obj
- X ztc $(CFLAGS) drop_dtr.obj timer.obj
- X
- mdm_init.com : $(IOBJS)
- X ztc $(CFLAGS) $(IOBJS)
- X
- monitor.com : $(MOBJS)
- X ztc -mti -omonitor $(MOBJS)
- X
- vt100.com : $(VOBJS)
- X ztc $(CFLAGS) $(VOBJS)
- X
- X$(MOBJS) :
- X
- X$(VOBJS) :
- X
- vt100.obj : vt100.c
- X ztc $(CFLAGS) -dSTANDALONE -c vt100.c
- X
- clean :
- X rm *.obj *.map
- X
- archive :
- X chmod -r comm_io.arc
- X pkarc -u comm_io *.c *.h *.rsp *.cmd *.asm makefile.*
- X chmod -a *.c *.h *.rsp makefile.*
- END_OF_FILE
- if test 1763 -ne `wc -c <'makefile.ztc'`; then
- echo shar: \"'makefile.ztc'\" unpacked with wrong size!
- fi
- # end of 'makefile.ztc'
- fi
- if test -f 'mdm_init.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'mdm_init.c'\"
- else
- echo shar: Extracting \"'mdm_init.c'\" \(4503 characters\)
- sed "s/^X//" >'mdm_init.c' <<'END_OF_FILE'
- X/*
- X * MDM_INIT.C
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X */
- X
- X#include <stdio.h>
- X#include <ctype.h>
- X#include "8250xon.h"
- X#include "ctrl_brk.h"
- X#include "timer.h"
- X
- X#if (!defined (TRUE))
- X# define TRUE (1)
- X# define FALSE (0)
- X#endif
- X
- X#define ETX 3
- X#define EOT 4
- void usage (void);
- X
- main (int argc, char **argv)
- X{
- X char m_cmd[80];
- X int port = 1, baud = 0, data = 0, stop = 0, parity = 0,
- X p_init = FALSE;
- X while (argc > 1)
- X {
- X if (*argv [1] == '?')
- X usage ();
- X if (argv [1] [0] != '-')
- X {
- X break;
- X }
- X argc--; argv++;
- X switch (toupper (argv[0][1]))
- X {
- X case 'B':
- X baud = atoi (&argv[0][2]);
- X break;
- X case 'C':
- X port = atoi (&argv[0][2]);
- X break;
- X case 'P':
- X parity = argv[0][2];
- X break;
- X case 'S':
- X stop = atoi (&argv[0][2]);
- X break;
- X case 'D':
- X data = atoi (&argv[0][2]);
- X break;
- X default:
- X fprintf (stderr, "Invalid option %s\n", *argv);
- X usage ();
- X break;
- X }
- X }
- X
- X
- X if (baud || data || parity || stop)
- X {
- X baud = (baud) ? baud : 1200;
- X data = (data) ? data : 8;
- X parity = (parity) ? toupper (parity) : (int) 'N';
- X stop = (stop) ? stop : 1;
- X sprintf (m_cmd, "%d %c %d %d", baud, parity, stop, data);
- X p_init = TRUE;
- X }
- X trap_ctrl_break ();
- X timer_init ();
- X xon8250_init (port, 256);
- X if (p_init)
- X xon8250_port_init (m_cmd);
- X else
- X xon8250_port_enable ();
- X modem_write ("#+++");
- X timeout (1);
- X while (argc-- > 1)
- X {
- X modem_write ("AT");
- X modem_write (*++argv);
- X modem_write ("\r");
- X }
- X while (!xon8250_write_buffer_empty ())
- X ;
- X timeout (1);
- X xon8250_term (0);
- X timer_term ();
- X release_ctrl_break ();
- X exit (0);
- X}
- X
- X
- X
- X
- int
- modem_write (char *s)
- X{
- X char ch, *cp;
- X for (cp = s; *cp; cp++)
- X {
- X switch (*cp)
- X {
- X case '~':
- X timeout (1);
- X continue;
- X case '#':
- X xon8250_dtnr ();
- X continue;
- X case '^':
- X ch = *++cp;
- X ch = toupper (ch) - '@';
- X while (xon8250_write (ch) == -1)
- X ;
- X break;
- X case '\\':
- X switch (ch = *++cp)
- X {
- X case 'e':
- X ch = 0x1b;
- X break;
- X case 'r':
- X ch = '\r';
- X break;
- X case 'n':
- X ch = '\n';
- X break;
- X case 'b':
- X ch = '\b';
- X break;
- X case 'a':
- X ch = '\a';
- X break;
- X case 'f':
- X ch = '\f';
- X break;
- X default:
- X break;
- X }
- X while (xon8250_write (ch) == -1)
- X ;
- X break;
- X default:
- X while (xon8250_write (*cp) == -1)
- X ;
- X break;
- X }
- X }
- X}
- X
- void
- usage (void)
- X{
- X fputs ("MDM_INIT:\n", stderr);
- X fputs ("Use the following command line options.\n\n", stderr);
- X fputs (" -C[1 or 2] Com Port 1 or 2 {Default Com Port 1}\n", stderr);
- X fputs (" -B[300 600 1200 2400 4800 9600] {Default 9600 Baud}\n", stderr);
- X fputs (" -D[7 or 8] Data Bits {Default 8}\n", stderr);
- X fputs (" -S[1 or 2] Stop Bits {Default 1}\n", stderr);
- X fputs (" -P[E O or N] Parity {Default None}\n\n", stderr);
- X fputs (" -b2400 -pn -s1 -d8 -c1\n\n", stderr);
- X fputs ("If any port options are set then the port will be left\n", stderr);
- X fputs ("in that state when the program exits, otherwise we just\n", stderr);
- X fputs (" enable the port and blast the strings we are passed to it\n\n", stderr);
- X exit (1);
- X}
- X
- END_OF_FILE
- if test 4503 -ne `wc -c <'mdm_init.c'`; then
- echo shar: \"'mdm_init.c'\" unpacked with wrong size!
- fi
- # end of 'mdm_init.c'
- fi
- if test -f 'monitor.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'monitor.c'\"
- else
- echo shar: Extracting \"'monitor.c'\" \(2509 characters\)
- sed "s/^X//" >'monitor.c' <<'END_OF_FILE'
- X/*
- X * MONITOR.C
- X *
- X * A simple-Minded little Serial Port Monitor
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X */
- X
- X#include <stdio.h>
- X#include "8250xon.h"
- X#include "monitor.h"
- X#include "options.h"
- X#include "_kb.h"
- X
- X#define EOT 4
- X#define ETX 3
- X#define TRUE (1)
- X#define FALSE (0)
- X#if (!defined (DLC))
- extern int cb_happened;
- X#endif
- X
- main (argc, argv)
- int argc;
- char **argv;
- X{
- X int ch;
- X int i;
- X
- X set_options (argc, argv);
- X trap_ctrl_break ();
- X timer_init ();
- X xon8250_init (Port, 8192);
- X fputs (" -- Monitor - RS232 Port Snooper --\n", stdout);
- X if (Cfg_Str [0])
- X {
- X xon8250_port_init (Cfg_Str);
- X fputs (Opt_Msg, stdout);
- X }
- X else
- X {
- X xon8250_port_enable ();
- X fputs ("Using Default Port Settings\n", stdout);
- X }
- X fputs ("Use <Alt>F10 to exit\n", stdout);
- X
- X while (TRUE)
- X {
- X if ((ch = xon8250_read ()) != -1)
- X {
- X xlate ((char) ch);
- X }
- X if ((ch = _kb ()) != -1)
- X {
- X if (ch == APF10)
- X {
- X xon8250_term ((Cfg_Str [0])?1:0);
- X timer_term ();
- X release_ctrl_break ();
- X exit (0);
- X }
- X xon8250_write (ch);
- X }
- X }
- X}
- X
- X
- X
- int
- xlate (char c)
- X{
- X static int lcnt = 0;
- X static char *x_table[] = {
- X "<NUL>", "<SOH>", "<STX>", "<ETX>", "<EOT>", "<ENQ>",
- X "<ACK>", "<BEL>", "<BS>", "<HT>", "<LF>", "<VT>",
- X "<FF>", "<CR>", "<SO>", "<SI>", "<DLE>", "<DC1>",
- X "<DC2>", "<DC3>", "<DC4>", "<NAK>", "<SYN>", "<ETB>",
- X "<CAN>", "<EM>", "<SUB>", "<ESC>", "<FS>", "<GS>",
- X "<RS>", "<US>"
- X };
- X
- X if (c < 32)
- X {
- X if (c == EOT)
- X {
- X putchar ('\n');
- X lcnt = 0;
- X }
- X myputs (x_table[c]);
- X lcnt += strlen (x_table[c]);
- X }
- X else
- X {
- X putchar (c);
- X lcnt += 1;
- X }
- X if (lcnt > 79)
- X {
- X putchar ('\n');
- X lcnt = 0;
- X }
- X fflush (stdout);
- X}
- X
- int
- myputs (s)
- char *s;
- X{
- X while (*s)
- X putchar (*s++);
- X}
- END_OF_FILE
- if test 2509 -ne `wc -c <'monitor.c'`; then
- echo shar: \"'monitor.c'\" unpacked with wrong size!
- fi
- # end of 'monitor.c'
- fi
- if test -f 'monitor.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'monitor.h'\"
- else
- echo shar: Extracting \"'monitor.h'\" \(570 characters\)
- sed "s/^X//" >'monitor.h' <<'END_OF_FILE'
- X/*
- X * MONITOR.H
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X */
- X# ifdef LINT
- extern int xlate (char);
- extern int myputs (char *);
- extern int good_baud (char *);
- extern int usage (void);
- extern int exit (...);
- X# endif
- END_OF_FILE
- if test 570 -ne `wc -c <'monitor.h'`; then
- echo shar: \"'monitor.h'\" unpacked with wrong size!
- fi
- # end of 'monitor.h'
- fi
- if test -f 'msc.asm' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'msc.asm'\"
- else
- echo shar: Extracting \"'msc.asm'\" \(1140 characters\)
- sed "s/^X//" >'msc.asm' <<'END_OF_FILE'
- X_TEXT SEGMENT WORD PUBLIC 'CODE'
- X_TEXT ENDS
- X_DATA SEGMENT WORD PUBLIC 'DATA'
- X_DATA ENDS
- CONST SEGMENT WORD PUBLIC 'CONST'
- CONST ENDS
- X_BSS SEGMENT WORD PUBLIC 'BSS'
- X_BSS ENDS
- DGROUP GROUP CONST, _BSS, _DATA
- X ASSUME CS: _TEXT, DS: DGROUP, SS: DGROUP
- X_TEXT SEGMENT
- X ASSUME CS: _TEXT
- X
- X PUBLIC _peekmem
- X_peekmem PROC NEAR
- X push bp
- X mov bp,sp
- X push es
- X push bx
- X push si
- X mov bx,WORD PTR [bp+4] ;seg
- X mov es, bx
- X mov bx, WORD PTR [bp+6] ;off
- X mov si, bx
- X mov bx,WORD PTR [bp+8] ;var
- X mov ax,WORD PTR es:[si]
- X mov WORD PTR [bx],ax
- X pop si
- X pop bx
- X pop es
- X pop bp
- X ret
- X_peekmem ENDP
- X
- X
- X
- X
- X PUBLIC _inbyte
- X_inbyte PROC NEAR
- X push bp
- X mov bp,sp
- X push dx
- X mov dx, [bp+4]
- X in al, dx
- X mov ah, 0
- X pop dx
- X pop bp
- X ret
- X_inbyte ENDP
- X
- X
- X PUBLIC _outbyte
- X_outbyte PROC NEAR
- X push bp
- X mov bp,sp
- X push dx
- X mov dx, [bp+4]
- X mov ax, [bp+6]
- X out dx, al
- X pop dx
- X pop bp
- X ret
- X_outbyte ENDP
- X
- X
- X PUBLIC __kbhit
- X__kbhit PROC near
- X mov ah, 1
- X int 16h
- X jz kbnothit
- X mov ax, 1
- X ret
- kbnothit:
- X mov ax, 0
- X ret
- X__kbhit ENDP
- X
- X
- X PUBLIC _enable
- X_enable PROC NEAR
- X sti
- X ret
- X_enable ENDP
- X
- X
- X
- X
- X PUBLIC _disable
- X_disable PROC NEAR
- X cli
- X ret
- X_disable ENDP
- X_TEXT ENDS
- XEND
- END_OF_FILE
- if test 1140 -ne `wc -c <'msc.asm'`; then
- echo shar: \"'msc.asm'\" unpacked with wrong size!
- fi
- # end of 'msc.asm'
- fi
- if test -f 'options.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'options.h'\"
- else
- echo shar: Extracting \"'options.h'\" \(515 characters\)
- sed "s/^X//" >'options.h' <<'END_OF_FILE'
- X/*
- X * OPTIONS.H
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X */
- X
- X extern char Cfg_Str [], Opt_Msg [];
- X extern int Port;
- X extern void set_options (int, char **);
- END_OF_FILE
- if test 515 -ne `wc -c <'options.h'`; then
- echo shar: \"'options.h'\" unpacked with wrong size!
- fi
- # end of 'options.h'
- fi
- if test -f 'printer.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'printer.c'\"
- else
- echo shar: Extracting \"'printer.c'\" \(917 characters\)
- sed "s/^X//" >'printer.c' <<'END_OF_FILE'
- X/*
- X * PRINTER.C
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X *
- X * Output a character to the printer port using software interrupt
- X * 0x17. Returns -1 if unsuccessful, 0 otherwise.
- X *
- X * Usage while (print_char (ch));
- X */
- X#include <dos.h>
- X#include "printer.h"
- X
- int
- print_char (ch)
- char ch;
- X{
- X char flag;
- X union REGS regs;
- X
- X regs.x.dx = 0;
- X regs.h.ah = 2;
- X int86 (0x17, ®s, ®s);
- X if (regs.h.ah != PR_SELECTED)
- X return regs.h.ah;
- X regs.x.dx = regs.h.ah = 0;
- X regs.h.al = ch;
- X int86 (0x17, ®s, ®s);
- X return 0;
- X}
- END_OF_FILE
- if test 917 -ne `wc -c <'printer.c'`; then
- echo shar: \"'printer.c'\" unpacked with wrong size!
- fi
- # end of 'printer.c'
- fi
- if test -f 'printer.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'printer.h'\"
- else
- echo shar: Extracting \"'printer.h'\" \(1083 characters\)
- sed "s/^X//" >'printer.h' <<'END_OF_FILE'
- X/*
- X * PRINTER.H
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X *
- X * Output a character to the printer port using software interrupt
- X * 0x17. Returns !0 if unsuccessful, 0 otherwise.
- X *
- X * Usage while (print_char (ch));
- X */
- X
- X#define PR_SELECTED 0x90
- X
- X/*
- X * flag returned 7 6 5 4 3 2 1 0
- X * | | | | | | | |------- Time out
- X * | | | | | | |---------
- X * | | | | | |-----------
- X * | | | | |------------- IO error
- X * | | | |--------------- Selected
- X * | | |----------------- Out of paper
- X * | |-------------------
- X * |--------------------- Busy
- X */
- X
- int print_char (char);
- END_OF_FILE
- if test 1083 -ne `wc -c <'printer.h'`; then
- echo shar: \"'printer.h'\" unpacked with wrong size!
- fi
- # end of 'printer.h'
- fi
- if test -f 'queue.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'queue.c'\"
- else
- echo shar: Extracting \"'queue.c'\" \(1374 characters\)
- sed "s/^X//" >'queue.c' <<'END_OF_FILE'
- X/*
- X * QUEUE.C
- X *
- X * Queue Handling Module
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X */
- X
- X#include "queue.h"
- X
- X/*
- X * QUEUE routines to allocate - enqueue - dequeue elements to a queue
- X */
- X
- QUEUE *
- alloc_queue (int size)
- X{
- X QUEUE *tmp;
- X if ((tmp = (QUEUE *) malloc (sizeof (QUEUE) + size)) != (QUEUE *) 0)
- X {
- X tmp->size = size;
- X tmp->head = 0;
- X tmp->tail = 0;
- X tmp->avail = size;
- X tmp->buf = ((char *) tmp) + sizeof (QUEUE);
- X }
- X return (tmp);
- X}
- X
- X
- X
- int
- en_queue (QUEUE *qp, char ch)
- X{
- X int head = qp->head;
- X
- X if (qp->avail == 0)
- X return (-1);
- X *(qp->buf + head) = ch;
- X if (++head == qp->size)
- X head = 0;
- X qp->head = head;
- X --(qp->avail);
- X return (qp->avail);
- X}
- X
- int
- de_queue (QUEUE *qp)
- X{
- X int tail = qp->tail, ch;
- X
- X if (qp->avail == qp->size)
- X return (-1);
- X ch = *(qp->buf + tail);
- X if (++tail == qp->size)
- X tail = 0;
- X qp->tail = tail;
- X qp->avail++;
- X return (ch);
- X}
- END_OF_FILE
- if test 1374 -ne `wc -c <'queue.c'`; then
- echo shar: \"'queue.c'\" unpacked with wrong size!
- fi
- # end of 'queue.c'
- fi
- if test -f 'queue.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'queue.h'\"
- else
- echo shar: Extracting \"'queue.h'\" \(788 characters\)
- sed "s/^X//" >'queue.h' <<'END_OF_FILE'
- X/*
- X * QUEUE.H
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X */
- X
- typedef struct {
- X int size,
- X head,
- X tail,
- X avail;
- X char *buf;
- X} QUEUE;
- X
- X# define queue_empty(qp) (qp)->head==(qp)->tail
- X# define queue_avail(qp) (qp)->avail
- X
- X# ifndef LINT
- X extern QUEUE *alloc_queue ();
- X extern int en_queue ();
- X extern de_queue ();
- X# else
- X extern QUEUE *alloc_queue (int);
- X extern int en_queue (QUEUE *, char);
- X extern int de_queue (QUEUE *);
- X# endif
- END_OF_FILE
- if test 788 -ne `wc -c <'queue.h'`; then
- echo shar: \"'queue.h'\" unpacked with wrong size!
- fi
- # end of 'queue.h'
- fi
- if test -f 'screen.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'screen.h'\"
- else
- echo shar: Extracting \"'screen.h'\" \(1502 characters\)
- sed "s/^X//" >'screen.h' <<'END_OF_FILE'
- X/*
- X * SCREEN.H
- X *
- X * Screen i/o Handler
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X */
- X
- extern int Scr_Cols;
- extern int Scr_Rows;
- extern char Scr_Window_Top;
- extern char Scr_Page;
- extern char Scr_ATTR;
- X
- X/*
- X * The screen attributes can be
- X *
- X * UnderLine OR Reverse OR Normal
- X *
- X * BRIGHT - BLINK are additional attributes applied to the above
- X */
- X
- X#if (!defined (SCREEN_ATTRIB))
- X# define SCR_ATTRIB 1
- X# define SECURE 0x77
- X# define REVERSE 0x70
- X# define NORMAL 7
- X# define UNDERLINE 1
- X# define BLINK 0x80
- X# define BRIGHT 9
- X# define INVERSE_UL (UNDERLINE | INVERSE)
- X#endif
- X
- X# ifdef LINT
- extern int _kb (void);
- extern int screen_init (void);
- extern int screen_smode (char);
- extern int rowcol (int, int);
- extern int g_rowcol (void);
- extern int clrscrn (void);
- extern int cleol (void);
- extern int cleop (void);
- extern int scroll_up (int, int, int, int, int);
- extern int scroll_dn (int, int, int, int, int);
- extern int screen_co (char);
- extern int sinp (void);
- extern int cursor_off (void);
- extern int cursor_on (void);
- extern int aputs (int, char *);
- extern int aput (int, char);
- X# endif
- END_OF_FILE
- if test 1502 -ne `wc -c <'screen.h'`; then
- echo shar: \"'screen.h'\" unpacked with wrong size!
- fi
- # end of 'screen.h'
- fi
- if test -f 'timer.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'timer.c'\"
- else
- echo shar: Extracting \"'timer.c'\" \(3201 characters\)
- sed "s/^X//" >'timer.c' <<'END_OF_FILE'
- X/*
- X * TIMER.C
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X *
- X * The timer routines used here are little approximations
- X * since the Timer Interrupt ( 0x1C ) is only updated 18
- X * times a second.
- X *
- X * The routines are NOT bulletproof - if you decide to use
- X * them I would heartily suggest you include a
- X * Control Break (Interrupt 0x23) intercept routine
- X * to allow for cleanup before Going South...
- X *
- X * There are basically three routines which you call
- X * timer_init () - sets up the timer interrupt vector
- X * (the interrupt handler is imbedded in
- X * there somewhere).
- X *
- X * timer_set () - sets the timer counter to 0
- X *
- X * timer_read () - returns the current value of the timer
- X * counter.
- X *
- X * timer_term () - a 'Must Do' - clean up our act and give
- X * the interrupt vector back
- X */
- X#include "dependnt.h"
- X
- X#if (!defined (TRUE))
- X# define TRUE (1)
- X# define FALSE (0)
- X#endif
- X
- volatile unsigned long int _Timer_cnt;
- static int _Timer_Active = 0;
- X
- X#if (defined (DLC))
- int
- Timer_ISR ()
- X{
- X _Timer_cnt++;
- X return (0);
- X}
- X#else
- void (interrupt far * timer_save_vec) (void);
- void interrupt far
- Timer_ISR (void)
- X{
- X _Timer_cnt++;
- X (*timer_save_vec) ();
- X}
- X#endif
- X
- X
- X
- X/*
- X * TIMER_INIT
- X */
- X
- int
- timer_init ()
- X{
- X if (!_Timer_Active)
- X {
- X#if (defined (DLC))
- X int_intercept (0x1C, &Timer_ISR, 128);
- X#else
- X timer_save_vec = getvect (0x1c);
- X setvect (0x1C, Timer_ISR);
- X#endif
- X _Timer_Active = TRUE;
- X }
- X}
- X
- X
- X
- X/*
- X * TIMER_TERM
- X */
- X
- int
- timer_term ()
- X{
- X if (_Timer_Active)
- X {
- X#if (defined (DLC))
- X int_restore (0x1C);
- X#else
- X setvect (0x1C, timer_save_vec);
- X#endif
- X _Timer_Active = FALSE;
- X }
- X}
- X
- X
- X
- X/*
- X * TIMER_SET
- X */
- X
- int
- timer_set ()
- X{
- X _Timer_cnt = 0L;
- X}
- X
- X
- X
- X/*
- X * TIMER_READ
- X */
- X
- unsigned long int
- timer_read ()
- X{
- X return (_Timer_cnt);
- X}
- X
- X
- X
- X
- X/*
- X * TIMEOUT - go away for the specified number of seconds
- X */
- X
- int
- timeout (sec)
- unsigned int sec;
- X{
- X unsigned long int flag;
- X sec *= 18;
- X _Timer_cnt = 0L;
- X do
- X {
- X flag = _Timer_cnt;
- X } while (flag < sec);
- X}
- X
- static unsigned int DELAY_millisecond;
- void
- DELAY_init (void)
- X{
- X static int d_init = 0;
- X int tna = 0;
- X long l;
- X if (d_init)
- X return;
- X d_init = 1;
- X if (!_Timer_Active)
- X {
- X timer_init ();
- X tna = 1;
- X }
- X timer_init ();
- X timer_set ();
- X while (timer_read () == 0L)
- X ;
- X timer_set ();
- X for (l = 0L; l != -1L; l++)
- X if (timer_read () == 3)
- X break;
- X l *= 197;
- X DELAY_millisecond = (int) ((l + 5000) / 10000);
- X if (tna)
- X timer_term ();
- X}
- static unsigned int _DELAY_cnt, _DELAY_ix;
- X
- int
- DELAY_loop (int msc)
- X{
- X for (_DELAY_ix = 0; _DELAY_ix < msc; _DELAY_ix++)
- X for (_DELAY_cnt = 0; _DELAY_cnt < DELAY_millisecond; _DELAY_cnt++)
- X ;
- X return (msc);
- X}
- END_OF_FILE
- if test 3201 -ne `wc -c <'timer.c'`; then
- echo shar: \"'timer.c'\" unpacked with wrong size!
- fi
- # end of 'timer.c'
- fi
- if test -f 'timer.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'timer.h'\"
- else
- echo shar: Extracting \"'timer.h'\" \(717 characters\)
- sed "s/^X//" >'timer.h' <<'END_OF_FILE'
- X/*
- X * TIMER.H
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X */
- X
- X# ifndef LINT
- X extern unsigned long int timer_read ();
- X# else
- X int timer_init (void);
- X extern int timer_term (void);
- X extern int timer_set (void);
- X extern unsigned long int timer_read (void);
- X extern int timeout (unsigned int);
- X extern void DELAY_init (void);
- X extern int DELAY_loop (int);
- X# endif
- END_OF_FILE
- if test 717 -ne `wc -c <'timer.h'`; then
- echo shar: \"'timer.h'\" unpacked with wrong size!
- fi
- # end of 'timer.h'
- fi
- if test -f 'tkb.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'tkb.c'\"
- else
- echo shar: Extracting \"'tkb.c'\" \(391 characters\)
- sed "s/^X//" >'tkb.c' <<'END_OF_FILE'
- X/*
- X * TKB.C
- X *
- X * Keyboard input test driver program
- X */
- X
- X#include <stdio.h>
- X#include "_kb.h"
- X
- X#if (!defined (TRUE))
- X# define TRUE (1)
- X# define FALSE (0)
- X#endif
- X
- main ()
- X{
- X int i;
- X while (TRUE)
- X {
- X while ((i = _kb ()) == -1);
- X if (i == 'q')
- X break;
- X printf ("_KB () = (%d) [%c]\n", i, i);
- X }
- X}
- END_OF_FILE
- if test 391 -ne `wc -c <'tkb.c'`; then
- echo shar: \"'tkb.c'\" unpacked with wrong size!
- fi
- # end of 'tkb.c'
- fi
- if test -f 'version.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'version.h'\"
- else
- echo shar: Extracting \"'version.h'\" \(811 characters\)
- sed "s/^X//" >'version.h' <<'END_OF_FILE'
- X/*
- X * VERSION.H
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X *
- X * Nothing but the current version of Laser.com
- X *
- X * Previous Versions
- X * char Version [] = "1.0 - 21 Apr '88"; First assigned version
- X * Added Contention Mode to the Poll Select Protocol
- X * char Version [] = "1.1 - 13 May '88"; First assigned version
- X */
- X
- X/*
- X * Setup for ZTC, TurboC and Microsoft C Compilers
- X */
- char Version [] = "2.0 - 28 Sep '89";
- X
- END_OF_FILE
- if test 811 -ne `wc -c <'version.h'`; then
- echo shar: \"'version.h'\" unpacked with wrong size!
- fi
- # end of 'version.h'
- fi
- if test -f 'vt100.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'vt100.h'\"
- else
- echo shar: Extracting \"'vt100.h'\" \(808 characters\)
- sed "s/^X//" >'vt100.h' <<'END_OF_FILE'
- X/*
- X * VT100.H
- X *
- X * Written for the
- X *
- X * Datalight
- X * Microsoft V 5.x
- X * TurboC
- X * &
- X * Zortech
- X *
- X * C Compilers
- X *
- X * Copyright (c) John Birchfield 1987, 1988, 1989
- X */
- X
- X#if (!defined (SCREEN_ATTRIB))
- X# define SCR_ATTRIB 1
- X# define BLINK 0x80
- X# define BRIGHT 9
- X# define INVERSE 0x70
- X# define NORMAL 7
- X# define UNDERLINE 1
- X/* #define UNDERLINE 0x71 */
- X#endif
- X#if (!defined (STANDALONE))
- extern char Duplex [2], RubOut [2],
- X BackSpace [2],
- X Cmask [2], CrLf [2];
- extern void vt100_driver (), VT100_init ();
- X#endif
- END_OF_FILE
- if test 808 -ne `wc -c <'vt100.h'`; then
- echo shar: \"'vt100.h'\" unpacked with wrong size!
- fi
- # end of 'vt100.h'
- fi
- echo shar: End of archive 1 \(of 3\).
- cp /dev/null ark1isdone
- MISSING=""
- for I in 1 2 3 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 3 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- +----------------------
- | John Birchfield
- | jb@altair.csustan.edu
- +----------------------
-
-
-