home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: DFÜ und Kommunikation / SOS-DFUE.ISO / programm / dos / terminal / cvt220 / cvt100.doc next >
Encoding:
Text File  |  1989-11-14  |  16.5 KB  |  383 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.                 CVT100, A Simple VT100 Emulator in Turbo C 2.0
  24.                        By Jerry Joplin CIS [70441,2627]
  25.  
  26.  
  27.  
  28.                      CVT100, Terminal Emulator for Turbo C
  29.  
  30.                                     Overview
  31.  
  32.  
  33.               CVT100 is a simple VT100 emulator programmed exclusively
  34.          in Turbo C 2.0.   *All* of the code is in Turbo C.  There are
  35.          no assembler routines or functions requiring an assembler.
  36.          All of the code is contained in 7 modules.  These are:
  37.  
  38.               comio.c       communications functions
  39.               cvt100.c      terminal emulator main
  40.               fileio.c      file manipulation functions
  41.               keyio.c       keyboard functions
  42.               vidio.c       video functions
  43.               vtsetup.c     setup functions
  44.               vttio.c       terminal output interpretation functions
  45.  
  46.          This is version 2.0 of the CVT100 emulator.  Version 1.0 of the
  47.          emulator was designed with the following objectives in mind:
  48.  
  49.               1)  To provide a public domain source for a VT100
  50.                   emulator written in Turbo C code that was easy to
  51.                   understand and modify,
  52.  
  53.               2)  To show the power and flexibility of Turbo C without
  54.                   having to resort to assembly language routines,
  55.  
  56.               3)  To aid (however slightly) in the development of a C
  57.                   version of Kermit for MS DOS systems,
  58.  
  59.               4)  To provide a terminal emulator that takes a very
  60.                   small amount of memory and is capable of running in
  61.                   a well behaved window in Windows or DesqView (less
  62.                   than 40k).
  63.  
  64.          CVT100 Vers 2.0 was aimed at 4 additional objectives:
  65.  
  66.               5)  Optimize the performance of the video system for
  67.                   operating environments such as MS Windows and
  68.                   DesqView.
  69.  
  70.               6)  Provide public domain code showing a method of
  71.                   designing a program achieving optimum output
  72.                   under MS Windows or DesqView without sacrificing
  73.                   performance as a standalone program under DOS.
  74.  
  75.               7)  Fix several bugs in the first version of CVT100.
  76.  
  77.               8)  Add a compile time DEBUG option that allows input
  78.                   to the communications system to be taken from a
  79.                   FILE rather than received characters from the
  80.                   communications port.
  81.  
  82.  
  83.  
  84.                      CVT100, Terminal Emulator for Turbo C
  85.  
  86.                                    Operation
  87.  
  88.               The terminal emulator is menu driven.  The top line of
  89.          the terminal screen is reserved as a status line.  A list of
  90.          choices is displayed on the status line for setting the
  91.          various parameters concerning the different aspects of the
  92.          programs operation.
  93.  
  94.               Function Key F5:  This activates the Communications menu
  95.                                 setup. Here the COM port is
  96.                                 established along with its associated
  97.                                 baud rate, parity, data bits
  98.                                 and stop bits.
  99.  
  100.  
  101.               Function Key F6:  This key will activate the Video setup
  102.                                 menu.  Here the screen colors can be
  103.                                 set and the "snow" inhibit mode can be
  104.                                 set.
  105.  
  106.               Function Key F7:  This key when pressed enters the
  107.                                 keyboard setup menu.  Here the
  108.                                 program's interpretation of the
  109.                                 backspace key can be set.  The
  110.                                 keyboard can be programmed to produce a
  111.                                 'key-click' and the state of the
  112.                                 keypad can be defined.
  113.  
  114.               Function Key F8:  An Emulation menu becomes active when
  115.                                 F8 is pressed.  Here the many mode
  116.                                 settings for the emulator may be set.
  117.                                 These include origin mode,
  118.                                 insert/replace mode, auto wrap mode,
  119.                                 new line mode, cursor visibility,
  120.                                 background video attributes and the
  121.                                 logical screen width.
  122.  
  123.               Function Key F9:  Function key F9 brings up a File menu.
  124.                                 The current settings for the terminal
  125.                                 can be saved in an initialization file
  126.                                 that is read when the program is
  127.                                 started.  Also a log of incoming
  128.                                 characters can be controlled.
  129.  
  130.               Function Key F10: This is used as the exit key.  When
  131.                                 pressed this will close any open log
  132.                                 files and exit.
  133.  
  134.  
  135.  
  136.  
  137.                      CVT100, Terminal Emulator for Turbo C
  138.  
  139.                                  Communications
  140.  
  141.               Characters are received via receiver interrupts
  142.          generated by the UART.  The interrupt service routine (ISR)
  143.          for the incoming characters is a function of type interrupt
  144.          for Turbo C.  Although any serious communications program
  145.          should have the transmission interrupts in assembler, this
  146.          program has been tested at 19,200 baud on a plain vanilla
  147.          4.77 Mghz PC with no loss of characters.
  148.  
  149.               An XON/XOFF 'handshake' is used to control the flow of
  150.          characters to and from the host.  An XOFF is transmitted to
  151.          the host when 75% of the communications circular buffer is
  152.          full.  This will tell the host to stop transmitting
  153.          characters until an XON is transmitted to it.  When the
  154.          buffer is back down to 25% full an XON will be sent to the
  155.          host signaling it that it is okay to begin transmission
  156.          again.
  157.  
  158.               Version 2.0 of CVT100 also adds a debugging feature in
  159.          the communication system.   Input can be taken from a file
  160.          and interpreted as received characters.  Debugging is enabled
  161.          by a #define DEBUG in module COMIO.C.
  162.  
  163.  
  164.  
  165.                      CVT100, Terminal Emulator for Turbo C
  166.  
  167.  
  168.                                      Video
  169.  
  170.               Most video manipulations are done by reading and writing
  171.          directly to the screen's memory.   This made it necessary to
  172.          provide "snow" protection on CGA systems, but much less time
  173.          is wasted on writing characters and attributes than using the
  174.          BIOS.
  175.  
  176.               A check is done before each video memory access to
  177.          detect a control program such as Windows, DesqView, or
  178.          TopView.   Each of these control programs will keep a video
  179.          "shadow" buffer for processes currently executing.  The
  180.          address of this buffer can be queried and output directed to
  181.          this buffer instead of the actual screen.  This will let
  182.          CVT100 run in a well behaved window in these environments.
  183.  
  184.               Not only will CVT100 run in a well behaved window,
  185.          but CVT100 version 2.0 was designed to provide excellent
  186.          performance under these operating environments.   CVT100
  187.          uses a simple character output buffering scheme.  This scheme
  188.          improves the performance under MS Windows by %400 while
  189.          hardly changing operation under DOS alone.
  190.  
  191.               There are several problems with the video system. A few
  192.          of the colors (Yellow foreground) do not work properly with
  193.          the emulation.  The program tries to juggle various
  194.          attributes defined by the host's control commands and tends
  195.          to lose the defined color in the process.
  196.  
  197.  
  198.  
  199.  
  200.                      CVT100, Terminal Emulator for Turbo C
  201.  
  202.  
  203.                                     Keyboard
  204.  
  205.               The most controversial part of any terminal emulator
  206.          will usually be the setup of the IBM PC keyboard to try and
  207.          match the Digital Equipment Corporation VT keypad.  Not an
  208.          easy task.  This program tries to map as closely as possible
  209.          the keypad for an IBM PC to a DEC VT keypad.   The results
  210.          are often better if NUM LOCK is left on through out the
  211.          entire session.
  212.  
  213.               If you are unsatisfied with the layout of the keyboard
  214.          there are currently no means to assign keys any differently,
  215.          but that is why the source is provided with this program!
  216.          Check module KEYIO.C for changing the default setup.
  217.  
  218.  
  219.  
  220.  
  221.                      CVT100, Terminal Emulator for Turbo C
  222.  
  223.                                    Emulation
  224.  
  225.               This program can best be described as a compromise
  226.          between the desire to make the code as simple and straight
  227.          forward as possible and the complexities and intricacies of a
  228.          real life DEC VT100.  So many things were left out of the
  229.          terminal emulation.
  230.  
  231.               Of the things left out of the emulation most notable
  232.          will be printer output commands and double high/width
  233.          character lines.  Local echo is also absent.
  234.  
  235.               The emulator can not change the video from 80 to 132
  236.          columns and vice-versa when these commands are received from
  237.          the host.  The commands are received and recognized but it
  238.          only changes the logical width of the screen held by the
  239.          emulation software.  It seems as if every video board
  240.          manufacturer that has a board capable of switching to 132
  241.          column mode has a different method of changing into this
  242.          mode.  However this mode can be utilized by setting the
  243.          screen to 132 columns *before* executing the program.  Then
  244.          the video system of the emulator will properly use all of the
  245.          columns.
  246.  
  247.  
  248.  
  249.  
  250.                      CVT100, Terminal Emulator for Turbo C
  251.  
  252.  
  253.                                   File System
  254.  
  255.               The setup information can be saved to a disk file when a
  256.          satisfactory setting has been reached.  When the program is
  257.          executed it looks in the current directory for this file
  258.          named 'CVT100.SET' from which to load the setup parameters.
  259.          If this file is not found then default values are provided.
  260.          Currently the only way to have multiple setups is to have
  261.          them in separate directories that the program can be executed
  262.          out of.
  263.  
  264.               Incoming characters can be logged to disk.  When logging
  265.          is selected then all incoming characters are saved in a disk
  266.          file names 'CVT100.LOG'.  If a file by that name exists at
  267.          the time when logging is selected then output is appended to
  268.          this file.  If no file is present when logging is selected
  269.          then a file will be created in the current directory.  Note
  270.          that *no interpretation* is performed on the characters
  271.          placed in the disk file.
  272.  
  273.  
  274.  
  275.  
  276.                      CVT100, Terminal Emulator for Turbo C
  277.  
  278.                               Program Termination
  279.  
  280.               Any time the program is exited the communications port
  281.          will be closed to prevent incoming characters generating
  282.          interrupts to ISR's which don't exist in memory any longer.
  283.          Additionally the log file will be closed if it is open on
  284.          program exit.
  285.  
  286.               There are several errors which may cause the emulator to
  287.          force itself to exit.  If memory can not be allocated from
  288.          the DOS heap for the screen save buffer then the program will
  289.          be terminated with an error message.  Also the file IO
  290.          functions may terminate the program if a system error has
  291.          occurred on a read or write of a disk file.  This could be
  292.          caused by a disk full error or fault media.   *CAREFUL*
  293.          because the program does not currently trap the fatal error
  294.          interrupt and disk errors will produce the not-too-kind error
  295.          message:
  296.  
  297.                   Not ready error writing drive A:
  298.                   Abort, Retry, Ignore?
  299.  
  300.          Choosing Abort will cause the terminal to exit without having
  301.          turned off communications interrupts.  This will cause a
  302.          quick system lockup if a character is received by the UART.
  303.  
  304.  
  305.  
  306.  
  307.                      CVT100, Terminal Emulator for Turbo C
  308.  
  309.                                     Testing
  310.  
  311.               The emulation has been tested primarily on 2 systems.
  312.          The first and most important was a Digital VAX running VMS.
  313.          There are several utilities running under VMS that try even
  314.          commercial VT100 emulators.  Most notable of these utilities
  315.          is the VAX TPU editor,  thus importance was given to getting
  316.          this version of a VT100 emulator working under the VAX TPU
  317.          editor as well as the EDT editor provided with VAX VMS.
  318.          Other exceptionally difficult programs to get an emulator
  319.          running under were the VAX/VMS debugger in full screen mode,
  320.          VAX/VMS mail, and programs using the VAX/VMS FMS screen forms
  321.          manager.
  322.  
  323.               Extensive testing was also done on the free practice
  324.          forum on CompuServ. (GO PRACTICE, I even got a good working
  325.          knowledge of the new SIG forum commands)   This turned out to
  326.          be a piece of cake after working with many of the VAX/VMS
  327.          programs.  As far as I can tell the CompuServ host computers
  328.          will only send cursor addressing commands and screen clearing
  329.          commands to terminals set up to be VT100's.  Therefore if
  330.          your terminal is set up to be an 80 X 24 VT100 to CompuServ
  331.          (GO TERMINAL) this VT100 emulator will provide thorough
  332.          terminal emulation.
  333.  
  334.  
  335.  
  336.  
  337.                      CVT100, Terminal Emulator for Turbo C
  338.  
  339.                                 Acknowledgments
  340.  
  341.               The VT100 emulation is based heavily on two versions of
  342.          Kermit.   The most notable version of Kermit was MSKermit
  343.          version 2.30 written in Microsoft Macro Assembler 3.0.
  344.          CKermit for Unix was also used for program design and
  345.          nomenclature.  Therefore this Copyright appears as required.
  346.  
  347.                               Copyright (c) 1981, 1988
  348.               Trustees of Columbia University in the City of New York
  349.  
  350.               Permission is granted to any individual or institution
  351.               to use, copy, or redistribute this program and
  352.               documentation as long as it is not sold for profit and
  353.               as long as the Columbia copyright notice is retained.
  354.  
  355.               This program would have never got off the ground if it
  356.          was not for the work put into a VT102 emulator written
  357.          primarily by J. R. Doupnik of Utah State University for
  358.          MSKermit.  Many other people have worked on MSKermit,
  359.          including Frank da Cruz and Christine Gianone of Columbia
  360.          University.  A list of these people would have been
  361.          incomplete and is not attempted here though their
  362.          work has been appreciated greatly by me over the years. If
  363.          any questions came up regarding a particular facet of VT100
  364.          emulation I would always refer to the MSKermit version 2.30
  365.          assembler source code.  The assembler source to MSKermit also
  366.          served as a design outline, although it was difficult to
  367.          maintain much of this outline in a conversion from assembler
  368.          to C.
  369.  
  370.               I also referred many times to a version of CKermit for
  371.          Unix systems.  Although there is no terminal emulation code
  372.          supplied with this version of Kermit, it helped in the
  373.          general design layout of the source modules and also helped
  374.          with the function naming conventions used by this program.
  375.          In fact it was my original intent to get a version of CKermit
  376.          going for MS DOS systems I now understand someone has already
  377.          done this somewhere.
  378.  
  379.               Special thanks to Bill Wood who located an error in
  380.          the video system of CVT100 version 1.0.  Not only did he
  381.          locate the error but also provided the code to fix the error!
  382.          This fix is incorporated into CVT100 version 2.0.
  383.