home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / modem / cvt100.zip / CVT100.DOC < prev    next >
Text File  |  1988-08-06  |  17KB  |  727 lines

  1.  
  2.                      CVT100, Terminal Emulator for Turbo C
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.                  VT100, A Simple VT100 Emulator in Turbo C 1.5
  25.                         By Jerry Joplin CIS [70441,2627]
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.                      CVT100, Terminal Emulator for Turbo C
  69.  
  70.  
  71.                                     Overview
  72.  
  73.  
  74.               CVT100 is a simple VT100 emulator programed exclusively
  75.          in Turbo C 1.5.   *All* of the code is in Turbo C.  There are
  76.          no assembler routines or functions requiring an assembler.
  77.          All of the code is contained in 7 modules.  These are:
  78.  
  79.               comio.c       communications functions
  80.               cvt100.c      terminal emulator main
  81.               fileio.c      file manipulation functions
  82.               keyio.c       keyboard functions
  83.               vidio.c       video functions
  84.               vtsetup.c     setup functions
  85.               vttio.c       terminal output interpretation functions
  86.  
  87.          The program was designed with several objectives in mind.
  88.  
  89.               1)  To provide a public domain source for a VT100
  90.                   emulator written in Turbo C code that was easy to
  91.                   understand and modify,
  92.  
  93.               2)  To show the power and flexibility of Turbo C without
  94.                   having to resort to assembly language routines,
  95.  
  96.               3)  To aid (however slightly) in the development of a C
  97.                   version of Kermit for MS DOS systems,
  98.  
  99.               4)  To provide a terminal emulator that takes a very
  100.                   small amount of memory and is capable of running in
  101.                   a well behaved window in Windows or DesqView (less
  102.                   than 40k).
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.                      CVT100, Terminal Emulator for Turbo C
  135.  
  136.  
  137.                                    Operation
  138.  
  139.               The terminal emulator is menu driven.  The top line of
  140.          the terminal screen is reserved as a status line.  A list of
  141.          choices is displayed on the status line for setting the
  142.          various parameters concerning the different aspects of the
  143.          programs operation.
  144.  
  145.               Function Key F5:  This activates the Communications menu
  146.                                 setup. Here the COM port is
  147.                                 established along with its associated
  148.                                 baud rate, parity, data bits
  149.                                 and stop bits.
  150.  
  151.  
  152.               Function Key F6:  This key will activate the Video setup
  153.                                 menu.  Here the screen colors can be
  154.                                 set and the "snow" inhibit mode can be
  155.                                 set.
  156.  
  157.               Function Key F7:  This key when pressed enters the
  158.                                 keyboard setup menu.  Here the
  159.                                 program's interpretation of the
  160.                                 backspace key can be set.  The
  161.                                 keyboard can be programed to produce a
  162.                                 'key-click' and the state of the
  163.                                 keypad can be defined.
  164.  
  165.               Function Key F8:  An Emulation menu becomes active when
  166.                                 F8 is pressed.  Here the many mode
  167.                                 settings for the emulator may be set.
  168.                                 These include origin mode,
  169.                                 insert/replace mode, auto wrap mode,
  170.                                 new line mode, cursor visibility,
  171.                                 background video attributes and the
  172.                                 logical screen width.
  173.  
  174.               Function Key F9:  Function key F9 brings up a File menu.
  175.                                 The current settings for the terminal
  176.                                 can be saved in an initialization file
  177.                                 that is read when the program is
  178.                                 started.  Also a log of incoming
  179.                                 characters can be controlled.
  180.  
  181.               Function Key F10: This is used as the exit key.  When
  182.                                 pressed this will close any open log
  183.                                 files and exit.
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.                      CVT100, Terminal Emulator for Turbo C
  201.  
  202.  
  203.                                  Communications
  204.  
  205.               Characters are received via receiver interrupts
  206.          generated by the UART.  The interrupt service routine (ISR)
  207.          for the incoming characters is a function of type interrupt
  208.          for Turbo C.  Although any serious communications program
  209.          should have the transmission interrupts in assembler, this
  210.          program has been tested at 19,200 baud on a plain vanilla
  211.          4.77 Mghz PC with no loss of characters.
  212.  
  213.               An XON/XOFF 'handshake' is used to control the flow of
  214.          characters to and from the host.  An XOFF is transmitted to
  215.          the host when 75% of the communications circular buffer is
  216.          full.  This will tell the host to stop transmitting
  217.          characters until an XON is transmitted to it.  When the
  218.          buffer is back down to 25% full an XON will be sent to the
  219.          host signaling it that it is okay to begin transmission
  220.          again.
  221.  
  222.               When an XOFF has been received from the host this
  223.          program will delay for a short period of time before sending
  224.          a character to check for an XON being sent.  Note that the
  225.          character will still be transmitted if the wait period passes
  226.          with no XON being received.
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.                      CVT100, Terminal Emulator for Turbo C
  267.  
  268.  
  269.                                      Video
  270.  
  271.               Most video manipulations are done by reading and writing
  272.          directly to the screen's memory.   This made it necessary to
  273.          provide "snow" protection on CGA systems, but much less time
  274.          is wasted on writing characters and attributes than using the
  275.          BIOS.
  276.  
  277.               A check is done before each video memory access to
  278.          detect a control program such as Windows, DesqView, or
  279.          TopView.   Each of these control programs will keep a video
  280.          "shadow" buffer for processes currently executing.  The
  281.          address of this buffer can be queried and output directed to
  282.          this buffer instead of the actual screen.  This will let
  283.          CVT100 run in a well behaved window in these environments.
  284.  
  285.               There are several problems with the video system. A few
  286.          of the colors (Yellow foreground) do not work properly with
  287.          the emulation.  The program tries to juggle various
  288.          attributes defined by the host's control commands and tends
  289.          to lose the defined color in the process.  Also changing the
  290.          screen foreground and background colors may or may not work
  291.          during program execution.  This is due to the fact that the
  292.          software tries to retain the contents of the terminal screen
  293.          while making the color changes and again may get confused by
  294.          defined attributes.  To get around this problem, exit the
  295.          emulator and re-execute it.  The new colors will take effect
  296.          properly upon video initialization.
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.                      CVT100, Terminal Emulator for Turbo C
  333.  
  334.  
  335.                                     Keyboard
  336.  
  337.               The most controversial part of any terminal emulator
  338.          will usually be the setup of the IBM PC keyboard to try and
  339.          match the Digital Equipment Corporation VT keypad.  Not an
  340.          easy task.  This program tries to map as closely as possible
  341.          the keypad for an IBM PC to a DEC VT keypad.   The results
  342.          are often better if NUM LOCK is left on through out the
  343.          entire session.
  344.  
  345.               If you are unsatisfied with the layout of the keyboard
  346.          there are currently no means to assign keys any differently,
  347.          but that is why the source is provided with this program!
  348.          Check module KEYIO.C for changing the default setup.
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.                      CVT100, Terminal Emulator for Turbo C
  399.  
  400.  
  401.                                    Emulation
  402.  
  403.               This program can best be described as a compromise
  404.          between the desire to make the code as simple and straight
  405.          forward as possible and the complexities and intricacies of a
  406.          real life DEC VT100.  So many things were left out of the
  407.          terminal emulation.
  408.  
  409.               Of the things left out of the emulation most notable
  410.          will be printer output commands and double high/width
  411.          character lines.  Local echo is also absent.
  412.  
  413.               The emulator can not change the video from 80 to 132
  414.          columns and vice-versa when these commands are received from
  415.          the host.  The commands are received and recognized but it
  416.          only changes the logical width of the screen held by the
  417.          emulation software.  It seems as if every video board
  418.          manufacturer that has a board capable of switching to 132
  419.          column mode has a different method of changing into this
  420.          mode.  However this mode can be utilized by setting the
  421.          screen to 132 columns *before* executing the program.  Then
  422.          the video system of the emulator will properly use all of the
  423.          columns.
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.                      CVT100, Terminal Emulator for Turbo C
  465.  
  466.  
  467.                                   File System
  468.  
  469.               The setup information can be saved to a disk file when a
  470.          satisfactory setting has been reached.  When the program is
  471.          executed it looks in the current directory for this file
  472.          named 'CVT100.SET' from which to load the setup parameters.
  473.          If this file is not found then default values are provided.
  474.          Currently the only way to have multiple setups is to have
  475.          them in separate directories that the program can be executed
  476.          out of.
  477.  
  478.               Incoming characters can be logged to disk.  When logging
  479.          is selected then all incoming characters are saved in a disk
  480.          file names 'CVT100.LOG'.  If a file by that name exists at
  481.          the time when logging is selected then output is appended to
  482.          this file.  If no file is present when logging is selected
  483.          then a file will be created in the current directory.  Note
  484.          that *no interpretation* is performed on the characters
  485.          placed in the disk file.
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.                      CVT100, Terminal Emulator for Turbo C
  531.  
  532.  
  533.                               Program Termination
  534.  
  535.               Any time the program is exited the communications port
  536.          will be closed to prevent incoming characters generating
  537.          interrupts to ISR's which don't exist in memory any longer.
  538.          Additionally the log file will be closed if it is open on
  539.          program exit.
  540.  
  541.               There are several errors which may cause the emulator to
  542.          force itself to exit.  If memory can not be allocated from
  543.          the DOS heap for the screen save buffer then the program will
  544.          be terminated with an error message.  Also the file IO
  545.          functions may terminate the program if a system error has
  546.          occurred on a read or write of a disk file.  This could be
  547.          caused by a disk full error or fault media.   *CAREFUL*
  548.          because the program does not currently trap the fatal error
  549.          interrupt and disk errors will produce the not-too-kind error
  550.          message:
  551.  
  552.                   Not ready error writing drive A:
  553.                   Abort, Retry, Ignore?
  554.  
  555.          Choosing Abort will cause the terminal to exit without having
  556.          turned off communications interrupts.  This will cause a
  557.          quick system lockup if a character is received by the UART.
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.                      CVT100, Terminal Emulator for Turbo C
  597.  
  598.  
  599.                                     Testing
  600.  
  601.               The emulation has been tested primarily on 2 systems.
  602.          The first and most important was a Digital VAX running VMS.
  603.          There are several utilities running under VMS that try even
  604.          commercial VT100 emulators.  Most notable of these utilities
  605.          is the VAX TPU editor,  thus importance was given to getting
  606.          this version of a VT100 emulator working under the VAX TPU
  607.          editor as well as the EDT editor provided with VAX VMS.
  608.          Other exceptionally difficult programs to get an emulator
  609.          running under were the VAX/VMS debugger in full screen mode,
  610.          VAX/VMS mail, and programs using the VAX/VMS FMS screen forms
  611.          manager.
  612.  
  613.               Extensive testing was also done on the free practice
  614.          forum on CompuServ. (GO PRACTICE, I even got a good working
  615.          knowledge of the new SIG forum commands)   This turned out to
  616.          be a piece of cake after working with many of the VAX/VMS
  617.          programs.  As far as I can tell the CompuServ host computers
  618.          will only send cursor addressing commands and screen clearing
  619.          commands to terminals set up to be VT100's.  Therefore if
  620.          your terminal is set up to be an 80 X 24 VT100 to CompuServ
  621.          (GO TERMINAL) this VT100 emulator will provide thorough
  622.          terminal emulation.
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.                      CVT100, Terminal Emulator for Turbo C
  663.  
  664.  
  665.                                 Acknowledgments
  666.  
  667.               The VT100 emulation is based heavily on two versions of
  668.          Kermit.   The most notable version of Kermit was MSKermit
  669.          version 2.30 written in Microsoft Macro Assembler 3.0.
  670.          CKermit for Unix was also used for program design and
  671.          nomenclature.  Therefore this Copyright appears as required.
  672.  
  673.                               Copyright (c) 1981, 1988
  674.               Trustees of Columbia University in the City of New York
  675.  
  676.               Permission is granted to any individual or institution
  677.               to use, copy, or redistribute this program and
  678.               documentation as long as it is not sold for profit and
  679.               as long as the Columbia copyright notice is retained.
  680.  
  681.               This program would have never got off the ground if it
  682.          was not for the work put into a VT102 emulator written
  683.          primarily by J. R. Doupnik of Utah State University for
  684.          MSKermit.  Many other people have worked on MSKermit,
  685.          including Frank da Cruz and Christine Gianone of Columbia
  686.          University.  A list of these people would have been
  687.          incomplete and is not attempted here though their
  688.          work has been appreciated greatly by me over the years. If
  689.          any questions came up regarding a particular facet of VT100
  690.          emulation I would always refer to the MSKermit version 2.30
  691.          assembler source code.  The assembler source to MSKermit also
  692.          served as a design outline, although it was difficult to
  693.          maintain much of this outline in a conversion from assembler
  694.          to C.
  695.  
  696.               I also referred many times to a version of CKermit for
  697.          Unix systems.  Although there is no terminal emulation code
  698.          supplied with this version of Kermit, it helped in the
  699.          general design layout of the source modules and also helped
  700.          with the function naming conventions used by this program.
  701.          In fact it was my original intent to get a version of CKermit
  702.          going for MS DOS systems I now understand someone has already
  703.          done this somewhere.
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.