             ANALYSI O WORDSTA  PRINTE DRIVE DAT SEGMENT

                            Charle Christenson
                                [76012,1050]

     WordStar 4 printer drivers consist of two segments: CODE and DATA.  The 
DATA segment contains the printer control codes required to make the printer 
perform its various functions.  Many of these codes are identified by label 
in a WSCHANGE menu but others are not, and the locations of the unidentified 
codes have not yet been publicly documented by MicroPro.  

      Although almost all of the WordStar 4 drivers have identical CODE 
segments (the exceptions are the generic drivers such as DRAFT and SIMPLE 
and the drivers for early-model daisy wheel printers), the DATA segments are 
different because of the different capabilities supported.  For this reason, 
the addresses of the control codes differ from driver to driver.  However, 
I have discovered that, for those drivers with a DATA segment beginning at 
address 1C08, the beginning of the DATA segment contains a jump table of 
two-byte addresses of the locations where the actual control codes are 
found, and this table has the identical form in all such drivers.

     The listing below is of this jump table.  I have included the function 
of the code pointed to in as many cases as I have been able to identify.  I 
believe I have been able to identify most of the code for printers following 
the Epson/IBM codes for dot matrix printers and the Hewlett-Packard codes 
for laser printers.  A question mark appears where I have not been able to 
identify the function.  

     To find a particular control code in a particular driver, use the 
listing to find where in the jump table to find the address, then use the 
address to find the code.  The addresses in the jump table are given in 
"back-word" order; that is, if the table look-up gives you the two bytes "BF 
20", the address you want to look for is "20BF." 

      Example using the HPLJET driver: To find the string setting landscape 
orientation, from the WSCHANGE main menu choose B C D = and then specify the 
Driver address as either "1C78" or "DATA+70".  The first two bytes displayed 
will be "BF 20".  Press X to go back to the previous menu, choose = again 
and then the address "20BF."  You will see "09 1B 26 6C 31 4F 1B 26 6C 45".  

      Entries in the "points to" column in upper case appear on the WSCHANGE 
menus, those in lower case generally do not.  (Some drivers do include the 
font size selection strings on the WSCHANGE menus).

 
Absolute       Offset    Points to 
========       ======    =========
 
  1C08           00      [driver name]
  1C0E           06      ?
  1C13           0B      ?
  1C15           0D      $START 
  1C17           0F      $DONE 
  1C19           11      $QUIT 
  1C2A           22      vertical cursor positioning string (Not 1)
  1C2C           24      ?
  1C2E           26      ?
  1C30           28      extended character translation table (Note 2) 
  1C32           2A      pointers to symbol set selection strings (Note 2) 
  1C34           2C      ?
  1C36           2E      ?
  1C38           30      $PF 
  1C3A           32      $PG 
  1C3C           34      ?
  1C3E           36      ?
  1C40           38      ?
  1C42           3A      ?
  1C44           3C      ?
  1C47           3F      horizontal motion index (HMI) string (Not 3)
  1C49           41      initiate high-density graphics (Not 4)
  1C4B           43      ?
  1C4E           46      horizontal cursor positioning strin (Not 1)
  1C50           48      ?
  1C52           4A      ?
  1C54           4C      start underline string (^PS on) 
  1C56           4E      end underline string (^PS off) 
  1C58           50      start boldface string (^PB on) 
  1C5A           52      end boldface string (^PB off) 
  1C5C           54      start doublestrike (^PD on)
  1C5E           56      end doublestrike (^PD off)
  1C60           58      emphasized print on
  1C62           5A      emphasized print off
  1C64           5C      start italics string (^PY on) 
  1C66           5E      end italics string (^PY off) 
  1C68           60      start superscript (^PT on)
  1C6A           62      end superscript (^PT off)
  1C6C           64      start subscript (^PV on)
  1C6E           66      end subscript (^PV off)
  1C70           68      start NLQ (.lq on)
  1C72           6A      end NLQ (.lq off)
  1C74           6C      start proportional spacing string (.ps on) 
  1C76           6E      end proportional spacing string (.ps off) 
  1C78           70      landscape orientation string (.pr or=l)
  1C7A           72      portrait orientation string (.pr or=p)
  1C7C           74      COMPOS 
  1C8           7      fon siz selectio string (.cw (Not 5)
 
Note 1.  For the Hewlett-Packard LaserJet family, and possibly for other 
printers, the strings pointed to by these addresses control vertical and 
horizontal microspacing respectively.

Note 2.  For the Hewlett-Packard LaserJet family of printers, and possibly 
for other printers, the address at 1C30 points to a 256-byte table that 
is used in conjunction with the COMPOS table to specify the character number 
and symbol set used by the driver to print each of the extended characters.  
Each extended character is assigned two bytes, the first byte being the 
character number and the second byte being the symbol set number, specified 
as explained in the following paragraph. 

For drivers that support multiple symbol sets (e.g., HPLJ:U), the address at 
1C32 points to a further table of pointers that in turn points to the 
specific symbol set selection strings.  The symbol sets are implicitly 
assigned numbers beginning with 00 which are used as described in the 
preceding paragraph.  For the HPLJ:U driver, for example, the first symbol 
set selection string begins at 2591 and is assigned number 00; it selects 
the Roman8 symbol set for both fixed-pitch and proportional fonts. The 
second symbol set selection string begins at 259A and is assigned number 01; 
it selects the Line Draw symbol set for both fixed-pitch and proportional 
fonts.  

Here is an illustration of how extended characters are printed (on the 
LaserJet, at least).  Suppose you wish to print a light upper-left box 
corner.  This is character 169 in the IBM PC character set.  You therefore 
hold down the Alt key while keying in the number 169 on the numeric keypad.  
In your file, this character is stored as 1B A9 1C, A9 being the hex 
equivalent of decimal 169 and 1B and 1C being the WordStar "flags" used to 
bracket extended characters.  When you print the file using the HPLJ:U 
driver, the driver first consults the COMPOS table and discovers that 
character A9 is to be printed as "80 00".  The "00" in the second position 
means that no overstriking is required to produce this character.   The "80" 
in the first position means that the character to be printed is the first 
character defined in the table pointed to by 1C30 (since this table defines 
only the extended characters, those from 80h to FFh).  The driver then 
consults this table and finds that the first character is defined as "52 
01".  This means that the character to be printed is character 52 in symbol 
set 01.  Symbol set 01 is the Line Draw set.  Therefore, the driver first 
sends to the printer the escape sequence to activate the Line Draw set.  
Then it sends character 52 (which is, indeed, a light upper-left box corner 
in the Line Draw set).  Finally, the driver sends the appropriate escape 
sequence to restore the default symbol set, that identified as number 00.  

Note 3.  For the Hewlett-Packard LaserJet family, and possibly for other 
printers, the string pointed to by this address determines how far the 
cursor (print head) advances when a character is printed.

Note 4.  For an Epson/IBM dot matrix printer, the string pointed to by this 
address initiates high-density graphics printing.  I believe that this 
string is used in microjustifying on such printers.

Note 5.  There is a separate font size selection string for each font size 
supported by the driver.  The addresses of all these strings are given 
beginning at the address 1C84.  In addition to the address of the font size 
selection string, the table beginning at 1C84 also appears to give other 
information about the font, including character width.  
