home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / UTILITY / SCREEN / ZAVT11.ZIP / ZAVT.DOC < prev    next >
Encoding:
Text File  |  1990-05-28  |  17.2 KB  |  441 lines

  1. zavt    - enhanced MS-DOS ansi/avatar console driver
  2.  
  3. SYNOPSIS
  4.     Include in \config.sys the line
  5.         device=zavt.sys
  6.  
  7. DESCRIPTION
  8.     Zavt.sys is a console driver which understands ANSI control sequences
  9.     as well as Avatar level 0. It has several advantages over most other
  10.     drivers.
  11.  
  12.     1. It supports any display mode the BIOS can set up (see below)
  13.     2. It can be addressed by two different names so the default
  14.         output can be left in raw mode (see below)
  15.     3. The blasted bell is now 1/9 second
  16.  
  17.     4. Any DOS console entry may make use of a full-screen editor
  18.  
  19.       One trivial advantage is the allowing of backspaces across the left
  20.     margin. I don't know what problems this may create, but it is nice
  21.     for the command line.
  22.  
  23.     COMPATABILITY
  24.     -------------
  25.  
  26.       Zavt gets all its information about the console from the BIOS data
  27.     area - nothing is assumed other than that modes 0-3 and 7 are text
  28.     modes. Other drivers assume your screen is 25 lines long, and that
  29.     the video card is always left on page 0. This is a safe assumption
  30.     most of the time, but bad practice. AutoCAD 2.5 for example is more
  31.     efficient in switching between graphics and text when you configure
  32.     it to write text on page one and use page 0 for its graphics, but
  33.     will not give a usable text page with other drivers. Nansi has code
  34.     in it to switch an EGA to 43 line mode, or an AT&T display to 50 line
  35.     mode, but if you switch back by any means other than Nansi's own
  36.     facilities, Nansi continues to assume 43 lines. Zavt responds to
  37.     changes in display size very well. If you switch to a mode with more
  38.     lines on screen (not by means of the driver - system specifics I
  39.     leave to other software), Zavt will use them immediately. If you
  40.     switch to a mode with fewer lines and the cursor is off the new
  41.     screen, the next scroll will bring it along with the screen region
  42.     around it into view. The best way to get a feel for this if you have
  43.     an EGA is to play with the xxLINE.COM programs included. The names
  44.     are for EGA, and will work for VGA, but will give you more lines than
  45.     advertised.
  46.  
  47.  
  48.     DEVICE DRIVERS
  49.     --------------
  50.  
  51.     When you, for example, type
  52.         C:> type foo.txt
  53.     COMMAND.COM opens the file foo.txt, reads it, and writes it to
  54.     the console driver, which puts it up on the screen. DOS has
  55.     two ways of writing to the console driver:
  56.  
  57.     raw/binary mode: where the device driver is called once for
  58.         a group of characters letting the device driver
  59.         handle them all at once, or
  60.  
  61.     cooked/ASCII mode: where DOS calls the device driver once for each
  62.         character to be sent, expanding any tabs.
  63.  
  64.        Raw mode is much faster as the device driver is called fewer
  65.     times requiring less overhead all together. However, you lose
  66.     the ability to abort in the middle of output. If you TYPE a large
  67.     file, COMMAND.COM sends it to the console driver 32K at a time, so
  68.     if you Ctrl-Break, you'll have to wait until the first 32K have been
  69.     displayed. DOS also no longer expands tabs, but this is easily
  70.     handled by the device driver. Run RAW.COM then type
  71.         C:> dir /w
  72.     and rather than tabs between filenames, the tab character is displayed.
  73.     Run COOKED.COM before continuing.
  74.        When DOS wants input from the console (such as when reading input
  75.     for a filter such as MORE), raw and cooked mode also apply. In
  76.     cooked mode, DOS will echo each character you enter, and interpret
  77.     the cursor keys and f-keys allowing you to edit what you enter. DOS
  78.     will also end entry when you hit CR, returning what you typed up
  79.     to that point, even if more characters were requested. To demonstrate
  80.     this, type
  81.         C:> more
  82.     and type some gibberish. DOS is requesting 4096 characters, but as soon
  83.     as you type <enter>, entry ends and more prints out what you typed.
  84.     Press f6 and enter to end.
  85.  
  86.        When the console is in raw mode however, DOS does not echo
  87.     characters, check for ^C, ^S, or ^P, and asks of the driver however
  88.     many characters the calling program wants. The driver has no choice
  89.     but to oblige, and without feedback, the computer seems frozen. Run
  90.     RAW.COM included in this archive, then try MORE. Unless you type 4096
  91.     characters, with a ^Z included to flag end of file, the computer is
  92.     for all intents and purposes crashed.
  93.  
  94.        So while setting the console to raw mode lets you display text
  95.     *MUCH* faster, you have a potential trap if you run into software
  96.     which requests data from the default input. The solution would seem
  97.     to be to write in raw mode, and read on cooked mode, but DOS will
  98.     speak to a device driver in only one way at a time. The solution?
  99.     Use a second device driver. The console is normally addressed as
  100.     CON, but Zavt has a secondary handler which allows it to be addressed
  101.     as KEYB as well. The problem is how to change the default input to
  102.     KEYB. CTTY will change both the default input, but it will change
  103.     the default output and error output as well. In DOS versions up to
  104.     3.3, CTTY has a bug which will allow you to
  105.         C:> CTTY <KEYB
  106.     DOS will say 'Invalid Device' but otherwise acts as expected. DOS
  107.     4.0 users will have to live with the risk (it's not that great).
  108.  
  109.        Once the default input is set to the alternate handler, you can
  110.     go ahead and set the default output (and with it, the error output)
  111.     to raw mode.
  112.  
  113.     ANSI (taken from documentation for NANSI 2.4)
  114.     ----
  115.  
  116.     While putting text up on the screen, zavt.sys keeps a lookout for
  117.     the escape character (chr(27), known as ESC); this character signals
  118.     the start of a terminal control sequence.
  119.     Terminal control sequences follow the format
  120.         ESC [ param; param; ...; param cmd
  121.     where
  122.         ESC    is the escape character chr$(27).
  123.         [    is the left bracket character.
  124.         param    is an ASCII decimal number, or a string in quotes.
  125.         cmd    is a case-specific letter identifying the command.
  126.     Usually, zero, one, or two parameters are given.  If parameters
  127.     are omitted, they usually default to 1. Spaces are not allowed
  128.     between parameters.
  129.  
  130.     For example, both ESC[1;1H and ESC[H send the cursor to the home
  131.     position (1,1), which is the upper left.
  132.  
  133.     Either single or double quotes may be used to quote a string.
  134.     Each character inside a quoted string is equivalent to one numeric
  135.     parameter.  Quoted strings are normally used only for the Keyboard
  136.     Key Reassignment command.
  137.  
  138.     ESCAPE.COM from PC-Magazine is included as an easy way to send
  139.     these control sequences, sending the ESC and [ followed immediately
  140.     by whatever is given to it on the command line.
  141.  
  142. Control Sequences
  143.     The following table lists the sequences understood by nansi.sys.
  144.     Differences between nansi.sys and the standard ansi.sys are marked
  145.     with a vertical bar (|).
  146.  
  147. Cursor Positioning
  148. Short    Long name        Format        Notes
  149. CUP    cursor position        ESC[y;xH    Sets cursor position.
  150. HVP    cursor position        ESC[y;xf    Same as CUP; not recommended.
  151. CUU    cursor up        ESC[nA        n = # of lines to move
  152. CUD    cursor down        ESC[nB
  153. CUF    cursor forward        ESC[nC        n = # of columns to move
  154. CUB    cursor backward        ESC[nD
  155. DSR    Device Status, Report!    ESC[6n        Find out cursor position.
  156. CPR    Cursor Position report    ESC[y;xR<CR>    Response to DSR, as if typed.
  157. SCP    Save Cursor Position    ESC[s        Not nestable.
  158. RCP    Restore Cursor Position ESC[u
  159.  
  160. Editing
  161. EID    Erase in Display    ESC[J     Clears screen to cursor
  162. EID    Erase in Display    ESC[1J    Clears screen from cursor.
  163. EID    Erase in Display    ESC[2J    Clears screen.
  164. EIL    Erase in Line        ESC[K    Clears to end of line.
  165. EIL    Erase in Line        ESC[1K    Clears line up to cursor.
  166. EIL    Erase in Line        ESC[2K    Clears entire line.
  167.  
  168. IL    Insert Lines        ESC[nL    Inserts n blank lines at cursor line.
  169. DL    Delete Lines        ESC[nM    Deletes n lines, including cursor line.
  170. IC    Insert Characters    ESC[n@    Inserts n blank chars at cursor.
  171. DC    Delete Characters    ESC[nP    Deletes n chars, including cursor char.
  172.  
  173.  
  174. Mode-Setting
  175. SGR    Set Graphics Rendition    ESC[n;n;...nm    See character attribute table.
  176. SM    Set Mode        ESC[=nh        See screen mode table.
  177. RM    Reset Mode        ESC[=nl        See screen mode table.
  178.  
  179. IBMKKR    Keyboard Key Reass.    ESC["string"p
  180.     The first char of the string gives the key to redefine; the rest
  181.     of the string is the key's new value.
  182.     To specify unprintable chars, give the ASCII value of the char
  183.     outside of quotes, as a normal parameter.
  184.     IBM function keys are two byte strings; see the IBM Basic manual.
  185.     For instance, ESC[0;59;"dir a:";13;p redefines function key 1 to
  186.     have the value "dir a:" followed by the ENTER key.
  187.     If no parameters given, all keys are reset to their default values.
  188.  
  189. Character Attributes
  190.     The Set Graphics Rendition command is used to select foreground
  191.     and background colors or attributes.
  192.     When you use multiple parameters, they are executed in sequence, and
  193.     the effects are cumulative.
  194.        Attrib code        Value
  195.         0        All attributes off (normal white on black)
  196.         1        Bold
  197.         2        Bold off
  198.         4        Underline
  199.         5        Blink
  200.         7        Reverse Video
  201.         8        Invisible (but why?)
  202.         30-37        foregnd blk/red/grn/yel/blu/magenta/cyan/white
  203.         40-47        background (no effect in graphics modes)
  204.  
  205. Screen Modes
  206.     The Set Mode and Reset Mode sequences both accept one parameter,
  207.     with the following values:
  208.         Mode Code    Value (same for Set and for Reset)
  209.         0    text 40x25 Black & White
  210.         1    text 40x25 Color
  211.         2    text 80x25 Black & White
  212.         3    text 80x25 Color
  213.         4    bitmap 320x200 4 bits/pixel
  214.         5    bitmap 320x200 1 bit/pixel
  215.         6    bitmap 640x200 1 bit/pixel
  216.         13    EGA graphics 320x200 4 bits/pixel
  217.         14    EGA graphics 640x200 4 bits/pixel
  218.         15    EGA [ IBM Monochrome display 640x350 2 bits/pixel?]
  219.         16    EGA graphics 640x350 4 bits/pixel [with full 256K]
  220.  
  221.         Mode Code    Set            Reset
  222.         7      *Wrap at end of line     No wrap at EOL
  223.         45     *Graphics Cursor        No simulated graphics cursor
  224.  
  225.     Note: Modes other than the two set codes are BIOS display modes
  226.           and modes not listed which may be supported by new cards
  227.           (VGA for example) can also be selected by these functions.
  228.  
  229.         [ * = default ]
  230.  
  231. Little Dead Blobs
  232.     If you are using a graphics mode, and the cursor leaves little
  233.     dead blobs behind when it moves, you are probably using a program
  234.     which bypasses DOS (naughty, naughty).  It might help to tell
  235.     Nansi to turn off its graphics cursor by sending the string
  236.         ESC [ = 45 l
  237.     (The last character in that string is a lowercase "L".)
  238.  
  239.  
  240.     AVATAR
  241.     ------
  242.  
  243.       While putting text up on the screen, Zavt.sys also looks out for
  244.     ^V, ^Y, ^L and ^P. The following is taken from documentation for
  245.     OANSI.
  246.  
  247.  
  248.     ALIASING
  249.  
  250.     In an Avatar sequence, the DLE character is "escaped."
  251.  
  252.     That's a scheme to let you use characters normally not available
  253.     to an editor.
  254.  
  255.         DLE    Hex=10 Decimal=16
  256.  
  257.  
  258.     Here are some examples of character aliases:
  259.  
  260.         Hex      Decimal    Real character
  261.         ----------------------------------
  262.         10 83    16 131      3   (^c)
  263.         10 9a    16 154     1a   (^z)
  264.         10 90    16 144     10   (^p)
  265.         10 10    16  16     10   (^p)
  266.  
  267.  
  268.     When an Avatar terminal runs into a DLE character, it grabs the next 
  269.     available byte and strips off the high-order bit.
  270.  
  271.  
  272.  
  273.     CONTROL CODES
  274.  
  275.  
  276.         Command           Description
  277.         -----------------------------------------------
  278.  
  279.         ^v ^a <a>    attribute
  280.                 The "<a>" is a single
  281.                 byte.  The value of this
  282.                 attribute byte corresponds
  283.                 to the video attributes
  284.                 used by IBM on their CGA
  285.                 monitors.  (Intense video
  286.                 is supported, black-on-black
  287.                 is not.)
  288.  
  289.         ^v ^b        blinking on
  290.                 blinking is turned off
  291.                 by the next "^v^a" 
  292.                 command
  293.  
  294.         ^v ^c        move cursor up a line
  295.  
  296.         ^v ^d        move cursor down a line
  297.  
  298.         ^v ^e        move cursor left a line
  299.  
  300.         ^v ^f        move cursor right a line
  301.  
  302.         ^v ^g        clear to end of line
  303.  
  304.         ^v ^h <r> <c>    set cursor position
  305.                 These are 1-based numbers
  306.                 with the "Y" (row) coordinate
  307.                 first.  The upper left of the
  308.                 display is "1,1."  The start 
  309.                 of the second line would be
  310.                 "2,1."
  311.  
  312.         ^l        set current attribute to cyan
  313.                 on black, home cursor and
  314.                 clear screen
  315.  
  316.  
  317.        Avatar is a binary based protocol while ANSI is ASCII based.
  318.     As a result, control codes which may have other meanins may
  319.     end up part of an Avatar control sequnce. This is not a problem
  320.     except when something tries to interpret a control code without
  321.     realizing it is to be preserved. The only situation where this
  322.     occurs that is of any concern is with DOS. If the console is in
  323.     cooked mode, any ^i will become some number of spaces as DOS
  324.     considers it to be a tab. This will corrupt any Avatar code with
  325.     a ^i in it. The solution is to set the console to raw mode, which
  326.     is the reccommended setup for speed as well.
  327.  
  328.  
  329.     Full-Screen input
  330.     -----------------
  331.  
  332.        Code for the full-screen editor was mostly taken from PC-Magazine's
  333.     DOS-EDIT and thus the mechanics are virtually identical. Being part
  334.     of the console handler rather than a TSR however allows the editor
  335.     to be used for any DOS input rather than only the command line.
  336.  
  337.        For those not familiar, pressing cursor-up on the command line
  338.     with DOS-EDIT loaded would move the cursor up one line and put
  339.     you into the full-screen editor. From there, the special keys are
  340.  
  341.     Escape        leave the fullscreen routine
  342.     Cursor keys    move the cursor accordingly
  343.     Home        move the cursor to the left margin
  344.     End        leave the full-screen routine, putting what is
  345.             on the screen under and following the cursor
  346.             into a buffer to be read as keyboard input
  347.     PgUp        move the cursor to its original column
  348.     PgDn        delete all characters on and following the cursor
  349.     Insert        toggle insert/delete mode
  350.     Delete        delete character to left of cursor and move text
  351.             under and to the right of the cursor one space left
  352.     Enter        same as End but adds a CR to the end of the data
  353.  
  354.        The alpha-numeric keys print to screen while control codes
  355.     may or may not depending on whether or not they have other purposes.
  356.     Alt-<num> input always prints however, so it is possible to queue
  357.     a sequence of strings by putting typing them on one line and typing
  358.     13 on the numeric keypad while holding Alt in between each string.
  359.  
  360.        Since ZAVT treats all console input the same, using cursor-up
  361.     as the full-screen key may preclude software such as 4DOS which
  362.     uses the key for its own purposes. In ZAVT without keyboard remapping
  363.     Ctrl-PgUp is used in its place as it is reasonably obscure but
  364.     still accessible. In ZAVT with keyboard mapping, there is no default.
  365.     When a key maps a double-null, that is taken as the hotkey. Thus
  366.     to define Ctrl-PgUp as the hotkey with ESCAPE.COM, type
  367.         c:>ESCAPE 0;132;0;0p
  368.  
  369. BUGS
  370.     The Set Mode and Reset Mode code 45 was chosen to match what
  371.     was used in NANSI 2.4 which in turn was chosen without even
  372.     looking to see if there were established codes for those functions.
  373.  
  374.     Insert and delete character do not work in graphics modes
  375.     because BIOS does not include a scroll left/right function.
  376.  
  377.     Cursor Position Report has a carriage return in it, which is what
  378.     ansi.sys does, but is nonstandard.
  379.  
  380.     Avatar RLE doesn't handle control characters - it assumes whatever
  381.     you give it to repeat is printable and prints it, also assuming
  382.     the repeat will not result in wrapping past the right margin.
  383.  
  384.     Wrap around left margin is nice, but nonstandard.
  385.  
  386. NOTE
  387.     While I polished off this code and added some of my own, the bulk
  388.     of it was written by Daniel Kegel, and Thomas Hanlin III to
  389.     whom credit is due. My distribution policy is the same as for the
  390.     formentioned authors' drivers, which is as follows as taken from
  391.     the documentation for NANSI24.
  392.  
  393.     This program and all files associated with it are hereby placed
  394.     in the public domain, and thus may be freely copied and distributed.
  395.  
  396.     If you really like this program, either
  397.     (a) improve it, and place your improvements in the public domain,
  398.     (b) write a neat program which uses Zavt's unique speed, and
  399.         place your program in the public domain,
  400.     (c) tip the author (Tip; contraction for "To Inspire Programmer";
  401.         traditionally, a contribution of $5 per copy), or
  402.     (d) resolve to become a better human being in the future.
  403.  
  404.     Any problems or suggestions can be made to the 'author', Luns Tee
  405.     32 Thyra Ave.
  406.     Toronto, Ontario, M4C-5G5
  407.     Canada
  408.  
  409.  
  410. FOR PROGRAMMERS
  411.  
  412.     If the code seems to be a mess, that's because it is. Code from ZANSI
  413.     has been juggled around so as to minimize the number of JMPs that are
  414.     not JMP SHORT. Just a few hints:
  415.         Search for "90" in the .LST files. If any follow a JMP
  416.     instruction, make the JMP a JMP SHORT as these are NOPs to pad
  417.     the size difference between the two variants of this instruction.
  418.         When writing anything which writes to the console, use
  419.     an IOCTL call to get the driver's attributes, save them, and set
  420.     the console to raw mode. Do not write to the console by calling
  421.     Int 21h function 2 once for each character (it's not that uncommon)
  422.     but rather function 40h for each string. Buffering strings larger
  423.     than about 10 characters starts diminishing returns. Just remember
  424.     to return the console to its original state before exiting.
  425.  
  426.         The file ZAVT.MAK has switches for Turbo Assembler and not
  427.     Microsoft MASM which NANSI was compiled under. The .MAK file itself
  428.     is for Microsoft's MAKE utility however.
  429.  
  430. FILES
  431.  
  432. ZAVT*.ASM    - console driver source files
  433. ZAVT.MAK    - make file for ZAVT.SYS
  434. ZAVT.SYS    - full-featured driver
  435. ZAVTNK.SYS    - driver with keyboard remapping disabled
  436. FONTS.ZIP    - assortment of ega/vga fonts
  437. RAW.COM        - program to set console to raw
  438. COOKED.COM    -   and cooked mode
  439. ESCAPE.COM    - program to send escape sequences to console
  440. ZAVT.DOC    - this file
  441.