PRINTER GIOS SKELETON December 6, 1983 The monochrome skeleton GIOS for dot matrix printers consists of two parts, firstly, the part that supports common functions and which requires no modification, and secondly, the part that needs to be customized for each different printer device. The Printer driver generates the output graph in two phases. In phase one, the driver simply creates an object list from each of the GSX function calls, and maintains the plot extents as output primitives are been stored in the object list. Phase two is invoked by a GSX close, clear or an update workstation command. In phase two, the graph is tailored to several strips, if neccessary, to fit the buffer allocated for the bit map. Objects in the list are first converted into the bit map buffer in raster bit image, which is then formatted to printer graphics data byte format and output to the printer. These steps are repeated for as many strips as is needed to complete the graph. (Appendix B describes the printer bit map accessing in detail) The following sections of this document outline all the printer driver modules and describes the printer dependent functions and parameters in detail. The procedure to assemble and build the printer GIOS from the skeleton driver is decribed in Appendix A. PART I - THE COMMON MODULES Part one of the printer skeleton modules are contained in a object module library file DDPSKELM.L86. The following section outlines the modules in part one that need not be modified. The Skeleton Object Module Library File - DDPSKELM.L86 The Printer Gios Library Module DDPSKELM.L86 contains the 8086 object modules. These are common modules that contain the optimized rasterization routines, the object list buffer manager, and routines that maintain the current primitive attribute settings. These modules are generic (device independent) to all printer gios (device driver), and need not be modified to build a new driver. PART 1, PHASE ONE ROUTINES PHASE I routines: Mainly stores each gios call and its parameter in the Object List buffer, creating a Picture Element List for the Phase 2 routines. The minimum and maximum plot extent is updated with each output primitive call, so the bit map buffer can be tailored to process each plot with the most economy and efficeincy. DDRIVER: Main entry point for printer driver. ZCOPWK - open workstation: Sets default parameters, returns device capabilities. ZCLWK - close workstation: Terminates the object list, invoke Phase II routines to process the object list for printer output. Contains the clear and update workstation modules. ZPL: Stores polyline opcode and parameters in the Object List buffer. ZPM: Stores polymarker opcode and parameters in the Object List buffer. ZTX: Stores Text opcode and parameters in the Object list buffer. ZFA: Stores the polygon opcode and the parameters including the polygon extent (min. and max. X, Y) in the Object List buffer. ZBAR: Stores cell array and GDP bar opcode and parameters in the Object List buffer. ZSATTR - set attributes: Stores set attribute (opcodes 12 - 25) calls in the Object List buffer. ROLLO: Supports Object List accesses, manages a temporary disk overflow file for pictures that requires more space than the allocated object buffer to store its element list. XREG: 16 bits multiply and divide routines, returns 16-bits fraction result, and other 16-bit operations that are used by various modules. (most can be replaced by direct calls to the 8086 instruction set) NOMSGOUT: This is a dummy module called by several routines. NOMSGOUT can be replaced by module MSGOUT to allow the printer driver to output debug messages to the console. MSGOUT: This routine is not included in the DDPSKELM.L86 object library, but is provided seperately for debugging use. The routine can be called with a message number to display appropriate messages on the console. This module can replace NOMSGOUT module during the testing stage. PART 1, PHASE II ROUTINES PHASE II routines: Tailor the bit map buffer according to the plot extent (size). Determine the number of scans neccessary to process the entire picture. Initialize the printer to graphics image mode. Generates properly clipped bit mapped dot image of each scan strip in the bitmap buffer, format and output the bit image to the printer. RASOUT - Phase II main module: Controls the objects rasterization and bitmap scan output process for generating each of the plot strips that composes the final plot on the printer. RASTERMX: Reinitializes current device attributes, get the opcodes from the Object List buffer, call the appropriate attribute or primitive modules to set the attributes or draw the object into the current plot strip for the entire object list. GETADDR: Computes the bit map address for the various drawing routines. Polyline drawing routines: DODRAWC: Setup the writing mode parameters for line ojects. Most common line drawing variables are declared in this module. DRAW: Get the polyline coordinates from the Object List, calls clipit to clip the line to inside the current plot strip, and calls drawline routine to rasterize the line. DRAWLINE: Rasterize line using incremental algorithm. CLIPIT: Clip the endpoint of a line to the current plot strip window, reporting trivially rejected lines. Draw Text and Polymarker routines: DOMARKC: Test the marker symbol against the current plot strip and if inside, calls textit routine to rasterize the symbol into the bit map. DOTEXTC: Test each character in the text string against the current plot strip and if inside calls textit routine to rasterize the character into the bit map. TEXTIT: Map a character cell into bitmap based on size and rotation and clip the cell to the current plot strip. FONT1: Bit mapped font (mirrored bit patterns). Polygon routines: DOFILLC: Determine the intersection points of the polygon edge for each raster line that falls in the current plot strip and calls drawline routine to 'fill' the interior. Cell array and GDP Bar routine: DOGDP: Calls polygon fill routine to output bar objects and calls polyline routine to draw the cell array outline. DOATTRMX: Supports current attribute settings for each attribute functions and set up the writing mode variables and masks for each of the output primitives. SCANER: Scan and output one 'plot strip' of bit image data from bit map to printer. PART II - DEVICE SPECIFIC MODULES Part two of the printer driver is seperated into five modules. THese modules contains device specific informations and functions. The following section describes each of the part two modules. ZCAPxxxx: This module contains six equate values that need to be modified for each particular printer: dxlng This is the displayable horizontal resolution of the printer. EXAMPLE: If the printer has a horizontal resolution of 144 dots per inch, with maximum plot size of 8 inches, dxlng = (144 x 8) - 1 = 1151 dots. dylng This is the displayable y resolution of the printer. EXAMPLE: If the printer has a vertical resolution of 72 dots per inch, with the maximum plot size of 10.33 inches, ( 8 x 10.33 inches plot size reserving the normal paper aspect ratio of 8.5 by 11 inches) dylng = (72 x 10.33) - 1 = 743 dots. pxsiz This is the size of the printable dots in microns in the x axis. EXAMPLE: If the printer has a horizontal resolution of 72 dots per inch, pxsiz = 25400 (microns per inch) / 144 dpi = 352 microns. pysiz This is the size of the printable dots in microns in the y axis. cor This is the number of predefined colors, for monochrome printers, this value is always 2. ccap This is the color capability flag, for monochrome printers, this value is always 0. PATxxxx: This module contains the polygon interior hatch and patterm fill bit masks. Three files are provided with the skeleton driver: patlxly, pathxly, and pathxhy. Depending on the printer resolution, one of these three files should be used to build the driver. This module is printer dependent, because each printer has a different x-y aspect ratio. In order to produce uniformed patterns, each need to use a fill pattern that is designed for that specific x-y aspect ratio. PATLXLY contains the standard pattern, should be used for printers with a normal resolution. For example, printers that have a 60 (horizontal) by 72 dots per inch, or 72 by 75 dots per inch or 84 by 84 dots per inch resolution. PATHXLY should be used for printers that have a much higher horizontal than vertical resolution. For example, printers with a 120 (horizontal) by 72 dots per inch, or 136 (horizontal) by 72 dots per inch resolution. PATHXHY should be used for printers that have very high resolution for both horizontal and vertical directions. Any resolution above 120 dots per inch would produce patterns that look too tight if the bit patterns in module patlxly was used. ZSETUPxx: This module sets up the bit map buffer accessing parameters for the driver. It computes several values needed by the rasterization and bit map scan output routines in Phase II, these values are all dependent on the maximum plot extent of the graph (size). Dot matrix printers print graphics images by mapping the bits in the graphics data bytes to a corresponding wire on the print head which cause dots to be printed on the paper. There are basically three types of dot addressing schemes used by almost all dot matrix printers (see Appendix C for a detailed description and diagram of the three different printer types). Routine GSETUP is called by this module to setup the Bit Map Buffer address pointer: MAPEND. Two skeleton gsetup modules are provided, depending on the type of the print wire addressing mode, one of these modules can be used to build the driver. ZDFXHR - Setup module for Epson High Resolution. ZDCITO - Setup module for C. Itoh printer. The following values are computed by this routine: nstrip Number of plot strips to process for this plot. xw Number of bytes per scan line in the bit map, this is used to compute the bit map address of a pixel, and to scan the bit map for output. ysize Number of vertical dots per plot strip, this is used to determine the top and bottom y values of each plot strip as it is been processed, ysize x nstrip = the y extent of the plot. mapend Byte address to start scanning the bit image from the bit map buffer. This value is computed according to the type of print wire addressing mode for the printer mentioned before. ZGSCANx: Calls MSKOUT routine to get bit patterns from the bit map, format them into printer specific graphics data byte format. Calls BYTOUT routine to output the bytes to printer. The bit map image is scanned from top to bottom and from from left to right (normal print line direction) relative to the graph. Example of special graphics data byte format: o IDS Prism printer requires that the graphics data byte 03H (ETX code) must be send twice to produce the bit pattern 00000011. o DEC. LA50 printer requires that the graphics data bytes be in the range of ASCII 3Fh to 7Eh, which means that a bit mask of 3Fh must be ORed with the actual graphics data bytes before data are send to the printer. o Printronix requires that the data bytes must have bit 8 set and bit 7 cleared. ZDxxxx: This module has five subroutines that must be written to support the following printer specific functions: GSETUP: Setup printer for graphics output. There may or may not be any special commands needed to setup the printer for graphics output. This is not an enter graphics mode command. Some printers, for example, the C. Itoh printer need to set the dot resolution used, or the Epson need to set the graphics line feed spacing, and the Data South printer needs no setup commands. GENTER: Command to put the printer into graphics bit image mode. There are basically two types of enter graphics commands. The first type requires for each print line, an Enter Graphics command with the number of graphics datas (byte count) followed by the exact number of graphics data bytes, so, this routine will be called for every print line. The second type requires the Enter Graphics command issued once, with any number of graphics bytes following it, all data other than the commands sequences sush as line feeds and carriage returns are intrepreted as being graphics data, until an Exit Graphics mode command is encountered, this routine is only called once for this type of printers. ZFORM: Printer Form Feed, probably the same FF code for all printers. NOTE: Some printers will lose the line registration normally maintained in print text mode to keep track of the next top of form control, there is no recommended solution to this problem. GLF: Graphics Line Feed, advance paper vertically to the next graphics print line position. Some printers have special graphics line feed command, for example, the DEC LA50 or the Data South DS180 printer. Some printers need the graphics line specing set seperatly, then uses the normal LF command to advance the paper an appropriate number of vertical dots, for example, the Epson printer models. Some printers automatically adjust LF to the graphics dot spacing once in graphics mode. GEXIT: Exit Graphics Mode, reset printer to normal print text mode, with normal 6 lines per inch vertical pitch and normal 10 characters per inch horizontal pitch. In addition, four equate values need to be modified for each different printer: pixel Number of dots printed per graphics data byte. pwire Number of vertical dots printed per print pass. For most printers, this is the same as the pixel value, but some printer, like the DIABLO model C150, 8 horizontal dots are printed per graphics byte (pixel = 8), but the vertical dots per print pass is four vertical dots (pwire = 4). BUFSIZE The Bit Map buffer size in bytes. Change this value to allocated a diffenrent size bit map buffer for the printer driver. The bit map buffer size directly affects the graph output speed of the printer driver. The bigger the size of the bit map buffer, the smaller the number of plot strips is required for the graph, the faster the output can be generated. WCOUNT The bit map buffer size in words (bufsize/2). This value is used to clear the bit map buffer before rasterizing the next plot strip. APPENDIX A. BUILDING THE PRINTER GIOS BUILDING THE PRINTER DEPENDENT MODULES : Step 1. Modify the device capability module ZCAPxxxx, replace the euqates with the resolution of the target printer. Step 2. Depending on the printer resolution, select one of the fill pattern modules PATxxxx. Step 3. Modify the six subroutines in module ZDxxxx with the proper command sequences to set up the printer for graphics image mode, graphics line feed, form feed, and other graphics set up commands as required by the printer. Step 4. Modify the bit map scan output routine ZGSCANx. This routine must map the raster bit images in the bit map into the correct graphics data byte format that the printer expects, Appendix C describes the three major type of mappings that are used by the different dot matrix printers. Step 5. Again depending on the printer print head address type, select one of the set up modules ZSETUPMx. Some slight modification may be required to adjust the bit map accessing parameters. The parameters computed in the set up module are decribed in the driver specific module section. Step 6. Assemble and placed these module in a device specific object module library file - DDxxxLIB.L86, (although it is not required that a library file be created). Do not included the ZCAPxxxx in this library, ZCAPxxxx need to be the first object module in the link process. EXAMPLE: RASM86 zcapxxxx RASM86 zdxxxx RASM86 zgscanx LIB86 ddxxxlib=pathxly,zsetupm1,zgscan4,zdxxxx THE LINKING PROCESS: Now you are ready to link these module with the generic module to build the GIOS for the target printer, EXAMPLE 1: LINK86 ddxxxx=zcapxxxx,ddpskelm.l86,ddxxxlib.l86,nomsgout EXAMPLE 2: you can create a command input file for the linker. If file ddxxxx contains the following line : ddxxxx=zcapxxxx,ddpskelm.l86,ddxxxlib.l86,nomsgout To link: LINK86 ddxxxx[input] EXAMPLE 3: If you have set up debugging messages for testing, and want to link in the msgout module. LINK86 ddxxxx=zcapxxxx,ddpskelm.l86,ddxxxlib.l86,msgout BUILDING THE GENERIC OBJECT MODULE LIBRARY - DDPSKELM.L86 : The Generic library is created by using the following library input file DDPSKELM.INP: DDPSKELM=DDRIVER,CHKABORT,ROLLO,XREG, ZSATTRC,ZPL,ZPM,ZTX,ZFA,ZBAR, RASOUT2,RASTERMX,DOATTRMX,DODRAWC, DOTEXTC,TEXTIT,DOMARKC,FONT1, DRAW,DRAWLINE,DOGDP,DOFILLC,CLIPIT, GETADDR,SCANER GENERAL NOTES: 1. The Plot size is set to 8.0 by 10.33 inches for a display aspect ratio of 0.773 which is derived from the standard paper size of 8.5 by 11.0 inches. Aspect ratio = 7.73, Plot Size = 8.0 x 10.33 inches. 2. Clear workstation must retain the current primitive attribute settings and NOT re-initialize the attributes back to open workstation defaults. Application programs expect that all the current attributes are still in effect after a close workstation call and not changed to their initial open workstation value. 3. Close workstation, Clear workstation and Update workstation all cause the plot to be generated on the printer and the object list buffer cleared. The only difference is that Clear workstation issues a form feed before output the picture to the printer. 4. The temporary disk file has a maximum file size of 64K records (8 megabytes). The file is always deleted automatically by the printer driver. 5. Module NOMSGOUT can be replaced by MSGOUT to allow the printer driver to output debug messages to the console. 6. The printer driver checks the version of operating system it is running under, and in PC DOS V2.0, allocates a block of 32K bytes memory to use as its bit map buffer, the larger buffer will reduce the number of plot strips the driver has to process and speed up the output. APPENDIX B. PRINTER BIT MAP BUFFER This section describes the printer bit map buffer and the set up procedures in detail. In the monochrome printer drivers, a 2.5K bytes BITMAP buffer is normally allocated to store the raster bit image display before this information can be formatted and send to the printer (through the system printer output device) as bytes in the graphics data format expected by the printer. Because the raster bit image data for the entire graph may not fit into the bit map buffer, the printer driver 'cut' the graph in several smaller strips that will fit into the bit map. It then has to rasterize and output each strip seperately. The size of the BITMAP buffer can easily be changed by modifying the equate constant bufsize in module ZDxxxx of the skeleton driver. In PC DOS V2.0, the printer driver will try to allocate a 32K bytes memory buffer to use as its bit map buffer to reduce the number of strips it has to process. In order to make maximum use of the BITMAP buffer, the buffer is tailored according to the horizontal size of each graph. The size of each graph is determined by its plot extent. The plot extent is defined by its maximum X (XMAX) and maximum Y (YMAX) values. The following examples illustrate the tailoring of the BITMAP for graphs of different sizes. GRAPH 1. GRAPH 2. XMAX = 5, YMAX = 5 XMAX = 10, YMAX = 5 +--+--+--+--+--+ +--+--+--+--+--+--+--+--+--+--+ | | | | +--+--+--+--+--+ +--+--+--+--+--+--+--+--+--+--+ | | | | +--+--+--+--+--+ +--+--+--+--+--+--+--+--+--+--+ | | | | +--+--+--+--+--+ +--+--+--+--+--+--+--+--+--+--+ | | | | +--+--+--+--+--+ +--+--+--+--+--+--+--+--+--+--+ | | | | +--+--+--+--+--+ +--+--+--+--+--+--+--+--+--+--+ GRAPH 3. XMAX = 15, YMAX = 20 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ | | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ If for example, the entire graph 3 does not fit into the buffer allocated for the BITMAP, the graph is cut into three strips, the output is then generated by rasterizing each strip into the BITMAP and send to the printer in three seperate passes. A normal size graph usually does not fit in a 2.5K bit map, with one bit per pixel, a 640 x 320 dots screen graph will require a 25K bytes bit map. On printers with 72 x 72 dots per inch resolution, a normal size graph (8 x 10 inches) has a bit image of about 576 x 720 dots, which would require a bit map of about 50K bytes. So, the printer driver needs to 'cut' and process most graphs in several seperate strips. The following information are required for setup module ZDxxxx to determine how the BITMAP buffer should be tailored and how many strips need to be generated for each graph: o Constants (EQUATES): pixel The number of dots printed for each graphics data byte. bufsize The BITMAP buffer size in bytes. o Variables: xmax The maximum horizontal plot extent (dots). ymax The maximum vertical plot extent (dots). APPENDIX C. PRINTER TYPES This section describes the three different types of print wire addressing modes. TYPE 1: Graphics byte is addressed by the printer top to bottom with the LSB (least significant bit) being printed as the top dot. The following printers are this type: C. Itoh model 8510A, DEC LA50 and LA100 series, Centronics model 351/352/353, Integral Data Sys tems Prism, Okidata model microline 84 step 2. TYPE 2: Graphics byte is addressed by the printer bottom to top with the MSB (most significant bit) being printed as the top dot. EXAMPLES: Epson, IBM dot matrix, Data South DS180, Anadex. TYPE 3: Graphics byte is addressed by the printer left to right with the LSB being printed in the leftmost dot position. EXAMPLE: Printronix MVP and the Philips GP models. The diagram below identifies the graphics bytes and the print wire position used in each of the three types. Type 1: TYPE 2: Top Dot o ---- Bit 0, LSB Top Dot o ---- Bit 7, MSB o ---- Bit 1 o ---- Bit 6 o ---- Bit 2 o ---- Bit 5 o ---- Bit 3 o ---- Bit 4 o ---- Bit 4 o ---- Bit 3 o ---- Bit 5 o ---- Bit 2 o ---- Bit 6 o ---- Bit 1 Bottom o ---- Bit 7, MSB Bottom o ---- Bit 0, LSB Type 3. In the following Printronix printer example, only the six low-order bits from each 8 bit data byte are used. Byte 1 Byte 2 ... LSB MSB Bit 0 1 2 3 4 5 6 7 0 1 2 3 ... Dot 1 2 3 4 5 6 7 8 9 10 ... ; PRINTER DRIVERS: Monochrome: 1. Anadex DP-9501 2. Centronics 353/352/351 3. C. Itoh 8510A 4. Data South DS180 5. DEC LA50 6. DEC LA100 7. Epson High Res. 8 bit 8. Epson Low Res. 8 bit 9. Epson Low Res. 7 bit 10. IDS Prism 11. Mannesman Tally MT160 12. Okidata Microline 84 step 2 13. Philips GP300L 14. Printronix MVP Color: 1. Diablo C150 2. Transtar 315