(FILECREATED "21-Mar-84 14:32:48" {DSK}FXPARALLELPRINTER.;1 12106  

      changes to:  (VARS FXPARALLELPRINTERCOMS)

      previous date: " 2-Mar-84 18:47:46" {ROSEBOWL}<LISP>LIBRARY>PRINTER.;2)


(* Copyright (c) 1984 by Xerox Corporation)

(PRETTYCOMPRINT FXPARALLELPRINTERCOMS)

(RPAQQ FXPARALLELPRINTERCOMS ([ADDVARS (PRINTERTYPES ((FX.80 LOCALPRINTER)
						      (CANPRINT (TEXT BITMAP))
						      (STATUS TRUE)
						      (PROPERTIES NILL)
						      (SEND LOCAL.PRINT]
			      (FNS GRAPHICS.MODE LOCAL.PRINT LOCAL.PRINTFILE LOCAL.WINDOW 
				   WINDOW.TO.BITMAP FBITMAP SLOW.BITMAP SAVE.BITMAP.FOR.LOCAL.PRINTER)
			      (FNS \LOCAL.GRAPHICSINIT \LOCAL.HEADING \LOCAL.PRINT.HEADING 
				   \LOCAL.TEXTINIT \LOCAL.SELECT \LOCAL.SENDCOMMAND \LOCAL.SENDBYTE 
				   \LOCAL.SENDSTRING)
			      (DECLARE: DONTCOPY (MACROS \LOCAL.MODE \LOCAL.CRLF))))

(ADDTOVAR PRINTERTYPES ((FX.80 LOCALPRINTER)
			(CANPRINT (TEXT BITMAP))
			(STATUS TRUE)
			(PROPERTIES NILL)
			(SEND LOCAL.PRINT)))
(DEFINEQ

(GRAPHICS.MODE
  [LAMBDA (ROWS)                                             (* edited: " 2-Mar-84 17:53")
    (\LOCAL.SENDCOMMAND (CHARCODE "*"))
    (\LOCAL.SENDBYTE 5)
    (COND
      ((LESSP ROWS 256)
	(\LOCAL.SENDBYTE ROWS)
	(\LOCAL.SENDBYTE 0))
      (T (\LOCAL.SENDBYTE (REMAINDER ROWS 256))
	 (\LOCAL.SENDBYTE (IQUOTIENT ROWS 256])

(LOCAL.PRINT
  [LAMBDA (FILE NOROTATE?)                                   (* edited: " 2-Mar-84 18:29")
    (COND
      ((BITMAPP FILE)
	(FBITMAP FILE NOROTATE?))
      ((WINDOWP FILE)
	(LOCAL.WINDOW FILE NOROTATE?))
      (T (\LOCAL.TEXTINIT)
	 (\LOCAL.PRINT.HEADING FILE)
	 (LOCAL.PRINTFILE FILE])

(LOCAL.PRINTFILE
  [LAMBDA (FILE)                                             (* edited: " 2-Mar-84 18:29")
    (RESETLST [RESETSAVE NIL (LIST (FUNCTION CLOSEF?)
				   (SETQ FILE (OPENSTREAM FILE (QUOTE INPUT)
							  (QUOTE OLD]
                                                             (* Now read and print the rest of the file)
	      (until (EOFP FILE) bind CHAR
		 do (SELCHARQ (SETQ CHAR (BIN FILE))
			      [↑F (SELCHARQ (SETQ CHAR (BIN FILE))
					    (↑B              (* print bold)
						(\LOCAL.MODE ProportionalOff)
						(\LOCAL.MODE ExpandOff)
						(\LOCAL.MODE CompressedOn)
						(\LOCAL.MODE BoldOn))
					    (↑C              (* print small)
						(\LOCAL.MODE EliteOff)
						(\LOCAL.MODE BoldOff)
						(\LOCAL.MODE SubScriptOn)
						(\LOCAL.MODE ItalicOn)
						(\LOCAL.MODE CompressedOn))
					    (↑D              (* print big)
						(\LOCAL.MODE BoldOff)
						(\LOCAL.MODE EliteOff)
						(\LOCAL.MODE ExpandOn)
						(\LOCAL.MODE ProportionalOn))
					    (PROGN           (* some other mode so print standard mode)
						   (\LOCAL.MODE EliteOff)
						   (\LOCAL.MODE CompressedOn)
						   (\LOCAL.MODE ItalicOff)
						   (\LOCAL.MODE ScriptOff)
						   (\LOCAL.MODE ExpandOff)
						   (\LOCAL.MODE BoldOff)
						   (\LOCAL.MODE ProportionalOff]
			      (CR (\LOCAL.CRLF))
			      (\LOCAL.SENDBYTE CHAR))
		 finally (\LOCAL.CRLF)
			 (\LOCAL.SENDBYTE 19])

(LOCAL.WINDOW
  [LAMBDA (WINDOW NOROTATE?)                                 (* JBleier "17-Feb-84 18:14")

          (* This function will print out a window onto the FX-80 printer using the RS232 Port. The image printed will 
	  either be printed straight across or rotated by a negative 90 degrees, depending on whether the user specifically 
	  requests no rotation in the initial function call.)


    (PROG (BITMAP)
          (SETQ BITMAP (WINDOW.TO.BITMAP WINDOW))

          (* Because the function \GETBASEBYTE is much faster than BITMAPBIT, and can only work on bit maps, first this 
	  function changes the window into a bit map, using WINDOW.TO.BITMAP, then it performs functions upon the created 
	  bit map as if it had been called from RS232.PRINT.)


          (FBITMAP BITMAP NOROTATE?])

(WINDOW.TO.BITMAP
  [LAMBDA (WINDOW)                                           (* JBleier "17-Feb-84 18:10")
    (PROG (BITMAP)
          [SETQ BITMAP (BITMAPCREATE (WINDOWPROP WINDOW (QUOTE WIDTH))
				     (WINDOWPROP WINDOW (QUOTE HEIGHT]
          (BITBLT WINDOW NIL NIL BITMAP)
          (RETURN BITMAP])

(FBITMAP
  [LAMBDA (BMAP NOROTATE?)                                   (* edited: " 2-Mar-84 17:59")

          (* This function takes a bit map, and, if the user doesn't make an explicit request (using a non-nil NOROTATE? 
	  argument), prints the image out rotated -90 degrees using the fast \GETBASEBYTE function.)


    (PROG ((HEIGHT (fetch BITMAPHEIGHT of BMAP))
	   (BASE (fetch BITMAPBASE of BMAP))
	   (BYTESPERROW (ITIMES 2 (fetch BITMAPRASTERWIDTH of BMAP)))
	   COLUMN J CNT OFFSET)
          (COND
	    (NOROTATE? (SLOW.BITMAP BMAP))
	    (T (\LOCAL.MODE UniDirectionalOn)
	       (\LOCAL.MODE EightSpacingOn)
	       (SETQ OFFSET BYTESPERROW)
	       (for COLUMN from 1 to BYTESPERROW
		  do (GRAPHICS.MODE HEIGHT)
		     [for J from HEIGHT to 1 by -1 do (\LOCAL.SENDBYTE
							(\GETBASEBYTE BASE
								      (IDIFFERENCE (ITIMES 
										      BYTESPERROW J)
										   OFFSET]
		     (\LOCAL.CRLF)
		     (SETQ OFFSET (SUB1 OFFSET)))
	       (\LOCAL.MODE UniDirectionalOff])

(SLOW.BITMAP
  [LAMBDA (BMAP)                                             (* edited: " 2-Mar-84 18:03")

          (* If the user specifies that the Bit Map is to be printed horizontally, then the slow method of printing the 
	  imapge via BITMAPBIT is used.)


    (PROG ((WIDTH (fetch BITMAPWIDTH of BMAP))
	   CURRENTHT EXP X Y PRINTVAL)
          (\LOCAL.MODE UniDirectionalOn)
          (\LOCAL.MODE EightSpacingOn)
          (for CURRENTHT from HEIGHT to 0 by -8
	     do ((GRAPHICS.MODE WIDTH)
		 (for X from 1 to WIDTH do ((SETQ PRINTVAL 0)
					    [for EXP from 7 to 0 by -1
					       do ((SETQ Y (DIFFERENCE CURRENTHT (DIFFERENCE 7 EXP)))
						   (SETQ PRINTVAL (IPLUS (ITIMES (EXPT 2 EXP)
										 (BITMAPBIT BMAP X Y))
									 PRINTVAL]
					    (\LOCAL.SENDBYTE PRINTVAL)))
		 (\LOCAL.CRLF)))
          (\LOCAL.MODE UniDirectionalOff])

(SAVE.BITMAP.FOR.LOCAL.PRINTER
  [LAMBDA (BITMAP REGION)                                    (* rmk: "22-SEP-83 18:13")
    (if REGION
	then (PROG [(BM (BITMAPCREATE (IMIN (fetch (REGION WIDTH) of REGION)
					    (BITMAPWIDTH BITMAP))
				      (IMIN (fetch (REGION HEIGHT) of REGION)
					    (BITMAPHEIGHT BITMAP]
	           (BITBLT BITMAP (fetch (REGION LEFT) of REGION)
			   (fetch (REGION BOTTOM) of REGION)
			   BM)
	           (RETURN BM))
      else BITMAP])
)
(DEFINEQ

(\LOCAL.GRAPHICSINIT
  [LAMBDA NIL                                                (* lmm " 3-OCT-83 21:06")
    (\LOCAL.MODE BoldOff)
    (\LOCAL.MODE PicaPitch)
    (\LOCAL.MODE UniDirectional)
    (\LOCAL.MODE Wideoff)
    (\LOCAL.SENDCOMMAND (CHARCODE T))
    (\LOCAL.SENDSTRING "16"])

(\LOCAL.HEADING
  [LAMBDA (FILENAME)                                         (* edited: " 2-Mar-84 18:14")
    (\LOCAL.SENDSTRING "Listing of File ")
    (\LOCAL.SENDSTRING FILENAME)
    (\LOCAL.SENDSTRING " ,")
    (\LOCAL.SENDSTRING (DATE))
    (\LOCAL.SENDSTRING " by ")
    (\LOCAL.SENDSTRING (USERNAME))
    (\LOCAL.CRLF])

(\LOCAL.PRINT.HEADING
  [LAMBDA (FILENAME)                                         (* edited: " 2-Mar-84 18:00")
    (\LOCAL.CRLF)
    (\LOCAL.MODE BoldOn)
    (\LOCAL.HEADING FILENAME)
    (\LOCAL.MODE BoldOff)
    (\LOCAL.CRLF])

(\LOCAL.TEXTINIT
  [LAMBDA NIL                                                (* edited: "24-Feb-84 21:04")
    (\LOCAL.MODE BoldOff)
    (\LOCAL.MODE ExpandOff)
    (\LOCAL.MODE EliteOff)
    (\LOCAL.MODE CompressedOn)
    (\LOCAL.MODE ProportionalOff)                            (* Set up all of the modes to standard pitch)
    (\LOCAL.SENDCOMMAND (CHARCODE "N"))
    (\LOCAL.SENDBYTE 7)                                      (* Set the printer (the Epson FX) to automatically skip 
							     the perforations in the paper...)
    (\LOCAL.MODE TwelveSpacingOn])

(\LOCAL.SELECT
  [LAMBDA NIL                                                (* lmm " 3-OCT-83 21:06")
    (WRITEPRINTERPORT 0)
    (\LOCAL.SENDBYTE 17])

(\LOCAL.SENDCOMMAND
  [LAMBDA (ComChar)                                          (* lmm " 3-OCT-83 21:06")
    (\LOCAL.SENDBYTE 27)                                     (* ESCAPE)
    (\LOCAL.SENDBYTE ComChar])

(\LOCAL.SENDBYTE
  [LAMBDA (Byte)                                             (* edited: " 2-Mar-84 15:30")
    (while (NEQ (LOGAND 32768 (READPRINTERPORT))
		0)
       do (BLOCK))
    (WRITEPRINTERPORT Byte)
    (WRITEPRINTERPORT (IPLUS 32768 Byte))
    (WRITEPRINTERPORT (IPLUS 32768 Byte])

(\LOCAL.SENDSTRING
  [LAMBDA (S)                                                (* lmm " 3-OCT-83 21:06")
    (PROG ((SLEN (NCHARS S)))
          (for I from 1 to SLEN do (\LOCAL.SENDBYTE (NTHCHARCODE S I])
)
(DECLARE: DONTCOPY 
(DECLARE: EVAL@COMPILE 

(PUTPROPS \LOCAL.MODE MACRO ((Mode)
			     (SELECTQ (QUOTE Mode)
				      (UniDirectionalOn      (* Print only while carriage is moving left to right)
							(\LOCAL.SENDCOMMAND (CHARCODE "U"))
							(\LOCAL.SENDBYTE (CHARCODE "1")))
				      (BiDirectional (\LOCAL.SENDCOMMAND (CHARCODE "U"))
						     (\LOCAL.SENDBYTE (CHARCODE "0")))
				      (BoldOn                (* Print Following character in BOLD face)
					      (\LOCAL.SENDCOMMAND (CHARCODE "E")))
				      (BoldOff               (* Print Following character in NORMAL face)
					       (\LOCAL.SENDCOMMAND (CHARCODE "F")))
				      (CompressedOn          (* Select 17 chars per inch (136 dots/inch, 1088 
							     dots/line))
                                                             (* SETQ DotsPerLine 1088)
						    (\LOCAL.SENDCOMMAND 15))
				      (CompressedOff (\LOCAL.SENDBYTE 18))
				      (EliteOn               (* Select 12 chars per inch (96 dots/inch, 768 
							     dots/line))
                                                             (* DotsPerLine 768)
					       (\LOCAL.SENDCOMMAND (CHARCODE "M")))
				      (EliteOff (\LOCAL.SENDCOMMAND (CHARCODE "P")))
				      (ItalicOn (\LOCAL.SENDCOMMAND (CHARCODE "4")))
				      (ItalicOff (\LOCAL.SENDCOMMAND (CHARCODE "5")))
				      (PicaOn                (* Select 10 chars per inch (80 dots/inch, 640 
							     dots/line))
					      (\LOCAL.SENDCOMMAND (CHARCODE "P"))
					      (\LOCAL.SENDBYTE 18))
				      (SubScriptOn (\LOCAL.SENDCOMMAND (CHARCODE "S"))
						   (\LOCAL.SENDBYTE (CHARCODE "0")))
				      (SuperScriptOn (\LOCAL.SENDCOMMAND (CHARCODE "S"))
						     (\LOCAL.SENDBYTE (CHARCODE "1")))
				      (ScriptOff (\LOCAL.SENDCOMMAND (CHARCODE "T")))
				      (ExpandOn              (* Print following character NORMAL width)
						(\LOCAL.SENDCOMMAND (CHARCODE "W"))
						(\LOCAL.SENDBYTE (CHARCODE "1")))
				      (ExpandOff             (* Print following character DOUBLE width)
						 (\LOCAL.SENDCOMMAND (CHARCODE "W"))
						 (\LOCAL.SENDBYTE (CHARCODE "0")))
				      (ProportionalOn (\LOCAL.SENDCOMMAND (CHARCODE "p"))
						      (\LOCAL.SENDBYTE (CHARCODE "1")))
				      (ProportionalOff (\LOCAL.SENDCOMMAND (CHARCODE "p"))
						       (\LOCAL.SENDBYTE (CHARCODE "0")))
				      (EightSpacingOn (\LOCAL.SENDCOMMAND (CHARCODE "A"))
						      (\LOCAL.SENDBYTE 8))
				      (TwelveSpacingOn (\LOCAL.SENDCOMMAND (CHARCODE "2")))
				      NIL)))

(PUTPROPS \LOCAL.CRLF MACRO (NIL (\LOCAL.SENDBYTE (CHARCODE CR))
				 (\LOCAL.SENDBYTE (CHARCODE LF))
				 (BLOCK)))
)
)
(PUTPROPS FXPARALLELPRINTER COPYRIGHT ("Xerox Corporation" 1984))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1009 6891 (GRAPHICS.MODE 1019 . 1389) (LOCAL.PRINT 1391 . 1718) (LOCAL.PRINTFILE 1720
 . 3171) (LOCAL.WINDOW 3173 . 4015) (WINDOW.TO.BITMAP 4017 . 4334) (FBITMAP 4336 . 5420) (SLOW.BITMAP 
5422 . 6366) (SAVE.BITMAP.FOR.LOCAL.PRINTER 6368 . 6889)) (6892 9351 (\LOCAL.GRAPHICSINIT 6902 . 7206)
 (\LOCAL.HEADING 7208 . 7567) (\LOCAL.PRINT.HEADING 7569 . 7811) (\LOCAL.TEXTINIT 7813 . 8406) (
\LOCAL.SELECT 8408 . 8572) (\LOCAL.SENDCOMMAND 8574 . 8803) (\LOCAL.SENDBYTE 8805 . 9113) (
\LOCAL.SENDSTRING 9115 . 9349)))))
STOP