(FILECREATED "24-Aug-85 13:23:34" {ERIS}<LISPCORE>SOURCES>DOVEDISPLAYHACK.;4 4507   

      changes to:  (VARS DOVEDISPLAYHACKCOMS)

      previous date: "23-Jul-85 00:04:28" {ERIS}<LISPCORE>SOURCES>DOVEDISPLAYHACK.;3)


(* Copyright (c) 1985 by XEROX. All rights reserved.)

(PRETTYCOMPRINT DOVEDISPLAYHACKCOMS)

(RPAQQ DOVEDISPLAYHACKCOMS ((FNS \STARTDISPLAY \CreateScreenBitMap)
			    (DECLARE: DONTEVAL@LOAD DOCOPY (P (\LOCKFN (FUNCTION 
								   \DoveDisplay.SetCursorPosition)))))
)
(DEFINEQ

(\STARTDISPLAY
  (LAMBDA NIL                                                (* jwo: "23-Jul-85 00:04")
    (DECLARE (GLOBALVARS SCREENWIDTH SCREENHEIGHT))
    (COND
      ((NEQ \MACHINETYPE \DAYBREAK)
	(SETQ ScreenBitMap (\CreateScreenBitMap SCREENWIDTH SCREENHEIGHT))))
    (UNINTERRUPTABLY
        (SHOWDISPLAY (fetch BITMAPBASE of ScreenBitMap)
		     (fetch BITMAPRASTERWIDTH of ScreenBitMap))
	(CHANGETTYDEVICE (QUOTE LISPDISPLAY))
	(SETQ \DisplayStarted T))
    (COND
      ((AND (NEQ \KEYBOARD.BEFORETYPE \DAYBREAK)
	    (EQ \MACHINETYPE \DAYBREAK))
	(PROG (OLDWINDOWS)
	      (SETQ OLDWINDOWS (COPY (OPENWINDOWS)))
	      (for W in OLDWINDOWS do (PROG ((WREG (fetch (WINDOW REG) of W)))

          (* * This gook is designed to move open windows into reasonable positions on the Daybreak screen, from wherever they
	  were on the LOADUP machine. The LOADUP process needs to be fixed to just leave around functions that initialize the 
	  screen and related things in a machine dependent (intelligent) way.)


					    (MOVEW W (IQUOTIENT (ITIMES 4 (fetch (REGION LEFT)
									     of WREG))
								5)
						   (IQUOTIENT (ITIMES (fetch (REGION BOTTOM)
									 of WREG)
								      3)
							      4))
					    (\CLOSEW1 W)))
	      (SETQ ScreenBitMap (\CreateScreenBitMap (SETQ SCREENWIDTH (\DoveDisplay.ScreenWidth))
						      (SETQ SCREENHEIGHT (\DoveDisplay.ScreenHeight)))
		)
	      (CHANGEBACKGROUND)
	      (for I in OLDWINDOWS do (\OPENW1 I)))))
    (SETQ WHOLESCREEN (SETQ WHOLEDISPLAY
	(create REGION
		LEFT ← 0
		BOTTOM ← 0
		WIDTH ← SCREENWIDTH
		HEIGHT ← SCREENHEIGHT)))))

(\CreateScreenBitMap
  (LAMBDA (WIDTH HEIGHT)                                     (* jwo: "22-Jul-85 23:51")
    (DECLARE (GLOBALVARS \MaxScreenPage))

          (* creates and locks the pages for the display bit map. Returns a BITMAP descriptor for it. Uses the first words of 
	  the segment \DISPLAYREGION.)



          (* * ??? (COND ((OR (NEQ \MACHINETYPE \DAYBREAK) FLG) (FOLDHI (CEIL WIDTH (UNFOLD \DisplayWordAlign BITSPERWORD)) 
	  BITSPERWORD)) (T 52)))


    (PROG ((RASTERWIDTH (IQUOTIENT WIDTH BITSPERWORD))
	   MAXPAGE#)                                         (* the display microcode needs to have the display fall
							     on \DisplayWordAlign word boundaries.)
          (COND
	    ((IGREATERP (SETQ MAXPAGE# (SUB1 (FOLDHI (ITIMES RASTERWIDTH HEIGHT)
						     WORDSPERPAGE)))
			\MaxScreenPage)

          (* new screen size is larger, allocate more pages. All pages are locked. NOERROR is true in \NEWPAGE call in case 
	  pages are already there, e.g. DLBOOT allocated them.)


	      (for I from (ADD1 \MaxScreenPage) to MAXPAGE# do (\NEWPAGE (\ADDBASE \DISPLAYREGION
										   (UNFOLD I 
										     WORDSPERPAGE))
									 T T))
	      (SETQ \MaxScreenPage MAXPAGE#)))
          (RETURN (COND
		    ((BITMAPP ScreenBitMap)                  (* reuse the same BITMAP ptr so that it will stay EQ to
							     the one in user datastructures.)
		      (replace BITMAPBASE of ScreenBitMap with \DISPLAYREGION)
		      (replace BITMAPWIDTH of ScreenBitMap with WIDTH)
		      (replace BITMAPRASTERWIDTH of ScreenBitMap with RASTERWIDTH)
		      (replace BITMAPHEIGHT of ScreenBitMap with HEIGHT)
		      ScreenBitMap)
		    (T (create BITMAP
			       BITMAPBASE ← \DISPLAYREGION
			       BITMAPRASTERWIDTH ← RASTERWIDTH
			       BITMAPWIDTH ← WIDTH
			       BITMAPHEIGHT ← HEIGHT)))))))
)
(DECLARE: DONTEVAL@LOAD DOCOPY 
(\LOCKFN (FUNCTION \DoveDisplay.SetCursorPosition))
)
(PUTPROPS DOVEDISPLAYHACK COPYRIGHT ("XEROX" 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (502 4347 (\STARTDISPLAY 512 . 2342) (\CreateScreenBitMap 2344 . 4345)))))
STOP