home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / pcserial.zoo / serial.1 next >
Encoding:
Text File  |  1990-04-04  |  56.4 KB  |  2,295 lines

  1.  
  2. #! /bin/sh
  3. # This is a shell archive.  Remove anything before this line, then unpack
  4. # it by saving it into a file and typing "sh file".  To overwrite existing
  5. # files, type "sh file -c".  You can also feed this as standard input via
  6. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  7. # will see the following message at the end:
  8. #        "End of archive 1 (of 3)."
  9. # Contents:  8250dtr.h 8250nsc.h 8250xon.h MANIFEST README _kb.h
  10. #   ctrl_brk.c ctrl_brk.h delay.c delay.h dependnt.h drop_dtr.c
  11. #   makefile.msc makefile.tcc makefile.ztc mdm_init.c monitor.c
  12. #   monitor.h msc.asm options.h printer.c printer.h queue.c queue.h
  13. #   screen.h timer.c timer.h tkb.c version.h vt100.h
  14. # Wrapped by jb@deneb on Sat Mar 24 10:42:16 1990
  15. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  16. if test -f '8250dtr.h' -a "${1}" != "-c" ; then 
  17.   echo shar: Will not clobber existing file \"'8250dtr.h'\"
  18. else
  19. echo shar: Extracting \"'8250dtr.h'\" \(928 characters\)
  20. sed "s/^X//" >'8250dtr.h' <<'END_OF_FILE'
  21. X/*
  22. X *                              8250DTR.H
  23. X *
  24. X *      Include file for Function Prototyping of 8250DTR.C Module
  25. X *
  26. X *                           Written for the
  27. X *
  28. X *                              Datalight
  29. X *                           Microsoft V 5.x
  30. X *                                TurboC
  31. X *                                  &
  32. X *                               Zortech
  33. X *
  34. X *                             C Compilers
  35. X *
  36. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  37. X */
  38. X
  39. extern int  dtr8250_get_status (void),
  40. X            dtr8250_modem_status (void),
  41. X            dtr8250_read (void),
  42. X            dtr8250_timed_read (int),
  43. X            dtr8250_write (char);
  44. extern void dtr8250_dtnr (void),
  45. X            dtr8250_init (int, int),
  46. X            dtr8250_lines (void),
  47. X            dtr8250_port_enable (void),
  48. X            dtr8250_port_init (char *),
  49. X            dtr8250_term (int),
  50. X            dtr8250_write_break (void);
  51. END_OF_FILE
  52. if test 928 -ne `wc -c <'8250dtr.h'`; then
  53.     echo shar: \"'8250dtr.h'\" unpacked with wrong size!
  54. fi
  55. # end of '8250dtr.h'
  56. fi
  57. if test -f '8250nsc.h' -a "${1}" != "-c" ; then 
  58.   echo shar: Will not clobber existing file \"'8250nsc.h'\"
  59. else
  60. echo shar: Extracting \"'8250nsc.h'\" \(4099 characters\)
  61. sed "s/^X//" >'8250nsc.h' <<'END_OF_FILE'
  62. X/*
  63. X *                             8250NSC.H
  64. X *
  65. X *                    National SemiConducter 8250
  66. X *
  67. X *               Serial Chip Routine Defines & Globals
  68. X *
  69. X *                           Written for the
  70. X *
  71. X *                              Datalight
  72. X *                           Microsoft V 5.x
  73. X *                                TurboC
  74. X *                                  &
  75. X *                               Zortech
  76. X *
  77. X *                             C Compilers
  78. X *
  79. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  80. X */
  81. X/*
  82. X *    Intel 8259a interrupt controller addresses and constants
  83. X */
  84. X
  85. X# define INT_cntrl        0x20
  86. X# define INT_mask         0x21
  87. X# define INT_port_enable  0xEF
  88. X# define EOI_word         0x20
  89. X
  90. X
  91. X/*
  92. X *    Constants used to enable and disable interrupts from the
  93. X *    8250 - they are stored in PORT_command 
  94. X */
  95. X
  96. X# define RX_enable        0x0D /* Enable Rcv & RLS Interrupt       */
  97. X# define TX_enable        0x0E /* Enable Xmit & RLS Interrupt      */
  98. X# define RX_TX_enable     0x0F /* Enable Rcv, Xmit & RLS Interrupt */
  99. X# define ERROR_reset      0xF1
  100. X# define LCR_DLAB         0x80
  101. X
  102. X
  103. X/*
  104. X *    8250 register offsets - should be added to value in PORT_address
  105. X */
  106. X
  107. X# define IER              1  /* interrupt enable offset */
  108. X# define IIR              2  /* interupt identification register */
  109. X# define LCR              3  /* line control register */
  110. X# define MCR              4  /* modem control register */
  111. X# define LSR              5  /* line status register */
  112. X# define MSR              6  /* modem status register */
  113. X
  114. X
  115. X/*
  116. X *    The following constants are primarily for documentaiton purposes
  117. X *    to show what the values sent to the 8250 Control Registers do to
  118. X *    the chip.
  119. X *
  120. X *
  121. X *                     INTERRUPT ENABLE REGISTER
  122. X */
  123. X
  124. X# define IER_Received_Data      1
  125. X# define IER_Xmt_Hld_Reg_Empty  (1<<1)
  126. X# define IER_Recv_Line_Status   (1<<2)
  127. X# define IER_Modem_Status       (1<<3)
  128. X# define IER_Not_Used           0xF0
  129. X
  130. X
  131. X/*
  132. X *                 INTERRUPT IDENTIFICATION REGISTER
  133. X */
  134. X
  135. X# define IIR_receive      4
  136. X# define IIR_transmit     2
  137. X# define IIR_mstatus      0
  138. X# define IIR_rls          6
  139. X# define IIR_complete     1
  140. X# define IIR_Not_Used     0xF8
  141. X
  142. X
  143. X/*
  144. X *                       LINE CONTROL REGISTER
  145. X */
  146. X
  147. X# define LCR_Word_Length_Mask     3
  148. X# define LCR_Stop_Bits            (1<<2)
  149. X# define LCR_Parity_Enable        (1<<3)
  150. X# define LCR_Even_Parity          (1<<4)
  151. X# define LCR_Stick_Parity         (1<<5)
  152. X# define LCR_Set_Break            (1<<6)
  153. X# define LCR_Divisor_Latch_Access (1<<7) /* Divisor Latch - must be set to 1
  154. X                                          * to get to the divisor latches of 
  155. X                                          * the baud rate generator - must
  156. X                                          * be set to 0 to access the
  157. X                                          * Receiver Buffer Register and
  158. X                                          * the Transmit Holding Register
  159. X                                          */
  160. X
  161. X
  162. X/*
  163. X *                        MODEM CONTROL REGISTER
  164. X */
  165. X
  166. X# define MCR_dtr          1
  167. X# define MCR_rts          (1<<1)
  168. X# define MCR_Out_1        (1<<2)
  169. X# define MCR_Out_2        (1<<3) /* MUST BE ASSERTED TO ENABLE INTERRRUPTS */
  170. X# define MCR_Loop_Back    (1<<4)
  171. X# define MCR_Not_Used     (7<<1)
  172. X
  173. X
  174. X/*
  175. X *                        LINE STATUS REGISTER
  176. X */
  177. X
  178. X# define LSR_Data_Ready      1
  179. X# define LSR_Overrun_Error   (1<<1)
  180. X# define LSR_Parity_Error    (1<<2)
  181. X# define LSR_Framing_Error   (1<<3)
  182. X# define LSR_Break_Interrupt (1<<4)
  183. X# define LSR_THR_Empty       (1<<5)  /* Transmitter Holding Register */
  184. X# define LSR_TSR_Empty       (1<<6)  /* Transmitter Shift Register */
  185. X# define LSR_Not_Used        (1<<7)
  186. X
  187. X
  188. X/*
  189. X *                       MODEM STATUS REGISTER
  190. X */
  191. X
  192. X# define MSR_Delta_CTS       1
  193. X# define MSR_Delta_DSR       (1<<1)
  194. X# define MSR_TERD            (1<<2)  /* Trailing Edge Ring Detect   */
  195. X# define MSR_Delta_RLSD      (1<<3)  /* Received Line Signal Detect */
  196. X# define MSR_CTS             (1<<4)  /* Clear to Send               */
  197. X# define MSR_DSR             (1<<5)  /* Data Set Ready              */
  198. X# define MSR_RD              (1<<6)  /* Ring Detect                 */
  199. X# define MSR_RLSD            (1<<7)  /* Received Line Signal Detect */
  200. END_OF_FILE
  201. if test 4099 -ne `wc -c <'8250nsc.h'`; then
  202.     echo shar: \"'8250nsc.h'\" unpacked with wrong size!
  203. fi
  204. # end of '8250nsc.h'
  205. fi
  206. if test -f '8250xon.h' -a "${1}" != "-c" ; then 
  207.   echo shar: Will not clobber existing file \"'8250xon.h'\"
  208. else
  209. echo shar: Extracting \"'8250xon.h'\" \(976 characters\)
  210. sed "s/^X//" >'8250xon.h' <<'END_OF_FILE'
  211. X/*
  212. X *                              8250XON.H
  213. X *
  214. X *      Include file for Function Prototyping of 8250XON.C Module
  215. X *
  216. X *                           Written for the
  217. X *
  218. X *                              Datalight
  219. X *                           Microsoft V 5.x
  220. X *                                TurboC
  221. X *                                  &
  222. X *                               Zortech
  223. X *
  224. X *                             C Compilers
  225. X *
  226. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  227. X */
  228. X
  229. X
  230. extern int  ioctl_set_xoff (char *),
  231. X            xon8250_get_status (void),
  232. X            xon8250_init (int, int),
  233. X            xon8250_port_init (char *),
  234. X            xon8250_read (void),
  235. X            xon8250_timed_read (int),
  236. X            xon8250_write (char),
  237. X            xon8250_write_buffer_empty (void),
  238. X            xon8250_xoff_sent (void);
  239. extern void xon8250_dtnr (void),
  240. X            xon8250_port_enable (void),
  241. X            xon8250_term (int),
  242. X            xon8250_write_break (void);
  243. END_OF_FILE
  244. if test 976 -ne `wc -c <'8250xon.h'`; then
  245.     echo shar: \"'8250xon.h'\" unpacked with wrong size!
  246. fi
  247. # end of '8250xon.h'
  248. fi
  249. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  250.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  251. else
  252. echo shar: Extracting \"'MANIFEST'\" \(1230 characters\)
  253. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  254. X   File Name        Archive #    Description
  255. X-----------------------------------------------------------
  256. X 8250dtr.c                  2    
  257. X 8250dtr.h                  1    
  258. X 8250nsc.h                  1    
  259. X 8250xon.c                  2    
  260. X 8250xon.h                  1    
  261. X MANIFEST                   1    This shipping list
  262. X README                     1    
  263. X _kb.c                      2    
  264. X _kb.h                      1    
  265. X ctrl_brk.c                 1    
  266. X ctrl_brk.h                 1    
  267. X delay.c                    1    
  268. X delay.h                    1    
  269. X dependnt.h                 1    
  270. X drop_dtr.c                 1    
  271. X makefile.msc               1    
  272. X makefile.tcc               1    
  273. X makefile.ztc               1    
  274. X mdm_init.c                 1    
  275. X monitor.c                  1    
  276. X monitor.h                  1    
  277. X msc.asm                    1    
  278. X options.c                  2    
  279. X options.h                  1    
  280. X printer.c                  1    
  281. X printer.h                  1    
  282. X queue.c                    1    
  283. X queue.h                    1    
  284. X screen.c                   2    
  285. X screen.h                   1    
  286. X timer.c                    1    
  287. X timer.h                    1    
  288. X tkb.c                      1    
  289. X version.h                  1    
  290. X vt100.c                    3    
  291. X vt100.h                    1    
  292. END_OF_FILE
  293. if test 1230 -ne `wc -c <'MANIFEST'`; then
  294.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  295. fi
  296. # end of 'MANIFEST'
  297. fi
  298. if test -f 'README' -a "${1}" != "-c" ; then 
  299.   echo shar: Will not clobber existing file \"'README'\"
  300. else
  301. echo shar: Extracting \"'README'\" \(1605 characters\)
  302. sed "s/^X//" >'README' <<'END_OF_FILE'
  303. X                               8250
  304. X                           Serial Chip
  305. X                         Support Routines
  306. X
  307. The files in this archive are a collection of tools I have used to
  308. muck about with serial i/o on the PC. The code compiles under
  309. TurboC V1.5 (and also 2.0 I think), as well as Microsoft C V5.x,
  310. DataLight C, and Zortech C.  The various makefiles are included to
  311. make life easy.
  312. X
  313. This code is copyrighted by myself and you may use it in any way
  314. you see fit as long as you don't charge money for it and as long
  315. as the copyright notices remain in the sources.
  316. X
  317. There are several programs which can be made:
  318. X
  319. X    1.  MDM_INIT - a little program to both tweek the serial port
  320. X        and initialize a modem. as an example if you had a Hayes
  321. X        on COM1: and you wanted to set it up at 2400 baud
  322. X        autoanswer you could enter:
  323. X
  324. X            mdm_init -b2400 -pn -d8 "S0=3"
  325. X
  326. X    2.    MONITOR - looks at the data on a serial line and
  327. X        displays the data on the screen (or if you redirect
  328. X        stdout, it will place it in a file). Use the command
  329. X
  330. X            monitor ?
  331. X
  332. X        to get a succinct description of the command line
  333. X        arguments.
  334. X
  335. X    3.    VT100 - a real simple vt100 terminal emulator - all it
  336. X        does is more or less emulate a vt100 (no alternate
  337. X        character sets and it's missing some (most?) of the DEC
  338. X        private stuff). <Alt>F10 exits the program, <Alt>F9 spawns
  339. X        DOS (use the dos exit command to get back to the program),
  340. X        and <Alt>F8 sends a break.  Use the command
  341. X
  342. X            vt100 ?
  343. X        
  344. X        to get a succinct description of the command line
  345. X        arguments.
  346. X
  347. X                          ---   jb   ---
  348. X                           Oct 11, 1989
  349. END_OF_FILE
  350. if test 1605 -ne `wc -c <'README'`; then
  351.     echo shar: \"'README'\" unpacked with wrong size!
  352. fi
  353. # end of 'README'
  354. fi
  355. if test -f '_kb.h' -a "${1}" != "-c" ; then 
  356.   echo shar: Will not clobber existing file \"'_kb.h'\"
  357. else
  358. echo shar: Extracting \"'_kb.h'\" \(3200 characters\)
  359. sed "s/^X//" >'_kb.h' <<'END_OF_FILE'
  360. X/*
  361. X *                               _KB.H
  362. X *
  363. X *                        Keyboard i/o Handler
  364. X *
  365. X *                           Written for the
  366. X *
  367. X *                              Datalight
  368. X *                           Microsoft V 5.x
  369. X *                                TurboC
  370. X *                                  &
  371. X *                               Zortech
  372. X *
  373. X *                             C Compilers
  374. X *
  375. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  376. X */
  377. X
  378. X/* control key translations */
  379. X
  380. X# define CTLX            0x4000
  381. X# define META            0x8000
  382. X# define up_char        240
  383. X# define down_char        241
  384. X# define right_char        242
  385. X# define left_char        243
  386. X
  387. X
  388. X# define home_char        META | 69        /* ESC O E   */
  389. X# define ctl_home_char    META | 70        /* ESC O F   */
  390. X# define pageup_char    META | 71        /* ESC O G  */
  391. X# define ctl_pu_char    META | 72        /* ESC O H  */
  392. X# define ctl_rt_char    META | 73        /* ESC O I  */
  393. X# define pagedown_char    META | 74        /* ESC O J  */
  394. X# define ctl_pd_char    META | 75        /* ESC O K  */
  395. X# define end_char        META | 76        /* ESC O L  */
  396. X# define ctl_end_char    META | 77        /* ESC O M  */
  397. X# define ctl_lft_char    META | 78        /* ESC O N  */
  398. X
  399. X# define Ins_char        206
  400. X# define Del_char        207
  401. X# define NextWord_char    208
  402. X# define PrevWord_char    209
  403. X
  404. X# define M1                210
  405. X# define M2                211
  406. X# define M3                212
  407. X# define M4                213
  408. X# define M5                214
  409. X# define M6                215
  410. X# define M7                216
  411. X# define M8                217
  412. X# define M9                218
  413. X# define M10            219
  414. X# define M11            220
  415. X# define M12            221
  416. X# define M13            222
  417. X# define M14            223
  418. X# define M15            224
  419. X# define M16            225
  420. X# define M17            226
  421. X# define M18            227
  422. X# define M19            228
  423. X# define M20            229
  424. X# define M21            230
  425. X# define M22            231
  426. X# define M23            232
  427. X# define M24            233
  428. X# define M25            234
  429. X# define M26            235
  430. X# define M27            236
  431. X# define M28            237
  432. X# define M29            238
  433. X# define M30            239
  434. X# define M31            240
  435. X# define M32            241
  436. X# define M33            242
  437. X# define M34            243
  438. X# define M35            244
  439. X# define M36            245
  440. X# define M37            246
  441. X# define M38            247
  442. X# define M39            248
  443. X# define M40            249
  444. X
  445. X
  446. X#define    NUL        0
  447. X#define    ENQ        5
  448. X#define    BEL        7
  449. X#define    BS        8
  450. X#define    HT        9
  451. X#define    LF        10
  452. X#define    VT        11
  453. X#define    FF        12
  454. X#define    CR        13
  455. X#define SO        14
  456. X#define    SI        15
  457. X#define    XON        17
  458. X#define    XOFF    19
  459. X#define    CAN        24
  460. X#define    SUB        26
  461. X#define    ESC        27
  462. X#define    DEL        127
  463. X#define DC2        18
  464. X#define DC4        20
  465. X#define    TAB        9
  466. X#define DEL1    207
  467. X
  468. X
  469. X/*
  470. X    Keyboard input characters after scan code translation
  471. X*/
  472. X
  473. X#define PF1            210
  474. X#define PF2            211
  475. X#define PF3            212
  476. X#define PF4            213
  477. X#define PF5            214
  478. X#define PF6            215
  479. X#define PF7            216
  480. X#define PF8            217
  481. X#define PF9            218
  482. X#define PF10        219
  483. X
  484. X#define SPF1        230
  485. X#define    SPF2        231
  486. X#define    SPF3        232
  487. X#define    SPF4        233
  488. X#define    SPF5        234
  489. X#define SPF6        235
  490. X#define SPF7        236
  491. X#define    SPF8        237
  492. X#define    SPF9        238
  493. X#define    SPF10        239
  494. X#define APF1        220
  495. X#define APF2        221
  496. X#define APF3        222
  497. X#define APF4        223
  498. X#define APF5        224
  499. X#define APF6        225
  500. X#define APF7        226
  501. X#define APF8        227
  502. X#define APF9        228
  503. X#define APF10        229
  504. X
  505. X#define    HCHAR        200
  506. X#define UPCHAR        240
  507. X#define    DNCHAR        241
  508. X#define    RTCHAR        242
  509. X#define    LFCHAR        243
  510. X#define INSCHAR        206
  511. X#define DELCHAR        207
  512. X#define BOLCHAR        200
  513. X#define EOLCHAR        201
  514. X#define    PGUCHAR        202
  515. X#define    PGDCHAR        203
  516. X#define    NWCHAR        208
  517. X#define    PWCHAR        209
  518. X
  519. extern int _kb (void);
  520. END_OF_FILE
  521. if test 3200 -ne `wc -c <'_kb.h'`; then
  522.     echo shar: \"'_kb.h'\" unpacked with wrong size!
  523. fi
  524. # end of '_kb.h'
  525. fi
  526. if test -f 'ctrl_brk.c' -a "${1}" != "-c" ; then 
  527.   echo shar: Will not clobber existing file \"'ctrl_brk.c'\"
  528. else
  529. echo shar: Extracting \"'ctrl_brk.c'\" \(1104 characters\)
  530. sed "s/^X//" >'ctrl_brk.c' <<'END_OF_FILE'
  531. X/*
  532. X *                              CTRL_BRK.C
  533. X *
  534. X *                           Written for the
  535. X *
  536. X *                              Datalight
  537. X *                           Microsoft V 5.x
  538. X *                                TurboC
  539. X *                                  &
  540. X *                               Zortech
  541. X *
  542. X *                             C Compilers
  543. X *
  544. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  545. X */
  546. X
  547. X#include "dependnt.h"
  548. X
  549. X#if (defined (DLC))
  550. int 
  551. brk_handler ()
  552. X{
  553. X    return (1);
  554. X}
  555. X#else
  556. int     cb_happened = 0;
  557. void    (interrupt far * brk_save_vec) (void);
  558. void interrupt far 
  559. brk_handler (void)
  560. X{
  561. X    cb_happened = 1;
  562. X}
  563. X#endif
  564. X
  565. static int ctrl_brk_blocked =  0;
  566. void 
  567. trap_ctrl_break (void)
  568. X{
  569. X    if (ctrl_brk_blocked)
  570. X        return;
  571. X    ctrl_brk_blocked = 1;
  572. X#if (defined (DLC))
  573. X    int_intercept (0x23, &brk_handler, 128);
  574. X#else
  575. X    brk_save_vec = getvect (0x23);
  576. X    setvect (0x23, brk_handler);
  577. X#endif
  578. X}
  579. X
  580. void 
  581. release_ctrl_break (void)
  582. X{
  583. X    if (!ctrl_brk_blocked)
  584. X        return;
  585. X    ctrl_brk_blocked = 0;
  586. X#if (defined (DLC))
  587. X    int_restore (0x23);
  588. X#else
  589. X    setvect (0x23, brk_save_vec);
  590. X#endif
  591. X}
  592. X
  593. END_OF_FILE
  594. if test 1104 -ne `wc -c <'ctrl_brk.c'`; then
  595.     echo shar: \"'ctrl_brk.c'\" unpacked with wrong size!
  596. fi
  597. # end of 'ctrl_brk.c'
  598. fi
  599. if test -f 'ctrl_brk.h' -a "${1}" != "-c" ; then 
  600.   echo shar: Will not clobber existing file \"'ctrl_brk.h'\"
  601. else
  602. echo shar: Extracting \"'ctrl_brk.h'\" \(497 characters\)
  603. sed "s/^X//" >'ctrl_brk.h' <<'END_OF_FILE'
  604. X/*
  605. X *                              CTRL_BRK.H
  606. X *
  607. X *                           Written for the
  608. X *
  609. X *                              Datalight
  610. X *                           Microsoft V 5.x
  611. X *                                TurboC
  612. X *                                  &
  613. X *                               Zortech
  614. X *
  615. X *                             C Compilers
  616. X *
  617. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  618. X */
  619. X
  620. extern void trap_ctrl_break    (void),
  621. X            release_ctrl_break (void);
  622. END_OF_FILE
  623. if test 497 -ne `wc -c <'ctrl_brk.h'`; then
  624.     echo shar: \"'ctrl_brk.h'\" unpacked with wrong size!
  625. fi
  626. # end of 'ctrl_brk.h'
  627. fi
  628. if test -f 'delay.c' -a "${1}" != "-c" ; then 
  629.   echo shar: Will not clobber existing file \"'delay.c'\"
  630. else
  631. echo shar: Extracting \"'delay.c'\" \(1745 characters\)
  632. sed "s/^X//" >'delay.c' <<'END_OF_FILE'
  633. X/*
  634. X *                               DELAY.C
  635. X *
  636. X *                           Written for the
  637. X *
  638. X *                              Datalight
  639. X *                           Microsoft V 5.x
  640. X *                                TurboC
  641. X *                                  &
  642. X *                               Zortech
  643. X *
  644. X *                             C Compilers
  645. X *
  646. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  647. X *
  648. X *    This module implements a more or less machine independent delay
  649. X *    loop - the general idea is we kinda tie the delay loop to the 
  650. X *    Timer Interrupt to get a general idea of how big the loop counter
  651. X *    has to be to count off a millisecond.  Crude eh?
  652. X */
  653. X
  654. X/*
  655. X *    We'll take the stand-alone testing stuff out entirely
  656. X *    one of these days.
  657. X */
  658. X
  659. unsigned long int timer_read ();
  660. X
  661. X#if (defined (TEST))
  662. X#    include <stdio.h>
  663. X#    include <time.h>
  664. main ()
  665. X{
  666. X    long    starttime, stoptime;
  667. X    DELAY_init ();
  668. X    printf ("\n\nBegin %d millisecond delay\n\n", 30000);
  669. X    time (&starttime);
  670. X    DELAY_loop (30000);
  671. X    time (&stoptime);
  672. X    printf ("End - Elapsed time = %ld\n", stoptime - starttime);
  673. X    timer_term ();
  674. X}
  675. X
  676. X#endif
  677. X
  678. X
  679. static unsigned int DELAY_millisecond;
  680. void
  681. DELAY_init (void)
  682. X{
  683. X    static d_init = 0;
  684. X    long    l;
  685. X    if (d_init)
  686. X        return;
  687. X    d_init = 0;
  688. X    timer_init ();
  689. X    timer_set ();
  690. X    while (timer_read () == 0L);
  691. X    timer_set ();
  692. X    for (l = 0L; l != -1L; l++)
  693. X        if (timer_read () == 3)
  694. X            break;
  695. X    l *= 197;
  696. X    DELAY_millisecond = (int) ((l + 5000) / 10000);
  697. X}
  698. static unsigned int _DELAY_cnt, _DELAY_ix;
  699. X
  700. int 
  701. DELAY_loop (int msc)
  702. X{
  703. X    for (_DELAY_ix = 0; _DELAY_ix < msc; _DELAY_ix++)
  704. X        for (_DELAY_cnt = 0; _DELAY_cnt < DELAY_millisecond; _DELAY_cnt++);
  705. X    return (msc);
  706. X}
  707. END_OF_FILE
  708. if test 1745 -ne `wc -c <'delay.c'`; then
  709.     echo shar: \"'delay.c'\" unpacked with wrong size!
  710. fi
  711. # end of 'delay.c'
  712. fi
  713. if test -f 'delay.h' -a "${1}" != "-c" ; then 
  714.   echo shar: Will not clobber existing file \"'delay.h'\"
  715. else
  716. echo shar: Extracting \"'delay.h'\" \(464 characters\)
  717. sed "s/^X//" >'delay.h' <<'END_OF_FILE'
  718. X/*
  719. X *                               DELAY.H
  720. X *
  721. X *                           Written for the
  722. X *
  723. X *                              Datalight
  724. X *                           Microsoft V 5.x
  725. X *                                TurboC
  726. X *                                  &
  727. X *                               Zortech
  728. X *
  729. X *                             C Compilers
  730. X *
  731. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  732. X */
  733. void DELAY_init (void);
  734. int  DELAY_loop (int);
  735. X
  736. END_OF_FILE
  737. if test 464 -ne `wc -c <'delay.h'`; then
  738.     echo shar: \"'delay.h'\" unpacked with wrong size!
  739. fi
  740. # end of 'delay.h'
  741. fi
  742. if test -f 'dependnt.h' -a "${1}" != "-c" ; then 
  743.   echo shar: Will not clobber existing file \"'dependnt.h'\"
  744. else
  745. echo shar: Extracting \"'dependnt.h'\" \(1626 characters\)
  746. sed "s/^X//" >'dependnt.h' <<'END_OF_FILE'
  747. X/*
  748. X *                              DEPENDNT.H
  749. X *
  750. X *                           Written for the
  751. X *
  752. X *                              Datalight
  753. X *                           Microsoft V 5.x
  754. X *                                TurboC
  755. X *                                  &
  756. X *                               Zortech
  757. X *
  758. X *                             C Compilers
  759. X *
  760. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  761. X *
  762. X *    This stuff is used so that the same source will compile
  763. X *    and run under either Zortech C , Turbo C, or Microsoft C.
  764. X *    We are attempting to localize differences in interrupt handling
  765. X *  as well as memory and i/o port handling diffferences here.
  766. X */
  767. X
  768. X#if (!defined (DEPENDENTSTUFF))
  769. X#    define DEPENDENTSTUFF
  770. X#    if (defined (DLC))
  771. X#        define inbyte(address)          inp(address)
  772. X#        define outbyte(address, value)  outp(address, value)
  773. X#        define enable                   int_on
  774. X#        define disable                  int_off
  775. X#        define peekmem(seg,offset,var)  peek(seg,offset,&var,2)
  776. X#        define setraw(fp)    fp->_flag &= ~_IOTRAN
  777. X#        define setcooked(fp) fp->_flag |= _IOTRAN
  778. X#    else
  779. X#        include <dos.h>
  780. X#        if (!defined (__TURBOC__))
  781. X#            define getvect(i)   _dos_getvect(i)
  782. X#            define setvect(i,v) _dos_setvect(i,v)
  783. X#            define setraw(fp)
  784. X#            define setcooked(fp)
  785. X#            define peekmem(seg,offset,var) peekmem(seg,offset,&var)
  786. X#        else
  787. X#            define setraw(fp)    fp->flags |= _F_BIN
  788. X#            define setcooked(fp) fp->flag &= ~_F_BIN
  789. X#            define inbyte(address)          inportb(address)
  790. X#            define outbyte(address, value)  outportb(address, value)
  791. X#            define peekmem(seg,offset, var) var=peek(seg,offset)
  792. X#        endif
  793. X#    endif
  794. X#endif
  795. END_OF_FILE
  796. if test 1626 -ne `wc -c <'dependnt.h'`; then
  797.     echo shar: \"'dependnt.h'\" unpacked with wrong size!
  798. fi
  799. # end of 'dependnt.h'
  800. fi
  801. if test -f 'drop_dtr.c' -a "${1}" != "-c" ; then 
  802.   echo shar: Will not clobber existing file \"'drop_dtr.c'\"
  803. else
  804. echo shar: Extracting \"'drop_dtr.c'\" \(1051 characters\)
  805. sed "s/^X//" >'drop_dtr.c' <<'END_OF_FILE'
  806. X/*
  807. X *                              DROP_DTR.C
  808. X *
  809. X *                           Written for the
  810. X *
  811. X *                              Datalight
  812. X *                           Microsoft V 5.x
  813. X *                                TurboC
  814. X *                                  &
  815. X *                               Zortech
  816. X *
  817. X *                             C Compilers
  818. X *
  819. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  820. X */
  821. X#include <stdlib.h>
  822. X#include "dependnt.h"
  823. X#include "timer.h"
  824. void dtnr (int);
  825. X
  826. main (int argc, char *argv [])
  827. X{
  828. X    if (argc > 1)
  829. X        dtnr (atoi (argv [1]));
  830. X    else
  831. X        dtnr (1);
  832. X}
  833. X
  834. X
  835. X
  836. X
  837. X/*----------------------------- dtnr () -----------------------------*/
  838. X/*
  839. X *
  840. X */
  841. X# define MCR              4  /* modem control register */
  842. unsigned PORT_addr;
  843. char     MCR_save  = 0;
  844. void
  845. dtnr (int channel)
  846. X{
  847. X    int Dos_address;
  848. X    unsigned i;
  849. X    Dos_address = (channel - 1) * 2;
  850. X    DELAY_init ();
  851. X    peekmem (0x40, Dos_address, PORT_addr);
  852. X    MCR_save = inbyte (PORT_addr+MCR);
  853. X    outbyte (PORT_addr+MCR, 0);
  854. X    DELAY_loop (1000);
  855. X    outbyte (PORT_addr+MCR, MCR_save);
  856. X}
  857. X
  858. END_OF_FILE
  859. if test 1051 -ne `wc -c <'drop_dtr.c'`; then
  860.     echo shar: \"'drop_dtr.c'\" unpacked with wrong size!
  861. fi
  862. # end of 'drop_dtr.c'
  863. fi
  864. if test -f 'makefile.msc' -a "${1}" != "-c" ; then 
  865.   echo shar: Will not clobber existing file \"'makefile.msc'\"
  866. else
  867. echo shar: Extracting \"'makefile.msc'\" \(1492 characters\)
  868. sed "s/^X//" >'makefile.msc' <<'END_OF_FILE'
  869. X#
  870. X#            Makefile for various Serial Port Handler Programs
  871. X#
  872. X#                               8250xxx.*
  873. X#
  874. X#                             Written for
  875. X#                       The MicroSoft C Compiler
  876. X#
  877. X#                            CopyRight 1989
  878. X#
  879. X#                            John Birchfield
  880. X#
  881. X#
  882. X#   MONITOR  - a simple line monitor program
  883. X#
  884. X#   MDM_INIT - a modem initialization program
  885. X#
  886. X#   VT100    - self explanitory
  887. X#
  888. X
  889. CFLAGS    =    -AS -J -Gs
  890. X
  891. IOBJS =        mdm_init.obj 8250xon.obj timer.obj queue.obj \
  892. X            ctrl_brk.obj msc.obj
  893. X
  894. MOBJS    =    monitor.obj options.obj 8250xon.obj queue.obj \
  895. X             ctrl_brk.obj _kb.obj msc.obj timer.obj
  896. X
  897. VOBJS    =    vt100.obj queue.obj screen.obj 8250xon.obj \
  898. X             ctrl_brk.obj _kb.obj timer.obj options.obj msc.obj
  899. X
  900. X.c.obj : 
  901. X    cl -c $(CFLAGS) $<
  902. X
  903. all          : drop_dtr laser mdm_init monitor vt100
  904. X
  905. drop_dtr     : drop_dtr.exe
  906. X
  907. mdm_init     : mdm_init.exe
  908. X
  909. monitor      : monitor.exe
  910. X
  911. vt100        : vt100.exe
  912. X
  913. drop_dtr.exe : drop_dtr.obj timer.obj msc.obj
  914. X    cl $(CFLAGS) drop_dtr.obj timer.obj msc.obj
  915. X
  916. mdm_init.exe : $(IOBJS)
  917. X    cl $(CFLAGS) $(IOBJS)
  918. X
  919. monitor.exe  : $(MOBJS)
  920. X    cl $(CFLAGS) $(MOBJS)
  921. X
  922. vt100.exe    : $(VOBJS)
  923. X    cl $(VOBJS) -link /ST:8192
  924. X
  925. msc.obj      : msc.asm
  926. X    masm -ml msc.asm;
  927. X
  928. vt100.obj    : vt100.c
  929. X    cl $(CFLAGS) -DSTANDALONE -c vt100.c
  930. X
  931. X$(MOBJS)     : 
  932. X
  933. X$(VOBJS)     : 
  934. X
  935. clean        :  
  936. X    del *.obj
  937. X    del *.map
  938. X
  939. archive      : 
  940. X    chmod -r comm_io.arc
  941. X    pkarc -u comm_io *.c *.h  *.asm *.rsp *.cmd makefile.*
  942. X    chmod -a *.c *.h *.rsp makefile.*
  943. END_OF_FILE
  944. if test 1492 -ne `wc -c <'makefile.msc'`; then
  945.     echo shar: \"'makefile.msc'\" unpacked with wrong size!
  946. fi
  947. # end of 'makefile.msc'
  948. fi
  949. if test -f 'makefile.tcc' -a "${1}" != "-c" ; then 
  950.   echo shar: Will not clobber existing file \"'makefile.tcc'\"
  951. else
  952. echo shar: Extracting \"'makefile.tcc'\" \(1654 characters\)
  953. sed "s/^X//" >'makefile.tcc' <<'END_OF_FILE'
  954. X#
  955. X#            Makefile for various Serial Port Handler Programs
  956. X#
  957. X#                               8250xxx.*
  958. X#
  959. X#                             Written for
  960. X#                         The Turbo C Compiler
  961. X#
  962. X#                            CopyRight 1988
  963. X#
  964. X#                            John Birchfield
  965. X#
  966. X#
  967. X#   MONITOR  - a simple line monitor program
  968. X#
  969. X#   MDM_INIT - a modem initialization program
  970. X#
  971. X#   VT100    - self explanitory
  972. X#
  973. X
  974. CFLAGS    =    -mt -K -DSTANDALONE
  975. BINDIR    =    /bin
  976. X
  977. IOBJS    =    mdm_init.obj 8250xon.obj timer.obj \
  978. X            queue.obj ctrl_brk.obj
  979. X
  980. MOBJS    =    monitor.obj options.obj 8250xon.obj queue.obj \
  981. X             ctrl_brk.obj _kb.obj timer.obj
  982. X
  983. VOBJS    =    vt100.obj queue.obj screen.obj 8250xon.obj \
  984. X             ctrl_brk.obj _kb.obj timer.obj options.obj
  985. X
  986. X
  987. X.c.obj : 
  988. X    tcc -c $(CFLAGS) $<
  989. X
  990. all          : drop_dtr laser mdm_init monitor vt100
  991. X
  992. drop_dtr     : drop_dtr.com
  993. X
  994. mdm_init     : mdm_init.com
  995. X
  996. monitor      : monitor.com
  997. X
  998. vt100        : vt100.com
  999. X
  1000. drop_dtr.com : drop_dtr.obj timer.obj
  1001. X    tcc $(CFLAGS) -f- drop_dtr.obj timer.obj
  1002. X    $(BINDIR)/exe2bin drop_dtr.exe drop_dtr.com
  1003. X    del drop_dtr.exe
  1004. X
  1005. mdm_init.com : $(IOBJS)
  1006. X    tcc $(CFLAGS) -f- $(IOBJS)
  1007. X    $(BINDIR)/exe2bin mdm_init.exe mdm_init.com
  1008. X    del mdm_init.exe
  1009. X
  1010. monitor.com  : $(MOBJS)
  1011. X    tcc $(CFLAGS) -f- $(MOBJS)
  1012. X    $(BINDIR)/exe2bin monitor.exe monitor.com
  1013. X    del monitor.exe
  1014. X
  1015. vt100.com    : $(VOBJS)
  1016. X    tcc $(CFLAGS) -f- $(VOBJS)
  1017. X    $(BINDIR)/exe2bin vt100.exe vt100.com
  1018. X    del vt100.exe
  1019. X
  1020. X$(MOBJS)     : 
  1021. X
  1022. X$(VOBJS)     : 
  1023. X
  1024. clean        :  
  1025. X    del *.obj
  1026. X    del *.map
  1027. X
  1028. archive      : 
  1029. X    $(BINDIR)/chmod -r comm_io.arc
  1030. X    $(BINDIR)/pkarc -u comm_io *.c *.h  *.asm *.rsp *.cmd makefile.*
  1031. X    $(BINDIR)/chmod -a *.c *.h *.rsp makefile.*
  1032. END_OF_FILE
  1033. if test 1654 -ne `wc -c <'makefile.tcc'`; then
  1034.     echo shar: \"'makefile.tcc'\" unpacked with wrong size!
  1035. fi
  1036. # end of 'makefile.tcc'
  1037. fi
  1038. if test -f 'makefile.ztc' -a "${1}" != "-c" ; then 
  1039.   echo shar: Will not clobber existing file \"'makefile.ztc'\"
  1040. else
  1041. echo shar: Extracting \"'makefile.ztc'\" \(1763 characters\)
  1042. sed "s/^X//" >'makefile.ztc' <<'END_OF_FILE'
  1043. X#
  1044. X#            Makefile for various Serial Port Handler Programs
  1045. X#
  1046. X#                               8250xxx.*
  1047. X#
  1048. X#                             Written for
  1049. X#
  1050. X#                        The Zortech C Compiler
  1051. X#
  1052. X#                            Copyright 1989
  1053. X#
  1054. X#                            John Birchfield
  1055. X#
  1056. X#
  1057. X#   MONITOR  - a simple line monitor program
  1058. X#
  1059. X#   MDM_INIT - a modem initialization program
  1060. X#
  1061. X#   VT100    - self explanitory
  1062. X#
  1063. X#    Invoke with -dDLC if using the Zortech v2.0 compiler
  1064. X#
  1065. X#    Invoke with CFLAGS=-dLINT <modulename> to invoke Formal Parameter
  1066. X#    checking a la ANSI C...
  1067. X#    or if you want both an exact invokation to compile the Monitor
  1068. X#    module would be:
  1069. X#
  1070. X#        make "CFLAGS=-dLINT -dDLC -o" monitor
  1071. X
  1072. X#CFLAGS    =    -mti -J -S -DLINT -DDLC -DSTANDALONE
  1073. CFLAGS    =    -g   -J -S -DLINT -DDLC -DSTANDALONE
  1074. X
  1075. IOBJS =        mdm_init.obj 8250xon.obj timer.obj queue.obj \
  1076. X            ctrl_brk.obj
  1077. X
  1078. MOBJS    =    monitor.obj options.obj 8250xon.obj queue.obj \
  1079. X             timer.obj ctrl_brk.obj _kb.obj
  1080. X
  1081. VOBJS    =    vt100.obj queue.obj screen.obj 8250xon.obj \
  1082. X             ctrl_brk.obj _kb.obj timer.obj options.obj
  1083. X
  1084. X.c.obj : 
  1085. X    ztc -c $(CFLAGS) $<
  1086. X
  1087. X
  1088. X
  1089. all          : drop_dtr mdm_init laser monitor vt100
  1090. X
  1091. drop_dtr     : drop_dtr.com
  1092. X
  1093. mdm_init     : mdm_init.com
  1094. X
  1095. monitor      : monitor.com
  1096. X
  1097. vt100        : vt100.com
  1098. X
  1099. drop_dtr.com : drop_dtr.obj timer.obj
  1100. X    ztc $(CFLAGS) drop_dtr.obj timer.obj
  1101. X
  1102. mdm_init.com : $(IOBJS)
  1103. X    ztc $(CFLAGS) $(IOBJS)
  1104. X
  1105. monitor.com  : $(MOBJS)
  1106. X    ztc -mti -omonitor $(MOBJS)
  1107. X
  1108. vt100.com    : $(VOBJS)
  1109. X    ztc $(CFLAGS) $(VOBJS)
  1110. X
  1111. X$(MOBJS)     : 
  1112. X
  1113. X$(VOBJS)     : 
  1114. X
  1115. vt100.obj    : vt100.c
  1116. X    ztc $(CFLAGS) -dSTANDALONE -c vt100.c
  1117. X
  1118. clean        :  
  1119. X    rm *.obj *.map
  1120. X
  1121. archive      : 
  1122. X    chmod -r comm_io.arc
  1123. X    pkarc -u comm_io *.c *.h  *.rsp *.cmd *.asm makefile.*
  1124. X    chmod -a *.c *.h *.rsp makefile.*
  1125. END_OF_FILE
  1126. if test 1763 -ne `wc -c <'makefile.ztc'`; then
  1127.     echo shar: \"'makefile.ztc'\" unpacked with wrong size!
  1128. fi
  1129. # end of 'makefile.ztc'
  1130. fi
  1131. if test -f 'mdm_init.c' -a "${1}" != "-c" ; then 
  1132.   echo shar: Will not clobber existing file \"'mdm_init.c'\"
  1133. else
  1134. echo shar: Extracting \"'mdm_init.c'\" \(4503 characters\)
  1135. sed "s/^X//" >'mdm_init.c' <<'END_OF_FILE'
  1136. X/*
  1137. X *                              MDM_INIT.C
  1138. X *
  1139. X *                           Written for the
  1140. X *
  1141. X *                              Datalight
  1142. X *                           Microsoft V 5.x
  1143. X *                                TurboC
  1144. X *                                  &
  1145. X *                               Zortech
  1146. X *
  1147. X *                             C Compilers
  1148. X *
  1149. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  1150. X */
  1151. X
  1152. X#include <stdio.h>
  1153. X#include <ctype.h>
  1154. X#include "8250xon.h"
  1155. X#include "ctrl_brk.h"
  1156. X#include "timer.h"
  1157. X
  1158. X#if (!defined (TRUE))
  1159. X#    define TRUE (1)
  1160. X#    define FALSE (0)
  1161. X#endif
  1162. X
  1163. X#define ETX 3
  1164. X#define EOT 4
  1165. void usage (void);
  1166. X
  1167. main (int argc, char **argv)
  1168. X{
  1169. X    char    m_cmd[80];
  1170. X    int     port = 1, baud = 0, data = 0, stop = 0, parity = 0,
  1171. X            p_init = FALSE;
  1172. X    while (argc > 1)
  1173. X    {
  1174. X        if (*argv [1] == '?')
  1175. X            usage ();
  1176. X        if (argv [1] [0] != '-')
  1177. X        {
  1178. X            break;
  1179. X        }
  1180. X        argc--; argv++;
  1181. X        switch (toupper (argv[0][1]))
  1182. X        {
  1183. X            case 'B':
  1184. X                baud = atoi (&argv[0][2]);
  1185. X                break;
  1186. X            case 'C':
  1187. X                port = atoi (&argv[0][2]);
  1188. X                break;
  1189. X            case 'P':
  1190. X                parity = argv[0][2];
  1191. X                break;
  1192. X            case 'S':
  1193. X                stop = atoi (&argv[0][2]);
  1194. X                break;
  1195. X            case 'D':
  1196. X                data = atoi (&argv[0][2]);
  1197. X                break;
  1198. X            default:
  1199. X                fprintf (stderr, "Invalid option %s\n", *argv);
  1200. X                usage ();
  1201. X                break;
  1202. X        }
  1203. X    }
  1204. X
  1205. X
  1206. X    if (baud || data || parity || stop)
  1207. X    {
  1208. X        baud = (baud) ? baud : 1200;
  1209. X        data = (data) ? data : 8;
  1210. X        parity = (parity) ? toupper (parity) : (int) 'N';
  1211. X        stop = (stop) ? stop : 1;
  1212. X        sprintf (m_cmd, "%d %c %d %d", baud, parity, stop, data);
  1213. X        p_init = TRUE;
  1214. X    }
  1215. X    trap_ctrl_break ();
  1216. X    timer_init ();
  1217. X    xon8250_init (port, 256);
  1218. X    if (p_init)
  1219. X        xon8250_port_init (m_cmd);
  1220. X    else
  1221. X        xon8250_port_enable ();
  1222. X    modem_write ("#+++");
  1223. X    timeout (1);
  1224. X    while (argc-- > 1)
  1225. X    {
  1226. X        modem_write ("AT");
  1227. X        modem_write (*++argv);
  1228. X        modem_write ("\r");
  1229. X    }
  1230. X    while (!xon8250_write_buffer_empty ())
  1231. X        ;
  1232. X    timeout (1);
  1233. X    xon8250_term (0);
  1234. X    timer_term ();
  1235. X    release_ctrl_break ();
  1236. X    exit (0);
  1237. X}
  1238. X
  1239. X
  1240. X
  1241. X
  1242. int
  1243. modem_write (char *s)
  1244. X{
  1245. X    char    ch, *cp;
  1246. X    for (cp = s; *cp; cp++)
  1247. X    {
  1248. X        switch (*cp)
  1249. X        {
  1250. X            case '~':
  1251. X                timeout (1);
  1252. X                continue;
  1253. X            case '#':
  1254. X                xon8250_dtnr ();
  1255. X                continue;
  1256. X            case '^':
  1257. X                ch = *++cp;
  1258. X                ch = toupper (ch) - '@';
  1259. X                while (xon8250_write (ch) == -1)
  1260. X                    ;
  1261. X                break;
  1262. X            case '\\':
  1263. X                switch (ch = *++cp)
  1264. X                {
  1265. X                    case 'e':
  1266. X                        ch = 0x1b;
  1267. X                        break;
  1268. X                    case 'r':
  1269. X                        ch = '\r';
  1270. X                        break;
  1271. X                    case 'n':
  1272. X                        ch = '\n';
  1273. X                        break;
  1274. X                    case 'b':
  1275. X                        ch = '\b';
  1276. X                        break;
  1277. X                    case 'a':
  1278. X                        ch = '\a';
  1279. X                        break;
  1280. X                    case 'f':
  1281. X                        ch = '\f';
  1282. X                        break;
  1283. X                    default:
  1284. X                        break;
  1285. X                }
  1286. X                while (xon8250_write (ch) == -1)
  1287. X                    ;
  1288. X                break;
  1289. X            default:
  1290. X                while (xon8250_write (*cp) == -1)
  1291. X                    ;
  1292. X                break;
  1293. X        }
  1294. X    }
  1295. X}
  1296. X
  1297. void
  1298. usage (void)
  1299. X{
  1300. X    fputs ("MDM_INIT:\n", stderr);
  1301. X    fputs ("Use the following command line options.\n\n", stderr);
  1302. X    fputs ("   -C[1 or 2] Com Port 1 or 2      {Default Com Port 1}\n", stderr);
  1303. X    fputs ("   -B[300 600 1200 2400 4800 9600] {Default 9600 Baud}\n", stderr);
  1304. X    fputs ("   -D[7 or 8]  Data Bits           {Default 8}\n", stderr);
  1305. X    fputs ("   -S[1 or 2] Stop Bits            {Default 1}\n", stderr);
  1306. X    fputs ("   -P[E O or N] Parity             {Default None}\n\n", stderr);
  1307. X    fputs ("   -b2400 -pn -s1 -d8 -c1\n\n", stderr);
  1308. X    fputs ("If any port options are set then the port will be left\n", stderr);
  1309. X    fputs ("in that state when the program exits, otherwise we just\n", stderr);
  1310. X    fputs (" enable the port and blast the strings we are passed to it\n\n", stderr);
  1311. X    exit (1);
  1312. X}
  1313. X
  1314. END_OF_FILE
  1315. if test 4503 -ne `wc -c <'mdm_init.c'`; then
  1316.     echo shar: \"'mdm_init.c'\" unpacked with wrong size!
  1317. fi
  1318. # end of 'mdm_init.c'
  1319. fi
  1320. if test -f 'monitor.c' -a "${1}" != "-c" ; then 
  1321.   echo shar: Will not clobber existing file \"'monitor.c'\"
  1322. else
  1323. echo shar: Extracting \"'monitor.c'\" \(2509 characters\)
  1324. sed "s/^X//" >'monitor.c' <<'END_OF_FILE'
  1325. X/*
  1326. X *                                MONITOR.C
  1327. X *
  1328. X *              A simple-Minded little Serial Port Monitor
  1329. X *
  1330. X *                           Written for the
  1331. X *
  1332. X *                              Datalight
  1333. X *                           Microsoft V 5.x
  1334. X *                                TurboC
  1335. X *                                  &
  1336. X *                               Zortech
  1337. X *
  1338. X *                             C Compilers
  1339. X *
  1340. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  1341. X */
  1342. X
  1343. X#include <stdio.h>
  1344. X#include "8250xon.h"
  1345. X#include "monitor.h"
  1346. X#include "options.h"
  1347. X#include "_kb.h"
  1348. X
  1349. X#define EOT 4
  1350. X#define ETX 3
  1351. X#define TRUE (1)
  1352. X#define FALSE (0)
  1353. X#if (!defined (DLC))
  1354. extern int cb_happened;
  1355. X#endif
  1356. X
  1357. main (argc, argv)
  1358. int     argc;
  1359. char  **argv;
  1360. X{
  1361. X    int     ch;
  1362. X    int     i;
  1363. X
  1364. X    set_options (argc, argv);
  1365. X    trap_ctrl_break ();
  1366. X    timer_init ();
  1367. X    xon8250_init (Port, 8192);
  1368. X    fputs ("                  --  Monitor - RS232 Port Snooper  --\n", stdout);
  1369. X    if (Cfg_Str [0])
  1370. X    {
  1371. X        xon8250_port_init (Cfg_Str);
  1372. X        fputs (Opt_Msg, stdout);
  1373. X    }
  1374. X    else
  1375. X    {
  1376. X        xon8250_port_enable ();
  1377. X        fputs ("Using Default Port Settings\n", stdout);
  1378. X    }
  1379. X    fputs ("Use <Alt>F10 to exit\n", stdout);
  1380. X
  1381. X    while (TRUE)
  1382. X    {
  1383. X        if ((ch = xon8250_read ()) != -1)
  1384. X        {
  1385. X            xlate ((char) ch);
  1386. X        }
  1387. X        if ((ch = _kb ()) != -1)
  1388. X        {
  1389. X            if (ch == APF10)
  1390. X            {
  1391. X                xon8250_term ((Cfg_Str [0])?1:0);
  1392. X                timer_term ();
  1393. X                release_ctrl_break ();
  1394. X                exit (0);
  1395. X            }
  1396. X            xon8250_write (ch);
  1397. X        }
  1398. X    }
  1399. X}
  1400. X
  1401. X
  1402. X
  1403. int 
  1404. xlate (char c)
  1405. X{
  1406. X    static int lcnt = 0;
  1407. X    static char *x_table[] = {
  1408. X                     "<NUL>", "<SOH>", "<STX>", "<ETX>", "<EOT>", "<ENQ>",
  1409. X                         "<ACK>", "<BEL>", "<BS>", "<HT>", "<LF>", "<VT>",
  1410. X                         "<FF>", "<CR>", "<SO>", "<SI>", "<DLE>", "<DC1>",
  1411. X                     "<DC2>", "<DC3>", "<DC4>", "<NAK>", "<SYN>", "<ETB>",
  1412. X                        "<CAN>", "<EM>", "<SUB>", "<ESC>", "<FS>", "<GS>",
  1413. X                              "<RS>", "<US>"
  1414. X    };
  1415. X
  1416. X    if (c < 32)
  1417. X    {
  1418. X        if (c == EOT)
  1419. X        {
  1420. X            putchar ('\n');
  1421. X            lcnt = 0;
  1422. X        }
  1423. X        myputs (x_table[c]);
  1424. X        lcnt += strlen (x_table[c]);
  1425. X    }
  1426. X    else
  1427. X    {
  1428. X        putchar (c);
  1429. X        lcnt += 1;
  1430. X    }
  1431. X    if (lcnt > 79)
  1432. X    {
  1433. X        putchar ('\n');
  1434. X        lcnt = 0;
  1435. X    }
  1436. X    fflush (stdout);
  1437. X}
  1438. X
  1439. int 
  1440. myputs (s)
  1441. char   *s;
  1442. X{
  1443. X    while (*s)
  1444. X        putchar (*s++);
  1445. X}
  1446. END_OF_FILE
  1447. if test 2509 -ne `wc -c <'monitor.c'`; then
  1448.     echo shar: \"'monitor.c'\" unpacked with wrong size!
  1449. fi
  1450. # end of 'monitor.c'
  1451. fi
  1452. if test -f 'monitor.h' -a "${1}" != "-c" ; then 
  1453.   echo shar: Will not clobber existing file \"'monitor.h'\"
  1454. else
  1455. echo shar: Extracting \"'monitor.h'\" \(570 characters\)
  1456. sed "s/^X//" >'monitor.h' <<'END_OF_FILE'
  1457. X/*
  1458. X *                              MONITOR.H
  1459. X *
  1460. X *                           Written for the
  1461. X *
  1462. X *                              Datalight
  1463. X *                           Microsoft V 5.x
  1464. X *                                TurboC
  1465. X *                                  &
  1466. X *                               Zortech
  1467. X *
  1468. X *                             C Compilers
  1469. X *
  1470. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  1471. X */
  1472. X# ifdef LINT
  1473. extern int xlate (char);
  1474. extern int myputs (char *);
  1475. extern int good_baud (char *);
  1476. extern int usage (void);
  1477. extern int exit (...);
  1478. X# endif
  1479. END_OF_FILE
  1480. if test 570 -ne `wc -c <'monitor.h'`; then
  1481.     echo shar: \"'monitor.h'\" unpacked with wrong size!
  1482. fi
  1483. # end of 'monitor.h'
  1484. fi
  1485. if test -f 'msc.asm' -a "${1}" != "-c" ; then 
  1486.   echo shar: Will not clobber existing file \"'msc.asm'\"
  1487. else
  1488. echo shar: Extracting \"'msc.asm'\" \(1140 characters\)
  1489. sed "s/^X//" >'msc.asm' <<'END_OF_FILE'
  1490. X_TEXT    SEGMENT  WORD PUBLIC 'CODE'
  1491. X_TEXT    ENDS
  1492. X_DATA    SEGMENT  WORD PUBLIC 'DATA'
  1493. X_DATA    ENDS
  1494. CONST    SEGMENT  WORD PUBLIC 'CONST'
  1495. CONST    ENDS
  1496. X_BSS    SEGMENT  WORD PUBLIC 'BSS'
  1497. X_BSS    ENDS
  1498. DGROUP    GROUP    CONST, _BSS, _DATA
  1499. X    ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP
  1500. X_TEXT      SEGMENT
  1501. X    ASSUME    CS: _TEXT
  1502. X
  1503. X    PUBLIC    _peekmem
  1504. X_peekmem    PROC NEAR
  1505. X    push    bp
  1506. X    mov    bp,sp
  1507. X    push    es
  1508. X    push     bx
  1509. X    push    si
  1510. X    mov    bx,WORD PTR [bp+4]    ;seg
  1511. X    mov    es, bx
  1512. X    mov    bx, WORD PTR [bp+6]    ;off
  1513. X    mov    si, bx
  1514. X    mov    bx,WORD PTR [bp+8]    ;var
  1515. X    mov    ax,WORD PTR es:[si]
  1516. X    mov    WORD PTR [bx],ax
  1517. X    pop    si
  1518. X    pop    bx
  1519. X    pop    es
  1520. X    pop    bp
  1521. X    ret    
  1522. X_peekmem    ENDP
  1523. X
  1524. X
  1525. X
  1526. X
  1527. X    PUBLIC    _inbyte
  1528. X_inbyte    PROC NEAR
  1529. X    push    bp
  1530. X    mov    bp,sp
  1531. X    push    dx
  1532. X    mov    dx, [bp+4]
  1533. X    in    al, dx
  1534. X    mov    ah, 0
  1535. X    pop    dx
  1536. X    pop    bp
  1537. X    ret    
  1538. X_inbyte    ENDP
  1539. X
  1540. X
  1541. X    PUBLIC    _outbyte
  1542. X_outbyte    PROC NEAR
  1543. X    push    bp
  1544. X    mov    bp,sp
  1545. X    push    dx
  1546. X    mov    dx, [bp+4]
  1547. X    mov    ax, [bp+6]
  1548. X    out    dx, al
  1549. X    pop    dx
  1550. X    pop    bp
  1551. X    ret    
  1552. X_outbyte    ENDP
  1553. X
  1554. X
  1555. X    PUBLIC    __kbhit
  1556. X__kbhit        PROC    near
  1557. X    mov    ah, 1
  1558. X    int    16h
  1559. X    jz    kbnothit
  1560. X    mov    ax, 1
  1561. X    ret
  1562. kbnothit:
  1563. X    mov    ax, 0
  1564. X    ret
  1565. X__kbhit        ENDP
  1566. X    
  1567. X
  1568. X    PUBLIC    _enable
  1569. X_enable    PROC NEAR
  1570. X    sti
  1571. X    ret    
  1572. X_enable    ENDP
  1573. X
  1574. X
  1575. X
  1576. X
  1577. X    PUBLIC    _disable
  1578. X_disable    PROC NEAR
  1579. X    cli
  1580. X    ret    
  1581. X_disable    ENDP
  1582. X_TEXT    ENDS
  1583. XEND
  1584. END_OF_FILE
  1585. if test 1140 -ne `wc -c <'msc.asm'`; then
  1586.     echo shar: \"'msc.asm'\" unpacked with wrong size!
  1587. fi
  1588. # end of 'msc.asm'
  1589. fi
  1590. if test -f 'options.h' -a "${1}" != "-c" ; then 
  1591.   echo shar: Will not clobber existing file \"'options.h'\"
  1592. else
  1593. echo shar: Extracting \"'options.h'\" \(515 characters\)
  1594. sed "s/^X//" >'options.h' <<'END_OF_FILE'
  1595. X/*
  1596. X *                              OPTIONS.H
  1597. X *
  1598. X *                           Written for the
  1599. X *
  1600. X *                              Datalight
  1601. X *                           Microsoft V 5.x
  1602. X *                                TurboC
  1603. X *                                  &
  1604. X *                               Zortech
  1605. X *
  1606. X *                             C Compilers
  1607. X *
  1608. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  1609. X */
  1610. X
  1611. X extern char Cfg_Str [], Opt_Msg [];
  1612. X extern int  Port;
  1613. X extern void set_options (int, char **);
  1614. END_OF_FILE
  1615. if test 515 -ne `wc -c <'options.h'`; then
  1616.     echo shar: \"'options.h'\" unpacked with wrong size!
  1617. fi
  1618. # end of 'options.h'
  1619. fi
  1620. if test -f 'printer.c' -a "${1}" != "-c" ; then 
  1621.   echo shar: Will not clobber existing file \"'printer.c'\"
  1622. else
  1623. echo shar: Extracting \"'printer.c'\" \(917 characters\)
  1624. sed "s/^X//" >'printer.c' <<'END_OF_FILE'
  1625. X/*
  1626. X *                             PRINTER.C
  1627. X *
  1628. X *                           Written for the
  1629. X *
  1630. X *                              Datalight
  1631. X *                           Microsoft V 5.x
  1632. X *                                TurboC
  1633. X *                                  &
  1634. X *                               Zortech
  1635. X *
  1636. X *                             C Compilers
  1637. X *
  1638. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  1639. X *
  1640. X * Output a character to the printer port using software interrupt
  1641. X * 0x17.  Returns -1 if unsuccessful, 0 otherwise.
  1642. X *
  1643. X * Usage while (print_char (ch));
  1644. X */
  1645. X#include <dos.h>
  1646. X#include "printer.h"
  1647. X
  1648. int 
  1649. print_char (ch)
  1650. char    ch;
  1651. X{
  1652. X    char    flag;
  1653. X    union REGS regs;
  1654. X
  1655. X    regs.x.dx = 0;
  1656. X    regs.h.ah = 2;
  1657. X    int86 (0x17, ®s, ®s);
  1658. X    if (regs.h.ah != PR_SELECTED)
  1659. X        return regs.h.ah;
  1660. X    regs.x.dx = regs.h.ah = 0;
  1661. X    regs.h.al = ch;
  1662. X    int86 (0x17, ®s, ®s);
  1663. X    return 0;
  1664. X}
  1665. END_OF_FILE
  1666. if test 917 -ne `wc -c <'printer.c'`; then
  1667.     echo shar: \"'printer.c'\" unpacked with wrong size!
  1668. fi
  1669. # end of 'printer.c'
  1670. fi
  1671. if test -f 'printer.h' -a "${1}" != "-c" ; then 
  1672.   echo shar: Will not clobber existing file \"'printer.h'\"
  1673. else
  1674. echo shar: Extracting \"'printer.h'\" \(1083 characters\)
  1675. sed "s/^X//" >'printer.h' <<'END_OF_FILE'
  1676. X/*
  1677. X *                             PRINTER.H
  1678. X *
  1679. X *                           Written for the
  1680. X *
  1681. X *                              Datalight
  1682. X *                           Microsoft V 5.x
  1683. X *                                TurboC
  1684. X *                                  &
  1685. X *                               Zortech
  1686. X *
  1687. X *                             C Compilers
  1688. X *
  1689. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  1690. X *
  1691. X * Output a character to the printer port using software interrupt
  1692. X * 0x17.  Returns !0 if unsuccessful, 0 otherwise.
  1693. X *
  1694. X * Usage while (print_char (ch));
  1695. X */
  1696. X
  1697. X#define PR_SELECTED 0x90
  1698. X
  1699. X/*
  1700. X *      flag returned   7 6 5 4 3 2 1 0
  1701. X *                      | | | | | | | |-------  Time out
  1702. X *                      | | | | | | |---------  
  1703. X *                      | | | | | |-----------
  1704. X *                      | | | | |-------------  IO error
  1705. X *                      | | | |---------------  Selected
  1706. X *                      | | |-----------------  Out of paper
  1707. X *                      | |-------------------  
  1708. X *            |---------------------    Busy
  1709. X */
  1710. X
  1711. int  print_char (char);
  1712. END_OF_FILE
  1713. if test 1083 -ne `wc -c <'printer.h'`; then
  1714.     echo shar: \"'printer.h'\" unpacked with wrong size!
  1715. fi
  1716. # end of 'printer.h'
  1717. fi
  1718. if test -f 'queue.c' -a "${1}" != "-c" ; then 
  1719.   echo shar: Will not clobber existing file \"'queue.c'\"
  1720. else
  1721. echo shar: Extracting \"'queue.c'\" \(1374 characters\)
  1722. sed "s/^X//" >'queue.c' <<'END_OF_FILE'
  1723. X/*
  1724. X *                               QUEUE.C
  1725. X *
  1726. X *                        Queue Handling Module
  1727. X *
  1728. X *                           Written for the
  1729. X *
  1730. X *                              Datalight
  1731. X *                           Microsoft V 5.x
  1732. X *                                TurboC
  1733. X *                                  &
  1734. X *                               Zortech
  1735. X *
  1736. X *                             C Compilers
  1737. X *
  1738. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  1739. X */
  1740. X
  1741. X#include "queue.h"
  1742. X
  1743. X/*
  1744. X *    QUEUE routines to allocate - enqueue - dequeue elements to a queue
  1745. X */
  1746. X
  1747. QUEUE  *
  1748. alloc_queue (int size)
  1749. X{
  1750. X    QUEUE  *tmp;
  1751. X    if ((tmp = (QUEUE *) malloc (sizeof (QUEUE) + size)) != (QUEUE *) 0)
  1752. X    {
  1753. X        tmp->size = size;
  1754. X        tmp->head = 0;
  1755. X        tmp->tail = 0;
  1756. X        tmp->avail = size;
  1757. X        tmp->buf = ((char *) tmp) + sizeof (QUEUE);
  1758. X    }
  1759. X    return (tmp);
  1760. X}
  1761. X
  1762. X
  1763. X
  1764. int 
  1765. en_queue (QUEUE *qp, char ch)
  1766. X{
  1767. X    int     head = qp->head;
  1768. X
  1769. X    if (qp->avail == 0)
  1770. X        return (-1);
  1771. X    *(qp->buf + head) = ch;
  1772. X    if (++head == qp->size)
  1773. X        head = 0;
  1774. X    qp->head = head;
  1775. X    --(qp->avail);
  1776. X    return (qp->avail);
  1777. X}
  1778. X
  1779. int 
  1780. de_queue (QUEUE *qp)
  1781. X{
  1782. X    int     tail = qp->tail, ch;
  1783. X
  1784. X    if (qp->avail == qp->size)
  1785. X        return (-1);
  1786. X    ch = *(qp->buf + tail);
  1787. X    if (++tail == qp->size)
  1788. X        tail = 0;
  1789. X    qp->tail = tail;
  1790. X    qp->avail++;
  1791. X    return (ch);
  1792. X}
  1793. END_OF_FILE
  1794. if test 1374 -ne `wc -c <'queue.c'`; then
  1795.     echo shar: \"'queue.c'\" unpacked with wrong size!
  1796. fi
  1797. # end of 'queue.c'
  1798. fi
  1799. if test -f 'queue.h' -a "${1}" != "-c" ; then 
  1800.   echo shar: Will not clobber existing file \"'queue.h'\"
  1801. else
  1802. echo shar: Extracting \"'queue.h'\" \(788 characters\)
  1803. sed "s/^X//" >'queue.h' <<'END_OF_FILE'
  1804. X/*
  1805. X *                               QUEUE.H
  1806. X *
  1807. X *                           Written for the
  1808. X *
  1809. X *                              Datalight
  1810. X *                           Microsoft V 5.x
  1811. X *                                TurboC
  1812. X *                                  &
  1813. X *                               Zortech
  1814. X *
  1815. X *                             C Compilers
  1816. X *
  1817. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  1818. X */
  1819. X
  1820. typedef struct {
  1821. X    int    size,
  1822. X        head,
  1823. X        tail,
  1824. X        avail;
  1825. X    char *buf;
  1826. X} QUEUE;
  1827. X
  1828. X# define queue_empty(qp) (qp)->head==(qp)->tail
  1829. X# define queue_avail(qp) (qp)->avail
  1830. X
  1831. X# ifndef LINT
  1832. X    extern QUEUE *alloc_queue ();
  1833. X    extern int en_queue ();
  1834. X    extern de_queue ();
  1835. X# else
  1836. X    extern QUEUE *alloc_queue (int);
  1837. X    extern int en_queue (QUEUE *, char);
  1838. X    extern int de_queue (QUEUE *);
  1839. X# endif
  1840. END_OF_FILE
  1841. if test 788 -ne `wc -c <'queue.h'`; then
  1842.     echo shar: \"'queue.h'\" unpacked with wrong size!
  1843. fi
  1844. # end of 'queue.h'
  1845. fi
  1846. if test -f 'screen.h' -a "${1}" != "-c" ; then 
  1847.   echo shar: Will not clobber existing file \"'screen.h'\"
  1848. else
  1849. echo shar: Extracting \"'screen.h'\" \(1502 characters\)
  1850. sed "s/^X//" >'screen.h' <<'END_OF_FILE'
  1851. X/*
  1852. X *                              SCREEN.H
  1853. X *
  1854. X *                         Screen i/o Handler
  1855. X *
  1856. X *                           Written for the
  1857. X *
  1858. X *                              Datalight
  1859. X *                           Microsoft V 5.x
  1860. X *                                TurboC
  1861. X *                                  &
  1862. X *                               Zortech
  1863. X *
  1864. X *                             C Compilers
  1865. X *
  1866. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  1867. X */
  1868. X
  1869. extern int  Scr_Cols;
  1870. extern int  Scr_Rows;
  1871. extern char Scr_Window_Top;
  1872. extern char Scr_Page;
  1873. extern char Scr_ATTR;
  1874. X
  1875. X/*
  1876. X *    The screen attributes can be
  1877. X *
  1878. X *           UnderLine OR Reverse OR Normal
  1879. X *
  1880. X *    BRIGHT - BLINK are additional attributes applied to the above
  1881. X */
  1882. X
  1883. X#if (!defined (SCREEN_ATTRIB))
  1884. X#    define SCR_ATTRIB    1
  1885. X#    define SECURE     0x77
  1886. X#    define REVERSE    0x70
  1887. X#    define NORMAL        7
  1888. X#    define UNDERLINE     1
  1889. X#    define BLINK      0x80
  1890. X#    define BRIGHT        9
  1891. X#    define INVERSE_UL (UNDERLINE | INVERSE)
  1892. X#endif
  1893. X
  1894. X# ifdef LINT
  1895. extern int _kb (void);
  1896. extern int screen_init (void);
  1897. extern int screen_smode (char);
  1898. extern int rowcol (int, int);
  1899. extern int g_rowcol (void);
  1900. extern int clrscrn (void);
  1901. extern int cleol (void);
  1902. extern int cleop (void);
  1903. extern int scroll_up (int, int, int, int, int);
  1904. extern int scroll_dn (int, int, int, int, int);
  1905. extern int screen_co (char);
  1906. extern int sinp (void);
  1907. extern int cursor_off (void);
  1908. extern int cursor_on (void);
  1909. extern int aputs (int, char *);
  1910. extern int aput (int, char);
  1911. X# endif
  1912. END_OF_FILE
  1913. if test 1502 -ne `wc -c <'screen.h'`; then
  1914.     echo shar: \"'screen.h'\" unpacked with wrong size!
  1915. fi
  1916. # end of 'screen.h'
  1917. fi
  1918. if test -f 'timer.c' -a "${1}" != "-c" ; then 
  1919.   echo shar: Will not clobber existing file \"'timer.c'\"
  1920. else
  1921. echo shar: Extracting \"'timer.c'\" \(3201 characters\)
  1922. sed "s/^X//" >'timer.c' <<'END_OF_FILE'
  1923. X/*
  1924. X *                               TIMER.C
  1925. X *
  1926. X *                           Written for the
  1927. X *
  1928. X *                              Datalight
  1929. X *                           Microsoft V 5.x
  1930. X *                                TurboC
  1931. X *                                  &
  1932. X *                               Zortech
  1933. X *
  1934. X *                             C Compilers
  1935. X *
  1936. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  1937. X *
  1938. X *    The timer routines used here are little approximations
  1939. X *    since the Timer Interrupt ( 0x1C ) is only updated 18
  1940. X *  times a second.
  1941. X *
  1942. X *    The routines are NOT bulletproof - if you decide to use
  1943. X *    them I would heartily suggest you include a 
  1944. X *    Control Break (Interrupt 0x23) intercept routine
  1945. X *    to allow for cleanup before Going South...
  1946. X *
  1947. X *    There are basically three routines which you call
  1948. X *        timer_init () - sets up the timer interrupt vector
  1949. X *                        (the interrupt handler is imbedded in
  1950. X *                         there somewhere).
  1951. X *
  1952. X *        timer_set () -  sets the timer counter to 0
  1953. X *
  1954. X *        timer_read () - returns the current value of the timer
  1955. X *                        counter.
  1956. X *
  1957. X *        timer_term () - a 'Must Do' - clean up our act and give
  1958. X *                        the interrupt vector back
  1959. X */
  1960. X#include "dependnt.h"
  1961. X
  1962. X#if (!defined (TRUE))
  1963. X#    define TRUE  (1)
  1964. X#    define FALSE (0)
  1965. X#endif
  1966. X
  1967. volatile unsigned long int _Timer_cnt;
  1968. static int _Timer_Active = 0;
  1969. X
  1970. X#if (defined (DLC))
  1971. int 
  1972. Timer_ISR ()
  1973. X{
  1974. X    _Timer_cnt++;
  1975. X    return (0);
  1976. X}
  1977. X#else
  1978. void    (interrupt far * timer_save_vec) (void);
  1979. void interrupt far 
  1980. Timer_ISR (void)
  1981. X{
  1982. X    _Timer_cnt++;
  1983. X    (*timer_save_vec) ();
  1984. X}
  1985. X#endif
  1986. X
  1987. X
  1988. X
  1989. X/*
  1990. X *    TIMER_INIT
  1991. X */
  1992. X
  1993. int 
  1994. timer_init ()
  1995. X{
  1996. X    if (!_Timer_Active)
  1997. X    {
  1998. X#if (defined (DLC))
  1999. X        int_intercept (0x1C, &Timer_ISR, 128);
  2000. X#else
  2001. X        timer_save_vec = getvect (0x1c);
  2002. X        setvect (0x1C, Timer_ISR);
  2003. X#endif
  2004. X        _Timer_Active = TRUE;
  2005. X    }
  2006. X}
  2007. X
  2008. X
  2009. X
  2010. X/*
  2011. X *    TIMER_TERM
  2012. X */
  2013. X
  2014. int 
  2015. timer_term ()
  2016. X{
  2017. X    if (_Timer_Active)
  2018. X    {
  2019. X#if (defined (DLC))
  2020. X        int_restore (0x1C);
  2021. X#else
  2022. X        setvect (0x1C, timer_save_vec);
  2023. X#endif
  2024. X        _Timer_Active = FALSE;
  2025. X    }
  2026. X}
  2027. X
  2028. X
  2029. X
  2030. X/*
  2031. X *    TIMER_SET
  2032. X */
  2033. X
  2034. int 
  2035. timer_set ()
  2036. X{
  2037. X    _Timer_cnt = 0L;
  2038. X}
  2039. X
  2040. X
  2041. X
  2042. X/*
  2043. X *    TIMER_READ
  2044. X */
  2045. X
  2046. unsigned long int 
  2047. timer_read ()
  2048. X{
  2049. X    return (_Timer_cnt);
  2050. X}
  2051. X
  2052. X
  2053. X
  2054. X
  2055. X/*
  2056. X *    TIMEOUT - go away for the specified number of seconds
  2057. X */
  2058. X
  2059. int 
  2060. timeout (sec)
  2061. unsigned int sec;
  2062. X{
  2063. X    unsigned long int flag;
  2064. X    sec *= 18;
  2065. X    _Timer_cnt = 0L;
  2066. X    do
  2067. X    {
  2068. X        flag = _Timer_cnt;
  2069. X    } while (flag < sec);
  2070. X}
  2071. X
  2072. static unsigned int DELAY_millisecond;
  2073. void
  2074. DELAY_init (void)
  2075. X{
  2076. X    static int d_init = 0;
  2077. X    int        tna = 0;
  2078. X    long    l;
  2079. X    if (d_init)
  2080. X        return;
  2081. X    d_init = 1;
  2082. X    if (!_Timer_Active)
  2083. X    {
  2084. X        timer_init ();
  2085. X        tna = 1;
  2086. X    }
  2087. X    timer_init ();
  2088. X    timer_set ();
  2089. X    while (timer_read () == 0L)
  2090. X        ;
  2091. X    timer_set ();
  2092. X    for (l = 0L; l != -1L; l++)
  2093. X        if (timer_read () == 3)
  2094. X            break;
  2095. X    l *= 197;
  2096. X    DELAY_millisecond = (int) ((l + 5000) / 10000);
  2097. X    if (tna)
  2098. X        timer_term ();
  2099. X}
  2100. static unsigned int _DELAY_cnt, _DELAY_ix;
  2101. X
  2102. int 
  2103. DELAY_loop (int msc)
  2104. X{
  2105. X    for (_DELAY_ix = 0; _DELAY_ix < msc; _DELAY_ix++)
  2106. X        for (_DELAY_cnt = 0; _DELAY_cnt < DELAY_millisecond; _DELAY_cnt++)
  2107. X            ;
  2108. X    return (msc);
  2109. X}
  2110. END_OF_FILE
  2111. if test 3201 -ne `wc -c <'timer.c'`; then
  2112.     echo shar: \"'timer.c'\" unpacked with wrong size!
  2113. fi
  2114. # end of 'timer.c'
  2115. fi
  2116. if test -f 'timer.h' -a "${1}" != "-c" ; then 
  2117.   echo shar: Will not clobber existing file \"'timer.h'\"
  2118. else
  2119. echo shar: Extracting \"'timer.h'\" \(717 characters\)
  2120. sed "s/^X//" >'timer.h' <<'END_OF_FILE'
  2121. X/*
  2122. X *                               TIMER.H
  2123. X *
  2124. X *                           Written for the
  2125. X *
  2126. X *                              Datalight
  2127. X *                           Microsoft V 5.x
  2128. X *                                TurboC
  2129. X *                                  &
  2130. X *                               Zortech
  2131. X *
  2132. X *                             C Compilers
  2133. X *
  2134. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  2135. X */
  2136. X
  2137. X# ifndef LINT 
  2138. X    extern unsigned long int timer_read ();
  2139. X# else
  2140. X    int timer_init (void);
  2141. X    extern int timer_term (void);
  2142. X    extern int timer_set (void);
  2143. X    extern unsigned long int timer_read (void);
  2144. X    extern int timeout (unsigned int);
  2145. X    extern void DELAY_init (void);
  2146. X    extern int  DELAY_loop (int);
  2147. X# endif
  2148. END_OF_FILE
  2149. if test 717 -ne `wc -c <'timer.h'`; then
  2150.     echo shar: \"'timer.h'\" unpacked with wrong size!
  2151. fi
  2152. # end of 'timer.h'
  2153. fi
  2154. if test -f 'tkb.c' -a "${1}" != "-c" ; then 
  2155.   echo shar: Will not clobber existing file \"'tkb.c'\"
  2156. else
  2157. echo shar: Extracting \"'tkb.c'\" \(391 characters\)
  2158. sed "s/^X//" >'tkb.c' <<'END_OF_FILE'
  2159. X/*
  2160. X *                                TKB.C
  2161. X *
  2162. X *                  Keyboard input test driver program
  2163. X */
  2164. X
  2165. X#include <stdio.h>
  2166. X#include "_kb.h"
  2167. X
  2168. X#if (!defined (TRUE))
  2169. X#    define TRUE  (1)
  2170. X#    define FALSE (0)
  2171. X#endif
  2172. X
  2173. main ()
  2174. X{
  2175. X    int     i;
  2176. X    while (TRUE)
  2177. X    {
  2178. X        while ((i = _kb ()) == -1);
  2179. X        if (i == 'q')
  2180. X            break;
  2181. X        printf ("_KB () = (%d) [%c]\n", i, i);
  2182. X    }
  2183. X}
  2184. END_OF_FILE
  2185. if test 391 -ne `wc -c <'tkb.c'`; then
  2186.     echo shar: \"'tkb.c'\" unpacked with wrong size!
  2187. fi
  2188. # end of 'tkb.c'
  2189. fi
  2190. if test -f 'version.h' -a "${1}" != "-c" ; then 
  2191.   echo shar: Will not clobber existing file \"'version.h'\"
  2192. else
  2193. echo shar: Extracting \"'version.h'\" \(811 characters\)
  2194. sed "s/^X//" >'version.h' <<'END_OF_FILE'
  2195. X/*
  2196. X *                              VERSION.H
  2197. X *
  2198. X *                           Written for the
  2199. X *
  2200. X *                              Datalight
  2201. X *                           Microsoft V 5.x
  2202. X *                                TurboC
  2203. X *                                  &
  2204. X *                               Zortech
  2205. X *
  2206. X *                             C Compilers
  2207. X *
  2208. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  2209. X *
  2210. X *    Nothing but the current version of Laser.com
  2211. X *
  2212. X *                         Previous Versions
  2213. X *    char Version [] = "1.0 - 21 Apr '88";         First assigned version
  2214. X *    Added Contention Mode to the Poll Select Protocol
  2215. X *    char Version [] = "1.1 - 13 May '88";         First assigned version
  2216. X */
  2217. X
  2218. X/*
  2219. X * Setup for ZTC, TurboC and Microsoft C Compilers
  2220. X */
  2221. char Version [] = "2.0 - 28 Sep '89";
  2222. X
  2223. END_OF_FILE
  2224. if test 811 -ne `wc -c <'version.h'`; then
  2225.     echo shar: \"'version.h'\" unpacked with wrong size!
  2226. fi
  2227. # end of 'version.h'
  2228. fi
  2229. if test -f 'vt100.h' -a "${1}" != "-c" ; then 
  2230.   echo shar: Will not clobber existing file \"'vt100.h'\"
  2231. else
  2232. echo shar: Extracting \"'vt100.h'\" \(808 characters\)
  2233. sed "s/^X//" >'vt100.h' <<'END_OF_FILE'
  2234. X/*
  2235. X *                               VT100.H
  2236. X *
  2237. X *                           Written for the
  2238. X *
  2239. X *                              Datalight
  2240. X *                           Microsoft V 5.x
  2241. X *                                TurboC
  2242. X *                                  &
  2243. X *                               Zortech
  2244. X *
  2245. X *                             C Compilers
  2246. X *
  2247. X *            Copyright (c) John Birchfield 1987, 1988, 1989
  2248. X */
  2249. X#if (!defined (SCREEN_ATTRIB))
  2250. X#    define SCR_ATTRIB    1
  2251. X#    define BLINK      0x80
  2252. X#    define BRIGHT        9
  2253. X#    define INVERSE    0x70
  2254. X#    define NORMAL         7
  2255. X#    define UNDERLINE     1
  2256. X/* #define UNDERLINE 0x71 */
  2257. X#endif
  2258. X#if (!defined (STANDALONE))
  2259. extern char Duplex [2], RubOut [2],
  2260. X            BackSpace [2],
  2261. X            Cmask  [2], CrLf   [2];
  2262. extern void vt100_driver (), VT100_init ();
  2263. X#endif
  2264. END_OF_FILE
  2265. if test 808 -ne `wc -c <'vt100.h'`; then
  2266.     echo shar: \"'vt100.h'\" unpacked with wrong size!
  2267. fi
  2268. # end of 'vt100.h'
  2269. fi
  2270. echo shar: End of archive 1 \(of 3\).
  2271. cp /dev/null ark1isdone
  2272. MISSING=""
  2273. for I in 1 2 3 ; do
  2274.     if test ! -f ark${I}isdone ; then
  2275.     MISSING="${MISSING} ${I}"
  2276.     fi
  2277. done
  2278. if test "${MISSING}" = "" ; then
  2279.     echo You have unpacked all 3 archives.
  2280.     rm -f ark[1-9]isdone
  2281. else
  2282.     echo You still need to unpack the following archives:
  2283.     echo "        " ${MISSING}
  2284. fi
  2285. ##  End of shell archive.
  2286. exit 0
  2287. +----------------------
  2288. | John Birchfield      
  2289. | jb@altair.csustan.edu
  2290. +----------------------
  2291.  
  2292.  
  2293.