home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / Amiga_Mail_Vol1 / Printer / WritingPD < prev   
Encoding:
Text File  |  1999-10-27  |  27.5 KB  |  641 lines

  1. (c)  Copyright 1989-1999 Amiga, Inc.   All rights reserved.
  2. The information contained herein is subject to change without notice, and 
  3. is provided "as is" without warranty of any kind, either expressed or implied.  
  4. The entire risk as to the use of this information is assumed by the user.
  5.  
  6.         Writing a V1.3 Graphics Printer Driver
  7.  
  8.             by David Berezowski
  9.  
  10.  
  11.  
  12. Under V1.3 of the Amiga system software, the printer device has been
  13. enhanced.  This article gives you an overview of the changes and provides
  14. some of the information you will need to bring you V1.2 drivers up to date.
  15.  
  16. Do not use this article alone as a 'how-to' reference.  You should also
  17. review the source code for the V1.3 printer drivers on the devcon disk.
  18. These are good examples to work from and show the changes needed from 
  19. previous Workbench releases.  Additionally, the "ROM Kernel Reference 
  20. Manual: Libraries and Devices" (chapter 15, Printer Device) should be used 
  21. as reference material.  Use this article as a supplement.
  22.  
  23.  
  24.  
  25. Printer Driver Source
  26. ---------------------
  27.  
  28. To help you in developing your own V1.3 custom printer drivers for the Amiga, 
  29. the source files to the Workbench printer drivers are included on the devcon 
  30. disk.  All the Workbench printer drivers include six modules: data.c, 
  31. dospecial.c, init.asm, printertag.asm, render.c, and transfer.c.  Additional 
  32. source code files may be required to handle the special capabilities of the
  33. printer you are working with.  The chart below shows the extra files needed
  34. with the Workbench printer drivers:
  35.  
  36.  
  37.       Printer         Extra Source Files       Printer Type
  38.       -------         ------------------       ----------------------
  39.  
  40.       ColorMaster     prtready.c               YMC_BW, multi-pass,
  41.                                                page oriented
  42.  
  43.       ColorMaster2    prtready.c               YMC_BW, page oriented
  44.  
  45.       EpsonQ          density.c                YMCB, 24 pin, multi-density 
  46.  
  47.       EpsonX          density.c                YMCB, 8 pin, multi-density,
  48.                                                interleaved densities
  49.  
  50.       HP_LaserJet     density.c                BW, multi-density,
  51.                                                page oriented
  52.  
  53.       Okimate_20      none                     YMC_BW
  54.  
  55.       Xerox_4020      none                     YMCB, ink jet,
  56.                                                uses run-length encoding
  57.  
  58.  
  59.     
  60. V1.3 RENDER.C 
  61. -------------
  62.  
  63. Render.c is the main module of a graphic printer driver.  The original
  64. documentation for this module appears in the "ROM Kernel Manual:Libraries
  65. and Devices".  Be sure to refer to the original docs as well as this
  66. article when writing you printer driver.
  67.  
  68. Render.c now has seven cases.  Before we consider the details of each case,
  69. there are two miscellaneous items not covered in the RKM that I want to 
  70. mention.  First, be sure the arguments to render.c - ct, x, y, status - are
  71. declared as longs.  Second, when you call PWrite, check the return code.  
  72. If it isn't PDERR_NOERR you must exit immediately.  If you do not exit
  73. immediately, the user may not be able to cancel the printing.
  74.  
  75.  
  76. Case 5: Pre-Master Initialization
  77. ---------------------------------
  78.  
  79. This is a new case and the first call you will get.  The render.c parameters 
  80. will be:
  81.  
  82.     ct - 0 or pointer to the IODRPReq structure passed to PCDumpRPort.
  83.      x - io_Special flag from the IODRPReq structure.
  84.      y - 0.
  85.  
  86. When the printer device is first opened it makes this call with ct=0.
  87. This gives the driver a chance to to set up the density values before the 
  88. actual graphic dump is called in a manner compatible with pre-1.3
  89. software.
  90.  
  91. The x parameter will contain the density and other SPECIAL flags which are
  92. defined in the file devices/printer.h.  Currently the only flags that 
  93. you will be interested in are DENSITY1 to DENSITY7.  These are explained
  94. further under case 1 below.  The flag SPECIAL_CENTER should be ignored as 
  95. it will always be cleared.  This flag is handled by the printer device.
  96.  
  97. Never call PWrite during this case, unless you want to crash.  When you are
  98. done handling this call, you should return PDERR_NOERR.
  99.  
  100. Case 0: Master Initialization
  101. -----------------------------
  102.  
  103. The parameters for this case are:
  104.  
  105.     ct - a pointer to a IODRPReq structure.
  106.      x - width (in pixels) of printed picture.
  107.      y - height (in pixels) of printed picture.
  108.  
  109. As under V1.2, you should allocate the memory that you will need to store 
  110. the printer data at this stage.  If the allocation fails, you should return a
  111. PDERR_BUFFERMEMORY.  If the allocation succeeds, return PDERR_NOERR.  This is
  112. also a good time to do any special one-time initializations to your printer
  113. or buffer.  
  114.  
  115. Some typical initialization codes you might send to the printer are:
  116.  
  117.    a) Carriage Return - some printers start printing graphics from where ever
  118.                         the printhead was last.  Sending a CR assures that
  119.                         printing will always start from the left edge.
  120.  
  121.    b) Uni-Directional - if you allow the printer to print graphics in
  122.       Mode              bi-directional mode you'll find that it will tend
  123.                         to produce wavy vertical lines as the two passes
  124.                         won't put dots in quite the same place.
  125.  
  126.    c) Clear Margins   - if your printer forces graphic dumps within text 
  127.                         margins, you will have to clear the margins (set left
  128.                         to minimum, right to maximum) before doing the dump.
  129.                         Refer to the EpsonX or EpsonQ source for an example.
  130.  
  131.    d) Any other       - enter graphics mode, set density, etc.
  132.       set-up
  133.  
  134.    
  135. Do not reset the printer during master initialization since this will cause
  136. problems during multiple dumps.  Also, do not use the value in ct unless 
  137. your printer is one of those rare kinds for which a render function cannot 
  138. be written.
  139.  
  140. With the addition of the Case 6 call and the PCC_MULTI_PASS color class 
  141. type, there are no known printers that need this value.  But if you do use 
  142. the value in ct to do the entire dump yourself then you must return an error
  143. of PDERR_TOOKCONTROL which tells the printer device that the dump has 
  144. already been done and to exit gracefully.
  145.  
  146.  
  147. Case 1: Put Pixels in Buffer
  148. ----------------------------
  149.  
  150.     ct - pointer to a PrtInfo structure.
  151.      x - PCM color code for this pass if the printer is PCC_MULTI_PASS.
  152.      The PCM defines from the file devices/prtgfx.h are PCMYELLOW, 
  153.          PCMMAGENTA, PCMCYAN and PCMBLACK.  
  154.      y - printer row # (range is 0 to height-1).
  155.  
  156. This case has changed completely from the V1.2 spec in order to facilitate
  157. shorter dump times.  In the call you are passed an entire row of YMCB
  158. (Yellow/Magenta/Cyan/Black) intensity values.  To handle this case, you should
  159. call transfer.c, which you may remember is one of the required driver
  160. modules.  This is described in more detail below.
  161.  
  162. You should return PDERR_NOERR after handling this case.
  163.  
  164.  
  165. Case 2: Dump Buffer To Printer 
  166. ------------------------------
  167.  
  168. The parameters for this case are:
  169.  
  170.     ct - 0.
  171.      x - 0.
  172.      y - # of rows sent (the range is 1 to NumRows).
  173.  
  174. This call has changed slightly from the V1.2 spec and has some new
  175. recommendations.  If your printer supports RLE (Run Length Encoding), now 
  176. is the time to RLE your data.  
  177.  
  178. If your printer doesn't support RLE then your should white-space strip your 
  179. data.  This involves scanning your buffer from back to front for the first 
  180. occurrence of a non-zero value.  You should send only the data up to the 
  181. first non-zero value.  In other words, do not send trailing white space data 
  182. to the printer.  Use of either of these techniques will significantly reduce 
  183. print times.  
  184.  
  185. Use the y parameter to determine how many pixels to advance the paper if 
  186. your printer supports this feature.  Implementing this feature will allow 
  187. successive graphic dumps to butt up against each other.
  188.  
  189. You should return the error from PWrite after this call.
  190.  
  191.  
  192. Case 3: Clear and Init Buffer
  193. -----------------------------
  194.  
  195.     ct - 0.
  196.      x - 0.
  197.      y - 0.
  198.  
  199. This call is made before each case 2 call.  Clear your active print buffer
  200. - remember you are double buffering - and initialize it if necessary.
  201.  
  202. You should return PDERR_NOERR after this call.
  203.  
  204.  
  205. Case 4: Close Down 
  206. ------------------
  207.  
  208.     ct - error code.
  209.      x - io_Special flag from the IODRPReq structure.
  210.      y - 0.
  211.  
  212. This call is made at the very end of a graphic dump or if the graphic dump
  213. was canceled for some reason.  You should free the printer's buffer memory
  214. at this point, but be careful.  The print buffer's memory should only be 
  215. freed if you allocated it.  If PD->pd_PrintBuf is not NULL then you have 
  216. allocated the memory, and must free it up.  
  217.  
  218. If your printer - usually a page oriented printer - requires a page eject 
  219. command, do it here.  But first check for the SPECIAL_NOFORMFEED bit in x.
  220. If it is set then you don't send the page eject command.  
  221.  
  222. If the error condition in ct is PDERR_CANCEL, then you should not PWrite.
  223. This code indicates that the user is trying to cancel the print due to a 
  224. printer problem, paper out condition, etc.  And for each PWrite you call,
  225. another printer trouble requester is generated.  Obviously we want to avoid 
  226. this. 
  227.  
  228. You should return either PDERR_NOERR or the error returned by PWrite if you
  229. called it.  Typical reasons for calling PWrite in this case are:
  230.  
  231.    a) reset line spacing -  if your printer doesn't have an advance n dots
  232.                             command, then you'll probably advance the paper
  233.                             by changing the line spacing.  If you do, then
  234.                             you should set it back to either 6 or 8 lpi
  235.                             (depending on Preferences).
  236.  
  237.    b) bi-directional mode - set it back if you selected uni-directional
  238.                             printing in case 0.
  239.  
  240.    c) black text          - some printers print the text in the last color
  241.                             used - even if it was in graphics mode.  If you 
  242.                             don't set the color to black, the text color 
  243.                             after a graphic dump will be a surprise.
  244.  
  245.    d) any other one time  - exit graphics mode, eject paper, etc.
  246.       commands
  247.  
  248.    e) If you cancelled the margins in case 0, you should restore them here.
  249.       Refer to the EpsonX or EpsonQ source code for an example.
  250.  
  251. Case 6: Switch to Next Color
  252. ----------------------------
  253.  
  254.     ct - 0.
  255.      x - 0.
  256.      y - 0.
  257.  
  258. This is a new call provided to support printers which require that colors be 
  259. sent in separate passes.  When this call is made you should instruct the 
  260. printer to advance its color panel.  You will not have to handle this case
  261. unless you are writing a driver for a printer type of PCC_MULTI_PASS, such as
  262. the CalComp ColorMaster.
  263.  
  264.  
  265.  
  266.  
  267. PRINTERTAG.ASM
  268. --------------
  269.  
  270. Printertag.asm is a standard printer description file you should create
  271. for all your printer drivers.  Here is a listing of the file and some
  272. typical values:
  273.  
  274.         MOVEQ   #0,D0              ;in case any one tries to run us
  275.         RTS
  276.         DC.W    VERSION            ;must be 35 (for V1.3)
  277.         DC.W    REVISION           ;your own revision number
  278. _PEDData:
  279.         DC.L    printerName        ;ptr to name
  280.         DC.L    _Init              ;ptr to initialization code
  281.         DC.L    _Expunge           ;ptr to expunge code
  282.         DC.L    _Open              ;ptr to open code
  283.         DC.L    _Close             ;ptr to close code
  284.         DC.B    PPC_COLORGFX       ;PrinterClass
  285.         DC.B    PCC_YMCB           ;ColorClass
  286.         DC.B    136                ;MaxColumns
  287.         DC.B    10                 ;NumCharSets
  288.         DC.W    8                  ;NumRows
  289.         DC.L    1632               ;MaxXDots
  290.         DC.L    0                  ;MaxYDots
  291.         DC.W    120                ;XDotsInch
  292.         DC.W    72                 ;YDotsInch
  293.         DC.L    _CommandTable      ;ptr to Command Strings
  294.         DC.L    _DoSpecial         ;ptr to Command Code
  295.         DC.L    _Render               ;ptr to Graphics Render
  296.         DC.L    30                 ;Timeout
  297.         DC.L    _ExtendedCharTable ;ptr to 8BitChars table($a0 to $ff)
  298.         DS.L    1                  ;PrintMode (reserve space)
  299.         DC.L    0                  ;ConvFunc (ptr to char conversion function)
  300.  
  301. printerName:
  302.     STRING    'EpsonX'
  303.  
  304. Be sure to set the VERSION field of printertag.asm to 35.  This identifies
  305. it as a V1.3 driver.  It is also important that you declare enough storage
  306. for this file.  Notice that three new fields have been added since V1.2.
  307. These new fields are 8BitChars, PrintMode and ConvFunc.
  308.  
  309. The 8BitChars field should contain a pointer to a table of chararacters for
  310. the ascii codes $a0-$ff.  The symbols for these codes are shown in the 
  311. "Amiga DOS Developer's Manual" Appendix.  Make this field null (DC.L 0) if
  312. you don't provide the table.  If you make the pointer null or use a VERSION
  313. number less than 33, a default table will be used instead.  
  314.  
  315. Creating your own table to handle codes $a0-$ff can be tricky because of
  316. the way the table is parsed by the printer device.  Valid expressions in
  317. the table include \011 where 011 is an octal number, \\000 for null and
  318. \\n where n is a 1-3 digit decimal number.  To enter an actual backslash in 
  319. the table requires the very awkward \\\\.  Shown below are the first few
  320. entries from the EpsonX[CBM_MPS-1250] table.  
  321.  
  322. char *ExtendedCharTable[] = {
  323.         " ",                                    /* NBSP*/
  324.     "\033R\007[\033R\\0",                   /* i */
  325.     "c\010|",                               /* c| */
  326.     "\033R\003#\033R\\0",                   /* L- */
  327.     "\033R\005$\033R\\0",                   /* o */
  328.     "\033R\010\\\\\033R\\0",                /* Y- */
  329.     "|",                                    /* | */
  330.     "\033R\002@\033R\\0",                   /* SS */
  331.     "\033R\001~\033R\\0",                   /* " */
  332.     "c",                                    /* copyright */
  333.         /* more entries etc. */
  334.  
  335.         };
  336.  
  337.  
  338. The PrintMode field is a flag set by the printer device and used by you in 
  339. DoSpecial and Render if you are working with a page oriented printer such 
  340. as the HP-LaserJet.  This field requires 4 bytes of storage  (ie. DS.L 1).
  341.  
  342. The ConvFunc field contains a  pointer to a character conversion function 
  343. that allows you to selectively translate any character to a combination of 
  344. any other characters.  If you don't have a translation function - most 
  345. printers won't - then you must declare the pointer to be null (ie. DC.L 0).  
  346.  
  347. ConvFunc's arguments are a pointer to a buffer, the character in question, 
  348. and a CR/LF flag.  Your ConvFunc routine should return a -1 if you didn't 
  349. do any conversion (ie. you want the character sent to the printer as is).  
  350. Return 0 if you do not want the character passed to the printer.  Or return 
  351. the number of characters that you translated the original character into.
  352.  
  353. The code for the conversion function can be put virtually anywhere (ie. 
  354. data.c, dospecial.c, etc.).  Here is an example of a simple conversion 
  355. function:
  356.  
  357.         ConvFunc(buf, c, flag)
  358.         char *buf, c;
  359.         int flag;        /* expand lf into lf/cr flag (0-yes, else no ) */
  360.         {
  361.               int err;
  362.               if (c == 0x7f) {          /* change DELETE to <DEL> */
  363.                         *buf++ = '<';
  364.                         *buf++ = 'D';
  365.                         *buf++ = 'E';
  366.                         *buf++ = 'L';
  367.                         *buf++ = '>';
  368.                         err = 5;      /* I added this many chars to buffer */
  369.               }
  370.               else {
  371.                    err = -1;    /* I didn't do anything with the char */ 
  372.               }
  373.         return(err);
  374.         }
  375.  
  376.  
  377. Another possible use for this routine would be to support underlining on a
  378. printer that doesn't do automatic underlining.  You could have an underline 
  379. flag that would tell you if underlining was on or off.  If off, your routine 
  380. would do nothing and return -1.  If on, your routine would put the character, 
  381. backspace, and the underline character in the buffer and return 3. 
  382.   
  383. When expanding one character into several chars with ConvFunc, try to keep 
  384. the expansions to a minimum.  This will help throughput and reduce the 
  385. possibility of data overrunning the printer.device buffer.  One other note,
  386. I recommended that you pass 0x1b (ESC) and 0x9b (CSI) back to the printer 
  387. device without processing them.  Simply return -1.
  388.  
  389.  
  390. DENSITY.C
  391. ---------
  392.  
  393. Density.c is a new printer driver module which implements multiple densities
  394. The handling of densities has changed quite a bit from V1.2.  Look at the
  395. Workbench printer driver source files on the devcon disk for examples of
  396. how to create this module.
  397.  
  398. Density.c gets called by render.c during pre-master initialization.  The
  399. density.c code should select either the desired density or, if the user asked 
  400. for a density higher than you support, the maximum density.  For example,
  401. if your driver supports four densities, DENSITY1 through DENSITY4, and the
  402. user selects DENSITY6, then your code should select DENSITY4.  The density.c 
  403. code is also responsible for handling narrow and wide tractor paper.  Refer 
  404. to the EpsonX or EpsonQ density.c source code for an example of this.
  405.  
  406. Density.c should not support densities below 80 dpi.  This convention
  407. results in a minimum of 640 dots across for a standard 8.5 x 11 inch piece
  408. of paper (8 inches x 80 dpi = 640 dots) and gives a 1-1 correspondence of
  409. dots on the printer to dots on the screen in x under standard screen sizes. 
  410.  
  411. The HP LaserJet  driver is a minor exception to this rule.  Its minimum 
  412. density is 75 dpi.  This was done as the HP LaserJet (not the Plus or II) has
  413. so little internal memory that 75 dpi is the only density at which it is able
  414. to output a full page.
  415.  
  416.  
  417.  
  418. TRANSFER.C
  419. ----------
  420.  
  421. This is the heart of the new printer drivers which consists of 2 parts -
  422. dithering and then rendering an entire row of source pixels.
  423.  
  424. Dithering is the process of thresholding, grey-scale dithering, or color
  425. dithering each destination pixel.  If PInfo->pi_threshold is non-zero,
  426. then the dither value is PInfo->pi_threshold ^ 15.  If PInfo->pi_threshold
  427. is zero, then the dither value is computed by
  428.  
  429.     *(PInfo->pi_dmatrix + ((y & 3) * 2) + (x & 3))
  430.  
  431. where x is initialized to PInfo->pi_xpos and is incremented for each of the
  432. destination pixels.  Since the printer device uses a 4x4 dither matrix, you
  433. must calculate the dither value exactly as given above.  If you don't, you
  434. will be writing a non-standard driver and the results will be unpredictable.
  435.  
  436. Rendering is the process of putting the pixel in the print buffer based on
  437. the dither value.  If the intensity value for the pixel is greater than the
  438. dither value as computed above then the pixel should be put in the printer
  439. buffer.  If it is less than the dither value, skip it and process the next 
  440. pixel.
  441.  
  442.  Printer     Type of
  443.  ColorClass  Dithering      Rendering Logic
  444.  ----------  ------------   -----------------------------------
  445.  
  446.  PCC_BW      Thresholding   Test the black value against the threshold value
  447.                             to see if you should render a black pixel.
  448.  
  449.              Grey Scale     Test the black value against the dither value
  450.                             to see if you should render a black pixel.
  451.  
  452.              Color          NA
  453.  
  454.                             (see HP_LaserJet transfer.c file)
  455.  
  456. PCC_YMC      Thresholding   Test the black value against the threshold value
  457.                             to see if you should render a black pixel. Print
  458.                             a yellow, magenta, and cyan pixel to make black.
  459.  
  460.              Grey_Scale     Test the black value against the dither value
  461.                             to see if you should render a black pixel. Print
  462.                             a yellow, magenta, and cyan pixel to make black.
  463.  
  464.          Color          Test the yellow value against the dither value
  465.                             to see if you should render a yellow pixel.
  466.                             Repeat this process for magenta and cyan.     
  467.  
  468.                             (see CalComp_ColorMaster2 transfer.c file)
  469.  
  470. PCC_YMCB     Thresholding   Test the black value against the threshold value
  471.                             to see if you should render a black pixel.
  472.  
  473.              Grey_Scale     Test the black value against the dither value
  474.                             to see if you should render a black pixel.
  475.  
  476.              Color          Test the black value against the dither value to 
  477.                             to see if you should render a black pixel.  If
  478.                             black is not rendered then test the yellow value
  479.                             against the dither value to see if you should 
  480.                             render a yellow pixel and repeat for magenta
  481.                             and cyan.
  482.  
  483.                             (see EpsonQ, EpsonX or Xerox_4020 transfer.c file)
  484.  
  485. PCC_YMC_BW   Thresholding   Test the black value against the threshold value
  486.                             to see if you should render a black pixel.
  487.  
  488.              Grey_Scale     Test the black value against the dither value
  489.                             to see if you should render a black pixel.
  490.  
  491.              Color          Test the yellow value against the dither value
  492.                             to see if you should render a yellow pixel.
  493.                             Repeat this for magenta and cyan.
  494.  
  495.                             (see Okimate_20 transfer.c file)
  496.  
  497. In general, if black is rendered for a specific printer dot then the YMC
  498. values should be ignored since the combination of YMC is black.  Also I
  499. recommend that you construct your print buffer so that the order of colors
  500. printed is yellow, magenta, cyan, black.  This is most important on color
  501. ribbon printers because it reduces the amount of ribbon color contamination.
  502. If you print black and then yellow, the yellow ribbon will get some black
  503. ink on it.
  504.  
  505. The bulk of the execution time of a graphic dump is spent in this call.  So
  506. this module is an excellent candidate for down-coding to 68000 assembler.  
  507. Experiments here at Commodore have shown that down coding transfer.c can halve
  508. the time for a graphic dump.
  509.  
  510.  
  511. DOSPECIAL.C
  512. -----------
  513.  
  514. The dospecial.c module implements the special ANSI functions which cannot be
  515. handled by substitution.  For instance, if you are writing a driver for a 
  516. page oriented printer such as  the HP LaserJet, you should delete the dummy 
  517. Close routine from the init.asm file and insert a real Close routine in
  518. dospecial.c.  The Close routine is responsible for ejecting the paper after 
  519. text has been sent to the printer and the printer has been closed.   
  520.  
  521. Some printers lose data when sent their own reset command.  For this reason,
  522. I recommend that if you are using the printer's own reset command that you
  523. define the variable PD->pd_PWaitEnabled to be a character that the printer 
  524. will not print.  Put this character in the reset string in data.c before and 
  525. after the reset character(s).  For example, in the EpsonX dospecial.c source 
  526. code you will see the line:
  527.  
  528.     if (*command == aRIS) {         /* reset command */
  529.         PD->pd_PWaitEnabled = 253;  /* same as \375  */
  530.     }
  531.  
  532. and in the data.c file the string for reset is "\375\033@\375".  This means 
  533. that when the printer device goes to output the reset string "\033@", it
  534. will first eat the "\375" and wait one second.  The "\033@" will be passed 
  535. and the printer will reset.  Finally, the printer device will eat the second
  536. "\375" and wait one more second.  This insures that no data will be lost if 
  537. a reset command is imbedded within a string as in "Hello \033#1world", where
  538. \033#1 is the code for reset.
  539.  
  540.  
  541.  
  542. DATA.C
  543. ------
  544.  
  545. The data.c module implements the special ANSI functions which can be handled
  546. by simple substitution.  It also contains the extended character translation 
  547. table if you choose to include it.  Data.c has been changed a little for V1.3.
  548.  
  549. Typefaces
  550. ---------
  551.  
  552. There is now support for selecting different typefaces.  Due to the extended
  553. character translation table, the character set selection commands (aFNT0 -
  554. aFNT10) are no longer really needed.  If you want your driver to support
  555. different typefaces you can use the FNT commands to select typefaces 0
  556. through 10.  Please include comments in the data.c file that tell which
  557. typefaces are selected by which commands.  The recommended standard for
  558. for selecting typefaces can be found in devices/printer.h.
  559.  
  560.  
  561. Raw Mode:
  562. ---------
  563.  
  564. There is now an escape sequence command (aRAW) which sets the printer device
  565. into raw mode for a given number of characters.  In raw mode, no translation
  566. of the data is done.  This command can be used to send commands directly to 
  567. the printer from the CLI.  
  568.  
  569. The format is ESC[Pn"r where Pn is an ascii digit argument specifying that 
  570. the next Pn characters are not to be translated, but sent directly to the 
  571. printer.  For example, ESC[5"r means that the next 5 characters are to be 
  572. sent directly to the printer.  For future compatibility, you should also
  573. add a dummy entry of \377 in the data.c table.
  574.  
  575.  
  576. TESTING
  577. -------
  578.  
  579. A comprehensive test of your printer driver is an important step and I
  580. have some recommendations.
  581.  
  582.     First, do a black and white (threshold = 7), grey scale, and color dump 
  583. of the same picture.  The color dump should be in color.  The grey scale dump 
  584. should look like the color dump except it will consist of patterns of black 
  585. dots - sort of like looking at a BW television.  The black and white dump 
  586. will have areas of solid black and areas of solid white.  
  587.  
  588.     Next do a dump with the DestX and DestY dots set to an even multiple of 
  589. the XDotsInch and YDotsInch for your printer.  For example, if your printer 
  590. has a resolution of 120 x 144 dpi, do a 480 x 432 dump.  The printed picture 
  591. should be 4 x 3 inches on the paper.  If the width of the picture is off 
  592. then you have put the wrong value for XDotsInch in printertag.asm.  If the 
  593. height of the picture is off then you have put the wrong value for YDotsInch 
  594. in printertag.asm.
  595.  
  596.     Test your driver at its maximums.  Do a color dump as wide as the printer
  597. can handle with the density set to 7.  Use the PrinterTest program on the 
  598. devcon disk to give the alpha commands a real workout.
  599.  
  600.     Check to make sure that your printer doesn't force graphic dumps to
  601. exist within text margins.  An easy test would be to set the text margins 
  602. to 30 and 50, pitch to 10 cpi and then do a graphic dump that would be wider
  603. than 2 inches.  If the printout is left justified and is as wide as you asked 
  604. for then all is fine.  If the printout starts at character position 30 and is
  605. cut off at character position 50 then you'll need to make some changes to
  606. your driver.  
  607.  
  608.      The changes involve clearing the margins before the dump (case 0) and 
  609. restoring the margins after the dump (case 4).  Refer to the any of of driver's
  610. render.c source code for an example.  Note that before the graphic dump you 
  611. must send some text (even just a carriage return) to the printer to get the 
  612. printer device to initialize the printer.  Optionally, you could invoke the 
  613. InitPrinter program before the graphic dump.
  614.  
  615.      As a final test, construct an image with a white background that has 
  616. objects in it surrounded by white space.  Dump this as a BW, grey scale, and 
  617. color printout.  This will test your white-space stripping or run-length 
  618. encoding and your ability to handle null lines.  Note that the non-white data 
  619. areas should be separated by at least as many lines of white space as the 
  620. NumRows value in your printertag.asm file.  The diagram below should help.
  621.  
  622.                 Display Area
  623.      ---------------------------------------------------------------
  624.     |                                |
  625.     |     -----------------------                |
  626.     |    |            |                |
  627.     |    | non-white data    |                |
  628.     |    |            |                |
  629.     |     -----------------------                |
  630.     |                                |
  631.     |        white background                |
  632.     |                                |
  633.     |         -----------------------            |
  634.     |        |            |            |
  635.     |        | non-white data    |            |
  636.     |        |            |            |
  637.     |         -----------------------            |
  638.     |                                |
  639.      ---------------------------------------------------------------
  640.  
  641.