
                           TOPKEY FOR WINDOWS

                              User's Guide



                                CONTENTS

   1. Introduction
   2. TopKey for Windows package
   3. TopKey for Windows installation
   4. Using TopKey for Windows
   5. Creating and editing keyboard profiles
   6. TopKey data file format

   Supplement 1. Names of keys and their scan-codes.
   Supplement 2. TRN files included into the TopKey for Windows package.



                           1. INTRODUCTION

   TopKey for Windows is an easy-to-use programmable keyboard mapper 
   for working in MS Windows 3.1.

   TopKey for Windows and its utilities provide for the opportunities 
   to create new keyboard profiles, edit existing ones, use more than 
   one profile at the same time, and switch from one profile to 
   another by pressing a key (so-called "hot-key"), as well as by 
   choosing necessary profile in the menu.

   TopKey for Windows is able to save current settings and restore 
   them next time the program is run.

   TopKey for Windows can indicate active keyboard profile by 
   changing the icon or the inscription below it.

   Keyboard profiles contain reassignments of keys which must be 
   interpreted in a non-standard way. Profiles have ID numbers which 
   must be unique (Topkey cannot use more than one keyboard profile 
   with a given number). A profile can also be given a hot-key 
   assignment, so that pressing this hot-key will result in switching 
   to this profile.

   When Topkey for Windows is checking if the key pressed is 
   reassigned, it is also checking the status of special keys (Alt, 
   Ctrl, Shift, Caps Lock, Num Lock, Scroll Lock). Thus, assignment 
   of the so-called "dead chars" is possible, which provide for the 
   opportunity to use subsequent pressings of two or more keys to 
   display necessary symbol (e.g., the ' A sequence may correspond to 
   the accented A character).


                    2. TOPKEY FOR WINDOWS PACKAGE

   The TopKey for Windows package contains the following files:

      WTOPKEY.EXE    - keyboard mapper, and sets of ready-for-use 
                       profiles in files with the .KBW extension 
                       (TopKey for Windows profiles). The package 
                       also includes files with the .TRN extension, 
                       providing for the opportunity to use already 
                       existing TopKey for DOS profiles in Windows.

      ED_WTK.EXE     - keyboard profile editor for WTOPKEY.EXE (it 
                       can also be used for editing TopKey for DOS 
                       keyboard profiles).

      USER'S GUIDES  - the present User's Guide (WTOPKEY.DOC).

      Readme         - brief instruction on installation of TopKey 
                       for Windows on your computer.

      INSTALL.EXE    - TopKey for Windows installation program.

   In addition to the files listed above, the TopKey for Windows 
   package contains other files necessary for correct operation of 
   the mapper and the editor.


                       3. TOPKEY INSTALLATION

   There is a special installation program, INSTALL.EXE, for 
   installation of TopKey for Windows on your computer.

   To run this program, perform the following steps:

      1. Insert the installation diskette into the A or B floppy disk 
         drive.

      2. Start the Windows INSTALL.EXE program. It can be done either 
         in DOS, or in Windows.

         To start in DOS:
            First, make sure that DOS isn't a separate Windows 
            application. To do that, ALT-TAB can be pressed. If DOS 
            was started in Windows, you will switch to a Windows 
            window. In this case, perform the installation in 
            Windows. If pressing ALT-TAB has no effect, you can 
            perform the installation as follows:

               win A:\install

            if you use the A floppy disk drive, or

               win B:\install<enter>

            if you use the B floppy disk drive.

            In case Windows is included into PATH, you can run the 
            INSTALL program simply from the diskette, e.g.:

               C:\DOS>a:
               A:\>install

         To start in Windows:
            Choose 'File' in the main menu of the Program Manager, 
            then choose 'Run' in the menu displayed. A small dialog 
            box appears using which you will be able to choose the 
            installation program:

               A:\INSTALL.EXE

      3. In the dialog box displayed by the installation program 
         choose a directory in which TopKey for Windows files will be 
         placed (this directory will be created, if necessary).

         To do that, type the name of the directory in the input box, 
         or choose a directory in the list-box and "press" the 
         Install button. To cancel the installation process, "press" 
         the Abort button.

      4. INSTALL will copy files needed to the directory chosen by 
         you, create other necessary files, and create and fill in 
         the group in the Program Manager.

      5. To start the TopKey mapper, run the WTOPKEY.EXE program 
         marked with the 'TopKey for Windows' icon.

         If you want TopKey to be started each time Windows is run, 
         move the TopKey icon to the STARTUP group, or type the 
         following line in WIN.INI, section [windows]:

               load= path_to_TopKey\WTOPKEY.EXE

      6. TopKey installation program creates the special UnInstall 
         utility which you can use later to delete TopKey for Windows 
         package previously installed.


   POSSIBLE ERRORS:

   INSTALL checks the disk containing your TopKey for Windows 
   installation package. If any necessary files are not found, 
   installation of TopKey will be aborted. This error may occur if 
   your TopKey installation package is defective.

   Windows may be configured so that a shell other than the Program 
   Manager is used. In this case, the installation program may not 
   create the TopKey for Windows group. This group is used by the 
   Program Manager itself only, it isn't obligatory for TopKey. If 
   necessary, you can create such group yourself by placing the 
   following two icons in it: WTOPKEY.EXE and ED_WTK.EXE.




                           4. USING TOPKEY

   On starting the WTOPKEY.EXE mapper, an additional icon appears on 
   the screen, which corresponds to the TopKey mapper started. This 
   icon and an inscription on it indicate current keyboard profile 
   used.

   You can change active keyboard profile by pressing corresponding 
   hot-key (key combination):

      CTRL ALT F1      - keyboard assigned in Windows
      CTRL ALT F4      - Russian
      CTRL ALT F5      - German
      CTRL ALT F6      - Finnish/Swedish
      CTRL ALT F7      - Norwegian
      CTRL ALT F8      - phonetic

   You can also do it, using menu: click by the mouse (left button) 
   on the icon of the TopKey mapper started. Then, system menu 
   appears which contains the following commands:

   Restore        - call dialog box to change TopKey for Windows 
                    parameters.
   Move           - move the TopKey icon.
   TopKey is ON   - TopKey mapper is active, if this command is 
                    ticked off.
   -----------
   Close          - close TopKey.
   -----------
   ...            - list of the names of the keyboard profiles loaded 
                    in memory, current keyboard profile is ticked 
                    off.

   Choose the name of necessary profile in this menu.

   Using the system menu, you can also turn the TopKey mapper on or 
   off (by choosing 'TopKey is ON'), or call a special dialog box to 
   change TopKey parameters by choosing 'Restore'.

   On choosing 'Restore', the dialog box is displayed on the screen, 
   which contains the following elements:

   Buttons:
      Done           - close the dialog box.
      Unload         - equivalent to 'Close' in the system menu.

      Tune Sounds    - switching profiles, and some events taking 
                       place in TopKey can be accompanied by sound. 
                       On pressing this key, the dialog box is called 
                       for setting sound connected with certain 
                       event.

      Tune Profiles  - call the dialog box to set profiles. This 
                       dialog box is used to delete unnecessary 
                       profiles, add new profiles, or change 
                       parameters (e.g., to choose sound accompanying 
                       the switching to a given profile).

      Save Settings  - save current parameters in the TOPKEY.INI 
                       file.


   The list of names of keyboard profiles
      ... - choose active profile.


   Group of checkboxes

      TopKey is ON         - equivalent to 'TopKey is ON' in the 
                             system menu.

      always on top        - TopKey icon is always over windows.

      play sounds          - all sounds generated by TopKey can be 
                             enabled or disabled.

      rename with profile  - icon and, optionally, an inscription 
                             below it are changed after changing a 
                             profile.

      autosave settings    - automatically save TopKey parameters on 
                             finishing the work.


                            Setting sound

   To make the use of TopKey easier, sound indicating certain evemts 
   and the changing of current active profile is provided for.

   Standard Windows means are used to produce sound, which function, 
   provided a special sound card (e.g., AdLib Sound) is present, or 
   the special 'PC Speaker' driver is present (standard Windows 
   package doesn't contain this driver).

   To enable sound in TopKey, it must be recorded first and written 
   in the format of a .WAV file. After that, corresponding sound can 
   be assigned to an event (or a profile).

   Dialog box 'Tune Event Sounds' provides for the opportunity to 
   connect events with files containing necessary record. The dialog 
   box contains the list of events and the files connected. In 
   choosing an event, a special list can be called which contains the 
   names of standard Windows sound effects and .WAV files. The 'None' 
   element meaning the absence of sound connected with the event is 
   always first in the list.

   TopKey generates sound for the following events:

      Start          - starting TopKey

      Exit           - exiting TopKey

      On             - turning TopKey on ('TopKey is ON' in the 
                       system menu).

      Off            - turning TopKey off ('TopKey is ON' in the 
                       system menu).

      Save settings  - save parameters to the disk.

      Duplicate run  - attempt to start TopKey which is started 
                       already. In this case, sound is generated, and 
                       the main dialog box of the mapper started is 
                       called.

      Error          - error occurred; e.g., if you try to load more 
                       than 200 different profiles at the same time, 
                       error of insufficient memory may occur.

      Acknowledge    - TopKey calls a special dialog box when certain 
                       errors occur.


                           Profile setting

   On pressing 'Tune Profiles' in the main menu, the special dialog 
   box 'Tune Keyboard Profiles' is called, providing for the 
   opportunity to choose parameters of the profiles used. It contains 
   several keys and lists, using which all necessary manipulations 
   with profiles can be performed.

   Keys 'Create New' and 'Delete' serve for adding new profile or 
   deleting an existing one, accordingly. The 'Rename' key is used to 
   change the name of current profile.

   Using the 'name of profile' list, a profile can be chosen, 
   parameters of which are described in the other lists of the dialog 
   box:

      'profile file .kbw'  - it provides for the opportunity to 
                             choose a file describing a keyboard 
                             profile.

      'transfer file .trn' - intermediate files used in DOS/Windows 
                             transcoding are needed to use keyboard 
                             profiles developed for the TopKey for 
                             DOS program.

      'assumed icon'       - it provides for the opportunity to 
                             choose an icon corresponding to a given 
                             profile.

      'sound file .wav'    - it is used to choose sound accompanying 
                             the switching to a given keyboard 
                             profile.


              5. CREATING AND EDITING KEYBOARD PROFILES

   Keyboard profiles for TopKey for Windows can be created and edited 
   using the ED_WTK.EXE program.

   Keyboard profile consists of a "root table" and (optionally) 
   sub-tables. Each profile has its own ID number which must be 
   unique (Topkey cannot use more than one keyboard profile with a 
   given number). A profile can also have (optionally) hot-key 
   assignment - key combination pressing which leads to switching to 
   this profile.

   Root table and sub-tables have similar format, and can be arranged 
   in a tree-like structure. Tables (sub-tables) contain new 
   assignments for keys which must be interpreted in non-standard 
   way.

   The following assignments for keys (key combinations) can be used:

   "ANSI symbol"              - on pressing the key, the symbol 
                                indicated is printed.

   "line of symbols"          - on pressing the key, line of symbols 
                                is printed, as opposed to a single 
                                symbol.

   "move to sub-table"        - the next time the key (key 
                                combination) is pressed, Topkey is 
                                looking for assignments for the key 
                                (key combination) in the sub-table 
                                indicated; if no reassignment is 
                                found, TopKey will be looking for it 
                                in the root table. This assignment is 
                                used in 'dead-char' sequences.

   "default function"         - this key is used in the standard way 
                                (this assignment is used very rarely, 
                                for all the keys not described in the 
                                keyboard profile are interpreted in 
                                the standard way).

   "ignore pressing the key"  - ignore pressing a given key (it is 
                                used very rarely, like the previous 
                                assignment).

   When Topkey for Windows is checking if the key pressed is 
   reassigned, it is also checking if special keys (Alt, Ctrl, Shift) 
   are pressed simultaneously, and the status of switch keys (Caps 
   Lock, Num Lock, Scroll Lock). Thus, it is possible to make 
   different assignments to a key and its various combinations with 
   special keys.


                         ED_WTK main screen

   Computer keyboard is displayed at the bottom of the screen. 
   Inscriptions on the keys correspond to their current assignments 
   in current (indicated) sub-table for current (indicated) status of 
   special keys.

   "Current" status of special keys and a button for calling the 
   dialog box to change the status are displayed above the keyboard 
   picture.

   There is a table of available key assignments placed in the top of 
   the screen: symbols with codes of 0 to 255, and special 
   assignments (in the right part of the table). Symbols are 
   displayed using font which can be changed using the FONT menu.

   Visualization conventions:

   - assignments of keys which are not reassigned are displayed on 
     black background;

   - assignments of keys in current table (sub-table) for current 
     status of special keys are displayed on grey background (default 
     color of Windows buttons);

   - macro assignment (line of symbols) is displayed by the "m" 
    character in the circle;

   - "go to sub-table"  - by the "s" character in the circle;

   - "ignore" - by the "i" character in the circle;

   - "default action"  - by the "d" character in the circle;

   - if the assignment will be used by the program in the current 
     table (sub-table) for current status of special keys, but will 
     be written to another sub-table or used for another (e.g., more 
     general, i.e., "any" etc.) status of special keys, "symbol 1" is 
     displayed additionally in the left part of the key (in the OEM 
     fonts it is a "happy face", in the ANSI fonts it is a vertical 
     band).


               Editing or creating a keyboard profile

   Use the "File" menu to read, write to disk or create new keyboard 
   profile.

   If you use fonts with various symbol codes, to display symbols 
   choose the font for which you are creating a keyboard profile. To 
   do that, use the "Font" menu.

   In editing, the program can be set so that either new assignments 
   only can be seen for keys in current table (sub-table), or "how 
   TopKey will interpret" the keys for current status of special keys 
   can be seen too. To set, use the "View" menu.

   Use the "Profile" menu and the hot-key to set the ID number of the 
   keyboard profile (Profile ID). Hot-key is a combination of keys, 
   used for switching to a given keyboard profile.

   To view the whole keyboard profile, change current status of 
   special keys, enter sub-tables.

   Use the "Customize status" button to call the dialog box for 
   choosing current status of special keys.

   In this dialog box you can set needed status of special keys, 
   using "radio buttons", or you can choose a suitable "list of 
   available statuses" in the combo-box. The list contains standard 
   statuses of special keys, and all statuses used in current table 
   (sub-table).

   The following definitions are used:

      Any      - any meaning (either the key is pressed, or not).

      On       - key is pressed, or "turned on" (Num Lock, Caps Lock, 
                 and Scroll Lock).

      Off      - key is not pressed, or "turned off".

      Left     - left key of two similar keys (Alt, Ctrl, Shift) is 
                 pressed.

      Right    - right key of two similar keys (Alt, Ctrl, Shift) is 
                 pressed.

      SumShift - integral status Shift and Caps Lock (equal to 'On', 
                 if Shift is pressed and Caps Lock is turned off, or 
                 Shift is not pressed and Caps Lock is turned on).


   Standard statuses:
      - Lowcase letters:
         Corresponds to SumShift=Off with Alt and Ctrl not pressed 
         and the NumLock and ScrollLock indicators turned off. It is 
         used to assign small letters.

      - Uppercase letters:
         Corresponds to SumShift=On with Alt and Ctrl not pressed and 
         the NumLock and ScrollLock indicators turned off. It is used 
         to assign capital letters.

      - Shift symbols:
         Corresponds to Shift=On with Alt and Ctrl not pressed and 
         the NumLock and ScrollLock indicators turned off. It is used 
         to assign symbols placed above the numerical characters in 
         the top line of the keyboard, and some other characters.

      - NonShift Symbols:
         Corresponds to Shift=Off with Alt and Ctrl not pressed and 
         the NumLock and ScrollLock indicators turned off. It is used 
         to assign numerical characters placed in the top line of the 
         keyboard, and some other characters.

      - "Any":
         Any status of special keys.

   You can also view the list of all assignments for keys in current 
   table (sub-table). To do that, click by the mouse on the picture 
   of the key. In the list displayed choose an assignment and "press" 
   the "Ok" button. Current status of special keys will change 
   according to this assignment, and you will be able to see the 
   assignments for other keys for this status.

   To reassign a key for current status of special keys, simply 
   "draw" by the mouse the assignment from the table of assignments 
   available to the key needed.

   If new assignment work incorrectly due to incorrect order of 
   records-assignments for this key, the program will warn you and 
   display the list of assignments for this key in the order in which 
   this list will be run over by the TopKey program. Correct the 
   order of the records in this list, using the "FLIP" button, or 
   delete unnecessary records.

   While TopKey is checking if the key is reassigned, it first runs 
   over the current table (sub-table), then (if no reassignment is 
   found) - the root table, and, if the key is not reassigned, uses 
   default assignment. If a suitable key reassignment is found, 
   further running over the table is not carried out (the first 
   assignment suitable for a given status of special keys is used).

   Some statuses of special keys "overlap" other statuses. E.g., the 
   "Shift On" status overlaps the "Shift Left" status, for "Shift On" 
   = "Shift Left" or "Shift Right" or both are pressed. So, the 
   conclusion can be made that the order of assignments is important 
   for TopKey.

   To edit macro assignment, simply click by the mouse on the picture 
   of the key which has this assignment. You can edit a line of 
   symbols, using the keyboard or clicking by the mouse on the 
   pictures of symbols in the table in the top of the screen.

   You can go to a sub-table, if there is the "go to sub-table" 
   assignment for current status of special keys in current table 
   (sub-table).

   Click by the mouse on the picture of the key which has the current 
   assignment of "go to sub-table", then click by the mouse on the 
   "go to sub-table" button.

   To return from the sub-table, click by the mouse on the "back from 
   sub-table" button.

   The "go to sub-table" assignment can be moved to another key 
   without destroying the table. Click by the mouse on the picture of 
   the key with the current assignment of "go to sub-table", then 
   click by the mouse on the "move it to another key" button. You 
   will see a special mouse cursor in the form of a flag. Put the 
   flag to the key needed (move the cursor and press the left button 
   on the mouse).

   The "go to sub-table" assignment can be also moved to the same key 
   for another status of special keys. Click by the mouse on the 
   picture of the key with the current assignment of "go to 
   sub-table", then click by the mouse on the "modify status" button. 
   The program will display the dialog box for changing the status of 
   special keys.


               Setting ID number of a keyboard profile

   Choose the "Profile"/"Set Profile ID" menu. Type the number and 
   press "Ok".

   Numbers from 1 to 32767 are available.

   Attention: The program does not allow to save a keyboard profile 
   without ID number to disk.

   Attention: Topkey does not allow to load in memory more than one 
   keyboard profile with the same ID number.


               Setting hot-key for a keyboard profile

   Choose the "Profile"/"Set Hot Key" menu.

   To set hot-key, the key and the status of special keys must be 
   indicated.

   To indicate the key, click by the mouse on the "set scan" button 
   in the "Hot key" dialog box. You will see a special mouse cursor 
   in the form of a flag. Put the flag to the key needed (move the 
   cursor and press the left button on the mouse).

   To set the status of special keys, corresponding to the hot-key, 
   click by the mouse on the "set status" botton in the "Hot key" 
   dialog box, and choose a status in the dialog displayed for 
   setting the status of special keys.

   To delete hot-key, click by the mouse on the "delete" button in 
   the "Hot Key" dialog box, then "press" the "Ok" button to confirm.


                     6. TOPKEY DATA FILE FORMAT

                  Keyboard profile description file

   Data format of TopKey for Windows is sismilar to that of TopKey 
   for DOS. It must be pointed out only, that symbol codes in DOS 
   (OEM codes) are different from those in Windows (ANSI codes); in 
   addition, there are several symbol code (code page) standards in 
   DOS and Windows, and non-standard code pages may be used too. So, 
   the use of keyboard profiles for DOS in Windows requires special 
   transcoding tables. These are *.TRN files in TopKey for Windows. 
   Detailed structure of these files will be discussed later, 
   following the discussion of the keyboard profile files format.

   Let's discuss the keyboard profile files format.

   A profile consists of 4 parts: head, key reassignment table 
   itself, and data thereof (if necessary); in addition, hot-key 
   assignment can be given in the end of the file.

     +----------_-------------------_------------------++----------+
     |1.header  | 2.keystroke table |  3.optional data ||4.hot-key |
     +----------+-------------------+------------------++----------+

   In memory the profiles loaded follow each other and have the same 
   format as the file, except for hot-key assignments. While TopKey 
   is loading the profile in memory, the hot-key is being included 
   into the "zero profile".

   Hot-key assignment consists of 3 bytes: the first byte is the 
   scan-code of the key, and the following word is the integrated 
   status of function keys (see below).

   Head of table:

         +-----------------------------------------------------+
         | word | Number of keys reassigned                    |
         +------+----------------------------------------------|
         | word | Table ID                                     |
         +------+----------------------------------------------|
         | word | Size of the table, including head, in bytes  |
         +-----------------------------------------------------+

   Keyboard profile table contains the list of those keys only 
   assignments of which differ from those used by the hardware 
   driver. The number of modifications must not be zero. A table 
   cannot contain zero number of assignments.

   Table ID is an integer number of 0 to 65535; the number 0 is 
   assigned to the base table; other numbers of tables must be 
   unique. A table is chosen in the list by this number.

   Size of the table must be indicated in bytes.

   Table of keyboard reassignments

   This table consists of records of the size of 4 or 6 bytes. Each 
   record reassigns one key. The number of records in the table is 
   indicated in the head of the table. The records follow each other 
   continuously; 4-byte records are NOT justified to 6-byte ones. The 
   size of each record is determined by the context of the record.

          +------------------------------------------+
          | byte | Scan-code of the key reassigned   |
          +------+-----------------------------------|
          | word | Modified status of the key        |
          +------+-----------------------------------|
          | byte | New assignment or command number  |
          |------+-----------------------------------+
          | word | additional data word              |
          +------------------------------------------+


   The list of scan-codes of keys is given in Supplement 1. You can 
   also refer to user's guides to your computer, particularly if it 
   somewise differs from standard version, or to Tech Help, Norton 
   Guide etc. The driver reads scan-code from port 60h.

   For the keys which have analogs (grey keys), you must indicate 
   either the scan-code - for white keys, or the scan code increased 
   by 80h (or decimal 128) - for grey keys. If you want to assign the 
   same meaning to both keys, you must assign the meaning to each of 
   them separately. Additionally take into account that the right 
   Ctrl and Alt keys are considered as "grey" ones, i.e. their 
   scan-codes must be increased by 80h. (More correctly: keys the 
   scan-code of which must be increased by 80h are the keys which are 
   preceded by code E0h (224)).

   Modified status of the keyboard determines at which combination of 
   the statuses Shift, Ctrl, Alt, CapsLock, ScrollLock, and NumLock 
   the reassignment for this key is active. This status is described 
   in a single word of the following format:

             Byte number                    Comment
    ----------------------------------------------------------
      F E DC BA 98 76 54 32 10
      | | || || || || || || +---- Shift         RL-attribute
      | | || || || || || +------- Ctrl          RL-attribute
      | | || || || || +---------- Alt           RL-attribute
      | | || || || +------------- Summary Shift UD-attribute
      | | || || +---------------- CapsLock      UD-attribute
      | | || +------------------- ScrollLock    UD-attribute
      | | +---------------------- NumLock       UD-attribute
      | +------------------------ compare       compare flag
      +-------------------------- command       command flag


   RL-attribute is a 2-byte attribute which can have one of the 
   following meanings:

      00b - any status allowed
      01b - left key only must be pressed
      10b - right key only must be pressed
      11b - either left, or right key must be pressed, i.e. the 
            status must be active.

   Meanings of RL-attributes change in some extent depending on the 
   compare flag: if the flag is dropped, the meaning of RL-attribute 
   is as described above; if the flag is set, the meaning of the 00b 
   attribute is "status must be dropped", i.e. neither of the two 
   keys (left and right) must be pressed. Compare flag effects all 
   three RL-statuses, Shift, Ctrl and Alt at the same time. In doing 
   so, the effect on the Shift status depends also on the "summary 
   shift" attribute (see below).

   RL is the abbreviation of (R)ight - (L)eft.

   UD-attribute is a 2-byte attribute which can have one of the 
   following meanings:
      00b - any attribute allowed
      01b - attribute must be active
      10b - attribute must be dropped
      11b - this value is illegal.

   Meanings of UD-attributes don't depend on compare flag or other 
   statuses. Meanings of the CapsLock, ScrollLock and NumLock 
   statuses correspond to their names.

   The "Summary  Shift" status is an integration of the Shift and 
   CapsLock attributes. This status is considered active, either if 
   one of the two Shift keys is pressed, or both of them, or the 
   CapsLock key; and it is considered dropped, if neither Shift, nor 
   CapsLock is pressed, or CapsLock and one of the two Shift keys, or 
   both of them are pressed. This status is used to assign keys of 
   the main alphabetic keyboard.

   Command flag can be dropped. In this case, it is considered that 
   this is a new ASCII-code assignment for the key. New ASCII-code is 
   written in the 4th byte of the record, additional data word is not 
   used. The record with the new ASCII-code is a 4-byte one. This 
   ASCII-code will be written to the keyboard buffer; in doind so, 
   the scan-code written to the buffer will be set as read from port 
   60h. Code E0h (224) cannot be handled in such way. To input a 
   symbol with this code, the scan-code must be dropped to 0 to 
   imitate ALT-input (see below).

   Command flag can be set to 1; in this case, the 4th byte 
   determines the code of the command, and the command can use 
   additional data word. The size of the record with the command is 4 
   or 6 bytes, depending on the command.

   The commands can be as follows:

      FFh - change current table by address
      FEh - send line
      FDh - change the table by address, for the next single pressing only
      FCh* - assign ASCII/SCAN combination
      FBh* - send line of ASCII/SCAN combinations
      FAh - change the table by table ident
      F9h* - send single ASCII/SCAN combination
      01h - do not send any data on pressing this key
      00h - do not change the hardware assignment

   Attention: (*) Commands marked with this symbol are used in TopKey 
   for DOS; TopKey for Windows doesn't use these commands, FCh and 
   F9h in it are equivalent to assignment of new symbol, FBh is 
   equivalent to FEh; in this case, SCAN is ignored.

   The FFh, FEh, FDh and FBh commands use address to indicate the 
   beginning of the corresponding object - a table or a line. The 
   address is read from the beginning of the record in which a given 
   command is described, to the beginning of the corresponding 
   object, i.e., the distance to the object is used as the address. 
   The size of the record of these commands is 6 bytes.

   The table at which the FFh and FDh commands point must be placed 
   in the third part of a given table - among optional additional 
   data. Any assignment can be written in the "ident" field of the 
   head of these tables, for this field is not used. In other 
   aspects, format of these pages is similar to that described above. 
   Changing a table for a single pressing is needed in many 
   languages, e.g., to describe accented symbols, or characters with 
   double comma above them. In doing so, the accent key is pressed 
   first, and then the key with the character is pressed.

   Lines sent by the FEh and FBh commands have similar format. The 
   number of symbols sent is indicated in the first byte, followed by 
   the list of the symbols. For the FEh command the symbols consist 
   of a single byte - ASCII-code, and for the FBh command the symbols 
   consist of two bytes - the ASCII-code is indicated in the first 
   one, and the SCAN-code (or the extended ASCII-code) is indicated 
   in the second one. The lines are sent through interrupt 16h.

   The FCh command is used to write ASCII/SCAN combination to the 
   keyboard buffer. This command is needed, e.g., to imitate 
   ALT-input of symbols, when the SCAN-code equal to 0 is set. The 
   ASCII-code is indicated in the junior byte of the additional data 
   word of the record, and the SCAN-code is indicated in the senior 
   one. Symbols with the code E0h or F0h can be printed by this 
   command. The size of the record is 6 bytes.

   The FAh command is used to change tables by their IDs. Relative 
   addressing (i.e., assignment of distances) is suitable inside a 
   table, but is not effective between tables, for tables may move as 
   modifications are being made. Calling tables is more convenient 
   using the ID access mechanism. In the record containing this 
   command an additional data word is used which contain the number 
   of the table chosen. This method is limited by tables of 
   "external" level only. See the following diagram:


   +------------------++------------------++------------------+
   |  Table 1         ||  Table 2         ||   Table 3        |
   |+----------------+||+----------------+||+----------------+|
   || Sub-table 1-a  |||| Sub-table 2-a  |||| Sub-table 3-a  ||
   |+----------------+||+----------------+||+----------------+|
   |+----------------+|+------------------+|+----------------+|
   || Sub-table 1-b  ||                    || Sub-table 3-b  ||
   |+----------------+|                    |+----------------+|
   +------------------+                    |+----------------+|
                                           || Sub-table 3-c  ||
                                           |+----------------+|
                                           +------------------+

   Using the FAh command, the tables 1,2,3 (there can be more or less 
   of them - three are pictured in this exmple) only can be chosen, 
   and the sub-tables included into the tables 1, 2 and 3 are 
   inaccessible for this function. E.g., to call the sub-table 3-b 
   from the table 3, use the FFh command, calling sub-tables of the 
   tables 1 or 2 from the table 3 is impossible, the corresponding 
   table must be called first.

   So, a single table of the "external" level is a unit of 
   description of keyboard and can correspond to any language. The 
   structure of this table may be very complicated, with sub-tables 
   enclosed and lines assigned. It provides for the opportunity to 
   use such tables not only for description of a language, but also 
   for modification of commands or creation of macro sequences for 
   specific applications.

   The 01 and 00 commands require no additional data; the size of a 
   record with these commands is 4 bytes. There are no any special 
   comments on the use of these commands - they are needed very 
   rarely.


   Description of *.TRN files

   TRN files contain the following data:

   Head of file:

        WORD=  size of the rest of the file
        WORD=  number of records

   Each record contain 3 bytes describing DOS/Windows symbol 
   transcoding.

   Format of the record:

      BYTE=  first symbol of the interval
      BYTE=  last symbol of the interval
      BYTE=  constant value which must be added to symbols of the interval for the purpose of transcoding.

   Such file can be easily compiled. Below a BASIC program is given 
   which form RU2ANSI.TRN. To form another TRN file, you need to edit 
   a few lines only in this program: the OPEN directive (change the 
   name of the file), and the DATA records in the end of the program.

     RU2ANSI.BAS:

     '
     ' opening the file which is to be formed (RU2ANSI.TRN)
     '
     100 open "ru2ansi.trn" for output as #1
     '
     ' calculating size and writing to file
     '
     110 read N%
     120 S%= N%*3 + 2                    ' data size
     130 SH%= S% / 256
     140 SL%= S% - SH% * 256
     150 print #1,chr$(SL%);chr$(SH%);   ' writing it to file
     '
     160 NH%= N% / 256
     170 NL%= N% - NH% * 256
     180 print #1,chr$(NL%);chr$(NH%);   ' writing the number of records
     '
     190 for i%= 1 to N%
     200    read f%,t%,a%                ' writing data
     210    print #1,chr$(f%);chr$(t%);chr$(a%);
     220 next i%
     '
     300 close #1
     310 stop
     '
     '  in the code page 866 in DOS
     '  the letters of Russian alphabet from '' through '' are located
     '  in the interval 128-175, and the letters from '' through '' -
     '  in the interval 224-239.
     '
     '  in russified Windows code page letters of Russian alphabet are
     '  located in the interval 192-255.
     '
     '  to transcode from DOS to Windows we add 64 to symbols of the
     '  interval 128-175, and we add 16 to symbols of the
     '  interval 224-239
     '
     '  number of records
     400 data 2
     '
     '  first record
     410 data 128, 175, 64
     '
     '  second record
     420 data 224, 239, 16
     '
     500 end
     RUN


   To use this BASIC program:
      - Create a text file of this program.
      - Run it, using your BASIC.

   E.g.:
   If you have GWBasic, type the command:

            C:\DOS>gwbasic <ru2ansi.bas

   Attention: In this case, there must be the RUN command typed in 
   the last line of the file of the program.

   If you use TuboBasic, type the command:

            C:\DOS>tb ru2ansi.bas

   On loading, press ESC and choose the 'RUN' command.  
   To escape, press ALT+X.

   If you have QuickBasic (it is included into standard MS-DOS v.5.0 
   package), type the command:

            C:\DOS>qbasic ru2ansi.bas

   On loading, press SHIFT+F5.
   To escape, press ALT+F first, then X.



                            Supplement 1.

                 Names of keys and their scan-codes

      +-----------------------------------------------------------------+
      | Key      Scan | Key      Scan | Key      Scan  | Key      Scan  |
      |---------------+---------------+----------------+----------------|
      | Esc         1 | I          23 | X           45 | F9          67 |
      | 1           2 | O          24 | C           46 | F10         68 |
      | 2           3 | P          25 | V           47 | NumLock     69 |
      | 3           4 | [{         26 | B           48 | ScrollLock  70 |
      | 4           5 | ]}         27 | N           49 | Home        71 |
      | 5           6 | Enter      28 | M           50 | Up Arrow    72 |
      | 6           7 | Ctrl       29 | ,<          51 | PgUp        73 |
      | 7           8 | A          30 | .>          52 | Gray -      74 |
      | 8           9 | S          31 | /?          53 | Left Arrow  75 |
      | 9          10 | D          32 | Right Shift 54 | Numpad [5]  76 |
      | 0          11 | F          33 | PrintScreen 55 | Right Arrow 77 |
      | -_         12 | G          34 | Alt         56 | Gray +      78 |
      | =+         13 | H          35 | Spacebar    57 | End         79 |
      | Backspace  14 | J          36 | CapsLock    58 | Down Arrow  80 |
      | Tab        15 | K          37 | F1          59 | PgDn        81 |
      | Q          16 | L          38 | F2          60 | Insert      82 |
      | W          17 | ;:         39 | F3          61 | Delete      83 |
      | E          18 | '"         40 | F4          62 | SysReq      84 |
      | R          19 | `~         41 | F5          63 | ??          85 |
      | T          20 | Left Shift 42 | F6          64 | ???         86 |
      | Y          21 | \|         43 | F7          65 | F11         87 |
      | U          22 | Z          44 | F8          66 | F12         88 |
      +-----------------------------------------------------------------+


                            Supplement 2.

       TRN files included into the TopKey for Windows package


   866-ANSI.TRN
      It provides for the use of keyboard profiles developed for the 
      code page 866 (alternative Russian code page, or all code pages 
      compatible with it) in Windows with russified fonts. As far as 
      symbols of the Russian alphabet are concerned, it is fully 
      compatible with the code pages 900 and 920.


   900-ANSI.TRN
      It is an extended 866/ansi transcoding table providing for the 
      use of keyboard profiles developed for the code page 900 
      (Russian and Finnish languages) in Windows, which uses a 
      special version of russified table. (Fonts needed are included 
      into the TopKey package).


   920-ANSI.TRN
      It is a further extention of the table 900/ansi. It provides 
      for the use of keyboard profiles with all additional symbols of 
      the code page 920 in Windows. Corresponding fonts must be used 
      in Windows.
