(FILECREATED "20-Oct-86 15:10:56" {ROSEBOWL}<RCLARKE>MICROTEK.;44 78214  

      changes to:  (FNS MT.SHRINKFN MT.COMMAND.MENU MT.SCAN MT.RESET MT.QUIT MT.INIT)
		   (VARS MICROTEKCOMS)

      previous date: "28-Aug-86 16:50:59" {ROSE}<RCLARKE>MICROTEK.;41)


(* Copyright (c) 1986 by XEROX Corporation. All rights reserved.)

(PRETTYCOMPRINT MICROTEKCOMS)

(RPAQQ MICROTEKCOMS ((P (FILESLOAD DLRS232C FREEMENU ICONW EDITBITMAP))
	(* * Microtek Initialization and Menu Functions)
	(FNS MT.INIT MT.SHRINKFN MICROTEKSCANNER RULERX RULEX# RULERY RULEY# MT.GETLENGTH 
	     MT.CURSOR.IN MT.CURSOR.OUT MT.PRINT.STATUS MT.CONTROL.MENU MT.CHANGE.BRIGHTBAR 
	     MT.RAISEBRIGHTNESS MT.LOWERBRIGHTNESS MT.CHANGE.CONTRASTBAR MT.RAISECONTRAST 
	     MT.LOWERCONTRAST MT.SELECT.BACKGROUND MT.GETTRANSFRAME MT.GETWINDOW1 MT.GETWINDOW2 
	     MT.GETWINDOW3 MT.GETWINDOW4 MT.UPDATE.HTWINDOWS)
	(* * Command Functions)
	(FNS MT.COMMAND.MENU MT.GET.OUTFILENAME MT.SCAN MT.START.SCANNING MT.SETUPSCANFILE 
	     MT.SEND.SCAN.PARAMETERS MT.SENDCOMMAND MT.COMPUTECHECKSUM MT.PRINT.ERROR.MSG MT.SENDACK 
	     MT.SENDNAK MT.STOP.SCANNING MT.RESET MT.PAGEMAP MT.QUIT)
	(* * Functions to convert and print scanned images)
	(FNS MT.DISPLAY.MENU MT.GET.SOURCEFILENAME MT.GET.BITMAPNAME MT.CREATEBM MT.BITMAPCREATE 
	     MT.CONVERTIMAGETOBM MT.CREATE.BIG.BM MT.CREATE.DISPLAYWINDOW MT.REPAINTWINDOW 
	     MT.RESHAPEWINDOW)
	(ADDVARS (BackgroundMenuCommands ("MicrotekScanner" (MT.INIT)
							    
"Open Microtek Scanner Command and Display windows, initilalize RS232 port and verifies Microtek Scanner is ready"
							    )))
	(VARS (BackgroundMenu NIL))
	(VARS MT.ICON MT.ICON.MASK BRIGHTBAR CONTRASTBAR INITIALBRIGHTBAR INITIALCONTRASTBAR 
	      LEFTARROW MANCURSOR RIGHTARROW MT.POINTER)
	(INITVARS (MT.BAUDRATE 19200)
		  (MT.DISPLAYFRAME (QUOTE YES))
		  (MT.PAPERLENGTH 4)
		  (MT.REDUCTION 0)
		  (MT.CONTRAST 0)
		  (MT.BRIGHTNESS 0)
		  (MT.GREYLEVEL 0)
		  (MT.DATACOMPRESSION (QUOTE NO))
		  (MT.BACKGROUND (QUOTE HALFTONE))
		  (MT.WINDOW (QUOTE LINEART))
		  (MT.FRAME (QUOTE (0 0 40 24)))
		  (MT.FRAME.BOX (QUOTE (0 460 200 120)))
		  (MT.TEXTW1 (QUOTE (0 0 0 0)))
		  (MT.TEXTW2 (QUOTE (0 0 0 0)))
		  (MT.TEXTW3 (QUOTE (0 0 0 0)))
		  (MT.TEXTW4 (QUOTE (0 0 0 0)))
		  (MT.TEXTW1BOX (QUOTE (0 0 0 0)))
		  (MT.TEXTW2BOX (QUOTE (0 0 0 0)))
		  (MT.TEXTW3BOX (QUOTE (0 0 0 0)))
		  (MT.TEXTW4BOX (QUOTE (0 0 0 0)))
		  (MT.HALFTONEW1 (QUOTE (0 0 0 0)))
		  (MT.HALFTONEW2 (QUOTE (0 0 0 0)))
		  (MT.HALFTONEW3 (QUOTE (0 0 0 0)))
		  (MT.HALFTONEW4 (QUOTE (0 0 0 0)))
		  (MT.HALFTONEW1BOX (QUOTE (0 0 0 0)))
		  (MT.HALFTONEW2BOX (QUOTE (0 0 0 0)))
		  (MT.HALFTONEW3BOX (QUOTE (0 0 0 0)))
		  (MT.HALFTONEW4BOX (QUOTE (0 0 0 0)))
		  (MT.OUTSTREAM NIL)
		  (MT.INSTREAM NIL)
		  (MT.BMSHRINKFACTOR 1))
	(GLOBALVARS MT.STATUSWINDOW MT.GRID MT.PAPERLENGTH MT.REDUCTION MT.BRIGHTNESS MT.CONTRAST 
		    MT.GREYLEVEL MT.DATACOMPRESSION MT.BACKGROUND MT.WINDOW MT.HEIGHTWINDOW MT.FRAME 
		    MT.TEXTW1 MT.TEXTW2 MT.TEXTW3 MT.TEXTW4 MT.HALFTONEW1 MT.HALFTONEW2 MT.HALFTONEW3 
		    MT.HALFTONEW4 MT.OUTSTREAM MT.INSTREAM BRIGHTBAR CONTRASTBAR LEFTARROW MANCURSOR 
		    RIGHTARROW)))
(FILESLOAD DLRS232C FREEMENU ICONW EDITBITMAP)
(* * Microtek Initialization and Menu Functions)

(DEFINEQ

(MT.INIT
  [LAMBDA NIL                                                (* rdc " 9-Oct-86 10:25")
    (MICROTEKSCANNER)
    (MT.CONTROL.MENU)
    (MT.COMMAND.MENU)
    (MT.DISPLAY.MENU)
    (SETQ MT.STATUSWINDOW (CREATEW (QUOTE (0 0 387 30))
				       "Microtek Status Window"))
    (SHAPEW MT.CONTROL.MENUWINDOW (QUOTE (529 100 387 232)))
    (ATTACHWINDOW MT.COMMAND.MENUWINDOW MT.CONTROL.MENUWINDOW (QUOTE TOP)
		    (QUOTE JUSTIFY))
    (ATTACHWINDOW MT.DISPLAY.MENUWINDOW MT.CONTROL.MENUWINDOW (QUOTE BOTTOM)
		    (QUOTE JUSTIFY))
    (ATTACHWINDOW MT.STATUSWINDOW MT.COMMAND.MENUWINDOW (QUOTE TOP)
		    (QUOTE JUSTIFY))
    (if (FNTYP (QUOTE MT.PRINT.MENU))
	then (MT.PRINT.MENU))
    (if (FNTYP (QUOTE MT.4045.MENU))
	then (MT.4045.MENU))
    (WINDOWPROP MT.CONTROL.MENUWINDOW (QUOTE ICONFN)
		  (QUOTE MT.SHRINKFN))
    [BITBLT MT.POINTER 0 0 MTHEIGHTRULER 20 (IDIFFERENCE 453
							     (FIX (FTIMES 5
									      (FDIFFERENCE
										(FQUOTIENT 
										   MT.PAPERLENGTH 
											     .125)
										24]
    (CLOSEF? MT.OUTSTREAM)
    (CLOSEF? MT.INSTREAM)
    (if \RS232C.READY
	then (RS232C.SHUTDOWN))
    (RS232C.INIT MT.BAUDRATE 8 (QUOTE NONE)
		   1
		   (QUOTE DTR))
    (SETQ MT.OUTSTREAM (OPENSTREAM (QUOTE {RS232})
				       (QUOTE OUTPUT)))
    (SETQ MT.INSTREAM (RS232C.OTHER.STREAM MT.OUTSTREAM))
    (if [SETQ RESPONSE (MT.SENDCOMMAND 1 (LIST (QUOTE !]
	then (CLRPROMPT)
	       (MT.PRINT.STATUS (CONCAT RESPONSE " READY"))
      else (RINGBELLS)
	     (MT.PRINT.STATUS "Microtek Not Responding ...Check scanner and cables"])

(MT.SHRINKFN
  [LAMBDA (WINDOW ICON)                                      (* rdc "14-Oct-86 13:53")
    (PROG NIL
	    (CLOSEW MTDISPLAYWINDOW)
	    (CLOSEW MTDISPLAYWINDOW)
	    (if (WINDOWPROP MT.CONTROL.MENUWINDOW (QUOTE ICONWINDOW))
		then (RETURN (WINDOWPROP MT.CONTROL.MENUWINDOW (QUOTE ICONWINDOW)))
	      else (RETURN (ICONW MT.ICON MT.ICON.MASK NIL T])

(MICROTEKSCANNER
  [LAMBDA NIL                                                (* rdc " 6-Aug-86 08:49")
    (PROG (MTWIDTHRULER YHEIGHT)
	    (SETQ MTDISPLAYWINDOW (DECODE.WINDOW.ARG (QUOTE (100 . 100))
							 350 579 "Microtek Scanner Page Map" 5))
	    (SETQ MTHEIGHTRULER (DECODE.WINDOW.ARG (QUOTE (100 . 100))
						       50 570 NIL 5 T))
	    (SETQ MTWIDTHRULER (DECODE.WINDOW.ARG (QUOTE (100 . 100))
						      350 50 NIL 5 T))
	    (DSPFONT (FONTCREATE (QUOTE GACHA)
				     10
				     (QUOTE BRR))
		       MTHEIGHTRULER)
	    (DSPFONT (FONTCREATE (QUOTE GACHA)
				     10
				     (QUOTE BRR))
		       MTWIDTHRULER)
	    (ATTACHWINDOW MTHEIGHTRULER MTDISPLAYWINDOW (QUOTE LEFT)
			    (QUOTE JUSTIFY))
	    (ATTACHWINDOW MTWIDTHRULER MTDISPLAYWINDOW (QUOTE TOP)
			    (QUOTE CENTER))
	    (WINDOWPROP MTDISPLAYWINDOW (QUOTE RESHAPEFN)
			  (QUOTE (DON'T)))
	    (WINDOWPROP MTHEIGHTRULER (QUOTE RESHAPEFN)
			  (QUOTE (DON'T)))
	    (WINDOWPROP MTHEIGHTRULER (QUOTE CURSORINFN)
			  (QUOTE MT.CURSOR.IN))
	    (WINDOWPROP MTHEIGHTRULER (QUOTE CURSOROUTFN)
			  (QUOTE MT.CURSOR.OUT))
	    (WINDOWPROP MTHEIGHTRULER (QUOTE BUTTONEVENTFN)
			  (QUOTE MT.GETLENGTH))
	    (WINDOWPROP MTWIDTHRULER (QUOTE RESHAPEFN)
			  (QUOTE (DON'T)))
	    (RULERX 0 1 16 16 40 1 MTWIDTHRULER)
	    (RULERX 0 1 12 32 20 1 MTWIDTHRULER)
	    (RULERX 0 1 8 64 10 1 MTWIDTHRULER)
	    (RULERX 0 1 4 128 5 1 MTWIDTHRULER)
	    (RULEX# 0 20 40 0 8 MTWIDTHRULER)
	    (SETQ YHEIGHT 580)
	    (RULERY YHEIGHT 1 16 15 -40 1 MTHEIGHTRULER)
	    (RULERY YHEIGHT 1 12 28 -20 1 MTHEIGHTRULER)
	    (RULERY YHEIGHT 1 8 56 -10 1 MTHEIGHTRULER)
	    (RULERY YHEIGHT 1 4 112 -5 1 MTHEIGHTRULER)
	    (RULEY# 0 YHEIGHT -40 0 14 MTHEIGHTRULER)
	    (SETQ MT.HEIGHT.BM (BITMAPCREATE 50 588))
	    (BITBLT MTHEIGHTRULER 0 0 MT.HEIGHT.BM)
	    (SETQ MT.GRID (BITMAPCREATE 350 579))
	    (GRID (QUOTE (0 20 10 10))
		    42 56 (QUOTE POINT)
		    MTDISPLAYWINDOW)
	    (BITBLT MTDISPLAYWINDOW 0 0 MT.GRID])

(RULERX
  [LAMBDA (STARTX STARTY LEN NUMLINES INCR LINEWIDTH WIND)   (* rdc "27-Jun-86 15:28")
    (for I from 1 to NUMLINES
       do (DRAWLINE STARTX 1 STARTX LEN LINEWIDTH NIL WIND)
	    (SETQ STARTX (PLUS STARTX INCR])

(RULEX#
  [LAMBDA (STARTX STARTY INCR STARTNUMBER ENDNUMBER WIND)    (* rdc " 6-Mar-86 16:13")
    (for I from STARTNUMBER to ENDNUMBER
       do (MOVETO STARTX STARTY WIND)
	    (PRINT I WIND)
	    (SETQ STARTX (PLUS STARTX INCR])

(RULERY
  [LAMBDA (STARTY STARTX LEN NUMLINES INCR LINEWIDTH WIND)   (* rdc " 6-Mar-86 16:25")
    (for I from 1 to NUMLINES
       do (DRAWLINE (DIFFERENCE (WINDOWPROP WIND (QUOTE WIDTH))
				      STARTX)
			STARTY
			(DIFFERENCE (DIFFERENCE (WINDOWPROP WIND (QUOTE WIDTH))
						    STARTX)
				      LEN)
			STARTY LINEWIDTH NIL WIND)
	    (SETQ STARTY (PLUS STARTY INCR])

(RULEY#
  [LAMBDA (STARTX STARTY INCR STARTNUMBER ENDNUMBER WIND)    (* rdc " 6-Mar-86 16:37")
    (for I from STARTNUMBER to ENDNUMBER
       do (MOVETO STARTX STARTY WIND)
	    (PRINT I WIND)
	    (SETQ STARTY (PLUS STARTY INCR])

(MT.GETLENGTH
  [LAMBDA NIL                                                (* rdc "30-Jul-86 19:34")
    (TOTOPW MTHEIGHTRULER)
    (if (MOUSESTATE LEFT)
	then [SETQ MT.PAPERLENGTH (IMIN 453 (CDR (CURSORPOSITION NIL MTHEIGHTRULER]
	       (CLEARW MTHEIGHTRULER)
	       (BITBLT MT.HEIGHT.BM 0 0 MTHEIGHTRULER 0 0)
	       (BITBLT MT.POINTER 0 0 MTHEIGHTRULER 20 MT.PAPERLENGTH)
	       (SETQ MT.PAPERLENGTH (FTIMES (FIX (FPLUS 24.0 (FQUOTIENT (FDIFFERENCE
										    453 
										   MT.PAPERLENGTH)
										  5)))
						.125))
	       (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE PAGELENGTH))
				 MT.CONTROL.MENUWINDOW MT.PAPERLENGTH])

(MT.CURSOR.IN
  [LAMBDA NIL                                                (* edited: " 1-Jul-86 17:55")
    (CURSOR (CURSORCREATE MT.POINTER 8 0])

(MT.CURSOR.OUT
  [LAMBDA NIL                                                (* edited: " 1-Jul-86 17:12")
    (CURSOR T])

(MT.PRINT.STATUS
  [LAMBDA (MSG)                                              (* rdc " 7-Aug-86 07:47")
    (CLEARW MT.STATUSWINDOW)
    (PRIN1 MSG MT.STATUSWINDOW])

(MT.CONTROL.MENU
  [LAMBDA NIL                                                (* rdc " 6-Aug-86 16:53")
    (PROG (MENU.DESCRIPTION)
	    [SETQ MENU.DESCRIPTION
	      (BQUOTE ((TYPE MOMENTARY LABEL "Frame: " FONT (MODERN 10 BOLD)
			       SELECTEDFN MT.GETTRANSFRAME LEFT 0 BOTTOM 90)
			 (TYPE TITLE LABEL X1 FONT (MODERN 10 BOLD)
			       LEFT 85 BOTTOM 90)
			 (TYPE EDIT ID TX1 LABEL "" LEFT 105 BOTTOM 90)
			 (TYPE TITLE LABEL Y1 FONT (MODERN 10 BOLD)
			       LEFT 145 BOTTOM 90)
			 (TYPE EDIT ID TY1 LABEL "" LEFT 185 BOTTOM 90)
			 (TYPE TITLE LABEL X2 FONT (MODERN 10 BOLD)
			       LEFT 225 BOTTOM 90)
			 (TYPE EDIT ID TX2 LABEL "" LEFT 255 BOTTOM 90)
			 (TYPE TITLE LABEL Y2 FONT (MODERN 10 BOLD)
			       LEFT 300 BOTTOM 90)
			 (TYPE EDIT ID TY2 LABEL "" LEFT 335 BOTTOM 90)
			 (TYPE TITLE LABEL , MT.WINDOW ID WINDOWTYPE FONT (MODERN 10 BOLD)
			       LEFT 0 BOTTOM 60)
			 (TYPE MOMENTARY LABEL "Window 1: " LEFT 0 BOTTOM 45 FONT (MODERN 10 BOLD)
			       SELECTEDFN MT.GETWINDOW1)
			 (TYPE NCHOOSE LABEL "" LEFT 50 BOTTOM 45 ID SW1 ITEMS (NO YES)
			       SELECTEDFN MT.UPDATE.HTWINDOWS)
			 (TYPE TITLE LABEL X1 FONT (MODERN 10 BOLD)
			       LEFT 85 BOTTOM 45)
			 (TYPE EDIT ID X11 LABEL "" LEFT 105 BOTTOM 45)
			 (TYPE TITLE LABEL Y1 FONT (MODERN 10 BOLD)
			       LEFT 145 BOTTOM 45)
			 (TYPE EDIT ID Y11 LABEL "" LEFT 170 BOTTOM 45)
			 (TYPE TITLE LABEL X2 FONT (MODERN 10 BOLD)
			       LEFT 225 BOTTOM 45)
			 (TYPE EDIT ID X21 LABEL "" LEFT 255 BOTTOM 45)
			 (TYPE TITLE LABEL Y2 FONT (MODERN 10 BOLD)
			       LEFT 300 BOTTOM 45)
			 (TYPE EDIT ID Y21 LABEL "" LEFT 335 BOTTOM 45)
			 (TYPE MOMENTARY LABEL "Window 2: " LEFT 0 BOTTOM 30 FONT (MODERN 10 BOLD)
			       SELECTEDFN MT.GETWINDOW2)
			 (TYPE NCHOOSE LABEL "" LEFT 50 BOTTOM 30 ID SW2 ITEMS (NO YES)
			       SELECTEDFN MT.UPDATE.HTWINDOWS)
			 (TYPE TITLE LABEL X1 FONT (MODERN 10 BOLD)
			       LEFT 85 BOTTOM 30)
			 (TYPE EDIT ID X12 LABEL "" LEFT 105 BOTTOM 30)
			 (TYPE TITLE LABEL Y1 FONT (MODERN 10 BOLD)
			       LEFT 145 BOTTOM 30)
			 (TYPE EDIT ID Y12 LABEL "" LEFT 170 BOTTOM 30)
			 (TYPE TITLE LABEL X2 FONT (MODERN 10 BOLD)
			       LEFT 225 BOTTOM 30)
			 (TYPE EDIT ID X22 LABEL "" LEFT 255 BOTTOM 30)
			 (TYPE TITLE LABEL Y2 FONT (MODERN 10 BOLD)
			       LEFT 300 BOTTOM 30)
			 (TYPE EDIT ID Y22 LABEL "" LEFT 335 BOTTOM 30)
			 (TYPE MOMENTARY LABEL "Window 3: " LEFT 0 BOTTOM 15 FONT (MODERN 10 BOLD)
			       SELECTEDFN MT.GETWINDOW3)
			 (TYPE NCHOOSE LABEL "" LEFT 50 BOTTOM 15 ID SW3 ITEMS (NO YES)
			       SELECTEDFN MT.UPDATE.HTWINDOWS)
			 (TYPE TITLE LABEL X1 FONT (MODERN 10 BOLD)
			       LEFT 85 BOTTOM 15)
			 (TYPE EDIT ID X13 LABEL "" LEFT 105 BOTTOM 15)
			 (TYPE TITLE LABEL Y1 FONT (MODERN 10 BOLD)
			       LEFT 145 BOTTOM 15)
			 (TYPE EDIT ID Y13 LABEL "" LEFT 170 BOTTOM 15)
			 (TYPE TITLE LABEL X2 FONT (MODERN 10 BOLD)
			       LEFT 225 BOTTOM 15)
			 (TYPE EDIT ID X23 LABEL "" LEFT 255 BOTTOM 15)
			 (TYPE TITLE LABEL Y2 FONT (MODERN 10 BOLD)
			       LEFT 300 BOTTOM 15)
			 (TYPE EDIT ID Y23 LABEL "" LEFT 335 BOTTOM 15)
			 (TYPE MOMENTARY LABEL "Window 4: " LEFT 0 BOTTOM 0 FONT (MODERN 10 BOLD)
			       SELECTEDFN MT.GETWINDOW4)
			 (TYPE NCHOOSE LABEL "" LEFT 50 BOTTOM 0 ID SW4 ITEMS (NO YES)
			       SELECTEDFN MT.UPDATE.HTWINDOWS)
			 (TYPE TITLE LABEL X1 FONT (MODERN 10 BOLD)
			       LEFT 85 BOTTOM 0)
			 (TYPE EDIT ID X14 LABEL "" LEFT 105 BOTTOM 0)
			 (TYPE TITLE LABEL Y1 FONT (MODERN 10 BOLD)
			       LEFT 145 BOTTOM 0)
			 (TYPE EDIT ID Y14 LABEL "" LEFT 170 BOTTOM 0)
			 (TYPE TITLE LABEL X2 FONT (MODERN 10 BOLD)
			       LEFT 225 BOTTOM 0)
			 (TYPE EDIT ID X24 LABEL "" LEFT 255 BOTTOM 0)
			 (TYPE TITLE LABEL Y2 FONT (MODERN 10 BOLD)
			       LEFT 300 BOTTOM 0)
			 (TYPE EDIT ID Y24 LABEL "" LEFT 335 BOTTOM 0)
			 (TYPE TITLE LABEL "Background: " FONT (MODERN 10 BOLD)
			       LEFT 0 BOTTOM 105)
			 (TYPE NWAY ID BACKGROUND LABEL HALFTONE LEFT 70 BOTTOM 105 SELECTEDFN 
			       MT.SELECT.BACKGROUND)
			 (TYPE TITLE LABEL "Page Length: " LEFT 225 BOTTOM 105 FONT (MODERN 10 BOLD))
			 (TYPE EDIT ID PAGELENGTH LABEL "" LEFT 295 BOTTOM 105)
			 (TYPE NWAY ID BACKGROUND LABEL LINEART LEFT 140 BOTTOM 105 SELECTEDFN 
			       MT.SELECT.BACKGROUND)
			 (TYPE TITLE LABEL "Reduction: " LEFT 0 BOTTOM 180 FONT (MODERN 10 BOLD))
			 (TYPE NCHOOSE LABEL "" LEFT 50 BOTTOM 180 ID REDUCTION ITEMS
			       (" 0%% = 300 DPI" " 5%% = 285 DPI" "10%% = 270 DPI" "15%% = 255 DPI" 
						 "20%% = 240 DPI"
						 "25%% = 225 DPI" "33%% = 200 DPI" "35%% = 195 DPI" 
						 "40%% = 180 DPI"
						 "45%% = 165 DPI" "50%% = 150 DPI" "55%% = 135 DPI" 
						 "60%% = 120 DPI"
						 "67%% = 100 DPI" "70%% =  90 DPI" "75%% =  75 DPI"))
			 (TYPE TITLE LABEL "Grain Size" LEFT 265 BOTTOM 195 FONT (MODERN 10 BOLD))
			 (TYPE TITLE LABEL "Levels" LEFT 320 BOTTOM 195 FONT (MODERN 10 BOLD))
			 (TYPE TITLE LABEL "Gray Level: " LEFT 170 BOTTOM 180 FONT (MODERN 10 BOLD))
			 (TYPE NCHOOSE LABEL "" LEFT 225 BOTTOM 180 ID GREYLEVEL ITEMS
			       (" 0 =   8X8    33" " 1 =   8X8    33" " 2 =   8X8    33" 
						   " 3 =   8X8    33"
						   " 4 =   6X6    37" " 5 =   5X5    26" 
						   " 6 =   5X5    18"
						   " 7 =   4X4    17" " 8 =   4X4    17" 
						   " 9 =   4X4    17"
						   "10 =   3X3    10" "11 =   2X2     5"))
			 (TYPE TITLE LABEL "Contrast:   " LEFT 0 BOTTOM 150 FONT (MODERN 10 BOLD))
			 (LABEL , LEFTARROW HELDFN MT.LOWERCONTRAST LEFT 71 BOTTOM 150 MESSAGE "")
			 (TYPE TITLE LABEL , CONTRASTBAR ID CONTRASTBAR LEFT 85 BOTTOM 150)
			 (LABEL , RIGHTARROW HELDFN MT.RAISECONTRAST LEFT 217 BOTTOM 150 MESSAGE "")
			 (TYPE EDIT ID CONTRAST LABEL 0 LEFT 233 BOTTOM 150)
			 (TYPE TITLE LABEL Brightness: FONT (MODERN 10 BOLD)
			       LEFT 0 BOTTOM 135)
			 (LABEL , LEFTARROW HELDFN MT.LOWERBRIGHTNESS LEFT 71 BOTTOM 135 MESSAGE "")
			 (TYPE TITLE LABEL , BRIGHTBAR ID BRIGHTBAR LEFT 85 BOTTOM 135)
			 (LABEL , RIGHTARROW HELDFN MT.RAISEBRIGHTNESS LEFT 217 BOTTOM 135 MESSAGE "")
			 (TYPE EDIT ID BRIGHTNESS LABEL 0 LEFT 233 BOTTOM 135)
			 (WINDOWPROPS TITLE "Microtek Configuration Menu" BORDER 5 LEFT 600 BOTTOM 
				      100]
	    (SETQ MT.CONTROL.MENUWINDOW (FM.MAKEMENU MENU.DESCRIPTION))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW MT.BACKGROUND)
			      MT.CONTROL.MENUWINDOW)
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE TX1))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES (CAR MT.FRAME)
					.125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE TY1))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES (CADR MT.FRAME)
					.125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE TX2))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES (CADDR MT.FRAME)
					.125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE TY2))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES (CADDDR MT.FRAME)
					.125))
	    (MT.SELECT.BACKGROUND)
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE PAGELENGTH))
			      MT.CONTROL.MENUWINDOW MT.PAPERLENGTH)
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE REDUCTION))
			      MT.CONTROL.MENUWINDOW MT.REDUCTION)
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE CONTRAST))
			      MT.CONTROL.MENUWINDOW MT.CONTRAST)
	    (FM.CHANGELABEL (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE BRIGHTNESS))
			      MT.CONTROL.MENUWINDOW MT.BRIGHTNESS)
	    (MT.CHANGE.BRIGHTBAR MT.BRIGHTNESS)
	    (MT.CHANGE.CONTRASTBAR MT.CONTRAST)
	    (OPENW MT.CONTROL.MENUWINDOW])

(MT.CHANGE.BRIGHTBAR
  [LAMBDA (BRIGHTNESS)                                       (* rdc " 5-Mar-86 14:18")

          (* * Moves the cursor in BRIGHTBAR from one place to another.)


    (BITBLT INITIALBRIGHTBAR NIL NIL BRIGHTBAR NIL NIL NIL NIL NIL (QUOTE REPLACE))
    (BITBLT MANCURSOR NIL NIL BRIGHTBAR (IPLUS 60 (FIX (TIMES BRIGHTNESS 2)))
	      0 10 10 NIL (QUOTE INVERT))                  (* BITBLT BRIGHTBAR NIL NIL MANIPULATOR.WINDOW 87 79)
    (FM.CHANGELABEL (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE BRIGHTBAR))
		      MT.CONTROL.MENUWINDOW BRIGHTBAR])

(MT.RAISEBRIGHTNESS
  [LAMBDA NIL                                                (* rdc " 5-Mar-86 14:19")
    [if (LEQ (IPLUS MT.BRIGHTNESS 4)
		 28)
	then (MT.CHANGE.BRIGHTBAR (SETQ MT.BRIGHTNESS (IPLUS MT.BRIGHTNESS 4]
    (FM.CHANGELABEL (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE BRIGHTNESS))
		      MT.CONTROL.MENUWINDOW MT.BRIGHTNESS])

(MT.LOWERBRIGHTNESS
  [LAMBDA NIL                                                (* rdc " 5-Mar-86 14:20")
    [if (GEQ (IDIFFERENCE MT.BRIGHTNESS 4)
		 -24)
	then (MT.CHANGE.BRIGHTBAR (SETQ MT.BRIGHTNESS (IDIFFERENCE MT.BRIGHTNESS 4]
    (FM.CHANGELABEL (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE BRIGHTNESS))
		      MT.CONTROL.MENUWINDOW MT.BRIGHTNESS])

(MT.CHANGE.CONTRASTBAR
  [LAMBDA (CONTRAST)                                         (* rdc " 5-Mar-86 14:18")

          (* * Moves the diamond cursor around inside CONTRASTBAR.)


    (BITBLT INITIALCONTRASTBAR NIL NIL CONTRASTBAR NIL NIL NIL NIL NIL (QUOTE REPLACE))
    (BITBLT MANCURSOR NIL NIL CONTRASTBAR (IPLUS 60 (FIX (TIMES CONTRAST 2)))
	      0 10 10 NIL (QUOTE INVERT))
    (FM.CHANGELABEL (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE CONTRASTBAR))
		      MT.CONTROL.MENUWINDOW CONTRASTBAR])

(MT.RAISECONTRAST
  [LAMBDA NIL                                                (* rdc " 5-Mar-86 14:22")
    [if (LEQ (IPLUS MT.CONTRAST 4)
		 28)
	then (MT.CHANGE.CONTRASTBAR (SETQ MT.CONTRAST (IPLUS MT.CONTRAST 4]
    (FM.CHANGELABEL (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE CONTRAST))
		      MT.CONTROL.MENUWINDOW MT.CONTRAST])

(MT.LOWERCONTRAST
  [LAMBDA NIL                                                (* rdc " 5-Mar-86 14:21")
    [if (GEQ (IDIFFERENCE MT.CONTRAST 4)
		 -24)
	then (MT.CHANGE.CONTRASTBAR (SETQ MT.CONTRAST (IDIFFERENCE MT.CONTRAST 4]
    (FM.CHANGELABEL (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE CONTRAST))
		      MT.CONTROL.MENUWINDOW MT.CONTRAST])

(MT.SELECT.BACKGROUND
  [LAMBDA NIL                                                (* rdc " 1-Aug-86 09:37")
    (SETQ MT.BACKGROUND (LISTGET (FM.READSTATE MT.CONTROL.MENUWINDOW)
				     (QUOTE BACKGROUND)))
    (if (EQ MT.BACKGROUND (QUOTE LINEART))
	then (FM.CHANGELABEL (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE WINDOWTYPE))
				 MT.CONTROL.MENUWINDOW
				 (QUOTE HALFTONE))
	       (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X11))
				 MT.CONTROL.MENUWINDOW
				 (FTIMES (CAR MT.HALFTONEW1)
					   .125))
	       (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y11))
				 MT.CONTROL.MENUWINDOW
				 (FTIMES (CADR MT.HALFTONEW1)
					   .125))
	       (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X21))
				 MT.CONTROL.MENUWINDOW
				 (FTIMES (CADDR MT.HALFTONEW1)
					   .125))
	       (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y21))
				 MT.CONTROL.MENUWINDOW
				 (FTIMES (CADDDR MT.HALFTONEW1)
					   .125))
	       (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X12))
				 MT.CONTROL.MENUWINDOW
				 (FTIMES (CAR MT.HALFTONEW2)
					   .125))
	       (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y12))
				 MT.CONTROL.MENUWINDOW
				 (FTIMES (CADR MT.HALFTONEW2)
					   .125))
	       (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X22))
				 MT.CONTROL.MENUWINDOW
				 (FTIMES (CADDR MT.HALFTONEW2)
					   .125))
	       (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y22))
				 MT.CONTROL.MENUWINDOW
				 (FTIMES (CADDDR MT.HALFTONEW2)
					   .125))
	       (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X13))
				 MT.CONTROL.MENUWINDOW
				 (FTIMES (CAR MT.HALFTONEW3)
					   .125))
	       (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y13))
				 MT.CONTROL.MENUWINDOW
				 (FTIMES (CADR MT.HALFTONEW3)
					   .125))
	       (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X23))
				 MT.CONTROL.MENUWINDOW
				 (FTIMES (CADDR MT.HALFTONEW3)
					   .125))
	       (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y23))
				 MT.CONTROL.MENUWINDOW
				 (FTIMES (CADDDR MT.HALFTONEW3)
					   .125))
	       (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X14))
				 MT.CONTROL.MENUWINDOW
				 (FTIMES (CAR MT.HALFTONEW4)
					   .125))
	       (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y14))
				 MT.CONTROL.MENUWINDOW
				 (FTIMES (CADR MT.HALFTONEW4)
					   .125))
	       (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X24))
				 MT.CONTROL.MENUWINDOW
				 (FTIMES (CADDR MT.HALFTONEW4)
					   .125))
	       (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y24))
				 MT.CONTROL.MENUWINDOW
				 (FTIMES (CADDDR MT.HALFTONEW4)
					   .125))
      else (FM.CHANGELABEL (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE WINDOWTYPE))
			       MT.CONTROL.MENUWINDOW
			       (QUOTE LINEART))
	     (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X11))
			       MT.CONTROL.MENUWINDOW
			       (FTIMES (CAR MT.TEXTW1)
					 .125))
	     (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y11))
			       MT.CONTROL.MENUWINDOW
			       (FTIMES (CADR MT.TEXTW1)
					 .125))
	     (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X21))
			       MT.CONTROL.MENUWINDOW
			       (FTIMES (CADDR MT.TEXTW1)
					 .125))
	     (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y21))
			       MT.CONTROL.MENUWINDOW
			       (FTIMES (CADDDR MT.TEXTW1)
					 .125))
	     (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X12))
			       MT.CONTROL.MENUWINDOW
			       (FTIMES (CAR MT.TEXTW2)
					 .125))
	     (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y12))
			       MT.CONTROL.MENUWINDOW
			       (FTIMES (CADR MT.TEXTW2)
					 .125))
	     (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X22))
			       MT.CONTROL.MENUWINDOW
			       (FTIMES (CADDR MT.TEXTW2)
					 .125))
	     (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y22))
			       MT.CONTROL.MENUWINDOW
			       (FTIMES (CADDDR MT.TEXTW2)
					 .125))
	     (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X13))
			       MT.CONTROL.MENUWINDOW
			       (FTIMES (CAR MT.TEXTW3)
					 .125))
	     (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y13))
			       MT.CONTROL.MENUWINDOW
			       (FTIMES (CADR MT.TEXTW3)
					 .125))
	     (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X23))
			       MT.CONTROL.MENUWINDOW
			       (FTIMES (CADDR MT.TEXTW3)
					 .125))
	     (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y23))
			       MT.CONTROL.MENUWINDOW
			       (FTIMES (CADDDR MT.TEXTW3)
					 .125))
	     (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X14))
			       MT.CONTROL.MENUWINDOW
			       (FTIMES (CAR MT.TEXTW4)
					 .125))
	     (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y14))
			       MT.CONTROL.MENUWINDOW
			       (FTIMES (CADR MT.TEXTW4)
					 .125))
	     (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X24))
			       MT.CONTROL.MENUWINDOW
			       (FTIMES (CADDR MT.TEXTW4)
					 .125))
	     (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y24))
			       MT.CONTROL.MENUWINDOW
			       (FTIMES (CADDDR MT.TEXTW4)
					 .125)))
    (MT.UPDATE.HTWINDOWS])

(MT.GETTRANSFRAME
  [LAMBDA NIL                                                (* rdc "30-Jul-86 17:50")
    (PROG (WINDOWLOC TWINDOW PAGEMAPWIDTH PAGEMAPHEIGHT ORGX ORGY WIDTH HEIGHT)
	    (TOTOPW MTDISPLAYWINDOW)
	    (SETQ WINDOWLOC (WINDOWPROP MTDISPLAYWINDOW (QUOTE REGION)))
	    (SETQ TWINDOW (SETQ WINDOW (GETREGION)))
	    [SETQ PAGEMAPWIDTH (IDIFFERENCE (WINDOWPROP MTDISPLAYWINDOW (QUOTE WIDTH))
						(ITIMES 2 (WINDOWPROP MTDISPLAYWINDOW
									  (QUOTE BORDER]
	    [SETQ PAGEMAPHEIGHT (IDIFFERENCE [IDIFFERENCE (WINDOWPROP MTDISPLAYWINDOW
									      (QUOTE HEIGHT))
								(ITIMES 2 (WINDOWPROP
									    MTDISPLAYWINDOW
									    (QUOTE BORDER]
						 (FONTPROP WindowTitleDisplayStream (QUOTE HEIGHT]
	    [SETQ ORGX (IMAX 0 (IMIN PAGEMAPWIDTH (IDIFFERENCE (IMAX 0 (IDIFFERENCE
										 (CAR TWINDOW)
										 (CAR WINDOWLOC)))
								       (WINDOWPROP MTDISPLAYWINDOW
										     (QUOTE BORDER]
	    [SETQ ORGY (IMAX 0 (IMIN PAGEMAPHEIGHT (IDIFFERENCE (IMAX 0
										(IDIFFERENCE
										  (CADR TWINDOW)
										  (CADR WINDOWLOC)))
									25]
	    (SETQ WIDTH (IMIN PAGEMAPWIDTH (CADDR TWINDOW)))
	    (if (GREATERP (IPLUS ORGX WIDTH)
			      PAGEMAPWIDTH)
		then (SETQ WIDTH (IDIFFERENCE PAGEMAPWIDTH ORGX)))
	    (SETQ HEIGHT (IMIN PAGEMAPHEIGHT (CADDDR TWINDOW)))
	    (if (GREATERP (IPLUS ORGY HEIGHT)
			      PAGEMAPHEIGHT)
		then (SETQ HEIGHT (IDIFFERENCE PAGEMAPHEIGHT ORGY)))
	    (SETQ X1 (FIX (QUOTIENT ORGX 5.0)))
	    (SETQ Y1 (FIX (QUOTIENT (IDIFFERENCE PAGEMAPHEIGHT (IPLUS ORGY HEIGHT))
					  5.0)))
	    (SETQ X2 (FIX (QUOTIENT (IPLUS ORGX WIDTH)
					  5.0)))
	    (SETQ Y2 (FIX (QUOTIENT (IDIFFERENCE PAGEMAPHEIGHT ORGY)
					  5.0)))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE TX1))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES X1 .125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE TY1))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES Y1 .125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE TX2))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES X2 .125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE TY2))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES Y2 .125))
	    (SETQ MT.FRAME (LIST X1 Y1 X2 Y2))
	    (SETQ MT.FRAME.BOX (LIST ORGX (IPLUS ORGY 20)
					 WIDTH HEIGHT))
	    (MT.UPDATE.HTWINDOWS])

(MT.GETWINDOW1
  [LAMBDA NIL                                                (* rdc "30-Jul-86 18:15")
    (PROG (WINDOWLOC TWINDOW PAGEMAPWIDTH PAGEMAPHEIGHT ORGX ORGY WIDTH HEIGHT)
	    (TOTOPW MTDISPLAYWINDOW)
	    (SETQ WINDOWLOC (WINDOWPROP MTDISPLAYWINDOW (QUOTE REGION)))
	    (SETQ TWINDOW (SETQ WINDOW (GETREGION)))
	    [SETQ PAGEMAPWIDTH (IDIFFERENCE (WINDOWPROP MTDISPLAYWINDOW (QUOTE WIDTH))
						(ITIMES 2 (WINDOWPROP MTDISPLAYWINDOW
									  (QUOTE BORDER]
	    [SETQ PAGEMAPHEIGHT (IDIFFERENCE [IDIFFERENCE (WINDOWPROP MTDISPLAYWINDOW
									      (QUOTE HEIGHT))
								(ITIMES 2 (WINDOWPROP
									    MTDISPLAYWINDOW
									    (QUOTE BORDER]
						 (FONTPROP WindowTitleDisplayStream (QUOTE HEIGHT]
	    [SETQ ORGX (IMAX 0 (IMIN PAGEMAPWIDTH (IDIFFERENCE (IMAX 0 (IDIFFERENCE
										 (CAR TWINDOW)
										 (CAR WINDOWLOC)))
								       (WINDOWPROP MTDISPLAYWINDOW
										     (QUOTE BORDER]
	    [SETQ ORGY (IMAX 0 (IMIN PAGEMAPHEIGHT (IDIFFERENCE (IMAX 0
										(IDIFFERENCE
										  (CADR TWINDOW)
										  (CADR WINDOWLOC)))
									25]
	    (SETQ WIDTH (IMIN PAGEMAPWIDTH (CADDR TWINDOW)))
	    (if (GREATERP (IPLUS ORGX WIDTH)
			      PAGEMAPWIDTH)
		then (SETQ WIDTH (IDIFFERENCE PAGEMAPWIDTH ORGX)))
	    (SETQ HEIGHT (IMIN PAGEMAPHEIGHT (CADDDR TWINDOW)))
	    (if (GREATERP (IPLUS ORGY HEIGHT)
			      PAGEMAPHEIGHT)
		then (SETQ HEIGHT (IDIFFERENCE PAGEMAPHEIGHT ORGY)))
	    (SETQ X1 (FIX (QUOTIENT ORGX 5.0)))
	    (SETQ Y1 (FIX (QUOTIENT (IDIFFERENCE PAGEMAPHEIGHT (IPLUS ORGY HEIGHT))
					  5.0)))
	    (SETQ X2 (FIX (QUOTIENT (IPLUS ORGX WIDTH)
					  5.0)))
	    (SETQ Y2 (FIX (QUOTIENT (IDIFFERENCE PAGEMAPHEIGHT ORGY)
					  5.0)))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X11))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES X1 .125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y11))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES Y1 .125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X21))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES X2 .125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y21))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES Y2 .125))
	    (if (EQ (QUOTE HALFTONE)
			(LISTGET (FM.READSTATE MT.CONTROL.MENUWINDOW)
				   (QUOTE BACKGROUND)))
		then (SETQ MT.TEXTW1 (LIST X1 Y1 X2 Y2))
		       (SETQ MT.TEXTW1BOX (LIST ORGX (IPLUS ORGY 20)
						    WIDTH HEIGHT))
	      else (SETQ MT.HALFTONEW1 (LIST X1 Y1 X2 Y2))
		     (SETQ MT.HALFTONEW1BOX (LIST ORGX (IPLUS ORGY 20)
						      WIDTH HEIGHT)))
	    (MT.UPDATE.HTWINDOWS])

(MT.GETWINDOW2
  [LAMBDA NIL                                                (* rdc "30-Jul-86 18:17")
    (PROG (WINDOWLOC TWINDOW PAGEMAPWIDTH PAGEMAPHEIGHT ORGX ORGY WIDTH HEIGHT)
	    (TOTOPW MTDISPLAYWINDOW)
	    (SETQ WINDOWLOC (WINDOWPROP MTDISPLAYWINDOW (QUOTE REGION)))
	    (SETQ TWINDOW (SETQ WINDOW (GETREGION)))
	    [SETQ PAGEMAPWIDTH (IDIFFERENCE (WINDOWPROP MTDISPLAYWINDOW (QUOTE WIDTH))
						(ITIMES 2 (WINDOWPROP MTDISPLAYWINDOW
									  (QUOTE BORDER]
	    [SETQ PAGEMAPHEIGHT (IDIFFERENCE [IDIFFERENCE (WINDOWPROP MTDISPLAYWINDOW
									      (QUOTE HEIGHT))
								(ITIMES 2 (WINDOWPROP
									    MTDISPLAYWINDOW
									    (QUOTE BORDER]
						 (FONTPROP WindowTitleDisplayStream (QUOTE HEIGHT]
	    [SETQ ORGX (IMAX 0 (IMIN PAGEMAPWIDTH (IDIFFERENCE (IMAX 0 (IDIFFERENCE
										 (CAR TWINDOW)
										 (CAR WINDOWLOC)))
								       (WINDOWPROP MTDISPLAYWINDOW
										     (QUOTE BORDER]
	    [SETQ ORGY (IMAX 0 (IMIN PAGEMAPHEIGHT (IDIFFERENCE (IMAX 0
										(IDIFFERENCE
										  (CADR TWINDOW)
										  (CADR WINDOWLOC)))
									25]
	    (SETQ WIDTH (IMIN PAGEMAPWIDTH (CADDR TWINDOW)))
	    (if (GREATERP (IPLUS ORGX WIDTH)
			      PAGEMAPWIDTH)
		then (SETQ WIDTH (IDIFFERENCE PAGEMAPWIDTH ORGX)))
	    (SETQ HEIGHT (IMIN PAGEMAPHEIGHT (CADDDR TWINDOW)))
	    (if (GREATERP (IPLUS ORGY HEIGHT)
			      PAGEMAPHEIGHT)
		then (SETQ HEIGHT (IDIFFERENCE PAGEMAPHEIGHT ORGY)))
	    (SETQ X1 (FIX (QUOTIENT ORGX 5.0)))
	    (SETQ Y1 (FIX (QUOTIENT (IDIFFERENCE PAGEMAPHEIGHT (IPLUS ORGY HEIGHT))
					  5.0)))
	    (SETQ X2 (FIX (QUOTIENT (IPLUS ORGX WIDTH)
					  5.0)))
	    (SETQ Y2 (FIX (QUOTIENT (IDIFFERENCE PAGEMAPHEIGHT ORGY)
					  5.0)))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X12))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES X1 .125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y12))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES Y1 .125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X22))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES X2 .125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y22))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES Y2 .125))
	    (if (EQ (QUOTE HALFTONE)
			(LISTGET (FM.READSTATE MT.CONTROL.MENUWINDOW)
				   (QUOTE BACKGROUND)))
		then (SETQ MT.TEXTW2 (LIST X1 Y1 X2 Y2))
		       (SETQ MT.TEXTW2BOX (LIST ORGX (IPLUS ORGY 20)
						    WIDTH HEIGHT))
	      else (SETQ MT.HALFTONEW2 (LIST X1 Y1 X2 Y2))
		     (SETQ MT.HALFTONEW2BOX (LIST ORGX (IPLUS ORGY 20)
						      WIDTH HEIGHT)))
	    (MT.UPDATE.HTWINDOWS])

(MT.GETWINDOW3
  [LAMBDA NIL                                                (* rdc "30-Jul-86 18:24")
    (PROG (WINDOWLOC TWINDOW PAGEMAPWIDTH PAGEMAPHEIGHT ORGX ORGY WIDTH HEIGHT)
	    (TOTOPW MTDISPLAYWINDOW)
	    (SETQ WINDOWLOC (WINDOWPROP MTDISPLAYWINDOW (QUOTE REGION)))
	    (SETQ TWINDOW (SETQ WINDOW (GETREGION)))
	    [SETQ PAGEMAPWIDTH (IDIFFERENCE (WINDOWPROP MTDISPLAYWINDOW (QUOTE WIDTH))
						(ITIMES 2 (WINDOWPROP MTDISPLAYWINDOW
									  (QUOTE BORDER]
	    [SETQ PAGEMAPHEIGHT (IDIFFERENCE [IDIFFERENCE (WINDOWPROP MTDISPLAYWINDOW
									      (QUOTE HEIGHT))
								(ITIMES 2 (WINDOWPROP
									    MTDISPLAYWINDOW
									    (QUOTE BORDER]
						 (FONTPROP WindowTitleDisplayStream (QUOTE HEIGHT]
	    [SETQ ORGX (IMAX 0 (IMIN PAGEMAPWIDTH (IDIFFERENCE (IMAX 0 (IDIFFERENCE
										 (CAR TWINDOW)
										 (CAR WINDOWLOC)))
								       (WINDOWPROP MTDISPLAYWINDOW
										     (QUOTE BORDER]
	    [SETQ ORGY (IMAX 0 (IMIN PAGEMAPHEIGHT (IDIFFERENCE (IMAX 0
										(IDIFFERENCE
										  (CADR TWINDOW)
										  (CADR WINDOWLOC)))
									25]
	    (SETQ WIDTH (IMIN PAGEMAPWIDTH (CADDR TWINDOW)))
	    (if (GREATERP (IPLUS ORGX WIDTH)
			      PAGEMAPWIDTH)
		then (SETQ WIDTH (IDIFFERENCE PAGEMAPWIDTH ORGX)))
	    (SETQ HEIGHT (IMIN PAGEMAPHEIGHT (CADDDR TWINDOW)))
	    (if (GREATERP (IPLUS ORGY HEIGHT)
			      PAGEMAPHEIGHT)
		then (SETQ HEIGHT (IDIFFERENCE PAGEMAPHEIGHT ORGY)))
	    (SETQ X1 (FIX (QUOTIENT ORGX 5.0)))
	    (SETQ Y1 (FIX (QUOTIENT (IDIFFERENCE PAGEMAPHEIGHT (IPLUS ORGY HEIGHT))
					  5.0)))
	    (SETQ X2 (FIX (QUOTIENT (IPLUS ORGX WIDTH)
					  5.0)))
	    (SETQ Y2 (FIX (QUOTIENT (IDIFFERENCE PAGEMAPHEIGHT ORGY)
					  5.0)))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X13))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES X1 .125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y13))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES Y1 .125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X23))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES X2 .125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y23))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES Y2 .125))
	    (if (EQ (QUOTE HALFTONE)
			(LISTGET (FM.READSTATE MT.CONTROL.MENUWINDOW)
				   (QUOTE BACKGROUND)))
		then (SETQ MT.TEXTW3 (LIST X1 Y1 X2 Y2))
		       (SETQ MT.TEXTW3BOX (LIST ORGX (IPLUS ORGY 20)
						    WIDTH HEIGHT))
	      else (SETQ MT.HALFTONEW3 (LIST X1 Y1 X2 Y2))
		     (SETQ MT.HALFTONEW3BOX (LIST ORGX (IPLUS ORGY 20)
						      WIDTH HEIGHT)))
	    (MT.UPDATE.HTWINDOWS])

(MT.GETWINDOW4
  [LAMBDA NIL                                                (* rdc "30-Jul-86 18:24")
    (PROG (WINDOWLOC TWINDOW PAGEMAPWIDTH PAGEMAPHEIGHT ORGX ORGY WIDTH HEIGHT)
	    (TOTOPW MTDISPLAYWINDOW)
	    (SETQ WINDOWLOC (WINDOWPROP MTDISPLAYWINDOW (QUOTE REGION)))
	    (SETQ TWINDOW (SETQ WINDOW (GETREGION)))
	    [SETQ PAGEMAPWIDTH (IDIFFERENCE (WINDOWPROP MTDISPLAYWINDOW (QUOTE WIDTH))
						(ITIMES 2 (WINDOWPROP MTDISPLAYWINDOW
									  (QUOTE BORDER]
	    [SETQ PAGEMAPHEIGHT (IDIFFERENCE [IDIFFERENCE (WINDOWPROP MTDISPLAYWINDOW
									      (QUOTE HEIGHT))
								(ITIMES 2 (WINDOWPROP
									    MTDISPLAYWINDOW
									    (QUOTE BORDER]
						 (FONTPROP WindowTitleDisplayStream (QUOTE HEIGHT]
	    [SETQ ORGX (IMAX 0 (IMIN PAGEMAPWIDTH (IDIFFERENCE (IMAX 0 (IDIFFERENCE
										 (CAR TWINDOW)
										 (CAR WINDOWLOC)))
								       (WINDOWPROP MTDISPLAYWINDOW
										     (QUOTE BORDER]
	    [SETQ ORGY (IMAX 0 (IMIN PAGEMAPHEIGHT (IDIFFERENCE (IMAX 0
										(IDIFFERENCE
										  (CADR TWINDOW)
										  (CADR WINDOWLOC)))
									25]
	    (SETQ WIDTH (IMIN PAGEMAPWIDTH (CADDR TWINDOW)))
	    (if (GREATERP (IPLUS ORGX WIDTH)
			      PAGEMAPWIDTH)
		then (SETQ WIDTH (IDIFFERENCE PAGEMAPWIDTH ORGX)))
	    (SETQ HEIGHT (IMIN PAGEMAPHEIGHT (CADDDR TWINDOW)))
	    (if (GREATERP (IPLUS ORGY HEIGHT)
			      PAGEMAPHEIGHT)
		then (SETQ HEIGHT (IDIFFERENCE PAGEMAPHEIGHT ORGY)))
	    (SETQ X1 (FIX (QUOTIENT ORGX 5.0)))
	    (SETQ Y1 (FIX (QUOTIENT (IDIFFERENCE PAGEMAPHEIGHT (IPLUS ORGY HEIGHT))
					  5.0)))
	    (SETQ X2 (FIX (QUOTIENT (IPLUS ORGX WIDTH)
					  5.0)))
	    (SETQ Y2 (FIX (QUOTIENT (IDIFFERENCE PAGEMAPHEIGHT ORGY)
					  5.0)))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X14))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES X1 .125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y14))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES Y1 .125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE X24))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES X2 .125))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.CONTROL.MENUWINDOW (QUOTE Y24))
			      MT.CONTROL.MENUWINDOW
			      (FTIMES Y2 .125))
	    (if (EQ (QUOTE HALFTONE)
			(LISTGET (FM.READSTATE MT.CONTROL.MENUWINDOW)
				   (QUOTE BACKGROUND)))
		then (SETQ MT.TEXTW4 (LIST X1 Y1 X2 Y2))
		       (SETQ MT.TEXTW4BOX (LIST ORGX (IPLUS ORGY 20)
						    WIDTH HEIGHT))
	      else (SETQ MT.HALFTONEW4 (LIST X1 Y1 X2 Y2))
		     (SETQ MT.HALFTONEW4BOX (LIST ORGX (IPLUS ORGY 20)
						      WIDTH HEIGHT)))
	    (MT.UPDATE.HTWINDOWS])

(MT.UPDATE.HTWINDOWS
  [LAMBDA NIL                                                (* rdc " 6-Aug-86 08:59")
    (PROG ((PARAMETER.LIST (FM.READSTATE MT.CONTROL.MENUWINDOW))
	     (WINDOW (LIST 0 0 0 0)))
	    (CLEARW MTDISPLAYWINDOW)
	    (BITBLT MT.GRID 0 0 MTDISPLAYWINDOW)
	    (DRAWGRAYBOX (CAR MT.FRAME.BOX)
			   (CADR MT.FRAME.BOX)
			   (IPLUS (CAR MT.FRAME.BOX)
				    (CADDR MT.FRAME.BOX))
			   (IPLUS (CADR MT.FRAME.BOX)
				    (CADDDR MT.FRAME.BOX))
			   MTDISPLAYWINDOW)
	    (if (EQ (LISTGET PARAMETER.LIST (QUOTE SW1))
			(QUOTE YES))
		then (if (EQ (LISTGET PARAMETER.LIST (QUOTE BACKGROUND))
				   (QUOTE HALFTONE))
			   then (SETQ WINDOW MT.TEXTW1BOX)
			 else (SETQ WINDOW MT.HALFTONEW1BOX)))
	    (BLTSHADE 2000 MTDISPLAYWINDOW (CAR WINDOW)
			(CADR WINDOW)
			(CADDR WINDOW)
			(CADDDR WINDOW))
	    (if (EQ (LISTGET PARAMETER.LIST (QUOTE SW2))
			(QUOTE YES))
		then (if (EQ (LISTGET PARAMETER.LIST (QUOTE BACKGROUND))
				   (QUOTE HALFTONE))
			   then (SETQ WINDOW MT.TEXTW2BOX)
			 else (SETQ WINDOW MT.HALFTONEW2BOX)))
	    (BLTSHADE GRAYSHADE MTDISPLAYWINDOW (CAR WINDOW)
			(CADR WINDOW)
			(CADDR WINDOW)
			(CADDDR WINDOW))
	    (if (EQ (LISTGET PARAMETER.LIST (QUOTE SW3))
			(QUOTE YES))
		then (if (EQ (LISTGET PARAMETER.LIST (QUOTE BACKGROUND))
				   (QUOTE HALFTONE))
			   then (SETQ WINDOW MT.TEXTW3BOX)
			 else (SETQ WINDOW MT.HALFTONEW3BOX)))
	    (BLTSHADE 45 MTDISPLAYWINDOW (CAR WINDOW)
			(CADR WINDOW)
			(CADDR WINDOW)
			(CADDDR WINDOW))
	    (if (EQ (LISTGET PARAMETER.LIST (QUOTE SW4))
			(QUOTE YES))
		then (if (EQ (LISTGET PARAMETER.LIST (QUOTE BACKGROUND))
				   (QUOTE HALFTONE))
			   then (SETQ WINDOW MT.TEXTW4BOX)
			 else (SETQ WINDOW MT.HALFTONEW4BOX)))
	    (BLTSHADE 50000 MTDISPLAYWINDOW (CAR WINDOW)
			(CADR WINDOW)
			(CADDR WINDOW)
			(CADDDR WINDOW])
)
(* * Command Functions)

(DEFINEQ

(MT.COMMAND.MENU
  [LAMBDA NIL                                                (* rdc "20-Oct-86 15:08")
    (PROG (MENU.DESCRIPTION)
	    [SETQ MENU.DESCRIPTION
	      (BQUOTE ((TYPE MOMENTARY LABEL SCAN LEFT 0 BOTTOM 15 FONT (MODERN 10 BOLD)
			       SELECTEDFN MT.SCAN)
			 (TYPE MOMENTARY LABEL STOP LEFT 70 BOTTOM 15 FONT (MODERN 10 BOLD)
			       SELECTEDFN MT.STOP.SCANNING)
			 (TYPE MOMENTARY LABEL RESET LEFT 140 BOTTOM 15 FONT (MODERN 10 BOLD)
			       SELECTEDFN MT.RESET)
			 (TYPE MOMENTARY LABEL PAGEMAP LEFT 210 BOTTOM 15 FONT (MODERN 10 BOLD)
			       SELECTEDFN MT.PAGEMAP)
			 (TYPE MOMENTARY LABEL QUIT ID QUIT LEFT 290 BOTTOM 15 FONT (MODERN 10 BOLD)
			       SELECTEDFN MT.QUIT)
			 (TYPE TITLE LABEL "Output Filename: " LEFT 0 BOTTOM 0 FONT (MODERN 10 BOLD)
			       SELECTEDFN MT.GET.OUTFILENAME)
			 (TYPE EDIT ID OUTFILENAME LABEL {DSK}<LISPFILES>IMAGE LEFT 105 BOTTOM 0)
			 (WINDOWPROPS TITLE "Microtek Command Menu" BORDER 5]
	    (SETQ MT.COMMAND.MENUWINDOW (FM.MAKEMENU MENU.DESCRIPTION))
	    (OPENW MT.COMMAND.MENUWINDOW])

(MT.GET.OUTFILENAME
  [LAMBDA NIL                                                (* rdc " 6-Jul-86 10:21")
    (FM.EDITITEM (FM.ITEMFROMID MT.COMMAND.MENUWINDOW (QUOTE OUTFILENAME))
		   MT.COMMAND.MENUWINDOW])

(MT.SCAN
  [LAMBDA NIL                                                (* rdc "20-Oct-86 15:06")
    (ADD.PROCESS (QUOTE (MT.START.SCANNING))
		   (QUOTE NAME)
		   (QUOTE MICROTEK.SCANNING])

(MT.START.SCANNING
  [LAMBDA NIL                                                (* rdc " 5-Aug-86 09:41")
    (PROG (COREFILE HDR DATACOUNT (SCANLINECOUNT 0)
		      CHECKSUM NUMBEROFBYTES OUTFILESTREAM CORESTREAM)

          (* * Reset the Scanner)


	    (MT.RESET)

          (* * Setup the Core output file)


	    (SETQ COREFILE (MT.SETUPSCANFILE))

          (* * Send the scan parameters)


	    (if (NOT (MT.SEND.SCAN.PARAMETERS))
		then (MT.PRINT.STATUS "SCANNING PARAMETER NOT VALID")
		       (RETURN NIL)
		       (MT.RESET))

          (* * Send start scanning command)


	    (MT.SENDCOMMAND 1 (LIST (QUOTE S)))
	    (MT.PRINT.STATUS "SCANNING ...")

          (* * Get headerof each scan line)


	AGAIN
	    (SETQ HDR (for I from 1 to 4 collect (BIN MT.INSTREAM)))
	    (if (OR (EQP (CADR HDR)
			       4)
			(EQP (CADR HDR)
			       0))
		then 

          (* * BYTE count are bytes 3 and 4 Need to LLSH 3 and add to 4 to get total byte count)


		       [SETQ DATACOUNT (IPLUS (LLSH (CAR (FNTH HDR 3))
							  8)
						  (CAR (FNTH HDR 4]
		       (SETQ SCANLINECOUNT (IPLUS SCANLINECOUNT 1))
		       (for I from 1 to DATACOUNT do (BOUT COREFILE (BIN MT.INSTREAM)))
		       (SETQ CHECKSUM (BIN MT.INSTREAM))
		       (MT.SENDACK)
		       (GO AGAIN)
	      else (SETQ DATA (BIN MT.INSTREAM))
		     (if (EQP DATA (CHARCODE E))
			 then (while (READP MT.INSTREAM) do (BIN MT.INSTREAM))
				(MT.SENDACK)
				(MT.PRINT.STATUS "SCANNING DONE")
		       elseif (EQP DATA (CHARCODE ?))
			 then (MT.PRINT.ERROR.MSG (BIN MT.INSTREAM))
				(until (NOT (READP MT.INSTREAM)) do (BIN MT.INSTREAM))
				(MT.SENDACK)
				(CLOSEF? COREFILE)
				(RETURN NIL)))
	    (MT.PRINT.STATUS "....COPYING TO FILE....")
	    (SETQ NUMBEROFBYTES (GETFILEPTR COREFILE))
	    (CLOSEF COREFILE)
	    (SETQ OUTFILESTREAM (OPENSTREAM (LISTGET (FM.READSTATE MT.COMMAND.MENUWINDOW)
							   (QUOTE OUTFILENAME))
						(QUOTE OUTPUT)))
	    (SETQ CORESTREAM (OPENSTREAM COREFILE (QUOTE INPUT)))
                                                             (* PRINTOUT HEADER INFORMATION ON FILE -
							     THE NO INDICATES THAT THIS DOES NOT CONTAIN COMPRESSED
							     DATA)
	    (PRINT (QUOTE NO)
		     OUTFILESTREAM)
	    (SETQ REDUCTION (SUBSTRING (LISTGET (FM.READSTATE MT.CONTROL.MENUWINDOW)
						      (QUOTE REDUCTION))
					   1 2))
	    (IF (STREQUAL (SUBSTRING REDUCTION 1 1)
			      " ")
		THEN (SETQ REDUCTION (SUBSTRING REDUCTION 2 2)))
	    (PRINT (MKATOM REDUCTION)
		     OUTFILESTREAM)
	    (PRINT (LISTGET (FM.READSTATE MT.CONTROL.MENUWINDOW)
				(QUOTE GREYLEVEL))
		     OUTFILESTREAM)
	    (PRINT (LISTGET (FM.READSTATE MT.CONTROL.MENUWINDOW)
				(QUOTE CONTRAST))
		     OUTFILESTREAM)
	    (PRINT (LISTGET (FM.READSTATE MT.CONTROL.MENUWINDOW)
				(QUOTE BRIGHTNESS))
		     OUTFILESTREAM)
	    (PRINT SCANLINECOUNT OUTFILESTREAM)
	    (PRINT DATACOUNT OUTFILESTREAM)
	    (COPYBYTES CORESTREAM OUTFILESTREAM NUMBEROFBYTES)
	    (CLOSEF OUTFILESTREAM)
	    (DELFILE (CLOSEF CORESTREAM))
	    (RINGBELLS)
	    (MT.PRINT.STATUS "DONE"])

(MT.SETUPSCANFILE
  [LAMBDA NIL                                                (* rdc " 5-Aug-86 09:41")

          (* * will check to see if the scratch file is in core. If it is it will dirty 500 pages to bring them into real 
	  memory (speedup when writing to them!). If there wasn't a file, it creates it and then dirtys 500 pgs.
	  RETURNS: stream to the file)


    (PROG (RECOG FILE)
	    (MT.PRINT.STATUS "...SETTING UP SCRATCH FILE...")
	    (SETQ RECOG (if (INFILEP (QUOTE {CORE}SCANNER.SCRATCH;1))
			      then (QUOTE OLD)
			    else (QUOTE NEW)))
	    [SETQ FILE (OPENSTREAM (QUOTE {CORE}SCANNER.SCRATCH;1)
				       (QUOTE OUTPUT)
				       RECOG
				       (QUOTE (SEQUENTIAL T]

          (* * now expand the file so you can read and transfer fast)


	    (for I from 0 to 260000 by 512
	       do (SETFILEPTR FILE I)
		    (BOUT FILE 1))

          (* * and reset to the beginning)


	    (SETFILEPTR FILE 0)
	    (MT.PRINT.STATUS "DONE...")
	    (RETURN FILE])

(MT.SEND.SCAN.PARAMETERS
  [LAMBDA NIL                                                (* rdc " 4-Aug-86 11:04")
    (PROG (PARAMETER.LIST (NO.OF.WINDOWS 0)
			    (COORD.LIST NIL))
	    (SETQ PARAMETER.LIST (FM.READSTATE MT.CONTROL.MENUWINDOW))
	    (SETQ PAPERLENGTH (IPLUS 24 (QUOTIENT (FDIFFERENCE MT.PAPERLENGTH 3.0)
							.125)))
	    (SETQ SCANFRAME MT.FRAME)
	    (if (EQ (MKATOM (LISTGET PARAMETER.LIST (QUOTE BACKGROUND)))
			(QUOTE HALFTONE))
		then (SETQ BACKGROUND (QUOTE H))
	      else (SETQ BACKGROUND (QUOTE T)))
	    [if (EQ (LISTGET PARAMETER.LIST (QUOTE SW1))
			(QUOTE YES))
		then (SETQ NO.OF.WINDOWS (IPLUS NO.OF.WINDOWS 1))
		       (SETQ COORD.LIST (APPEND COORD.LIST (if (EQ BACKGROUND (QUOTE H))
								   then MT.TEXTW1
								 else MT.HALFTONEW1]
	    [if (EQ (LISTGET PARAMETER.LIST (QUOTE SW2))
			(QUOTE YES))
		then (SETQ NO.OF.WINDOWS (IPLUS NO.OF.WINDOWS 1))
		       (SETQ COORD.LIST (APPEND COORD.LIST (if (EQ BACKGROUND (QUOTE H))
								   then MT.TEXTW2
								 else MT.HALFTONEW2]
	    [if (EQ (LISTGET PARAMETER.LIST (QUOTE SW3))
			(QUOTE YES))
		then (SETQ NO.OF.WINDOWS (IPLUS NO.OF.WINDOWS 1))
		       (SETQ COORD.LIST (APPEND COORD.LIST (if (EQ BACKGROUND (QUOTE H))
								   then MT.TEXTW3
								 else MT.HALFTONEW3]
	    [if (EQ (LISTGET PARAMETER.LIST (QUOTE SW4))
			(QUOTE YES))
		then (SETQ NO.OF.WINDOWS (IPLUS NO.OF.WINDOWS 1))
		       (SETQ COORD.LIST (APPEND COORD.LIST (if (EQ BACKGROUND (QUOTE H))
								   then MT.TEXTW4
								 else MT.HALFTONEW4]
	    (if (STREQUAL (SUBSTRING (SETQ GREYLEVEL (SUBSTRING (LISTGET PARAMETER.LIST
										     (QUOTE 
											GREYLEVEL))
									  1 2))
					   1 1)
			      " ")
		then (SETQ GREYLEVEL (SUBSTRING GREYLEVEL 2 2)))
	    (SETQ GREYLEVEL (MKATOM GREYLEVEL))
	    (SETQ CONTRAST (IPLUS 7 (IQUOTIENT (MKATOM (LISTGET PARAMETER.LIST
									  (QUOTE CONTRAST)))
						     4)))
	    (SETQ BRIGHTNESS (IPLUS 7 (IQUOTIENT (MKATOM (LISTGET PARAMETER.LIST
									    (QUOTE BRIGHTNESS)))
						       4)))
	    (if (STREQUAL (SUBSTRING (SETQ REDUCTION (SUBSTRING (LISTGET PARAMETER.LIST
										     (QUOTE 
											REDUCTION))
									  1 2))
					   1 1)
			      " ")
		then (SETQ REDUCTION (SUBSTRING REDUCTION 2 2)))
	    (SETQ RESOLUTION
	      (LISTGET (QUOTE (0 16 5 17 10 18 15 19 20 20 25 21 33 22 35 23 40 24 45 25 50 26 55 
				     27 60 28 67 29 70 30 75 31))
			 (MKATOM REDUCTION)))
	    (if [EQ (QUOTE YES)
			(MKATOM (LISTGET PARAMETER.LIST (QUOTE COMPRESSDATA]
		then (SETQ DATACOMPRESSION 1)
	      else (SETQ DATACOMPRESSION 0))
	    (if [AND (MT.SENDCOMMAND 2 (LIST (QUOTE L)
						     PAPERLENGTH))
			 (MT.SENDCOMMAND 5 (APPEND (LIST (QUOTE F))
						       SCANFRAME))
			 [if (GREATERP NO.OF.WINDOWS 0)
			     then (MT.SENDCOMMAND (IPLUS 2 (ITIMES NO.OF.WINDOWS 4))
						      (APPEND (LIST BACKGROUND)
								(LIST NO.OF.WINDOWS)
								COORD.LIST))
			   else (MT.SENDCOMMAND 2 (APPEND (LIST BACKGROUND)
								(LIST 0]
			 (MT.SENDCOMMAND 2 (APPEND (LIST (QUOTE G))
						       (LIST GREYLEVEL)))
			 (MT.SENDCOMMAND 2 (APPEND (LIST (QUOTE K))
						       (LIST CONTRAST)))
			 (MT.SENDCOMMAND 2 (APPEND (LIST (QUOTE B))
						       (LIST BRIGHTNESS)))
			 (MT.SENDCOMMAND 2 (APPEND (LIST (QUOTE R))
						       (LIST RESOLUTION)))
			 (MT.SENDCOMMAND 2 (APPEND (LIST (QUOTE C))
						       (LIST DATACOMPRESSION]
		then (RETURN T)
	      else (RETURN NIL])

(MT.SENDCOMMAND
  [LAMBDA (DATACOUNT DATALIST)                               (* rdc " 6-Jul-86 12:58")
    (PROG (DATA RESPONSE (CHECKSUM 0)
		  (RETRYCOUNT 0))                            (* SEND \ AND 80H)
	RETRY
	    (BOUT MT.OUTSTREAM (CHARCODE "\"))
	    (BOUT MT.OUTSTREAM 128)
	    (BOUT MT.OUTSTREAM 0)
	    (BOUT MT.OUTSTREAM DATACOUNT)
	    (SETQ CHECKSUM (IPLUS CHECKSUM 128 0 DATACOUNT))
	    [for DATA in DATALIST do (if (NUMBERP DATA)
					       then (BOUT MT.OUTSTREAM DATA)
						      (SETQ CHECKSUM (IPLUS CHECKSUM DATA))
					     else (BOUT MT.OUTSTREAM (CAR (CHCON DATA)))
						    (SETQ CHECKSUM (IPLUS CHECKSUM
									      (CAR (CHCON DATA]
	    (FORCEOUTPUT MT.OUTSTREAM)
	    (BOUT MT.OUTSTREAM (IPLUS (LOGXOR 255 CHECKSUM)
					  1))
	    (FORCEOUTPUT MT.OUTSTREAM)
	REREAD
	    (BLOCK 500)
	    (SETQ RESPONSE (until (NOT (READP MT.INSTREAM)) collect (BIN MT.INSTREAM)))
	    (if (NEQ (CAR RESPONSE)
			 6)
		then (SETQ CHECKSUM 0)
		       (SETQ RETRYCOUNT (IPLUS RETRYCOUNT 1))
		       (if (EQ RETRYCOUNT 5)
			   then (RETURN NIL)
			 else (GO RETRY)))
	    (if (GREATERP (LENGTH RESPONSE)
			      2)
		then 

          (* * Compute checksum on all characters after the \)


		       (if [NOT (SETQ RESPONSE (MT.COMPUTECHECKSUM
					(CDR (MEMBER (CHARCODE "\")
							 RESPONSE]
			   then (GO REREAD))
		       (if (EQP (CAR RESPONSE)
				    (CHARCODE ?))
			   then (MT.PRINT.ERROR.MSG (CADR RESPONSE))
				  (RETURN NIL)
			 else (RETURN (PACKC RESPONSE)))
	      else (RETURN T])

(MT.COMPUTECHECKSUM
  [LAMBDA (RESPONSE)                                         (* edited: " 4-Jul-86 14:13")

          (* * Response should be all bytes after the \. Byte 1 = Command type Byte 2 = High part data count Byte 3 = Low 
	  part of data count Last byte = Checksum)


    (PROG (DATACOUNT DATALIST CHECKSUM (SUMCHECK 0))
	    (SETQ DATACOUNT (IPLUS (LLSH (CADR RESPONSE)
					       8)
				       (CADDR RESPONSE)))
	    [SETQ DATALIST (REVERSE (CDR (REVERSE RESPONSE]
	    (SETQ CHECKSUM (CAR (REVERSE RESPONSE)))
	    (for DATA in DATALIST do (SETQ SUMCHECK (IPLUS SUMCHECK DATA)))
	    (if (OR (EQP CHECKSUM (IPLUS (LOGXOR 255 (LRSH (LLSH SUMCHECK 24)
								       24))
						 1))
			(EQ CHECKSUM 0))
		then (MT.SENDACK) 

          (* * Return data minus the response type, hi & low data count and checksum)


		       (RETURN (CDDDR DATALIST))
	      else (MT.SENDNAK)
		     (RETURN NIL])

(MT.PRINT.ERROR.MSG
  [LAMBDA (ERRORCODE)                                        (* rdc " 5-Aug-86 09:39")
    (RINGBELLS)
    (SELECTQ ERRORCODE
	       (1 (MT.PRINT.STATUS "U88 ROM FAILURE"))
	       (2 (MT.PRINT.STATUS "U81 ROM FAILURE"))
	       (3 (MT.PRINT.STATUS "U64 ROM FAILURE"))
	       (4 (MT.PRINT.STATUS "U72 ROM FAILURE"))
	       (6 (MT.PRINT.STATUS "U23 ROM FAILURE"))
	       (7 (MT.PRINT.STATUS "U31 ROM FAILURE"))
	       (8 (MT.PRINT.STATUS "U29 ROM FAILURE"))
	       (9 (MT.PRINT.STATUS "Paper sensor failure"))
	       (16 (MT.PRINT.STATUS "Lamp failure or image sensor circuit failure"))
	       (128 (MT.PRINT.STATUS "Illegal Command"))
	       (129 (MT.PRINT.STATUS "Illegal Gray Scale Setting"))
	       (131 (MT.PRINT.STATUS "Illegal Resolution Setting"))
	       (132 (MT.PRINT.STATUS "Illegal Data Compression Parameter"))
	       (133 (MT.PRINT.STATUS "Illegal Scanning Frame Coordinate"))
	       (134 (MT.PRINT.STATUS "Illegal number of windows"))
	       (135 (MT.PRINT.STATUS "Illegal window coordinate"))
	       (136 (MT.PRINT.STATUS "Illegal Contrast Setting"))
	       (137 (MT.PRINT.STATUS "Illegal Paper Length setting"))
	       (138 (MT.PRINT.STATUS "Record Type error"))
	       (139 (MT.PRINT.STATUS "NAK receiced on 5 consecutive transmissions"))
	       (140 (MT.PRINT.STATUS "Paper jammed or longer than length setting"))
	       (141 (MT.PRINT.STATUS "Illegal Brightness setting"))
	       (T])

(MT.SENDACK
  [LAMBDA NIL                                                (* rdc "22-Jun-86 16:26")
    (BOUT MT.OUTSTREAM 6)
    (FORCEOUTPUT MT.OUTSTREAM])

(MT.SENDNAK
  [LAMBDA NIL                                                (* rdc "22-Jun-86 16:27")
    (BOUT MT.OUTSTREAM 21)
    (FORCEOUTPUT MT.OUTSTREAM])

(MT.STOP.SCANNING
  [LAMBDA NIL                                                (* rdc "28-Jun-86 11:27")
    (PROG NIL
	    (BOUT MT.OUTSTREAM 3)
	    (FORCEOUTPUT MT.OUTSTREAM)
	    (DEL.PROCESS (BQUOTE MICROTEK.SCANNING))
	    (MT.RESET])

(MT.RESET
  [LAMBDA NIL                                                (* rdc "20-Oct-86 15:08")
    [if (AND (EQ \RS232C.READY T)
		 (EQ [CDAR (RS232C.GET.PARAMETERS (QUOTE (BaudRate]
		       MT.BAUDRATE)
		 (EQ [CADAR (RS232C.GET.PARAMETERS (QUOTE (FlowControl]
		       0)
		 (OPENP MT.OUTSTREAM)
		 (OPENP MT.INSTREAM))
	then (MT.SENDCOMMAND 1 (LIST (QUOTE X)))
      else (RS232C.INIT MT.BAUDRATE 8 (QUOTE NONE)
			    1
			    (QUOTE DTR))
	     (CLOSEF? MT.OUTSTREAM)
	     (CLOSEF? MT.INSTREAM)
	     (SETQ MT.OUTSTREAM (OPENSTREAM (QUOTE {RS232})
						(QUOTE OUTPUT)))
	     (SETQ MT.INSTREAM (RS232C.OTHER.STREAM MT.OUTSTREAM))
	     (MT.SENDCOMMAND 1 (LIST (QUOTE X]
    (DELFILE (CLOSEF? (QUOTE {CORE}SCANNER.SCRATCH)))
    (if [SETQ RESPONSE (MT.SENDCOMMAND 1 (LIST (QUOTE !]
	then (CLRPROMPT)
	       (MT.PRINT.STATUS (CONCAT RESPONSE " READY"))
      else (RINGBELLS)
	     (MT.PRINT.STATUS "Microtek Not Responding ...Check scanner and cables"])

(MT.PAGEMAP
  [LAMBDA NIL                                                (* rdc "31-Jul-86 09:19")
    (if (OPENWP MTDISPLAYWINDOW)
	then (CLOSEW MTDISPLAYWINDOW)
      else (OPENW MTDISPLAYWINDOW])

(MT.QUIT
  [LAMBDA NIL                                                (* rdc "20-Oct-86 15:02")
    [SETQ RESPONSE (MENU (create MENU
				       ITEMS ←(QUOTE ("QUIT" "SHUTDOWN RS232 PORT ONLY"))
				       MENUFONT ←(FONTCREATE (QUOTE MODERN)
							       10
							       (QUOTE BOLD]
    (CLOSEF? MT.INSTREAM)
    (CLOSEF? MT.OUTSTREAM)
    (RS232C.SHUTDOWN)
    (if (STREQUAL RESPONSE "QUIT")
	then (DELFILE (CLOSEF? (QUOTE {CORE}SCANNER.SCRATCH)))
	       (CLOSEW MTDISPLAYWINDOW)
	       (CLOSEW MT.CONTROL.MENUWINDOW])
)
(* * Functions to convert and print scanned images)

(DEFINEQ

(MT.DISPLAY.MENU
  [LAMBDA NIL                                                (* rdc "28-Aug-86 10:49")
    (PROG (MENU.DESCRIPTION)
	    [SETQ MENU.DESCRIPTION
	      (BQUOTE ((TYPE TITLE LABEL "Source Filename: " LEFT 0 BOTTOM 35 FONT
			       (MODERN 10 BOLD)
			       SELECTEDFN MT.GET.SOURCEFILENAME)
			 (TYPE EDIT ID SOURCEFILENAME LABEL {DSK}<LISPFILES>IMAGE LEFT 105 BOTTOM 35)
			 (TYPE MOMENTARY LABEL "CREATE BITMAP" LEFT 0 BOTTOM 20 FONT
			       (MODERN 10 BOLD)
			       SELECTEDFN MT.CREATEBM)
			 (TYPE TITLE LABEL "Bitmap Name: " LEFT 90 BOTTOM 20 FONT (MODERN 10 BOLD)
			       SELECTEDFN MT.GET.BITMAPNAME)
			 (TYPE EDIT ID BITMAPNAME LABEL IMAGE LEFT 170 BOTTOM 20)
			 (TYPE TITLE LABEL "Shrinkfactor: " LEFT 0 BOTTOM 5 FONT (MODERN 10 BOLD))
			 (TYPE NCHOOSE LABEL "" LEFT 65 BOTTOM 5 ID BMSHRINKFACTOR ITEMS
			       (10 9 8 7 6 5 4 3 2 1))
			 (TYPE TITLE LABEL "Rotation: " LEFT 100 BOTTOM 5 FONT (MODERN 10 BOLD))
			 (TYPE NCHOOSE LABEL "" LEFT 145 BOTTOM 5 ID ROTATE ITEMS (NONE LEFT RIGHT))
			 (WINDOWPROPS TITLE "Microtek Display Menu" BORDER 5]
	    (SETQ MT.DISPLAY.MENUWINDOW (FM.MAKEMENU MENU.DESCRIPTION))
	    (FM.CHANGESTATE (FM.ITEMFROMID MT.DISPLAY.MENUWINDOW (QUOTE BMSHRINKFACTOR))
			      MT.DISPLAY.MENUWINDOW MT.BMSHRINKFACTOR)
	    (OPENW MT.DISPLAY.MENUWINDOW])

(MT.GET.SOURCEFILENAME
  [LAMBDA NIL                                                (* rdc "21-Jul-86 15:08")
    (FM.EDITITEM (FM.ITEMFROMID MT.DISPLAY.MENUWINDOW (QUOTE SOURCEFILENAME))
		   MT.DISPLAY.MENUWINDOW])

(MT.GET.BITMAPNAME
  [LAMBDA NIL                                                (* rdc "21-Jul-86 15:08")
    (FM.EDITITEM (FM.ITEMFROMID MT.DISPLAY.MENUWINDOW (QUOTE BITMAPNAME))
		   MT.DISPLAY.MENUWINDOW])

(MT.CREATEBM
  [LAMBDA NIL                                                (* rdc "28-Aug-86 14:00")
    (MT.BITMAPCREATE (LISTGET (FM.READSTATE MT.DISPLAY.MENUWINDOW)
				  (QUOTE BITMAPNAME))
		       (LISTGET (FM.READSTATE MT.DISPLAY.MENUWINDOW)
				  (QUOTE SOURCEFILENAME))
		       (MKATOM (LISTGET (FM.READSTATE MT.DISPLAY.MENUWINDOW)
					    (QUOTE BMSHRINKFACTOR)))
		       (LISTGET (FM.READSTATE MT.DISPLAY.MENUWINDOW)
				  (QUOTE ROTATE])

(MT.BITMAPCREATE
  [LAMBDA (BITMAPNAME INFILENAME BMSHRINKFACTOR ROTATION)    (* rdc "28-Aug-86 13:59")
                                                             (* "edited by: MonkeyBoy: " " 9-Apr-86 14:17")
    (PROG* (SCANFILE SCANTYPE BYTESPERSCANLINE SCANDENSITY)
           (SETQ FINISHEDBM (MKATOM BITMAPNAME))
           (if (AND INFILENAME FINISHEDBM)
	       then (SETQ SCANFILE (OPENSTREAM INFILENAME (QUOTE INPUT)))
		      (SETQ COMPRESSION (READ SCANFILE))
		      (SETQ RESOLUTION (READ SCANFILE))
		      (SETQ GREYLEVEL (READ SCANFILE))
		      (SETQ CONTRAST (READ SCANFILE))
		      (SETQ BRIGHTNESS (READ SCANFILE))
		      (SETQ SCANLINES (READ SCANFILE))
		      (SETQ BYTESPERSCANLINE (READ SCANFILE)) 

          (* * To Pick up trailing CR)


		      (BIN SCANFILE)
		      (if (EQ COMPRESSION (QUOTE NO))
			  then (SET FINISHEDBM (MT.CONVERTIMAGETOBM SCANFILE SCANLINES 
									  BYTESPERSCANLINE FINISHEDBM 
									  BMSHRINKFACTOR ROTATION))
				 (PUTPROP (MKATOM BITMAPNAME)
					    (QUOTE RESOLUTION)
					    RESOLUTION)
			else (MT.PRINT.STATUS "NOT YET IMPLEMENTED")
			       (CLOSEF? SCANFILE))
	     else (MT.PRINT.STATUS "ERROR IN BITMAP OR SCANFILE NAME")
		    (CLOSEF? SCANFILE))
           (RETURN FINISHEDBM])

(MT.CONVERTIMAGETOBM
  [LAMBDA (BFILE SCANLINES BYTESPERSCANLINE BMAPNAME SCANNERSHRINKFACTOR ROTATION)
                                                             (* rdc "28-Aug-86 16:20")
                                                             (* "edited by: MonkeyBoy: " " 9-Apr-86 15:17")

          (* * Returns a bitmap that is shrunken (by factor) image of the data. Creates a temporary bitmap that is exact 
	  width but only 200 lines max long. That is shrunken then blt'ed into the final bitmap)


    (PROG (FINALBM FINALBMLINES CLINE BMPTR CBYTE SHRINKHEIGHTFACTOR SHRINKWIDTHFACTOR)
	    (SETQ OFFSET 0)
	    (SETQ BITWIDTH (ITIMES BYTESPERSCANLINE 8))
	    (SETQ LINEOFFSET (if (ODDP BYTESPERSCANLINE)
				   then (IPLUS BYTESPERSCANLINE 1)
				 else BYTESPERSCANLINE))
	    (SETQ TEMPBM (BITMAPCREATE BITWIDTH 200))
	    (SETQ FINALBMOFFSET -1)
	    [SETQ FINALBMWNAME (MKATOM (CONCAT BMAPNAME (QUOTE WINDOW]
	    (SETQ FINALBMOFFSETFACTOR (QUOTIENT 200 SCANNERSHRINKFACTOR))
	    (MT.PRINT.STATUS "SETTING UP BITMAP...")

          (* * Set up the bmap parameters)


	    (SETQ SHRINKHEIGHTFACTOR SCANNERSHRINKFACTOR)
	    (SETQ SHRINKWIDTHFACTOR SCANNERSHRINKFACTOR)

          (* * Set number of lines in final bitmap)


	    (SETQ FINALBMLINES (IPLUS (IQUOTIENT SCANLINES SHRINKHEIGHTFACTOR)
					  1))

          (* * create the final bitmap FACTOR width and FACTOR high)


	    (SETQ FINALBM (if (GEQ (ITIMES BITWIDTH SCANLINES)
					 2000000)
				then (MT.CREATE.BIG.BM BITWIDTH SCANLINES)
			      else (BITMAPCREATE (QUOTIENT (ITIMES BYTESPERSCANLINE 8)
								 SHRINKWIDTHFACTOR)
						     FINALBMLINES)))

          (* * make a window that you can bitblt the image to while you are working...)



          (* * now start doing the serious work)


	    (MT.PRINT.STATUS "WORKING...")
	    (SETQ BMPTR (fetch BITMAPBASE of TEMPBM))
	    (for Y from 0 to (SUB1 SCANLINES)
	       do (if (EQ OFFSET 200)
			then                               (* We've done 200 lines, so now lets move it and reset
							     the offset pointers!)
			       (MT.PRINT.STATUS "BLT'ING A CHUNK...") 

          (* * first reset everything)


			       (SETQ BMPTR (fetch BITMAPBASE of TEMPBM))
			       (SETQ OFFSET 0) 

          (* * set the new offset into the final bitmap DONT forget we are working top down in BMAP)


			       (SETQ FINALBMOFFSET (IPLUS FINALBMOFFSET FINALBMOFFSETFACTOR)) 

          (* * BITBLT the shrunken bitmap (by SHRINKHEIGHTFACTOR) to the final bitmap and then the finalbitmap to the display
	  window)


			       (BITBLT (SHRINKBITMAP TEMPBM SHRINKWIDTHFACTOR SHRINKHEIGHTFACTOR)
					 0 0 FINALBM 0 (IDIFFERENCE FINALBMLINES FINALBMOFFSET))
			       (MT.PRINT.STATUS "DONE...WORKING..."))
		    (SETQ CLINE (ITIMES OFFSET LINEOFFSET))
		    (for X from 0 to (IDIFFERENCE BYTESPERSCANLINE 1)
		       do (\PUTBASEBYTE BMPTR (PLUS X CLINE)
					    (BIN BFILE)))
		    (SETQ OFFSET (ADD1 OFFSET)))

          (* * Now do the final shrink and blt)


	    (MT.PRINT.STATUS " BLT'ING FINAL CHUNK...")
	    (SETQ OFFSET (IPLUS (IMOD OFFSET SHRINKHEIGHTFACTOR)
				    (QUOTIENT OFFSET SHRINKHEIGHTFACTOR)))
	    (SETQ FINALBMOFFSET (IPLUS FINALBMOFFSET OFFSET))
	    (BITBLT (SHRINKBITMAP TEMPBM SHRINKWIDTHFACTOR SHRINKHEIGHTFACTOR)
		      0
		      (IDIFFERENCE FINALBMOFFSETFACTOR OFFSET)
		      FINALBM 0 (IDIFFERENCE FINALBMLINES FINALBMOFFSET))
	    (MT.CREATE.DISPLAYWINDOW (if (EQ ROTATION (QUOTE LEFT))
					   then (MT.PRINT.STATUS 
								"..ROTATING BITMAP...PLEASE WAIT")
						  (SETQ FINALBM (ROTATE.BITMAP.LEFT FINALBM))
					 elseif (EQ ROTATION (QUOTE RIGHT))
					   then (MT.PRINT.STATUS 
								"..ROTATING BITMAP...PLEASE WAIT")
						  (SETQ FINALBM (ROTATE.BITMAP.RIGHT FINALBM))
					 else FINALBM))
	    (MT.PRINT.STATUS "DONE")
	    (CLOSEF BFILE)
	    (CLRPROMPT)
	    (RETURN FINALBM])

(MT.CREATE.BIG.BM
  [LAMBDA (WIDTH HEIGHT)                                     (* was: "14-Jul-86 15:55")
    (LET* ((RASTERWIDTH (IQUOTIENT (IPLUS WIDTH (IDIFFERENCE 16 (IMOD WIDTH 16)))
				     16))
	   (TOTALBYTES (ITIMES HEIGHT (ITIMES RASTERWIDTH 2)))
	   [NPAGES (COND
		     ((ZEROP (IMOD TOTALBYTES 512))
		       (IQUOTIENT TOTALBYTES 512))
		     (T (ADD1 (IQUOTIENT TOTALBYTES 512]
	   (BMPTR (\ALLOCPAGEBLOCK NPAGES))
	   (REALLYBIGBM (create BITMAP
				  BITMAPBASE ← BMPTR
				  BITMAPRASTERWIDTH ← RASTERWIDTH
				  BITMAPHEIGHT ← HEIGHT
				  BITMAPWIDTH ← WIDTH
				  BITMAPBITSPERPIXEL ← 1)))
          (BLTSHADE WHITESHADE REALLYBIGBM)
      REALLYBIGBM])

(MT.CREATE.DISPLAYWINDOW
  [LAMBDA (BITMAP)                                           (* rdc " 5-Aug-86 09:54")
    (PROG (WINDOW)
	    (RINGBELLS)
	    (MT.PRINT.STATUS "SWEEP OUT WINDOW FOR BITMAP")
	    [SETQ WINDOW (CREATEW NIL (LISTGET (FM.READSTATE MT.DISPLAY.MENUWINDOW)
						     (QUOTE BITMAPNAME]
	    (WINDOWPROP WINDOW (QUOTE SRCBM)
			  BITMAP)
	    (WINDOWPROP WINDOW (QUOTE REPAINTFN)
			  (FUNCTION MT.REPAINTWINDOW))
	    (WINDOWPROP WINDOW (QUOTE RESHAPEFN)
			  (FUNCTION MT.RESHAPEWINDOW))
	    (WINDOWPROP WINDOW (QUOTE SCROLLFN)
			  (FUNCTION SCROLLBYREPAINTFN))
	    (MT.RESHAPEWINDOW WINDOW)
	    (RETURN WINDOW])

(MT.REPAINTWINDOW
  [LAMBDA (WINDOW REGION)                                    (* rdc "11-Jul-86 14:41")
    (MOVETO (WINDOWPROP WINDOW (QUOTE BMORIGX))
	      (WINDOWPROP WINDOW (QUOTE BMORIGY))
	      WINDOW)
    (BITBLT (WINDOWPROP WINDOW (QUOTE SRCBM))
	      0 0 WINDOW])

(MT.RESHAPEWINDOW
  [LAMBDA (WINDOW)                                           (* rdc "11-Jul-86 14:18")
    (PROG NIL
	    (DSPRESET WINDOW)
	    (WINDOWPROP WINDOW (QUOTE BMORIGX)
			  (DSPXPOSITION NIL WINDOW))
	    (WINDOWPROP WINDOW (QUOTE BMORIGY)
			  (DSPYPOSITION NIL WINDOW))
	    (MT.REPAINTWINDOW WINDOW)
	    (WINDOWPROP WINDOW (QUOTE EXTENT)
			  (CREATEREGION 0 0 (BITMAPWIDTH (WINDOWPROP WINDOW (QUOTE SRCBM)))
					  (BITMAPHEIGHT (WINDOWPROP WINDOW (QUOTE SRCBM])
)

(ADDTOVAR BackgroundMenuCommands ("MicrotekScanner" (MT.INIT)
						      
"Open Microtek Scanner Command and Display windows, initilalize RS232 port and verifies Microtek Scanner is ready"
						      ))

(RPAQQ BackgroundMenu NIL)

(RPAQ MT.ICON (READBITMAP))
(50 50
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@OOOOOH@@@@@@@"
"@@@H@@@@H@@@@@@@"
"@@@H@@@@H@@@@@@@"
"@@@H@@@@OOOOL@@@"
"@@AH@@@@H@@@L@@@"
"@@BH@@@@H@@AD@@@"
"@@DH@@@@H@@BD@@@"
"@@HH@@@@H@@DD@@@"
"@A@H@@@@H@@HD@@@"
"@B@H@@@@H@A@D@@@"
"@DCH@@@@N@B@D@@@"
"@HCOOOOON@D@D@@@"
"A@@@@@@@@@H@D@@@"
"B@@@@@@@@A@@D@@@"
"GOOOOOOOON@@H@@@"
"D@@@@@@@@B@A@@@@"
"D@@@@@@@@B@B@@@@"
"D@@@@@@@@B@D@@@@"
"DOOOOOOOOB@H@@@@"
"DH@@@@@@ABA@@@@@"
"DH@@@@@@ABB@@@@@"
"DH@@@@@@ABD@@@@@"
"DH@@@@@@ABH@@@@@"
"DH@@@@@@AC@@@@@@"
"GOOOOOOOON@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@")

(RPAQ MT.ICON.MASK (READBITMAP))
(50 50
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@OOOOOH@@@@@@@"
"@@@OOOOOH@@@@@@@"
"@@@OOOOOH@@@@@@@"
"@@@OOOOOOOOOL@@@"
"@@AOOOOOOOOOL@@@"
"@@COOOOOOOOOL@@@"
"@@GOOOOOOOOOL@@@"
"@@OOOOOOOOOOL@@@"
"@AOOOOOOOOOOL@@@"
"@COOOOOOOOOOL@@@"
"@GOOOOOOOOOOL@@@"
"@OOOOOOOOOOOL@@@"
"AOOOOOOOOOOOL@@@"
"COOOOOOOOOOOL@@@"
"GOOOOOOOOOOOH@@@"
"GOOOOOOOOOOO@@@@"
"GOOOOOOOOOON@@@@"
"GOOOOOOOOOOL@@@@"
"GOOOOOOOOOOH@@@@"
"GOOOOOOOOOO@@@@@"
"GOOOOOOOOON@@@@@"
"GOOOOOOOOOL@@@@@"
"GOOOOOOOOOH@@@@@"
"GOOOOOOOOO@@@@@@"
"GOOOOOOOON@@@@@@"
"@@@@@@@@@@@@@@@@"
"@@@@@@@@@@@@@@@@")

(RPAQ BRIGHTBAR (READBITMAP))
(128 10
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"
"H@@@@@@@@@@@@@@@H@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@AD@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@CF@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@GG@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@OGH@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@GG@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@CF@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@AD@@@@@@@@@@@@@@A"
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO")

(RPAQ CONTRASTBAR (READBITMAP))
(128 10
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"
"H@@@@@@@@@@@@@@@H@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@AD@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@CF@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@GG@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@OGH@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@GG@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@CF@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@AD@@@@@@@@@@@@@@A"
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO")

(RPAQ INITIALBRIGHTBAR (READBITMAP))
(128 10
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"
"H@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@@H@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@@H@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@@H@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@@H@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@@H@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@@H@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@@H@@@@@@@@@@@@@@A"
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO")

(RPAQ INITIALCONTRASTBAR (READBITMAP))
(128 10
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"
"H@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@@H@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@@H@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@@H@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@@H@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@@H@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@@H@@@@@@@@@@@@@@A"
"H@@@@@@@@@@@@@@@H@@@@@@@@@@@@@@A"
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO")

(RPAQ LEFTARROW (READBITMAP))
(10 10
"@H@@"
"AH@@"
"CH@@"
"GOL@"
"OOL@"
"OOL@"
"GOL@"
"CH@@"
"AH@@"
"@H@@")

(RPAQ MANCURSOR (READBITMAP))
(9 9
"@H@@"
"AL@@"
"CN@@"
"GO@@"
"OOH@"
"GO@@"
"CN@@"
"AL@@"
"@@@@")

(RPAQ RIGHTARROW (READBITMAP))
(10 10
"@D@@"
"@F@@"
"@G@@"
"OOH@"
"OOL@"
"OOL@"
"OOH@"
"@G@@"
"@F@@"
"@D@@")

(RPAQ MT.POINTER (READBITMAP))
(16 16
"L@@@"
"O@@@"
"OL@@"
"OO@@"
"OOL@"
"OOO@"
"OOOL"
"OOOO"
"OOOO"
"OOOL"
"OOO@"
"OOL@"
"OO@@"
"OL@@"
"O@@@"
"L@@@")

(RPAQ? MT.BAUDRATE 19200)

(RPAQ? MT.DISPLAYFRAME (QUOTE YES))

(RPAQ? MT.PAPERLENGTH 4)

(RPAQ? MT.REDUCTION 0)

(RPAQ? MT.CONTRAST 0)

(RPAQ? MT.BRIGHTNESS 0)

(RPAQ? MT.GREYLEVEL 0)

(RPAQ? MT.DATACOMPRESSION (QUOTE NO))

(RPAQ? MT.BACKGROUND (QUOTE HALFTONE))

(RPAQ? MT.WINDOW (QUOTE LINEART))

(RPAQ? MT.FRAME (QUOTE (0 0 40 24)))

(RPAQ? MT.FRAME.BOX (QUOTE (0 460 200 120)))

(RPAQ? MT.TEXTW1 (QUOTE (0 0 0 0)))

(RPAQ? MT.TEXTW2 (QUOTE (0 0 0 0)))

(RPAQ? MT.TEXTW3 (QUOTE (0 0 0 0)))

(RPAQ? MT.TEXTW4 (QUOTE (0 0 0 0)))

(RPAQ? MT.TEXTW1BOX (QUOTE (0 0 0 0)))

(RPAQ? MT.TEXTW2BOX (QUOTE (0 0 0 0)))

(RPAQ? MT.TEXTW3BOX (QUOTE (0 0 0 0)))

(RPAQ? MT.TEXTW4BOX (QUOTE (0 0 0 0)))

(RPAQ? MT.HALFTONEW1 (QUOTE (0 0 0 0)))

(RPAQ? MT.HALFTONEW2 (QUOTE (0 0 0 0)))

(RPAQ? MT.HALFTONEW3 (QUOTE (0 0 0 0)))

(RPAQ? MT.HALFTONEW4 (QUOTE (0 0 0 0)))

(RPAQ? MT.HALFTONEW1BOX (QUOTE (0 0 0 0)))

(RPAQ? MT.HALFTONEW2BOX (QUOTE (0 0 0 0)))

(RPAQ? MT.HALFTONEW3BOX (QUOTE (0 0 0 0)))

(RPAQ? MT.HALFTONEW4BOX (QUOTE (0 0 0 0)))

(RPAQ? MT.OUTSTREAM NIL)

(RPAQ? MT.INSTREAM NIL)

(RPAQ? MT.BMSHRINKFACTOR 1)
(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS MT.STATUSWINDOW MT.GRID MT.PAPERLENGTH MT.REDUCTION MT.BRIGHTNESS MT.CONTRAST 
	    MT.GREYLEVEL MT.DATACOMPRESSION MT.BACKGROUND MT.WINDOW MT.HEIGHTWINDOW MT.FRAME 
	    MT.TEXTW1 MT.TEXTW2 MT.TEXTW3 MT.TEXTW4 MT.HALFTONEW1 MT.HALFTONEW2 MT.HALFTONEW3 
	    MT.HALFTONEW4 MT.OUTSTREAM MT.INSTREAM BRIGHTBAR CONTRASTBAR LEFTARROW MANCURSOR 
	    RIGHTARROW)
)
(PUTPROPS MICROTEK COPYRIGHT ("XEROX Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (3287 44153 (MT.INIT 3297 . 5116) (MT.SHRINKFN 5118 . 5540) (MICROTEKSCANNER 5542 . 7781
) (RULERX 7783 . 8041) (RULEX# 8043 . 8314) (RULERY 8316 . 8756) (RULEY# 8758 . 9029) (MT.GETLENGTH 
9031 . 9773) (MT.CURSOR.IN 9775 . 9938) (MT.CURSOR.OUT 9940 . 10073) (MT.PRINT.STATUS 10075 . 10256) (
MT.CONTROL.MENU 10258 . 17995) (MT.CHANGE.BRIGHTBAR 17997 . 18622) (MT.RAISEBRIGHTNESS 18624 . 19016) 
(MT.LOWERBRIGHTNESS 19018 . 19423) (MT.CHANGE.CONTRASTBAR 19425 . 19980) (MT.RAISECONTRAST 19982 . 
20364) (MT.LOWERCONTRAST 20366 . 20761) (MT.SELECT.BACKGROUND 20763 . 26882) (MT.GETTRANSFRAME 26884
 . 29650) (MT.GETWINDOW1 29652 . 32722) (MT.GETWINDOW2 32724 . 35794) (MT.GETWINDOW3 35796 . 38866) (
MT.GETWINDOW4 38868 . 41938) (MT.UPDATE.HTWINDOWS 41940 . 44151)) (44184 61675 (MT.COMMAND.MENU 44194
 . 45286) (MT.GET.OUTFILENAME 45288 . 45518) (MT.SCAN 45520 . 45738) (MT.START.SCANNING 45740 . 49326)
 (MT.SETUPSCANFILE 49328 . 50438) (MT.SEND.SCAN.PARAMETERS 50440 . 54594) (MT.SENDCOMMAND 54596 . 
56436) (MT.COMPUTECHECKSUM 56438 . 57499) (MT.PRINT.ERROR.MSG 57501 . 59049) (MT.SENDACK 59051 . 59223
) (MT.SENDNAK 59225 . 59398) (MT.STOP.SCANNING 59400 . 59672) (MT.RESET 59674 . 60833) (MT.PAGEMAP 
60835 . 61065) (MT.QUIT 61067 . 61673)) (61734 72222 (MT.DISPLAY.MENU 61744 . 63106) (
MT.GET.SOURCEFILENAME 63108 . 63344) (MT.GET.BITMAPNAME 63346 . 63574) (MT.CREATEBM 63576 . 64091) (
MT.BITMAPCREATE 64093 . 65525) (MT.CONVERTIMAGETOBM 65527 . 69861) (MT.CREATE.BIG.BM 69863 . 70606) (
MT.CREATE.DISPLAYWINDOW 70608 . 71339) (MT.REPAINTWINDOW 71341 . 71657) (MT.RESHAPEWINDOW 71659 . 
72220)))))
STOP